diff --git a/Assemblies/PrisonLabor.dll b/Assemblies/PrisonLabor.dll index 43d4f7c7..3faba5d9 100644 Binary files a/Assemblies/PrisonLabor.dll and b/Assemblies/PrisonLabor.dll differ diff --git a/Source/HarmonyPatches/Patches_Construction/Patch_RoofReservation.cs b/Source/HarmonyPatches/Patches_Construction/Patch_RoofReservation.cs new file mode 100644 index 00000000..22d7b30e --- /dev/null +++ b/Source/HarmonyPatches/Patches_Construction/Patch_RoofReservation.cs @@ -0,0 +1,36 @@ +using HarmonyLib; +using RimWorld; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace PrisonLabor.HarmonyPatches.Patches_Construction +{ + [HarmonyPatch()] + [HarmonyPatch(typeof(WorkGiver_BuildRoof), "HasJobOnCell")] + class Patch_RoofReservation + { + public static bool Postfix(bool __result, WorkGiver_BuildRoof __instance, Pawn pawn, IntVec3 c, bool forced) + { + if (__result && pawn.IsPrisonerOfColony) + { + try + { + System.Reflection.MethodInfo methodInfo = AccessTools.Method(typeof(WorkGiver_BuildRoof), "BuildingToTouchToBeAbleToBuildRoof"); + Building building = methodInfo.Invoke(__instance, new object[] { c, pawn }) as Building; + if (building != null) + { + return pawn.CanReach(building, Verse.AI.PathEndMode.Touch, pawn.NormalMaxDanger()); + } + } catch(Exception e) + { + Verse.Log.Message($"Exception in roof patch{e}"); + } + } + return __result; + } + } +} diff --git a/Source/HarmonyPatches/Patches_LaborArea/Patch_Scanner_HasJob.cs b/Source/HarmonyPatches/Patches_LaborArea/Patch_Scanner_HasJob.cs new file mode 100644 index 00000000..87a407ac --- /dev/null +++ b/Source/HarmonyPatches/Patches_LaborArea/Patch_Scanner_HasJob.cs @@ -0,0 +1,36 @@ +using HarmonyLib; +using PrisonLabor.Core; +using PrisonLabor.Core.AI.WorkGivers; +using RimWorld; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace PrisonLabor.HarmonyPatches.Patches_LaborArea +{ + [HarmonyPatch] + class Patch_Scanner_HasJob + { + static IEnumerable TargetMethods() + { + return Assembly.GetAssembly(typeof(WorkGiver_Scanner)).GetTypes() + .Where(myType => myType.IsClass && !myType.IsAbstract && myType.IsSubclassOf(typeof(WorkGiver_Scanner)) && myType != typeof(WorkGiver_Supervise) && myType != typeof(WorkGiver_Warden)) + .SelectMany(type => type.GetMethods()) + .Where(method => method.Name.Equals("HasJobOnThing")) + .Cast(); + } + + static bool Postfix(bool __result, WorkGiver_Scanner __instance, Pawn pawn, Thing t, bool forced = false) + { + if (__result && t != null ) + { + return PrisonLaborUtility.canWorkHere(t.Position, pawn, __instance.def.workType); + } + return __result; + } + } +} diff --git a/Source/Initialization.cs b/Source/Initialization.cs index da58a7da..e21d0395 100644 --- a/Source/Initialization.cs +++ b/Source/Initialization.cs @@ -32,7 +32,7 @@ static Initialization() } catch (Exception e) { - Log.Error($"Prison Labor v{VersionUtility.versionString} caught error during start up:\n{e.Message}"); + Log.Error($"Prison Labor v{VersionUtility.versionString} caught error during start up:\n{e}"); } } diff --git a/Source/PrisonLabor.csproj b/Source/PrisonLabor.csproj index 7258c372..f6359b45 100644 --- a/Source/PrisonLabor.csproj +++ b/Source/PrisonLabor.csproj @@ -38,34 +38,30 @@ False - packages\Rimworld\Assembly-CSharp.dll - False + ..\..\..\Gry\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\Assembly-CSharp.dll + + + + + + + - packages\Rimworld\UnityEngine.dll - False + ..\..\..\Gry\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.dll - packages\Rimworld\UnityEngine.CoreModule.dll - False + ..\..\..\Gry\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.CoreModule.dll - packages\Rimworld\UnityEngine.IMGUIModule.dll - False + ..\..\..\Gry\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.IMGUIModule.dll - packages\Rimworld\UnityEngine.TextRenderingModule.dll - False + ..\..\..\Gry\Steam\steamapps\common\RimWorld\RimWorldWin64_Data\Managed\UnityEngine.TextRenderingModule.dll - - - - - - - + @@ -79,13 +75,11 @@ - - - + @@ -96,6 +90,9 @@ + + + @@ -105,6 +102,12 @@ + + + + + + @@ -120,7 +123,6 @@ - @@ -135,6 +137,9 @@ + + + @@ -191,6 +196,7 @@ +