Skip to content

Commit

Permalink
v3.8.5 fixes ignore forbidden/restrictions functions
Browse files Browse the repository at this point in the history
  • Loading branch information
pardeike committed Sep 23, 2023
1 parent 22700ab commit 11163c8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 9 deletions.
Binary file modified 1.4/Assemblies/AchtungMod.dll
Binary file not shown.
2 changes: 1 addition & 1 deletion About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</li>
</modDependencies>
<packageId>brrainz.achtung</packageId>
<modVersion>3.8.4.0</modVersion>
<modVersion>3.8.5.0</modVersion>
<steamAppId>730936602</steamAppId>
<url>https://github.com/pardeike/Achtung2</url>
<description>Command your colonists like a boss!
Expand Down
2 changes: 1 addition & 1 deletion About/Manifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Manifest>
<identifier>net.pardeike.rimworld.mod.achtung</identifier>
<version>3.8.4.0</version>
<version>3.8.5.0</version>
<targetVersions>
<li>1.0.0</li>
<li>1.1.0</li>
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<ModName>Achtung</ModName>
<ModFileName>Achtung</ModFileName>
<Repository>https://github.com/pardeike/Achtung2</Repository>
<ModVersion>3.8.4.0</ModVersion>
<ModVersion>3.8.5.0</ModVersion>
<ProjectGuid>{8BD5A28F-96C4-43B4-907F-600AA0162F84}</ProjectGuid>
</PropertyGroup>

Expand Down
2 changes: 2 additions & 0 deletions Source/ForcedWork.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public void Unprepare(Pawn pawn)
_ = preparing.Remove(pawn);
}

public bool IsPreparing(Pawn pawn) => preparing.Contains(pawn);

public bool HasForcedJob(Pawn pawn, bool ignorePreparing = false)
{
if (pawn == null)
Expand Down
12 changes: 6 additions & 6 deletions Source/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -451,11 +451,11 @@ static class ForbidUtility_InAllowedArea_Patch
public static void Postfix(/*IntVec3 c,*/ Pawn forPawn, ref bool __result)
{
var map = forPawn?.Map;
if (map == null || forPawn.RaceProps.Humanlike == false)
if (map == null || __result || forPawn.RaceProps.Humanlike == false)
return;

var forcedWork = ForcedWork.Instance;
if (forcedWork.hasForcedJobs == false)
if (forcedWork.hasForcedJobs == false && forcedWork.IsPreparing(forPawn) == false)
return;

if (forcedWork.HasForcedJob(forPawn))
Expand Down Expand Up @@ -727,13 +727,13 @@ public static void FixPatch()
}
}

[HarmonyPrefix]
public static bool Patch(Pawn pawn, ref bool __result)
public static bool Prefix(Thing t, Pawn pawn, ref bool __result)
{
if (pawn?.Map != null && pawn.RaceProps.Humanlike && Achtung.Settings.ignoreForbidden)
if (pawn?.Map != null && pawn.RaceProps.Humanlike)
{
var forcedWork = ForcedWork.Instance;
if (forcedWork.HasForcedJob(pawn))
// t.IsForbidden() is necessary or else we allow a lot more jobs as a side effect
if (forcedWork.HasForcedJob(pawn) && t.IsForbidden(pawn.Faction))
{
__result = false;
return false;
Expand Down

0 comments on commit 11163c8

Please sign in to comment.