Skip to content

Commit

Permalink
Merge pull request #242 from Aviuz/1.3.3
Browse files Browse the repository at this point in the history
NPR fixes
  • Loading branch information
Hazzer authored Sep 11, 2021
2 parents 820f7f0 + 074f714 commit 6ec9c0f
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 18 deletions.
Binary file modified 1.3/Assemblies/PrisonLabor.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 @@ -25,7 +25,7 @@
</li>
</modDependencies>

<description>Version 1.3.2
<description>Version 1.3.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.3.2-orange.svg?style=flat" alt="v1.3.2" />
<img src="https://img.shields.io/badge/version-1.3.3-orange.svg?style=flat" alt="v1.3.3" />
</a>
</p>

Expand Down
19 changes: 13 additions & 6 deletions Source/Core/AI/ThinkNodes/ThinkNode_Labor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,25 @@ protected override bool Satisfied(Pawn pawn)

// Prisoner will escape if get ready to run.
// If he can run he will start ticking impatient, once complete he will get ready.

var prisonerComp = pawn.TryGetComp<PrisonerComp>();
if (pawn.guest.PrisonerIsSecure && RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn))
if (prisonerComp != null)
{
if (prisonerComp.escapeTracker.ReadyToEscape)
return false;
if (pawn.guest.PrisonerIsSecure && RCellFinder.TryFindBestExitSpot(pawn, out c, TraverseMode.ByPawn))
{
if (prisonerComp.EscapeTracker.ReadyToEscape)
return false;
else
prisonerComp.EscapeTracker.CanEscape = true;
}
else
prisonerComp.escapeTracker.CanEscape = true;
{
prisonerComp.EscapeTracker.CanEscape = false;
}
}
else
{
prisonerComp.escapeTracker.CanEscape = false;
DebugLogger.warn($"Prisoner comp is null for {pawn.NameShortColored}");
}


Expand Down
4 changes: 2 additions & 2 deletions Source/Core/AI/WorkGivers/WorkGiver_Supervise.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false)
return null;
var prisonerComp = prisoner.TryGetComp<PrisonerComp>(); ;

if (!PrisonLaborUtility.LaborEnabled(prisoner) && prisonerComp != null && !prisonerComp.escapeTracker.CanEscape)
if (!PrisonLaborUtility.LaborEnabled(prisoner) && prisonerComp != null && !prisonerComp.EscapeTracker.CanEscape)
return null;
if (PrisonLaborUtility.RecruitInLaborEnabled(prisoner))
return new Job(JobDefOf.PrisonerAttemptRecruit, t);
if (PrisonLaborUtility.ConvertInLaborEnabled(prisoner))
return new Job(JobDefOf.PrisonerConvert, t);
if (PrisonLaborUtility.EnslaveInLaborEnabled(prisoner))
return new Job(JobDefOf.PrisonerEnslave, t);
if ((!PrisonLaborUtility.WorkTime(prisoner) || !need.ShouldBeMotivated) && prisonerComp != null && !prisonerComp.escapeTracker.CanEscape)
if ((!PrisonLaborUtility.WorkTime(prisoner) || !need.ShouldBeMotivated) && prisonerComp != null && !prisonerComp.EscapeTracker.CanEscape)
return null;

return new Job(DefDatabase<JobDef>.GetNamed("PrisonLabor_PrisonerSupervise"), prisoner);
Expand Down
16 changes: 14 additions & 2 deletions Source/Core/Components/PrisonerComp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,19 @@ namespace PrisonLabor.Core.Components

public class PrisonerComp : ThingComp
{
public EscapeTracker escapeTracker;
private EscapeTracker escapeTracker;

public EscapeTracker EscapeTracker
{
get
{
if (escapeTracker == null)
{
escapeTracker = new EscapeTracker(this.parent as Pawn);
}
return escapeTracker;
}
}

private bool Active
{
Expand Down Expand Up @@ -83,7 +95,7 @@ public override void CompTickRare()
{
if (Active)
{
escapeTracker?.Tick();
EscapeTracker.Tick();
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Source/Core/MainButton_Window/ColumnWorker_EscapeTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ protected override string GetTextFor(Pawn pawn)
var prisonerComp = pawn.TryGetComp<PrisonerComp>();
if(prisonerComp != null)
{
return (prisonerComp.escapeTracker.ReadyToEscape ? "ready" : prisonerComp.escapeTracker.ReadyToRunPercentage + " %");
return (prisonerComp.EscapeTracker.ReadyToEscape ? "ready" : prisonerComp.EscapeTracker.ReadyToRunPercentage + " %");
}

return null;
Expand All @@ -28,7 +28,7 @@ protected override string GetTip(Pawn pawn)
var prisonerComp = pawn.TryGetComp<PrisonerComp>();
if (prisonerComp != null)
{
return $"(Cap:{ prisonerComp.escapeTracker.EscapeLevel})";
return $"(Cap:{ prisonerComp.EscapeTracker.EscapeLevel})";
}
return null;
}
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 @@ -70,6 +70,7 @@ public enum Version
v1_2_5,
v1_3,
v1_3_1,
v1_3_2
v1_3_2,
v1_3_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
{
class VersionUtility
{
public const Version versionNumber = Version.v1_3_2;
public const string versionString = "1.3.2";
public const Version versionNumber = Version.v1_3_3;
public const string versionString = "1.3.3";

public static Version VersionOfSaveFile { get; set; }

Expand Down
5 changes: 5 additions & 0 deletions Source/Core/Other/DebugLogger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,10 @@ public static void info(string msg)
{
Log.Message(msg);
}

internal static void warn(string msg)
{
Log.Warning(msg);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static bool IsReadyToEscape(Pawn pawn)
{

var prisonerComp = pawn.TryGetComp<PrisonerComp>();
if (prisonerComp != null && prisonerComp.escapeTracker.ReadyToEscape)
if (prisonerComp != null && prisonerComp.EscapeTracker.ReadyToEscape)
return true;
else
return false;
Expand Down
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.3.3" silent="true"/>
<patch version="1.3.2" silent="true"/>
<patch version="1.3.0" silent ="false">
<title>Prison Labor v 1.3.0</title>
Expand Down
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Changelog:
1.3.3
- NPR fixes for EscapeTracker
1.3.2
- Added Multiplayer mod compatibility (https://github.com/Thomas107500)
1.3.1
Expand Down

0 comments on commit 6ec9c0f

Please sign in to comment.