From 87dc60763c4be629f9d05bea594075de42b374ea Mon Sep 17 00:00:00 2001 From: PhatPhuckDave Date: Sun, 6 Apr 2025 00:40:20 +0200 Subject: [PATCH] Copy paste terratech to quasimorph --- Projects/Quasimorph/.clang-format | 3 + Projects/Quasimorph/.vs/Quasimorph/v16/.suo | Bin 0 -> 48640 bytes Projects/Quasimorph/Quasimorph.sln | 16 + Projects/Quasimorph/Quasimorph/Class1.cs | 33 ++ Projects/Quasimorph/Quasimorph/CykUtil.cs | 28 + .../Quasimorph/ModuleBoosterManager.cs | 84 +++ .../Quasimorph/ModuleEnergyManager.cs | 67 +++ .../Quasimorph/ModuleEnergyStoreManager.cs | 60 ++ .../Quasimorph/ModuleFuelTankManager.cs | 67 +++ .../Quasimorph/ModuleGyroManager.cs | 60 ++ .../Quasimorph/ModuleHeartManager.cs | 76 +++ .../Quasimorph/ModuleItemHolderManager.cs | 164 ++++++ .../Quasimorph/ModuleItemProducerManager.cs | 77 +++ .../Quasimorph/ModuleRemoteChargerManager.cs | 77 +++ .../ModuleShieldGeneratorManager.cs | 88 +++ .../Quasimorph/ModuleWeaponGunManager.cs | 121 ++++ .../Quasimorph/ModuleWeaponManager.cs | 60 ++ .../Quasimorph/ModuleWheelsManager.cs | 71 +++ .../Quasimorph/ModuleWingManager.cs | 83 +++ Projects/Quasimorph/Quasimorph/MultiBuy.cs | 71 +++ .../Quasimorph/ObjectFieldMultiplier.cs | 531 ++++++++++++++++++ Projects/Quasimorph/Quasimorph/Patches.cs | 24 + .../Quasimorph/Quasimorph/ProjectilePatch.cs | 22 + .../Quasimorph/Properties/AssemblyInfo.cs | 35 ++ .../Quasimorph/Quasimorph/Quasimorph.csproj | 97 ++++ .../Quasimorph/SeekingProjectileManager.cs | 30 + .../Quasimorph/Quasimorph/TankBeamManager.cs | 53 ++ Projects/Quasimorph/Quasimorph/TankManager.cs | 53 ++ .../Quasimorph/UISnapshotPanelBuyAll.cs | 181 ++++++ Projects/Quasimorph/Quasimorph/log.cs | 14 + Projects/Quasimorph/format.sh | 1 + Projects/Quasimorph/sync.yml | 3 + 32 files changed, 2350 insertions(+) create mode 100644 Projects/Quasimorph/.clang-format create mode 100644 Projects/Quasimorph/.vs/Quasimorph/v16/.suo create mode 100644 Projects/Quasimorph/Quasimorph.sln create mode 100644 Projects/Quasimorph/Quasimorph/Class1.cs create mode 100644 Projects/Quasimorph/Quasimorph/CykUtil.cs create mode 100644 Projects/Quasimorph/Quasimorph/ModuleBoosterManager.cs create mode 100644 Projects/Quasimorph/Quasimorph/ModuleEnergyManager.cs create mode 100644 Projects/Quasimorph/Quasimorph/ModuleEnergyStoreManager.cs create mode 100644 Projects/Quasimorph/Quasimorph/ModuleFuelTankManager.cs create mode 100644 Projects/Quasimorph/Quasimorph/ModuleGyroManager.cs create mode 100644 Projects/Quasimorph/Quasimorph/ModuleHeartManager.cs create mode 100644 Projects/Quasimorph/Quasimorph/ModuleItemHolderManager.cs create mode 100644 Projects/Quasimorph/Quasimorph/ModuleItemProducerManager.cs create mode 100644 Projects/Quasimorph/Quasimorph/ModuleRemoteChargerManager.cs create mode 100644 Projects/Quasimorph/Quasimorph/ModuleShieldGeneratorManager.cs create mode 100644 Projects/Quasimorph/Quasimorph/ModuleWeaponGunManager.cs create mode 100644 Projects/Quasimorph/Quasimorph/ModuleWeaponManager.cs create mode 100644 Projects/Quasimorph/Quasimorph/ModuleWheelsManager.cs create mode 100644 Projects/Quasimorph/Quasimorph/ModuleWingManager.cs create mode 100644 Projects/Quasimorph/Quasimorph/MultiBuy.cs create mode 100644 Projects/Quasimorph/Quasimorph/ObjectFieldMultiplier.cs create mode 100644 Projects/Quasimorph/Quasimorph/Patches.cs create mode 100644 Projects/Quasimorph/Quasimorph/ProjectilePatch.cs create mode 100644 Projects/Quasimorph/Quasimorph/Properties/AssemblyInfo.cs create mode 100644 Projects/Quasimorph/Quasimorph/Quasimorph.csproj create mode 100644 Projects/Quasimorph/Quasimorph/SeekingProjectileManager.cs create mode 100644 Projects/Quasimorph/Quasimorph/TankBeamManager.cs create mode 100644 Projects/Quasimorph/Quasimorph/TankManager.cs create mode 100644 Projects/Quasimorph/Quasimorph/UISnapshotPanelBuyAll.cs create mode 100644 Projects/Quasimorph/Quasimorph/log.cs create mode 100644 Projects/Quasimorph/format.sh create mode 100644 Projects/Quasimorph/sync.yml diff --git a/Projects/Quasimorph/.clang-format b/Projects/Quasimorph/.clang-format new file mode 100644 index 0000000..d53bf86 --- /dev/null +++ b/Projects/Quasimorph/.clang-format @@ -0,0 +1,3 @@ +BasedOnStyle: Google +IndentWidth: 4 +ColumnLimit: 120 \ No newline at end of file diff --git a/Projects/Quasimorph/.vs/Quasimorph/v16/.suo b/Projects/Quasimorph/.vs/Quasimorph/v16/.suo new file mode 100644 index 0000000000000000000000000000000000000000..18f3d71a3ee1e670ecb9d6f9aae2ca0e50e43bb8 GIT binary patch literal 48640 zcmeHQTZ|i586GEXX-f-~mQYHe+cZsE$hh9!S=+mzZM?oDDZAvdo1}ng6W(@OSoUztbB0c8s#cOd;r&*&`8(mv<)-D*xjAd8RL)OW*;XL&&mq0l$8?dPgpQuP9UZ#l65=+f8fLT z_ey}<`ah1euQYPJ8t4BRD!{q?@kUMU^&8# zcoF06xV`Z#$C7;VbGT+7?*OQPAmCm=2rvp51B?SSzyyG0iQpUsOai6=I{{w+JOGgS z?l)Y^IIrge$YZXN&pghD0EYqW+0elK@D}eO&vw%+nI47>fIR)S{ zuoZ9z;7$PZy{mD)8|V8P*Aibp&i5nFU5$KWI8OuOfCL~3VEK0Aya%us@F3uefEmCn z;7fpgfP(;8o-Z4&Wt=>J1^;~&kOq7WFi13kWg&b6<$4I@MoGy3u`P04 zxj)jbO##xf%>cLfSCN)H6~hwRcma6o;@0!=x*qsX@_eM*4F3FQuU)=j8gn_PoWK~Q z9JYe-n8!@7AU2QnkP=Wv43rK>%)jOu$X4u-%oI)jm@*)PmCnS0TgaiDk^3N%NeX07 z2ZBA|Cyy?9RVn`!&#qGzG*PLm2a)^(GJFw*Hh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XJ+P9gl@=@2b6pv90ujvo#2Ay^kDfhB^S zv`+Y`qqaWJ_kwc|V+$)&*_RE~zZQR5g83cz0p%t;mx03^^Yo%&?t1AvB}WBX&yA1z^S=*d%Af!GXcY&4{;&7^7lcFk zK_I7p=wk&UoOtOzUqIjaLmzzgJvWT;<+0*(8?Bd}WD#%t&_{cUM?s$3UrBEtOQLK` z{th*YzK0)WF#go$o%5CP8D2BcZQs5e_Oaa7%9_-$Jc$ngcr2D&bDmxJ35Bwq}$6oWy3|Dq?wDGP74&jbG@$d;(>cGShl8?Lo%J5j6t<{0eq zjhrC*ZW;usjy)5{a8*X@82Qi#`d*&SqoZ3{$o9riPVQIXmtKtHjw6y@4XyVMw~sw? z|3T$BF!nbhbwK&O)wOjEGGA^gy;3VwYw1jWv9wgG)vK9$rJAmm@`Wm8*FvsdOJ@tq zrKQ5@bTh&rzZx#rD9R2|wGu;9mzJn}C_a@wqz{#tX{a3JP}whs%5-C>G$Rc1wc)ZU zYG0gOFM+6TqwZ-b5bW>=lr^ggF#DUT0$zIx54~<9etXDa8>lS5*mMFr)Tntl0alRj za3DiTmXJrMK=sE@LHoRXC2DQ&B0ONreA~yie`8Cqi%Ns}->>YCJ zfsIr57yokpn{Pfo_v{~@nf~>!-g|!jmTyhI`0tsw|MC1gfBomPS3Q+sKg;i+%Cl47 z^FODrZ_s<0-$FBr7qb0jzSj1a@ovvP|3?nQ=l^=;zJ31B=l|SVXng+9=l`sxBA@^B N`M-_A`wk=j_kSduJ3RmZ literal 0 HcmV?d00001 diff --git a/Projects/Quasimorph/Quasimorph.sln b/Projects/Quasimorph/Quasimorph.sln new file mode 100644 index 0000000..e12ed4a --- /dev/null +++ b/Projects/Quasimorph/Quasimorph.sln @@ -0,0 +1,16 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Quasimorph", "Quasimorph\Quasimorph.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/Quasimorph/Quasimorph/Class1.cs b/Projects/Quasimorph/Quasimorph/Class1.cs new file mode 100644 index 0000000..75cac7b --- /dev/null +++ b/Projects/Quasimorph/Quasimorph/Class1.cs @@ -0,0 +1,33 @@ +using System.Linq; +using BepInEx; +using BepInEx.Configuration; +using HarmonyLib; +using HarmonyLib.Tools; + +// TODO: Make shield and repair bigger +// TODO: Maybe make props faster, thrusters work fine + +namespace Quasimorph { + [BepInPlugin(PluginGuid, PluginName, PluginVersion)] + public class Main : BaseUnityPlugin { + private const string PluginGuid = "Quasicyka"; + private const string PluginName = "Quasicyka"; + private const string PluginVersion = "1.0.0"; + + public static ConfigEntry debug; + public static ConfigEntry scrappingMultiplier; + + public void Awake() { + debug = Config.Bind("General", "Debug", false); + scrappingMultiplier = Config.Bind("General", "Scrapping Multiplier", 1, + new ConfigDescription("Scrapping Multiplier", new AcceptableValueRange(1, 10000))); + + Logger.LogInfo("Quasicyka 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/Quasimorph/Quasimorph/CykUtil.cs b/Projects/Quasimorph/Quasimorph/CykUtil.cs new file mode 100644 index 0000000..cbac40c --- /dev/null +++ b/Projects/Quasimorph/Quasimorph/CykUtil.cs @@ -0,0 +1,28 @@ +using System; + +namespace Quasimorph { + 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/Quasimorph/Quasimorph/ModuleBoosterManager.cs b/Projects/Quasimorph/Quasimorph/ModuleBoosterManager.cs new file mode 100644 index 0000000..7124c72 --- /dev/null +++ b/Projects/Quasimorph/Quasimorph/ModuleBoosterManager.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Quasimorph { + [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/Quasimorph/Quasimorph/ModuleEnergyManager.cs b/Projects/Quasimorph/Quasimorph/ModuleEnergyManager.cs new file mode 100644 index 0000000..82935b6 --- /dev/null +++ b/Projects/Quasimorph/Quasimorph/ModuleEnergyManager.cs @@ -0,0 +1,67 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Quasimorph { + [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/Quasimorph/Quasimorph/ModuleEnergyStoreManager.cs b/Projects/Quasimorph/Quasimorph/ModuleEnergyStoreManager.cs new file mode 100644 index 0000000..e87b5db --- /dev/null +++ b/Projects/Quasimorph/Quasimorph/ModuleEnergyStoreManager.cs @@ -0,0 +1,60 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Quasimorph { + [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/Quasimorph/Quasimorph/ModuleFuelTankManager.cs b/Projects/Quasimorph/Quasimorph/ModuleFuelTankManager.cs new file mode 100644 index 0000000..b330a3a --- /dev/null +++ b/Projects/Quasimorph/Quasimorph/ModuleFuelTankManager.cs @@ -0,0 +1,67 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Quasimorph { + [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/Quasimorph/Quasimorph/ModuleGyroManager.cs b/Projects/Quasimorph/Quasimorph/ModuleGyroManager.cs new file mode 100644 index 0000000..24bbc3f --- /dev/null +++ b/Projects/Quasimorph/Quasimorph/ModuleGyroManager.cs @@ -0,0 +1,60 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Quasimorph { + [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/Quasimorph/Quasimorph/ModuleHeartManager.cs b/Projects/Quasimorph/Quasimorph/ModuleHeartManager.cs new file mode 100644 index 0000000..7b0fbf8 --- /dev/null +++ b/Projects/Quasimorph/Quasimorph/ModuleHeartManager.cs @@ -0,0 +1,76 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Quasimorph { + [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/Quasimorph/Quasimorph/ModuleItemHolderManager.cs b/Projects/Quasimorph/Quasimorph/ModuleItemHolderManager.cs new file mode 100644 index 0000000..8b2e48b --- /dev/null +++ b/Projects/Quasimorph/Quasimorph/ModuleItemHolderManager.cs @@ -0,0 +1,164 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Quasimorph { + [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/Quasimorph/Quasimorph/ModuleItemProducerManager.cs b/Projects/Quasimorph/Quasimorph/ModuleItemProducerManager.cs new file mode 100644 index 0000000..3e16f1e --- /dev/null +++ b/Projects/Quasimorph/Quasimorph/ModuleItemProducerManager.cs @@ -0,0 +1,77 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Quasimorph { + [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/Quasimorph/Quasimorph/ModuleRemoteChargerManager.cs b/Projects/Quasimorph/Quasimorph/ModuleRemoteChargerManager.cs new file mode 100644 index 0000000..bcd876f --- /dev/null +++ b/Projects/Quasimorph/Quasimorph/ModuleRemoteChargerManager.cs @@ -0,0 +1,77 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Quasimorph { + [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/Quasimorph/Quasimorph/ModuleShieldGeneratorManager.cs b/Projects/Quasimorph/Quasimorph/ModuleShieldGeneratorManager.cs new file mode 100644 index 0000000..99520ae --- /dev/null +++ b/Projects/Quasimorph/Quasimorph/ModuleShieldGeneratorManager.cs @@ -0,0 +1,88 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Quasimorph { + [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/Quasimorph/Quasimorph/ModuleWeaponGunManager.cs b/Projects/Quasimorph/Quasimorph/ModuleWeaponGunManager.cs new file mode 100644 index 0000000..77c77f7 --- /dev/null +++ b/Projects/Quasimorph/Quasimorph/ModuleWeaponGunManager.cs @@ -0,0 +1,121 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Quasimorph { + [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/Quasimorph/Quasimorph/ModuleWeaponManager.cs b/Projects/Quasimorph/Quasimorph/ModuleWeaponManager.cs new file mode 100644 index 0000000..14c44f9 --- /dev/null +++ b/Projects/Quasimorph/Quasimorph/ModuleWeaponManager.cs @@ -0,0 +1,60 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Quasimorph { + [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/Quasimorph/Quasimorph/ModuleWheelsManager.cs b/Projects/Quasimorph/Quasimorph/ModuleWheelsManager.cs new file mode 100644 index 0000000..f9e8b05 --- /dev/null +++ b/Projects/Quasimorph/Quasimorph/ModuleWheelsManager.cs @@ -0,0 +1,71 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Quasimorph { + [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/Quasimorph/Quasimorph/ModuleWingManager.cs b/Projects/Quasimorph/Quasimorph/ModuleWingManager.cs new file mode 100644 index 0000000..8ef3dd7 --- /dev/null +++ b/Projects/Quasimorph/Quasimorph/ModuleWingManager.cs @@ -0,0 +1,83 @@ +using System; +using BepInEx.Configuration; +using HarmonyLib; + +namespace Quasimorph { + [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/Quasimorph/Quasimorph/MultiBuy.cs b/Projects/Quasimorph/Quasimorph/MultiBuy.cs new file mode 100644 index 0000000..f7e5310 --- /dev/null +++ b/Projects/Quasimorph/Quasimorph/MultiBuy.cs @@ -0,0 +1,71 @@ +using System; +using System.Reflection; +using HarmonyLib; +using UnityEngine; +using UnityEngine.EventSystems; +using UnityEngine.UI; + +namespace Quasimorph { + [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