Add battery capacity multiplier configuration
This commit is contained in:
@@ -42,6 +42,7 @@ namespace TerraTech {
|
|||||||
public static ConfigEntry<float> shieldRadiusMultiplier;
|
public static ConfigEntry<float> shieldRadiusMultiplier;
|
||||||
public static ConfigEntry<float> shieldHeartbeatIntervalMultiplier;
|
public static ConfigEntry<float> shieldHeartbeatIntervalMultiplier;
|
||||||
public static ConfigEntry<float> powerUpDelayMultiplier;
|
public static ConfigEntry<float> powerUpDelayMultiplier;
|
||||||
|
public static ConfigEntry<float> batteryCapacityMultiplier;
|
||||||
public static ConfigEntry<float> weaponRotationSpeedMultiplier;
|
public static ConfigEntry<float> weaponRotationSpeedMultiplier;
|
||||||
public static ConfigEntry<float> shopBlocksGeneratedTotalMultiplier;
|
public static ConfigEntry<float> shopBlocksGeneratedTotalMultiplier;
|
||||||
public static ConfigEntry<float> shopPerBlockStopMultiplier;
|
public static ConfigEntry<float> shopPerBlockStopMultiplier;
|
||||||
@@ -151,6 +152,9 @@ namespace TerraTech {
|
|||||||
powerUpDelayMultiplier = Config.Bind(
|
powerUpDelayMultiplier = Config.Bind(
|
||||||
"PowerUp", "Power Up Delay Multiplier", 1f,
|
"PowerUp", "Power Up Delay Multiplier", 1f,
|
||||||
new ConfigDescription("Power Up Delay Multiplier", new AcceptableValueRange<float>(0.001f, 32f)));
|
new ConfigDescription("Power Up Delay Multiplier", new AcceptableValueRange<float>(0.001f, 32f)));
|
||||||
|
batteryCapacityMultiplier = Config.Bind(
|
||||||
|
"PowerUp", "Battery Capacity Multiplier", 1f,
|
||||||
|
new ConfigDescription("Battery Capacity Multiplier", new AcceptableValueRange<float>(0.001f, 32f)));
|
||||||
|
|
||||||
shootingSpeedMultiplier.SettingChanged += (sender, args) => WeaponPropertiesManager.DoPatch();
|
shootingSpeedMultiplier.SettingChanged += (sender, args) => WeaponPropertiesManager.DoPatch();
|
||||||
weaponRotationSpeedMultiplier.SettingChanged += (sender, args) => WeaponPropertiesManager.DoPatch();
|
weaponRotationSpeedMultiplier.SettingChanged += (sender, args) => WeaponPropertiesManager.DoPatch();
|
||||||
|
@@ -5,8 +5,7 @@ using HarmonyLib;
|
|||||||
namespace TerraTech {
|
namespace TerraTech {
|
||||||
[HarmonyPatch]
|
[HarmonyPatch]
|
||||||
public class ModuleEnergy {
|
public class ModuleEnergy {
|
||||||
private static Dictionary<ModuleEnergy, float> powerUpDelay =
|
private static Dictionary<ModuleEnergy, float> powerUpDelay = new Dictionary<ModuleEnergy, float>();
|
||||||
new Dictionary<ModuleEnergy, float>();
|
|
||||||
|
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ModuleEnergy), "OnAttached")]
|
[HarmonyPatch(typeof(ModuleEnergy), "OnAttached")]
|
||||||
|
65
Projects/TerraTech/TerraTech/ModuleEnergyStoreManager.cs
Normal file
65
Projects/TerraTech/TerraTech/ModuleEnergyStoreManager.cs
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
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];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -46,6 +46,7 @@
|
|||||||
<Compile Include="MagnetPropertiesManager.cs" />
|
<Compile Include="MagnetPropertiesManager.cs" />
|
||||||
<Compile Include="MinerPropertiesManager.cs" />
|
<Compile Include="MinerPropertiesManager.cs" />
|
||||||
<Compile Include="ModuleEnergy.cs" />
|
<Compile Include="ModuleEnergy.cs" />
|
||||||
|
<Compile Include="ModuleEnergyStoreManager.cs" />
|
||||||
<Compile Include="ModuleShieldGeneratorManager.cs" />
|
<Compile Include="ModuleShieldGeneratorManager.cs" />
|
||||||
<Compile Include="Patches.cs" />
|
<Compile Include="Patches.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
Reference in New Issue
Block a user