-
-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fixes for roof building and HasJob method in all scanners * Cleaning Co-authored-by: Hazzer <[email protected]>
- Loading branch information
Showing
5 changed files
with
100 additions
and
22 deletions.
There are no files selected for viewing
Binary file not shown.
36 changes: 36 additions & 0 deletions
36
Source/HarmonyPatches/Patches_Construction/Patch_RoofReservation.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
Source/HarmonyPatches/Patches_LaborArea/Patch_Scanner_HasJob.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<MethodBase> 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<MethodBase>(); | ||
} | ||
|
||
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters