diff --git a/FastTrack/GamePatches/FastAttributePatches.cs b/FastTrack/GamePatches/FastAttributePatches.cs index 4d7da3f3..e4f8685a 100644 --- a/FastTrack/GamePatches/FastAttributePatches.cs +++ b/FastTrack/GamePatches/FastAttributePatches.cs @@ -252,8 +252,8 @@ public static class ManualGenerator_OnWorkTick_Patch { /// Applied before OnWorkTick runs. /// [HarmonyPriority(Priority.Low)] - internal static bool Prefix(ref bool __result, Generator ___generator, Worker worker, - float dt) { + internal static bool Prefix(ref bool __result, Generator ___generator, + KMonoBehaviour worker, float dt) { var circuitManager = Game.Instance.circuitManager; bool charged = false; if (circuitManager != null) { @@ -288,7 +288,8 @@ public static class Workable_GetEfficiencyMultiplier_Patch { /// Applied before GetEfficiencyMultiplier runs. /// [HarmonyPriority(Priority.Low)] - internal static bool Prefix(Worker worker, ref float __result, Workable __instance) { + internal static bool Prefix(KMonoBehaviour worker, ref float __result, + Workable __instance) { float mult = 1f; int cell; var ac = __instance.attributeConverter; @@ -307,7 +308,7 @@ internal static bool Prefix(Worker worker, ref float __result, Workable __instan bool lit; if (Grid.LightIntensity[cell] > 0) { lit = true; - mult += TUNING.DUPLICANTSTATS.LIGHT.LIGHT_WORK_EFFICIENCY_BONUS; + mult += TUNING.DUPLICANTSTATS.STANDARD.Light.LIGHT_WORK_EFFICIENCY_BONUS; if (hv == Guid.Empty && worker.TryGetComponent(out KSelectable ks)) handle = ks.AddStatusItem(Db.Get().DuplicantStatusItems. LightWorkEfficiencyBonus, __instance); @@ -329,7 +330,7 @@ internal static bool Prefix(Worker worker, ref float __result, Workable __instan /// /// Applied to Worker to work more efficiently using faster attribute leveling! /// - [HarmonyPatch(typeof(Worker), nameof(Worker.Work), typeof(float))] + [HarmonyPatch(typeof(StandardWorker), nameof(StandardWorker.Work), typeof(float))] public static class Worker_Work_Patch { internal static bool Prepare() => FastTrackOptions.Instance.FastAttributesMode; @@ -339,10 +340,10 @@ public static class Worker_Work_Patch { /// The attribute being trained. /// The worker doing the job. /// The time since the last update. - /// The worker's total experience resume. - private static Workable UpdateExperience(Attribute workAttribute, Worker worker, - float dt, MinionResume resume) { - var workable = worker.workable; + /// The location where the experience gained will be stored. + private static Workable UpdateExperience(Attribute workAttribute, WorkerBase worker, + float dt, IExperienceRecipient recipient) { + var workable = worker.GetWorkable(); if (worker.TryGetComponent(out AttributeLevels levels) && workAttribute != null && workAttribute.IsTrainable) { var lookup = LookupAttributeLevel.GetAttributeLookup(levels); @@ -354,8 +355,8 @@ private static Workable UpdateExperience(Attribute workAttribute, Worker worker, levels.AddExperience(workAttribute.Id, dt, exp); } string experienceGroup = workable.GetSkillExperienceSkillGroup(); - if (resume != null && experienceGroup != null) - resume.AddExperienceWithAptitude(experienceGroup, dt, workable. + if (recipient != null && experienceGroup != null) + recipient.AddExperienceWithAptitude(experienceGroup, dt, workable. GetSkillExperienceMultiplier()); return workable; } @@ -367,13 +368,14 @@ private static Workable UpdateExperience(Attribute workAttribute, Worker worker, internal static TranspiledMethod Transpiler(TranspiledMethod instructions) { var getAttribute = typeof(Workable).GetMethodSafe(nameof(Workable. GetWorkAttribute), false); - var getResume = typeof(Worker).GetFieldSafe(nameof(Worker.resume), false); + var getTarget = typeof(StandardWorker).GetFieldSafe(nameof(StandardWorker. + experienceRecipient), false); var updateExp = typeof(Worker_Work_Patch).GetMethodSafe(nameof(UpdateExperience), - true, typeof(Attribute), typeof(Worker), typeof(float), typeof(MinionResume)); + true, typeof(Attribute), typeof(StandardWorker), typeof(float), typeof(MinionResume)); var getEfficiency = typeof(Workable).GetMethodSafe(nameof(Workable. - GetEfficiencyMultiplier), false, typeof(Worker)); + GetEfficiencyMultiplier), false, typeof(WorkerBase)); int state = 0; - if (getAttribute != null && getEfficiency != null && getResume != null && + if (getAttribute != null && getEfficiency != null && getTarget != null && updateExp != null) foreach (var instr in instructions) { if (state == 1 && instr.Is(OpCodes.Callvirt, getEfficiency)) { @@ -381,7 +383,7 @@ internal static TranspiledMethod Transpiler(TranspiledMethod instructions) { // Load this yield return new CodeInstruction(OpCodes.Ldarg_0); #if DEBUG - PUtil.LogDebug("Patched Worker.Work"); + PUtil.LogDebug("Patched StandardWorker.Work"); #endif } if (state != 1) @@ -394,7 +396,7 @@ internal static TranspiledMethod Transpiler(TranspiledMethod instructions) { yield return new CodeInstruction(OpCodes.Ldarg_1); // Load this.resume yield return new CodeInstruction(OpCodes.Ldarg_0); - yield return new CodeInstruction(OpCodes.Ldfld, getResume); + yield return new CodeInstruction(OpCodes.Ldfld, getTarget); // Call our method yield return new CodeInstruction(OpCodes.Call, updateExp); state = 1; diff --git a/FastTrack/SensorPatches/FastReachabilityMonitor.cs b/FastTrack/SensorPatches/FastReachabilityMonitor.cs index 10de16ce..382da55d 100644 --- a/FastTrack/SensorPatches/FastReachabilityMonitor.cs +++ b/FastTrack/SensorPatches/FastReachabilityMonitor.cs @@ -196,12 +196,13 @@ internal static bool Prefix(int cell, ref bool __result) { /// /// Applied to MinionGroupProber to use our check for reachability instead of its own. /// - [HarmonyPatch(typeof(MinionGroupProber), nameof(MinionGroupProber.IsReachable_AssumeLock))] - public static class MinionGroupProber_IsReachableAssumeLock_Patch { + [HarmonyPatch(typeof(MinionGroupProber), nameof(MinionGroupProber.IsReachable), + typeof(int))] + public static class MinionGroupProber_IsReachable_Patch { internal static bool Prepare() => FastTrackOptions.Instance.FastReachability; /// - /// Applied before IsReachable_AssumeLock runs. + /// Applied before IsReachable runs. /// [HarmonyPriority(Priority.Low)] internal static bool Prefix(int cell, ref bool __result) { diff --git a/FastTrack/UIPatches/MeterScreenPatches.cs b/FastTrack/UIPatches/MeterScreenPatches.cs index 35a59c5f..3ba8bdf7 100644 --- a/FastTrack/UIPatches/MeterScreenPatches.cs +++ b/FastTrack/UIPatches/MeterScreenPatches.cs @@ -95,11 +95,11 @@ internal static bool Prefix(KMonoBehaviour ___sparkLayer) { } /// - /// Applied to MeterScreen to reduce allocations and speed up getting the list of + /// Applied to MeterScreen_Stress to reduce allocations and speed up getting the list of /// Duplicants by stress value. /// - [HarmonyPatch(typeof(MeterScreen), nameof(MeterScreen.GetStressedMinions))] - public static class MeterScreen_GetStressedMinions_Patch { + [HarmonyPatch(typeof(MeterScreen_Stress), nameof(MeterScreen_Stress.GetStressedMinions))] + public static class MeterScreen_Stress_GetStressedMinions_Patch { /// /// Avoids allocating new lists every frame. /// @@ -112,13 +112,13 @@ public static class MeterScreen_GetStressedMinions_Patch { /// Applied before GetStressedMinions runs. /// [HarmonyPriority(Priority.Low)] - internal static bool Prefix(MeterScreen __instance, ref IList __result) - { + internal static bool Prefix(MeterScreen_Stress __instance, + ref IList __result) { var stressAmount = Db.Get().Amounts.Stress; var duplicants = __instance.GetWorldMinionIdentities(); var result = CACHED_LIST; int n = duplicants.Count; - var byStress = ListPool.Allocate(); + var byStress = ListPool.Allocate(); result.Clear(); // The previous comparer looked up the stress on every comparison! for (int i = 0; i < n; i++) { diff --git a/MoreAchievements/Criteria/CollectNArtifacts.cs b/MoreAchievements/Criteria/CollectNArtifacts.cs index de81b99d..1c16d434 100644 --- a/MoreAchievements/Criteria/CollectNArtifacts.cs +++ b/MoreAchievements/Criteria/CollectNArtifacts.cs @@ -27,7 +27,7 @@ public sealed class CollectNArtifacts : ColonyAchievementRequirement, Achievemen /// /// The number of artifacts required. /// - protected int required; + private int required; public CollectNArtifacts(int required) { this.required = Math.Max(1, required); diff --git a/SandboxTools/FilteredDestroyTool.cs b/SandboxTools/FilteredDestroyTool.cs index 22a0b891..773230eb 100644 --- a/SandboxTools/FilteredDestroyTool.cs +++ b/SandboxTools/FilteredDestroyTool.cs @@ -132,6 +132,7 @@ internal FilteredDestroyTool() { SandboxToolsStrings.DESTROY_SHIPPING) }; pendingCells = new HashSet(); +#pragma warning disable CS0168 try { // Take from stock tool if possible color = RECENTLY_AFFECTED.Get(SandboxDestroyerTool.instance); @@ -142,6 +143,7 @@ internal FilteredDestroyTool() { // Use default color = new Color(1f, 1f, 1f, 0.1f); } +#pragma warning restore CS0168 // Read value at runtime if possible numObjectLayers = (int)PGameUtils.GetObjectLayer(nameof(ObjectLayer.NumLayers), ObjectLayer.NumLayers); diff --git a/TurnBackTheClock/MD509629.cs b/TurnBackTheClock/MD509629.cs index f85db85c..a89f2b4c 100644 --- a/TurnBackTheClock/MD509629.cs +++ b/TurnBackTheClock/MD509629.cs @@ -36,12 +36,12 @@ internal static bool Prepare() => TurnBackTheClockOptions.Instance. internal static void Postfix(Diet.Info[] __result) { var oldInfo = __result[0]; - // BUG: Klei still has not set the disease per produced kg correctly __result[0] = new Diet.Info(new HashSet { "ForestTree" }, oldInfo.producedElement, oldInfo.caloriesPerKg, oldInfo. producedConversionRate, null, oldInfo.diseasePerKgProduced, oldInfo. - produceSolidTile, oldInfo.eatsPlantsDirectly); + produceSolidTile, oldInfo.foodType, oldInfo.emmitDiseaseOnCell, + oldInfo.eatAnims); } } diff --git a/TurnBackTheClock/TurnBackTheClock.csproj b/TurnBackTheClock/TurnBackTheClock.csproj index ae1b5787..dbf69d09 100644 --- a/TurnBackTheClock/TurnBackTheClock.csproj +++ b/TurnBackTheClock/TurnBackTheClock.csproj @@ -2,13 +2,13 @@ Turn Back The Clock - 1.4.0.0 + 1.5.0.0 PeterHan.TurnBackTheClock Changes the game to be more like previous versions. 1.2.0.0 true VANILLA_ID - 535720 + 642443 Vanilla;Mergedown