-
-
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.
Merge pull request #228 from Aviuz/1.2.4
1.2.4
- Loading branch information
Showing
13 changed files
with
182 additions
and
17 deletions.
There are no files selected for viewing
Binary file not shown.
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,38 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<Patch> | ||
<Operation Class="PatchOperationSequence"> | ||
<success>Always</success> | ||
<operations> | ||
<li Class="PatchOperationSequence"> | ||
<success>Always</success> | ||
<operations> | ||
<li Class="PatchOperationTest"> | ||
<xpath>/Defs/DesignationCategoryDef[defName = "Zone"]/specialDesignatorClasses[li = "PrisonLabor.Core.LaborArea.Designator_AreaLaborExpand"]</xpath> | ||
<success>Invert</success> | ||
</li> | ||
<li Class="PatchOperationAdd"> | ||
<xpath>/Defs/DesignationCategoryDef[defName = "Zone"]/specialDesignatorClasses</xpath> | ||
<value> | ||
<li>PrisonLabor.Core.LaborArea.Designator_AreaLaborExpand</li> | ||
</value> | ||
</li> | ||
</operations> | ||
</li> | ||
<li Class="PatchOperationSequence"> | ||
<success>Always</success> | ||
<operations> | ||
<li Class="PatchOperationTest"> | ||
<xpath>/Defs/DesignationCategoryDef[defName = "Zone"]/specialDesignatorClasses[li = "PrisonLabor.Core.LaborArea.Designator_AreaLaborClear"]</xpath> | ||
<success>Invert</success> | ||
</li> | ||
<li Class="PatchOperationAdd"> | ||
<xpath>/Defs/DesignationCategoryDef[defName = "Zone"]/specialDesignatorClasses</xpath> | ||
<value> | ||
<li>PrisonLabor.Core.LaborArea.Designator_AreaLaborClear</li> | ||
</value> | ||
</li> | ||
</operations> | ||
</li> | ||
</operations> | ||
</Operation> | ||
</Patch> |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,6 +65,7 @@ public enum Version | |
v1_2_0, | ||
v1_2_1, | ||
v1_2_2, | ||
v1_2_3 | ||
v1_2_3, | ||
v1_2_4 | ||
} | ||
} |
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
31 changes: 31 additions & 0 deletions
31
Source/HarmonyPatches/Patches_Food/GetFoodRestrictionPatch.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,31 @@ | ||
using HarmonyLib; | ||
using PrisonLabor.Core.Needs; | ||
using PrisonLabor.Core.Trackers; | ||
using RimWorld; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using Verse; | ||
|
||
namespace PrisonLabor.HarmonyPatches.Patches_Food | ||
{ | ||
[HarmonyPatch(typeof(Pawn_FoodRestrictionTracker))] | ||
[HarmonyPatch(nameof(Pawn_FoodRestrictionTracker.GetCurrentRespectedRestriction))] | ||
class GetFoodRestrictionPatch | ||
{ | ||
static FoodRestriction Postfix(FoodRestriction __result, Pawn_FoodRestrictionTracker __instance, Pawn getter) | ||
{ | ||
if(__result == null && __instance.pawn.IsPrisonerOfColony && !__instance.pawn.InMentalState) | ||
{ | ||
Need_Motivation motivation = __instance.pawn.needs.TryGetNeed<Need_Motivation>(); | ||
if(motivation != null && (motivation.CurLevel > 0.7 || __instance.pawn.IsWatched() )) | ||
{ | ||
return __instance.CurrentFoodRestriction; | ||
} | ||
} | ||
return __result; | ||
} | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_OperateScanner.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,82 @@ | ||
using HarmonyLib; | ||
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; | ||
using Verse.AI; | ||
|
||
namespace PrisonLabor.HarmonyPatches.Patches_Work | ||
{ | ||
[HarmonyPatch(typeof(WorkGiver_OperateScanner))] | ||
class Patch_WorkGiver_OperateScanner | ||
{ | ||
[HarmonyPatch("ShouldSkip")] | ||
[HarmonyPostfix] | ||
static bool ShouldSkipPostfix(bool __result, WorkGiver_OperateScanner __instance, Pawn pawn, bool forced) | ||
{ | ||
if (__result && pawn.IsPrisonerOfColony) | ||
{ | ||
return CanOperate(pawn, __instance); | ||
} | ||
return __result; | ||
} | ||
|
||
private static bool CanOperate(Pawn pawn, WorkGiver_OperateScanner __instance) | ||
{ | ||
List<Thing> list = pawn.Map.listerThings.ThingsOfDef(__instance.ScannerDef); | ||
for (int i = 0; i < list.Count; i++) | ||
{ | ||
if (list[i].Faction == Faction.OfPlayer) | ||
{ | ||
CompScanner compScanner = list[i].TryGetComp<CompScanner>(); | ||
if (compScanner != null && compScanner.CanUseNow) | ||
{ | ||
return false; | ||
} | ||
} | ||
} | ||
return true; | ||
} | ||
|
||
[HarmonyPatch("HasJobOnThing")] | ||
[HarmonyPostfix] | ||
static bool HasJobOnThingPostfix(bool __result, Pawn pawn, Thing t, bool forced) | ||
{ | ||
if(!__result && pawn.IsPrisonerOfColony) | ||
{ | ||
if(t.Faction != Faction.OfPlayer) | ||
{ | ||
return false; | ||
} | ||
Building building = t as Building; | ||
if (building == null) | ||
{ | ||
return false; | ||
} | ||
if (building.IsForbidden(pawn)) | ||
{ | ||
return false; | ||
} | ||
if (!pawn.CanReserve(building, 1, -1, null, forced)) | ||
{ | ||
return false; | ||
} | ||
if (!building.TryGetComp<CompScanner>().CanUseNow) | ||
{ | ||
return false; | ||
} | ||
if (building.IsBurning()) | ||
{ | ||
return false; | ||
} | ||
return true; | ||
} | ||
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
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