Major refactoring
This commit is contained in:
79
Projects/TerraTech/TerraTech/BeamPropertiesManager.cs
Normal file
79
Projects/TerraTech/TerraTech/BeamPropertiesManager.cs
Normal file
@@ -0,0 +1,79 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,15 +1,16 @@
|
|||||||
using System;
|
using System.Linq;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using BepInEx;
|
using BepInEx;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using HarmonyLib.Tools;
|
using HarmonyLib.Tools;
|
||||||
using UnityEngine;
|
|
||||||
|
|
||||||
// TODO: Make battery bigger
|
// TODO: Make battery bigger
|
||||||
// TODO: Make shield and repair bigger
|
// TODO: Make shield and repair bigger
|
||||||
// TODO: Make fuel tanks bigger
|
// TODO: Make fuel tanks bigger
|
||||||
|
// TODO: Fix fuel tank refill
|
||||||
|
// TODO: Add loggers
|
||||||
|
// TODO: See about faster wheel maybe
|
||||||
|
// TODO: See about more better thruster maybe
|
||||||
|
|
||||||
namespace TerraTech {
|
namespace TerraTech {
|
||||||
[BepInPlugin(pluginGuid, pluginName, pluginVersion)]
|
[BepInPlugin(pluginGuid, pluginName, pluginVersion)]
|
||||||
@@ -30,8 +31,12 @@ namespace TerraTech {
|
|||||||
public static ConfigEntry<float> beamStrenghtMultiplier;
|
public static ConfigEntry<float> beamStrenghtMultiplier;
|
||||||
public static ConfigEntry<float> beamRadiusMultiplier;
|
public static ConfigEntry<float> beamRadiusMultiplier;
|
||||||
public static ConfigEntry<float> fuelTankRefillMultiplier;
|
public static ConfigEntry<float> fuelTankRefillMultiplier;
|
||||||
|
public static ConfigEntry<float> fuelTankCapacityMultiplier;
|
||||||
public static ConfigEntry<float> minerGroundArea;
|
public static ConfigEntry<float> minerGroundArea;
|
||||||
public static ConfigEntry<float> minerMiningSpeed;
|
public static ConfigEntry<float> minerMiningSpeed;
|
||||||
|
public static ConfigEntry<float> wheelTorqueMultiplier;
|
||||||
|
public static ConfigEntry<float> wheelSpeedMultiplier;
|
||||||
|
public static ConfigEntry<float> jetThrustMultiplier;
|
||||||
|
|
||||||
public void Awake() {
|
public void Awake() {
|
||||||
xpMultiplier = Config.Bind("General", "XP Multiplier", 1f, new ConfigDescription("XP Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
xpMultiplier = Config.Bind("General", "XP Multiplier", 1f, new ConfigDescription("XP Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
||||||
@@ -41,10 +46,12 @@ namespace TerraTech {
|
|||||||
new ConfigDescription("Energy Generation Multiplier", new AcceptableValueRange<float>(1f, 64f)));
|
new ConfigDescription("Energy Generation Multiplier", new AcceptableValueRange<float>(1f, 64f)));
|
||||||
heartbeatIntervalMultiplier = Config.Bind("General", "Heartbeat Interval Multiplier", 1f,
|
heartbeatIntervalMultiplier = Config.Bind("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)));
|
||||||
|
|
||||||
shootingSpeedMultiplier = Config.Bind("Weapons", "Shooting Speed Multiplier", 1f,
|
shootingSpeedMultiplier = Config.Bind("Weapons", "Shooting Speed Multiplier", 1f,
|
||||||
new ConfigDescription("Shooting Speed Multiplier", new AcceptableValueRange<float>(0.5f, 8f)));
|
new ConfigDescription("Shooting Speed Multiplier", new AcceptableValueRange<float>(0.5f, 8f)));
|
||||||
muzzleVelocityMultiplier = Config.Bind("Weapons", "Muzzle Velocity Multiplier", 1f,
|
muzzleVelocityMultiplier = Config.Bind("Weapons", "Muzzle Velocity Multiplier", 1f,
|
||||||
new ConfigDescription("Muzzle Velocity Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
new ConfigDescription("Muzzle Velocity Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
||||||
|
|
||||||
magnetStrenghtMultiplier = Config.Bind("Attractors", "Magnet Strength Multiplier", 1f,
|
magnetStrenghtMultiplier = Config.Bind("Attractors", "Magnet Strength Multiplier", 1f,
|
||||||
new ConfigDescription("Magnet Strength Multiplier", new AcceptableValueRange<float>(1f, 16f)));
|
new ConfigDescription("Magnet Strength Multiplier", new AcceptableValueRange<float>(1f, 16f)));
|
||||||
magnetRadiusMultiplier = Config.Bind("Attractors", "Magnet Radius Multiplier", 1f,
|
magnetRadiusMultiplier = Config.Bind("Attractors", "Magnet Radius Multiplier", 1f,
|
||||||
@@ -53,8 +60,18 @@ namespace TerraTech {
|
|||||||
new ConfigDescription("Beam Strength Multiplier", new AcceptableValueRange<float>(1f, 16f)));
|
new ConfigDescription("Beam Strength Multiplier", new AcceptableValueRange<float>(1f, 16f)));
|
||||||
beamRadiusMultiplier = Config.Bind("Attractors", "Beam Radius Multiplier", 1f,
|
beamRadiusMultiplier = Config.Bind("Attractors", "Beam Radius Multiplier", 1f,
|
||||||
new ConfigDescription("Beam Radius Multiplier", new AcceptableValueRange<float>(1f, 16f)));
|
new ConfigDescription("Beam Radius Multiplier", new AcceptableValueRange<float>(1f, 16f)));
|
||||||
|
|
||||||
fuelTankRefillMultiplier = Config.Bind("Propulsion", "Fuel Tank Refill Rate Multiplier", 1f,
|
fuelTankRefillMultiplier = Config.Bind("Propulsion", "Fuel Tank Refill Rate Multiplier", 1f,
|
||||||
new ConfigDescription("Fuel Tank Refill Rate Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
new ConfigDescription("Fuel Tank Refill Rate Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
||||||
|
fuelTankCapacityMultiplier = Config.Bind("Propulsion", "Fuel Tank Capacity Multiplier", 1f,
|
||||||
|
new ConfigDescription("Fuel Tank Capacity Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
||||||
|
wheelTorqueMultiplier = Config.Bind("Propulsion", "Wheel Torque Multiplier", 1f,
|
||||||
|
new ConfigDescription("Wheel Torque Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
||||||
|
wheelSpeedMultiplier = Config.Bind("Propulsion", "Wheel Max RPM Multiplier", 1f,
|
||||||
|
new ConfigDescription("Wheel Max RPM Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
||||||
|
jetThrustMultiplier = Config.Bind("Propulsion", "Jet Thrust Multiplier", 1f,
|
||||||
|
new ConfigDescription("Jet Thrust Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
||||||
|
|
||||||
minerGroundArea = Config.Bind("Production", "Miner Ground Deposit Scan Area", 1f,
|
minerGroundArea = Config.Bind("Production", "Miner Ground Deposit Scan Area", 1f,
|
||||||
new ConfigDescription("Miner Ground Deposit Scan Area", new AcceptableValueRange<float>(1f, 32f)));
|
new ConfigDescription("Miner Ground Deposit Scan Area", new AcceptableValueRange<float>(1f, 32f)));
|
||||||
minerMiningSpeed = Config.Bind("Production", "Miner Mining Speed", 1f,
|
minerMiningSpeed = Config.Bind("Production", "Miner Mining Speed", 1f,
|
||||||
@@ -69,6 +86,10 @@ namespace TerraTech {
|
|||||||
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();
|
||||||
|
wheelTorqueMultiplier.SettingChanged += (sender, args) => WheelPropertiesManager.DoPatch();
|
||||||
|
wheelSpeedMultiplier.SettingChanged += (sender, args) => WheelPropertiesManager.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();
|
||||||
|
|
||||||
@@ -80,415 +101,4 @@ namespace TerraTech {
|
|||||||
Logger.LogInfo("Patched " + originalMethods.Count() + " methods");
|
Logger.LogInfo("Patched " + originalMethods.Count() + " methods");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch]
|
|
||||||
public class Patches {
|
|
||||||
[HarmonyPrefix]
|
|
||||||
[HarmonyPatch(typeof(ManLicenses), "AddXP")]
|
|
||||||
static void XPMulti(FactionSubTypes corporation, ref int xp, bool showUI = true) {
|
|
||||||
xp = (int)(xp * Main.xpMultiplier.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPrefix]
|
|
||||||
[HarmonyPatch(typeof(ManPlayer), "AddMoney")]
|
|
||||||
static void MoneyMulti(ref int amount) {
|
|
||||||
amount = (int)(amount * Main.moneyMultiplier.Value);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPrefix]
|
|
||||||
[HarmonyPatch(typeof(TechHolders), "SetHeartbeatInterval")]
|
|
||||||
static void HeartbeatMulti(ref float interval) {
|
|
||||||
interval *= Main.heartbeatIntervalMultiplier.Value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(typeof(Projectile), "Fire")]
|
|
||||||
public class HomingProjectilePatch {
|
|
||||||
private static Dictionary<FireData, bool> patchedObjects = new Dictionary<FireData, bool>();
|
|
||||||
|
|
||||||
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 (Main.muzzleVelocityMultiplier.Value != -1f && !patchedObjects.ContainsKey(fireData)) {
|
|
||||||
fireData.m_MuzzleVelocity *= Main.muzzleVelocityMultiplier.Value;
|
|
||||||
patchedObjects.Add(fireData, true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch]
|
|
||||||
public class WeaponPropertiesManager {
|
|
||||||
private static Dictionary<ModuleWeaponGun, float> weapons = new Dictionary<ModuleWeaponGun, float>();
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(ModuleWeaponGun), "OnAttached")]
|
|
||||||
static void PostfixCreate(ModuleWeaponGun __instance) {
|
|
||||||
if (!weapons.ContainsKey(__instance)) {
|
|
||||||
weapons.Add(__instance, __instance.m_ShotCooldown);
|
|
||||||
DoPatchSingle(__instance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(ModuleWeaponGun), "OnDetaching")]
|
|
||||||
static void PostfixDestroy(ModuleWeaponGun __instance) {
|
|
||||||
DoRestoreSingle(__instance);
|
|
||||||
weapons.Remove(__instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DoPatch() {
|
|
||||||
// Console.WriteLine("Modifying " + weapons.Count + " weapons");
|
|
||||||
foreach (KeyValuePair<ModuleWeaponGun, float> keyValuePair in weapons) {
|
|
||||||
DoRestoreSingle(keyValuePair.Key);
|
|
||||||
DoPatchSingle(keyValuePair.Key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DoPatchSingle(ModuleWeaponGun weapon) {
|
|
||||||
// Console.WriteLine("Patching " + weapon.name);
|
|
||||||
// Console.WriteLine("Old value " + weapon.m_ShotCooldown);
|
|
||||||
weapon.m_ShotCooldown /= Main.shootingSpeedMultiplier.Value;
|
|
||||||
// Console.WriteLine("New value " + weapon.m_ShotCooldown);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DoRestoreSingle(ModuleWeaponGun weapon) {
|
|
||||||
if (weapons.ContainsKey(weapon)) {
|
|
||||||
weapon.m_ShotCooldown = weapons[weapon];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch]
|
|
||||||
public class GeneratorPropertiesManager {
|
|
||||||
private static Dictionary<ModuleEnergy, float> generators = new Dictionary<ModuleEnergy, float>();
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(ModuleEnergy), "OnAttached")]
|
|
||||||
static void PostfixCreate(ModuleEnergy __instance) {
|
|
||||||
if (!generators.ContainsKey(__instance)) {
|
|
||||||
generators.Add(__instance, GetValue(__instance));
|
|
||||||
DoPatchSingle(__instance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(ModuleEnergy), "OnDetaching")]
|
|
||||||
static void PostfixDestroy(ModuleEnergy __instance) {
|
|
||||||
DoRestoreSingle(__instance);
|
|
||||||
generators.Remove(__instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DoPatch() {
|
|
||||||
// Console.WriteLine("Modifying " + generators.Count + " generators");
|
|
||||||
// Console.WriteLine("Should patch: " + ShouldPatch());
|
|
||||||
foreach (KeyValuePair<ModuleEnergy, float> keyValuePair in generators) {
|
|
||||||
DoRestoreSingle(keyValuePair.Key);
|
|
||||||
DoPatchSingle(keyValuePair.Key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DoPatchSingle(ModuleEnergy moduleEnergy) {
|
|
||||||
// Console.WriteLine("Patching " + moduleEnergy.name);
|
|
||||||
// Console.WriteLine("Old value " + GetValue(moduleEnergy));
|
|
||||||
SetValue(moduleEnergy, GetValue(moduleEnergy) * Main.energyGenMultiplier.Value);
|
|
||||||
// Console.WriteLine("New value " + GetValue(moduleEnergy));
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch]
|
|
||||||
public class FuelPropertiesManager {
|
|
||||||
private static Dictionary<ModuleFuelTank, float> tanks = new Dictionary<ModuleFuelTank, float>();
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(ModuleFuelTank), "OnAttached")]
|
|
||||||
static void PostfixCreate(ModuleFuelTank __instance) {
|
|
||||||
if (!tanks.ContainsKey(__instance)) {
|
|
||||||
tanks.Add(__instance, GetValue(__instance));
|
|
||||||
DoPatchSingle(__instance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(ModuleFuelTank), "OnDetaching")]
|
|
||||||
static void PostfixDestroy(ModuleFuelTank __instance) {
|
|
||||||
DoRestoreSingle(__instance);
|
|
||||||
tanks.Remove(__instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DoPatch() {
|
|
||||||
// Console.WriteLine("Modifying " + generators.Count + " generators");
|
|
||||||
// Console.WriteLine("Should patch: " + ShouldPatch());
|
|
||||||
foreach (KeyValuePair<ModuleFuelTank, float> keyValuePair in tanks) {
|
|
||||||
DoRestoreSingle(keyValuePair.Key);
|
|
||||||
DoPatchSingle(keyValuePair.Key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DoPatchSingle(ModuleFuelTank moduleFuelTank) {
|
|
||||||
// Console.WriteLine("Patching " + moduleEnergy.name);
|
|
||||||
// Console.WriteLine("Old value " + GetValue(moduleEnergy));
|
|
||||||
SetValue(moduleFuelTank, GetValue(moduleFuelTank) * Main.energyGenMultiplier.Value);
|
|
||||||
// Console.WriteLine("New value " + GetValue(moduleEnergy));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DoRestoreSingle(ModuleFuelTank moduleFuelTank) {
|
|
||||||
if (tanks.ContainsKey(moduleFuelTank)) {
|
|
||||||
SetValue(moduleFuelTank, tanks[moduleFuelTank]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static float GetValue(ModuleFuelTank moduleFuelTank) {
|
|
||||||
return moduleFuelTank.m_RefillRate;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void SetValue(ModuleFuelTank moduleFuelTank, float value) {
|
|
||||||
moduleFuelTank.m_RefillRate = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch]
|
|
||||||
public class MagnetPropertiesManager {
|
|
||||||
private static Dictionary<ModuleItemHolderMagnet, float> strenghts = new Dictionary<ModuleItemHolderMagnet, float>();
|
|
||||||
private static Dictionary<ModuleItemHolderMagnet, float> radii = new Dictionary<ModuleItemHolderMagnet, float>();
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(ModuleItemHolderMagnet), "OnAttached")]
|
|
||||||
static void PostfixCreate(ModuleItemHolderMagnet __instance) {
|
|
||||||
if (!strenghts.ContainsKey(__instance)) {
|
|
||||||
strenghts.Add(__instance, GetStrength(__instance));
|
|
||||||
radii.Add(__instance, GetRadius(__instance));
|
|
||||||
DoPatchSingle(__instance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(ModuleItemHolderMagnet), "OnDetaching")]
|
|
||||||
static void PostfixDestroy(ModuleItemHolderMagnet __instance) {
|
|
||||||
DoRestoreSingle(__instance);
|
|
||||||
strenghts.Remove(__instance);
|
|
||||||
radii.Remove(__instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DoPatch() {
|
|
||||||
// Console.WriteLine("Modifying " + generators.Count + " generators");
|
|
||||||
// Console.WriteLine("Should patch: " + ShouldPatch());
|
|
||||||
foreach (KeyValuePair<ModuleItemHolderMagnet, float> keyValuePair in strenghts) {
|
|
||||||
DoRestoreSingle(keyValuePair.Key);
|
|
||||||
DoPatchSingle(keyValuePair.Key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DoPatchSingle(ModuleItemHolderMagnet moduleItemHolderMagnet) {
|
|
||||||
// Console.WriteLine("Patching " + moduleEnergy.name);
|
|
||||||
// Console.WriteLine("Old value " + GetValue(moduleEnergy));
|
|
||||||
SetStrength(moduleItemHolderMagnet, GetStrength(moduleItemHolderMagnet) * Main.magnetStrenghtMultiplier.Value);
|
|
||||||
SetRadius(moduleItemHolderMagnet, GetRadius(moduleItemHolderMagnet) * Main.magnetRadiusMultiplier.Value);
|
|
||||||
// Console.WriteLine("New value " + GetValue(moduleEnergy));
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch]
|
|
||||||
public class BeamPropertiesManager {
|
|
||||||
private static Dictionary<ModuleItemHolderBeam, float> strenghts = new Dictionary<ModuleItemHolderBeam, float>();
|
|
||||||
private static Dictionary<ModuleItemHolderBeam, float> radii = new Dictionary<ModuleItemHolderBeam, float>();
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(ModuleItemHolderBeam), "OnAttached")]
|
|
||||||
static void PostfixCreate(ModuleItemHolderBeam __instance) {
|
|
||||||
if (!strenghts.ContainsKey(__instance)) {
|
|
||||||
strenghts.Add(__instance, GetStrength(__instance));
|
|
||||||
radii.Add(__instance, GetRadius(__instance));
|
|
||||||
DoPatchSingle(__instance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(ModuleItemHolderBeam), "OnDetaching")]
|
|
||||||
static void PostfixDestroy(ModuleItemHolderBeam __instance) {
|
|
||||||
DoRestoreSingle(__instance);
|
|
||||||
strenghts.Remove(__instance);
|
|
||||||
radii.Remove(__instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DoPatch() {
|
|
||||||
// Console.WriteLine("Modifying " + generators.Count + " generators");
|
|
||||||
// Console.WriteLine("Should patch: " + ShouldPatch());
|
|
||||||
foreach (KeyValuePair<ModuleItemHolderBeam, float> keyValuePair in strenghts) {
|
|
||||||
DoRestoreSingle(keyValuePair.Key);
|
|
||||||
DoPatchSingle(keyValuePair.Key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DoPatchSingle(ModuleItemHolderBeam moduleItemHolderBeam) {
|
|
||||||
// Console.WriteLine("Patching " + moduleEnergy.name);
|
|
||||||
// Console.WriteLine("Old value " + GetValue(moduleEnergy));
|
|
||||||
SetStrength(moduleItemHolderBeam, GetStrength(moduleItemHolderBeam) * Main.beamStrenghtMultiplier.Value);
|
|
||||||
SetRadius(moduleItemHolderBeam, GetRadius(moduleItemHolderBeam) * Main.beamRadiusMultiplier.Value);
|
|
||||||
// Console.WriteLine("New value " + GetValue(moduleEnergy));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DoRestoreSingle(ModuleItemHolderBeam moduleItemHolderBeam) {
|
|
||||||
if (strenghts.ContainsKey(moduleItemHolderBeam)) {
|
|
||||||
SetStrength(moduleItemHolderBeam, strenghts[moduleItemHolderBeam]);
|
|
||||||
}
|
|
||||||
if (radii.ContainsKey(moduleItemHolderBeam)) {
|
|
||||||
SetRadius(moduleItemHolderBeam, radii[moduleItemHolderBeam]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static float GetStrength(ModuleItemHolderBeam moduleItemHolderBeam) {
|
|
||||||
return Traverse.Create(moduleItemHolderBeam).Field("m_Strength").GetValue() as float? ?? 0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void SetStrength(ModuleItemHolderBeam moduleItemHolderBeam, float value) {
|
|
||||||
Traverse.Create(moduleItemHolderBeam).Field("m_Strength").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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch]
|
|
||||||
public class MinerPropertiesManager {
|
|
||||||
private static Dictionary<ModuleItemProducer, float> area = new Dictionary<ModuleItemProducer, float>();
|
|
||||||
private static Dictionary<ModuleItemProducer, float> speed = new Dictionary<ModuleItemProducer, float>();
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(ModuleItemProducer), "GetClosestResourceReservoirInRange")]
|
|
||||||
static void PostfixCreate(ModuleItemProducer __instance) {
|
|
||||||
// Console.WriteLine("ModuleItemProducer OnPool");
|
|
||||||
if (!area.ContainsKey(__instance)) {
|
|
||||||
// Console.WriteLine("Is new ModuleItemProducer");
|
|
||||||
area.Add(__instance, GetArea(__instance));
|
|
||||||
speed.Add(__instance, GetSpeed(__instance));
|
|
||||||
DoPatchSingle(__instance);
|
|
||||||
} else {
|
|
||||||
if (GetArea(__instance) == area[__instance]) {
|
|
||||||
DoPatchSingle(__instance);
|
|
||||||
}
|
|
||||||
if (GetSpeed(__instance) == speed[__instance]) {
|
|
||||||
DoPatchSingle(__instance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(ModuleItemProducer), "OnRecycle")]
|
|
||||||
static void PostfixDestroy(ModuleItemProducer __instance) {
|
|
||||||
// Console.WriteLine("ModuleItemProducer OnRecycle");
|
|
||||||
DoRestoreSingle(__instance);
|
|
||||||
area.Remove(__instance);
|
|
||||||
speed.Remove(__instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void DoPatch() {
|
|
||||||
// Console.WriteLine("Modifying " + generators.Count + " generators");
|
|
||||||
// Console.WriteLine("Should patch: " + ShouldPatch());
|
|
||||||
foreach (KeyValuePair<ModuleItemProducer, float> keyValuePair in area) {
|
|
||||||
DoRestoreSingle(keyValuePair.Key);
|
|
||||||
DoPatchSingle(keyValuePair.Key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DoPatchSingle(ModuleItemProducer moduleItemProducer) {
|
|
||||||
// Console.WriteLine("Patching " + moduleItemProducer.name);
|
|
||||||
// Console.WriteLine("Old value " + GetArea(moduleItemProducer));
|
|
||||||
// Console.WriteLine("Multiplier " + Main.minerGroundArea.Value);
|
|
||||||
SetArea(moduleItemProducer, area[moduleItemProducer] * Main.minerGroundArea.Value);
|
|
||||||
SetSpeed(moduleItemProducer, speed[moduleItemProducer] / Main.minerMiningSpeed.Value);
|
|
||||||
// Console.WriteLine("New value " + GetArea(moduleItemProducer));
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPrefix]
|
|
||||||
[HarmonyPatch(typeof(ModuleItemProducer), "GetClosestResourceReservoirInRange")]
|
|
||||||
static void Test(ModuleItemProducer __instance) {
|
|
||||||
Console.WriteLine("" + GetArea(__instance));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void DoRestoreSingle(ModuleItemProducer moduleItemProducer) {
|
|
||||||
if (area.ContainsKey(moduleItemProducer)) {
|
|
||||||
SetArea(moduleItemProducer, area[moduleItemProducer]);
|
|
||||||
}
|
|
||||||
if (speed.ContainsKey(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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
55
Projects/TerraTech/TerraTech/FuelPropertiesManager.cs
Normal file
55
Projects/TerraTech/TerraTech/FuelPropertiesManager.cs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
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];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
58
Projects/TerraTech/TerraTech/GeneratorPropertiesManager.cs
Normal file
58
Projects/TerraTech/TerraTech/GeneratorPropertiesManager.cs
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -0,0 +1,22 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
81
Projects/TerraTech/TerraTech/MagnetPropertiesManager.cs
Normal file
81
Projects/TerraTech/TerraTech/MagnetPropertiesManager.cs
Normal file
@@ -0,0 +1,81 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
86
Projects/TerraTech/TerraTech/MinerPropertiesManager.cs
Normal file
86
Projects/TerraTech/TerraTech/MinerPropertiesManager.cs
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
24
Projects/TerraTech/TerraTech/Patches.cs
Normal file
24
Projects/TerraTech/TerraTech/Patches.cs
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
|
||||||
|
namespace TerraTech {
|
||||||
|
[HarmonyPatch]
|
||||||
|
public class Patches {
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(ManLicenses), "AddXP")]
|
||||||
|
static void XPMulti(FactionSubTypes corporation, ref int xp, bool showUI = true) {
|
||||||
|
xp = (int)(xp * Main.xpMultiplier.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(ManPlayer), "AddMoney")]
|
||||||
|
static void MoneyMulti(ref int amount) {
|
||||||
|
amount = (int)(amount * Main.moneyMultiplier.Value);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(TechHolders), "SetHeartbeatInterval")]
|
||||||
|
static void HeartbeatMulti(ref float interval) {
|
||||||
|
interval *= Main.heartbeatIntervalMultiplier.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -32,8 +32,18 @@
|
|||||||
<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="MagnetPropertiesManager.cs" />
|
||||||
|
<Compile Include="MinerPropertiesManager.cs" />
|
||||||
|
<Compile Include="Patches.cs" />
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="ThrusterPropertiesManager.cs" />
|
||||||
|
<Compile Include="WeaponPropertiesManager.cs" />
|
||||||
|
<Compile Include="WheelPropertiesManager.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
|
89
Projects/TerraTech/TerraTech/ThrusterPropertiesManager.cs
Normal file
89
Projects/TerraTech/TerraTech/ThrusterPropertiesManager.cs
Normal file
@@ -0,0 +1,89 @@
|
|||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
51
Projects/TerraTech/TerraTech/WeaponPropertiesManager.cs
Normal file
51
Projects/TerraTech/TerraTech/WeaponPropertiesManager.cs
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using BepInEx.Configuration;
|
||||||
|
using HarmonyLib;
|
||||||
|
|
||||||
|
namespace TerraTech {
|
||||||
|
[HarmonyPatch]
|
||||||
|
public class WeaponPropertiesManager {
|
||||||
|
private static Dictionary<ModuleWeaponGun, float> shotCooldown = new Dictionary<ModuleWeaponGun, float>();
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(ModuleWeaponGun), "OnAttached")]
|
||||||
|
static void PostfixCreate(ModuleWeaponGun __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(ModuleWeaponGun), "OnDetaching")]
|
||||||
|
static void PostfixDestroy(ModuleWeaponGun __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<ModuleWeaponGun, float> keyValuePair in shotCooldown) {
|
||||||
|
DoRestoreSingle(keyValuePair.Key);
|
||||||
|
DoPatchSingle(keyValuePair.Key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DoPatchSingle(ModuleWeaponGun moduleWeaponGun) {
|
||||||
|
moduleWeaponGun.m_ShotCooldown = shotCooldown[moduleWeaponGun] / Main.shootingSpeedMultiplier.Value;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void DoRestoreSingle(ModuleWeaponGun moduleWeaponGun) {
|
||||||
|
if (shotCooldown.ContainsKey(moduleWeaponGun)) {
|
||||||
|
moduleWeaponGun.m_ShotCooldown = shotCooldown[moduleWeaponGun];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
63
Projects/TerraTech/TerraTech/WheelPropertiesManager.cs
Normal file
63
Projects/TerraTech/TerraTech/WheelPropertiesManager.cs
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
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];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user