diff --git a/Projects/TerraTech/TerraTech/Class1.cs b/Projects/TerraTech/TerraTech/Class1.cs index a92e5c6..a230cfe 100644 --- a/Projects/TerraTech/TerraTech/Class1.cs +++ b/Projects/TerraTech/TerraTech/Class1.cs @@ -7,10 +7,8 @@ using HarmonyLib; using HarmonyLib.Tools; using UnityEngine; -// TODO: Make attractor more range // TODO: Make battery bigger // TODO: Make shield and repair bigger -// TODO: Make turbo more turbo namespace TerraTech { [BepInPlugin(pluginGuid, pluginName, pluginVersion)] @@ -30,6 +28,7 @@ namespace TerraTech { public static ConfigEntry magnetRadiusMultiplier; public static ConfigEntry beamStrenghtMultiplier; public static ConfigEntry beamRadiusMultiplier; + public static ConfigEntry fuelTankRefillMultiplier; public void Awake() { xpMultiplier = Config.Bind("General", "XP Multiplier", 1f, new ConfigDescription("XP Multiplier", new AcceptableValueRange(1f, 32f))); @@ -50,6 +49,8 @@ namespace TerraTech { new ConfigDescription("Beam Strength Multiplier", new AcceptableValueRange(1f, 16f))); beamRadiusMultiplier = Config.Bind("General", "Beam Radius Multiplier", 1f, new ConfigDescription("Beam Radius Multiplier", new AcceptableValueRange(1f, 16f))); + beamRadiusMultiplier = Config.Bind("General", "Fuel Tank Refill Rate Multiplier", 1f, + new ConfigDescription("Fuel Tank Refill Rate Multiplier", new AcceptableValueRange(1f, 32f))); allProjectilesHoming = Config.Bind("General", "Make All Projectiles Home", false); @@ -57,6 +58,9 @@ namespace TerraTech { energyGenMultiplier.SettingChanged += (sender, args) => GeneratorPropertiesManager.DoPatch(); magnetStrenghtMultiplier.SettingChanged += (sender, args) => MagnetPropertiesManager.DoPatch(); magnetRadiusMultiplier.SettingChanged += (sender, args) => MagnetPropertiesManager.DoPatch(); + beamStrenghtMultiplier.SettingChanged += (sender, args) => BeamPropertiesManager.DoPatch(); + beamRadiusMultiplier.SettingChanged += (sender, args) => BeamPropertiesManager.DoPatch(); + fuelTankRefillMultiplier.SettingChanged += (sender, args) => FuelPropertiesManager.DoPatch(); Logger.LogInfo("Cyka mod loaded"); HarmonyFileLog.Enabled = true; @@ -69,18 +73,21 @@ namespace TerraTech { [HarmonyPatch] public class Patches { + [HarmonyPrefix] [HarmonyPatch(typeof(ManLicenses), "AddXP")] static void XPMulti(FactionSubTypes corporation, ref int xp, bool showUI = true) { xp = (int)(xp * Main.xpMultiplier.Value); } + [HarmonyPrefix] [HarmonyPatch(typeof(ManPlayer), "AddMoney")] static void MoneyMulti(ref int amount) { amount = (int)(amount * Main.moneyMultiplier.Value); } + [HarmonyPrefix] [HarmonyPatch(typeof(TechHolders), "SetHeartbeatInterval")] - static void MoneyMulti(ref float interval) { + static void HeartbeatMulti(ref float interval) { interval *= Main.heartbeatIntervalMultiplier.Value; } } @@ -193,6 +200,57 @@ namespace TerraTech { } } + [HarmonyPatch] + public class FuelPropertiesManager { + private static Dictionary tanks = new Dictionary(); + + [HarmonyPostfix] + [HarmonyPatch(typeof(ModuleFuelTank), "OnAttached")] + static void PostfixCreate(ModuleFuelTank __instance) { + if (!tanks.ContainsKey(__instance)) { + tanks.Add(__instance, GetValue(__instance)); + DoPatchSingle(__instance); + } + } + + [HarmonyPostfix] + [HarmonyPatch(typeof(ModuleFuelTank), "OnDetaching")] + static void PostfixDestroy(ModuleFuelTank __instance) { + DoRestoreSingle(__instance); + tanks.Remove(__instance); + } + + public static void DoPatch() { + // Console.WriteLine("Modifying " + generators.Count + " generators"); + // Console.WriteLine("Should patch: " + ShouldPatch()); + foreach (KeyValuePair keyValuePair in tanks) { + DoRestoreSingle(keyValuePair.Key); + DoPatchSingle(keyValuePair.Key); + } + } + + static void DoPatchSingle(ModuleFuelTank moduleFuelTank) { + // Console.WriteLine("Patching " + moduleEnergy.name); + // Console.WriteLine("Old value " + GetValue(moduleEnergy)); + SetValue(moduleFuelTank, GetValue(moduleFuelTank) * Main.energyGenMultiplier.Value); + // Console.WriteLine("New value " + GetValue(moduleEnergy)); + } + + static void DoRestoreSingle(ModuleFuelTank moduleFuelTank) { + if (tanks.ContainsKey(moduleFuelTank)) { + SetValue(moduleFuelTank, tanks[moduleFuelTank]); + } + } + + private static float GetValue(ModuleFuelTank moduleFuelTank) { + return moduleFuelTank.m_RefillRate; + } + + private static void SetValue(ModuleFuelTank moduleFuelTank, float value) { + moduleFuelTank.m_RefillRate = value; + } + } + [HarmonyPatch] public class MagnetPropertiesManager { private static Dictionary strenghts = new Dictionary(); diff --git a/Projects/TerraTech/TerraTech/bin/Debug/TerraTech.dll b/Projects/TerraTech/TerraTech/bin/Debug/TerraTech.dll index 53cb99a..88a1909 100644 Binary files a/Projects/TerraTech/TerraTech/bin/Debug/TerraTech.dll and b/Projects/TerraTech/TerraTech/bin/Debug/TerraTech.dll differ diff --git a/Projects/TerraTech/TerraTech/bin/Debug/TerraTech.pdb b/Projects/TerraTech/TerraTech/bin/Debug/TerraTech.pdb index 436af2a..76f5970 100644 Binary files a/Projects/TerraTech/TerraTech/bin/Debug/TerraTech.pdb and b/Projects/TerraTech/TerraTech/bin/Debug/TerraTech.pdb differ diff --git a/Projects/TerraTech/TerraTech/obj/Debug/TerraTech.dll b/Projects/TerraTech/TerraTech/obj/Debug/TerraTech.dll index 53cb99a..88a1909 100644 Binary files a/Projects/TerraTech/TerraTech/obj/Debug/TerraTech.dll and b/Projects/TerraTech/TerraTech/obj/Debug/TerraTech.dll differ diff --git a/Projects/TerraTech/TerraTech/obj/Debug/TerraTech.pdb b/Projects/TerraTech/TerraTech/obj/Debug/TerraTech.pdb index 436af2a..76f5970 100644 Binary files a/Projects/TerraTech/TerraTech/obj/Debug/TerraTech.pdb and b/Projects/TerraTech/TerraTech/obj/Debug/TerraTech.pdb differ