Add vehicle cargo multiplier

This commit is contained in:
2024-09-28 14:15:10 +02:00
parent d704437cc7
commit a4c81ea445
2 changed files with 24 additions and 0 deletions

View File

@@ -3,15 +3,19 @@ using System.Collections.Generic;
using System.Linq;
using BepInEx;
using BepInEx.Configuration;
using Controllers.Weather;
using GameCustomization;
using Gameplay.Buildings;
using Gameplay.GameResources;
using Gameplay.InGameResources;
using Gameplay.Scavenge;
using Gameplay.Units.Icons;
using Gameplay.Units.Movements;
using Gameplay.Units.Workers.WorkSystem.Works;
using Gameplay.Vehicles;
using HarmonyLib;
using HarmonyLib.Tools;
using Zenject;
// See:
// ConstructableWork
@@ -38,6 +42,7 @@ namespace InfectionFreeZone {
public static ConfigEntry<float> buildingQuartersCapacityMultiplier;
public static ConfigEntry<float> buildingDeconstructionResourcesMultiplier;
public static ConfigEntry<float> humanMovementSpeedMultiplier;
public static ConfigEntry<float> vehicleTrunkCapacityMultiplier;
// public static ConfigEntry<float> workSpeedMultiplier;
public void Awake() {
@@ -51,6 +56,7 @@ namespace InfectionFreeZone {
buildingDeconstructionResourcesMultiplier =
Config.Bind("General", "Building Deconstruction Resources Multiplier", 1f);
humanMovementSpeedMultiplier = Config.Bind("General", "Human Movement Speed Multiplier", 1f);
vehicleTrunkCapacityMultiplier = Config.Bind("General", "Vehicle Trunk Capacity Multiplier", 1f);
// workSpeedMultiplier = Config.Bind("General", "WorkSpeedMultiplier", 1f);
Logger.LogInfo("Cyka mod loaded");
@@ -189,5 +195,20 @@ namespace InfectionFreeZone {
// if (Main.debug.Value)
// Console.WriteLine($"Human movement speed modified to {__result}");
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Vehicle), "Constructor",
typeof(GroupIconsPool), typeof(SignalBus), typeof(WeatherController))]
public static void PostfixVehicle(ref Vehicle __instance) {
if (Main.vehicleTrunkCapacityMultiplier.Value <= 0)
return;
if (Main.debug.Value)
Console.WriteLine($"Vehicle trunk capacity is {__instance.Trunk.Capacity}");
__instance.Trunk.SetCapacity((int)(__instance.Trunk.Capacity * Main.vehicleTrunkCapacityMultiplier.Value),
true);
if (Main.debug.Value)
Console.WriteLine($"Vehicle trunk capacity modified to {__instance.Trunk.Capacity}");
}
}
}

View File

@@ -60,6 +60,9 @@
<Reference Include="Ifz">
<HintPath>$(GAME_MANAGED)/Ifz.dll</HintPath>
</Reference>
<Reference Include="Zenject">
<HintPath>$(GAME_MANAGED)/Zenject.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets"/>
</Project>