Add speed multiplier for humans
This commit is contained in:
@@ -8,6 +8,7 @@ using Gameplay.Buildings;
|
|||||||
using Gameplay.GameResources;
|
using Gameplay.GameResources;
|
||||||
using Gameplay.InGameResources;
|
using Gameplay.InGameResources;
|
||||||
using Gameplay.Scavenge;
|
using Gameplay.Scavenge;
|
||||||
|
using Gameplay.Units.Movements;
|
||||||
using Gameplay.Units.Workers.WorkSystem.Works;
|
using Gameplay.Units.Workers.WorkSystem.Works;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using HarmonyLib.Tools;
|
using HarmonyLib.Tools;
|
||||||
@@ -18,7 +19,8 @@ using HarmonyLib.Tools;
|
|||||||
// GatherResourcesWork
|
// GatherResourcesWork
|
||||||
// GatherableObject
|
// GatherableObject
|
||||||
// AreaWork
|
// AreaWork
|
||||||
|
// Gameplay.Vehicles.Vehicle.Update() : void @060044A1
|
||||||
|
// System.Single Gameplay.Units.Movements.Movement::CalculateSpeed()
|
||||||
|
|
||||||
namespace InfectionFreeZone {
|
namespace InfectionFreeZone {
|
||||||
[BepInPlugin(pluginGuid, pluginName, pluginVersion)]
|
[BepInPlugin(pluginGuid, pluginName, pluginVersion)]
|
||||||
@@ -35,6 +37,7 @@ namespace InfectionFreeZone {
|
|||||||
public static ConfigEntry<float> buildingStorageCapacityMultiplier;
|
public static ConfigEntry<float> buildingStorageCapacityMultiplier;
|
||||||
public static ConfigEntry<float> buildingQuartersCapacityMultiplier;
|
public static ConfigEntry<float> buildingQuartersCapacityMultiplier;
|
||||||
public static ConfigEntry<float> buildingDeconstructionResourcesMultiplier;
|
public static ConfigEntry<float> buildingDeconstructionResourcesMultiplier;
|
||||||
|
public static ConfigEntry<float> humanMovementSpeedMultiplier;
|
||||||
// public static ConfigEntry<float> workSpeedMultiplier;
|
// public static ConfigEntry<float> workSpeedMultiplier;
|
||||||
|
|
||||||
public void Awake() {
|
public void Awake() {
|
||||||
@@ -45,7 +48,9 @@ namespace InfectionFreeZone {
|
|||||||
resourceScavengingMultiplier = Config.Bind("General", "Resource Scavenging Multiplier", 1f);
|
resourceScavengingMultiplier = Config.Bind("General", "Resource Scavenging Multiplier", 1f);
|
||||||
buildingStorageCapacityMultiplier = Config.Bind("General", "Building Storage Capacity Multiplier", 1f);
|
buildingStorageCapacityMultiplier = Config.Bind("General", "Building Storage Capacity Multiplier", 1f);
|
||||||
buildingQuartersCapacityMultiplier = Config.Bind("General", "Building Quarters Capacity Multiplier", 1f);
|
buildingQuartersCapacityMultiplier = Config.Bind("General", "Building Quarters Capacity Multiplier", 1f);
|
||||||
buildingDeconstructionResourcesMultiplier = Config.Bind("General", "BuildingDeconstructionResourcesMultiplier", 1f);
|
buildingDeconstructionResourcesMultiplier =
|
||||||
|
Config.Bind("General", "Building Deconstruction Resources Multiplier", 1f);
|
||||||
|
humanMovementSpeedMultiplier = Config.Bind("General", "Human Movement Speed Multiplier", 1f);
|
||||||
// workSpeedMultiplier = Config.Bind("General", "WorkSpeedMultiplier", 1f);
|
// workSpeedMultiplier = Config.Bind("General", "WorkSpeedMultiplier", 1f);
|
||||||
|
|
||||||
Logger.LogInfo("Cyka mod loaded");
|
Logger.LogInfo("Cyka mod loaded");
|
||||||
@@ -168,96 +173,21 @@ namespace InfectionFreeZone {
|
|||||||
Console.WriteLine($"Resource quantity value modified to {resourceQuantity.value}");
|
Console.WriteLine($"Resource quantity value modified to {resourceQuantity.value}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// private void InstantiateResources()
|
|
||||||
// {
|
|
||||||
// foreach (KeyValuePair<ResourceID, int> generatedResource in this._resourcesToDrop)
|
|
||||||
// {
|
|
||||||
// for (int i = 0; i < generatedResource.Value; i++)
|
|
||||||
// {
|
|
||||||
// this.InstantiateResource(generatedResource.Key);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// this._resourcesCreated = true;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// [HarmonyPrefix]
|
[HarmonyPostfix]
|
||||||
// [HarmonyPatch(typeof(WorkBase), "SetProgress")]
|
[HarmonyPatch(typeof(Movement), "CalculateSpeed")]
|
||||||
// public static void PostfixSetProgress(WorkBase __instance, ref float progress) {
|
public static void PostfixCalculateSpeedHuman(Movement __instance, ref float __result) {
|
||||||
// if (Main.debug.Value)
|
if (Main.humanMovementSpeedMultiplier.Value <= 0)
|
||||||
// Console.WriteLine($"Progress is {progress}");
|
return;
|
||||||
// if (progress > 0) {
|
// Humans are "Human(Clone)", infected are "inf_human(Clone)"
|
||||||
// var traversed = Traverse.Create(__instance);
|
if (__instance.gameObject.name != "Human(Clone)")
|
||||||
// var _previousProgress = traversed.Field<float>("_previousProgress");
|
return;
|
||||||
// if (Main.debug.Value)
|
|
||||||
// Console.WriteLine($"_previousProgress is {_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
|
if (Main.debug.Value)
|
||||||
// And then calculate the delta and update progress with progress+delta
|
Console.WriteLine($"Human movement speed is {__result}");
|
||||||
// Or like progress+delta*multiplier
|
__result *= Main.humanMovementSpeedMultiplier.Value;
|
||||||
// public void SetProgress(float progress)
|
if (Main.debug.Value)
|
||||||
// {
|
Console.WriteLine($"Human movement speed modified to {__result}");
|
||||||
// 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]
|
|
||||||
// [HarmonyPatch(typeof(UiController), "ChangeGameSpeed")]
|
|
||||||
// public static void PrefixSpeed(ref int gameSpeed) {
|
|
||||||
// if (Main.debug.Value)
|
|
||||||
// Console.WriteLine($"Game speed is {gameSpeed}");
|
|
||||||
// if (gameSpeed > 1) {
|
|
||||||
// gameSpeed = Main.fastSpeed.Value;
|
|
||||||
// if (Main.debug.Value)
|
|
||||||
// Console.WriteLine($"Game speed modified to {gameSpeed}");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// [HarmonyPrefix]
|
|
||||||
// [HarmonyPatch(typeof(StaffModel), "UpdateXp")]
|
|
||||||
// public static void PrefixXp(ref int id, ref int amount) {
|
|
||||||
// if (Main.debug.Value)
|
|
||||||
// Console.WriteLine($"Staff xp is {amount}");
|
|
||||||
// if (amount > 0) {
|
|
||||||
// amount = (int)(amount * Main.staffXpMultiplier.Value);
|
|
||||||
// if (Main.debug.Value)
|
|
||||||
// Console.WriteLine($"Staff xp modified to {amount}");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// [HarmonyPostfix]
|
|
||||||
// [HarmonyPatch(typeof(TechTreeModel), nameof(TechTreeModel.GetBonusPeoplePerMinute))]
|
|
||||||
// public static void PostfixPeoplePerMinute(ref float __result) {
|
|
||||||
// __result *= Main.peoplePerMinuteMultiplier.Value;
|
|
||||||
// __result += Main.peoplePerMinuteOffset.Value;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// [HarmonyPostfix]
|
|
||||||
// [HarmonyPatch(typeof(TavernModel), nameof(TavernModel.GetQuality))]
|
|
||||||
// public static void PostfixQuality(ref int __result) {
|
|
||||||
// if (Main.debug.Value)
|
|
||||||
// Console.WriteLine($"Quality is {__result}");
|
|
||||||
// if (__result > 0) {
|
|
||||||
// __result = (int)(__result * Main.prestigeMultiplier.Value);
|
|
||||||
// if (Main.debug.Value)
|
|
||||||
// Console.WriteLine($"Quality modified to {__result}");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Reference in New Issue
Block a user