Add vehicle movement speed patch

This commit is contained in:
2024-09-29 11:27:34 +02:00
parent fda4abd0ea
commit 32f62fff02

View File

@@ -74,6 +74,7 @@ namespace InfectionFreeZone {
public static ConfigEntry<float> buildingDeconstructionResourcesMultiplier;
public static ConfigEntry<float> humanMovementSpeedMultiplier;
public static ConfigEntry<float> vehicleMovementSpeedMultiplier;
public static ConfigEntry<bool> vehicleTrunkCapacityMultiplierDebug;
public static ConfigEntry<float> vehicleTrunkCapacityMultiplier;
@@ -146,6 +147,7 @@ namespace InfectionFreeZone {
humanMovementSpeedMultiplier = Config.Bind("General", "Human Movement Speed Multiplier", 1f);
vehicleMovementSpeedMultiplier = Config.Bind("General", "Vehicle Movement Speed Multiplier", 1f);
vehicleTrunkCapacityMultiplierDebug =
Config.Bind("General", "Vehicle Trunk Capacity Multiplier Debug", false);
@@ -382,15 +384,12 @@ namespace InfectionFreeZone {
public static void PostfixCalculateSpeedHuman(Movement __instance, ref float __result) {
if (Main.humanMovementSpeedMultiplier.Value <= 0)
return;
// Humans are "Human(Clone)", infected are "inf_human(Clone)"
if (__instance.gameObject.name != "Human(Clone)")
return;
// if (Main.debug.Value)
// Console.WriteLine($"Human movement speed is {__result}");
__result *= Main.humanMovementSpeedMultiplier.Value;
// if (Main.debug.Value)
// Console.WriteLine($"Human movement speed modified to {__result}");
// Humans are "Human(Clone)", infected are "inf_human(Clone)" and vehicles are "ve_<name>"
var name = __instance.ToString();
if (name == "Human(Clone)")
__result *= Main.humanMovementSpeedMultiplier.Value;
if (name.StartsWith("ve_"))
__result *= Main.vehicleMovementSpeedMultiplier.Value;
}
[HarmonyPostfix]