From fda4abd0eafe3c2244a4daf431be6ddb335f050a Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sun, 29 Sep 2024 02:51:42 +0200 Subject: [PATCH] Add config for max building volume --- .../InfectionFreeZone/InfectionFreeZone.cs | 24 ++++++++++++++++++- .../InfectionFreeZone.csproj | 3 +++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Projects/InfectionFreeZone/InfectionFreeZone/InfectionFreeZone.cs b/Projects/InfectionFreeZone/InfectionFreeZone/InfectionFreeZone.cs index 4224072..ac82c5d 100644 --- a/Projects/InfectionFreeZone/InfectionFreeZone/InfectionFreeZone.cs +++ b/Projects/InfectionFreeZone/InfectionFreeZone/InfectionFreeZone.cs @@ -111,6 +111,9 @@ namespace InfectionFreeZone { public static ConfigEntry towerEchoSelection; public static List> towerEchoSelectionList; + public static ConfigEntry buildingMaxVolumeDebug; + public static ConfigEntry buildingMaxVolume; + // See System.Void UI.InfoPanels.NestedUIElements.SelectWeaponPanel::OnWeaponItemClicked(UI.InfoPanels.NestedUIElements.WeaponItem) public void Awake() { @@ -188,6 +191,9 @@ namespace InfectionFreeZone { towerEchoSelection = Config.Bind("General", "Tower Echo Selection", false); towerEchoSelectionList = new List>(); + buildingMaxVolumeDebug = Config.Bind("General", "Building Max Volume Debug", false); + buildingMaxVolume = Config.Bind("General", "Building Max Volume", 50000f); + Logger.LogInfo("Cyka mod loaded"); HarmonyFileLog.Enabled = true; Harmony harmony = new Harmony(pluginGuid); @@ -707,9 +713,25 @@ namespace InfectionFreeZone { [HarmonyPrefix] [HarmonyPatch(typeof(WallConstructor), MethodType.Constructor, typeof(Wall.Factory), typeof(WorkersRadio), typeof(WallConfig))] - public static void PostfixWallConstructor(Wall.Factory factory, WorkersRadio workersRadio, ref WallConfig wallConfig) { + public static void PostfixWallConstructor(Wall.Factory factory, WorkersRadio workersRadio, + ref WallConfig wallConfig) { Console.WriteLine($"Wall config created"); wallConfig.maxAngel = 2f; } + + [HarmonyPrefix] + [HarmonyPatch(typeof(AdaptController), MethodType.Constructor, typeof(AdaptConfig))] + public static void PostfixAdaptConfig(ref AdaptConfig adaptConfig) { + var trav = Traverse.Create(adaptConfig); + var buildingsMaxVolume = trav.Field("buildingsMaxVolume"); + + if (Main.buildingMaxVolumeDebug.Value) + Console.WriteLine($"Building max volume is {buildingsMaxVolume.Value}"); + + buildingsMaxVolume.Value = Main.buildingMaxVolume.Value; + + if (Main.buildingMaxVolumeDebug.Value) + Console.WriteLine($"Building max volume modified to {buildingsMaxVolume.Value}"); + } } } \ No newline at end of file diff --git a/Projects/InfectionFreeZone/InfectionFreeZone/InfectionFreeZone.csproj b/Projects/InfectionFreeZone/InfectionFreeZone/InfectionFreeZone.csproj index 877f12f..981f354 100644 --- a/Projects/InfectionFreeZone/InfectionFreeZone/InfectionFreeZone.csproj +++ b/Projects/InfectionFreeZone/InfectionFreeZone/InfectionFreeZone.csproj @@ -66,6 +66,9 @@ $(GAME_MANAGED)/Sirenix.Serialization.dll + + $(GAME_MANAGED)/JutsuGamesConfig.dll +