diff --git a/extracommands/SetScaleCommandEngine.cs b/extracommands/SetScaleCommandEngine.cs index cab399f..211f3b5 100644 --- a/extracommands/SetScaleCommandEngine.cs +++ b/extracommands/SetScaleCommandEngine.cs @@ -1,4 +1,5 @@ using System; +using System.Linq; using System.Reflection; using Harmony; using RobocraftX.GUI.CommandLine; @@ -33,9 +34,20 @@ namespace ExtraCommands.Basics } private static float3 _scale; + //private HarmonyInstance harmony; private void SetScaleCommand(float x, float y, float z) { + /*if (harmony == null) + { + Console.WriteLine("Patching..."); + harmony = HarmonyInstance.Create("org.exmods.extracommands.setscale"); + var type = Type.GetType("RobocraftX.CR.MachineEditing.PlacementCursorEngine"); + var method = type.GetMethod("g__UpdatePlacementCursorScales|10_0"); + harmony.Patch(method, new HarmonyMethod(((Func) PatchPrefix).Method)); + Console.WriteLine("Patched"); + }*/ + _scale = new float3(x, y, z); GhostScalingEntityStruct[] scalings = entitiesDB.QueryEntities( @@ -94,6 +106,14 @@ namespace ExtraCommands.Basics public void Remove(ref GhostScalingEntityStruct entityView, EGID egid) { }*/ + + /*private bool PatchPrefix() + { + if (math.any(_scale < new float3(4e-5))) + return true; + return false; //Prevent updating + }*/ + //ScaleGhostBlockEngine.UpdateScaling [HarmonyPatch] public class ScalePatch @@ -111,11 +131,12 @@ namespace ExtraCommands.Basics BindingFlags.NonPublic | BindingFlags.Instance); } } - //UniformScaleGhostBlockEngine.SimulatePhysicsStep - Does not update the ghost block but the outline still gets rounded - //RobocraftX.Blocks.Ghost.GhostScalingSyncEngine (reflection) - Doesn't do anything immediately visible + //RobocraftX.Blocks.Ghost.UniformScaleGhostBlockEngine.SimulatePhysicsStep - Does not update the ghost block but the outline still gets rounded + //RobocraftX.Blocks.Ghost.GhostScalingSyncEngine.SimulatePhysicsStep (reflection) - Doesn't do anything immediately visible + //RobocraftX.CR.MachineEditing.PlacementCursorEngine.g__UpdatePlacementCursorScales|10_0 //[HarmonyPatch(typeof(UniformScaleGhostBlockEngine))] //[HarmonyPatch("SimulatePhysicsStep")] - [HarmonyPatch] + //[HarmonyPatch] public class UniformScalePatch { static bool Prefix() @@ -127,8 +148,9 @@ namespace ExtraCommands.Basics static MethodBase TargetMethod(HarmonyInstance instance) { - return Type.GetType("RobocraftX.Blocks.Ghost.GhostScalingSyncEngine").GetMethod("SimulatePhysicsStep", - BindingFlags.NonPublic | BindingFlags.Instance); + return typeof(PlacementCursorEngine) + .GetMethods(BindingFlags.NonPublic | BindingFlags.Instance) + .First(m => m.Name.Contains("UpdatePlacementCursorScales")); } } }