Add failed builderdecoration

This commit is contained in:
2024-08-23 21:41:30 +02:00
parent 0ee56fc7b1
commit d8d717c53a
2 changed files with 70 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
using System;
using System.Diagnostics;
using HarmonyLib;
using HutongGames.PlayMaker.Actions;
using UnityEngine;
namespace DavesPhatStore {
[HarmonyPatch]
public class BuilderDecoration {
// private static Transform lastValidPosition = null;
// [HarmonyPostfix]
// [HarmonyPatch(typeof(Builder_Decoration), "Update")]
// public static void Update(Builder_Decoration __instance) {
// var instanceT = Traverse.Create(__instance);
// var dummyOBJ = instanceT.Field("dummyOBJ").GetValue<GameObject>();
// if (dummyOBJ == null) {
// Console.WriteLine("No dummyOBJ");
// return;
// }
// var canPlace = instanceT.Field("canPlace").GetValue<bool>();
// if (canPlace) {
// Console.WriteLine($"Can place at {dummyOBJ.transform}");
// lastValidPosition = dummyOBJ.transform;
// } else {
// Console.WriteLine($"Cannot place, reverting to {lastValidPosition.position}");
// dummyOBJ.transform.position = lastValidPosition.position;
// }
// }
// [HarmonyPrefix]
// [HarmonyPatch(typeof(NetworkSpawner), "UserCode_CmdSpawn__Int32__Vector3__Vector3")]
// public static void UserCode_CmdSpawn__Int32__Vector3__Vector3(ref int prefabID, ref Vector3 pos, ref Vector3 rot) {
// Console.WriteLine(new StackTrace().ToString());
// Console.WriteLine($"Spawning {prefabID} at {pos.ToString()} with rot {rot.ToString()}");
// }
// [HarmonyPrefix]
// [HarmonyPatch(typeof(NetworkSpawner), "CmdSpawn")]
// public static void CmdSpawn(ref int prefabID, ref Vector3 pos, ref Vector3 rot) {
// Console.WriteLine(new StackTrace().ToString());
// Console.WriteLine($"Spawning {prefabID} at {pos.ToString()} with rot {rot.ToString()}");
// }
// [HarmonyPrefix]
// [HarmonyPatch(typeof(CallMethod), "DoMethodCall")]
// public static void DoMethodCall(CallMethod __instance) {
// var traverse = Traverse.Create(__instance);
// Console.WriteLine($"DoMethodCall cachedMethodInfo: {traverse.Field("cachedMethodInfo").GetValue()}");
// Console.WriteLine($"DoMethodCall cachedBehaviour: {traverse.Field("cachedBehaviour").GetValue()}");
// Console.WriteLine($"DoMethodCall parameters: {traverse.Field("parameters").GetValue()}");
// Console.WriteLine(new StackTrace().ToString());
// }
// [HarmonyPostfix]
// [HarmonyPatch(typeof(CallMethod), "DoMethodCall")]
// public static void PostDoMethodCall(CallMethod __instance) {
// var traverse = Traverse.Create(__instance);
// Console.WriteLine($"DoMethodCall cachedMethodInfo: {traverse.Field("cachedMethodInfo").GetValue()}");
// Console.WriteLine($"DoMethodCall cachedBehaviour: {traverse.Field("cachedBehaviour").GetValue()}");
// Console.WriteLine($"DoMethodCall parameters: {traverse.Field("parameters").GetValue()}");
// Console.WriteLine(new StackTrace().ToString());
// }
}
}

View File

@@ -41,6 +41,7 @@
<Compile Include="PlayerFaking.cs" /> <Compile Include="PlayerFaking.cs" />
<Compile Include="Properties\AssemblyInfo.cs"/> <Compile Include="Properties\AssemblyInfo.cs"/>
<Compile Include="WaitTimes.cs" /> <Compile Include="WaitTimes.cs" />
<Compile Include="BuilderDecoration.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="0Harmony"> <Reference Include="0Harmony">
@@ -64,6 +65,9 @@
<Reference Include="Mirror"> <Reference Include="Mirror">
<HintPath>$(GAME_MANAGED)/Mirror.dll</HintPath> <HintPath>$(GAME_MANAGED)/Mirror.dll</HintPath>
</Reference> </Reference>
<Reference Include="PlayMaker">
<HintPath>$(GAME_MANAGED)/PlayMaker.dll</HintPath>
</Reference>
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
</Project> </Project>