• R/O
  • HTTP
  • SSH
  • HTTPS

提交

标签

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Adjustor mod plugin for VS


Commit MetaInfo

修订版bec2800391ac01e3d6733b621e4e1e566042786a (tree)
时间2021-01-09 08:48:12
作者melchior <melchior@user...>
Commitermelchior

Log Message

W.I.P. Chute support 1/3

更改概述

差异

--- a/AdjustorMod/Items/ItemAdjustor.cs
+++ b/AdjustorMod/Items/ItemAdjustor.cs
@@ -27,11 +27,15 @@ namespace AdjustorMod
2727 private const string _meshAngleKey = @"MeshAngle";
2828 private const string _toolMode = @"toolMode";
2929 private const string _sideKey = @"side";
30+
3031 private const string _rotKey = @"rot";//Slabs use this key instead....
3132 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";
3235
3336 private static string _simpleCoatingClass = @"BlockSimpleCoating";//Similar to slabs...
3437
38+
3539 private static string[] _cardinalCodes = new string[]
3640 {
3741 @"north",
@@ -48,10 +52,14 @@ namespace AdjustorMod
4852
4953 private static string[] _axialRotationCodes = new string[]
5054 {
51- //tree logs, and tree log-like things; pillars, axles....;
55+ //tree logs, and tree log-like things; pillars, axles, some chutes....;
5256 @"ud",
5357 @"ns",
54- @"we"
58+ @"we",
59+ @"ud-n",
60+ @"ud-e",
61+ @"ud-s",
62+ @"ud-w"
5563 };
5664
5765 private static string[] _blacklistedClasses = new string[]
@@ -194,7 +202,8 @@ namespace AdjustorMod
194202 var meshSpin = RotatableByAngledMeshEntity(thatBlock, position);
195203
196204 if (meshSpin) {
197- madeAdjustment = MeshRotation(this.CurrentRotationMode(slot), thePlayer, thatBlock, position);
205+ madeAdjustment = true;
206+ MeshRotation(this.CurrentRotationMode(slot), thePlayer, thatBlock, position);
198207 }
199208 else if (this.CurrentRotationMode(slot) == RotationModes.Free) {
200209 madeAdjustment = FreeRotation(blockSel, byEntity, thePlayer, thatBlock, position);
@@ -481,8 +490,8 @@ namespace AdjustorMod
481490 {
482491 string oppositeDirection = string.Empty;
483492
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];
486495 if (axisNormal) {
487496 switch (directionName) {
488497 case @"ud":
@@ -515,15 +524,71 @@ namespace AdjustorMod
515524 }
516525
517526 /// <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?
519575 /// </summary>
520576 /// <returns>If its axial.</returns>
521577 /// <param name="thatBlock">That block.</param>
522578 private static bool IsAxialOriented(Block thatBlock)
523579 {
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;
525586 }
526587
588+ private bool IsChute(Block thatBlock)
589+ {
590+ return thatBlock.Code.BeginsWith(GlobalConstants.DefaultDomain, _chuteCode);
591+ }
527592
528593
529594
@@ -565,8 +630,15 @@ namespace AdjustorMod
565630 }
566631
567632 if (IsAxialOriented(thatBlock)) {
568-
633+
634+ if (IsChute(thatBlock)) {
635+ renamedAsset = ChuteSpecificFlip(thatBlock, blockSel.Face.Axis, rotateHorizontal);
636+ }
637+ else {
569638 renamedAsset = AxialOmniFlip(thatBlock, blockSel.Face.Axis, rotateHorizontal); //Wood logs also special
639+ }
640+
641+
570642 #if DEBUG
571643 Logger.VerboseDebug("{0} Special Axial Case {1}", thatBlock.Code, renamedAsset);
572644 #endif
@@ -645,7 +717,7 @@ namespace AdjustorMod
645717
646718 if (renamedAsset.Equals(thatBlock.Code) == false) {
647719 #if DEBUG
648- Logger.VerboseDebug("{0} Forcing: {1}", thatBlock.Code, renamedAsset);
720+ Logger.VerboseDebug("{0} Renamed: {1}", thatBlock.Code, renamedAsset);
649721 #endif
650722
651723 var rotatedBlock = ServerApi.World.GetBlock(renamedAsset);
@@ -673,7 +745,7 @@ namespace AdjustorMod
673745 /// <param name="thePlayer">The player.</param>
674746 /// <param name="thatBlock">That block.</param>
675747 /// <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)
677749 {//Context: SERVER!
678750
679751 dynamic subjectBE = ServerApi.World.BlockAccessor.GetBlockEntity(position);
@@ -705,8 +777,7 @@ namespace AdjustorMod
705777 #endif
706778
707779 subjectBE.MarkDirty(true);
708-
709- return false;
780+
710781 }
711782
712783 private AssetLocation RenameBlockFace(Block thatBlock, RotationModes rotationMode)