• 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

修訂6340b87b164e47a8226af68f2fa159f998acc8f3 (tree)
時間2021-01-06 12:15:58
作者melchior <melchior@user...>
Commitermelchior

Log Message

Mesh rotation works....mostly

Change Summary

差異

--- a/AdjustorMod/AdjustorMod.csproj
+++ b/AdjustorMod/AdjustorMod.csproj
@@ -7,7 +7,7 @@
77 <OutputType>Library</OutputType>
88 <RootNamespace>AdjustorMod</RootNamespace>
99 <AssemblyName>AdjustorMod</AssemblyName>
10- <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
10+ <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
1111 </PropertyGroup>
1212 <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
1313 <DebugSymbols>true</DebugSymbols>
@@ -56,6 +56,8 @@
5656 <HintPath>VC_libs\cairo-sharp.dll</HintPath>
5757 <Private>False</Private>
5858 </Reference>
59+ <Reference Include="System.Dynamic" />
60+ <Reference Include="Microsoft.CSharp" />
5961 </ItemGroup>
6062 <ItemGroup>
6163 <Compile Include="Properties\AssemblyInfo.cs" />
--- a/AdjustorMod/Items/ItemAdjustor.cs
+++ b/AdjustorMod/Items/ItemAdjustor.cs
@@ -1,20 +1,17 @@
11 using System;
2-
3-using System.Collections;
4-using System.Collections.Generic;
5-using System.Collections.ObjectModel;
62 using System.Linq;
7-using System.Text.RegularExpressions;
3+using System.Text;
4+using System.Dynamic;
5+using System.Runtime;
86
97 using Vintagestory.API.Common;
10-using Vintagestory.API.Datastructures;
118 using Vintagestory.API.MathTools;
129 using Vintagestory.API.Config;
1310 using Vintagestory.API.Server;
1411 using Vintagestory.API.Client;
1512
16-using Cairo;
17-using System.Text;
13+using Vintagestory.GameContent;
14+
1815
1916 //using Vintagestory.ServerMods;
2017
@@ -27,6 +24,7 @@ namespace AdjustorMod
2724 private ILogger Logger { get; set; }
2825 private ICoreClientAPI ClientApi { get; set; }
2926
27+ private const string _meshAngleKey = @"MeshAngle";
3028 private const string _toolMode = @"toolMode";
3129 private const string _sideKey = @"side";
3230 private const string _rotKey = @"rot";//Slabs use this key instead....
@@ -69,9 +67,10 @@ namespace AdjustorMod
6967
7068 private static string[] _blacklistedEntityClasses = new string[]
7169 {
72- @"GenericTypedContainer",
70+ //@"GenericTypedContainer",
7371 };
7472
73+
7574 private static string[] _verticalVariantKeys = new string[]
7675 {
7776 "verticalorientation",
@@ -108,7 +107,9 @@ namespace AdjustorMod
108107 this.ClientApi = ( ICoreClientAPI )api;
109108 this.Logger = this.ClientApi.World.Logger;
110109 }
111- Logger.VerboseDebug("ItemAdjustor ~ OnLoaded");
110+ #if DEBUG
111+ Logger.VerboseDebug("{0} >> ItemAdjustor ~ OnLoaded", this.Code);
112+ #endif
112113 }
113114
114115 public override bool OnHeldInteractCancel(float secondsUsed, ItemSlot slot, EntityAgent byEntity, BlockSelection blockSel, EntitySelection entitySel, EnumItemUseCancelReason cancelReason)
@@ -138,7 +139,7 @@ namespace AdjustorMod
138139 BlockPos position = blockSel.Position;
139140 Block thatBlock = byEntity.World.BlockAccessor.GetBlock(position);
140141
141- if (RotatableByVariant(thatBlock) || RotatableByBehavior(thatBlock)) {
142+ if (RotatableByVariant(thatBlock) || RotatableByBehavior(thatBlock) || RotatableByAngledMeshEntity(thatBlock, position)) {
142143 #if DEBUG
143144 Logger.VerboseDebug("[{0}] Looks Rotatable, FromFace: {1}", thatBlock.Code.Path, blockSel.Face.Code);
144145 ClientApi.ShowChatMessage(string.Format("Appears Rotatable: {0}", thatBlock.Code));
@@ -176,7 +177,6 @@ namespace AdjustorMod
176177 Block thatBlock = byEntity.World.BlockAccessor.GetBlock(position);
177178 IPlayer thePlayer = null;
178179
179-
180180 if (byEntity is EntityPlayer) {
181181 thePlayer = ServerApi.World.PlayerByUid((( EntityPlayer )byEntity).PlayerUID);
182182 }
@@ -191,11 +191,16 @@ namespace AdjustorMod
191191 ServerApi.SendMessage(thePlayer, GlobalConstants.CurrentChatGroup, string.Format("Not permitted, {0}", why), EnumChatType.Notification);
192192 return false;
193193 }
194+ var meshSpin = RotatableByAngledMeshEntity(thatBlock, position);
194195
195- if (this.CurrentRotationMode(slot) == RotationModes.Free) {
196- madeAdjustment = FreeRotation(blockSel, byEntity, thePlayer, thatBlock, position);
197- } else {
198- madeAdjustment = FixedRotation(this.CurrentRotationMode(slot),blockSel, byEntity, thePlayer, thatBlock, position);
196+ if (meshSpin) {
197+ madeAdjustment = MeshRotation(this.CurrentRotationMode(slot), thePlayer, thatBlock, position);
198+ }
199+ else if (this.CurrentRotationMode(slot) == RotationModes.Free) {
200+ madeAdjustment = FreeRotation(blockSel, byEntity, thePlayer, thatBlock, position);
201+ }
202+ else {
203+ madeAdjustment = FixedRotation(this.CurrentRotationMode(slot), blockSel, byEntity, thePlayer, thatBlock, position);
199204 }
200205
201206 if (madeAdjustment) DamageItem(ServerApi.World, byEntity, slot);
@@ -354,6 +359,22 @@ namespace AdjustorMod
354359 return false;
355360 }
356361
362+ private bool RotatableByAngledMeshEntity(Block thatBlock, BlockPos pos)
363+ {
364+ //Coulda: (IAngledMeshBlockEnt >>> public virtual float MeshAngle ) ---but Nooooo....
365+ //Annnd the 1st thing is to try for the BlockEntity...
366+ var mabeyBE = Api.World.BlockAccessor.GetBlockEntity(pos.Copy( ));
367+ if (mabeyBE != null)
368+ {
369+ var someType = mabeyBE.GetType( );
370+ if (someType.GetProperty(_meshAngleKey) != null) return true;
371+ if (someType.GetField(_meshAngleKey) != null) return true;
372+ }
373+
374+
375+ return false;
376+ }
377+
357378 /// <summary>
358379 /// Determines if slab, sheet, plate type block in a N/E/W/S configuration
359380 /// </summary>
@@ -637,6 +658,30 @@ namespace AdjustorMod
637658 return false;
638659 }
639660
661+ /// <summary>
662+ /// rotation by/to MESH - not block!
663+ /// </summary>
664+ /// <returns>The rotation.</returns>
665+ /// <param name="rotationModes">Rotation modes.</param>
666+ /// <param name="thePlayer">The player.</param>
667+ /// <param name="thatBlock">That block.</param>
668+ /// <param name="position">Position.</param>
669+ private bool MeshRotation(RotationModes rotationModes, IPlayer thePlayer, Block thatBlock, BlockPos position)
670+ {//Context: SERVER!
671+ bool rotateClockwise = rotationModes != RotationModes.West;
672+
673+ dynamic subjectBE = ServerApi.World.BlockAccessor.GetBlockEntity(position);
674+
675+ if (rotateClockwise)
676+ { subjectBE.MeshAngle += 45; }
677+ else
678+ { subjectBE.MeshAngle -= 45; }
679+
680+ subjectBE.MarkDirty(true);
681+
682+ return false;
683+ }
684+
640685 private AssetLocation RenameBlockFace(Block thatBlock, RotationModes rotationMode)
641686 {
642687 string renamedLocationPath = null;
--- a/AdjustorMod/assets/Adjustor/recipes/smithing/adjustor.json
+++ b/AdjustorMod/assets/Adjustor/recipes/smithing/adjustor.json
@@ -1,12 +1,12 @@
11 {
22 ingredient: { type: "item", code: "game:ingot-*", name: "metal", allowedVariants: ["copper", "tinbronze", "bismuthbronze", "blackbronze", "iron"] },
3- pattern: [
3+ pattern: [[
44 "_####______#____",
55 "_#__#______##___",
66 "____############",
77 "_#__#______##___",
88 "_####______#____",
9- ],
9+ ]],
1010 name: "Adjustor",
1111 output: { type: "item", code: "adjustmenttool-{metal}" }
1212 }
\ No newline at end of file
--- a/AdjustorMod/modinfo.json
+++ b/AdjustorMod/modinfo.json
@@ -1,12 +1,12 @@
11 {
22 "type": "code",
33 "name": "Adjustment Tool",
4- "description" : "Alter, Rotate blocks without breaking them. Now with Economy tool!",
4+ "description" : "Reposition and Rotate blocks without breaking them. (Even chutes)",
55 "authors": ["Melchior" ],
66 "contributors": ["bunnyviking"],
7- "version": "0.1.10",
7+ "version": "0.1.11",
88 "dependencies": {
9- "game": "1.12.0",
9+ "game": "1.14.0",
1010 "survival": ""
1111 },
1212 "website": "http://nowebsite.nope"