|
|
@@ -1,6 +1,7 @@ |
|
|
|
using System; |
|
|
|
using System.Reflection; |
|
|
|
using HarmonyLib; |
|
|
|
using TechbloxModdingAPI.Utility; |
|
|
|
using UnityEngine; |
|
|
|
|
|
|
|
namespace BuildingTools |
|
|
@@ -11,10 +12,11 @@ namespace BuildingTools |
|
|
|
|
|
|
|
public void Toggle() |
|
|
|
{ |
|
|
|
Console.WriteLine("Toggling no garage"); |
|
|
|
Logging.CommandLog("Toggling no garage"); |
|
|
|
// ReSharper disable once AssignmentInConditionalExpression |
|
|
|
if(_enabled = !_enabled) |
|
|
|
Enable(); |
|
|
|
Console.WriteLine($"{(_enabled ? "Enabled" : "Disabled")} no garage"); |
|
|
|
Logging.CommandLog($"{(_enabled ? "Enabled" : "Disabled")} no garage"); |
|
|
|
} |
|
|
|
|
|
|
|
private void Enable() |
|
|
@@ -23,13 +25,7 @@ namespace BuildingTools |
|
|
|
var simObj = (GameObject)AccessTools.Field(type, |
|
|
|
"THIS_IS_TEMPORARY_CODE_IT_IS_GOING_TO_BE_DELETED_ONCE_WE_HAVE_THE_FINAL_WORLD_SWITCHING_sim_go") |
|
|
|
.GetValue(null); |
|
|
|
/*var buildObjField = AccessTools.Field(type, |
|
|
|
"THIS_IS_TEMPORARY_CODE_IT_IS_GOING_TO_BE_DELETED_ONCE_WE_HAVE_THE_FINAL_WORLD_SWITCHING_build_go"); |
|
|
|
var buildObj = (GameObject) buildObjField.GetValue(null); |
|
|
|
Console.WriteLine($"obj: {simObj}");*/ |
|
|
|
var componentType = AccessTools.TypeByName("Techblox.Garage.GarageMachineBoundaryImplementor"); |
|
|
|
//var component = buildObj.GetComponent(componentType); |
|
|
|
//var newBuildObj = Object.Instantiate(simObj); |
|
|
|
simObj.AddComponent(componentType); |
|
|
|
var component = simObj.GetComponent(componentType); |
|
|
|
AccessTools.Field(componentType, "_bounds") |
|
|
@@ -38,7 +34,6 @@ namespace BuildingTools |
|
|
|
.SetValue(component, 1f); |
|
|
|
AccessTools.Field(componentType, "_cameraLookPointDistance") |
|
|
|
.SetValue(component, 1f); |
|
|
|
//buildObjField.SetValue(null, newBuildObj); |
|
|
|
} |
|
|
|
|
|
|
|
[HarmonyPatch] |
|
|
@@ -47,10 +42,10 @@ namespace BuildingTools |
|
|
|
public static bool Prefix(object __instance) |
|
|
|
{ |
|
|
|
if (!_enabled) return true; |
|
|
|
Console.WriteLine("Got a time stopped init event"); |
|
|
|
Logging.MetaDebugLog("Got a time stopped init event"); |
|
|
|
AccessTools.Method("Techblox.Environment.Temporary.EnvironmentSwitchEngine:OnTimeRunningInitializationComplete") |
|
|
|
.Invoke(__instance, Array.Empty<object>()); |
|
|
|
Console.WriteLine("Successfully called time running init event"); |
|
|
|
Logging.MetaDebugLog("Successfully called time running init event"); |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|