Skip to content

Commit

Permalink
Merge pull request #258 from Aviuz/1.4.3
Browse files Browse the repository at this point in the history
1.4.3 fixes
  • Loading branch information
Hazzer authored Nov 6, 2022
2 parents 0d108fc + 0b94843 commit a2696cb
Show file tree
Hide file tree
Showing 18 changed files with 65 additions and 33 deletions.
Binary file modified 1.4/Assemblies/PrisonLabor.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified 1.4/Kijin/Assemblies/PrisonLaborKijinCompatibility.dll
Binary file not shown.
Binary file modified 1.4/Quarry/Assemblies/PrisonLaborQuarryCompatibility.dll
Binary file not shown.
Binary file modified 1.4/Therapy/Assemblies/PrisonLaborTherapyCompatibility.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 @@ -34,7 +34,7 @@
</modDependencies>

<description>
Version 1.4.2
Version 1.4.3

This mod force prisoners to work. To enable this feature prisoners must have "Force to work" option checked ("Prisoner" tab). Prison labor needs management that consist:
- Motivation - prisoners need to be motivated by presence of colonists. Wardens have new job - supervising prisoners. Low motivation can lead to revolts.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
</p>
<p align="center">
<a href="https://github.com/Aviuz/PrisonLabor/releases">
<img src="https://img.shields.io/badge/version-1.4.2-orange.svg?style=flat" alt="v1.4.2" />
<img src="https://img.shields.io/badge/version-1.4.3-orange.svg?style=flat" alt="v1.4.3" />
</a>
</p>

Expand Down
3 changes: 2 additions & 1 deletion Source/Core/Meta/Version.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public enum Version
v1_3_11,
v1_4_0,
v1_4_1,
v1_4_2
v1_4_2,
v1_4_3
}
}
4 changes: 2 additions & 2 deletions Source/Core/Meta/VersionUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ namespace PrisonLabor.Core.Meta
{
public class VersionUtility
{
public const Version versionNumber = Version.v1_4_2;
public const string versionString = "1.4.2";
public const Version versionNumber = Version.v1_4_3;
public const string versionString = "1.4.3";

public static Version VersionOfSaveFile { get; set; }

Expand Down
2 changes: 1 addition & 1 deletion Source/Core/Needs/Need_Motivation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public override void SetInitialLevel()
IsPrisonerWorking = false;
}

protected override bool IsFrozen => !PrisonLaborPrefs.EnableMotivationMechanics || base.IsFrozen;
protected override bool IsFrozen => !PrisonLaborPrefs.EnableMotivationMechanics || base.IsFrozen || pawn.Map == null;

public override void NeedInterval()
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Core/PrisonLaborUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public static bool IsDisabledByLabor(IntVec3 pos, Pawn pawn, WorkTypeDef workTyp

public static bool CanWorkHere(IntVec3 pos, Pawn pawn, WorkTypeDef workType)
{
if (pawn.IsFreeNonSlaveColonist && pos != null && pawn.Map.areaManager.Get<Area_Labor>() != null && !WorkSettings.WorkDisabled(workType))
if ((pawn.IsFreeNonSlaveColonist || pawn.IsColonyMech) && pos != null && pawn.Map.areaManager.Get<Area_Labor>() != null && !WorkSettings.WorkDisabled(workType))
{
bool result = true;
try
Expand Down
25 changes: 25 additions & 0 deletions Source/HarmonyPatches/Patches_Work/Patch_CarryToBuilding.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
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_Work
{

[HarmonyPatch(typeof(WorkGiver_CarryToBuilding), "FindBuildingFor")]
public class Patch_CarryToBuilding
{
static Building Postfix(Building __result, Pawn pawn, Pawn traveller, bool forced)
{
if (traveller.IsPrisonerOfColony && pawn.IsPrisonerOfColony && traveller == pawn)
{
return null;
}
return __result;
}
}
}
52 changes: 26 additions & 26 deletions Source/HarmonyPatches/Patches_Work/Patch_WorkGiver_Refuel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,37 +18,37 @@ static bool Postfix(bool __result, Pawn pawn, Thing t, bool forced)
{
if (!__result && pawn.IsPrisonerOfColony)
{
return CanRefuel(pawn, t, forced);
}
return CanRefuel(pawn, t, forced);
}
return __result;
}


private static bool CanRefuel(Pawn pawn, Thing t, bool forced)
private static bool CanRefuel(Pawn pawn, Thing t, bool forced)
{
CompRefuelable compRefuelable = t.TryGetComp<CompRefuelable>();
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;
}
CompRefuelable compRefuelable = t.TryGetComp<CompRefuelable>();
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<Thing>() == null)
{
ThingFilter fuelFilter = t.TryGetComp<CompRefuelable>().Props.fuelFilter;
JobFailReason.Is("NoFuelToRefuel".Translate(fuelFilter.Summary));
return false;
}
if (t.TryGetComp<CompRefuelable>().Props.atomicFueling && Traverse.Create(typeof(RefuelWorkGiverUtility)).Method("FindAllFuel", new[] { pawn, t }).GetValue<List<Thing>>() == null)
{
ThingFilter fuelFilter2 = t.TryGetComp<CompRefuelable>().Props.fuelFilter;
JobFailReason.Is("NoFuelToRefuel".Translate(fuelFilter2.Summary));
return false;
}
return true;
}
if (Traverse.Create(typeof(RefuelWorkGiverUtility)).Method("FindBestFuel", new[] { pawn, t }).GetValue<Thing>() == null)
{
ThingFilter fuelFilter = t.TryGetComp<CompRefuelable>().Props.fuelFilter;
JobFailReason.Is("NoFuelToRefuel".Translate(fuelFilter.Summary));
return false;
}
if (t.TryGetComp<CompRefuelable>().Props.atomicFueling && Traverse.Create(typeof(RefuelWorkGiverUtility)).Method("FindAllFuel", new[] { pawn, t }).GetValue<List<Thing>>() == null)
{
ThingFilter fuelFilter2 = t.TryGetComp<CompRefuelable>().Props.fuelFilter;
JobFailReason.Is("NoFuelToRefuel".Translate(fuelFilter2.Summary));
return false;
}
return true;
}
}
}
1 change: 1 addition & 0 deletions Source/Organizer/NewsFeed.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<!-- [img] ... [/img] for image (inside name of file) -->
<!-- [gap] for gap -->
<patches>
<patch version="1.4.3" silent="true"/>
<patch version="1.4.2" silent="true"/>
<patch version="1.4.1" silent ="false">
<title>Prison Labor v 1.4.1</title>
Expand Down
1 change: 1 addition & 0 deletions Source/PrisonLabor.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@
<Compile Include="HarmonyPatches\Patches_GUI\GUI_WorkTab\Patch_WorkDisabled.cs" />
<Compile Include="HarmonyPatches\Patches_GUI\GUI_WorkTab\Patch_WorkDisabled2.cs" />
<Compile Include="HarmonyPatches\Patches_GUI\GUI_WorkTab\Patch_PawnTableSetDirtyFix.cs" />
<Compile Include="HarmonyPatches\Patches_Work\Patch_CarryToBuilding.cs" />
<Compile Include="HarmonyPatches\Patches_Work\Patch_JobDriver_Mine.cs" />
<Compile Include="HarmonyPatches\Patches_Work\Patch_PlantWork.cs" />
<Compile Include="HarmonyPatches\Patches_Work\Patch_WorkGiver_CleanFilth.cs" />
Expand Down
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
Changelog:
1.4.3
- Fix: game should not freeze when prisoner is seleted for gene extraction
- Fix: machanoids should not work in prison labor area
- Fix: game should not throw an error when prisoners is carred by pawn
1.4.2
- Recreation fixes
1.4.1
Expand Down

0 comments on commit a2696cb

Please sign in to comment.