• 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

修订版75ca75c4e259bc1467deb686d287e2fc25ec2d97 (tree)
时间2021-01-28 13:53:21
作者melchior <melchior@user...>
Commitermelchior

Log Message

W.I.P. chute fixes

更改概述

差异

--- a/AdjustorMod/AdjustorMod.csproj
+++ b/AdjustorMod/AdjustorMod.csproj
@@ -65,6 +65,7 @@
6565 <Compile Include="Items\ItemAdjustor.cs" />
6666 <Compile Include="Skills\AdjustorSkills.cs" />
6767 <Compile Include="Skills\RotationModes.cs" />
68+ <Compile Include="Helpers.cs" />
6869 </ItemGroup>
6970 <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
7071 <ItemGroup>
--- a/AdjustorMod/Items/ItemAdjustor.cs
+++ b/AdjustorMod/Items/ItemAdjustor.cs
@@ -33,7 +33,7 @@ namespace AdjustorMod
3333 private const string _axialRotationKey = @"rotation";//Trees and Pillars; ns, we, ud - axial rotation
3434 private const string _verticalCode = @"vertical";
3535
36- private const string _chuteCode = @"chute";//Just for "normal" Chutes...
36+
3737 private const string _chuteTypeStraight = @"straight";
3838 private const string _chuteTypeCross = @"cross";
3939 private const string _chuteTypeTjunction = @"t";
@@ -154,7 +154,7 @@ namespace AdjustorMod
154154 Block thatBlock = byEntity.World.BlockAccessor.GetBlock(position);
155155 var mode = CurrentRotationMode(itemslot);
156156
157- if (RotatableByVariant(thatBlock) || RotatableByBehavior(thatBlock) || RotatableByAngledMeshEntity(thatBlock, position) || IsChute(thatBlock)) {
157+ if (RotatableByVariant(thatBlock) || RotatableByBehavior(thatBlock) || RotatableByAngledMeshEntity(thatBlock, position) || thatBlock.IsChute( )) {
158158 #if DEBUG
159159 Logger.VerboseDebug("[{0}] Looks Rotatable, FromFace: {1}", thatBlock.Code.Path, blockSel.Face.Code);
160160 ClientApi.ShowChatMessage(string.Format("Appears Rotatable: {0}", thatBlock.Code));
@@ -821,10 +821,7 @@ namespace AdjustorMod
821821 return false;
822822 }
823823
824- private bool IsChute(Block thatBlock)
825- {
826- return thatBlock.Code.BeginsWith(GlobalConstants.DefaultDomain, _chuteCode);
827- }
824+
828825
829826
830827
@@ -873,7 +870,7 @@ namespace AdjustorMod
873870 #endif
874871 }
875872
876- if (IsChute(thatBlock)) {
873+ if (thatBlock.IsChute()) {
877874 renamedAsset = ChuteSpecificFlip(thatBlock, blockSel.Face.Axis, rotateHorizontal);
878875 }
879876
@@ -885,6 +882,7 @@ namespace AdjustorMod
885882 var rotatedBlock = ServerApi.World.GetBlock(renamedAsset);
886883 if (rotatedBlock != null) {
887884 ServerApi.World.BlockAccessor.ExchangeBlock(rotatedBlock.BlockId, position);
885+ ServerApi.TryUnborkChute(rotatedBlock, position);
888886 return true;
889887 } else {
890888 Logger.VerboseDebug("{0} CAN'T EXCHANGE {1}", thatBlock.Code, renamedAsset);
@@ -913,7 +911,7 @@ namespace AdjustorMod
913911 #endif
914912 }
915913
916- if (IsChute(thatBlock)) {
914+ if (thatBlock.IsChute( )) {
917915 renamedAsset = ChuteSpecificFlip(thatBlock, blockSel.Face.Axis, rotateHorizontal);
918916 }
919917
@@ -926,6 +924,7 @@ namespace AdjustorMod
926924 var rotatedBlock = ServerApi.World.GetBlock(renamedAsset);
927925 if (rotatedBlock != null) {
928926 ServerApi.World.BlockAccessor.ExchangeBlock(rotatedBlock.BlockId, position);
927+ ServerApi.TryUnborkChute(rotatedBlock, position);
929928 return true;
930929 } else {
931930 Logger.VerboseDebug("{0} CAN'T EXCHANGE {1}", thatBlock.Code, renamedAsset);
@@ -948,7 +947,7 @@ namespace AdjustorMod
948947 private bool FixedRotation(RotationModes rotationMode, BlockSelection blockSel, EntityAgent byEntity, IPlayer thePlayer, Block thatBlock, BlockPos position)
949948 {
950949 AssetLocation renamedAsset;
951- if (IsChute(thatBlock))
950+ if (thatBlock.IsChute( ))
952951 { renamedAsset = ChuteSpecificForce(thatBlock, rotationMode); }
953952 else { renamedAsset = RenameBlockFace(thatBlock, rotationMode); }
954953
@@ -962,6 +961,7 @@ namespace AdjustorMod
962961 var rotatedBlock = ServerApi.World.GetBlock(renamedAsset);
963962 if (rotatedBlock != null) {
964963 ServerApi.World.BlockAccessor.ExchangeBlock(rotatedBlock.BlockId, position);
964+ ServerApi.TryUnborkChute(rotatedBlock, position);
965965 return true;
966966 } else {
967967 Logger.VerboseDebug("{0} CAN'T EXCHANGE {1}", thatBlock.Code, renamedAsset);
--- /dev/null
+++ b/AdjustorMod/Tamperers.cs
@@ -0,0 +1,60 @@
1+using System;
2+
3+using Vintagestory.API.Common;
4+using Vintagestory.API.Config;
5+using Vintagestory.API.MathTools;
6+using Vintagestory.API.Server;
7+using Vintagestory.GameContent;
8+
9+namespace AdjustorMod
10+{
11+ public static class Tamperers
12+ {
13+ private const string _chuteCode = @"chute";//Just for "normal" Chutes...
14+
15+ public static bool TryUnborkChute(this ICoreServerAPI ServerAPI, Block thatBlock, BlockPos position)
16+ {
17+ if (thatBlock.IsChute( )) {
18+ var entity = ServerAPI.World.BlockAccessor.GetBlockEntity(position) as BlockEntityItemFlow;
19+ UnborkChute_ItemFlowStates(entity);
20+ return true;
21+ }
22+ return false;
23+ }
24+
25+ private static void UnborkChute_ItemFlowStates( BlockEntityItemFlow itemFlowEntity)
26+ {
27+ if (itemFlowEntity == null) return;
28+
29+ var theChute = itemFlowEntity.Block as BlockChute;
30+
31+ if (theChute.Attributes != null)
32+ {
33+ if (theChute.Attributes["pullFaces"].Exists) {
34+ string[ ] faces = theChute.Attributes["pullFaces"].AsArray<string>(null);
35+ itemFlowEntity.PullFaces = new BlockFacing[faces.Length];
36+ for (int i = 0; i < faces.Length; i++) itemFlowEntity.PullFaces[i] = BlockFacing.FromCode(faces[i]);
37+ }
38+
39+ if (theChute.Attributes["pushFaces"].Exists) {
40+ string[ ] faces = theChute.Attributes["pushFaces"].AsArray<string>(null);
41+ itemFlowEntity.PushFaces = new BlockFacing[faces.Length];
42+ for (int i = 0; i < faces.Length; i++) itemFlowEntity.PushFaces[i] = BlockFacing.FromCode(faces[i]);
43+ }
44+
45+ if (theChute.Attributes["acceptFromFaces"].Exists) {
46+ string[ ] faces = theChute.Attributes["acceptFromFaces"].AsArray<string>(null);
47+ itemFlowEntity.AcceptFromFaces = new BlockFacing[faces.Length];
48+ for (int i = 0; i < faces.Length; i++) itemFlowEntity.AcceptFromFaces[i] = BlockFacing.FromCode(faces[i]);
49+ }
50+ }
51+
52+ }
53+
54+ public static bool IsChute(this Block thatBlock)
55+ {
56+ return thatBlock.Code.BeginsWith(GlobalConstants.DefaultDomain, _chuteCode);
57+ }
58+ }
59+}
60+