diff --git a/Projects/TerraTech/TerraTech/BeamPropertiesManager.cs b/Projects/TerraTech/TerraTech/BeamPropertiesManager.cs deleted file mode 100644 index e57fae3..0000000 --- a/Projects/TerraTech/TerraTech/BeamPropertiesManager.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System; -using System.Collections.Generic; -using HarmonyLib; - -namespace TerraTech { - [HarmonyPatch] - public class BeamPropertiesManager { - private static Dictionary strenghts = - new Dictionary(); - private static Dictionary radii = new Dictionary(); - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleItemHolderBeam), "OnAttached")] - static void PostfixCreate(ModuleItemHolderBeam __instance) { - // Console.WriteLine("ModuleItemHolderBeam.OnAttached"); - if (!strenghts.ContainsKey(__instance)) { - strenghts.Add(__instance, GetStrength(__instance)); - radii.Add(__instance, GetRadius(__instance)); - // Console.WriteLine("Patching {0}; m_BeamStrength: {1}; - // m_Pickup.m_PickupRange: {2}", __instance.name, GetStrength(__instance), - // GetRadius(__instance)); - DoPatchSingle(__instance); - // Console.WriteLine("Patched {0}; m_BeamStrength: {1}; - // m_Pickup.m_PickupRange: {2}", __instance.name, GetStrength(__instance), - // GetRadius(__instance)); - } - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleItemHolderBeam), "OnDetaching")] - static void PostfixDestroy(ModuleItemHolderBeam __instance) { - // Console.WriteLine("ModuleItemHolderBeam.OnDetaching"); - // Console.WriteLine("Restoring {0}; m_BeamStrength: {1}; - // m_Pickup.m_PickupRange: {2}", __instance.name, GetStrength(__instance), - // GetRadius(__instance)); - DoRestoreSingle(__instance); - // Console.WriteLine("Restored {0}; m_BeamStrength: {1}; - // m_Pickup.m_PickupRange: {2}", __instance.name, GetStrength(__instance), - // GetRadius(__instance)); - strenghts.Remove(__instance); - radii.Remove(__instance); - } - - public static void DoPatch() { - // Console.WriteLine("Modifying {0} ModuleItemHolderBeam", strenghts.Count); - foreach (KeyValuePair keyValuePair in strenghts) { - DoRestoreSingle(keyValuePair.Key); - DoPatchSingle(keyValuePair.Key); - } - } - - static void DoPatchSingle(ModuleItemHolderBeam moduleItemHolderBeam) { - SetStrength(moduleItemHolderBeam, strenghts[moduleItemHolderBeam] * Main.beamStrenghtMultiplier.Value); - SetRadius(moduleItemHolderBeam, radii[moduleItemHolderBeam] * Main.beamRadiusMultiplier.Value); - } - - static void DoRestoreSingle(ModuleItemHolderBeam moduleItemHolderBeam) { - if (strenghts.ContainsKey(moduleItemHolderBeam)) { - SetStrength(moduleItemHolderBeam, strenghts[moduleItemHolderBeam]); - SetRadius(moduleItemHolderBeam, radii[moduleItemHolderBeam]); - } - } - - private static float GetStrength(ModuleItemHolderBeam moduleItemHolderBeam) { - return Traverse.Create(moduleItemHolderBeam).Field("m_BeamStrength").GetValue() as float ? ?? 0f; - } - - private static void SetStrength(ModuleItemHolderBeam moduleItemHolderBeam, float value) { - Traverse.Create(moduleItemHolderBeam).Field("m_BeamStrength").SetValue(value); - } - - private static float GetRadius(ModuleItemHolderBeam moduleItemHolderBeam) { - ModuleItemPickup moduleItemPickup = - Traverse.Create(moduleItemHolderBeam).Field("m_Pickup").GetValue() as ModuleItemPickup; - if (moduleItemPickup) { - float radius = Traverse.Create(moduleItemPickup).Field("m_PickupRange").GetValue() as float ? ?? 0f; - return radius; - } - return 0f; - } - - private static void SetRadius(ModuleItemHolderBeam moduleItemHolderBeam, float value) { - ModuleItemPickup moduleItemPickup = - Traverse.Create(moduleItemHolderBeam).Field("m_Pickup").GetValue() as ModuleItemPickup; - if (moduleItemPickup) { - Traverse.Create(moduleItemPickup).Field("m_PickupRange").SetValue(value); - } - } - } -} \ No newline at end of file diff --git a/Projects/TerraTech/TerraTech/Class1.cs b/Projects/TerraTech/TerraTech/Class1.cs index 69299af..86ac568 100644 --- a/Projects/TerraTech/TerraTech/Class1.cs +++ b/Projects/TerraTech/TerraTech/Class1.cs @@ -39,14 +39,16 @@ namespace TerraTech { public static ConfigEntry wirelessChargingRadiusMultiplier; public static ConfigEntry wirelessChargingPowerPerArcMultiplier; public static ConfigEntry wirelessChargingArcFiringIntervalMultiplier; - public static ConfigEntry shieldRadiusMultiplier; - public static ConfigEntry shieldHeartbeatIntervalMultiplier; public static ConfigEntry powerUpDelayMultiplier; public static ConfigEntry batteryCapacityMultiplier; public static ConfigEntry weaponRotationSpeedMultiplier; public static ConfigEntry shopBlocksGeneratedTotalMultiplier; public static ConfigEntry shopPerBlockStopMultiplier; + public static ConfigEntry shieldRadiusMultiplier; + public static ConfigEntry shieldHeartbeatIntervalMultiplier; + public static ConfigEntry shieldPowerUpDelayMultiplier; + public void Awake() { debug = Config.Bind("General", "Debug", false); @@ -63,6 +65,18 @@ namespace TerraTech { "General", "Heartbeat Interval Multiplier", 1f, new ConfigDescription("Heartbeat Interval Multiplier", new AcceptableValueRange(0.1f, 2f))); + shieldRadiusMultiplier = Config.Bind( + "Shield", "Shield Radius Multiplier", 1f, + new ConfigDescription("Shield Radius Multiplier", new AcceptableValueRange(0.001f, 32f))); + shieldHeartbeatIntervalMultiplier = + Config.Bind("Shield", "Shield Heartbeat Interval Multiplier", 1f, + new ConfigDescription("Shield Heartbeat Interval Multiplier", + new AcceptableValueRange(0.001f, 32f))); + shieldPowerUpDelayMultiplier = + Config.Bind("Shield", "Shield Power Up Delay Multiplier", 1f, + new ConfigDescription("Shield Power Up Delay Multiplier", + new AcceptableValueRange(0.001f, 32f))); + shootingSpeedMultiplier = Config.Bind( "Weapons", "Shooting Speed Multiplier", 1f, new ConfigDescription("Shooting Speed Multiplier", new AcceptableValueRange(0.2f, 8f))); @@ -142,13 +156,6 @@ namespace TerraTech { "Shop", "Shop Per Block Stop Multiplier", 1f, new ConfigDescription("Shop Per Block Stop Multiplier", new AcceptableValueRange(1f, 32f))); - shieldRadiusMultiplier = Config.Bind( - "Shield", "Shield Radius Multiplier", 1f, - new ConfigDescription("Shield Radius Multiplier", new AcceptableValueRange(0.001f, 32f))); - shieldHeartbeatIntervalMultiplier = - Config.Bind("Shield", "Shield Heartbeat Interval Multiplier", 1f, - new ConfigDescription("Shield Heartbeat Interval Multiplier", - new AcceptableValueRange(0.001f, 32f))); powerUpDelayMultiplier = Config.Bind( "PowerUp", "Power Up Delay Multiplier", 1f, new ConfigDescription("Power Up Delay Multiplier", new AcceptableValueRange(0.001f, 32f))); @@ -156,29 +163,30 @@ namespace TerraTech { "PowerUp", "Battery Capacity Multiplier", 1f, new ConfigDescription("Battery Capacity Multiplier", new AcceptableValueRange(0.001f, 32f))); - shootingSpeedMultiplier.SettingChanged += (sender, args) => WeaponPropertiesManager.DoPatch(); - weaponRotationSpeedMultiplier.SettingChanged += (sender, args) => WeaponPropertiesManager.DoPatch(); - 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(); - fuelTankCapacityMultiplier.SettingChanged += (sender, args) => FuelPropertiesManager.DoPatch(); - wheelTorqueMultiplier.SettingChanged += (sender, args) => WheelPropertiesManager.DoPatch(); - wheelSpeedMultiplier.SettingChanged += (sender, args) => WheelPropertiesManager.DoPatch(); - jetThrustMultiplier.SettingChanged += (sender, args) => ThrusterPropertiesManager.DoPatch(); - minerGroundArea.SettingChanged += (sender, args) => MinerPropertiesManager.DoPatch(); - minerMiningSpeed.SettingChanged += (sender, args) => MinerPropertiesManager.DoPatch(); - wirelessChargingPowerPerArcMultiplier.SettingChanged += (sender, args) => - WirelessChargerPropertiesManager.DoPatch(); - wirelessChargingArcFiringIntervalMultiplier.SettingChanged += (sender, args) => - WirelessChargerPropertiesManager.DoPatch(); - wirelessChargingRadiusMultiplier.SettingChanged += (sender, args) => - WirelessChargerPropertiesManager.DoPatch(); - shopBlocksGeneratedTotalMultiplier.SettingChanged += (sender, args) => - InventorySupplierPropertiesManager.DoPatch(); - shopPerBlockStopMultiplier.SettingChanged += (sender, args) => InventorySupplierPropertiesManager.DoPatch(); + // shootingSpeedMultiplier.SettingChanged += (sender, args) => WeaponPropertiesManager.DoPatch(); + // weaponRotationSpeedMultiplier.SettingChanged += (sender, args) => WeaponPropertiesManager.DoPatch(); + // 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(); + // fuelTankCapacityMultiplier.SettingChanged += (sender, args) => FuelPropertiesManager.DoPatch(); + // wheelTorqueMultiplier.SettingChanged += (sender, args) => WheelPropertiesManager.DoPatch(); + // wheelSpeedMultiplier.SettingChanged += (sender, args) => WheelPropertiesManager.DoPatch(); + // jetThrustMultiplier.SettingChanged += (sender, args) => ThrusterPropertiesManager.DoPatch(); + // minerGroundArea.SettingChanged += (sender, args) => MinerPropertiesManager.DoPatch(); + // minerMiningSpeed.SettingChanged += (sender, args) => MinerPropertiesManager.DoPatch(); + // wirelessChargingPowerPerArcMultiplier.SettingChanged += (sender, args) => + // WirelessChargerPropertiesManager.DoPatch(); + // wirelessChargingArcFiringIntervalMultiplier.SettingChanged += (sender, args) => + // WirelessChargerPropertiesManager.DoPatch(); + // wirelessChargingRadiusMultiplier.SettingChanged += (sender, args) => + // WirelessChargerPropertiesManager.DoPatch(); + // shopBlocksGeneratedTotalMultiplier.SettingChanged += (sender, args) => + // InventorySupplierPropertiesManager.DoPatch(); + // shopPerBlockStopMultiplier.SettingChanged += (sender, args) => + // InventorySupplierPropertiesManager.DoPatch(); Logger.LogInfo("Cyka mod loaded"); HarmonyFileLog.Enabled = true; diff --git a/Projects/TerraTech/TerraTech/FuelPropertiesManager.cs b/Projects/TerraTech/TerraTech/FuelPropertiesManager.cs deleted file mode 100644 index 37e0449..0000000 --- a/Projects/TerraTech/TerraTech/FuelPropertiesManager.cs +++ /dev/null @@ -1,59 +0,0 @@ -using System; -using System.Collections.Generic; -using HarmonyLib; - -namespace TerraTech { - [HarmonyPatch] - public class FuelPropertiesManager { - private static Dictionary refillRate = new Dictionary(); - private static Dictionary capacity = new Dictionary(); - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleFuelTank), "OnAttached")] - static void PostfixCreate(ModuleFuelTank __instance) { - // Console.WriteLine("ModuleFuelTank.OnAttached"); - if (!refillRate.ContainsKey(__instance)) { - refillRate.Add(__instance, __instance.m_RefillRate); - capacity.Add(__instance, __instance.m_Capacity); - // Console.WriteLine("Patching {0}; m_RefillRate: {1}; m_Capacity: {2}", - // __instance.name, __instance.m_RefillRate, __instance.m_Capacity); - DoPatchSingle(__instance); - // Console.WriteLine("Patched {0}; m_RefillRate: {1}; m_Capacity: {2}", - // __instance.name, __instance.m_RefillRate, __instance.m_Capacity); - } - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleFuelTank), "OnDetaching")] - static void PostfixDestroy(ModuleFuelTank __instance) { - // Console.WriteLine("ModuleFuelTank.OnAttached"); - // Console.WriteLine("Restoring {0}; m_RefillRate: {1}; m_Capacity: {2}", - // __instance.name, __instance.m_RefillRate, __instance.m_Capacity); - DoRestoreSingle(__instance); - // Console.WriteLine("Restored {0}; m_RefillRate: {1}; m_Capacity: {2}", - // __instance.name, __instance.m_RefillRate, __instance.m_Capacity); - refillRate.Remove(__instance); - capacity.Remove(__instance); - } - - public static void DoPatch() { - // Console.WriteLine("Modifying {0} ModuleFuelTank", refillRate.Count); - foreach (KeyValuePair keyValuePair in refillRate) { - DoRestoreSingle(keyValuePair.Key); - DoPatchSingle(keyValuePair.Key); - } - } - - static void DoPatchSingle(ModuleFuelTank moduleFuelTank) { - moduleFuelTank.m_RefillRate = refillRate[moduleFuelTank] * Main.fuelTankRefillMultiplier.Value; - moduleFuelTank.m_Capacity = capacity[moduleFuelTank] * Main.fuelTankCapacityMultiplier.Value; - } - - static void DoRestoreSingle(ModuleFuelTank moduleFuelTank) { - if (refillRate.ContainsKey(moduleFuelTank)) { - moduleFuelTank.m_RefillRate = refillRate[moduleFuelTank]; - moduleFuelTank.m_Capacity = capacity[moduleFuelTank]; - } - } - } -} \ No newline at end of file diff --git a/Projects/TerraTech/TerraTech/GeneratorPropertiesManager.cs b/Projects/TerraTech/TerraTech/GeneratorPropertiesManager.cs deleted file mode 100644 index e2c831e..0000000 --- a/Projects/TerraTech/TerraTech/GeneratorPropertiesManager.cs +++ /dev/null @@ -1,62 +0,0 @@ -using System; -using System.Collections.Generic; -using HarmonyLib; - -namespace TerraTech { - [HarmonyPatch] - public class GeneratorPropertiesManager { - private static Dictionary generators = new Dictionary(); - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleEnergy), "OnAttached")] - static void PostfixCreate(ModuleEnergy __instance) { - // Console.WriteLine("ModuleEnergy.OnAttached"); - if (!generators.ContainsKey(__instance)) { - generators.Add(__instance, GetValue(__instance)); - // Console.WriteLine("Patching {0}; m_OutputPerSecond: {1}", - // __instance.name, GetValue(__instance)); - DoPatchSingle(__instance); - // Console.WriteLine("Patched {0}; m_OutputPerSecond: {1}", - // __instance.name, GetValue(__instance)); - } - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleEnergy), "OnDetaching")] - static void PostfixDestroy(ModuleEnergy __instance) { - // Console.WriteLine("ModuleEnergy.OnDetaching"); - // Console.WriteLine("Restoring {0}; m_OutputPerSecond: {1}", - // __instance.name, GetValue(__instance)); - DoRestoreSingle(__instance); - // Console.WriteLine("Restored {0}; m_OutputPerSecond: {1}", - // __instance.name, GetValue(__instance)); - generators.Remove(__instance); - } - - public static void DoPatch() { - // Console.WriteLine("Modifying {0} ModuleEnergy", generators.Count); - foreach (KeyValuePair keyValuePair in generators) { - DoRestoreSingle(keyValuePair.Key); - DoPatchSingle(keyValuePair.Key); - } - } - - static void DoPatchSingle(ModuleEnergy moduleEnergy) { - SetValue(moduleEnergy, generators[moduleEnergy] * Main.energyGenMultiplier.Value); - } - - static void DoRestoreSingle(ModuleEnergy moduleEnergy) { - if (generators.ContainsKey(moduleEnergy)) { - SetValue(moduleEnergy, generators[moduleEnergy]); - } - } - - private static float GetValue(ModuleEnergy moduleEnergy) { - return Traverse.Create(moduleEnergy).Field("m_OutputPerSecond").GetValue() as float ? ?? 0f; - } - - private static void SetValue(ModuleEnergy moduleEnergy, float value) { - Traverse.Create(moduleEnergy).Field("m_OutputPerSecond").SetValue(value); - } - } -} \ No newline at end of file diff --git a/Projects/TerraTech/TerraTech/HomingAndVelocityProjectilePatch.cs b/Projects/TerraTech/TerraTech/HomingAndVelocityProjectilePatch.cs deleted file mode 100644 index 60c33bf..0000000 --- a/Projects/TerraTech/TerraTech/HomingAndVelocityProjectilePatch.cs +++ /dev/null @@ -1,23 +0,0 @@ -using System.Collections.Generic; -using HarmonyLib; -using UnityEngine; - -namespace TerraTech { - [HarmonyPatch(typeof(Projectile), "Fire")] - public class HomingAndVelocityProjectilePatch { - private static Dictionary velocities = new Dictionary(); - - static void Prefix(Vector3 fireDirection, ref FireData fireData, ref ModuleWeaponGun weapon, Tank shooter, - ref bool seekingRounds, bool replayRounds) { - if (Main.allProjectilesHoming.Value) { - seekingRounds = true; - } - if (!velocities.ContainsKey(fireData)) { - velocities.Add(fireData, fireData.m_MuzzleVelocity); - fireData.m_MuzzleVelocity *= Main.muzzleVelocityMultiplier.Value; - } else if (velocities[fireData] != fireData.m_MuzzleVelocity * Main.muzzleVelocityMultiplier.Value) { - fireData.m_MuzzleVelocity = velocities[fireData] * Main.muzzleVelocityMultiplier.Value; - } - } - } -} \ No newline at end of file diff --git a/Projects/TerraTech/TerraTech/InventorySupplierPropertiesManager.cs b/Projects/TerraTech/TerraTech/InventorySupplierPropertiesManager.cs deleted file mode 100644 index 61a5127..0000000 --- a/Projects/TerraTech/TerraTech/InventorySupplierPropertiesManager.cs +++ /dev/null @@ -1,111 +0,0 @@ -using System; -using System.Collections.Generic; -using HarmonyLib; - -namespace TerraTech { - [HarmonyPatch] - public class InventorySupplierPropertiesManager { - private static Dictionary inventoryNumBlockTypes = - new Dictionary(); - private static Dictionary inventoryQuantityPerBlockType = - new Dictionary(); - - [HarmonyPrefix] - [HarmonyPatch(typeof(InventorySupplier), "CreateRandomInventoryBlockList")] - static void PrefixCreateRandomInventoryBlockList(InventorySupplier __instance) { - if (Main.debug.Value) - Console.WriteLine("InventorySupplier.CreateRandomInventoryBlockList"); - try { - if (!inventoryNumBlockTypes.ContainsKey(__instance)) { - // if (Main.debug.Value) - // Console.WriteLine("Patching; m_NumBlockTypes: {0}", __instance.m_NumBlockTypes); - DoPatchSingle(__instance); - // if (Main.debug.Value) - // Console.WriteLine("Patched; m_NumBlockTypes: {0}", __instance.m_NumBlockTypes); - } - } catch (Exception e) { - Console.WriteLine("Error patching InventorySupplier: {0}\nStack trace: {1}", e.Message, e.StackTrace); - } - } - - public static void DoPatch() { - if (Main.debug.Value) - Console.WriteLine("Modifying {0} InventorySupplier", inventoryNumBlockTypes.Count); - foreach (KeyValuePair keyValuePair in inventoryNumBlockTypes) { - try { - DoRestoreSingle(keyValuePair.Key); - DoPatchSingle(keyValuePair.Key); - } catch (Exception e) { - Console.WriteLine("Error patching InventorySupplier: {0}\nStack trace: {1}", e.Message, - e.StackTrace); - continue; - } - } - } - - static void DoPatchSingle(InventorySupplier inventorySupplier) { - var trav = Traverse.Create(inventorySupplier); - var rarityRange = trav.Field("m_RarityRangeParams").GetValue(); - var blockTypesField = trav.Field("m_RarityRangeParams").Field("m_NumBlockTypes"); - var quantityPerBlockField = trav.Field("m_RarityRangeParams").Field("m_QuantityPerBlockType"); - - if (Main.debug.Value) - Console.WriteLine("Patching {0}; rarityRange: {1}; blockTypesField: {2}; quantityPerBlockField: {3}", - "InventorySupplier", rarityRange, blockTypesField.GetValue(), - quantityPerBlockField.GetValue()); - - if (!inventoryNumBlockTypes.ContainsKey(inventorySupplier)) { - inventoryNumBlockTypes.Add(inventorySupplier, (int)blockTypesField.GetValue()); - if (Main.debug.Value) - Console.WriteLine("Added {0} to inventoryNumBlockTypes with value: {1}", inventorySupplier, - (int)blockTypesField.GetValue()); - } - if (!inventoryQuantityPerBlockType.ContainsKey(inventorySupplier)) { - inventoryQuantityPerBlockType.Add(inventorySupplier, (int)quantityPerBlockField.GetValue()); - if (Main.debug.Value) - Console.WriteLine("Added {0} to inventoryQuantityPerBlockType with value: {1}", inventorySupplier, - (int)quantityPerBlockField.GetValue()); - } - - if (inventoryNumBlockTypes.ContainsKey(inventorySupplier)) { - int newBlockTypesValue = - (int)(inventoryNumBlockTypes[inventorySupplier] * Main.shopBlocksGeneratedTotalMultiplier.Value); - blockTypesField.SetValue(newBlockTypesValue); - if (Main.debug.Value) - Console.WriteLine("Set blockTypesField value to: {0}", newBlockTypesValue); - } - if (inventoryQuantityPerBlockType.ContainsKey(inventorySupplier)) { - int newQuantityPerBlockValue = - (int)(inventoryQuantityPerBlockType[inventorySupplier] * Main.shopPerBlockStopMultiplier.Value); - quantityPerBlockField.SetValue(newQuantityPerBlockValue); - if (Main.debug.Value) - Console.WriteLine("Set quantityPerBlockField value to: {0}", newQuantityPerBlockValue); - } - - if (Main.debug.Value) - Console.WriteLine("Patched {0}; rarityRange: {1}; blockTypesField: {2}; quantityPerBlockField: {3}", - "InventorySupplier", rarityRange, blockTypesField.GetValue(), - quantityPerBlockField.GetValue()); - } - - static void DoRestoreSingle(InventorySupplier inventorySupplier) { - var trav = Traverse.Create(inventorySupplier); - var rarityRange = trav.Field("m_RarityRangeParams").GetValue(); - var blockTypesField = trav.Field("m_RarityRangeParams").Field("m_NumBlockTypes"); - var quantityPerBlockField = trav.Field("m_RarityRangeParams").Field("m_QuantityPerBlockType"); - - if (Main.debug.Value) - Console.WriteLine("Restoring {0}; rarityRange: {1}; blockTypesField: {2}; quantityPerBlockField: {3}", - "InventorySupplier", rarityRange, blockTypesField.GetValue(), - quantityPerBlockField.GetValue()); - if (inventoryNumBlockTypes.ContainsKey(inventorySupplier)) { - blockTypesField.SetValue(inventoryNumBlockTypes[inventorySupplier]); - quantityPerBlockField.SetValue(inventoryQuantityPerBlockType[inventorySupplier]); - if (Main.debug.Value) - Console.WriteLine( - "Restored {0}; rarityRange: {1}; blockTypesField: {2}; quantityPerBlockField: {3}", - "InventorySupplier", rarityRange, blockTypesField.GetValue(), quantityPerBlockField.GetValue()); - } - } - } -} diff --git a/Projects/TerraTech/TerraTech/MagnetPropertiesManager.cs b/Projects/TerraTech/TerraTech/MagnetPropertiesManager.cs deleted file mode 100644 index d5c6377..0000000 --- a/Projects/TerraTech/TerraTech/MagnetPropertiesManager.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Collections.Generic; -using HarmonyLib; - -namespace TerraTech { - [HarmonyPatch] - public class MagnetPropertiesManager { - private static Dictionary strenghts = - new Dictionary(); - private static Dictionary radii = - new Dictionary(); - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleItemHolderMagnet), "OnAttached")] - static void PostfixCreate(ModuleItemHolderMagnet __instance) { - // Console.WriteLine("ModuleItemHolderMagnet.OnAttached"); - if (!strenghts.ContainsKey(__instance)) { - strenghts.Add(__instance, GetStrength(__instance)); - radii.Add(__instance, GetRadius(__instance)); - // Console.WriteLine("Patching {0}; m_Strength: {1}; - // m_Pickup.m_PickupRange: {2}", __instance.name, GetStrength(__instance), - // GetRadius(__instance)); - DoPatchSingle(__instance); - // Console.WriteLine("Patched {0}; m_Strength: {1}; - // m_Pickup.m_PickupRange: {2}", __instance.name, GetStrength(__instance), - // GetRadius(__instance)); - } - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleItemHolderMagnet), "OnDetaching")] - static void PostfixDestroy(ModuleItemHolderMagnet __instance) { - // Console.WriteLine("ModuleItemHolderMagnet.OnDetaching"); - // Console.WriteLine("Restoring {0}; m_Strength: {1}; - // m_Pickup.m_PickupRange: {2}", __instance.name, GetStrength(__instance), - // GetRadius(__instance)); - DoRestoreSingle(__instance); - // Console.WriteLine("Restored {0}; m_Strength: {1}; m_Pickup.m_PickupRange: - // {2}", __instance.name, GetStrength(__instance), GetRadius(__instance)); - strenghts.Remove(__instance); - radii.Remove(__instance); - } - - public static void DoPatch() { - // Console.WriteLine("Modifying {0} ModuleItemHolderMagnet", - // strenghts.Count); - foreach (KeyValuePair keyValuePair in strenghts) { - DoRestoreSingle(keyValuePair.Key); - DoPatchSingle(keyValuePair.Key); - } - } - - static void DoPatchSingle(ModuleItemHolderMagnet moduleItemHolderMagnet) { - SetStrength(moduleItemHolderMagnet, - strenghts[moduleItemHolderMagnet] * Main.magnetStrenghtMultiplier.Value); - SetRadius(moduleItemHolderMagnet, radii[moduleItemHolderMagnet] * Main.magnetRadiusMultiplier.Value); - } - - static void DoRestoreSingle(ModuleItemHolderMagnet moduleItemHolderMagnet) { - if (strenghts.ContainsKey(moduleItemHolderMagnet)) { - SetStrength(moduleItemHolderMagnet, strenghts[moduleItemHolderMagnet]); - } - if (radii.ContainsKey(moduleItemHolderMagnet)) { - SetRadius(moduleItemHolderMagnet, radii[moduleItemHolderMagnet]); - } - } - - private static float GetStrength(ModuleItemHolderMagnet moduleItemHolderMagnet) { - return Traverse.Create(moduleItemHolderMagnet).Field("m_Strength").GetValue() as float ? ?? 0f; - } - - private static void SetStrength(ModuleItemHolderMagnet moduleItemHolderMagnet, float value) { - Traverse.Create(moduleItemHolderMagnet).Field("m_Strength").SetValue(value); - } - - private static float GetRadius(ModuleItemHolderMagnet moduleItemHolderMagnet) { - ModuleItemPickup moduleItemPickup = - Traverse.Create(moduleItemHolderMagnet).Field("m_Pickup").GetValue() as ModuleItemPickup; - if (moduleItemPickup) { - float radius = Traverse.Create(moduleItemPickup).Field("m_PickupRange").GetValue() as float ? ?? 0f; - return radius; - } - return 0f; - } - - private static void SetRadius(ModuleItemHolderMagnet moduleItemHolderMagnet, float value) { - ModuleItemPickup moduleItemPickup = - Traverse.Create(moduleItemHolderMagnet).Field("m_Pickup").GetValue() as ModuleItemPickup; - if (moduleItemPickup) { - Traverse.Create(moduleItemPickup).Field("m_PickupRange").SetValue(value); - } - } - } -} \ No newline at end of file diff --git a/Projects/TerraTech/TerraTech/MinerPropertiesManager.cs b/Projects/TerraTech/TerraTech/MinerPropertiesManager.cs deleted file mode 100644 index c1f4c83..0000000 --- a/Projects/TerraTech/TerraTech/MinerPropertiesManager.cs +++ /dev/null @@ -1,92 +0,0 @@ -using System; -using System.Collections.Generic; -using HarmonyLib; - -namespace TerraTech { - [HarmonyPatch] - public class MinerPropertiesManager { - private static Dictionary area = new Dictionary(); - private static Dictionary speed = new Dictionary(); - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleItemProducer), "GetClosestResourceReservoirInRange")] - static void PostfixCreate(ModuleItemProducer __instance) { - // Console.WriteLine("ModuleItemProducer.GetClosestResourceReservoirInRange"); - if (!area.ContainsKey(__instance)) { - area.Add(__instance, GetArea(__instance)); - speed.Add(__instance, GetSpeed(__instance)); - // Console.WriteLine("Patching {0}; m_ResourceGroundRadius: {1}; - // m_SecPerItemProduced: {2}", __instance.name, GetArea(__instance), - // GetSpeed(__instance)); - DoPatchSingle(__instance); - // Console.WriteLine("Patched {0}; m_ResourceGroundRadius: {1}; - // m_SecPerItemProduced: {2}", __instance.name, GetArea(__instance), - // GetSpeed(__instance)); - } else { - if (GetArea(__instance) == area[__instance]) { - // Console.WriteLine("{0} area reset, patching again... - // m_ResourceGroundRadius: {1}; m_SecPerItemProduced: {2}", - // __instance.name, GetArea(__instance), GetSpeed(__instance)); - DoPatchSingle(__instance); - // Console.WriteLine("Patched {0}; m_ResourceGroundRadius: {1}; - // m_SecPerItemProduced: {2}", __instance.name, GetArea(__instance), - // GetSpeed(__instance)); - } - if (GetSpeed(__instance) == speed[__instance]) { - // Console.WriteLine("{0} speed reset, patching again... - // m_ResourceGroundRadius: {1}; m_SecPerItemProduced: {2}", - // __instance.name, GetArea(__instance), GetSpeed(__instance)); - DoPatchSingle(__instance); - // Console.WriteLine("Patched {0}; m_ResourceGroundRadius: {1}; - // m_SecPerItemProduced: {2}", __instance.name, GetArea(__instance), - // GetSpeed(__instance)); - } - } - } - - [HarmonyPostfix] - [HarmonyPatch(typeof(ModuleItemProducer), "OnDetaching")] - static void PostfixDestroy(ModuleItemProducer __instance) { - // Console.WriteLine("ModuleItemProducer.OnRecycle"); - DoRestoreSingle(__instance); - area.Remove(__instance); - speed.Remove(__instance); - } - - public static void DoPatch() { - // Console.WriteLine("Modifying {0} ModuleItemProducer", area.Count); - foreach (KeyValuePair keyValuePair in area) { - DoRestoreSingle(keyValuePair.Key); - DoPatchSingle(keyValuePair.Key); - } - } - - static void DoPatchSingle(ModuleItemProducer moduleItemProducer) { - SetArea(moduleItemProducer, area[moduleItemProducer] * Main.minerGroundArea.Value); - SetSpeed(moduleItemProducer, speed[moduleItemProducer] / Main.minerMiningSpeed.Value); - } - - static void DoRestoreSingle(ModuleItemProducer moduleItemProducer) { - if (area.ContainsKey(moduleItemProducer)) { - SetArea(moduleItemProducer, area[moduleItemProducer]); - SetSpeed(moduleItemProducer, speed[moduleItemProducer]); - } - } - - private static float GetArea(ModuleItemProducer moduleItemProducer) { - return Traverse.Create(moduleItemProducer).Field("m_ResourceGroundRadius").GetValue() as float ? ?? 0f; - } - - private static void SetArea(ModuleItemProducer moduleItemProducer, float value) { - Traverse.Create(moduleItemProducer).Field("m_ResourceGroundRadius").SetValue(value); - } - - private static float GetSpeed(ModuleItemProducer moduleItemProducer) { - return Traverse.Create(moduleItemProducer).Field("m_SecPerItemProduced").GetValue() as float ? ?? 0f; - } - - private static void SetSpeed(ModuleItemProducer moduleItemProducer, float value) { - Traverse.Create(moduleItemProducer).Field("m_SecPerItemProduced").SetValue(value); - } - } -} \ No newline at end of file diff --git a/Projects/TerraTech/TerraTech/ModuleEnergy.cs b/Projects/TerraTech/TerraTech/ModuleEnergy.cs deleted file mode 100644 index 4abe749..0000000 --- a/Projects/TerraTech/TerraTech/ModuleEnergy.cs +++ /dev/null @@ -1,78 +0,0 @@ -using System; -using System.Collections.Generic; -using HarmonyLib; - -namespace TerraTech { - [HarmonyPatch] - public class ModuleEnergy { - private static Dictionary powerUpDelay = new Dictionary(); - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleEnergy), "OnAttached")] - static void PostfixCreate(ModuleEnergy __instance) { - var trav = Traverse.Create(__instance); - var powerUpDelayField = trav.Field("m_PowerUpDelay"); - - if (Main.debug.Value) - Console.WriteLine("ModuleEnergy.OnAttached"); - - if (!powerUpDelay.ContainsKey(__instance)) { - powerUpDelay.Add(__instance, (float)powerUpDelayField.GetValue()); - if (Main.debug.Value) - Console.WriteLine("Patching {0}; m_PowerUpDelay: {1}", __instance.ToString(), - (float)powerUpDelayField.GetValue()); - } - - DoPatchSingle(__instance); - - if (Main.debug.Value) - Console.WriteLine("Patched {0}; m_PowerUpDelay: {1}", __instance.ToString(), - (float)powerUpDelayField.GetValue()); - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleEnergy), "OnDetaching")] - static void PostfixDestroy(ModuleEnergy __instance) { - var trav = Traverse.Create(__instance); - var powerUpDelayField = trav.Field("m_PowerUpDelay"); - - if (Main.debug.Value) - Console.WriteLine("ModuleEnergy.OnDetaching"); - if (Main.debug.Value) - Console.WriteLine("Restoring {0}; m_PowerUpDelay: {1}", __instance.ToString(), - (float)powerUpDelayField.GetValue()); - - DoRestoreSingle(__instance); - - if (Main.debug.Value) - Console.WriteLine("Restored {0}; m_PowerUpDelay: {1}", __instance.ToString(), - (float)powerUpDelayField.GetValue()); - - powerUpDelay.Remove(__instance); - } - - public static void DoPatch() { - if (Main.debug.Value) - Console.WriteLine("Modifying {0} ModuleEnergy", powerUpDelay.Count); - foreach (KeyValuePair keyValuePair in powerUpDelay) { - DoRestoreSingle(keyValuePair.Key); - DoPatchSingle(keyValuePair.Key); - } - } - - static void DoPatchSingle(ModuleEnergy moduleEnergy) { - var trav = Traverse.Create(moduleEnergy); - var powerUpDelayField = trav.Field("m_PowerUpDelay"); - - powerUpDelayField.SetValue(powerUpDelay[moduleEnergy] * Main.powerUpDelayMultiplier.Value); - } - - static void DoRestoreSingle(ModuleEnergy moduleEnergy) { - var trav = Traverse.Create(moduleEnergy); - var powerUpDelayField = trav.Field("m_PowerUpDelay"); - - if (powerUpDelay.ContainsKey(moduleEnergy)) - powerUpDelayField.SetValue(powerUpDelay[moduleEnergy]); - } - } -} diff --git a/Projects/TerraTech/TerraTech/ModuleEnergyStoreManager.cs b/Projects/TerraTech/TerraTech/ModuleEnergyStoreManager.cs deleted file mode 100644 index 3dcd180..0000000 --- a/Projects/TerraTech/TerraTech/ModuleEnergyStoreManager.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Collections.Generic; -using HarmonyLib; - -namespace TerraTech { - [HarmonyPatch] - public class ModuleEnergyStoreManager { - private static Dictionary batteryCapacity = - new Dictionary(); - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleEnergyStore), "OnAttached")] - static void PostfixCreate(ModuleEnergyStore __instance) { - if (Main.debug.Value) - Console.WriteLine("ModuleEnergyStore.OnAttached"); - if (!batteryCapacity.ContainsKey(__instance)) { - batteryCapacity.Add(__instance, __instance.m_BatteryCapacity); - if (Main.debug.Value) - Console.WriteLine("Patching {0}; m_BatteryCapacity: {1}", __instance.ToString(), - __instance.m_BatteryCapacity); - } - - DoPatchSingle(__instance); - - if (Main.debug.Value) - Console.WriteLine("Patched {0}; m_BatteryCapacity: {1}", __instance.ToString(), - __instance.m_BatteryCapacity); - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleEnergyStore), "OnDetaching")] - static void PostfixDestroy(ModuleEnergyStore __instance) { - if (Main.debug.Value) - Console.WriteLine("ModuleEnergyStore.OnDetaching"); - if (Main.debug.Value) - Console.WriteLine("Restoring {0}; m_BatteryCapacity: {1}", __instance.ToString(), - __instance.m_BatteryCapacity); - - DoRestoreSingle(__instance); - - if (Main.debug.Value) - Console.WriteLine("Restored {0}; m_BatteryCapacity: {1}", __instance.ToString(), - __instance.m_BatteryCapacity); - - batteryCapacity.Remove(__instance); - } - - public static void DoPatch() { - if (Main.debug.Value) - Console.WriteLine("Modifying {0} ModuleEnergyStore", batteryCapacity.Count); - foreach (KeyValuePair keyValuePair in batteryCapacity) { - DoRestoreSingle(keyValuePair.Key); - DoPatchSingle(keyValuePair.Key); - } - } - - static void DoPatchSingle(ModuleEnergyStore moduleEnergyStore) { - moduleEnergyStore.m_BatteryCapacity = - batteryCapacity[moduleEnergyStore] * Main.batteryCapacityMultiplier.Value; - } - - static void DoRestoreSingle(ModuleEnergyStore moduleEnergyStore) { - if (batteryCapacity.ContainsKey(moduleEnergyStore)) - moduleEnergyStore.m_BatteryCapacity = batteryCapacity[moduleEnergyStore]; - } - } -} diff --git a/Projects/TerraTech/TerraTech/TerraTech.csproj b/Projects/TerraTech/TerraTech/TerraTech.csproj index d575277..d8f4dab 100644 --- a/Projects/TerraTech/TerraTech/TerraTech.csproj +++ b/Projects/TerraTech/TerraTech/TerraTech.csproj @@ -37,25 +37,12 @@ 4 - - - - - - - - - - - - - diff --git a/Projects/TerraTech/TerraTech/ThrusterPropertiesManager.cs b/Projects/TerraTech/TerraTech/ThrusterPropertiesManager.cs deleted file mode 100644 index 25f17a1..0000000 --- a/Projects/TerraTech/TerraTech/ThrusterPropertiesManager.cs +++ /dev/null @@ -1,94 +0,0 @@ -using System; -using System.Collections.Generic; -using HarmonyLib; - -namespace TerraTech { - [HarmonyPatch] - public class ThrusterPropertiesManager { - private static Dictionary> boosters = - new Dictionary>(); - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleBooster), "OnAttached")] - static void PostfixCreate(ModuleBooster __instance) { - // Console.WriteLine("ModuleBooster.OnAttached"); - if (!boosters.ContainsKey(__instance)) { - boosters.Add(__instance, Map(__instance)); - // Console.WriteLine("Patching {0}; force: {1}", __instance.name, - // GetForceAsString(__instance)); - DoPatchSingle(__instance); - // Console.WriteLine("Patched {0}; force: {1}", __instance.name, - // GetForceAsString(__instance)); - } - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleBooster), "OnDetaching")] - static void PostfixDestroy(ModuleBooster __instance) { - // Console.WriteLine("ModuleBooster.OnDetaching"); - // Console.WriteLine("Restoring {0}; force: {1}", __instance.name, - // GetForceAsString(__instance)); - DoRestoreSingle(__instance); - // Console.WriteLine("Restored {0}; force: {1}", __instance.name, - // GetForceAsString(__instance)); - boosters.Remove(__instance); - } - - public static void DoPatch() { - // Console.WriteLine("Modifying {0} ModuleBooster", boosters.Count); - foreach (KeyValuePair> keyValuePair in boosters) { - DoRestoreSingle(keyValuePair.Key); - DoPatchSingle(keyValuePair.Key); - } - } - - static void DoPatchSingle(ModuleBooster moduleBooster) { - List jets = GetValue(moduleBooster); - for (var i = 0; i < jets.Count; i++) { - boosters[moduleBooster][jets[i]] = GetValue(jets[i]); - SetValue(jets[i], GetValue(jets[i]) * Main.jetThrustMultiplier.Value); - } - SetValue(moduleBooster, jets); - } - - static void DoRestoreSingle(ModuleBooster moduleBooster) { - if (boosters.ContainsKey(moduleBooster)) { - foreach (BoosterJet boosterJet in GetValue(moduleBooster)) { - SetValue(boosterJet, boosters[moduleBooster][boosterJet]); - } - } - } - - private static Dictionary Map(ModuleBooster moduleBooster) { - Dictionary jets = new Dictionary(); - foreach (BoosterJet boosterJet in GetValue(moduleBooster)) { - jets.Add(boosterJet, GetValue(boosterJet)); - } - return jets; - } - - private static List GetValue(ModuleBooster moduleBooster) { - return Traverse.Create(moduleBooster).Field("jets").GetValue() as List; - } - - private static void SetValue(ModuleBooster moduleBooster, List value) { - Traverse.Create(moduleBooster).Field("jets").SetValue(value); - } - - private static float GetValue(BoosterJet boosterJet) { - return Traverse.Create(boosterJet).Field("m_Force").GetValue() as float ? ?? 0f; - } - - private static void SetValue(BoosterJet boosterJet, float value) { - Traverse.Create(boosterJet).Field("m_Force").SetValue(value); - } - - private static string GetForceAsString(ModuleBooster moduleBooster) { - string result = ""; - foreach (BoosterJet boosterJet in GetValue(moduleBooster)) { - result += GetValue(boosterJet) + ", "; - } - return result; - } - } -} \ No newline at end of file diff --git a/Projects/TerraTech/TerraTech/WeaponPropertiesManager.cs b/Projects/TerraTech/TerraTech/WeaponPropertiesManager.cs deleted file mode 100644 index 9363d48..0000000 --- a/Projects/TerraTech/TerraTech/WeaponPropertiesManager.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Collections.Generic; -using BepInEx.Configuration; -using HarmonyLib; - -namespace TerraTech { - [HarmonyPatch] - public class WeaponPropertiesManager { - private static Dictionary shotCooldown = new Dictionary(); - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleWeapon), "OnAttached")] - static void PostfixCreate(ModuleWeapon __instance) { - // Console.WriteLine("ModuleWeaponGun.OnAttached"); - if (!shotCooldown.ContainsKey(__instance)) { - shotCooldown.Add(__instance, __instance.m_ShotCooldown); - // Console.WriteLine("Patching {0}; m_ShotCooldown: {1}", __instance.name, - // __instance.m_ShotCooldown); - DoPatchSingle(__instance); - // Console.WriteLine("Patched {0}; m_ShotCooldown: {1}", __instance.name, - // __instance.m_ShotCooldown); - } - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleWeapon), "OnDetaching")] - static void PostfixDestroy(ModuleWeapon __instance) { - // Console.WriteLine("ModuleWeaponGun.OnDetaching"); - // Console.WriteLine("Restoring {0}; m_ShotCooldown: {1}", __instance.name, - // __instance.m_ShotCooldown); - DoRestoreSingle(__instance); - // Console.WriteLine("Restored {0}; m_ShotCooldown: {1}", __instance.name, - // __instance.m_ShotCooldown); - shotCooldown.Remove(__instance); - } - - public static void DoPatch() { - // Console.WriteLine("Modifying {0} ModuleWeaponGun", shotCooldown.Count); - foreach (KeyValuePair keyValuePair in shotCooldown) { - DoRestoreSingle(keyValuePair.Key); - DoPatchSingle(keyValuePair.Key); - } - } - - static void DoPatchSingle(ModuleWeapon moduleWeapon) { - if (Main.debug.Value) - Console.WriteLine("Patching {0}; m_ShotCooldown: {1}", moduleWeapon.name, moduleWeapon.m_ShotCooldown); - moduleWeapon.m_ShotCooldown = shotCooldown[moduleWeapon] / Main.shootingSpeedMultiplier.Value; - moduleWeapon.m_RotateSpeed *= Main.weaponRotationSpeedMultiplier.Value; - if (Main.debug.Value) - Console.WriteLine("Patched {0}; m_ShotCooldown: {1}", moduleWeapon.name, moduleWeapon.m_ShotCooldown); - } - - static void DoRestoreSingle(ModuleWeapon moduleWeapon) { - if (Main.debug.Value) - Console.WriteLine("Restoring {0}; m_ShotCooldown: {1}", moduleWeapon.name, moduleWeapon.m_ShotCooldown); - if (shotCooldown.ContainsKey(moduleWeapon)) { - moduleWeapon.m_ShotCooldown = shotCooldown[moduleWeapon]; - if (Main.debug.Value) - Console.WriteLine("Restored {0}; m_ShotCooldown: {1}", moduleWeapon.name, - moduleWeapon.m_ShotCooldown); - } - } - } -} diff --git a/Projects/TerraTech/TerraTech/WheelPropertiesManager.cs b/Projects/TerraTech/TerraTech/WheelPropertiesManager.cs deleted file mode 100644 index b151a6b..0000000 --- a/Projects/TerraTech/TerraTech/WheelPropertiesManager.cs +++ /dev/null @@ -1,67 +0,0 @@ -using System; -using System.Collections.Generic; -using HarmonyLib; - -namespace TerraTech { - [HarmonyPatch] - public class WheelPropertiesManager { - private static Dictionary torques = new Dictionary(); - private static Dictionary maxRpm = new Dictionary(); - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleWheels), "OnAttached")] - static void PostfixCreate(ModuleWheels __instance) { - // Console.WriteLine("ModuleWheels.OnAttached"); - if (!torques.ContainsKey(__instance)) { - torques.Add(__instance, __instance.m_TorqueParams.torqueCurveMaxTorque); - maxRpm.Add(__instance, __instance.m_TorqueParams.torqueCurveMaxRpm); - // Console.WriteLine("Patching {0}; m_TorqueParams.torqueCurveMaxTorque: - // {1}; m_TorqueParams.torqueCurveMaxRpm: {2}", __instance.name, - // __instance.m_TorqueParams.torqueCurveMaxTorque, - // __instance.m_TorqueParams.torqueCurveMaxRpm); - DoPatchSingle(__instance); - // Console.WriteLine("Patched {0}; m_TorqueParams.torqueCurveMaxTorque: - // {1}; m_TorqueParams.torqueCurveMaxRpm: {2}", __instance.name, - // __instance.m_TorqueParams.torqueCurveMaxTorque, - // __instance.m_TorqueParams.torqueCurveMaxRpm); - } - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleWheels), "OnDetaching")] - static void PostfixDestroy(ModuleWheels __instance) { - // Console.WriteLine("ModuleWheels.OnDetaching"); - // Console.WriteLine("Restoring {0}; m_TorqueParams.torqueCurveMaxTorque: - // {1}; m_TorqueParams.torqueCurveMaxRpm: {2}", __instance.name, - // __instance.m_TorqueParams.torqueCurveMaxTorque, - // __instance.m_TorqueParams.torqueCurveMaxRpm); - DoRestoreSingle(__instance); - // Console.WriteLine("Restored {0}; m_TorqueParams.torqueCurveMaxTorque: - // {1}; m_TorqueParams.torqueCurveMaxRpm: {2}", __instance.name, - // __instance.m_TorqueParams.torqueCurveMaxTorque, - // __instance.m_TorqueParams.torqueCurveMaxRpm); - torques.Remove(__instance); - maxRpm.Remove(__instance); - } - - public static void DoPatch() { - // Console.WriteLine("Modifying {0} ModuleWheels", torques.Count); - foreach (KeyValuePair keyValuePair in torques) { - DoRestoreSingle(keyValuePair.Key); - DoPatchSingle(keyValuePair.Key); - } - } - - static void DoPatchSingle(ModuleWheels moduleWheels) { - moduleWheels.m_TorqueParams.torqueCurveMaxRpm = maxRpm[moduleWheels] * Main.wheelSpeedMultiplier.Value; - moduleWheels.m_TorqueParams.torqueCurveMaxTorque = torques[moduleWheels] * Main.wheelTorqueMultiplier.Value; - } - - static void DoRestoreSingle(ModuleWheels moduleWheels) { - if (torques.ContainsKey(moduleWheels)) { - moduleWheels.m_TorqueParams.torqueCurveMaxTorque = torques[moduleWheels]; - moduleWheels.m_TorqueParams.torqueCurveMaxRpm = maxRpm[moduleWheels]; - } - } - } -} \ No newline at end of file diff --git a/Projects/TerraTech/TerraTech/WirelessChargerPropertiesManager.cs b/Projects/TerraTech/TerraTech/WirelessChargerPropertiesManager.cs deleted file mode 100644 index 12fb45c..0000000 --- a/Projects/TerraTech/TerraTech/WirelessChargerPropertiesManager.cs +++ /dev/null @@ -1,69 +0,0 @@ -using System.Collections.Generic; -using HarmonyLib; - -// TODO: Fix this, no workey -namespace TerraTech { - [HarmonyPatch] - public class WirelessChargerPropertiesManager { - private static Dictionary radius = new Dictionary(); - private static Dictionary transferPerArc = - new Dictionary(); - private static Dictionary arcFiringInterval = - new Dictionary(); - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleRemoteCharger), "OnAttached")] - static void PostfixCreate(ModuleRemoteCharger __instance) { - // Console.WriteLine("ModuleRemoteCharger.OnAttached"); - if (!radius.ContainsKey(__instance)) { - radius.Add(__instance, __instance.m_ChargingRadius); - transferPerArc.Add(__instance, __instance.m_PowerTransferPerArc); - arcFiringInterval.Add(__instance, __instance.m_ArcFiringInterval); - // Console.WriteLine("Patching {0}; m_RefillRate: {1}; m_Capacity: {2}", - // __instance.name, __instance.m_RefillRate, __instance.m_Capacity); - DoPatchSingle(__instance); - // Console.WriteLine("Patched {0}; m_RefillRate: {1}; m_Capacity: {2}", - // __instance.name, __instance.m_RefillRate, __instance.m_Capacity); - } - } - - [HarmonyPrefix] - [HarmonyPatch(typeof(ModuleRemoteCharger), "OnDetaching")] - static void PostfixDestroy(ModuleRemoteCharger __instance) { - // Console.WriteLine("ModuleRemoteCharger.OnAttached"); - // Console.WriteLine("Restoring {0}; m_RefillRate: {1}; m_Capacity: {2}", - // __instance.name, __instance.m_RefillRate, __instance.m_Capacity); - DoRestoreSingle(__instance); - // Console.WriteLine("Restored {0}; m_RefillRate: {1}; m_Capacity: {2}", - // __instance.name, __instance.m_RefillRate, __instance.m_Capacity); - radius.Remove(__instance); - transferPerArc.Remove(__instance); - arcFiringInterval.Remove(__instance); - } - - public static void DoPatch() { - // Console.WriteLine("Modifying {0} ModuleRemoteCharger", radius.Count); - foreach (KeyValuePair keyValuePair in radius) { - DoRestoreSingle(keyValuePair.Key); - DoPatchSingle(keyValuePair.Key); - } - } - - static void DoPatchSingle(ModuleRemoteCharger moduleRemoteCharger) { - moduleRemoteCharger.m_ChargingRadius = - radius[moduleRemoteCharger] * Main.wirelessChargingRadiusMultiplier.Value; - moduleRemoteCharger.m_PowerTransferPerArc = - radius[moduleRemoteCharger] * Main.wirelessChargingPowerPerArcMultiplier.Value; - moduleRemoteCharger.m_ArcFiringInterval = - radius[moduleRemoteCharger] * Main.wirelessChargingArcFiringIntervalMultiplier.Value; - } - - static void DoRestoreSingle(ModuleRemoteCharger moduleRemoteCharger) { - if (radius.ContainsKey(moduleRemoteCharger)) { - moduleRemoteCharger.m_ChargingRadius = radius[moduleRemoteCharger]; - moduleRemoteCharger.m_PowerTransferPerArc = radius[moduleRemoteCharger]; - moduleRemoteCharger.m_ArcFiringInterval = radius[moduleRemoteCharger]; - } - } - } -} \ No newline at end of file