From 69125d634254882a47e4ce5f09d3e6d46e9666eb Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Tue, 15 Apr 2025 20:34:52 +0200 Subject: [PATCH] Copy terratech to erenshor --- Projects/Ereshor/.clang-format | 3 + Projects/Ereshor/.vs/Ereshor/v16/.suo | Bin 0 -> 45568 bytes Projects/Ereshor/Ereshor.sln | 16 + Projects/Ereshor/Ereshor/Class1.cs | 33 ++ Projects/Ereshor/Ereshor/CykUtil.cs | 28 + Projects/Ereshor/Ereshor/Ereshor.csproj | 94 ++++ .../Ereshor/Ereshor/ModuleBoosterManager.cs | 84 +++ .../Ereshor/Ereshor/ModuleEnergyManager.cs | 67 +++ .../Ereshor/ModuleEnergyStoreManager.cs | 60 ++ .../Ereshor/Ereshor/ModuleFuelTankManager.cs | 67 +++ Projects/Ereshor/Ereshor/ModuleGyroManager.cs | 60 ++ .../Ereshor/Ereshor/ModuleHeartManager.cs | 76 +++ .../Ereshor/ModuleItemHolderManager.cs | 164 ++++++ .../Ereshor/ModuleItemProducerManager.cs | 77 +++ .../Ereshor/ModuleRemoteChargerManager.cs | 77 +++ .../Ereshor/ModuleShieldGeneratorManager.cs | 88 +++ .../Ereshor/Ereshor/ModuleWeaponGunManager.cs | 121 ++++ .../Ereshor/Ereshor/ModuleWeaponManager.cs | 60 ++ .../Ereshor/Ereshor/ModuleWheelsManager.cs | 71 +++ Projects/Ereshor/Ereshor/ModuleWingManager.cs | 83 +++ Projects/Ereshor/Ereshor/MultiBuy.cs | 71 +++ .../Ereshor/Ereshor/ObjectFieldMultiplier.cs | 531 ++++++++++++++++++ Projects/Ereshor/Ereshor/Patches.cs | 24 + Projects/Ereshor/Ereshor/ProjectilePatch.cs | 22 + .../Ereshor/Properties/AssemblyInfo.cs | 35 ++ .../Ereshor/SeekingProjectileManager.cs | 30 + Projects/Ereshor/Ereshor/TankBeamManager.cs | 53 ++ Projects/Ereshor/Ereshor/TankManager.cs | 53 ++ .../Ereshor/Ereshor/UISnapshotPanelBuyAll.cs | 181 ++++++ Projects/Ereshor/Ereshor/log.cs | 14 + Projects/Ereshor/sync.yml | 3 + 31 files changed, 2346 insertions(+) create mode 100644 Projects/Ereshor/.clang-format create mode 100644 Projects/Ereshor/.vs/Ereshor/v16/.suo create mode 100644 Projects/Ereshor/Ereshor.sln create mode 100644 Projects/Ereshor/Ereshor/Class1.cs create mode 100644 Projects/Ereshor/Ereshor/CykUtil.cs create mode 100644 Projects/Ereshor/Ereshor/Ereshor.csproj create mode 100644 Projects/Ereshor/Ereshor/ModuleBoosterManager.cs create mode 100644 Projects/Ereshor/Ereshor/ModuleEnergyManager.cs create mode 100644 Projects/Ereshor/Ereshor/ModuleEnergyStoreManager.cs create mode 100644 Projects/Ereshor/Ereshor/ModuleFuelTankManager.cs create mode 100644 Projects/Ereshor/Ereshor/ModuleGyroManager.cs create mode 100644 Projects/Ereshor/Ereshor/ModuleHeartManager.cs create mode 100644 Projects/Ereshor/Ereshor/ModuleItemHolderManager.cs create mode 100644 Projects/Ereshor/Ereshor/ModuleItemProducerManager.cs create mode 100644 Projects/Ereshor/Ereshor/ModuleRemoteChargerManager.cs create mode 100644 Projects/Ereshor/Ereshor/ModuleShieldGeneratorManager.cs create mode 100644 Projects/Ereshor/Ereshor/ModuleWeaponGunManager.cs create mode 100644 Projects/Ereshor/Ereshor/ModuleWeaponManager.cs create mode 100644 Projects/Ereshor/Ereshor/ModuleWheelsManager.cs create mode 100644 Projects/Ereshor/Ereshor/ModuleWingManager.cs create mode 100644 Projects/Ereshor/Ereshor/MultiBuy.cs create mode 100644 Projects/Ereshor/Ereshor/ObjectFieldMultiplier.cs create mode 100644 Projects/Ereshor/Ereshor/Patches.cs create mode 100644 Projects/Ereshor/Ereshor/ProjectilePatch.cs create mode 100644 Projects/Ereshor/Ereshor/Properties/AssemblyInfo.cs create mode 100644 Projects/Ereshor/Ereshor/SeekingProjectileManager.cs create mode 100644 Projects/Ereshor/Ereshor/TankBeamManager.cs create mode 100644 Projects/Ereshor/Ereshor/TankManager.cs create mode 100644 Projects/Ereshor/Ereshor/UISnapshotPanelBuyAll.cs create mode 100644 Projects/Ereshor/Ereshor/log.cs create mode 100644 Projects/Ereshor/sync.yml diff --git a/Projects/Ereshor/.clang-format b/Projects/Ereshor/.clang-format new file mode 100644 index 0000000..d53bf86 --- /dev/null +++ b/Projects/Ereshor/.clang-format @@ -0,0 +1,3 @@ +BasedOnStyle: Google +IndentWidth: 4 +ColumnLimit: 120 \ No newline at end of file diff --git a/Projects/Ereshor/.vs/Ereshor/v16/.suo b/Projects/Ereshor/.vs/Ereshor/v16/.suo new file mode 100644 index 0000000000000000000000000000000000000000..6f0b1fb430d87511d735e0cf36bebcd17db9ebb0 GIT binary patch literal 45568 zcmeHQZ;)G66@MudT0o>Ch=8z`Qcy{n-OVQ1UH)`8$+pE7mTqZL18uU&Zqug8nq>RO zw&K`Uzv(v}MjgkIFN(tqesWZX89y=z4C8;oz|Ad}@(|0@5 zZIy{DGxh-c0q5OnJ4RahZC7I0j2>d?cXTRjx zHlg<59IpRTy=T4sk1txnM-i{0Zqu$+9MA0cdbkPcZUlS+a0}pOz$XEl0Ze-<&ZLn$ z0Cxh00G|es6z&3S1KbVR4!8$!FW@r(zWX_x?*sS&0l*Hx2teT<#dQcU2Kc-duby|~ zycgentjV|cBW@0G0AQ_?Zs1+bZ*;T&e+uPy3P*nYuZ?5q|3N0|UjG+#w2u8>^gq=` zPUTn6R-^x4jgK=A3Ww8K@Bb>_8}S190O^;!k?|kF`TFWL<3EP$D*;;o3g0GNUkkVf zz<1U64-sy!${!r_nS*My=UfG|s1y1Im9Vk)QdN(jSMh4LOyYuQ^F=6W!Qs~ z&q4A$1IcE@7=;Wo44xGPUkZa4C2%Bnvk%)Lf0B1AK5d`Ud_oDEb;iK{-wep#t??`) zFCG?*~jBQKEM*+YbIS0}|X_>U(mj36ER?)xGzp|)-3VLD*B_JPA`d~?LrV4Ub z6y>(&CRpV^q$#)fSs&^x~7==J|Nuu$txq4r5{_4LpR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^9vHJsP}E89P>-`l^`d|SZvE|$4Wbs;v9d|d3vI90bJ<6Lz|##yx^<9@Lt zqd2O#)(aDv^|D{RS m;F*N*mi5r|Njp~a_Wl! literal 0 HcmV?d00001 diff --git a/Projects/Ereshor/Ereshor.sln b/Projects/Ereshor/Ereshor.sln new file mode 100644 index 0000000..6a0ed6c --- /dev/null +++ b/Projects/Ereshor/Ereshor.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ereshor", "Ereshor\Ereshor.csproj", "{EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection +EndGlobal diff --git a/Projects/Ereshor/Ereshor/Class1.cs b/Projects/Ereshor/Ereshor/Class1.cs new file mode 100644 index 0000000..3f9a50a --- /dev/null +++ b/Projects/Ereshor/Ereshor/Class1.cs @@ -0,0 +1,33 @@ +using System.Linq; +using BepInEx; +using BepInEx.Configuration; +using HarmonyLib; +using HarmonyLib.Tools; + +namespace Ereshor { + [BepInPlugin(PluginGuid, PluginName, PluginVersion)] + public class Main : BaseUnityPlugin { + private const string PluginGuid = "CykaMod"; + private const string PluginName = "CykaMod"; + private const string PluginVersion = "1.0.0"; + + public static ConfigEntry debug; + + public static ConfigEntry xpMultiplier; + + public void Awake() { + debug = Config.Bind("General", "Debug", false); + + xpMultiplier = + Config.Bind("General", "XP Multiplier", 1f, + new ConfigDescription("XP Multiplier", new AcceptableValueRange(0.01f, 1024f))); + + Logger.LogInfo("Cyka mod loaded"); + HarmonyFileLog.Enabled = true; + Harmony harmony = new Harmony(PluginGuid); + harmony.PatchAll(); + var originalMethods = harmony.GetPatchedMethods(); + Logger.LogInfo("Patched " + originalMethods.Count() + " methods"); + } + } +} diff --git a/Projects/Ereshor/Ereshor/CykUtil.cs b/Projects/Ereshor/Ereshor/CykUtil.cs new file mode 100644 index 0000000..cf5c4c6 --- /dev/null +++ b/Projects/Ereshor/Ereshor/CykUtil.cs @@ -0,0 +1,28 @@ +using System; + +namespace Ereshor { + public class CykUtil { + public static bool IsPlayerTank(Module module) { + if (module == null) + return false; + TankBlock block = module.block; + if (block == null) + return false; + Tank tank = block.tank; + if (tank == null) + return false; + return tank.ControllableByLocalPlayer; + } + + public static Func isObjectPlayerTank = obj => { + if (obj == null) + return false; + try { + return IsPlayerTank(obj as Module); + } catch (Exception e) { + Console.WriteLine("Failed to check if object is a player tank: " + e.Message); + return false; + } + }; + } +} diff --git a/Projects/Ereshor/Ereshor/Ereshor.csproj b/Projects/Ereshor/Ereshor/Ereshor.csproj new file mode 100644 index 0000000..fabcc70 --- /dev/null +++ b/Projects/Ereshor/Ereshor/Ereshor.csproj @@ -0,0 +1,94 @@ + + + + + Debug + C:/Games/Erenshor.Early.Access + $(GAME_DIR)/Erenshor_Data/Managed + $(GAME_DIR)/BepInEx + AnyCPU + {EE5EFB7F-A4DC-44F0-967B-F71ECA2D46AE} + Library + Properties + Ereshor + Ereshor + v4.8 + 512 + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + + + + $(GAME_BEPINEX)/core/0Harmony.dll + + + $(GAME_BEPINEX)/core/BepInEx.dll + + + $(GAME_MANAGED)/UnityEngine.dll + + + $(GAME_MANAGED)/UnityEngine.CoreModule.dll + + + $(GAME_MANAGED)/Assembly-CSharp.dll + + + $(GAME_BEPINEX)/plugins/ConfigurationManager/ConfigurationManager.dll + + + + + \ No newline at end of file diff --git a/Projects/Ereshor/Ereshor/ModuleBoosterManager.cs b/Projects/Ereshor/Ereshor/ModuleBoosterManager.cs new file mode 100644 index 0000000..ea701a1 --- /dev/null +++ b/Projects/Ereshor/Ereshor/ModuleBoosterManager.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Ereshor { + [HarmonyPatch] + public class ModuleBoosterManager { + private static readonly MultipliedObjectManager FanManager = + new MultipliedObjectManager(ConfigureFanThruster); + private static readonly MultipliedObjectManager JetManager = + new MultipliedObjectManager(ConfigureJetThruster); + + private static ConfigEntry playerOnly; + private static ConfigEntry fanThrustMultiplier; + private static ConfigEntry jetThrustMultiplier; + + public static void Setup(ConfigFile config) { + float min = 0.01f; + float max = 32f; + + playerOnly = config.Bind("Booster", "Player Only", false, new ConfigDescription("Player Only")); + playerOnly.SettingChanged += (sender, args) => DoPatch(); + + fanThrustMultiplier = + config.Bind("Booster", "Fan Thrust Multiplier", 1f, + new ConfigDescription("Fan Thrust Multiplier", new AcceptableValueRange(min, max))); + fanThrustMultiplier.SettingChanged += (sender, args) => DoPatch(); + + jetThrustMultiplier = + config.Bind("Booster", "Jet Thrust Multiplier", 1f, + new ConfigDescription("Jet Thrust Multiplier", new AcceptableValueRange(min, max))); + jetThrustMultiplier.SettingChanged += (sender, args) => DoPatch(); + } + + private static void ConfigureFanThruster(MultipliedObject obj) { + obj.AddField(new FieldConfiguration("m_Force", fanThrustMultiplier, ShouldApply)); + } + + private static void ConfigureJetThruster(MultipliedObject obj) { + obj.AddField(new FieldConfiguration("m_Force", jetThrustMultiplier, ShouldApply)); + } + + private static readonly Func ShouldApply = obj => { + if (!playerOnly.Value) + return true; + return CykUtil.isObjectPlayerTank(obj); + }; + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleBooster), "OnAttached")] + public static void PostfixCreate(ModuleBooster __instance) { + var trav = Traverse.Create(__instance); + var fans = trav.Field("fans").GetValue>(); + var jets = trav.Field("jets").GetValue>(); + + foreach (var fan in fans) FanManager.OnObjectAttached(fan); + foreach (var jet in jets) JetManager.OnObjectAttached(jet); + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleBooster), "OnDetaching")] + public static void PostfixDestroy(ModuleBooster __instance) { + var trav = Traverse.Create(__instance); + var fans = trav.Field("fans").GetValue>(); + var jets = trav.Field("jets").GetValue>(); + + foreach (var fan in fans) FanManager.OnObjectDetached(fan); + foreach (var jet in jets) JetManager.OnObjectDetached(jet); + } + + private static void DoPatch() { + FanManager.ApplyAll(); + JetManager.ApplyAll(); + } + + public static readonly Func Register = obj => { + if (Main.debug.Value) + Console.WriteLine("Registering ModuleBooster: {0}", obj); + PostfixCreate(obj as ModuleBooster); + return true; + }; + } +} diff --git a/Projects/Ereshor/Ereshor/ModuleEnergyManager.cs b/Projects/Ereshor/Ereshor/ModuleEnergyManager.cs new file mode 100644 index 0000000..1357732 --- /dev/null +++ b/Projects/Ereshor/Ereshor/ModuleEnergyManager.cs @@ -0,0 +1,67 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Ereshor { + [HarmonyPatch] + public class ModuleEnergyManager { + private static readonly MultipliedObjectManager Manager = + new MultipliedObjectManager(ConfigureModuleEnergy); + + private static ConfigEntry playerOnly; + private static ConfigEntry outputMultiplier; + private static ConfigEntry powerUpDelayMultiplier; + + public static void Setup(ConfigFile config) { + float min = 0.01f; + float max = 32f; + + playerOnly = config.Bind("Energy", "Player Only", false, new ConfigDescription("Player Only")); + playerOnly.SettingChanged += (sender, args) => DoPatch(); + + outputMultiplier = + config.Bind("Energy", "Output Multiplier", 1f, + new ConfigDescription("Output Multiplier", new AcceptableValueRange(min, max))); + outputMultiplier.SettingChanged += (sender, args) => DoPatch(); + + powerUpDelayMultiplier = config.Bind( + "Energy", "Power Up Delay Multiplier", 1f, + new ConfigDescription("Power Up Delay Multiplier", new AcceptableValueRange(min, max))); + powerUpDelayMultiplier.SettingChanged += (sender, args) => DoPatch(); + } + + private static void ConfigureModuleEnergy(MultipliedObject obj) { + obj.AddField(new FieldConfiguration("m_OutputPerSecond", outputMultiplier, ShouldApply)); + obj.AddField(new FieldConfiguration("m_PowerUpDelay", powerUpDelayMultiplier, ShouldApply)); + } + + private static readonly Func ShouldApply = obj => { + if (!playerOnly.Value) + return true; + return CykUtil.IsPlayerTank(obj as Module); + }; + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleEnergy), "OnAnchorStatusChanged")] + public static void PostfixCreate(ModuleEnergy __instance) { + Manager.OnObjectAttached(__instance); + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleEnergy), "OnDetaching")] + public static void PostfixDestroy(ModuleEnergy __instance) { + Manager.OnObjectDetached(__instance); + } + + private static void DoPatch() { + Manager.ApplyAll(); + } + + public static readonly Func Register = obj => { + if (Main.debug.Value) + Console.WriteLine("Registering ModuleEnergy: {0}", obj); + PostfixCreate(obj as ModuleEnergy); + return true; + }; + } +} diff --git a/Projects/Ereshor/Ereshor/ModuleEnergyStoreManager.cs b/Projects/Ereshor/Ereshor/ModuleEnergyStoreManager.cs new file mode 100644 index 0000000..d1a55eb --- /dev/null +++ b/Projects/Ereshor/Ereshor/ModuleEnergyStoreManager.cs @@ -0,0 +1,60 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Ereshor { + [HarmonyPatch] + public class ModuleEnergyStoreManager { + private static readonly MultipliedObjectManager Manager = + new MultipliedObjectManager(ConfigureModuleEnergyStore); + + private static ConfigEntry playerOnly; + private static ConfigEntry capacityMultiplier; + + public static void Setup(ConfigFile config) { + float min = 0.01f; + float max = 32f; + + playerOnly = config.Bind("Energy", "Player Only", false, new ConfigDescription("Player Only")); + playerOnly.SettingChanged += (sender, args) => DoPatch(); + + capacityMultiplier = + config.Bind("Energy", "Capacity Multiplier", 1f, + new ConfigDescription("Capacity Multiplier", new AcceptableValueRange(min, max))); + capacityMultiplier.SettingChanged += (sender, args) => DoPatch(); + } + + private static void ConfigureModuleEnergyStore(MultipliedObject obj) { + obj.AddField(new FieldConfiguration("m_Capacity", capacityMultiplier, ShouldApply)); + } + + private static readonly Func ShouldApply = obj => { + if (!playerOnly.Value) + return true; + return CykUtil.IsPlayerTank(obj as Module); + }; + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleEnergyStore), "OnAttached")] + public static void PostfixCreate(ModuleEnergyStore __instance) { + Manager.OnObjectAttached(__instance); + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleEnergyStore), "OnDetaching")] + public static void PostfixDestroy(ModuleEnergyStore __instance) { + Manager.OnObjectDetached(__instance); + } + + private static void DoPatch() { + Manager.ApplyAll(); + } + + public static readonly Func Register = obj => { + if (Main.debug.Value) + Console.WriteLine("Registering ModuleEnergyStore: {0}", obj); + PostfixCreate(obj as ModuleEnergyStore); + return true; + }; + } +} diff --git a/Projects/Ereshor/Ereshor/ModuleFuelTankManager.cs b/Projects/Ereshor/Ereshor/ModuleFuelTankManager.cs new file mode 100644 index 0000000..65f043d --- /dev/null +++ b/Projects/Ereshor/Ereshor/ModuleFuelTankManager.cs @@ -0,0 +1,67 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Ereshor { + [HarmonyPatch] + public class ModuleFuelTankManager { + private static readonly MultipliedObjectManager Manager = + new MultipliedObjectManager(ConfigureFuelTank); + + private static ConfigEntry playerOnly; + private static ConfigEntry fuelCapacityMultiplier; + private static ConfigEntry fuelRefillMultiplier; + + public static void Setup(ConfigFile config) { + float min = 0.01f; + float max = 32f; + + playerOnly = config.Bind("FuelTank", "Player Only", false, new ConfigDescription("Player Only")); + playerOnly.SettingChanged += (sender, args) => DoPatch(); + + fuelCapacityMultiplier = config.Bind( + "FuelTank", "Fuel Capacity Multiplier", 1f, + new ConfigDescription("Fuel Capacity Multiplier", new AcceptableValueRange(min, max))); + fuelCapacityMultiplier.SettingChanged += (sender, args) => DoPatch(); + + fuelRefillMultiplier = + config.Bind("FuelTank", "Fuel Refill Multiplier", 1f, + new ConfigDescription("Fuel Refill Multiplier", new AcceptableValueRange(min, max))); + fuelRefillMultiplier.SettingChanged += (sender, args) => DoPatch(); + } + + private static void ConfigureFuelTank(MultipliedObject obj) { + obj.AddField(new FieldConfiguration("m_Capacity", fuelCapacityMultiplier, ShouldApply)); + obj.AddField(new FieldConfiguration("m_RefillRate", fuelRefillMultiplier, ShouldApply)); + } + + private static readonly Func ShouldApply = obj => { + if (!playerOnly.Value) + return true; + return CykUtil.isObjectPlayerTank(obj); + }; + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleFuelTank), "OnAttached")] + public static void PostfixCreate(ModuleFuelTank __instance) { + Manager.OnObjectAttached(__instance); + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleFuelTank), "OnDetaching")] + public static void PostfixDestroy(ModuleFuelTank __instance) { + Manager.OnObjectDetached(__instance); + } + + private static void DoPatch() { + Manager.ApplyAll(); + } + + public static readonly Func Register = obj => { + if (Main.debug.Value) + Console.WriteLine("Registering ModuleFuelTank: {0}", obj); + PostfixCreate(obj as ModuleFuelTank); + return true; + }; + } +} diff --git a/Projects/Ereshor/Ereshor/ModuleGyroManager.cs b/Projects/Ereshor/Ereshor/ModuleGyroManager.cs new file mode 100644 index 0000000..fe14de1 --- /dev/null +++ b/Projects/Ereshor/Ereshor/ModuleGyroManager.cs @@ -0,0 +1,60 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Ereshor { + [HarmonyPatch] + public class ModuleGyroManager { + private static readonly MultipliedObjectManager Manager = + new MultipliedObjectManager(ConfigureModuleGyro); + + private static ConfigEntry playerOnly; + private static ConfigEntry activeSpeedMultiplier; + + public static void Setup(ConfigFile config) { + float min = 0.01f; + float max = 32f; + + playerOnly = config.Bind("Gyro", "Player Only", false, new ConfigDescription("Player Only")); + playerOnly.SettingChanged += (sender, args) => DoPatch(); + + activeSpeedMultiplier = config.Bind( + "Gyro", "Active Speed Multiplier", 1f, + new ConfigDescription("Active Speed Multiplier", new AcceptableValueRange(min, max))); + activeSpeedMultiplier.SettingChanged += (sender, args) => DoPatch(); + } + + private static void ConfigureModuleGyro(MultipliedObject obj) { + obj.AddField(new FieldConfiguration("m_ActiveSpeed", activeSpeedMultiplier, ShouldApply)); + } + + private static readonly Func ShouldApply = obj => { + if (!playerOnly.Value) + return true; + return CykUtil.IsPlayerTank(obj as Module); + }; + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleGyro), "OnAttached")] + public static void PostfixCreate(ModuleGyro __instance) { + Manager.OnObjectAttached(__instance); + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleGyro), "OnDetaching")] + public static void PostfixDestroy(ModuleGyro __instance) { + Manager.OnObjectDetached(__instance); + } + + private static void DoPatch() { + Manager.ApplyAll(); + } + + public static readonly Func Register = obj => { + if (Main.debug.Value) + Console.WriteLine("Registering ModuleGyro: {0}", obj); + PostfixCreate(obj as ModuleGyro); + return true; + }; + } +} diff --git a/Projects/Ereshor/Ereshor/ModuleHeartManager.cs b/Projects/Ereshor/Ereshor/ModuleHeartManager.cs new file mode 100644 index 0000000..6d9a0f2 --- /dev/null +++ b/Projects/Ereshor/Ereshor/ModuleHeartManager.cs @@ -0,0 +1,76 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Ereshor { + [HarmonyPatch] + public class ModuleHeartManager { + private static readonly MultipliedObjectManager Manager = + new MultipliedObjectManager(ConfigureHeart); + + private static ConfigEntry playerOnly; + private static ConfigEntry eventHorizonRadiusMultiplier; + private static ConfigEntry setupTimeMultiplier; + private static ConfigEntry startShrinkingRadiusMultiplier; + + public static void Setup(ConfigFile config) { + float min = 0.01f; + float max = 32f; + + playerOnly = config.Bind("Heart", "Player Only", false, new ConfigDescription("Player Only")); + playerOnly.SettingChanged += (sender, args) => DoPatch(); + + eventHorizonRadiusMultiplier = config.Bind( + "Heart", "Event Horizon Radius Multiplier", 1f, + new ConfigDescription("Event Horizon Radius Multiplier", new AcceptableValueRange(min, max))); + eventHorizonRadiusMultiplier.SettingChanged += (sender, args) => DoPatch(); + + setupTimeMultiplier = + config.Bind("Heart", "Setup Time Multiplier", 1f, + new ConfigDescription("Setup Time Multiplier", new AcceptableValueRange(min, max))); + setupTimeMultiplier.SettingChanged += (sender, args) => DoPatch(); + + startShrinkingRadiusMultiplier = config.Bind( + "Heart", "Start Shrinking Radius Multiplier", 1f, + new ConfigDescription("Start Shrinking Radius Multiplier", new AcceptableValueRange(min, max))); + startShrinkingRadiusMultiplier.SettingChanged += (sender, args) => DoPatch(); + } + + private static void ConfigureHeart(MultipliedObject obj) { + obj.AddField(new FieldConfiguration("m_EventHorizonRadius", eventHorizonRadiusMultiplier, + ShouldApply)); + obj.AddField(new FieldConfiguration("m_SetupTime", setupTimeMultiplier, ShouldApply)); + obj.AddField(new FieldConfiguration("m_StartShrinkingRadius", startShrinkingRadiusMultiplier, + ShouldApply)); + } + + private static readonly Func ShouldApply = obj => { + if (!playerOnly.Value) + return true; + return CykUtil.isObjectPlayerTank(obj); + }; + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleHeart), "OnAttached")] + public static void PostfixCreate(ModuleHeart __instance) { + Manager.OnObjectAttached(__instance); + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleHeart), "OnDetaching")] + public static void PostfixDestroy(ModuleHeart __instance) { + Manager.OnObjectDetached(__instance); + } + + private static void DoPatch() { + Manager.ApplyAll(); + } + + public static readonly Func Register = obj => { + if (Main.debug.Value) + Console.WriteLine("Registering ModuleHeart: {0}", obj); + PostfixCreate(obj as ModuleHeart); + return true; + }; + } +} diff --git a/Projects/Ereshor/Ereshor/ModuleItemHolderManager.cs b/Projects/Ereshor/Ereshor/ModuleItemHolderManager.cs new file mode 100644 index 0000000..7e8ef84 --- /dev/null +++ b/Projects/Ereshor/Ereshor/ModuleItemHolderManager.cs @@ -0,0 +1,164 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Ereshor { + [HarmonyPatch] + public class ModuleItemHolderManager { + private static readonly MultipliedObjectManager BeamManager = + new MultipliedObjectManager(ConfigureBeam); + private static readonly MultipliedObjectManager BeamHolderManager = + new MultipliedObjectManager(ConfigureBeamHolder); + private static readonly MultipliedObjectManager BeamPickupManager = + new MultipliedObjectManager(ConfigureBeamPickup); + + private static readonly MultipliedObjectManager MagnetHolderManager = + new MultipliedObjectManager(ConfigureMagnetHolder); + private static readonly MultipliedObjectManager MagnetPickupManager = + new MultipliedObjectManager(ConfigureMagnetPickup); + + private static ConfigEntry playerOnly; + private static ConfigEntry capacityPerStackMultiplier; + private static ConfigEntry beamStrengthMultiplier; + private static ConfigEntry beamHeightIncrementScaleMultiplier; + private static ConfigEntry beamPickupRangeMultiplier; + private static ConfigEntry magnetStrengthMultiplier; + private static ConfigEntry magnetPickupRangeMultiplier; + + public static void Setup(ConfigFile config) { + float min = 0.01f; + float max = 32f; + + playerOnly = config.Bind("Item Holder", "Player Only", false, new ConfigDescription("Player Only")); + playerOnly.SettingChanged += (sender, args) => DoPatch(); + + capacityPerStackMultiplier = config.Bind( + "Item Holder", "Capacity Per Stack Multiplier", 1f, + new ConfigDescription("Capacity Per Stack Multiplier", new AcceptableValueRange(min, max))); + capacityPerStackMultiplier.SettingChanged += (sender, args) => DoPatch(); + + beamStrengthMultiplier = config.Bind( + "Item Holder", "Beam Strength Multiplier", 1f, + new ConfigDescription("Beam Strength Multiplier", new AcceptableValueRange(min, max))); + beamStrengthMultiplier.SettingChanged += (sender, args) => DoPatch(); + + beamHeightIncrementScaleMultiplier = + config.Bind("Item Holder", "Beam Height Increment Scale Multiplier", 1f, + new ConfigDescription("Beam Height Increment Scale Multiplier", + new AcceptableValueRange(min, max))); + beamHeightIncrementScaleMultiplier.SettingChanged += (sender, args) => DoPatch(); + + beamPickupRangeMultiplier = config.Bind( + "Item Holder", "Beam Pickup Range Multiplier", 1f, + new ConfigDescription("Beam Pickup Range Multiplier", new AcceptableValueRange(min, max))); + beamPickupRangeMultiplier.SettingChanged += (sender, args) => DoPatch(); + + magnetStrengthMultiplier = config.Bind( + "Item Holder", "Magnet Strength Multiplier", 1f, + new ConfigDescription("Magnet Strength Multiplier", new AcceptableValueRange(min, max))); + magnetStrengthMultiplier.SettingChanged += (sender, args) => DoPatch(); + + magnetPickupRangeMultiplier = config.Bind( + "Item Holder", "Magnet Pickup Range Multiplier", 1f, + new ConfigDescription("Magnet Pickup Range Multiplier", new AcceptableValueRange(min, max))); + magnetPickupRangeMultiplier.SettingChanged += (sender, args) => DoPatch(); + } + + private static void ConfigureBeam(MultipliedObject obj) { + obj.AddField( + new FieldConfiguration("m_CapacityPerStack", capacityPerStackMultiplier, ShouldApply)); + } + + private static void ConfigureBeamHolder(MultipliedObject obj) { + obj.AddField(new FieldConfiguration("m_BeamStrength", beamStrengthMultiplier, ShouldApply)); + obj.AddField(new FieldConfiguration("m_HeightIncrementScale", + beamHeightIncrementScaleMultiplier, ShouldApply)); + } + + private static void ConfigureBeamPickup(MultipliedObject obj) { + obj.AddField(new FieldConfiguration("m_PickupRange", beamPickupRangeMultiplier, ShouldApply)); + } + + private static void ConfigureMagnetHolder(MultipliedObject obj) { + obj.AddField(new FieldConfiguration("m_Strength", magnetStrengthMultiplier, ShouldApply)); + } + + private static void ConfigureMagnetPickup(MultipliedObject obj) { + obj.AddField( + new FieldConfiguration("m_PickupRange", magnetPickupRangeMultiplier, ShouldApply)); + } + + private static readonly Func ShouldApply = obj => { + if (!playerOnly.Value) + return true; + return CykUtil.IsPlayerTank(obj as Module); + }; + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleItemHolder), "OnAttached")] + public static void PostfixCreate(ModuleItemHolder __instance) { + BeamManager.OnObjectAttached(__instance); + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleItemHolder), "OnDetaching")] + public static void PostfixDestroy(ModuleItemHolder __instance) { + BeamManager.OnObjectDetached(__instance); + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleItemHolderBeam), "OnAttached")] + public static void PostfixCreate(ModuleItemHolderBeam __instance) { + var trav = Traverse.Create(__instance); + var pickup = trav.Field("m_Pickup").GetValue(); + + BeamHolderManager.OnObjectAttached(__instance); + BeamPickupManager.OnObjectAttached(pickup); + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleItemHolderBeam), "OnDetaching")] + public static void PostfixDestroy(ModuleItemHolderBeam __instance) { + var trav = Traverse.Create(__instance); + var pickup = trav.Field("m_Pickup").GetValue(); + + BeamHolderManager.OnObjectDetached(__instance); + BeamPickupManager.OnObjectDetached(pickup); + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleItemHolderMagnet), "OnAttached")] + public static void PostfixCreate(ModuleItemHolderMagnet __instance) { + var trav = Traverse.Create(__instance); + var pickup = trav.Field("m_Pickup").GetValue(); + + MagnetHolderManager.OnObjectAttached(__instance); + MagnetPickupManager.OnObjectAttached(pickup); + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleItemHolderMagnet), "OnDetaching")] + public static void PostfixDestroy(ModuleItemHolderMagnet __instance) { + var trav = Traverse.Create(__instance); + var pickup = trav.Field("m_Pickup").GetValue(); + + MagnetHolderManager.OnObjectDetached(__instance); + MagnetPickupManager.OnObjectDetached(pickup); + } + + private static void DoPatch() { + BeamManager.ApplyAll(); + BeamHolderManager.ApplyAll(); + BeamPickupManager.ApplyAll(); + MagnetHolderManager.ApplyAll(); + MagnetPickupManager.ApplyAll(); + } + + public static readonly Func Register = obj => { + if (Main.debug.Value) + Console.WriteLine("Registering ModuleItemHolder: {0}", obj); + PostfixCreate(obj as ModuleItemHolder); + return true; + }; + } +} diff --git a/Projects/Ereshor/Ereshor/ModuleItemProducerManager.cs b/Projects/Ereshor/Ereshor/ModuleItemProducerManager.cs new file mode 100644 index 0000000..58c20ee --- /dev/null +++ b/Projects/Ereshor/Ereshor/ModuleItemProducerManager.cs @@ -0,0 +1,77 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Ereshor { + [HarmonyPatch] + public class ModuleItemProducerManager { + private static readonly MultipliedObjectManager Manager = + new MultipliedObjectManager(ConfigureModuleItemProducer); + + private static ConfigEntry playerOnly; + private static ConfigEntry resourceGroundRadiusMultiplier; + private static ConfigEntry minDispenseIntervalMultiplier; + private static ConfigEntry secPerItemProducedMultiplier; + + public static void Setup(ConfigFile config) { + float min = 0.01f; + float max = 32f; + + playerOnly = config.Bind("Item Producer", "Player Only", false, new ConfigDescription("Player Only")); + playerOnly.SettingChanged += (sender, args) => DoPatch(); + + resourceGroundRadiusMultiplier = config.Bind( + "Item Producer", "Resource Ground Radius Multiplier", 1f, + new ConfigDescription("Resource Ground Radius Multiplier", new AcceptableValueRange(min, max))); + resourceGroundRadiusMultiplier.SettingChanged += (sender, args) => DoPatch(); + + minDispenseIntervalMultiplier = config.Bind( + "Item Producer", "Min Dispense Interval Multiplier", 1f, + new ConfigDescription("Min Dispense Interval Multiplier", new AcceptableValueRange(min, max))); + minDispenseIntervalMultiplier.SettingChanged += (sender, args) => DoPatch(); + + secPerItemProducedMultiplier = config.Bind( + "Item Producer", "Sec Per Item Produced Multiplier", 1f, + new ConfigDescription("Sec Per Item Produced Multiplier", new AcceptableValueRange(min, max))); + secPerItemProducedMultiplier.SettingChanged += (sender, args) => DoPatch(); + } + + private static void ConfigureModuleItemProducer(MultipliedObject obj) { + obj.AddField(new FieldConfiguration("m_ResourceGroundRadius", resourceGroundRadiusMultiplier, + ShouldApply)); + obj.AddField(new FieldConfiguration("m_MinDispenseInterval", minDispenseIntervalMultiplier, + ShouldApply)); + obj.AddField(new FieldConfiguration("m_SecPerItemProduced", secPerItemProducedMultiplier, + ShouldApply)); + } + + private static readonly Func ShouldApply = obj => { + if (!playerOnly.Value) + return true; + return CykUtil.IsPlayerTank(obj as Module); + }; + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleItemProducer), "GetClosestResourceReservoirInRange")] + public static void PostfixCreate(ModuleItemProducer __instance) { + Manager.OnObjectAttached(__instance); + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleItemProducer), "OnDetaching")] + public static void PostfixDestroy(ModuleItemProducer __instance) { + Manager.OnObjectDetached(__instance); + } + + private static void DoPatch() { + Manager.ApplyAll(); + } + + public static readonly Func Register = obj => { + if (Main.debug.Value) + Console.WriteLine("Registering ModuleItemProducer: {0}", obj); + PostfixCreate(obj as ModuleItemProducer); + return true; + }; + } +} diff --git a/Projects/Ereshor/Ereshor/ModuleRemoteChargerManager.cs b/Projects/Ereshor/Ereshor/ModuleRemoteChargerManager.cs new file mode 100644 index 0000000..4a9bdc6 --- /dev/null +++ b/Projects/Ereshor/Ereshor/ModuleRemoteChargerManager.cs @@ -0,0 +1,77 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Ereshor { + [HarmonyPatch] + public class ModuleRemoteChargerManager { + private static readonly MultipliedObjectManager Manager = + new MultipliedObjectManager(ConfigureModuleRemoteCharger); + + private static ConfigEntry playerOnly; + private static ConfigEntry arcFiringIntervalMultiplier; + private static ConfigEntry chargingRadiusMultiplier; + private static ConfigEntry powerTransferPerArcMultiplier; + + public static void Setup(ConfigFile config) { + const float min = 0.01f; + const float max = 32f; + + playerOnly = config.Bind("Remote Charger", "Player Only", false, new ConfigDescription("Player Only")); + playerOnly.SettingChanged += (sender, args) => DoPatch(); + + arcFiringIntervalMultiplier = config.Bind( + "Remote Charger", "Arc Firing Interval Multiplier", 1f, + new ConfigDescription("Arc Firing Interval Multiplier", new AcceptableValueRange(min, max))); + arcFiringIntervalMultiplier.SettingChanged += (sender, args) => DoPatch(); + + chargingRadiusMultiplier = config.Bind( + "Remote Charger", "Charging Radius Multiplier", 1f, + new ConfigDescription("Charging Radius Multiplier", new AcceptableValueRange(min, max))); + chargingRadiusMultiplier.SettingChanged += (sender, args) => DoPatch(); + + powerTransferPerArcMultiplier = config.Bind( + "Remote Charger", "Power Transfer Per Arc Multiplier", 1f, + new ConfigDescription("Power Transfer Per Arc Multiplier", new AcceptableValueRange(min, max))); + powerTransferPerArcMultiplier.SettingChanged += (sender, args) => DoPatch(); + } + + private static void ConfigureModuleRemoteCharger(MultipliedObject obj) { + obj.AddField( + new FieldConfiguration("m_ArcFiringInterval", arcFiringIntervalMultiplier, ShouldApply)); + obj.AddField( + new FieldConfiguration("m_ChargingRadius", chargingRadiusMultiplier, ShouldApply)); + obj.AddField(new FieldConfiguration("m_PowerTransferPerArc", powerTransferPerArcMultiplier, + ShouldApply)); + } + + private static readonly Func ShouldApply = obj => { + if (!playerOnly.Value) + return true; + return CykUtil.IsPlayerTank(obj as Module); + }; + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleRemoteCharger), "OnAttached")] + public static void PostfixCreate(ModuleRemoteCharger __instance) { + Manager.OnObjectAttached(__instance); + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleRemoteCharger), "OnDetaching")] + public static void PostfixDestroy(ModuleRemoteCharger __instance) { + Manager.OnObjectDetached(__instance); + } + + private static void DoPatch() { + Manager.ApplyAll(); + } + + public static readonly Func Register = obj => { + if (Main.debug.Value) + Console.WriteLine("Registering ModuleRemoteCharger: {0}", obj); + PostfixCreate(obj as ModuleRemoteCharger); + return true; + }; + } +} diff --git a/Projects/Ereshor/Ereshor/ModuleShieldGeneratorManager.cs b/Projects/Ereshor/Ereshor/ModuleShieldGeneratorManager.cs new file mode 100644 index 0000000..2298403 --- /dev/null +++ b/Projects/Ereshor/Ereshor/ModuleShieldGeneratorManager.cs @@ -0,0 +1,88 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Ereshor { + [HarmonyPatch] + public class ModuleShieldGeneratorManager { + private static readonly MultipliedObjectManager Manager = + new MultipliedObjectManager(ConfigureShieldGenerator); + + private static ConfigEntry playerOnly; + private static ConfigEntry radiusMultiplier; + private static ConfigEntry radiusMultiplierHealing; + private static ConfigEntry heartbeatIntervalMultiplier; + private static ConfigEntry powerUpDelayMultiplier; + + public static void Setup(ConfigFile config) { + const float min = 0.01f; + const float max = 32f; + + playerOnly = config.Bind("Shield", "Player Only", false, new ConfigDescription("Player Only")); + playerOnly.SettingChanged += (sender, args) => DoPatch(); + + radiusMultiplier = + config.Bind("Shield", "Radius Multiplier", 1f, + new ConfigDescription("Radius Multiplier", new AcceptableValueRange(min, max))); + radiusMultiplier.SettingChanged += (sender, args) => DoPatch(); + + heartbeatIntervalMultiplier = config.Bind( + "Shield", "Heartbeat Interval Multiplier", 1f, + new ConfigDescription("Heartbeat Interval Multiplier", new AcceptableValueRange(min, max))); + heartbeatIntervalMultiplier.SettingChanged += (sender, args) => DoPatch(); + + powerUpDelayMultiplier = config.Bind( + "Shield", "Power Up Delay Multiplier", 1f, + new ConfigDescription("Power Up Delay Multiplier", new AcceptableValueRange(min, max))); + powerUpDelayMultiplier.SettingChanged += (sender, args) => DoPatch(); + + radiusMultiplierHealing = config.Bind( + "Shield", "Radius Multiplier Healing", 1f, + new ConfigDescription("Radius Multiplier Healing", new AcceptableValueRange(min, max))); + radiusMultiplierHealing.SettingChanged += (sender, args) => DoPatch(); + } + + private static void ConfigureShieldGenerator(MultipliedObject obj) { + obj.AddField(new FieldConfiguration("m_HealingHeartbeatInterval", heartbeatIntervalMultiplier, + ShouldApply)); + + obj.AddField(new FieldConfiguration("m_Radius", radiusMultiplier, __instance => { + if (!ShouldApply(__instance)) + return radiusMultiplier; + var shield = (ModuleShieldGenerator)__instance; + return shield.m_Healing ? radiusMultiplierHealing : radiusMultiplier; + })); + + obj.AddField(new FieldConfiguration("m_PowerUpDelay", powerUpDelayMultiplier, ShouldApply)); + } + + private static readonly Func ShouldApply = obj => { + if (!playerOnly.Value) + return true; + return CykUtil.IsPlayerTank(obj as Module); + }; + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleShieldGenerator), "OnAttached")] + public static void PostfixCreate(ModuleShieldGenerator __instance) { + Manager.OnObjectAttached(__instance); + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleShieldGenerator), "OnDetaching")] + public static void PostfixDestroy(ModuleShieldGenerator __instance) { + Manager.OnObjectDetached(__instance); + } + + private static void DoPatch() { + Manager.ApplyAll(); + } + + public static readonly Func Register = obj => { + if (Main.debug.Value) + Console.WriteLine("Registering ModuleShieldGenerator: {0}", obj); + PostfixCreate(obj as ModuleShieldGenerator); + return true; + }; + } +} diff --git a/Projects/Ereshor/Ereshor/ModuleWeaponGunManager.cs b/Projects/Ereshor/Ereshor/ModuleWeaponGunManager.cs new file mode 100644 index 0000000..7539ac5 --- /dev/null +++ b/Projects/Ereshor/Ereshor/ModuleWeaponGunManager.cs @@ -0,0 +1,121 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Ereshor { + [HarmonyPatch] + public class ModuleWeaponGunManager { + private static readonly MultipliedObjectManager Manager = + new MultipliedObjectManager(ConfigureManager); + private static readonly MultipliedObjectManager FireDataManager = + new MultipliedObjectManager(ConfigureFireData); + + private static ConfigEntry playerOnly; + private static ConfigEntry kickbackStrengthMultiplier; + private static ConfigEntry muzzleVelocityMultiplier; + private static ConfigEntry burstCooldownMultiplier; + private static ConfigEntry burstShotCountMultiplier; + private static ConfigEntry shotCooldownMultiplier; + private static ConfigEntry seekingRoundsAll; + private static ConfigEntry resetBurstOnInterruptAll; + + public static void Setup(ConfigFile config) { + const float min = 0.01f; + const float max = 32f; + + playerOnly = config.Bind("WeaponGun", "Player Only", false, new ConfigDescription("Player Only")); + playerOnly.SettingChanged += (sender, args) => DoPatch(); + + kickbackStrengthMultiplier = config.Bind( + "FireData", "Kickback Strength Multiplier", 1f, + new ConfigDescription("Kickback Strength Multiplier", new AcceptableValueRange(min, max))); + kickbackStrengthMultiplier.SettingChanged += (sender, args) => DoPatch(); + + muzzleVelocityMultiplier = config.Bind( + "FireData", "Muzzle Velocity Multiplier", 1f, + new ConfigDescription("Muzzle Velocity Multiplier", new AcceptableValueRange(min, max))); + muzzleVelocityMultiplier.SettingChanged += (sender, args) => DoPatch(); + + burstCooldownMultiplier = config.Bind( + "FireData", "Burst Cooldown Multiplier", 1f, + new ConfigDescription("Burst Cooldown Multiplier", new AcceptableValueRange(min, max))); + burstCooldownMultiplier.SettingChanged += (sender, args) => DoPatch(); + + burstShotCountMultiplier = config.Bind( + "FireData", "Burst Shot Count Multiplier", 1f, + new ConfigDescription("Burst Shot Count Multiplier", new AcceptableValueRange(min, max))); + burstShotCountMultiplier.SettingChanged += (sender, args) => DoPatch(); + + shotCooldownMultiplier = config.Bind( + "FireData", "Shot Cooldown Multiplier", 1f, + new ConfigDescription("Shot Cooldown Multiplier", new AcceptableValueRange(min, max))); + shotCooldownMultiplier.SettingChanged += (sender, args) => DoPatch(); + + seekingRoundsAll = + config.Bind("FireData", "Seeking Rounds All", false, + new ConfigDescription("Seeking Rounds All", new AcceptableValueRange(false, true))); + seekingRoundsAll.SettingChanged += (sender, args) => DoPatch(); + + resetBurstOnInterruptAll = config.Bind( + "FireData", "Reset Burst On Interrupt All", false, + new ConfigDescription("Reset Burst On Interrupt All", new AcceptableValueRange(false, true))); + resetBurstOnInterruptAll.SettingChanged += (sender, args) => DoPatch(); + } + + private static void ConfigureManager(MultipliedObject obj) { + obj.AddBooleanField(new BooleanFieldConfiguration("m_SeekingRounds", seekingRoundsAll, ShouldApply)); + obj.AddBooleanField( + new BooleanFieldConfiguration("m_ResetBurstOnInterrupt", resetBurstOnInterruptAll, ShouldApply)); + obj.AddField(new FieldConfiguration("m_BurstCooldown", burstCooldownMultiplier, ShouldApply)); + obj.AddField(new FieldConfiguration("m_BurstShotCount", burstShotCountMultiplier, ShouldApply)); + obj.AddField(new FieldConfiguration("m_ShotCooldown", shotCooldownMultiplier, ShouldApply)); + } + + private static void ConfigureFireData(MultipliedObject obj) { + obj.AddField(new FieldConfiguration("m_MuzzleVelocity", muzzleVelocityMultiplier)); + obj.AddField(new FieldConfiguration("m_KickbackStrength", kickbackStrengthMultiplier)); + } + + private static readonly Func ShouldApply = obj => { + if (!playerOnly.Value) + return true; + return CykUtil.IsPlayerTank(obj as Module); + }; + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleWeaponGun), "OnAttached")] + public static void PostfixCreate(ModuleWeaponGun __instance) { + Manager.OnObjectAttached(__instance); + if (playerOnly.Value && !CykUtil.IsPlayerTank(__instance)) + return; + + var trav = Traverse.Create(__instance); + var firingData = trav.Field("m_FiringData"); + FireDataManager.OnObjectAttached(firingData.GetValue()); + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleWeaponGun), "OnDetaching")] + public static void PostfixDestroy(ModuleWeaponGun __instance) { + Manager.OnObjectAttached(__instance); + var trav = Traverse.Create(__instance); + if (playerOnly.Value && !CykUtil.IsPlayerTank(__instance)) + return; + + var firingData = trav.Field("m_FiringData"); + FireDataManager.OnObjectDetached(firingData.GetValue()); + } + + private static void DoPatch() { + FireDataManager.ApplyAll(); + Manager.ApplyAll(); + } + + public static readonly Func Register = obj => { + if (Main.debug.Value) + Console.WriteLine("Registering ModuleWeaponGun: {0}", obj); + PostfixCreate(obj as ModuleWeaponGun); + return true; + }; + } +} diff --git a/Projects/Ereshor/Ereshor/ModuleWeaponManager.cs b/Projects/Ereshor/Ereshor/ModuleWeaponManager.cs new file mode 100644 index 0000000..af8c597 --- /dev/null +++ b/Projects/Ereshor/Ereshor/ModuleWeaponManager.cs @@ -0,0 +1,60 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Ereshor { + [HarmonyPatch] + public class ModuleWeaponManager { + private static readonly MultipliedObjectManager Manager = + new MultipliedObjectManager(ConfigureManager); + + private static ConfigEntry playerOnly; + private static ConfigEntry rotateSpeedMultiplier; + + public static void Setup(ConfigFile config) { + const float min = 0.01f; + const float max = 32f; + + playerOnly = config.Bind("ModuleWeapon", "Player Only", false, new ConfigDescription("Player Only")); + playerOnly.SettingChanged += (sender, args) => DoPatch(); + + rotateSpeedMultiplier = config.Bind( + "ModuleWeapon", "Rotate Speed Multiplier", 1f, + new ConfigDescription("Rotate Speed Multiplier", new AcceptableValueRange(min, max))); + rotateSpeedMultiplier.SettingChanged += (sender, args) => DoPatch(); + } + + private static void ConfigureManager(MultipliedObject obj) { + obj.AddField(new FieldConfiguration("m_RotateSpeed", rotateSpeedMultiplier, ShouldApply)); + } + + private static readonly Func ShouldApply = obj => { + if (!playerOnly.Value) + return true; + return CykUtil.IsPlayerTank(obj as Module); + }; + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleWeapon), "OnAttached")] + public static void PostfixCreate(ModuleWeapon __instance) { + Manager.OnObjectAttached(__instance); + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleWeapon), "OnDetaching")] + public static void PostfixDestroy(ModuleWeapon __instance) { + Manager.OnObjectDetached(__instance); + } + + private static void DoPatch() { + Manager.ApplyAll(); + } + + public static readonly Func Register = obj => { + if (Main.debug.Value) + Console.WriteLine("Registering ModuleWeapon: {0}", obj); + PostfixCreate(obj as ModuleWeapon); + return true; + }; + } +} diff --git a/Projects/Ereshor/Ereshor/ModuleWheelsManager.cs b/Projects/Ereshor/Ereshor/ModuleWheelsManager.cs new file mode 100644 index 0000000..fd7e998 --- /dev/null +++ b/Projects/Ereshor/Ereshor/ModuleWheelsManager.cs @@ -0,0 +1,71 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Ereshor { + [HarmonyPatch] + public class ModuleWheelsManager { + private static readonly MultipliedObjectManager TorqueParamsManager = + new MultipliedObjectManager(ConfigureTorqueParams); + + private static ConfigEntry playerOnly; + private static ConfigEntry torqueRpmMultiplier; + private static ConfigEntry torqueMultiplier; + + public static void Setup(ConfigFile config) { + const float min = 0.01f; + const float max = 32f; + + playerOnly = config.Bind("TorqueParams", "Player Only", false, new ConfigDescription("Player Only")); + playerOnly.SettingChanged += (sender, args) => DoPatch(); + + torqueRpmMultiplier = + config.Bind("TorqueParams", "Torque RPM Multiplier", 1f, + new ConfigDescription("Torque RPM Multiplier", new AcceptableValueRange(min, max))); + torqueRpmMultiplier.SettingChanged += (sender, args) => DoPatch(); + + torqueMultiplier = + config.Bind("TorqueParams", "Torque Multiplier", 1f, + new ConfigDescription("Torque Multiplier", new AcceptableValueRange(min, max))); + torqueMultiplier.SettingChanged += (sender, args) => DoPatch(); + } + + private static void ConfigureTorqueParams(MultipliedObject obj) { + obj.AddField(new FieldConfiguration("torqueCurveMaxRpm", torqueRpmMultiplier, ShouldApply)); + obj.AddField(new FieldConfiguration("torqueCurveMaxTorque", torqueMultiplier, ShouldApply)); + } + + private static readonly Func ShouldApply = obj => { + if (!playerOnly.Value) + return true; + return CykUtil.IsPlayerTank(obj as Module); + }; + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleWheels), "OnAttached")] + public static void PostfixCreate(ModuleWheels __instance) { + var trav = Traverse.Create(__instance); + var torqueParams = trav.Field("torqueParams"); + TorqueParamsManager.OnObjectAttached(torqueParams.GetValue()); + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleWheels), "OnDetaching")] + public static void PostfixDestroy(ModuleWheels __instance) { + var trav = Traverse.Create(__instance); + var torqueParams = trav.Field("torqueParams"); + TorqueParamsManager.OnObjectDetached(torqueParams.GetValue()); + } + + private static void DoPatch() { + TorqueParamsManager.ApplyAll(); + } + + public static readonly Func Register = obj => { + if (Main.debug.Value) + Console.WriteLine("Registering ModuleWheels: {0}", obj); + PostfixCreate(obj as ModuleWheels); + return true; + }; + } +} diff --git a/Projects/Ereshor/Ereshor/ModuleWingManager.cs b/Projects/Ereshor/Ereshor/ModuleWingManager.cs new file mode 100644 index 0000000..27080a2 --- /dev/null +++ b/Projects/Ereshor/Ereshor/ModuleWingManager.cs @@ -0,0 +1,83 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Ereshor { + [HarmonyPatch] + public class ModuleWingManager { + private static readonly MultipliedObjectManager Manager = + new MultipliedObjectManager(ConfigureAerofoil); + + private static ConfigEntry playerOnly; + private static ConfigEntry angleRangeMultiplier; + private static ConfigEntry turnSpeedMultiplier; + private static ConfigEntry liftStrengthMultiplier; + + public static void Setup(ConfigFile config) { + const float min = 0.01f; + const float max = 32f; + + playerOnly = config.Bind("Aerofoil", "Player Only", false, new ConfigDescription("Player Only")); + playerOnly.SettingChanged += (sender, args) => DoPatch(); + + angleRangeMultiplier = + config.Bind("Aerofoil", "Angle Range Multiplier", 1f, + new ConfigDescription("Angle Range Multiplier", new AcceptableValueRange(min, max))); + angleRangeMultiplier.SettingChanged += (sender, args) => DoPatch(); + + turnSpeedMultiplier = + config.Bind("Aerofoil", "Turn Speed Multiplier", 1f, + new ConfigDescription("Turn Speed Multiplier", new AcceptableValueRange(min, max))); + turnSpeedMultiplier.SettingChanged += (sender, args) => DoPatch(); + + liftStrengthMultiplier = config.Bind( + "Aerofoil", "Lift Strength Multiplier", 1f, + new ConfigDescription("Lift Strength Multiplier", new AcceptableValueRange(min, max))); + liftStrengthMultiplier.SettingChanged += (sender, args) => DoPatch(); + } + + private static void ConfigureAerofoil(MultipliedObject obj) { + obj.AddField(new FieldConfiguration("flapAngleRangeActual", angleRangeMultiplier)); + obj.AddField(new FieldConfiguration("flapAngleRangeVisual", angleRangeMultiplier)); + + obj.AddField(new FieldConfiguration("flapTurnSpeed", turnSpeedMultiplier)); + obj.AddField(new FieldConfiguration("liftStrength", liftStrengthMultiplier)); + } + + private static readonly Func ShouldApply = obj => { + if (!playerOnly.Value) + return true; + return CykUtil.IsPlayerTank(obj as Module); + }; + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleWing), "OnAttached")] + public static void PostfixCreate(ModuleWing __instance) { + if (playerOnly.Value && !CykUtil.IsPlayerTank(__instance)) + return; + for (int i = 0; i < __instance.m_Aerofoils.Length; i++) { + var aerofoil = __instance.m_Aerofoils[i]; + Manager.OnObjectAttached(aerofoil); + } + } + + [HarmonyPrefix] + [HarmonyPatch(typeof(ModuleWing), "OnDetaching")] + public static void PostfixDestroy(ModuleWing __instance) { + if (playerOnly.Value && !CykUtil.IsPlayerTank(__instance)) + return; + foreach (var aerofoil in __instance.m_Aerofoils) Manager.OnObjectDetached(aerofoil); + } + + private static void DoPatch() { + Manager.ApplyAll(); + } + + public static readonly Func Register = obj => { + if (Main.debug.Value) + Console.WriteLine("Registering ModuleWing: {0}", obj); + PostfixCreate(obj as ModuleWing); + return true; + }; + } +} diff --git a/Projects/Ereshor/Ereshor/MultiBuy.cs b/Projects/Ereshor/Ereshor/MultiBuy.cs new file mode 100644 index 0000000..2caffaa --- /dev/null +++ b/Projects/Ereshor/Ereshor/MultiBuy.cs @@ -0,0 +1,71 @@ +using System; +using System.Reflection; +using HarmonyLib; +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.UI; + +namespace Ereshor { + [HarmonyPatch] + public class MultiBuy { + public static UIShopBlockSelect panel; + public static Traverse panelTraverse; + + [HarmonyPostfix] + [HarmonyPatch(typeof(UIShopBlockSelect), "OnSpawn")] + public static void PostfixCreate(UIShopBlockSelect __instance) { + panel = __instance; + if (Main.debugBuyAll.Value) + Console.WriteLine("UISnapshotPanel.OnPool: {0}", __instance); + panelTraverse = Traverse.Create(__instance); + var placeButton = panelTraverse.Field("m_PurchaseBlockButton").GetValue