Remove old shit
This commit is contained in:
@@ -1,90 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using HarmonyLib;
|
|
||||||
|
|
||||||
namespace TerraTech {
|
|
||||||
[HarmonyPatch]
|
|
||||||
public class BeamPropertiesManager {
|
|
||||||
private static Dictionary<ModuleItemHolderBeam, float> strenghts =
|
|
||||||
new Dictionary<ModuleItemHolderBeam, float>();
|
|
||||||
private static Dictionary<ModuleItemHolderBeam, float> radii = new Dictionary<ModuleItemHolderBeam, float>();
|
|
||||||
|
|
||||||
[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<ModuleItemHolderBeam, float> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -39,14 +39,16 @@ 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> powerUpDelayMultiplier;
|
||||||
public static ConfigEntry<float> batteryCapacityMultiplier;
|
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;
|
||||||
|
|
||||||
|
public static ConfigEntry<float> shieldRadiusMultiplier;
|
||||||
|
public static ConfigEntry<float> shieldHeartbeatIntervalMultiplier;
|
||||||
|
public static ConfigEntry<float> shieldPowerUpDelayMultiplier;
|
||||||
|
|
||||||
public void Awake() {
|
public void Awake() {
|
||||||
debug = Config.Bind("General", "Debug", false);
|
debug = Config.Bind("General", "Debug", false);
|
||||||
|
|
||||||
@@ -63,6 +65,18 @@ namespace TerraTech {
|
|||||||
"General", "Heartbeat Interval Multiplier", 1f,
|
"General", "Heartbeat Interval Multiplier", 1f,
|
||||||
new ConfigDescription("Heartbeat Interval Multiplier", new AcceptableValueRange<float>(0.1f, 2f)));
|
new ConfigDescription("Heartbeat Interval Multiplier", new AcceptableValueRange<float>(0.1f, 2f)));
|
||||||
|
|
||||||
|
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)));
|
||||||
|
shieldPowerUpDelayMultiplier =
|
||||||
|
Config.Bind("Shield", "Shield Power Up Delay Multiplier", 1f,
|
||||||
|
new ConfigDescription("Shield Power Up Delay Multiplier",
|
||||||
|
new AcceptableValueRange<float>(0.001f, 32f)));
|
||||||
|
|
||||||
shootingSpeedMultiplier = Config.Bind(
|
shootingSpeedMultiplier = Config.Bind(
|
||||||
"Weapons", "Shooting Speed Multiplier", 1f,
|
"Weapons", "Shooting Speed Multiplier", 1f,
|
||||||
new ConfigDescription("Shooting Speed Multiplier", new AcceptableValueRange<float>(0.2f, 8f)));
|
new ConfigDescription("Shooting Speed Multiplier", new AcceptableValueRange<float>(0.2f, 8f)));
|
||||||
@@ -142,13 +156,6 @@ 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(
|
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)));
|
||||||
@@ -156,29 +163,30 @@ namespace TerraTech {
|
|||||||
"PowerUp", "Battery Capacity Multiplier", 1f,
|
"PowerUp", "Battery Capacity Multiplier", 1f,
|
||||||
new ConfigDescription("Battery Capacity Multiplier", new AcceptableValueRange<float>(0.001f, 32f)));
|
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();
|
||||||
energyGenMultiplier.SettingChanged += (sender, args) => GeneratorPropertiesManager.DoPatch();
|
// energyGenMultiplier.SettingChanged += (sender, args) => GeneratorPropertiesManager.DoPatch();
|
||||||
magnetStrenghtMultiplier.SettingChanged += (sender, args) => MagnetPropertiesManager.DoPatch();
|
// magnetStrenghtMultiplier.SettingChanged += (sender, args) => MagnetPropertiesManager.DoPatch();
|
||||||
magnetRadiusMultiplier.SettingChanged += (sender, args) => MagnetPropertiesManager.DoPatch();
|
// magnetRadiusMultiplier.SettingChanged += (sender, args) => MagnetPropertiesManager.DoPatch();
|
||||||
beamStrenghtMultiplier.SettingChanged += (sender, args) => BeamPropertiesManager.DoPatch();
|
// beamStrenghtMultiplier.SettingChanged += (sender, args) => BeamPropertiesManager.DoPatch();
|
||||||
beamRadiusMultiplier.SettingChanged += (sender, args) => BeamPropertiesManager.DoPatch();
|
// beamRadiusMultiplier.SettingChanged += (sender, args) => BeamPropertiesManager.DoPatch();
|
||||||
fuelTankRefillMultiplier.SettingChanged += (sender, args) => FuelPropertiesManager.DoPatch();
|
// fuelTankRefillMultiplier.SettingChanged += (sender, args) => FuelPropertiesManager.DoPatch();
|
||||||
fuelTankCapacityMultiplier.SettingChanged += (sender, args) => FuelPropertiesManager.DoPatch();
|
// fuelTankCapacityMultiplier.SettingChanged += (sender, args) => FuelPropertiesManager.DoPatch();
|
||||||
wheelTorqueMultiplier.SettingChanged += (sender, args) => WheelPropertiesManager.DoPatch();
|
// wheelTorqueMultiplier.SettingChanged += (sender, args) => WheelPropertiesManager.DoPatch();
|
||||||
wheelSpeedMultiplier.SettingChanged += (sender, args) => WheelPropertiesManager.DoPatch();
|
// wheelSpeedMultiplier.SettingChanged += (sender, args) => WheelPropertiesManager.DoPatch();
|
||||||
jetThrustMultiplier.SettingChanged += (sender, args) => ThrusterPropertiesManager.DoPatch();
|
// jetThrustMultiplier.SettingChanged += (sender, args) => ThrusterPropertiesManager.DoPatch();
|
||||||
minerGroundArea.SettingChanged += (sender, args) => MinerPropertiesManager.DoPatch();
|
// minerGroundArea.SettingChanged += (sender, args) => MinerPropertiesManager.DoPatch();
|
||||||
minerMiningSpeed.SettingChanged += (sender, args) => MinerPropertiesManager.DoPatch();
|
// minerMiningSpeed.SettingChanged += (sender, args) => MinerPropertiesManager.DoPatch();
|
||||||
wirelessChargingPowerPerArcMultiplier.SettingChanged += (sender, args) =>
|
// wirelessChargingPowerPerArcMultiplier.SettingChanged += (sender, args) =>
|
||||||
WirelessChargerPropertiesManager.DoPatch();
|
// WirelessChargerPropertiesManager.DoPatch();
|
||||||
wirelessChargingArcFiringIntervalMultiplier.SettingChanged += (sender, args) =>
|
// wirelessChargingArcFiringIntervalMultiplier.SettingChanged += (sender, args) =>
|
||||||
WirelessChargerPropertiesManager.DoPatch();
|
// WirelessChargerPropertiesManager.DoPatch();
|
||||||
wirelessChargingRadiusMultiplier.SettingChanged += (sender, args) =>
|
// wirelessChargingRadiusMultiplier.SettingChanged += (sender, args) =>
|
||||||
WirelessChargerPropertiesManager.DoPatch();
|
// WirelessChargerPropertiesManager.DoPatch();
|
||||||
shopBlocksGeneratedTotalMultiplier.SettingChanged += (sender, args) =>
|
// shopBlocksGeneratedTotalMultiplier.SettingChanged += (sender, args) =>
|
||||||
InventorySupplierPropertiesManager.DoPatch();
|
// InventorySupplierPropertiesManager.DoPatch();
|
||||||
shopPerBlockStopMultiplier.SettingChanged += (sender, args) => InventorySupplierPropertiesManager.DoPatch();
|
// shopPerBlockStopMultiplier.SettingChanged += (sender, args) =>
|
||||||
|
// InventorySupplierPropertiesManager.DoPatch();
|
||||||
|
|
||||||
Logger.LogInfo("Cyka mod loaded");
|
Logger.LogInfo("Cyka mod loaded");
|
||||||
HarmonyFileLog.Enabled = true;
|
HarmonyFileLog.Enabled = true;
|
||||||
|
@@ -1,59 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using HarmonyLib;
|
|
||||||
|
|
||||||
namespace TerraTech {
|
|
||||||
[HarmonyPatch]
|
|
||||||
public class FuelPropertiesManager {
|
|
||||||
private static Dictionary<ModuleFuelTank, float> refillRate = new Dictionary<ModuleFuelTank, float>();
|
|
||||||
private static Dictionary<ModuleFuelTank, float> capacity = new Dictionary<ModuleFuelTank, float>();
|
|
||||||
|
|
||||||
[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<ModuleFuelTank, float> 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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,62 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using HarmonyLib;
|
|
||||||
|
|
||||||
namespace TerraTech {
|
|
||||||
[HarmonyPatch]
|
|
||||||
public class GeneratorPropertiesManager {
|
|
||||||
private static Dictionary<ModuleEnergy, float> generators = new Dictionary<ModuleEnergy, float>();
|
|
||||||
|
|
||||||
[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<ModuleEnergy, float> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,23 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using HarmonyLib;
|
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
namespace TerraTech {
|
|
||||||
[HarmonyPatch(typeof(Projectile), "Fire")]
|
|
||||||
public class HomingAndVelocityProjectilePatch {
|
|
||||||
private static Dictionary<FireData, float> velocities = new Dictionary<FireData, float>();
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,111 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using HarmonyLib;
|
|
||||||
|
|
||||||
namespace TerraTech {
|
|
||||||
[HarmonyPatch]
|
|
||||||
public class InventorySupplierPropertiesManager {
|
|
||||||
private static Dictionary<InventorySupplier, int> inventoryNumBlockTypes =
|
|
||||||
new Dictionary<InventorySupplier, int>();
|
|
||||||
private static Dictionary<InventorySupplier, int> inventoryQuantityPerBlockType =
|
|
||||||
new Dictionary<InventorySupplier, int>();
|
|
||||||
|
|
||||||
[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<InventorySupplier, int> 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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,94 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using HarmonyLib;
|
|
||||||
|
|
||||||
namespace TerraTech {
|
|
||||||
[HarmonyPatch]
|
|
||||||
public class MagnetPropertiesManager {
|
|
||||||
private static Dictionary<ModuleItemHolderMagnet, float> strenghts =
|
|
||||||
new Dictionary<ModuleItemHolderMagnet, float>();
|
|
||||||
private static Dictionary<ModuleItemHolderMagnet, float> radii =
|
|
||||||
new Dictionary<ModuleItemHolderMagnet, float>();
|
|
||||||
|
|
||||||
[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<ModuleItemHolderMagnet, float> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,92 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using HarmonyLib;
|
|
||||||
|
|
||||||
namespace TerraTech {
|
|
||||||
[HarmonyPatch]
|
|
||||||
public class MinerPropertiesManager {
|
|
||||||
private static Dictionary<ModuleItemProducer, float> area = new Dictionary<ModuleItemProducer, float>();
|
|
||||||
private static Dictionary<ModuleItemProducer, float> speed = new Dictionary<ModuleItemProducer, float>();
|
|
||||||
|
|
||||||
[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<ModuleItemProducer, float> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,78 +0,0 @@
|
|||||||
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]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -37,25 +37,12 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="BeamPropertiesManager.cs" />
|
|
||||||
<Compile Include="Class1.cs" />
|
<Compile Include="Class1.cs" />
|
||||||
<Compile Include="FuelPropertiesManager.cs" />
|
|
||||||
<Compile Include="GeneratorPropertiesManager.cs" />
|
|
||||||
<Compile Include="HomingAndVelocityProjectilePatch.cs" />
|
|
||||||
<Compile Include="InventorySupplierPropertiesManager.cs" />
|
|
||||||
<Compile Include="MagnetPropertiesManager.cs" />
|
|
||||||
<Compile Include="MinerPropertiesManager.cs" />
|
|
||||||
<Compile Include="ModuleEnergy.cs" />
|
|
||||||
<Compile Include="ModuleEnergyStoreManager.cs" />
|
|
||||||
<Compile Include="ModuleShieldGeneratorManager.cs" />
|
<Compile Include="ModuleShieldGeneratorManager.cs" />
|
||||||
<Compile Include="ObjectFieldMultiplier.cs" />
|
<Compile Include="ObjectFieldMultiplier.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" />
|
||||||
<Compile Include="ThrusterPropertiesManager.cs" />
|
|
||||||
<Compile Include="WeaponPropertiesManager.cs" />
|
|
||||||
<Compile Include="WheelPropertiesManager.cs" />
|
|
||||||
<Compile Include="WirelessChargerPropertiesManager.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
|
@@ -1,94 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using HarmonyLib;
|
|
||||||
|
|
||||||
namespace TerraTech {
|
|
||||||
[HarmonyPatch]
|
|
||||||
public class ThrusterPropertiesManager {
|
|
||||||
private static Dictionary<ModuleBooster, Dictionary<BoosterJet, float>> boosters =
|
|
||||||
new Dictionary<ModuleBooster, Dictionary<BoosterJet, float>>();
|
|
||||||
|
|
||||||
[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<ModuleBooster, Dictionary<BoosterJet, float>> keyValuePair in boosters) {
|
|
||||||
DoRestoreSingle(keyValuePair.Key);
|
|
||||||
DoPatchSingle(keyValuePair.Key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DoPatchSingle(ModuleBooster moduleBooster) {
|
|
||||||
List<BoosterJet> 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<BoosterJet, float> Map(ModuleBooster moduleBooster) {
|
|
||||||
Dictionary<BoosterJet, float> jets = new Dictionary<BoosterJet, float>();
|
|
||||||
foreach (BoosterJet boosterJet in GetValue(moduleBooster)) {
|
|
||||||
jets.Add(boosterJet, GetValue(boosterJet));
|
|
||||||
}
|
|
||||||
return jets;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static List<BoosterJet> GetValue(ModuleBooster moduleBooster) {
|
|
||||||
return Traverse.Create(moduleBooster).Field("jets").GetValue() as List<BoosterJet>;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void SetValue(ModuleBooster moduleBooster, List<BoosterJet> 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,65 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using BepInEx.Configuration;
|
|
||||||
using HarmonyLib;
|
|
||||||
|
|
||||||
namespace TerraTech {
|
|
||||||
[HarmonyPatch]
|
|
||||||
public class WeaponPropertiesManager {
|
|
||||||
private static Dictionary<ModuleWeapon, float> shotCooldown = new Dictionary<ModuleWeapon, float>();
|
|
||||||
|
|
||||||
[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<ModuleWeapon, float> 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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,67 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using HarmonyLib;
|
|
||||||
|
|
||||||
namespace TerraTech {
|
|
||||||
[HarmonyPatch]
|
|
||||||
public class WheelPropertiesManager {
|
|
||||||
private static Dictionary<ModuleWheels, float> torques = new Dictionary<ModuleWheels, float>();
|
|
||||||
private static Dictionary<ModuleWheels, float> maxRpm = new Dictionary<ModuleWheels, float>();
|
|
||||||
|
|
||||||
[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<ModuleWheels, float> 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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@@ -1,69 +0,0 @@
|
|||||||
using System.Collections.Generic;
|
|
||||||
using HarmonyLib;
|
|
||||||
|
|
||||||
// TODO: Fix this, no workey
|
|
||||||
namespace TerraTech {
|
|
||||||
[HarmonyPatch]
|
|
||||||
public class WirelessChargerPropertiesManager {
|
|
||||||
private static Dictionary<ModuleRemoteCharger, float> radius = new Dictionary<ModuleRemoteCharger, float>();
|
|
||||||
private static Dictionary<ModuleRemoteCharger, float> transferPerArc =
|
|
||||||
new Dictionary<ModuleRemoteCharger, float>();
|
|
||||||
private static Dictionary<ModuleRemoteCharger, float> arcFiringInterval =
|
|
||||||
new Dictionary<ModuleRemoteCharger, float>();
|
|
||||||
|
|
||||||
[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<ModuleRemoteCharger, float> 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];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user