diff --git a/1.4/Assemblies/PrisonLabor.dll b/1.4/Assemblies/PrisonLabor.dll
index 4bbf5297..a222488e 100644
Binary files a/1.4/Assemblies/PrisonLabor.dll and b/1.4/Assemblies/PrisonLabor.dll differ
diff --git a/1.4/CashRegistry/Assemblies/PrisonLaborCashRegistryCompatibility.dll b/1.4/CashRegistry/Assemblies/PrisonLaborCashRegistryCompatibility.dll
index 643151f5..923300aa 100644
Binary files a/1.4/CashRegistry/Assemblies/PrisonLaborCashRegistryCompatibility.dll and b/1.4/CashRegistry/Assemblies/PrisonLaborCashRegistryCompatibility.dll differ
diff --git a/1.4/CleaningArea/Assemblies/PrisonLaborCleaningAreaCompatibility.dll b/1.4/CleaningArea/Assemblies/PrisonLaborCleaningAreaCompatibility.dll
index d0ccee3f..b64c769d 100644
Binary files a/1.4/CleaningArea/Assemblies/PrisonLaborCleaningAreaCompatibility.dll and b/1.4/CleaningArea/Assemblies/PrisonLaborCleaningAreaCompatibility.dll differ
diff --git a/1.4/Hospitality/Assemblies/PrisonLaborHospitalityCompatibility.dll b/1.4/Hospitality/Assemblies/PrisonLaborHospitalityCompatibility.dll
index 14758e0a..1340443d 100644
Binary files a/1.4/Hospitality/Assemblies/PrisonLaborHospitalityCompatibility.dll and b/1.4/Hospitality/Assemblies/PrisonLaborHospitalityCompatibility.dll differ
diff --git a/1.4/Kijin/Assemblies/PrisonLaborKijinCompatibility.dll b/1.4/Kijin/Assemblies/PrisonLaborKijinCompatibility.dll
index 624ca27d..65664771 100644
Binary files a/1.4/Kijin/Assemblies/PrisonLaborKijinCompatibility.dll and b/1.4/Kijin/Assemblies/PrisonLaborKijinCompatibility.dll differ
diff --git a/1.4/Kijin2/Assemblies/PrisonLaborKijinCompatibility.dll b/1.4/Kijin2/Assemblies/PrisonLaborKijinCompatibility.dll
new file mode 100644
index 00000000..624ca27d
Binary files /dev/null and b/1.4/Kijin2/Assemblies/PrisonLaborKijinCompatibility.dll differ
diff --git a/1.4/Quarry/Assemblies/PrisonLaborQuarryCompatibility.dll b/1.4/Quarry/Assemblies/PrisonLaborQuarryCompatibility.dll
index 80df66c9..4372fe41 100644
Binary files a/1.4/Quarry/Assemblies/PrisonLaborQuarryCompatibility.dll and b/1.4/Quarry/Assemblies/PrisonLaborQuarryCompatibility.dll differ
diff --git a/1.4/Therapy/Assemblies/PrisonLaborTherapyCompatibility.dll b/1.4/Therapy/Assemblies/PrisonLaborTherapyCompatibility.dll
index ea0dd7bc..b818084b 100644
Binary files a/1.4/Therapy/Assemblies/PrisonLaborTherapyCompatibility.dll and b/1.4/Therapy/Assemblies/PrisonLaborTherapyCompatibility.dll differ
diff --git a/About/About.xml b/About/About.xml
index f8196300..c01d2483 100644
--- a/About/About.xml
+++ b/About/About.xml
@@ -19,6 +19,7 @@
orion.therapy
ogliss.thewhitecrayon.quarry
ssulunge.kijinrace2
+ ssulunge.kijinrace3
orion.cashregister
orion.hospitality
orion.gastronomy
diff --git a/LoadFolders.xml b/LoadFolders.xml
index 3024e6ee..0391afd9 100644
--- a/LoadFolders.xml
+++ b/LoadFolders.xml
@@ -26,7 +26,8 @@
1.4/Hospitality
1.4/CleaningArea
1.4/CashRegistry
- 1.4/Kijin
+ 1.4/Kijin2
+ 1.4/Kijin
1.4/Quarry
\ No newline at end of file
diff --git a/README.md b/README.md
index a8c48250..f309ec5e 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
-
+
diff --git a/Source/CompatibilityProjects/KijinCompatibility/HarmonyInit.cs b/Source/CompatibilityProjects/KijinCompatibility/HarmonyInit.cs
index 69a24aa8..c9c0b41f 100644
--- a/Source/CompatibilityProjects/KijinCompatibility/HarmonyInit.cs
+++ b/Source/CompatibilityProjects/KijinCompatibility/HarmonyInit.cs
@@ -18,11 +18,11 @@ static HarmonyInit()
try
{
harmony.PatchAll(Assembly.GetExecutingAssembly());
- Log.Message("[PL] Kijin Race 2.0 patched");
+ Log.Message("[PL] Kijin Race 3.0 patched");
}
catch (Exception e)
{
- Log.Error($"[PL] Patches for Kijin Race 2.0 failed: {e}");
+ Log.Error($"[PL] Patches for Kijin Race 3.0 failed: {e}");
}
}
}
diff --git a/Source/CompatibilityProjects/KijinCompatibility/HarmonyPatches/PrisonerHarvestResourcesPatch.cs b/Source/CompatibilityProjects/KijinCompatibility/HarmonyPatches/PrisonerHarvestResourcesPatch.cs
index 7cf03de0..caaebde8 100644
--- a/Source/CompatibilityProjects/KijinCompatibility/HarmonyPatches/PrisonerHarvestResourcesPatch.cs
+++ b/Source/CompatibilityProjects/KijinCompatibility/HarmonyPatches/PrisonerHarvestResourcesPatch.cs
@@ -10,30 +10,39 @@
using Verse.AI;
using Verse;
using Verse.Noise;
+using System.Reflection.Emit;
+using PrisonLabor.HarmonyPatches;
namespace KijinCompatibility.HarmonyPatches
{
- [HarmonyPatch]
- class PrisonerHarvestResourcesPatch
+ [HarmonyPatch]
+ class PrisonerHarvestResourcesPatch
+ {
+ static MethodBase TargetMethod()
{
- static MethodBase TargetMethod()
+ return AccessTools.Method("Kijin3.Kijin3PlantCollectedPatch:GetFirstPawnNotDeadOrDowned");
+ }
+
+ static IEnumerable Transpiler(IEnumerable instructions)
+ {
+ var codes = new List(instructions);
+ for (int i = 0; i < codes.Count(); i++)
+ {
+ if (i > 0 && ShouldPatch(codes[i], codes[i - 1]))
{
- return AccessTools.Method("Kijin2.Kijin2PlantCollectedPatch:GetFirstPawnNotDeadOrDowned");
+ yield return new CodeInstruction(OpCodes.Call, typeof(PrisonLaborUtility).GetMethod(nameof(PrisonLaborUtility.GetPawnFaction)));
}
- static Pawn Postfix(Pawn __result, IntVec3 c, Map map)
+ else
{
- if (__result == null)
- {
- foreach (Thing thing in GridsUtility.GetThingList(c, map))
- {
- Pawn val = thing as Pawn;
- if (val != null && !val.Dead && !val.Downed && val.IsPrisonerOfColony)
- {
- return val;
- }
- }
- }
- return __result;
+ yield return codes[i];
}
+ }
}
+
+ private static bool ShouldPatch(CodeInstruction actual, CodeInstruction prev)
+ {
+ return prev.opcode == OpCodes.Ldloc_2 && actual.opcode == OpCodes.Callvirt && actual.operand != null && actual.operand.ToString().Contains("RimWorld.Faction get_Faction()");
+ }
+
+ }
}
diff --git a/Source/Core/MainButton_Window/CustomTabWindow.cs b/Source/Core/MainButton_Window/CustomTabWindow.cs
index b4d25d6a..865d5136 100644
--- a/Source/Core/MainButton_Window/CustomTabWindow.cs
+++ b/Source/Core/MainButton_Window/CustomTabWindow.cs
@@ -9,112 +9,112 @@
namespace PrisonLabor.Core.MainButton_Window
{
- public abstract class CustomTabWindow : Window
+ public abstract class CustomTabWindow : Window
+ {
+ private PawnTable table;
+
+ protected virtual float ExtraBottomSpace => 53f;
+
+ protected virtual float ExtraTopSpace => 0f;
+
+ protected abstract PawnTableDef PawnTableDef
+ {
+ get;
+ }
+
+ protected override float Margin => 6f;
+
+ public virtual Vector2 RequestedTabSize
+ {
+ get
+ {
+ if (table == null)
+ {
+ return Vector2.zero;
+ }
+ return new Vector2(table.Size.x + Margin * 2f, table.Size.y + ExtraTopSpace + ExtraBottomSpace + Margin * 2f);
+ }
+ }
+
+ public virtual MainTabWindowAnchor Anchor => MainTabWindowAnchor.Left;
+
+ public override Vector2 InitialSize
+ {
+ get
+ {
+ Vector2 requestedTabSize = RequestedTabSize;
+ if (requestedTabSize.y > (float)(UI.screenHeight - 35))
+ {
+ requestedTabSize.y = UI.screenHeight - 35;
+ }
+ if (requestedTabSize.x > (float)UI.screenWidth)
+ {
+ requestedTabSize.x = UI.screenWidth;
+ }
+ return requestedTabSize;
+ }
+ }
+ protected virtual IEnumerable Pawns => Find.CurrentMap.mapPawns.FreeColonists;
+
+ public override void PostOpen()
+ {
+ base.PostOpen();
+ if (table == null)
+ {
+ table = CreateTable();
+ }
+ SetDirty();
+ }
+
+ public override void DoWindowContents(Rect rect)
+ {
+ table.PawnTableOnGUI(new Vector2(rect.x, rect.y + ExtraTopSpace));
+ }
+
+ public void Notify_PawnsChanged()
+ {
+ SetDirty();
+ }
+
+ public override void Notify_ResolutionChanged()
+ {
+ table = CreateTable();
+ base.Notify_ResolutionChanged();
+ }
+
+ private PawnTable CreateTable()
+ {
+ return (PawnTable)Activator.CreateInstance(PawnTableDef.workerClass, PawnTableDef, (Func>)(() => Pawns), UI.screenWidth - (int)(Margin * 2f), (int)((float)(UI.screenHeight - 35) - ExtraBottomSpace * 1.5f - ExtraTopSpace - Margin * 2f));
+ }
+
+ protected void SetDirty()
+ {
+ table.SetDirty();
+ SetInitialSizeAndPosition();
+ }
+ public CustomTabWindow()
+ {
+ layer = WindowLayer.GameUI;
+ soundAppear = null;
+ soundClose = SoundDefOf.TabClose;
+ doCloseButton = false;
+ doCloseX = false;
+ preventCameraMotion = false;
+ }
+
+ protected override void SetInitialSizeAndPosition()
{
- private PawnTable table;
-
- protected virtual float ExtraBottomSpace => 53f;
-
- protected virtual float ExtraTopSpace => 0f;
-
- protected abstract PawnTableDef PawnTableDef
- {
- get;
- }
-
- protected override float Margin => 6f;
-
- public virtual Vector2 RequestedTabSize
- {
- get
- {
- if (table == null)
- {
- return Vector2.zero;
- }
- return new Vector2(table.Size.x + Margin * 2f, table.Size.y + ExtraBottomSpace + ExtraTopSpace + Margin * 2f);
- }
- }
-
- public virtual MainTabWindowAnchor Anchor => MainTabWindowAnchor.Left;
-
- public override Vector2 InitialSize
- {
- get
- {
- Vector2 requestedTabSize = RequestedTabSize;
- if (requestedTabSize.y > (float)(UI.screenHeight - 35))
- {
- requestedTabSize.y = UI.screenHeight - 35;
- }
- if (requestedTabSize.x > (float)UI.screenWidth)
- {
- requestedTabSize.x = UI.screenWidth;
- }
- return requestedTabSize;
- }
- }
- protected virtual IEnumerable Pawns => Find.CurrentMap.mapPawns.FreeColonists;
-
- public override void PostOpen()
- {
- base.PostOpen();
- if (table == null)
- {
- table = CreateTable();
- }
- SetDirty();
- }
-
- public override void DoWindowContents(Rect rect)
- {
- table.PawnTableOnGUI(new Vector2(rect.x, rect.y + ExtraTopSpace));
- }
-
- public void Notify_PawnsChanged()
- {
- SetDirty();
- }
-
- public override void Notify_ResolutionChanged()
- {
- table = CreateTable();
- base.Notify_ResolutionChanged();
- }
-
- private PawnTable CreateTable()
- {
- return (PawnTable)Activator.CreateInstance(PawnTableDef.workerClass, PawnTableDef, (Func>)(() => Pawns), UI.screenWidth - (int)(Margin * 2f), (int)((float)(UI.screenHeight - 35) - ExtraBottomSpace - ExtraTopSpace - Margin * 2f));
- }
-
- protected void SetDirty()
- {
- table.SetDirty();
- SetInitialSizeAndPosition();
- }
- public CustomTabWindow()
- {
- layer = WindowLayer.GameUI;
- soundAppear = null;
- soundClose = SoundDefOf.TabClose;
- doCloseButton = false;
- doCloseX = false;
- preventCameraMotion = false;
- }
-
- protected override void SetInitialSizeAndPosition()
- {
- base.SetInitialSizeAndPosition();
- if (Anchor == MainTabWindowAnchor.Left)
- {
- windowRect.x = 0f;
- }
- else
- {
- windowRect.x = (float)UI.screenWidth - windowRect.width;
- }
- windowRect.y = (float)(UI.screenHeight - 35) - windowRect.height;
- }
-
- }
+ base.SetInitialSizeAndPosition();
+ if (Anchor == MainTabWindowAnchor.Left)
+ {
+ windowRect.x = 0f;
+ }
+ else
+ {
+ windowRect.x = (float)UI.screenWidth - windowRect.width;
+ }
+ windowRect.y = (float)(UI.screenHeight - 35) - windowRect.height;
+ }
+
+ }
}
diff --git a/Source/Core/MainButton_Window/MainTabWindow_Labor.cs b/Source/Core/MainButton_Window/MainTabWindow_Labor.cs
index ed2305a8..a1c0d9c6 100644
--- a/Source/Core/MainButton_Window/MainTabWindow_Labor.cs
+++ b/Source/Core/MainButton_Window/MainTabWindow_Labor.cs
@@ -1,6 +1,7 @@
using HarmonyLib;
using Multiplayer.API;
using PrisonLabor.Core.LaborWorkSettings;
+using PrisonLabor.Core.Other;
using RimWorld;
using System;
using System.Collections.Generic;
@@ -12,80 +13,80 @@
namespace PrisonLabor.Core.MainButton_Window
{
- public class MainTabWindow_Labor : CustomTabWindow
- {
+ public class MainTabWindow_Labor : CustomTabWindow
+ {
- protected override float ExtraTopSpace => 40f;
- protected override PawnTableDef PawnTableDef => PawnTableDefOf.Work;
+ protected override float ExtraTopSpace => 40f;
+ protected override PawnTableDef PawnTableDef => PawnTableDefOf.Work;
- protected override IEnumerable Pawns
- {
- get
- {
- foreach (var pawn in Find.CurrentMap.mapPawns.PrisonersOfColony)
- {
- if (PrisonLaborUtility.LaborEnabled(pawn))
- {
- WorkSettings.InitWorkSettings(pawn);
- yield return pawn;
- }
- }
- }
- }
- public override void DoWindowContents(Rect rect)
- {
- base.DoWindowContents(rect);
- if (Event.current.type != EventType.Layout)
- {
- DoManualPrioritiesCheckbox(rect);
- GUI.color = new Color(1f, 1f, 1f, 0.5f);
- Text.Anchor = TextAnchor.UpperCenter;
- Text.Font = GameFont.Tiny;
- Widgets.Label(new Rect(rect.x + 370f, rect.y + 5f, 160f, 30f), "<= " + "HigherPriority".Translate());
- Widgets.Label(new Rect(rect.x + 630f, rect.y + 5f, 160f, 30f), "LowerPriority".Translate() + " =>");
- GUI.color = Color.white;
- Text.Font = GameFont.Small;
- Text.Anchor = TextAnchor.UpperLeft;
- }
-
- }
+ protected override IEnumerable Pawns
+ {
+ get
+ {
+ foreach (var pawn in Find.CurrentMap.mapPawns.PrisonersOfColony)
+ {
+ if (PrisonLaborUtility.LaborEnabled(pawn))
+ {
+ WorkSettings.InitWorkSettings(pawn);
+ yield return pawn;
+ }
+ }
+ }
+ }
+ public override void DoWindowContents(Rect rect)
+ {
+ base.DoWindowContents(rect);
+ if (Event.current.type != EventType.Layout)
+ {
+ DoManualPrioritiesCheckbox(rect);
+ GUI.color = new Color(1f, 1f, 1f, 0.5f);
+ Text.Anchor = TextAnchor.UpperCenter;
+ Text.Font = GameFont.Tiny;
+ Widgets.Label(new Rect(rect.x + 370f, rect.y + 5f, 160f, 30f), "<= " + "HigherPriority".Translate());
+ Widgets.Label(new Rect(rect.x + 630f, rect.y + 5f, 160f, 30f), "LowerPriority".Translate() + " =>");
+ GUI.color = Color.white;
+ Text.Font = GameFont.Small;
+ Text.Anchor = TextAnchor.UpperLeft;
+ }
- private void DoManualPrioritiesCheckbox(Rect globalRect)
- {
- Text.Font = GameFont.Small;
- GUI.color = Color.white;
- Text.Anchor = TextAnchor.UpperLeft;
- Rect rect = new Rect(globalRect.x + 5f, globalRect.y + 5f, 140f, 30f);
- bool useWorkPriorities = Current.Game.playSettings.useWorkPriorities;
- Widgets.CheckboxLabeled(rect, "ManualPriorities".Translate(), ref Current.Game.playSettings.useWorkPriorities);
- if (useWorkPriorities != Current.Game.playSettings.useWorkPriorities)
- {
- foreach (Pawn item in PawnsFinder.AllMapsWorldAndTemporary_Alive)
- {
- if (item.IsPrisonerOfColony && item.workSettings != null)
- {
- item.workSettings.Notify_UseWorkPrioritiesChanged();
- }
- }
- }
- if (Current.Game.playSettings.useWorkPriorities)
- {
- GUI.color = new Color(1f, 1f, 1f, 0.5f);
- Text.Font = GameFont.Tiny;
- Widgets.Label(new Rect(rect.x, rect.y + rect.height + 4f, rect.width, 60f), "PriorityOneDoneFirst".Translate());
- Text.Font = GameFont.Small;
- GUI.color = Color.white;
- }
- if (!Current.Game.playSettings.useWorkPriorities)
- {
- UIHighlighter.HighlightOpportunity(rect, "ManualPriorities-Off");
- }
- }
- public override void PostOpen()
+ }
+
+ private void DoManualPrioritiesCheckbox(Rect globalRect)
+ {
+ Text.Font = GameFont.Small;
+ GUI.color = Color.white;
+ Text.Anchor = TextAnchor.UpperLeft;
+ Rect rect = new Rect(globalRect.x + 5f, globalRect.y + 5f, 140f, 30f);
+ bool useWorkPriorities = Current.Game.playSettings.useWorkPriorities;
+ Widgets.CheckboxLabeled(rect, "ManualPriorities".Translate(), ref Current.Game.playSettings.useWorkPriorities);
+ if (useWorkPriorities != Current.Game.playSettings.useWorkPriorities)
+ {
+ foreach (Pawn item in PawnsFinder.AllMapsWorldAndTemporary_Alive)
{
-
- base.PostOpen();
- Log.Message("Called PostOpen");
+ if (item.IsPrisonerOfColony && item.workSettings != null)
+ {
+ item.workSettings.Notify_UseWorkPrioritiesChanged();
+ }
}
+ }
+ if (Current.Game.playSettings.useWorkPriorities)
+ {
+ GUI.color = new Color(1f, 1f, 1f, 0.5f);
+ Text.Font = GameFont.Tiny;
+ Widgets.Label(new Rect(rect.x, rect.y + rect.height + 4f, rect.width, 60f), "PriorityOneDoneFirst".Translate());
+ Text.Font = GameFont.Small;
+ GUI.color = Color.white;
+ }
+ if (!Current.Game.playSettings.useWorkPriorities)
+ {
+ UIHighlighter.HighlightOpportunity(rect, "ManualPriorities-Off");
+ }
+ }
+ public override void PostOpen()
+ {
+
+ base.PostOpen();
+ DebugLogger.debug("Called PostOpen");
}
+ }
}
diff --git a/Source/Core/MainButton_Window/PrisonerButtonWindow.cs b/Source/Core/MainButton_Window/PrisonerButtonWindow.cs
index 7dddc2aa..4e0c68fd 100644
--- a/Source/Core/MainButton_Window/PrisonerButtonWindow.cs
+++ b/Source/Core/MainButton_Window/PrisonerButtonWindow.cs
@@ -84,7 +84,7 @@ public PrisonerButtonWindow() : base()
{
foreach(var def in DefDatabase.AllDefs)
{
- Log.Message($"Def: {def.defName}, def.dev: {def.dev}, dev: {Prefs.DevMode}");
+ DebugLogger.debug($"Def: {def.defName}, def.dev: {def.dev}, dev: {Prefs.DevMode}");
if(def.dev == false)
{
tabsView.Add(def, CreateWindow(def));
diff --git a/Source/Core/Meta/Version.cs b/Source/Core/Meta/Version.cs
index 37efac4f..e2ddf9be 100644
--- a/Source/Core/Meta/Version.cs
+++ b/Source/Core/Meta/Version.cs
@@ -83,6 +83,7 @@ public enum Version
v1_4_0,
v1_4_1,
v1_4_2,
- v1_4_3
+ v1_4_3,
+ v1_4_4
}
}
diff --git a/Source/Core/Meta/VersionUtility.cs b/Source/Core/Meta/VersionUtility.cs
index 491320b5..58a819d7 100644
--- a/Source/Core/Meta/VersionUtility.cs
+++ b/Source/Core/Meta/VersionUtility.cs
@@ -5,8 +5,8 @@ namespace PrisonLabor.Core.Meta
{
public class VersionUtility
{
- public const Version versionNumber = Version.v1_4_3;
- public const string versionString = "1.4.3";
+ public const Version versionNumber = Version.v1_4_4;
+ public const string versionString = "1.4.4";
public static Version VersionOfSaveFile { get; set; }
diff --git a/Source/HarmonyPatches/HPatcher.cs b/Source/HarmonyPatches/HPatcher.cs
index 9fb68688..4e567820 100644
--- a/Source/HarmonyPatches/HPatcher.cs
+++ b/Source/HarmonyPatches/HPatcher.cs
@@ -10,7 +10,7 @@
namespace PrisonLabor.HarmonyPatches
{
- internal static class HPatcher
+ public static class HPatcher
{
// For logging purposes, it stores whenever each fragment was completed
private static Dictionary fragments;
diff --git a/Source/HarmonyPatches/Patches_AssignBed/Patch_AssignPrisonersToBed.cs b/Source/HarmonyPatches/Patches_AssignBed/Patch_AssignPrisonersToBed.cs
index 9095e6fd..af1f4779 100644
--- a/Source/HarmonyPatches/Patches_AssignBed/Patch_AssignPrisonersToBed.cs
+++ b/Source/HarmonyPatches/Patches_AssignBed/Patch_AssignPrisonersToBed.cs
@@ -11,85 +11,74 @@
namespace PrisonLabor.HarmonyPatches.Patches_AssignBed
{
- [HarmonyPatch(typeof(Building_Bed))]
- [HarmonyPatch(nameof(Building_Bed.GetGizmos))]
- static class Patch_AssignPrisonersToBed
+ [HarmonyPatch(typeof(Building_Bed))]
+ [HarmonyPatch(nameof(Building_Bed.GetGizmos))]
+ static class Patch_AssignPrisonersToBed
+ {
+ static IEnumerable Postfix(IEnumerable __result, Building_Bed __instance)
{
- static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable instructions)
- {
- foreach (var instr in instructions)
- {
- if (instr.opcode == OpCodes.Ret)
- {
- yield return new CodeInstruction(OpCodes.Ldarg_0);
- yield return new CodeInstruction(OpCodes.Call, typeof(Patch_AssignPrisonersToBed).GetMethod(nameof(NewGizmos)));
- }
- yield return instr;
- }
- }
+ foreach (var gizmo in __result)
+ {
+ yield return gizmo;
+ }
- public static IEnumerable NewGizmos(IEnumerable gizmos, Building_Bed bed)
+ if (__instance.ForPrisoners)
+ {
+ yield return new Command_Action()
{
- foreach (var gizmo in gizmos)
- yield return gizmo;
-
- if (bed.ForPrisoners)
- {
- yield return new Command_Action()
- {
- defaultLabel = "PrisonLabor_CommandBedSetOwnerLabel".Translate(),
- defaultDesc = "PrisonLabor_CommandBedSetOwnerDesc".Translate(),
- icon = ContentFinder.Get("ui/commands/AssignOwner", true),
- action = new Action(() => Find.WindowStack.Add(new Dialog_AssignBuildingOwner(bed.CompAssignableToPawn))),
- };
- }
- }
+ defaultLabel = "PrisonLabor_CommandBedSetOwnerLabel".Translate(),
+ defaultDesc = "PrisonLabor_CommandBedSetOwnerDesc".Translate(),
+ icon = ContentFinder.Get("ui/commands/AssignOwner", true),
+ action = new Action(() => Find.WindowStack.Add(new Dialog_AssignBuildingOwner(__instance.CompAssignableToPawn))),
+ };
+ }
}
+ }
- [HarmonyPatch(typeof(CompAssignableToPawn_Bed))]
- [HarmonyPatch("get_" + nameof(CompAssignableToPawn.AssigningCandidates))]
- static class Patch_MakePrisonersCandidates
+ [HarmonyPatch(typeof(CompAssignableToPawn_Bed))]
+ [HarmonyPatch("get_" + nameof(CompAssignableToPawn.AssigningCandidates))]
+ static class Patch_MakePrisonersCandidates
+ {
+ static bool Prefix(ref IEnumerable __result, CompAssignableToPawn __instance)
{
- static bool Prefix(ref IEnumerable __result, CompAssignableToPawn __instance)
- {
- Building_Bed bed = __instance.parent as Building_Bed;
- if (bed != null && bed.Spawned && __instance is CompAssignableToPawn_Bed && bed.ForPrisoners)
- {
- __result = bed.Map.mapPawns.PrisonersOfColony;
- return false;
- }
+ Building_Bed bed = __instance.parent as Building_Bed;
+ if (bed != null && bed.Spawned && __instance is CompAssignableToPawn_Bed && bed.ForPrisoners)
+ {
+ __result = bed.Map.mapPawns.PrisonersOfColony;
+ return false;
+ }
- return true;
- }
+ return true;
}
+ }
- [HarmonyPatch(typeof(WorkGiver_Warden_TakeToBed))]
- [HarmonyPatch("TakeToPreferredBedJob")]
- static class Patch_TakePrisonersToOwnedBed
- {
- /* === Orignal code Look-up===
- *
- * if (RestUtility.FindBedFor(prisoner, prisoner, true, true, false) != null)
- * {
- * return null;
- * }
- *
- * === CIL Instructions ===
- *
- * ldarg.1 | | Label 2
- * ldarg.1 | | no labels
- * ldc.i4.1 | | no labels
- * ldc.i4.1 | | no labels
- * ldc.i4.0 | | no labels
- * call | RimWorld.Building_Bed FindBedFor(Verse.Pawn, Verse.Pawn, Boolean, Boolean, Boolean) | no labels
- * brfalse | Label 3 | no labels
- */
+ [HarmonyPatch(typeof(WorkGiver_Warden_TakeToBed))]
+ [HarmonyPatch("TakeToPreferredBedJob")]
+ static class Patch_TakePrisonersToOwnedBed
+ {
+ /* === Orignal code Look-up===
+ *
+ * if (RestUtility.FindBedFor(prisoner, prisoner, true, true, false) != null)
+ * {
+ * return null;
+ * }
+ *
+ * === CIL Instructions ===
+ *
+ * ldarg.1 | | Label 2
+ * ldarg.1 | | no labels
+ * ldc.i4.1 | | no labels
+ * ldc.i4.1 | | no labels
+ * ldc.i4.0 | | no labels
+ * call | RimWorld.Building_Bed FindBedFor(Verse.Pawn, Verse.Pawn, Boolean, Boolean, Boolean) | no labels
+ * brfalse | Label 3 | no labels
+ */
- static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable instructions)
- {
- OpCode[] opCodes1 =
+ static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable instructions)
+ {
+ OpCode[] opCodes1 =
{
OpCodes.Ldarg_0,
OpCodes.Ldarg_0,
@@ -100,8 +89,8 @@ static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase
OpCodes.Call,
OpCodes.Brfalse_S,
};
- string[] operands1 =
- {
+ string[] operands1 =
+ {
"",
"",
"",
@@ -111,37 +100,37 @@ static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase
"RimWorld.Building_Bed FindBedFor(Verse.Pawn, Verse.Pawn, Boolean, Boolean, System.Nullable`1[RimWorld.GuestStatus])",
"System.Reflection.Emit.Label",
};
- int step1 = 0;
+ int step1 = 0;
- var label_OriginalBranch = gen.DefineLabel();
- foreach (var instr in instructions)
- {
- if (HPatcher.IsFragment(opCodes1, operands1, instr, ref step1, nameof(Patch_TakePrisonersToOwnedBed), true))
- {
- yield return new CodeInstruction(OpCodes.Ldarg_1);
- yield return new CodeInstruction(OpCodes.Call, typeof(Patch_TakePrisonersToOwnedBed).GetMethod(nameof(HaveOwnedBed)));
- yield return new CodeInstruction(OpCodes.Brfalse, label_OriginalBranch);
- yield return new CodeInstruction(OpCodes.Pop);
- yield return new CodeInstruction(OpCodes.Ldarg_1);
- yield return new CodeInstruction(OpCodes.Call, typeof(Patch_TakePrisonersToOwnedBed).GetMethod(nameof(CanReachBed)));
- yield return new CodeInstruction(OpCodes.Brfalse, instr.operand);
- yield return new CodeInstruction(OpCodes.Ldnull);
- yield return new CodeInstruction(OpCodes.Ret);
+ var label_OriginalBranch = gen.DefineLabel();
+ foreach (var instr in instructions)
+ {
+ if (HPatcher.IsFragment(opCodes1, operands1, instr, ref step1, nameof(Patch_TakePrisonersToOwnedBed), true))
+ {
+ yield return new CodeInstruction(OpCodes.Ldarg_1);
+ yield return new CodeInstruction(OpCodes.Call, typeof(Patch_TakePrisonersToOwnedBed).GetMethod(nameof(HaveOwnedBed)));
+ yield return new CodeInstruction(OpCodes.Brfalse, label_OriginalBranch);
+ yield return new CodeInstruction(OpCodes.Pop);
+ yield return new CodeInstruction(OpCodes.Ldarg_1);
+ yield return new CodeInstruction(OpCodes.Call, typeof(Patch_TakePrisonersToOwnedBed).GetMethod(nameof(CanReachBed)));
+ yield return new CodeInstruction(OpCodes.Brfalse, instr.operand);
+ yield return new CodeInstruction(OpCodes.Ldnull);
+ yield return new CodeInstruction(OpCodes.Ret);
- instr.labels.Add(label_OriginalBranch);
- }
- yield return instr;
- }
+ instr.labels.Add(label_OriginalBranch);
}
+ yield return instr;
+ }
+ }
- public static bool HaveOwnedBed(Pawn pawn)
- {
- return pawn.ownership != null && pawn.ownership.OwnedBed != null;
- }
+ public static bool HaveOwnedBed(Pawn pawn)
+ {
+ return pawn.ownership != null && pawn.ownership.OwnedBed != null;
+ }
- public static bool CanReachBed(Pawn pawn)
- {
- return pawn.CanReach(pawn.ownership.OwnedBed, PathEndMode.OnCell, Danger.Some);
- }
+ public static bool CanReachBed(Pawn pawn)
+ {
+ return pawn.CanReach(pawn.ownership.OwnedBed, PathEndMode.OnCell, Danger.Some);
}
+ }
}
diff --git a/Source/HarmonyPatches/Patches_Construction/EnableConstructionFinishFrames.cs b/Source/HarmonyPatches/Patches_Construction/EnableConstructionFinishFrames.cs
deleted file mode 100644
index 0df97df8..00000000
--- a/Source/HarmonyPatches/Patches_Construction/EnableConstructionFinishFrames.cs
+++ /dev/null
@@ -1,65 +0,0 @@
-using HarmonyLib;
-using RimWorld;
-using System.Collections.Generic;
-using System.Reflection;
-using System.Reflection.Emit;
-using Verse;
-
-namespace PrisonLabor.HarmonyPatches.Patches_Construction
-{
- [HarmonyPatch(typeof(WorkGiver_ConstructFinishFrames))]
- [HarmonyPatch(nameof(WorkGiver_ConstructFinishFrames.JobOnThing))]
- static class EnableConstructionFinishFrames
- {
- /* === Orignal code Look-up===
- *
- * if (t.Faction != pawn.Faction)
- * {
- * return false;
- * }
- *
- * === CIL Instructions ===
- *
- * ldarg.2 | | no labels
- * callvirt | RimWorld.Faction get_Faction() | no labels
- * ldarg.1 | | no labels
- * callvirt | RimWorld.Faction get_Faction() | no labels
- * beq | Label 1 | no labels
- * ldc.i4.0 | | no labels
- * ret | | no labels
- * ldarg.2 | | Label 1
- */
-
- static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable instructions)
- {
- //find label to jump
- OpCode[] opCodes1 =
- {
- OpCodes.Ldarg_2,
- OpCodes.Callvirt,
- OpCodes.Ldarg_1,
- OpCodes.Callvirt,
- OpCodes.Beq_S,
- };
- string[] operands1 =
- {
- "",
- "RimWorld.Faction get_Faction()",
- "",
- "RimWorld.Faction get_Faction()",
- "System.Reflection.Emit.Label",
- };
- var label = HPatcher.FindOperandAfter(opCodes1, operands1, instructions, true);
-
- //Add If(pawn.IsPrisonerOfColony) {jump next condition}
- yield return new CodeInstruction(OpCodes.Ldarg_1);
- yield return new CodeInstruction(OpCodes.Callvirt, typeof(Pawn).GetProperty(nameof(Pawn.IsPrisoner)).GetGetMethod());
- yield return new CodeInstruction(OpCodes.Brtrue, label);
-
- foreach (var instr in instructions)
- {
- yield return instr;
- }
- }
- }
-}
diff --git a/Source/HarmonyPatches/Patches_Construction/Patch_BlueprintsForPlayerFAction.cs b/Source/HarmonyPatches/Patches_Construction/Patch_BlueprintsForPlayerFAction.cs
deleted file mode 100644
index 82cebc91..00000000
--- a/Source/HarmonyPatches/Patches_Construction/Patch_BlueprintsForPlayerFAction.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using HarmonyLib;
-using RimWorld;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Management.Instrumentation;
-using System.Reflection;
-using System.Text;
-using System.Threading.Tasks;
-using Verse;
-
-namespace PrisonLabor.HarmonyPatches.Patches_Construction
-{
- [HarmonyPatch(typeof(Blueprint), "TryReplaceWithSolidThing")]
- class Patch_BlueprintsForPlayerFaction
- {
-
- public static void Postfix(Pawn workerPawn, Thing createdThing, bool __result)
- {
-
- if (__result && createdThing != null && createdThing.def.CanHaveFaction && workerPawn.IsPrisonerOfColony)
- {
-#if DEBUG
- Log.Message($"Setting faction for: {createdThing}");
-#endif
- createdThing.SetFactionDirect(Faction.OfPlayer);
- }
-
- }
-
- }
-}
diff --git a/Source/HarmonyPatches/Patches_Construction/Patch_WorkGiver_ConstructDeliverResourcesToFrames.cs b/Source/HarmonyPatches/Patches_Construction/Patch_WorkGiver_ConstructDeliverResourcesToFrames.cs
deleted file mode 100644
index 4eb471dc..00000000
--- a/Source/HarmonyPatches/Patches_Construction/Patch_WorkGiver_ConstructDeliverResourcesToFrames.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using HarmonyLib;
-using PrisonLabor.WorkUtils;
-using RimWorld;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Reflection.Emit;
-using System.Text;
-using System.Threading.Tasks;
-using Verse;
-using Verse.AI;
-
-namespace PrisonLabor.HarmonyPatches.Patches_Construction
-{
- [HarmonyPatch(typeof(WorkGiver_ConstructDeliverResourcesToFrames))]
- [HarmonyPatch("JobOnThing")]
- [HarmonyPatch(new[] { typeof(Pawn), typeof(Thing), typeof(bool) })]
- class Patch_WorkGiver_ConstructDeliverResourcesToFrames
- {
- static IEnumerable Transpiler(IEnumerable instructions)
- {
-
- OpCode[] opCodes1 =
- {
- OpCodes.Ldarg_2,
- OpCodes.Callvirt,
- OpCodes.Ldarg_1,
- OpCodes.Callvirt,
- OpCodes.Beq_S,
- };
- string[] operands1 =
- {
- "",
- "RimWorld.Faction get_Faction()",
- "",
- "RimWorld.Faction get_Faction()",
- "System.Reflection.Emit.Label",
- };
-
-
- var label = HPatcher.FindOperandAfter(opCodes1, operands1, instructions, true);
-
- //Add If(pawn.IsPrisonerOfColony) {jump next condition}
- yield return new CodeInstruction(OpCodes.Ldarg_2);
- yield return new CodeInstruction(OpCodes.Ldarg_1);
- yield return new CodeInstruction(OpCodes.Call, typeof(ConstructionUtils).GetMethod(nameof(ConstructionUtils.IsPrisonerWork)));
- yield return new CodeInstruction(OpCodes.Brtrue, label);
-
- foreach (var instr in instructions)
- {
- yield return instr;
- }
-
- }
- }
-}
diff --git a/Source/HarmonyPatches/Patches_Construction/Patch_WorkGiver_Deconstruct.cs b/Source/HarmonyPatches/Patches_Construction/Patch_WorkGiver_Deconstruct.cs
deleted file mode 100644
index e0c8314d..00000000
--- a/Source/HarmonyPatches/Patches_Construction/Patch_WorkGiver_Deconstruct.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using HarmonyLib;
-using PrisonLabor.Core;
-using PrisonLabor.Core.Other;
-using RimWorld;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Reflection.Emit;
-using System.Text;
-using System.Threading.Tasks;
-using Verse;
-
-namespace PrisonLabor.HarmonyPatches.Patches_Construction
-{
- [HarmonyPatch(typeof(WorkGiver_Deconstruct), "HasJobOnThing")]
- class Patch_WorkGiver_Deconstruct
- {
- static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable inst)
- {
- var codes = new List(inst);
- for (int i = 0; i < codes.Count(); i++)
- {
- if (i > 0 && ShouldPatch(codes[i], codes[i - 1]))
- {
- DebugLogger.debug($"Deconstruct HasJobOnThing patch: {mBase.ReflectedType.Name}.{mBase.Name}");
- yield return new CodeInstruction(OpCodes.Call, typeof(PrisonLaborUtility).GetMethod(nameof(PrisonLaborUtility.GetPawnFaction)));
- }
- else
- {
- yield return codes[i];
- }
- }
- }
-
- private static bool ShouldPatch(CodeInstruction actual, CodeInstruction prev)
- {
- return prev.opcode == OpCodes.Ldarg_1 && actual.opcode == OpCodes.Callvirt && actual.operand != null && actual.operand.ToString().Contains("RimWorld.Faction get_Faction()");
- }
- }
-}
diff --git a/Source/HarmonyPatches/Patches_Construction/Patch_WorkGiver_Repair.cs b/Source/HarmonyPatches/Patches_Construction/Patch_WorkGiver_Repair.cs
deleted file mode 100644
index f0b4effb..00000000
--- a/Source/HarmonyPatches/Patches_Construction/Patch_WorkGiver_Repair.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using HarmonyLib;
-using PrisonLabor.Core;
-using PrisonLabor.WorkUtils;
-using RimWorld;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Verse;
-using Verse.AI;
-
-namespace PrisonLabor.HarmonyPatches.Patches_Construction
-{
- [HarmonyPatch(typeof(WorkGiver_Repair))]
- class Patch_WorkGiver_Repair
- {
-
- [HarmonyPrefix]
- [HarmonyPatch("HasJobOnThing")]
- [HarmonyPatch(new[] { typeof(Pawn), typeof(Thing), typeof(bool) })]
- static bool HasJobOnThingPrefix(ref bool __result, Pawn pawn,Thing t, bool forced)
- {
- if (pawn.IsPrisonerOfColony)
- {
- __result = ConstructionUtils.HasJobOnThingFixed(pawn, t, forced);
- return false;
- }
- return true;
-
- }
- }
-}
diff --git a/Source/HarmonyPatches/Patches_Construction/WorkGiver_ConstructDeliverResourcesToBlueprints.cs b/Source/HarmonyPatches/Patches_Construction/WorkGiver_ConstructDeliverResourcesToBlueprints.cs
deleted file mode 100644
index ce294029..00000000
--- a/Source/HarmonyPatches/Patches_Construction/WorkGiver_ConstructDeliverResourcesToBlueprints.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-using HarmonyLib;
-using PrisonLabor.WorkUtils;
-using RimWorld;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Reflection.Emit;
-using System.Text;
-using System.Threading.Tasks;
-using Verse;
-using Verse.AI;
-
-namespace PrisonLabor.HarmonyPatches.Patches_Construction
-{
- [HarmonyPatch(typeof(WorkGiver_ConstructDeliverResourcesToBlueprints))]
- [HarmonyPatch("JobOnThing")]
- [HarmonyPatch(new[] { typeof(Pawn), typeof(Thing), typeof(bool) })]
- class Patch_WorkGiver_ConstructDeliverResourcesToBlueprints
- {
- static IEnumerable Transpiler(IEnumerable instructions)
- {
-
- OpCode[] opCodes1 =
- {
- OpCodes.Ldarg_2,
- OpCodes.Callvirt,
- OpCodes.Ldarg_1,
- OpCodes.Callvirt,
- OpCodes.Beq_S,
- };
- string[] operands1 =
- {
- "",
- "RimWorld.Faction get_Faction()",
- "",
- "RimWorld.Faction get_Faction()",
- "System.Reflection.Emit.Label",
- };
-
-
- var label = HPatcher.FindOperandAfter(opCodes1, operands1, instructions, true);
-
- //Add If(pawn.IsPrisonerOfColony) {jump next condition}
- yield return new CodeInstruction(OpCodes.Ldarg_2);
- yield return new CodeInstruction(OpCodes.Ldarg_1);
- yield return new CodeInstruction(OpCodes.Call, typeof(ConstructionUtils).GetMethod(nameof(ConstructionUtils.IsPrisonerWork)));
- yield return new CodeInstruction(OpCodes.Brtrue, label);
-
- foreach (var instr in instructions)
- {
- yield return instr;
- }
-
- }
- }
-}
diff --git a/Source/HarmonyPatches/Patches_Food/AddCustomFoodReservation.cs b/Source/HarmonyPatches/Patches_Food/AddCustomFoodReservation.cs
index 9cea3ba1..df6cc2e2 100644
--- a/Source/HarmonyPatches/Patches_Food/AddCustomFoodReservation.cs
+++ b/Source/HarmonyPatches/Patches_Food/AddCustomFoodReservation.cs
@@ -12,7 +12,7 @@ namespace PrisonLabor.HarmonyPatches.Patches_Food
/// Adds check if food is already reserved before trying to bring it
///
[HarmonyPatch(typeof(FoodUtility))]
- [HarmonyPatch(nameof(FoodUtility.BestFoodSourceOnMap))]
+ [HarmonyPatch(nameof(FoodUtility.BestFoodSourceOnMap_NewTemp))]
static class AddCustomFoodReservation
{
/* === Orignal code Look-up===
diff --git a/Source/HarmonyPatches/Patches_DeepDrill/EnableDeepDrillsToPrisoners.cs b/Source/HarmonyPatches/Patches_Work/EnableDeepDrillsToPrisoners.cs
similarity index 95%
rename from Source/HarmonyPatches/Patches_DeepDrill/EnableDeepDrillsToPrisoners.cs
rename to Source/HarmonyPatches/Patches_Work/EnableDeepDrillsToPrisoners.cs
index c82d9d8e..e7c2c37e 100644
--- a/Source/HarmonyPatches/Patches_DeepDrill/EnableDeepDrillsToPrisoners.cs
+++ b/Source/HarmonyPatches/Patches_Work/EnableDeepDrillsToPrisoners.cs
@@ -10,7 +10,7 @@
using Verse;
using Verse.AI;
-namespace PrisonLabor.HarmonyPatches.Patches_DeepDrill
+namespace PrisonLabor.HarmonyPatches.Patches_Work
{
[HarmonyPatch(typeof(WorkGiver_DeepDrill))]
static class EnableDeepDrillsToPrisoners
diff --git a/Source/HarmonyPatches/Patches_Work/Patch_BlueprintsForPlayerFaction.cs b/Source/HarmonyPatches/Patches_Work/Patch_BlueprintsForPlayerFaction.cs
new file mode 100644
index 00000000..1db2baf0
--- /dev/null
+++ b/Source/HarmonyPatches/Patches_Work/Patch_BlueprintsForPlayerFaction.cs
@@ -0,0 +1,30 @@
+using HarmonyLib;
+using PrisonLabor.Core.Other;
+using RimWorld;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Management.Instrumentation;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+
+namespace PrisonLabor.HarmonyPatches.Patches_Work
+{
+ /**
+ * Construciton patches
+ */
+ [HarmonyPatch(typeof(Blueprint), "TryReplaceWithSolidThing")]
+ class Patch_BlueprintsForPlayerFaction
+ {
+ public static void Postfix(Pawn workerPawn, Thing createdThing, bool __result)
+ {
+ if (__result && createdThing != null && createdThing.def.CanHaveFaction && workerPawn.IsPrisonerOfColony)
+ {
+ DebugLogger.debug($"Setting faction for: {createdThing}");
+ createdThing.SetFactionDirect(Faction.OfPlayer);
+ }
+ }
+ }
+}
diff --git a/Source/HarmonyPatches/Patches_Work/Patch_JobDriver_Mine.cs b/Source/HarmonyPatches/Patches_Work/Patch_JobDriver_Mine.cs
index 2ca3a70b..efe13ec5 100644
--- a/Source/HarmonyPatches/Patches_Work/Patch_JobDriver_Mine.cs
+++ b/Source/HarmonyPatches/Patches_Work/Patch_JobDriver_Mine.cs
@@ -10,48 +10,48 @@
namespace PrisonLabor.HarmonyPatches.Patches_Work
{
- [HarmonyPatch(typeof(JobDriver_Mine))]
- [HarmonyPatch("MakeNewToils")]
- class Patch_JobDriver_Mine
+ [HarmonyPatch(typeof(JobDriver_Mine))]
+ [HarmonyPatch("MakeNewToils")]
+ class Patch_JobDriver_Mine
+ {
+ static IEnumerable Postfix(IEnumerable toilList, JobDriver_Mine __instance)
{
- static IEnumerable Postfix(IEnumerable toilList, JobDriver_Mine __instance)
+ int counter = 1;
+ int count = toilList.Count();
+ foreach (var toil in toilList)
+ {
+ if (counter == count)
{
- int counter = 1;
- int count = toilList.Count();
- foreach (var toil in toilList)
- {
- if (counter == count)
- {
- toil.AddFinishAction(CreateDelegate(__instance));
- }
- counter++;
- yield return toil;
- }
-
- }
+ toil.AddFinishAction(CreateDelegate(__instance));
+ }
+ counter++;
+ yield return toil;
+ }
- static private Action CreateDelegate(JobDriver_Mine __instance)
- {
- return delegate
- {
- Thing mineTarget = __instance.job.GetTarget(TargetIndex.A).Thing;
- Pawn pawn = __instance.pawn;
- if (pawn != null && mineTarget != null && mineTarget.Destroyed)
- {
+ }
- if (pawn.IsPrisonerOfColony)
- {
- IntVec3 position = mineTarget.Position;
- List thingList = position.GetThingList(pawn.Map);
- for (int i = 0; i < thingList.Count; i++)
- {
- thingList[i].SetForbidden(value: false, warnOnFail: false);
- }
- }
- }
+ static private Action CreateDelegate(JobDriver_Mine __instance)
+ {
+ return delegate
+ {
+ Thing mineTarget = __instance.job.GetTarget(TargetIndex.A).Thing;
+ Pawn pawn = __instance.pawn;
+ if (pawn != null && mineTarget != null && mineTarget.Destroyed)
+ {
- };
- }
+ if (pawn.IsPrisonerOfColony)
+ {
+ IntVec3 position = mineTarget.Position;
+ List thingList = position.GetThingList(pawn.Map);
+ for (int i = 0; i < thingList.Count; i++)
+ {
+ thingList[i].SetForbidden(value: false, warnOnFail: false);
+ }
+ }
+ }
+ };
}
+
+ }
}
diff --git a/Source/HarmonyPatches/Patches_Construction/Patch_Smoothing.cs b/Source/HarmonyPatches/Patches_Work/Patch_Smoothing.cs
similarity index 100%
rename from Source/HarmonyPatches/Patches_Construction/Patch_Smoothing.cs
rename to Source/HarmonyPatches/Patches_Work/Patch_Smoothing.cs
diff --git a/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_CleanFilth.cs b/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_CleanFilth.cs
deleted file mode 100644
index a3046ead..00000000
--- a/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_CleanFilth.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using HarmonyLib;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Verse;
-using RimWorld;
-using System.Reflection;
-using PrisonLabor.Core;
-using Verse.AI;
-
-namespace PrisonLabor.HarmonyPatches.Patches_Work
-{
- [HarmonyPatch]
- class Patch_WorkGiver_CleanFilth
- {
- private static int MinTicksSinceThickened = 600;
- static MethodBase TargetMethod()
- {
- Assembly asm = typeof(WorkGiver_Scanner).Assembly;
- Type type = asm.GetType("RimWorld.WorkGiver_CleanFilth");
- return type.GetMethod("HasJobOnThing");
- }
- static bool Postfix(bool __result, Pawn pawn, Thing t, bool forced)
- {
- if (pawn.IsPrisonerOfColony)
- {
- WorkGiverDef workGiverDef = DefDatabase.GetNamed("CleanFilth");
- return t is Filth filth && filth.Map.areaManager.Home[filth.Position]
- && pawn.CanReserveAndReach(t, PathEndMode.ClosestTouch, pawn.NormalMaxDanger(), 1, -1, null, forced)
- && filth.TicksSinceThickened >= MinTicksSinceThickened
- && PrisonLaborUtility.CanWorkHere(filth.Position, pawn, workGiverDef.workType);
- }
- return __result;
- }
-
- }
-}
diff --git a/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_CleanReach.cs b/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_CleanReach.cs
new file mode 100644
index 00000000..18c6b499
--- /dev/null
+++ b/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_CleanReach.cs
@@ -0,0 +1,34 @@
+using HarmonyLib;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Verse;
+using RimWorld;
+using System.Reflection;
+using PrisonLabor.Core;
+using Verse.AI;
+
+namespace PrisonLabor.HarmonyPatches.Patches_Work
+{
+ [HarmonyPatch]
+ class Patch_WorkGiver_CleanReach
+ {
+ static MethodBase TargetMethod()
+ {
+ Assembly asm = typeof(WorkGiver_Scanner).Assembly;
+ return asm.GetType("RimWorld.WorkGiver_CleanFilth").GetMethod("HasJobOnThing");
+ }
+
+ static bool Postfix(bool __result, Pawn pawn, Thing t, bool forced)
+ {
+ if (__result && pawn.IsPrisonerOfColony)
+ {
+ return __result && pawn.CanReach(t, PathEndMode.ClosestTouch, pawn.NormalMaxDanger());
+ }
+ return __result;
+ }
+
+ }
+}
diff --git a/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_CleanSnow.cs b/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_CleanSnow.cs
index c60d8953..9e671c71 100644
--- a/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_CleanSnow.cs
+++ b/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_CleanSnow.cs
@@ -1,32 +1,29 @@
using HarmonyLib;
-using PrisonLabor.Core;
-using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
+using RimWorld;
+using System.Reflection;
+using PrisonLabor.Core;
using Verse.AI;
namespace PrisonLabor.HarmonyPatches.Patches_Work
{
- [HarmonyPatch(typeof(WorkGiver_ClearSnow), "HasJobOnCell")]
- class Patch_WorkGiver_CleanSnow
+ [HarmonyPatch(typeof(WorkGiver_ClearSnow), "HasJobOnCell")]
+ class Patch_WorkGiver_CleanSnow
+ {
+
+ static bool Postfix(bool __result, Pawn pawn, IntVec3 c, bool forced)
{
- static bool Postfix(bool __result, Pawn pawn, IntVec3 c, bool forced)
- {
- if(pawn.IsPrisonerOfColony)
- {
- WorkGiverDef workGiverDef = DefDatabase.GetNamed("CleanClearSnow");
- return pawn.Map.snowGrid.GetDepth(c) >= 0.200000002980232 &&
- !c.IsForbidden(pawn) &&
- pawn.CanReserveAndReach(c, PathEndMode.ClosestTouch, pawn.NormalMaxDanger(), 1, -1, null, forced) &&
- PrisonLaborUtility.CanWorkHere(c, pawn, workGiverDef.workType);
-
-
- }
- return __result;
- }
+ if (__result && pawn.IsPrisonerOfColony)
+ {
+ return __result && pawn.CanReach(c, PathEndMode.OnCell, pawn.NormalMaxDanger());
+ }
+ return __result;
}
+
+ }
}
diff --git a/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_PrisonerFaction.cs b/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_PrisonerFaction.cs
index 986fe86b..fd1a29c7 100644
--- a/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_PrisonerFaction.cs
+++ b/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_PrisonerFaction.cs
@@ -13,39 +13,45 @@
namespace PrisonLabor.HarmonyPatches.Patches_Work
{
- [HarmonyPatch]
- public class Patch_WorkGiver_PrisonerFaction
+ [HarmonyPatch]
+ public class Patch_WorkGiver_PrisonerFaction
+ {
+ static IEnumerable TargetMethods()
{
- static IEnumerable TargetMethods()
- {
- return Assembly.GetAssembly(typeof(WorkGiver_Scanner)).GetTypes()
- .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(WorkGiver_Scanner)))
- .SelectMany(type => type.GetMethods())
- .Where(method => method.Name.Equals("PotentialWorkThingsGlobal") || method.Name.Equals("ShouldSkip") || method.Name.Equals("HasJobOnThing"))
- .Distinct()
- .Cast();
- }
+ foreach (MethodBase mb in Assembly.GetAssembly(typeof(WorkGiver_Scanner)).GetTypes()
+ .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(WorkGiver_Scanner)))
+ .SelectMany(type => type.GetMethods())
+ .Where(method => method.Name.Equals("PotentialWorkThingsGlobal") || method.Name.Equals("ShouldSkip") || method.Name.Equals("HasJobOnThing"))
+ .Distinct()
+ .Cast())
+ {
+ yield return mb;
+ }
+ yield return typeof(WorkGiver_ConstructFinishFrames).GetMethod(nameof(WorkGiver_ConstructFinishFrames.JobOnThing));
+ yield return typeof(WorkGiver_ConstructDeliverResourcesToFrames).GetMethod(nameof(WorkGiver_ConstructDeliverResourcesToFrames.JobOnThing));
+ yield return typeof(WorkGiver_ConstructDeliverResourcesToBlueprints).GetMethod(nameof(WorkGiver_ConstructDeliverResourcesToBlueprints.JobOnThing));
+ }
- public static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable inst)
+ public static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable inst)
+ {
+ var codes = new List(inst);
+ for (int i = 0; i < codes.Count(); i++)
+ {
+ if (i > 0 && ShouldPatch(codes[i], codes[i - 1]))
{
- var codes = new List(inst);
- for (int i = 0; i < codes.Count(); i++)
- {
- if (i > 0 && ShouldPatch(codes[i], codes[i - 1]))
- {
- DebugLogger.debug($"WorkThingsGlobal & ShouldSkip patch: {mBase.ReflectedType.Assembly.GetName().Name}.{mBase.ReflectedType.Name}.{mBase.Name}");
- yield return new CodeInstruction(OpCodes.Call, typeof(PrisonLaborUtility).GetMethod(nameof(PrisonLaborUtility.GetPawnFaction)));
- }
- else
- {
- yield return codes[i];
- }
- }
+ DebugLogger.debug($"Patch_WorkGiver_PrisonerFaction patch: {mBase.ReflectedType.Assembly.GetName().Name}.{mBase.ReflectedType.Name}.{mBase.Name}");
+ yield return new CodeInstruction(OpCodes.Call, typeof(PrisonLaborUtility).GetMethod(nameof(PrisonLaborUtility.GetPawnFaction)));
}
-
- private static bool ShouldPatch(CodeInstruction actual, CodeInstruction prev)
+ else
{
- return prev.opcode == OpCodes.Ldarg_1 && actual.opcode == OpCodes.Callvirt && actual.operand != null && actual.operand.ToString().Contains("RimWorld.Faction get_Faction()");
+ yield return codes[i];
}
+ }
+ }
+
+ private static bool ShouldPatch(CodeInstruction actual, CodeInstruction prev)
+ {
+ return prev.opcode == OpCodes.Ldarg_1 && actual.opcode == OpCodes.Callvirt && actual.operand != null && actual.operand.ToString().Contains("RimWorld.Faction get_Faction()");
}
+ }
}
diff --git a/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_Refuel.cs b/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_Refuel.cs
index 80dc27bf..068925f9 100644
--- a/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_Refuel.cs
+++ b/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_Refuel.cs
@@ -1,9 +1,11 @@
using HarmonyLib;
+using PrisonLabor.Core;
using PrisonLabor.Core.Other;
using RimWorld;
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Reflection.Emit;
using System.Text;
using System.Threading.Tasks;
using Verse;
@@ -11,44 +13,36 @@
namespace PrisonLabor.HarmonyPatches.Patches_Work
{
- [HarmonyPatch(typeof(RefuelWorkGiverUtility), "CanRefuel")]
- class Patch_WorkGiver_Refuel
+ [HarmonyPatch(typeof(RefuelWorkGiverUtility), "CanRefuel")]
+ class Patch_WorkGiver_Refuel
+ {
+ static IEnumerable Transpiler(IEnumerable instructions)
{
- static bool Postfix(bool __result, Pawn pawn, Thing t, bool forced)
+ var codes = new List(instructions);
+ for (int i = 0; i < codes.Count(); i++)
+ {
+ if (i > 0 && ShouldPatch(codes[i], codes[i - 1]))
{
- if (!__result && pawn.IsPrisonerOfColony)
- {
- return CanRefuel(pawn, t, forced);
- }
- return __result;
+ yield return new CodeInstruction(OpCodes.Call, typeof(PrisonLaborUtility).GetMethod(nameof(PrisonLaborUtility.GetPawnFaction)));
}
-
-
- private static bool CanRefuel(Pawn pawn, Thing t, bool forced)
+ else
{
- CompRefuelable compRefuelable = t.TryGetComp();
- if (compRefuelable == null || compRefuelable.IsFull || !compRefuelable.allowAutoRefuel || !compRefuelable.ShouldAutoRefuelNow)
- {
- return false;
- }
- if (t.IsForbiddenForPrisoner(pawn) || !pawn.CanReserveAndReach(t, PathEndMode.ClosestTouch, pawn.NormalMaxDanger(), 1, -1, null, forced))
- {
- return false;
- }
-
- if (Traverse.Create(typeof(RefuelWorkGiverUtility)).Method("FindBestFuel", new[] { pawn, t }).GetValue() == null)
- {
- ThingFilter fuelFilter = t.TryGetComp().Props.fuelFilter;
- JobFailReason.Is("NoFuelToRefuel".Translate(fuelFilter.Summary));
- return false;
- }
- if (t.TryGetComp().Props.atomicFueling && Traverse.Create(typeof(RefuelWorkGiverUtility)).Method("FindAllFuel", new[] { pawn, t }).GetValue>() == null)
- {
- ThingFilter fuelFilter2 = t.TryGetComp().Props.fuelFilter;
- JobFailReason.Is("NoFuelToRefuel".Translate(fuelFilter2.Summary));
- return false;
- }
- return true;
+ yield return codes[i];
}
+ }
+ }
+
+ private static bool ShouldPatch(CodeInstruction actual, CodeInstruction prev)
+ {
+ return prev.opcode == OpCodes.Ldarg_0 && actual.opcode == OpCodes.Callvirt && actual.operand != null && actual.operand.ToString().Contains("RimWorld.Faction get_Faction()");
+ }
+ static bool Postfix(bool __result, Pawn pawn, Thing t, bool forced)
+ {
+ if (__result && pawn.IsPrisonerOfColony)
+ {
+ return __result && pawn.CanReach(t, PathEndMode.ClosestTouch, pawn.NormalMaxDanger());
+ }
+ return __result;
}
+ }
}
diff --git a/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_Repair.cs b/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_Repair.cs
new file mode 100644
index 00000000..c6564866
--- /dev/null
+++ b/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_Repair.cs
@@ -0,0 +1,56 @@
+using HarmonyLib;
+using PrisonLabor.Core;
+using RimWorld;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection.Emit;
+using System.Reflection;
+using Verse;
+using Verse.AI;
+
+namespace PrisonLabor.HarmonyPatches.Patches_Work
+{
+ [HarmonyPatch]
+ class Patch_RepairUtility
+ {
+ static IEnumerable TargetMethods()
+ {
+ yield return typeof(RepairUtility).GetMethod(nameof(RepairUtility.PawnCanRepairEver));
+ yield return typeof(RepairUtility).GetMethod(nameof(RepairUtility.PawnCanRepairNow));
+ }
+
+ static IEnumerable Transpiler(IEnumerable instructions)
+ {
+ var codes = new List(instructions);
+ for (int i = 0; i < codes.Count(); i++)
+ {
+ if (i > 0 && ShouldPatch(codes[i], codes[i - 1]))
+ {
+ yield return new CodeInstruction(OpCodes.Call, typeof(PrisonLaborUtility).GetMethod(nameof(PrisonLaborUtility.GetPawnFaction)));
+ }
+ else
+ {
+ yield return codes[i];
+ }
+ }
+ }
+
+ private static bool ShouldPatch(CodeInstruction actual, CodeInstruction prev)
+ {
+ return prev.opcode == OpCodes.Ldarg_0 && actual.opcode == OpCodes.Callvirt && actual.operand != null && actual.operand.ToString().Contains("RimWorld.Faction get_Faction()");
+ }
+ }
+
+ [HarmonyPatch(typeof(WorkGiver_Repair), "HasJobOnThing")]
+ class Patch_WorkGiver_Repair
+ {
+ static bool Postfix(bool __result, Pawn pawn, Thing t, bool forced)
+ {
+ if (__result && pawn.IsPrisonerOfColony)
+ {
+ return __result && pawn.CanReach(t, PathEndMode.ClosestTouch, pawn.NormalMaxDanger());
+ }
+ return __result;
+ }
+ }
+}
diff --git a/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_RescueDowned.cs b/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_RescueDowned.cs
index dfe8e2f6..eb341023 100644
--- a/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_RescueDowned.cs
+++ b/Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_RescueDowned.cs
@@ -15,44 +15,17 @@
namespace PrisonLabor.HarmonyPatches.Patches_Work
{
- [HarmonyPatch(typeof(RestUtility), "FindBedFor", new Type[] { typeof(Pawn), typeof(Pawn), typeof(bool), typeof(bool), typeof(GuestStatus) } )]
- class Patch_RestUtility
+ [HarmonyPatch(typeof(RestUtility), "FindBedFor", new Type[] { typeof(Pawn), typeof(Pawn), typeof(bool), typeof(bool), typeof(GuestStatus) })]
+ class Patch_RestUtility
+ {
+ //Don't try to take wounded to unreachable bed
+ static Building_Bed Postfix(Building_Bed __result, Pawn sleeper, Pawn traveler, bool checkSocialProperness, bool ignoreOtherReservations, GuestStatus? guestStatus)
{
- //Don't try to take wounded to unreachable bed
- static Building_Bed Postfix(Building_Bed __result, Pawn sleeper, Pawn traveler, bool checkSocialProperness, bool ignoreOtherReservations, GuestStatus? guestStatus)
- {
- if(__result != null && traveler.IsPrisonerOfColony && !traveler.CanReach(__result, PathEndMode.ClosestTouch, traveler.NormalMaxDanger()))
- {
- return null;
- }
- return __result;
- }
- }
-
-
- [HarmonyPatch(typeof(WorkGiver_RescueDowned), "HasJobOnThing")]
- class Patch_WorkGiver_RescueDowned
- {
- static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase, IEnumerable inst)
- {
- var codes = new List(inst);
- for (int i = 0; i < codes.Count(); i++)
- {
- if (i > 0 && ShouldPatch(codes[i], codes[i - 1]))
- {
- DebugLogger.debug($"WorkGiver_RescueDowned patch: {mBase.ReflectedType.Name}.{mBase.Name}");
- yield return new CodeInstruction(OpCodes.Call, typeof(PrisonLaborUtility).GetMethod(nameof(PrisonLaborUtility.GetPawnFaction)));
- }
- else
- {
- yield return codes[i];
- }
- }
- }
-
- private static bool ShouldPatch(CodeInstruction actual, CodeInstruction prev)
- {
- return prev.opcode == OpCodes.Ldarg_1 && actual.opcode == OpCodes.Callvirt && actual.operand != null && actual.operand.ToString().Contains("RimWorld.Faction get_Faction()");
- }
+ if (__result != null && traveler.IsPrisonerOfColony && !traveler.CanReach(__result, PathEndMode.ClosestTouch, traveler.NormalMaxDanger()))
+ {
+ return null;
+ }
+ return __result;
}
+ }
}
diff --git a/Source/HarmonyPatches/Patches_WorkSettings/Patch_DisableAreaRestrictionsForPrisoners.cs b/Source/HarmonyPatches/Patches_WorkSettings/Patch_DisableAreaRestrictionsForPrisoners.cs
index 9716526f..1d19e3df 100644
--- a/Source/HarmonyPatches/Patches_WorkSettings/Patch_DisableAreaRestrictionsForPrisoners.cs
+++ b/Source/HarmonyPatches/Patches_WorkSettings/Patch_DisableAreaRestrictionsForPrisoners.cs
@@ -9,45 +9,6 @@
namespace PrisonLabor.HarmonyPatches.Patches_WorkSettings
{
- ///
- /// This patch will remove prisoners in "Restrict" tab.
- /// They are there in first place, because of adding them to PawnTable in another patch.
- ///
- /* [HarmonyPatch(typeof(PawnColumnWorker_AllowedArea))]
- [HarmonyPatch("DoCell")]
- [HarmonyPatch(new[] {typeof(Rect), typeof(Pawn), typeof(PawnTable)})]
- internal class DisableAreaRestrictionsForPrisoners
- {
- private static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase,
- IEnumerable instr)
- {
- var jumpTo = gen.DefineLabel();
- yield return new CodeInstruction(OpCodes.Ldarg_2);
- yield return new CodeInstruction(OpCodes.Call,
- typeof(DisableAreaRestrictionsForPrisoners).GetMethod(nameof(isPrisoner)));
- yield return new CodeInstruction(OpCodes.Brfalse, jumpTo);
- yield return new CodeInstruction(OpCodes.Ret);
-
- var first = true;
- foreach (var ci in instr)
- {
- if (first)
- {
- first = false;
- ci.labels.Add(jumpTo);
- }
- yield return ci;
- }
- }
-
- public static bool isPrisoner(Pawn pawn)
- {
- if (pawn.IsPrisoner)
- return true;
- return false;
- }
- }*/
-
[HarmonyPatch(typeof(PawnColumnWorker_AllowedArea))]
[HarmonyPatch("DoCell")]
class EnableAreaRestrictionsForPrisoners
diff --git a/Source/HarmonyPatches/Patches_WorkSettings/Patch_ResetWorktableWhenRecruited.cs b/Source/HarmonyPatches/Patches_WorkSettings/Patch_ResetWorktableWhenRecruited.cs
index d4143da7..a7d9eb25 100644
--- a/Source/HarmonyPatches/Patches_WorkSettings/Patch_ResetWorktableWhenRecruited.cs
+++ b/Source/HarmonyPatches/Patches_WorkSettings/Patch_ResetWorktableWhenRecruited.cs
@@ -12,20 +12,20 @@
namespace PrisonLabor.HarmonyPatches.Patches_WorkSettings
{
- [HarmonyPatch(typeof(InteractionWorker_RecruitAttempt))]
- [HarmonyPatch("DoRecruit")]
- [HarmonyPatch(new Type[] { typeof(Pawn), typeof(Pawn), typeof(string), typeof(string), typeof(bool), typeof(bool) },
- new ArgumentType[] { ArgumentType.Normal, ArgumentType.Normal, ArgumentType.Out, ArgumentType.Out, ArgumentType.Normal, ArgumentType.Normal })]
- class Patch_ResetWorktableWhenRecruited
+ [HarmonyPatch(typeof(InteractionWorker_RecruitAttempt))]
+ [HarmonyPatch("DoRecruit")]
+ [HarmonyPatch(new Type[] { typeof(Pawn), typeof(Pawn), typeof(string), typeof(string), typeof(bool), typeof(bool) },
+ new ArgumentType[] { ArgumentType.Normal, ArgumentType.Normal, ArgumentType.Out, ArgumentType.Out, ArgumentType.Normal, ArgumentType.Normal })]
+ class Patch_ResetWorktableWhenRecruited
+ {
+ static void Prefix(Pawn recruiter, Pawn recruitee)
{
- static void Prefix(Pawn recruiter, Pawn recruitee)
- {
- if(recruitee != null && recruitee.IsPrisonerOfColony && recruiter != null && recruiter.Faction == Faction.OfPlayer)
- {
- CleanPrisonersStatus.Clean(recruitee);
- Log.Message($"[PrisonLabor] Removed prisoners effects from {recruitee.LabelShort}");
- }
- }
-
+ if (recruitee != null && recruitee.IsPrisonerOfColony && recruiter != null && recruiter.Faction == Faction.OfPlayer)
+ {
+ CleanPrisonersStatus.Clean(recruitee);
+ Log.Message($"[PrisonLabor] Removed prisoners effects from {recruitee.LabelShort}");
+ }
}
+
+ }
}
diff --git a/Source/Organizer/NewsFeed.xml b/Source/Organizer/NewsFeed.xml
index 829135c7..100e06c6 100644
--- a/Source/Organizer/NewsFeed.xml
+++ b/Source/Organizer/NewsFeed.xml
@@ -4,6 +4,7 @@
+
diff --git a/Source/PrisonLabor.csproj b/Source/PrisonLabor.csproj
index f0159d09..b3179c40 100644
--- a/Source/PrisonLabor.csproj
+++ b/Source/PrisonLabor.csproj
@@ -145,11 +145,9 @@
-
-
-
-
-
+
+
+
@@ -168,9 +166,8 @@
-
-
-
+
+
@@ -202,8 +199,7 @@
-
-
+
@@ -252,7 +248,6 @@
-
diff --git a/Source/WorkUtils/ConstructionUtils.cs b/Source/WorkUtils/ConstructionUtils.cs
deleted file mode 100644
index 9b608e0b..00000000
--- a/Source/WorkUtils/ConstructionUtils.cs
+++ /dev/null
@@ -1,50 +0,0 @@
-using HarmonyLib;
-using PrisonLabor.Core;
-using RimWorld;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection.Emit;
-using System.Text;
-using System.Threading.Tasks;
-using Verse;
-using Verse.AI;
-
-namespace PrisonLabor.WorkUtils
-{
- class ConstructionUtils
- {
- public static bool HasJobOnThingFixed(Pawn pawn, Thing t, bool forced)
- {
- if (!PawnCanRepairNow(pawn, t))
- return false;
- Building t1 = t as Building;
- if (PrisonLaborUtility.GetPawnFaction(pawn) == Faction.OfPlayer && !pawn.Map.areaManager.Home[t.Position])
- {
- JobFailReason.Is(WorkGiver_FixBrokenDownBuilding.NotInHomeAreaTrans, null);
- return false;
- }
- return pawn.CanReserveAndReach(t1, PathEndMode.ClosestTouch, pawn.NormalMaxDanger(), 1, -1, null, forced) &&
- t1.Map.designationManager.DesignationOn(t1, DesignationDefOf.Deconstruct) == null &&
- (!t1.def.mineable || t1.Map.designationManager.DesignationAt(t1.Position, DesignationDefOf.Mine) == null) &&
- !t1.IsBurning();
-
- }
-
-
- public static bool IsPrisonerWork(Thing t, Pawn pawn)
- {
- return pawn.IsPrisonerOfColony && t.Faction == Faction.OfPlayer;
- }
-
- private static bool PawnCanRepairEver(Pawn pawn, Thing t)
- {
- return t is Building building && t.def.useHitPoints && (building.def.building.repairable && t.Faction == PrisonLaborUtility.GetPawnFaction(pawn));
- }
-
- private static bool PawnCanRepairNow(Pawn pawn, Thing t)
- {
- return PawnCanRepairEver(pawn, t) && pawn.Map.listerBuildingsRepairable.Contains(PrisonLaborUtility.GetPawnFaction(pawn), (Building)t) && t.HitPoints != t.MaxHitPoints;
- }
- }
-}
diff --git a/changelog.txt b/changelog.txt
index 984a3eba..f4c4b4c5 100644
--- a/changelog.txt
+++ b/changelog.txt
@@ -1,4 +1,9 @@
Changelog:
+1.4.4
+- Fix: prisoner work window should be better displayed with greater number of prisoners
+- Harmony patches refactor
+- Compatibility patches for "Kijin Race 3.0"
+- Fixes for new Rimworld version.
1.4.3
- Fix: game should not freeze when prisoner is seleted for gene extraction
- Fix: machanoids should not work in prison labor area