Adjustor mod plugin for VS
修订版 | bec2800391ac01e3d6733b621e4e1e566042786a (tree) |
---|---|
时间 | 2021-01-09 08:48:12 |
作者 | melchior <melchior@user...> |
Commiter | melchior |
W.I.P. Chute support 1/3
@@ -27,11 +27,15 @@ namespace AdjustorMod | ||
27 | 27 | private const string _meshAngleKey = @"MeshAngle"; |
28 | 28 | private const string _toolMode = @"toolMode"; |
29 | 29 | private const string _sideKey = @"side"; |
30 | + | |
30 | 31 | private const string _rotKey = @"rot";//Slabs use this key instead.... |
31 | 32 | private const string _axialRotationKey = @"rotation";//Trees and Pillars; ns, we, ud - axial rotation |
33 | + private const string _chuteCode = @"chute";//Just for Chutes... | |
34 | + private const string _verticalCode = @"vertical"; | |
32 | 35 | |
33 | 36 | private static string _simpleCoatingClass = @"BlockSimpleCoating";//Similar to slabs... |
34 | 37 | |
38 | + | |
35 | 39 | private static string[] _cardinalCodes = new string[] |
36 | 40 | { |
37 | 41 | @"north", |
@@ -48,10 +52,14 @@ namespace AdjustorMod | ||
48 | 52 | |
49 | 53 | private static string[] _axialRotationCodes = new string[] |
50 | 54 | { |
51 | - //tree logs, and tree log-like things; pillars, axles....; | |
55 | + //tree logs, and tree log-like things; pillars, axles, some chutes....; | |
52 | 56 | @"ud", |
53 | 57 | @"ns", |
54 | - @"we" | |
58 | + @"we", | |
59 | + @"ud-n", | |
60 | + @"ud-e", | |
61 | + @"ud-s", | |
62 | + @"ud-w" | |
55 | 63 | }; |
56 | 64 | |
57 | 65 | private static string[] _blacklistedClasses = new string[] |
@@ -194,7 +202,8 @@ namespace AdjustorMod | ||
194 | 202 | var meshSpin = RotatableByAngledMeshEntity(thatBlock, position); |
195 | 203 | |
196 | 204 | if (meshSpin) { |
197 | - madeAdjustment = MeshRotation(this.CurrentRotationMode(slot), thePlayer, thatBlock, position); | |
205 | + madeAdjustment = true; | |
206 | + MeshRotation(this.CurrentRotationMode(slot), thePlayer, thatBlock, position); | |
198 | 207 | } |
199 | 208 | else if (this.CurrentRotationMode(slot) == RotationModes.Free) { |
200 | 209 | madeAdjustment = FreeRotation(blockSel, byEntity, thePlayer, thatBlock, position); |
@@ -481,8 +490,8 @@ namespace AdjustorMod | ||
481 | 490 | { |
482 | 491 | string oppositeDirection = string.Empty; |
483 | 492 | |
484 | - //wood Log by: ns / we - change to opposite | |
485 | - string directionName = thatBlock.Variant[_axialRotationKey]; | |
493 | + //Axial block: ud / ns / we - change to opposite | |
494 | + string directionName = thatBlock.Variant[_axialRotationKey] ?? thatBlock.Variant[_sideKey]; | |
486 | 495 | if (axisNormal) { |
487 | 496 | switch (directionName) { |
488 | 497 | case @"ud": |
@@ -515,15 +524,71 @@ namespace AdjustorMod | ||
515 | 524 | } |
516 | 525 | |
517 | 526 | /// <summary> |
518 | - /// Is this a axial type thing / wood log? | |
527 | + /// Custom Block variant Determinator - as Chutes are...."SPECIAL" | |
528 | + /// </summary> | |
529 | + /// <returns>The specific flip.</returns> | |
530 | + /// <param name="thatBlock">That block.</param> | |
531 | + /// <param name="axis">Axis.</param> | |
532 | + /// <param name="rotateHorizontal">Rotate horizontal.</param> | |
533 | + private AssetLocation ChuteSpecificFlip(Block thatBlock, EnumAxis axis, bool rotateHorizontal) | |
534 | + { | |
535 | + /*Is: ? | |
536 | + { code: "vertical", states: ["up", "down" ] }, | |
537 | + >> NEWS-UD | |
538 | + //////////// Otherwise: | |
539 | + { code: "side", states: ["ns", "we", "ud-n", "ud-e", "ud-s", "ud-w"] } << t | |
540 | + { code: "side", states: ["ns", "we", "ground"] } << cross | |
541 | + { code: "side", states: ["ns", "we", "ud"] } << straight | |
542 | + */ | |
543 | + AssetLocation translatedCode = null; | |
544 | + | |
545 | + if (thatBlock.Variant.ContainsKey(_verticalCode)) | |
546 | + { | |
547 | + string vert = thatBlock.Variant[_verticalCode]; | |
548 | + string side = thatBlock.Variant[_sideKey]; | |
549 | + | |
550 | + switch (axis) { | |
551 | + case EnumAxis.X: | |
552 | + if (side == "east") { translatedCode = thatBlock.CodeWithVariant(_verticalCode, "west"); } | |
553 | + else { translatedCode = thatBlock.CodeWithVariant(_verticalCode, "east"); } | |
554 | + break; | |
555 | + | |
556 | + case EnumAxis.Y: | |
557 | + if (vert == "up") { translatedCode = thatBlock.CodeWithVariant(_verticalCode, "down"); } | |
558 | + else { translatedCode = thatBlock.CodeWithVariant(_verticalCode, "up"); } | |
559 | + break; | |
560 | + | |
561 | + case EnumAxis.Z: | |
562 | + if (side == "north") { translatedCode = thatBlock.CodeWithVariant(_verticalCode, "south"); } | |
563 | + else { translatedCode = thatBlock.CodeWithVariant(_verticalCode, "north"); } | |
564 | + break; | |
565 | + } | |
566 | + | |
567 | + return translatedCode; | |
568 | + } | |
569 | + | |
570 | + return null; | |
571 | + } | |
572 | + | |
573 | + /// <summary> | |
574 | + /// Is this a axial type thing / wood log / chute? | |
519 | 575 | /// </summary> |
520 | 576 | /// <returns>If its axial.</returns> |
521 | 577 | /// <param name="thatBlock">That block.</param> |
522 | 578 | private static bool IsAxialOriented(Block thatBlock) |
523 | 579 | { |
524 | - return thatBlock.Variant.ContainsKey(_axialRotationKey); | |
580 | + if (thatBlock.Variant.ContainsKey(_axialRotationKey)) return true; | |
581 | + | |
582 | + //Axial variants - vary... | |
583 | + if (_axialRotationCodes.Any(arc => arc == thatBlock.Variant[_sideKey])) return true; | |
584 | + | |
585 | + return false; | |
525 | 586 | } |
526 | 587 | |
588 | + private bool IsChute(Block thatBlock) | |
589 | + { | |
590 | + return thatBlock.Code.BeginsWith(GlobalConstants.DefaultDomain, _chuteCode); | |
591 | + } | |
527 | 592 | |
528 | 593 | |
529 | 594 |
@@ -565,8 +630,15 @@ namespace AdjustorMod | ||
565 | 630 | } |
566 | 631 | |
567 | 632 | if (IsAxialOriented(thatBlock)) { |
568 | - | |
633 | + | |
634 | + if (IsChute(thatBlock)) { | |
635 | + renamedAsset = ChuteSpecificFlip(thatBlock, blockSel.Face.Axis, rotateHorizontal); | |
636 | + } | |
637 | + else { | |
569 | 638 | renamedAsset = AxialOmniFlip(thatBlock, blockSel.Face.Axis, rotateHorizontal); //Wood logs also special |
639 | + } | |
640 | + | |
641 | + | |
570 | 642 | #if DEBUG |
571 | 643 | Logger.VerboseDebug("{0} Special Axial Case {1}", thatBlock.Code, renamedAsset); |
572 | 644 | #endif |
@@ -645,7 +717,7 @@ namespace AdjustorMod | ||
645 | 717 | |
646 | 718 | if (renamedAsset.Equals(thatBlock.Code) == false) { |
647 | 719 | #if DEBUG |
648 | - Logger.VerboseDebug("{0} Forcing: {1}", thatBlock.Code, renamedAsset); | |
720 | + Logger.VerboseDebug("{0} Renamed: {1}", thatBlock.Code, renamedAsset); | |
649 | 721 | #endif |
650 | 722 | |
651 | 723 | var rotatedBlock = ServerApi.World.GetBlock(renamedAsset); |
@@ -673,7 +745,7 @@ namespace AdjustorMod | ||
673 | 745 | /// <param name="thePlayer">The player.</param> |
674 | 746 | /// <param name="thatBlock">That block.</param> |
675 | 747 | /// <param name="position">Position.</param> |
676 | - private bool MeshRotation(RotationModes rotationModes, IPlayer thePlayer, Block thatBlock, BlockPos position) | |
748 | + private void MeshRotation(RotationModes rotationModes, IPlayer thePlayer, Block thatBlock, BlockPos position) | |
677 | 749 | {//Context: SERVER! |
678 | 750 | |
679 | 751 | dynamic subjectBE = ServerApi.World.BlockAccessor.GetBlockEntity(position); |
@@ -705,8 +777,7 @@ namespace AdjustorMod | ||
705 | 777 | #endif |
706 | 778 | |
707 | 779 | subjectBE.MarkDirty(true); |
708 | - | |
709 | - return false; | |
780 | + | |
710 | 781 | } |
711 | 782 | |
712 | 783 | private AssetLocation RenameBlockFace(Block thatBlock, RotationModes rotationMode) |