Implement fuel recharge faster
This commit is contained in:
@@ -7,10 +7,8 @@ using HarmonyLib;
|
|||||||
using HarmonyLib.Tools;
|
using HarmonyLib.Tools;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
// TODO: Make attractor more range
|
|
||||||
// TODO: Make battery bigger
|
// TODO: Make battery bigger
|
||||||
// TODO: Make shield and repair bigger
|
// TODO: Make shield and repair bigger
|
||||||
// TODO: Make turbo more turbo
|
|
||||||
|
|
||||||
namespace TerraTech {
|
namespace TerraTech {
|
||||||
[BepInPlugin(pluginGuid, pluginName, pluginVersion)]
|
[BepInPlugin(pluginGuid, pluginName, pluginVersion)]
|
||||||
@@ -30,6 +28,7 @@ namespace TerraTech {
|
|||||||
public static ConfigEntry<float> magnetRadiusMultiplier;
|
public static ConfigEntry<float> magnetRadiusMultiplier;
|
||||||
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 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)));
|
||||||
@@ -50,6 +49,8 @@ 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("General", "Beam Radius Multiplier", 1f,
|
beamRadiusMultiplier = Config.Bind("General", "Beam Radius Multiplier", 1f,
|
||||||
new ConfigDescription("Beam Radius Multiplier", new AcceptableValueRange<float>(1f, 16f)));
|
new ConfigDescription("Beam Radius Multiplier", new AcceptableValueRange<float>(1f, 16f)));
|
||||||
|
beamRadiusMultiplier = Config.Bind("General", "Fuel Tank Refill Rate Multiplier", 1f,
|
||||||
|
new ConfigDescription("Fuel Tank Refill Rate Multiplier", new AcceptableValueRange<float>(1f, 32f)));
|
||||||
|
|
||||||
allProjectilesHoming = Config.Bind("General", "Make All Projectiles Home", false);
|
allProjectilesHoming = Config.Bind("General", "Make All Projectiles Home", false);
|
||||||
|
|
||||||
@@ -57,6 +58,9 @@ namespace TerraTech {
|
|||||||
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();
|
||||||
|
beamRadiusMultiplier.SettingChanged += (sender, args) => BeamPropertiesManager.DoPatch();
|
||||||
|
fuelTankRefillMultiplier.SettingChanged += (sender, args) => FuelPropertiesManager.DoPatch();
|
||||||
|
|
||||||
Logger.LogInfo("Cyka mod loaded");
|
Logger.LogInfo("Cyka mod loaded");
|
||||||
HarmonyFileLog.Enabled = true;
|
HarmonyFileLog.Enabled = true;
|
||||||
@@ -69,18 +73,21 @@ namespace TerraTech {
|
|||||||
|
|
||||||
[HarmonyPatch]
|
[HarmonyPatch]
|
||||||
public class Patches {
|
public class Patches {
|
||||||
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ManLicenses), "AddXP")]
|
[HarmonyPatch(typeof(ManLicenses), "AddXP")]
|
||||||
static void XPMulti(FactionSubTypes corporation, ref int xp, bool showUI = true) {
|
static void XPMulti(FactionSubTypes corporation, ref int xp, bool showUI = true) {
|
||||||
xp = (int)(xp * Main.xpMultiplier.Value);
|
xp = (int)(xp * Main.xpMultiplier.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(ManPlayer), "AddMoney")]
|
[HarmonyPatch(typeof(ManPlayer), "AddMoney")]
|
||||||
static void MoneyMulti(ref int amount) {
|
static void MoneyMulti(ref int amount) {
|
||||||
amount = (int)(amount * Main.moneyMultiplier.Value);
|
amount = (int)(amount * Main.moneyMultiplier.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(typeof(TechHolders), "SetHeartbeatInterval")]
|
[HarmonyPatch(typeof(TechHolders), "SetHeartbeatInterval")]
|
||||||
static void MoneyMulti(ref float interval) {
|
static void HeartbeatMulti(ref float interval) {
|
||||||
interval *= Main.heartbeatIntervalMultiplier.Value;
|
interval *= Main.heartbeatIntervalMultiplier.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,6 +200,57 @@ namespace TerraTech {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[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]
|
[HarmonyPatch]
|
||||||
public class MagnetPropertiesManager {
|
public class MagnetPropertiesManager {
|
||||||
private static Dictionary<ModuleItemHolderMagnet, float> strenghts = new Dictionary<ModuleItemHolderMagnet, float>();
|
private static Dictionary<ModuleItemHolderMagnet, float> strenghts = new Dictionary<ModuleItemHolderMagnet, float>();
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user