diff --git a/Assemblies/PrisonLabor.dll b/1.1/Assemblies/PrisonLabor.dll similarity index 100% rename from Assemblies/PrisonLabor.dll rename to 1.1/Assemblies/PrisonLabor.dll diff --git a/1.1/Defs/ConceptDef.xml b/1.1/Defs/ConceptDef.xml new file mode 100644 index 00000000..91060a87 --- /dev/null +++ b/1.1/Defs/ConceptDef.xml @@ -0,0 +1,48 @@ + + + + PrisonLabor_Indroduction + + 45 + True + +
  • ITab-Prisoner-Closed
  • +
    + You can force your prisoners to do labor.\n\nTo do so you must select "Force to work" option from "Prisoner" pane\n\nPrisoners will work on orders and bills that are in allowed area. Make sure prisoners can reach their work.\n\nThey can only cook, mine, cut plants, haul, clean, or grow plants, that do not require special skills.\n\nPrisoner sometimes refuses to work. Reasons can be different. He can be injured, hungry, tired, or not motivated enough.\n\nHINT: You can assign work types in "Work" pane.\n\nHINT: If you put a stove in a prison cell make sure they can reach raw food.\n\nHINT: You can let prioners moving through doors by leaving them open. +
    + + PrisonLabor_Motivation + + 100 + True + One of yours prisoners stopped working.\nHe won't work any longer, unless he gets motivated.\n\nYou can check status of motivation in "Needs" tab.\n\nMake sure you have enough wardens (check "Work" tab), or draft one of your colonist and order him to stand around your prisoners.\n\nLow motivation of prisoners can lead to revolts. + + + PrisonLabor_Growing + + 100 + True + Prisoners can only grow plants that don't require any special skills like potato or cotton. They can however gather any plant that is ordered to harvest. + + + PrisonLabor_Management + + 100 + True + You can manage your prison labor in several ways.\n\nYou can assign work types to prisoners by accessing "Work" tab.\n\nYou can restrict when prisoners should work, rest, or sleep by accessing "Restrict" tab.\n\nYou can restrict work to "Prisoners only". For work orders that covers area you can choose "Labor area" tool from "Architect"->"Orders" panel.\nFor bills there is an option "Prisoners only". + + + PrisonLabor_Timetable + + 100 + True + You can make time restrictions for prisoners.\n\n"Work" time will force them to work even when they're hungry or tired.\n\n"Joy" time will let them rest from job and get motivation bonus.\n\n"Sleep" time will force them to stay in prison cell.\n\n"Anything" is default setting. + + + PrisonLabor_Treatment + + 50 + True + In prison labor you need to take care for prisoners. Good treatment can prevent revolts, and can provoke recruit proposition (without recruting process!).\n\nTo maintain good treatment status you need to feed prisoners regularly and set some free time so they can regenerate their strength\n\nTreatment will go lower if you beat prisoners, starve them, or exploit in terms of labor.\nGood treatment will result in:\n - Random offers with request to join colony\n - Preventing revolts\n - Preventing suicide + +
    diff --git a/1.1/Defs/Hediffs.xml b/1.1/Defs/Hediffs.xml new file mode 100644 index 00000000..54128de0 --- /dev/null +++ b/1.1/Defs/Hediffs.xml @@ -0,0 +1,29 @@ + + + + PrisonLabor_PrisonerChains + This pawn has prisoners chains. Note: it is default Vanilla mechanics, but in hediff state + + +
  • + + false +
  • +
  • + + false + 0.01 + +
  • + Manipulation + -0.3 +
  • +
  • + Moving + 0.5 +
  • + + +
    +
    +
    \ No newline at end of file diff --git a/1.1/Defs/Incidents.xml b/1.1/Defs/Incidents.xml new file mode 100644 index 00000000..c10bf685 --- /dev/null +++ b/1.1/Defs/Incidents.xml @@ -0,0 +1,49 @@ + + + PrisonLabor_Revolt + + +
  • Map_PlayerHome
  • +
    + PrisonLabor.Core.Incidents.IncidentWorker_Revolt + Revolt + Revolt has been started by {0}. The prisoners united under faction {1}, and began uprising with self-made weapons + ThreatBig + 5.4 + 20 + ThreatBig + true + 200 +
    + + + PrisonLabor_ResocializationOffer + + Misc + +
  • Map_PlayerHome
  • +
    + PrisonLabor.Core.Incidents.IncidentWorker_ResocializationOffer + Resocialization offer + Offer by {0}. + PositiveEvent + 10 + IncreaseEasy +
    + + + PrisonLabor_Suicide + + Misc + +
  • Map_PlayerHome
  • +
    + PrisonLabor.Core.Incidents.IncidentWorker_Suicide + Prisoner suicide + {0} has commited suicide, because of bad treatment. + NegativeEvent + 2 + 500 + false +
    +
    diff --git a/1.1/Defs/JobDef.xml b/1.1/Defs/JobDef.xml new file mode 100644 index 00000000..3627197a --- /dev/null +++ b/1.1/Defs/JobDef.xml @@ -0,0 +1,32 @@ + + + + PrisonLabor_PrisonerSupervise + PrisonLabor.Core.AI.JobDrivers.JobDriver_Supervise + watching prisoner TargetA. + true + + + PrisonLabor_Arrest + JobDriver_TakeToBed + arresting TargetA. + true + true + false + + + PrisonLabor_Mine_Tweak + PrisonLabor.Tweaks.JobDriver_Mine_Tweak + digging at TargetA. + + + PrisonLabor_Harvest_Tweak + PrisonLabor.Tweaks.JobDriver_PlantHarvest_Tweak + harvesting TargetA. + + + PrisonLabor_CutPlant_Tweak + PrisonLabor.Tweaks.JobDriver_PlantCut_Tweak + cutting TargetA. + + diff --git a/1.1/Defs/Needs.xml b/1.1/Defs/Needs.xml new file mode 100644 index 00000000..e8ab7b5c --- /dev/null +++ b/1.1/Defs/Needs.xml @@ -0,0 +1,22 @@ + + + + PrisonLabor_Motivation + PrisonLabor.Core.Needs.Need_Motivation + + Motivation represents how motivated to work is prisoner. Motivation can be improved by colonists standing nearby. + 90 + false + false + + + PrisonLabor_Treatment + PrisonLabor.Core.Needs.Need_Treatment + + Treatment happiness represents how prisoners are content of treatment in colony. + 89 + false + false + false + + diff --git a/1.1/Defs/PrisonerInteractionModeDef.xml b/1.1/Defs/PrisonerInteractionModeDef.xml new file mode 100644 index 00000000..1077ec61 --- /dev/null +++ b/1.1/Defs/PrisonerInteractionModeDef.xml @@ -0,0 +1,13 @@ + + + + PrisonLabor_workOption + + 5 + + + PrisonLabor_workAndRecruitOption + + 6 + + diff --git a/1.1/Defs/ThinkTreeDef.xml b/1.1/Defs/ThinkTreeDef.xml new file mode 100644 index 00000000..18571ade --- /dev/null +++ b/1.1/Defs/ThinkTreeDef.xml @@ -0,0 +1,26 @@ + + + + PrisonLabor_WorkThinkTree + Humanlike_PostDuty + 80 + + false + +
  • + +
  • + +
  • +
  • + +
  • +
  • +
  • +
  • + +
  • +
    +
    +
    +
    diff --git a/1.1/Defs/ThoughtsDef.xml b/1.1/Defs/ThoughtsDef.xml new file mode 100644 index 00000000..4fb5052d --- /dev/null +++ b/1.1/Defs/ThoughtsDef.xml @@ -0,0 +1,37 @@ + + + + + PrisonLabor_VeryGoodTreatment + PrisonLabor.Core.AI.ThoughtWorkers.ThoughtWorker_VeryGoodTreatment + +
  • + + In this prison I've been treated very well. + 15 +
  • +
    +
    + + PrisonLabor_LowMotivation + PrisonLabor.Core.AI.ThoughtWorkers.ThoughtWorker_LowMotivation + +
  • + + Nobody cares if I'm working or not. + 5 +
  • +
    +
    + + PrisonLabor_FreeTime + PrisonLabor.Core.AI.ThoughtWorkers.ThoughtWorker_FreeTime + +
  • + + Even tough I'm prisoner, I can still have some free time. + 5 +
  • +
    +
    +
    diff --git a/1.1/Defs/WorkGiverDef.xml b/1.1/Defs/WorkGiverDef.xml new file mode 100644 index 00000000..aa7f87aa --- /dev/null +++ b/1.1/Defs/WorkGiverDef.xml @@ -0,0 +1,15 @@ + + + + PrisonLabor_SupervisePrisonLabor + + PrisonLabor.Core.AI.WorkGivers.WorkGiver_Supervise + PrisonLabor_Jailor + 5 + watch prisoner + watching prisoner + +
  • Talking
  • +
    +
    +
    diff --git a/1.1/Defs/WorkTypes.xml b/1.1/Defs/WorkTypes.xml new file mode 100644 index 00000000..c84ec975 --- /dev/null +++ b/1.1/Defs/WorkTypes.xml @@ -0,0 +1,19 @@ + + + + PrisonLabor_Jailor + Jailor + Jailor + watching prisoners + Manage prisoners, which includes escort, watching, releasing, and execution of prisoners. + Supervise + 1099 + true + +
  • Social
  • +
    + +
  • Social
  • +
    +
    +
    diff --git a/1.2/Assemblies/PrisonLabor.dll b/1.2/Assemblies/PrisonLabor.dll index 458e8559..e0b5fe4f 100644 Binary files a/1.2/Assemblies/PrisonLabor.dll and b/1.2/Assemblies/PrisonLabor.dll differ diff --git a/About/About.xml b/About/About.xml index 99788447..90cdc9e8 100644 --- a/About/About.xml +++ b/About/About.xml @@ -20,7 +20,7 @@ - Version 1.1.11 + Version 1.2.0 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. diff --git a/Defs/Hediffs.xml b/Defs/Hediffs.xml index 54128de0..9adf6c0d 100644 --- a/Defs/Hediffs.xml +++ b/Defs/Hediffs.xml @@ -10,19 +10,78 @@ false
  • - + false 0.01 +
  • +
  • + + false + 0.60
  • Manipulation -0.3
  • + + +
  • + + false + 0.80 +
  • Moving 0.5
  • + +
  • + + false + 0.90 + +
  • + Manipulation + -0.3 +
  • +
  • + Moving + 0.5 +
  • + + + + + + PrisonLabor_RemovedHandscuffs + Prisoner has removed handscuffs + + +
  • + + false +
  • +
  • + + true + 0.01 +
  • +
    +
    + + PrisonLabor_RemovedLegscuffs + Prisoner has removed legscuffs + + +
  • + + false +
  • +
  • + + true + 0.01
  • diff --git a/Defs/JobDef.xml b/Defs/JobDef.xml index 3627197a..db721c93 100644 --- a/Defs/JobDef.xml +++ b/Defs/JobDef.xml @@ -29,4 +29,16 @@ PrisonLabor.Tweaks.JobDriver_PlantCut_Tweak cutting TargetA. + + PrisonLabor_HandlePrisonersLegChain + PrisonLabor.Core.AI.JobDrivers.JobDriver_UnchainLegs + handling legcuffs of prisoner TargetA. + true + + + PrisonLabor_HandlePrisonersHandChain + PrisonLabor.Core.AI.JobDrivers.JobDriver_UnchainHands + handling handcuffs of prisoner TargetA. + true + diff --git a/Languages/English/Keyed/Keys.xml b/Languages/English/Keyed/Keys.xml index e5276874..f7f8c219 100644 --- a/Languages/English/Keyed/Keys.xml +++ b/Languages/English/Keyed/Keys.xml @@ -83,4 +83,12 @@ Enable prisoner full heal rest Prisoner will stay in bed until fully healed + + Put handcuffs + Remove handcuffs + Put legcuffs + Remove legcuffs + + Remove/put handcuffs + Remove/put legscuffs diff --git a/LoadFolders.xml b/LoadFolders.xml index 3b4443d4..cd15049f 100644 --- a/LoadFolders.xml +++ b/LoadFolders.xml @@ -5,6 +5,7 @@
  • /
  • +
  • 1.1
  • /
  • diff --git a/MakeRelease.bat b/MakeRelease.bat index 20d1f58a..287a099b 100644 --- a/MakeRelease.bat +++ b/MakeRelease.bat @@ -12,8 +12,8 @@ mkdir "%target_directory%\About" xcopy "About\*.*" "%target_directory%\About" /e :: Assemblies -mkdir "%target_directory%\Assemblies" -xcopy "Assemblies\*.*" "%target_directory%\Assemblies" /e +::mkdir "%target_directory%\Assemblies" +::xcopy "Assemblies\*.*" "%target_directory%\Assemblies" /e :: Defs mkdir "%target_directory%\Defs" @@ -31,6 +31,14 @@ xcopy "Textures\*.*" "%target_directory%\Textures" /e mkdir "%target_directory%\1.0" xcopy "1.0\*.*" "%target_directory%\1.0" /e +:: 1.1 +mkdir "%target_directory%\1.1" +xcopy "1.1\*.*" "%target_directory%\1.1" /e + +:: 1.2 +mkdir "%target_directory%\1.2" +xcopy "1.2\*.*" "%target_directory%\1.2" /e + :: 1.2 mkdir "%target_directory%\1.2" xcopy "1.2\*.*" "%target_directory%\1.2" /e diff --git a/README.md b/README.md index c67565e1..aaeeaf7a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@

    - v1.1.11 + v1.2.0

    diff --git a/Source/Constants/BGP.cs b/Source/Constants/BGP.cs index 08a78b36..0fd3f33a 100644 --- a/Source/Constants/BGP.cs +++ b/Source/Constants/BGP.cs @@ -47,5 +47,9 @@ public static class BGP public const float BeatenHit = -0.1f; #endregion + + #region Chains + public const int Unchain_Ticks = 10; + #endregion } } diff --git a/Source/Constants/PL_DefOf.cs b/Source/Constants/PL_DefOf.cs index f6a9fed4..e14e30d1 100644 --- a/Source/Constants/PL_DefOf.cs +++ b/Source/Constants/PL_DefOf.cs @@ -17,5 +17,11 @@ public static class PL_DefOf public static NeedDef PrisonLabor_Motivation; public static NeedDef PrisonLabor_Treatment; + + public static HediffDef PrisonLabor_RemovedHandscuffs; + public static HediffDef PrisonLabor_RemovedLegscuffs; + + public static JobDef PrisonLabor_HandlePrisonersHandChain; + public static JobDef PrisonLabor_HandlePrisonersLegChain; } } diff --git a/Source/Core/AI/JobDrivers/JobDriver_Unchain.cs b/Source/Core/AI/JobDrivers/JobDriver_Unchain.cs new file mode 100644 index 00000000..b24fac71 --- /dev/null +++ b/Source/Core/AI/JobDrivers/JobDriver_Unchain.cs @@ -0,0 +1,76 @@ +using PrisonLabor.Constants; +using RimWorld; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; +using Verse.AI; + +namespace PrisonLabor.Core.AI.JobDrivers +{ + abstract class JobDriver_Unchain : JobDriver + { + private int ticks = 0; + public override bool TryMakePreToilReservations(bool errorOnFailed) + { + return pawn.Reserve(job.GetTarget(TargetIndex.A), job, 1, -1, null, errorOnFailed); + } + + protected IEnumerable MakeNewToils(HediffDef hediffDef) + { + this.FailOnDespawnedNullOrForbidden(TargetIndex.A); + //this.FailOnDowned(TargetIndex.A); + this.FailOnAggroMentalState(TargetIndex.A); + yield return Toils_Goto.GotoThing(TargetIndex.A, PathEndMode.Touch); + Toil wait = new Toil(); + wait.initAction = delegate + { + Pawn actor2 = wait.actor; + Pawn pawn2 = (Pawn)job.GetTarget(TargetIndex.A).Thing; + actor2.pather.StopDead(); + PawnUtility.ForceWait(pawn2, 15000, null, maintainPosture: true); + }; + wait.tickAction = delegate + { + ticks++; + }; + wait.AddFinishAction(delegate + { + Pawn pawn = (Pawn)job.GetTarget(TargetIndex.A).Thing; + if (pawn != null) + { + Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(hediffDef, false); + if (hediff == null) + { + hediff = HediffMaker.MakeHediff(hediffDef, pawn, null); + pawn.health.AddHediff(hediff, null, null); + } + else + { + pawn.health.hediffSet.hediffs.Remove(hediff); + } + if (pawn.CurJobDef == JobDefOf.Wait_MaintainPosture) + { + pawn.jobs.EndCurrentJob(JobCondition.InterruptForced); + } + } + }); + wait.FailOnDespawnedOrNull(TargetIndex.A); + wait.FailOnCannotTouch(TargetIndex.A, PathEndMode.Touch); + wait.AddEndCondition(() => + { + if (ticks >= BGP.Unchain_Ticks) + { + return JobCondition.Succeeded; + } + return JobCondition.Ongoing; + } + ); + wait.defaultCompleteMode = ToilCompleteMode.Never; + wait.WithProgressBar(TargetIndex.A, () => ticks / BGP.Unchain_Ticks); + yield return wait; + } + } +} diff --git a/Source/Core/AI/JobDrivers/JobDriver_UnchainHands.cs b/Source/Core/AI/JobDrivers/JobDriver_UnchainHands.cs new file mode 100644 index 00000000..55dc6018 --- /dev/null +++ b/Source/Core/AI/JobDrivers/JobDriver_UnchainHands.cs @@ -0,0 +1,20 @@ +using PrisonLabor.Constants; +using RimWorld; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; +using Verse.AI; + +namespace PrisonLabor.Core.AI.JobDrivers +{ + class JobDriver_UnchainHands : JobDriver_Unchain + { + protected override IEnumerable MakeNewToils() + { + return MakeNewToils(PL_DefOf.PrisonLabor_RemovedHandscuffs); + } + } +} diff --git a/Source/Core/AI/JobDrivers/JobDriver_UnchainLegs.cs b/Source/Core/AI/JobDrivers/JobDriver_UnchainLegs.cs new file mode 100644 index 00000000..b8fb3489 --- /dev/null +++ b/Source/Core/AI/JobDrivers/JobDriver_UnchainLegs.cs @@ -0,0 +1,21 @@ +using PrisonLabor.Constants; +using RimWorld; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; +using Verse.AI; + +namespace PrisonLabor.Core.AI.JobDrivers +{ + class JobDriver_UnchainLegs : JobDriver_Unchain + { + + protected override IEnumerable MakeNewToils() + { + return MakeNewToils(PL_DefOf.PrisonLabor_RemovedLegscuffs); + } + } +} diff --git a/Source/Core/Hediffs/HediffGiver_PrisonersChains.cs b/Source/Core/Hediffs/HediffGiver_PrisonersChains.cs index 3c3ace79..07516824 100644 --- a/Source/Core/Hediffs/HediffGiver_PrisonersChains.cs +++ b/Source/Core/Hediffs/HediffGiver_PrisonersChains.cs @@ -4,6 +4,7 @@ using System.Text; using Verse; using RimWorld; +using PrisonLabor.Constants; namespace PrisonLabor.Core.Hediffs { @@ -12,20 +13,38 @@ class HediffGiver_PrisonersChains : HediffGiver public override void OnIntervalPassed(Pawn pawn, Hediff cause) { Hediff hediff = pawn.health.hediffSet.GetFirstHediffOfDef(this.hediff, false); - + float mod = 0f; + if (pawn != null && pawn.IsPrisonerOfColony) + { + if (pawn.health.hediffSet.GetFirstHediffOfDef(PL_DefOf.PrisonLabor_RemovedHandscuffs, false) != null) + { + mod += 0.19f; + } + if (pawn.health.hediffSet.GetFirstHediffOfDef(PL_DefOf.PrisonLabor_RemovedLegscuffs, false) != null) + { + mod += 0.19f * 2f; + + } + } float value; if (RestraintsUtility.InRestraints(pawn)) - value = 1.0f; - else if(hediff != null && pawn.Faction != Faction.OfPlayer) + value = 1.0f - mod; + else if (hediff != null && pawn.Faction != Faction.OfPlayer) value = hediff.Severity - 0.01f; else value = 0.0f; + + if (pawn.guest != null && pawn.guest.Released) + { + value = 0f; + } + if (hediff != null) { hediff.Severity = value; } - else if (value != 0) + else if (value != 0 && pawn.IsPrisonerOfColony) { hediff = HediffMaker.MakeHediff(this.hediff, pawn, null); hediff.Severity = value; diff --git a/Source/Core/Meta/Version.cs b/Source/Core/Meta/Version.cs index e74ab070..0ea7197c 100644 --- a/Source/Core/Meta/Version.cs +++ b/Source/Core/Meta/Version.cs @@ -61,6 +61,7 @@ public enum Version v1_1_8, v1_1_9, v1_1_10, - v1_1_11 + v1_1_11, + v1_2_0 } } diff --git a/Source/Core/Meta/VersionUtility.cs b/Source/Core/Meta/VersionUtility.cs index 30dd4811..dd6234a1 100644 --- a/Source/Core/Meta/VersionUtility.cs +++ b/Source/Core/Meta/VersionUtility.cs @@ -5,8 +5,8 @@ namespace PrisonLabor.Core.Meta { class VersionUtility { - public const Version versionNumber = Version.v1_1_11; - public const string versionString = "1.1.11"; + public const Version versionNumber = Version.v1_2_0; + public const string versionString = "1.2.0"; public static Version VersionOfSaveFile { get; set; } diff --git a/Source/HarmonyPatches/Patches_GUI/GUI_Bill/Patch_BillCheckbox.cs b/Source/HarmonyPatches/Patches_GUI/GUI_Bill/Patch_BillCheckbox.cs index de16fe89..de741e69 100644 --- a/Source/HarmonyPatches/Patches_GUI/GUI_Bill/Patch_BillCheckbox.cs +++ b/Source/HarmonyPatches/Patches_GUI/GUI_Bill/Patch_BillCheckbox.cs @@ -68,7 +68,7 @@ private static IEnumerable Transpiler(ILGenerator gen, MethodBa { "Void PlayOneShotOnCamera(Verse.SoundDef, Verse.Map)", "System.Reflection.Emit.Label", - "Verse.Listing_Standard (30)", + "Verse.Listing_Standard (31)", }; var listing = HPatcher.FindOperandAfter(opCodes4, operands4, instr); diff --git a/Source/HarmonyPatches/Patches_GUI/GUI_Bill/Patch_RestrictBillToPrisoner.cs b/Source/HarmonyPatches/Patches_GUI/GUI_Bill/Patch_RestrictBillToPrisoner.cs new file mode 100644 index 00000000..e1adfe2d --- /dev/null +++ b/Source/HarmonyPatches/Patches_GUI/GUI_Bill/Patch_RestrictBillToPrisoner.cs @@ -0,0 +1,93 @@ +using HarmonyLib; +using PrisonLabor.Core; +using RimWorld; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace PrisonLabor.HarmonyPatches.Patches_GUI.GUI_Bill +{ + [HarmonyPatch(typeof(Dialog_BillConfig))] + [HarmonyPatch("GeneratePawnRestrictionOptions")] + class Patch_RestrictBillToPrisoner + { + static IEnumerable> Postfix(IEnumerable> values, Dialog_BillConfig __instance) + { + foreach (Widgets.DropdownMenuElement value in values) + { + yield return value; + } + Bill_Production bill = Traverse.Create(__instance).Field("bill").GetValue(); + WorkGiverDef workGiver = bill.billStack.billGiver.GetWorkgiver(); + List allPrisonersOfColony = PawnsFinder.AllMaps_PrisonersOfColony; + Widgets.DropdownMenuElement dropdownMenuElement; + foreach (Pawn pawn in allPrisonersOfColony) + { + if (PrisonLaborUtility.LaborEnabled(pawn)) + { + if (pawn.WorkTypeIsDisabled(workGiver.workType)) + { + dropdownMenuElement = new Widgets.DropdownMenuElement + { + option = new FloatMenuOption(string.Format("{0} ({1})", pawn.LabelShortCap, "WillNever".Translate(workGiver.verb)), null), + payload = pawn + }; + yield return dropdownMenuElement; + } + else if (bill.recipe.workSkill != null && !pawn.workSettings.WorkIsActive(workGiver.workType)) + { + dropdownMenuElement = new Widgets.DropdownMenuElement + { + option = new FloatMenuOption(string.Format("{0} ({1} {2}, {3})", pawn.LabelShortCap, pawn.skills.GetSkill(bill.recipe.workSkill).Level, bill.recipe.workSkill.label, "NotAssigned".Translate()), delegate + { + bill.pawnRestriction = pawn; + }), + payload = pawn + }; + yield return dropdownMenuElement; + } + else if (!pawn.workSettings.WorkIsActive(workGiver.workType)) + { + dropdownMenuElement = new Widgets.DropdownMenuElement + { + option = new FloatMenuOption(string.Format("{0} ({1})", pawn.LabelShortCap, "NotAssigned".Translate()), delegate + { + bill.pawnRestriction = pawn; + }), + payload = pawn + }; + yield return dropdownMenuElement; + } + else if (bill.recipe.workSkill != null) + { + dropdownMenuElement = new Widgets.DropdownMenuElement + { + option = new FloatMenuOption($"{pawn.LabelShortCap} ({pawn.skills.GetSkill(bill.recipe.workSkill).Level} {bill.recipe.workSkill.label})", delegate + { + bill.pawnRestriction = pawn; + }), + payload = pawn + }; + yield return dropdownMenuElement; + } + else + { + dropdownMenuElement = new Widgets.DropdownMenuElement + { + option = new FloatMenuOption($"{pawn.LabelShortCap}", delegate + { + bill.pawnRestriction = pawn; + }), + payload = pawn + }; + yield return dropdownMenuElement; + } + } + } + } + } + +} diff --git a/Source/HarmonyPatches/Patches_GUI/GUI_RMB/Patch_RMB_Chains.cs b/Source/HarmonyPatches/Patches_GUI/GUI_RMB/Patch_RMB_Chains.cs new file mode 100644 index 00000000..434d8d4d --- /dev/null +++ b/Source/HarmonyPatches/Patches_GUI/GUI_RMB/Patch_RMB_Chains.cs @@ -0,0 +1,55 @@ +using HarmonyLib; +using PrisonLabor.Constants; +using RimWorld; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using UnityEngine; +using Verse; +using Verse.AI; + +namespace PrisonLabor.HarmonyPatches.Patches_GUI.GUI_RMB +{ + [HarmonyPatch(typeof(FloatMenuMakerMap))] + [HarmonyPatch("AddHumanlikeOrders")] + class Patch_RMB_Chains + { + static void Postfix(Vector3 clickPos, Pawn pawn, List opts) + { + TargetingParameters targetParams = new TargetingParameters() + { + canTargetHumans = true, + canTargetPawns = true, + mapObjectTargetsMustBeAutoAttackable = false, + }; + + var validtargets = GenUI.TargetsAt(clickPos, targetParams); + + foreach (LocalTargetInfo target in validtargets) + { + if(target.Pawn != null && target.Pawn.IsPrisonerOfColony && pawn.CanReach(target, PathEndMode.ClosestTouch, Danger.Deadly)) + { + + opts.AddDistinct(AddOption(pawn, target, labelSelect(target, PL_DefOf.PrisonLabor_RemovedLegscuffs, "PrisonLabor_LegcuffsPut", "PrisonLabor_LegcuffsRemove"), PL_DefOf.PrisonLabor_HandlePrisonersLegChain)); + opts.AddDistinct(AddOption(pawn, target, labelSelect(target, PL_DefOf.PrisonLabor_RemovedHandscuffs, "PrisonLabor_HandcuffsPut", "PrisonLabor_HandcuffsRemove"), PL_DefOf.PrisonLabor_HandlePrisonersHandChain)); + } + } + } + + private static string labelSelect(LocalTargetInfo target, HediffDef hediffDef, String labelA, String labelB) + { + return target.Pawn.health.hediffSet.HasHediff(hediffDef, false) ? labelA : labelB; + } + + + private static FloatMenuOption AddOption(Pawn pawn, LocalTargetInfo target, string keyname, JobDef jobdef) + { + return FloatMenuUtility.DecoratePrioritizedTask(new FloatMenuOption(keyname.Translate(), delegate () + { + pawn.jobs.TryTakeOrderedJob(new Job(jobdef, target.Pawn)); + }, MenuOptionPriority.High), pawn, target); + } + } +} diff --git a/Source/PrisonLabor.csproj b/Source/PrisonLabor.csproj index ce22b277..39274e6e 100644 --- a/Source/PrisonLabor.csproj +++ b/Source/PrisonLabor.csproj @@ -17,7 +17,7 @@ false none false - ..\Assemblies\ + ..\1.2\Assemblies\ DEBUG;TRACE prompt 4 @@ -67,6 +67,9 @@ + + + @@ -106,6 +109,8 @@ + + diff --git a/changelog.txt b/changelog.txt index dfb6fa2a..3b0ab527 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,6 +1,9 @@ Changelog: 1.2.0 - +New features and bugfixes works only with Rimworld 1.2+. Should work fine on old saves but new game recommended. +- Added posibility to remove handcuffs and legscuffs. Those changes affects only moving and manipulation. More effects will be added in future. +- Added posibility to assign bill to selected prisoner +- Fixed prisoners chains hediff for arrivals or crashlanders. Released prisoners also should not be effected by chain (hopefully) 1.1.11 - Another fixes for roof construction. Prisoners should not stuct in roof is outside their reach - Preparation to 1.2 rimworld version