Add work speed and gather multipliers
This commit is contained in:
@@ -3,6 +3,9 @@ using System.Linq;
|
|||||||
using BepInEx;
|
using BepInEx;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using GameCustomization;
|
using GameCustomization;
|
||||||
|
using Gameplay.GameResources;
|
||||||
|
using Gameplay.Units.Player.Workers.WorkSystem;
|
||||||
|
using Gameplay.Units.Workers;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using HarmonyLib.Tools;
|
using HarmonyLib.Tools;
|
||||||
|
|
||||||
@@ -16,11 +19,15 @@ namespace InfectionFreeZone {
|
|||||||
public static ConfigEntry<bool> debug;
|
public static ConfigEntry<bool> debug;
|
||||||
|
|
||||||
public static ConfigEntry<float> resourceMultiplier;
|
public static ConfigEntry<float> resourceMultiplier;
|
||||||
|
public static ConfigEntry<float> resourceGatheringMultiplier;
|
||||||
|
public static ConfigEntry<float> workSpeedMultiplier;
|
||||||
|
|
||||||
public void Awake() {
|
public void Awake() {
|
||||||
debug = Config.Bind("General", "Debug", false);
|
debug = Config.Bind("General", "Debug", false);
|
||||||
|
|
||||||
resourceMultiplier = Config.Bind("General", "ResourceMultiplier", 1f);
|
resourceMultiplier = Config.Bind("General", "ResourceMultiplier", 1f);
|
||||||
|
resourceGatheringMultiplier = Config.Bind("General", "ResourceGatheringMultiplier", 1f);
|
||||||
|
workSpeedMultiplier = Config.Bind("General", "WorkSpeedMultiplier", 1f);
|
||||||
|
|
||||||
Logger.LogInfo("Cyka mod loaded");
|
Logger.LogInfo("Cyka mod loaded");
|
||||||
HarmonyFileLog.Enabled = true;
|
HarmonyFileLog.Enabled = true;
|
||||||
@@ -47,6 +54,53 @@ namespace InfectionFreeZone {
|
|||||||
Console.WriteLine($"Resource multiplier modified to {multiplier}");
|
Console.WriteLine($"Resource multiplier modified to {multiplier}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(Work), "AddProfit")]
|
||||||
|
public static void PostfixGatheredResource(ref ResourceID resourceID, ref float amount) {
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine($"Gathered resource {resourceID} x {amount}");
|
||||||
|
if (amount > 0) {
|
||||||
|
amount *= Main.resourceGatheringMultiplier.Value;
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine($"Gathered resource modified to {resourceID} x {amount}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(typeof(WorkBase), "SetProgress")]
|
||||||
|
public static void PostfixSetProgress(WorkBase __instance, ref float progress) {
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine($"Progress is {progress}");
|
||||||
|
if (progress > 0) {
|
||||||
|
var traversed = Traverse.Create(__instance);
|
||||||
|
var _previousProgress = traversed.Field<float>("_previousProgress");
|
||||||
|
var delta = progress - _previousProgress.Value;
|
||||||
|
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine($"Delta is {delta}");
|
||||||
|
|
||||||
|
progress += delta * Main.workSpeedMultiplier.Value;
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine($"Progress modified to {progress}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Maybe prefix this with __instance
|
||||||
|
// And then calculate the delta and update progress with progress+delta
|
||||||
|
// Or like progress+delta*multiplier
|
||||||
|
// public void SetProgress(float progress)
|
||||||
|
// {
|
||||||
|
// this._previousProgress = this._progress;
|
||||||
|
// this._progress = progress;
|
||||||
|
// this.ProgressDelta = this._progress - this._previousProgress;
|
||||||
|
// Action<float> onProgressUpdated = this.OnProgressUpdated;
|
||||||
|
// if (onProgressUpdated != null)
|
||||||
|
// {
|
||||||
|
// onProgressUpdated(this._progress);
|
||||||
|
// }
|
||||||
|
// this.ProgressUpdated(this._progress);
|
||||||
|
// }
|
||||||
//
|
//
|
||||||
// [HarmonyPrefix]
|
// [HarmonyPrefix]
|
||||||
// [HarmonyPatch(typeof(UiController), "ChangeGameSpeed")]
|
// [HarmonyPatch(typeof(UiController), "ChangeGameSpeed")]
|
||||||
|
Reference in New Issue
Block a user