More attempts

This commit is contained in:
Norbi Peti 2020-01-18 01:28:59 +01:00
parent 9c30f0f3b8
commit f681287af1
No known key found for this signature in database
GPG key ID: DBA4C4549A927E56

View file

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