Add shield and energy module configuration multipliers
This commit is contained in:
@@ -39,6 +39,9 @@ namespace TerraTech {
|
|||||||
public static ConfigEntry<float> wirelessChargingRadiusMultiplier;
|
public static ConfigEntry<float> wirelessChargingRadiusMultiplier;
|
||||||
public static ConfigEntry<float> wirelessChargingPowerPerArcMultiplier;
|
public static ConfigEntry<float> wirelessChargingPowerPerArcMultiplier;
|
||||||
public static ConfigEntry<float> wirelessChargingArcFiringIntervalMultiplier;
|
public static ConfigEntry<float> wirelessChargingArcFiringIntervalMultiplier;
|
||||||
|
public static ConfigEntry<float> shieldRadiusMultiplier;
|
||||||
|
public static ConfigEntry<float> shieldHeartbeatIntervalMultiplier;
|
||||||
|
public static ConfigEntry<float> powerUpDelayMultiplier;
|
||||||
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;
|
||||||
@@ -138,6 +141,17 @@ namespace TerraTech {
|
|||||||
"Shop", "Shop Per Block Stop Multiplier", 1f,
|
"Shop", "Shop Per Block Stop Multiplier", 1f,
|
||||||
new ConfigDescription("Shop Per Block Stop Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
new ConfigDescription("Shop Per Block Stop Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
||||||
|
|
||||||
|
shieldRadiusMultiplier = Config.Bind(
|
||||||
|
"Shield", "Shield Radius Multiplier", 1f,
|
||||||
|
new ConfigDescription("Shield Radius Multiplier", new AcceptableValueRange<float>(0.001f, 32f)));
|
||||||
|
shieldHeartbeatIntervalMultiplier =
|
||||||
|
Config.Bind("Shield", "Shield Heartbeat Interval Multiplier", 1f,
|
||||||
|
new ConfigDescription("Shield Heartbeat Interval Multiplier",
|
||||||
|
new AcceptableValueRange<float>(0.001f, 32f)));
|
||||||
|
powerUpDelayMultiplier = Config.Bind(
|
||||||
|
"PowerUp", "Power Up Delay Multiplier", 1f,
|
||||||
|
new ConfigDescription("Power Up Delay 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();
|
||||||
energyGenMultiplier.SettingChanged += (sender, args) => GeneratorPropertiesManager.DoPatch();
|
energyGenMultiplier.SettingChanged += (sender, args) => GeneratorPropertiesManager.DoPatch();
|
||||||
|
79
Projects/TerraTech/TerraTech/ModuleEnergy.cs
Normal file
79
Projects/TerraTech/TerraTech/ModuleEnergy.cs
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using HarmonyLib;
|
||||||
|
|
||||||
|
namespace TerraTech {
|
||||||
|
[HarmonyPatch]
|
||||||
|
public class ModuleEnergy {
|
||||||
|
private static Dictionary<ModuleEnergy, float> powerUpDelay =
|
||||||
|
new Dictionary<ModuleEnergy, float>();
|
||||||
|
|
||||||
|
[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<ModuleEnergy, float> 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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
116
Projects/TerraTech/TerraTech/ModuleShieldGeneratorManager.cs
Normal file
116
Projects/TerraTech/TerraTech/ModuleShieldGeneratorManager.cs
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using HarmonyLib;
|
||||||
|
|
||||||
|
namespace TerraTech {
|
||||||
|
[HarmonyPatch]
|
||||||
|
public class ModuleShieldGeneratorManager {
|
||||||
|
private static Dictionary<ModuleShieldGenerator, float> healingHeartbeatInterval =
|
||||||
|
new Dictionary<ModuleShieldGenerator, float>();
|
||||||
|
private static Dictionary<ModuleShieldGenerator, float> radius = new Dictionary<ModuleShieldGenerator, float>();
|
||||||
|
private static Dictionary<ModuleShieldGenerator, float> powerUpDelay =
|
||||||
|
new Dictionary<ModuleShieldGenerator, float>();
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(ModuleShieldGenerator), "OnAttached")]
|
||||||
|
static void PostfixCreate(ModuleShieldGenerator __instance) {
|
||||||
|
var trav = Traverse.Create(__instance);
|
||||||
|
var powerUpDelayField = trav.Field("m_PowerUpDelay");
|
||||||
|
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine("ModuleShieldGenerator.OnAttached");
|
||||||
|
if (!healingHeartbeatInterval.ContainsKey(__instance)) {
|
||||||
|
healingHeartbeatInterval.Add(__instance, __instance.m_HealingHeartbeatInterval);
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine("Patching {0}; m_HealingHeartbeatInterval: {1}", __instance.ToString(),
|
||||||
|
__instance.m_HealingHeartbeatInterval);
|
||||||
|
}
|
||||||
|
if (!radius.ContainsKey(__instance)) {
|
||||||
|
radius.Add(__instance, __instance.m_Radius);
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine("Patching {0}; m_Radius: {1}", __instance.ToString(), __instance.m_Radius);
|
||||||
|
}
|
||||||
|
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_HealingHeartbeatInterval: {1}", __instance.ToString(),
|
||||||
|
__instance.m_HealingHeartbeatInterval);
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine("Patched {0}; m_Radius: {1}", __instance.ToString(), __instance.m_Radius);
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine("Patched {0}; m_PowerUpDelay: {1}", __instance.ToString(),
|
||||||
|
(float)powerUpDelayField.GetValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(ModuleShieldGenerator), "OnDetaching")]
|
||||||
|
static void PostfixDestroy(ModuleShieldGenerator __instance) {
|
||||||
|
var trav = Traverse.Create(__instance);
|
||||||
|
var powerUpDelayField = trav.Field("m_PowerUpDelay");
|
||||||
|
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine("ModuleShieldGenerator.OnDetaching");
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine("Restoring {0}; m_HealingHeartbeatInterval: {1}", __instance.ToString(),
|
||||||
|
__instance.m_HealingHeartbeatInterval);
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine("Restoring {0}; m_Radius: {1}", __instance.ToString(), __instance.m_Radius);
|
||||||
|
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_HealingHeartbeatInterval: {1}", __instance.ToString(),
|
||||||
|
__instance.m_HealingHeartbeatInterval);
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine("Restored {0}; m_Radius: {1}", __instance.ToString(), __instance.m_Radius);
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine("Restored {0}; m_PowerUpDelay: {1}", __instance.ToString(),
|
||||||
|
(float)powerUpDelayField.GetValue());
|
||||||
|
|
||||||
|
healingHeartbeatInterval.Remove(__instance);
|
||||||
|
radius.Remove(__instance);
|
||||||
|
powerUpDelay.Remove(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void DoPatch() {
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine("Modifying {0} ModuleShieldGenerator", healingHeartbeatInterval.Count);
|
||||||
|
foreach (KeyValuePair<ModuleShieldGenerator, float> keyValuePair in healingHeartbeatInterval) {
|
||||||
|
DoRestoreSingle(keyValuePair.Key);
|
||||||
|
DoPatchSingle(keyValuePair.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DoPatchSingle(ModuleShieldGenerator moduleShieldGenerator) {
|
||||||
|
var trav = Traverse.Create(moduleShieldGenerator);
|
||||||
|
var powerUpDelayField = trav.Field("m_PowerUpDelay");
|
||||||
|
|
||||||
|
moduleShieldGenerator.m_HealingHeartbeatInterval =
|
||||||
|
healingHeartbeatInterval[moduleShieldGenerator] * Main.shieldHeartbeatIntervalMultiplier.Value;
|
||||||
|
moduleShieldGenerator.m_Radius = radius[moduleShieldGenerator] * Main.shieldRadiusMultiplier.Value;
|
||||||
|
powerUpDelayField.SetValue(powerUpDelay[moduleShieldGenerator] * Main.powerUpDelayMultiplier.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DoRestoreSingle(ModuleShieldGenerator moduleShieldGenerator) {
|
||||||
|
var trav = Traverse.Create(moduleShieldGenerator);
|
||||||
|
var powerUpDelayField = trav.Field("m_PowerUpDelay");
|
||||||
|
|
||||||
|
if (healingHeartbeatInterval.ContainsKey(moduleShieldGenerator))
|
||||||
|
moduleShieldGenerator.m_HealingHeartbeatInterval = healingHeartbeatInterval[moduleShieldGenerator];
|
||||||
|
if (radius.ContainsKey(moduleShieldGenerator))
|
||||||
|
moduleShieldGenerator.m_Radius = radius[moduleShieldGenerator];
|
||||||
|
if (powerUpDelay.ContainsKey(moduleShieldGenerator))
|
||||||
|
powerUpDelayField.SetValue(powerUpDelay[moduleShieldGenerator]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -45,6 +45,8 @@
|
|||||||
<Compile Include="InventorySupplierPropertiesManager.cs" />
|
<Compile Include="InventorySupplierPropertiesManager.cs" />
|
||||||
<Compile Include="MagnetPropertiesManager.cs" />
|
<Compile Include="MagnetPropertiesManager.cs" />
|
||||||
<Compile Include="MinerPropertiesManager.cs" />
|
<Compile Include="MinerPropertiesManager.cs" />
|
||||||
|
<Compile Include="ModuleEnergy.cs" />
|
||||||
|
<Compile Include="ModuleShieldGeneratorManager.cs" />
|
||||||
<Compile Include="Patches.cs" />
|
<Compile Include="Patches.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
<Compile Include="SeekingProjectileManager.cs" />
|
<Compile Include="SeekingProjectileManager.cs" />
|
||||||
|
Reference in New Issue
Block a user