Add scavenge multiplier item
This commit is contained in:
@@ -1,14 +1,24 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using BepInEx;
|
using BepInEx;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using GameCustomization;
|
using GameCustomization;
|
||||||
using Gameplay.GameResources;
|
using Gameplay.GameResources;
|
||||||
|
using Gameplay.Scavenge;
|
||||||
using Gameplay.Units.Player.Workers.WorkSystem;
|
using Gameplay.Units.Player.Workers.WorkSystem;
|
||||||
using Gameplay.Units.Workers;
|
using Gameplay.Units.Workers;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using HarmonyLib.Tools;
|
using HarmonyLib.Tools;
|
||||||
|
|
||||||
|
// See:
|
||||||
|
// ConstructableWork
|
||||||
|
// ProductionWork
|
||||||
|
// GatherResourceWork
|
||||||
|
// GatherableObject
|
||||||
|
// AreaWork
|
||||||
|
|
||||||
|
|
||||||
namespace InfectionFreeZone {
|
namespace InfectionFreeZone {
|
||||||
[BepInPlugin(pluginGuid, pluginName, pluginVersion)]
|
[BepInPlugin(pluginGuid, pluginName, pluginVersion)]
|
||||||
public class Main : BaseUnityPlugin {
|
public class Main : BaseUnityPlugin {
|
||||||
@@ -20,6 +30,7 @@ namespace InfectionFreeZone {
|
|||||||
|
|
||||||
public static ConfigEntry<float> resourceMultiplier;
|
public static ConfigEntry<float> resourceMultiplier;
|
||||||
public static ConfigEntry<float> resourceGatheringMultiplier;
|
public static ConfigEntry<float> resourceGatheringMultiplier;
|
||||||
|
public static ConfigEntry<float> resourceScavengingMultiplier;
|
||||||
// public static ConfigEntry<float> workSpeedMultiplier;
|
// public static ConfigEntry<float> workSpeedMultiplier;
|
||||||
|
|
||||||
public void Awake() {
|
public void Awake() {
|
||||||
@@ -27,6 +38,7 @@ namespace InfectionFreeZone {
|
|||||||
|
|
||||||
resourceMultiplier = Config.Bind("General", "ResourceMultiplier", 1f);
|
resourceMultiplier = Config.Bind("General", "ResourceMultiplier", 1f);
|
||||||
resourceGatheringMultiplier = Config.Bind("General", "ResourceGatheringMultiplier", 1f);
|
resourceGatheringMultiplier = Config.Bind("General", "ResourceGatheringMultiplier", 1f);
|
||||||
|
resourceScavengingMultiplier = Config.Bind("General", "ResourceScavengingMultiplier", 1f);
|
||||||
// workSpeedMultiplier = Config.Bind("General", "WorkSpeedMultiplier", 1f);
|
// workSpeedMultiplier = Config.Bind("General", "WorkSpeedMultiplier", 1f);
|
||||||
|
|
||||||
Logger.LogInfo("Cyka mod loaded");
|
Logger.LogInfo("Cyka mod loaded");
|
||||||
@@ -67,6 +79,29 @@ namespace InfectionFreeZone {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(typeof(ScavengeWork), MethodType.Constructor,
|
||||||
|
typeof(float), typeof(List<ResourceCrate>))]
|
||||||
|
public static void PostfixScavengeWork(ref ScavengeWork __instance) {
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine($"Scavenge work created");
|
||||||
|
if (Main.resourceScavengingMultiplier.Value > 0) {
|
||||||
|
for (int i = 0; i < __instance.ResourcesToFind.Count; i++) {
|
||||||
|
var resource = __instance.ResourcesToFind[i];
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine($"Resource {resource} to find");
|
||||||
|
var rtraverse = Traverse.Create(resource);
|
||||||
|
var resourceCount = rtraverse.Field<float>($"_quantity");
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine($"Resource count is {resourceCount}");
|
||||||
|
resourceCount.Value *= Main.resourceScavengingMultiplier.Value;
|
||||||
|
if (Main.debug.Value)
|
||||||
|
Console.WriteLine($"Resource count modified to {resourceCount}");
|
||||||
|
rtraverse.Field<float>($"_quantity").Value = resourceCount.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// [HarmonyPrefix]
|
// [HarmonyPrefix]
|
||||||
// [HarmonyPatch(typeof(WorkBase), "SetProgress")]
|
// [HarmonyPatch(typeof(WorkBase), "SetProgress")]
|
||||||
// public static void PostfixSetProgress(WorkBase __instance, ref float progress) {
|
// public static void PostfixSetProgress(WorkBase __instance, ref float progress) {
|
||||||
|
Reference in New Issue
Block a user