Browse Source

More attempts

master
NorbiPeti 5 years ago
parent
commit
f681287af1
Signed by: NorbiPeti <szatmari.norbert.peter@gmail.com> GPG Key ID: DBA4C4549A927E56
1 changed files with 27 additions and 5 deletions
  1. +27
    -5
      extracommands/SetScaleCommandEngine.cs

+ 27
- 5
extracommands/SetScaleCommandEngine.cs View File

@@ -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("<UpdateCursor>g__UpdatePlacementCursorScales|10_0");
harmony.Patch(method, new HarmonyMethod(((Func<bool>) PatchPrefix).Method));
Console.WriteLine("Patched");
}*/

_scale = new float3(x, y, z);
GhostScalingEntityStruct[] scalings =
entitiesDB.QueryEntities<GhostScalingEntityStruct>(
@@ -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.<UpdateCursor>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"));
}
}
}

Loading…
Cancel
Save