Remove old shit

This commit is contained in:
2025-02-24 08:30:46 +01:00
parent fd8ce5c59e
commit e0b9bed690
15 changed files with 40 additions and 1016 deletions

View File

@@ -1,67 +0,0 @@
using System;
using System.Collections.Generic;
using HarmonyLib;
namespace TerraTech {
[HarmonyPatch]
public class ModuleEnergyStoreManager {
private static Dictionary<ModuleEnergyStore, float> batteryCapacity =
new Dictionary<ModuleEnergyStore, float>();
[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<ModuleEnergyStore, float> 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];
}
}
}