Skip to content

Commit

Permalink
Merge pull request #260 from Aviuz/1.4.5
Browse files Browse the repository at this point in the history
1.4.5
  • Loading branch information
Hazzer authored Nov 24, 2022
2 parents 8112131 + a1f8e89 commit d9db0d4
Show file tree
Hide file tree
Showing 16 changed files with 142 additions and 125 deletions.
Binary file modified 1.4/Assemblies/PrisonLabor.dll
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 4 additions & 0 deletions 1.4/Defs/Needs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<listPriority>90</listPriority>
<major>false</major>
<showForCaravanMembers>false</showForCaravanMembers>
<minIntelligence>Humanlike</minIntelligence>
<colonistAndPrisonersOnly>true</colonistAndPrisonersOnly>
</NeedDef>
<NeedDef>
<defName>PrisonLabor_Treatment</defName>
Expand All @@ -18,5 +20,7 @@
<major>false</major>
<showForCaravanMembers>false</showForCaravanMembers>
<showOnNeedList>false</showOnNeedList>
<minIntelligence>Humanlike</minIntelligence>
<colonistAndPrisonersOnly>true</colonistAndPrisonersOnly>
</NeedDef>
</Defs>
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 @@ -35,7 +35,7 @@
</modDependencies>

<description>
Version 1.4.3
Version 1.4.5

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.4-orange.svg?style=flat" alt="v1.4.4" />
<img src="https://img.shields.io/badge/version-1.4.5-orange.svg?style=flat" alt="v1.4.5" />
</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 @@ -84,6 +84,7 @@ public enum Version
v1_4_1,
v1_4_2,
v1_4_3,
v1_4_4
v1_4_4,
v1_4_5
}
}
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_4;
public const string versionString = "1.4.4";
public const Version versionNumber = Version.v1_4_5;
public const string versionString = "1.4.5";

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 || pawn.Map == null;
protected override bool IsFrozen => !PrisonLaborPrefs.EnableMotivationMechanics || !pawn.IsPrisoner || base.IsFrozen || pawn.Map == null || pawn.Dead;

public override void NeedInterval()
{
Expand Down
247 changes: 128 additions & 119 deletions Source/Core/Needs/Need_Treatment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,139 +8,148 @@

namespace PrisonLabor.Core.Needs
{
/// <summary>
/// VeryGood: 4
/// Good: 3
/// Normal: 2
/// Bad: 1
/// VeryBad: 0
/// </summary>
public enum TreatmentCategory : byte
/// <summary>
/// VeryGood: 4
/// Good: 3
/// Normal: 2
/// Bad: 1
/// VeryBad: 0
/// </summary>
public enum TreatmentCategory : byte
{
VeryGood = 4,
Good = 3,
Normal = 2,
Bad = 1,
VeryBad = 0,
}

public class Need_Treatment : Need
{
private bool _resocializationReady = false;

public float PercentageThreshVeryGood => 0.85f;
public float PercentageThreshGood => 0.65f;
public float PercentageThreshNormal => 0.35f;
public float PercentageThreshBad => 0.15f;

public override int GUIChangeArrow => 0;

public static NeedDef Def => PL_DefOf.PrisonLabor_Treatment;

public bool ResocializationReady
{
VeryGood = 4,
Good = 3,
Normal = 2,
Bad = 1,
VeryBad = 0,
get => _resocializationReady;
set { _resocializationReady = value; }
}

public class Need_Treatment : Need
public TreatmentCategory CurCategory
{
private bool _resocializationReady = false;

public float PercentageThreshVeryGood => 0.85f;
public float PercentageThreshGood => 0.65f;
public float PercentageThreshNormal => 0.35f;
public float PercentageThreshBad => 0.15f;

public override int GUIChangeArrow => 0;

public static NeedDef Def => PL_DefOf.PrisonLabor_Treatment;

public bool ResocializationReady
get
{
if (IsFrozen)
{
get => _resocializationReady;
set { _resocializationReady = value; }
return TreatmentCategory.Normal;
}
if (CurLevelPercentage < PercentageThreshBad)
return TreatmentCategory.VeryBad;
else if (CurLevelPercentage < PercentageThreshNormal)
return TreatmentCategory.Bad;
else if (CurLevelPercentage < PercentageThreshGood)
return TreatmentCategory.Normal;
else if (CurLevelPercentage < PercentageThreshVeryGood)
return TreatmentCategory.Good;
else
return TreatmentCategory.VeryGood;
}
}

public TreatmentCategory CurCategory
{
get
{
if (CurLevelPercentage < PercentageThreshBad)
return TreatmentCategory.VeryBad;
else if (CurLevelPercentage < PercentageThreshNormal)
return TreatmentCategory.Bad;
else if (CurLevelPercentage < PercentageThreshGood)
return TreatmentCategory.Normal;
else if (CurLevelPercentage < PercentageThreshVeryGood)
return TreatmentCategory.Good;
else
return TreatmentCategory.VeryGood;
}
}

public static bool ShowOnList
{
get
{
return PL_DefOf.PrisonLabor_Treatment.showOnNeedList;
}
set
{
PL_DefOf.PrisonLabor_Treatment.showOnNeedList = value;
}
}

public Need_Treatment(Pawn pawn) : base(pawn) { }

public override void SetInitialLevel()
{
CurLevelPercentage = 0.5f;
}

public override void NeedInterval()
{
// Joy
if (pawn.timetable != null && pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Joy)
CurLevel += BGP.JoyRate;

// Status
if (pawn.needs.food != null)
{
var hunger = pawn.needs.TryGetNeed<Need_Food>();

int statusScore = 0;
if (hunger.CurCategory < HungerCategory.UrgentlyHungry)
statusScore += 5;
if (hunger.CurCategory < HungerCategory.Hungry)
statusScore += 5;
statusScore -= (int)pawn.health.hediffSet.PainTotal / 10;
if (pawn.health.HasHediffsNeedingTend())
statusScore -= 7;

CurLevel += statusScore * BGP.StatusMultiplier;
}
public static bool ShowOnList
{
get
{
return PL_DefOf.PrisonLabor_Treatment.showOnNeedList;
}
set
{
PL_DefOf.PrisonLabor_Treatment.showOnNeedList = value;
}
}

public Need_Treatment(Pawn pawn) : base(pawn) { }

// Labor
var motivation = pawn.needs.TryGetNeed<Need_Motivation>();
if (motivation != null && motivation.IsPrisonerWorking)
CurLevel += BGP.LaborRate;
public override void SetInitialLevel()
{
CurLevelPercentage = 0.5f;
}

}
protected override bool IsFrozen => !pawn.IsPrisoner || base.IsFrozen || pawn.Map == null || pawn.Dead;
public override void NeedInterval()
{
if (IsFrozen)
{
return;
}
// Joy
if (pawn.timetable != null && pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Joy)
CurLevel += BGP.JoyRate;

// Status
if (pawn.needs.food != null)
{
var hunger = pawn.needs.TryGetNeed<Need_Food>();

int statusScore = 0;
if (hunger.CurCategory < HungerCategory.UrgentlyHungry)
statusScore += 5;
if (hunger.CurCategory < HungerCategory.Hungry)
statusScore += 5;
statusScore -= (int)pawn.health.hediffSet.PainTotal / 10;
if (pawn.health.HasHediffsNeedingTend())
statusScore -= 7;

CurLevel += statusScore * BGP.StatusMultiplier;
}


// Labor
var motivation = pawn.needs.TryGetNeed<Need_Motivation>();
if (motivation != null && motivation.IsPrisonerWorking)
CurLevel += BGP.LaborRate;

public override string GetTipString()
{
var stringBuilder = new StringBuilder();
stringBuilder.AppendLine(base.GetTipString());
return stringBuilder.ToString();
}
}

public void NotifyPrisonerBeaten(DamageInfo dinfo, bool absorbed)
{
CurLevel += BGP.BeatenHit;
}
public override string GetTipString()
{
var stringBuilder = new StringBuilder();
stringBuilder.AppendLine(base.GetTipString());
return stringBuilder.ToString();
}

public override void DrawOnGUI(Rect rect, int maxThresholdMarkers = 2147483647, float customMargin = -1f, bool drawArrows = true, bool doTooltip = true, Rect? rectForTooltip = null, bool drawLabel = true)
{
if (threshPercents == null)
{
threshPercents = new List<float>();
threshPercents.Add(PercentageThreshBad);
threshPercents.Add(PercentageThreshNormal);
threshPercents.Add(PercentageThreshGood);
threshPercents.Add(PercentageThreshVeryGood);
}
base.DrawOnGUI(rect, maxThresholdMarkers, customMargin, drawArrows, doTooltip, rectForTooltip);
}
public void NotifyPrisonerBeaten(DamageInfo dinfo, bool absorbed)
{
CurLevel += BGP.BeatenHit;
}

public override void ExposeData()
{
base.ExposeData();
Scribe_Values.Look<bool>(ref _resocializationReady, "PrisonLabor_resocialization_ready", false, false);
}
public override void DrawOnGUI(Rect rect, int maxThresholdMarkers = 2147483647, float customMargin = -1f, bool drawArrows = true, bool doTooltip = true, Rect? rectForTooltip = null, bool drawLabel = true)
{
if (threshPercents == null)
{
threshPercents = new List<float>();
threshPercents.Add(PercentageThreshBad);
threshPercents.Add(PercentageThreshNormal);
threshPercents.Add(PercentageThreshGood);
threshPercents.Add(PercentageThreshVeryGood);
}
base.DrawOnGUI(rect, maxThresholdMarkers, customMargin, drawArrows, doTooltip, rectForTooltip);
}

public override bool ShowOnNeedList => pawn.IsPrisoner && ShowOnList;
public override void ExposeData()
{
base.ExposeData();
Scribe_Values.Look<bool>(ref _resocializationReady, "PrisonLabor_resocialization_ready", false, false);
}

public override bool ShowOnNeedList => pawn.IsPrisoner && ShowOnList;
}
}
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.5" silent="true"/>
<patch version="1.4.4" silent="true"/>
<patch version="1.4.3" silent="true"/>
<patch version="1.4.2" silent="true"/>
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.4.5
- Fix: need assigments for prisoners only
1.4.4
- Fix: prisoner work window should be better displayed with greater number of prisoners
- Harmony patches refactor
Expand Down

0 comments on commit d9db0d4

Please sign in to comment.