|
|
@@ -36,6 +36,10 @@ namespace GamecraftModdingAPI.Blocks |
|
|
|
AccessTools.DeclaredField(PlaceBlueprintUtilityType, "_localBlockMap"); |
|
|
|
private static readonly MethodInfo BuildBlock = AccessTools.Method(PlaceBlueprintUtilityType, "BuildBlock"); |
|
|
|
private static readonly MethodInfo BuildWires = AccessTools.Method(PlaceBlueprintUtilityType, "BuildWires"); |
|
|
|
private static readonly Type SerializeGhostBlueprintType = |
|
|
|
AccessTools.TypeByName("RobocraftX.CR.MachineEditing.BoxSelect.SerializeGhostChildrenOnAddEngine"); |
|
|
|
private static readonly MethodInfo SerializeGhostBlueprint = |
|
|
|
AccessTools.Method(SerializeGhostBlueprintType, "SerializeClipboardGhostEntities"); |
|
|
|
|
|
|
|
private static NativeEntityRemove nativeRemove; |
|
|
|
private static MachineGraphConnectionEntityFactory connectionFactory; |
|
|
@@ -44,6 +48,8 @@ namespace GamecraftModdingAPI.Blocks |
|
|
|
private static IEntitySerialization entitySerialization; |
|
|
|
private static IEntityFactory entityFactory; |
|
|
|
private static FasterList<EGID> globalBlockMap; |
|
|
|
private static object SerializeGhostBlueprintInstance; |
|
|
|
private static GhostChildEntityFactory BuildGhostBlueprintFactory; |
|
|
|
|
|
|
|
public void Ready() |
|
|
|
{ |
|
|
@@ -130,6 +136,19 @@ namespace GamecraftModdingAPI.Blocks |
|
|
|
SelectionSerializationUtility.CopySelectionToClipboard(playerID, entitiesDB, |
|
|
|
serializationData.blueprintData, entitySerialization, entityFactory, blockIDs, |
|
|
|
(uint) blockIDs.Length, pos, rot, -1); |
|
|
|
BuildGhostBlueprint(selected, pos, rot, playerID); |
|
|
|
SerializeGhostBlueprint.Invoke(SerializeGhostBlueprintInstance, new object[] {playerID, blueprintID}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void BuildGhostBlueprint(ICollection<Block> blocks, float3 pos, quaternion rot, uint playerID) |
|
|
|
{ |
|
|
|
GhostChildUtility.ClearGhostChildren(playerID, entitiesDB, entityFunctions); |
|
|
|
foreach (var block in blocks) |
|
|
|
{ |
|
|
|
GhostChildUtility.BuildGhostChild(in playerID, block.Id, in pos, in rot, entitiesDB, |
|
|
|
BuildGhostBlueprintFactory, false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public Block[] PlaceBlueprintBlocks(uint blueprintID, uint playerID, float3 pos, float3 rot) |
|
|
@@ -238,6 +257,34 @@ namespace GamecraftModdingAPI.Blocks |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[HarmonyPatch] |
|
|
|
private static class SerializeGhostBlueprintPatch |
|
|
|
{ |
|
|
|
public static void Postfix(object __instance) |
|
|
|
{ |
|
|
|
SerializeGhostBlueprintInstance = __instance; |
|
|
|
} |
|
|
|
|
|
|
|
public static MethodBase TargetMethod() |
|
|
|
{ |
|
|
|
return AccessTools.GetDeclaredConstructors(SerializeGhostBlueprintType)[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
[HarmonyPatch] |
|
|
|
private static class BuildGhostBlueprintPatch |
|
|
|
{ |
|
|
|
public static void Postfix(GhostChildEntityFactory ghostChildEntityFactory) |
|
|
|
{ |
|
|
|
BuildGhostBlueprintFactory = ghostChildEntityFactory; |
|
|
|
} |
|
|
|
|
|
|
|
public static MethodBase TargetMethod() |
|
|
|
{ |
|
|
|
return AccessTools.GetDeclaredConstructors(AccessTools.TypeByName("RobocraftX.CR.MachineEditing.BuildGhostChildForMultiblockPickEngine"))[0]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public IEntityFactory Factory { get; set; } |
|
|
|
} |
|
|
|
} |