diff --git a/1.5/Assemblies/0MultiplayerAPI.dll b/1.5/Assemblies/0MultiplayerAPI.dll new file mode 100644 index 00000000..96486062 Binary files /dev/null and b/1.5/Assemblies/0MultiplayerAPI.dll differ diff --git a/1.5/Assemblies/PrisonLabor.dll b/1.5/Assemblies/PrisonLabor.dll new file mode 100644 index 00000000..b78c2b93 Binary files /dev/null and b/1.5/Assemblies/PrisonLabor.dll differ diff --git a/1.5/CashRegistry/Assemblies/PrisonLaborCashRegistryCompatibility.dll b/1.5/CashRegistry/Assemblies/PrisonLaborCashRegistryCompatibility.dll new file mode 100644 index 00000000..221a3352 Binary files /dev/null and b/1.5/CashRegistry/Assemblies/PrisonLaborCashRegistryCompatibility.dll differ diff --git a/1.5/CleaningArea/Assemblies/PrisonLaborCleaningAreaCompatibility.dll b/1.5/CleaningArea/Assemblies/PrisonLaborCleaningAreaCompatibility.dll new file mode 100644 index 00000000..fc44fc46 Binary files /dev/null and b/1.5/CleaningArea/Assemblies/PrisonLaborCleaningAreaCompatibility.dll differ diff --git a/1.5/ColonyGroups/Assemblies/PrisonLaborColonyGroupsCompatibility.dll b/1.5/ColonyGroups/Assemblies/PrisonLaborColonyGroupsCompatibility.dll new file mode 100644 index 00000000..623bbc02 Binary files /dev/null and b/1.5/ColonyGroups/Assemblies/PrisonLaborColonyGroupsCompatibility.dll differ diff --git a/1.5/Defs/ConceptDef.xml b/1.5/Defs/ConceptDef.xml new file mode 100644 index 00000000..91060a87 --- /dev/null +++ b/1.5/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.5/Defs/Hediffs.xml b/1.5/Defs/Hediffs.xml new file mode 100644 index 00000000..f0fee538 --- /dev/null +++ b/1.5/Defs/Hediffs.xml @@ -0,0 +1,91 @@ + + + + PrisonLabor_PrisonerChains + This pawn has prisoners chains. Note: it is default Vanilla mechanics, but in hediff state + + false + +
  • + + 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 + +
  • + + false +
  • +
  • + + true + 0.01 +
  • +
    +
    + + PrisonLabor_RemovedLegscuffs + Prisoner has removed legscuffs + + false + +
  • + + false +
  • +
  • + + true + 0.01 +
  • +
    +
    +
    \ No newline at end of file diff --git a/1.5/Defs/Incidents.xml b/1.5/Defs/Incidents.xml new file mode 100644 index 00000000..c10bf685 --- /dev/null +++ b/1.5/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.5/Defs/Interrogation/InterrogationDefs.xml b/1.5/Defs/Interrogation/InterrogationDefs.xml new file mode 100644 index 00000000..da7e0e2e --- /dev/null +++ b/1.5/Defs/Interrogation/InterrogationDefs.xml @@ -0,0 +1,15 @@ + + + + PL_GenQuest + +
  • OpportunitySite_ItemStash
  • +
  • OpportunitySite_WorkSite
  • +
    +
    + + PL_InterrogationRoom + + PrisonLabor.Core.Interrogation.RoomRoleWorker_InterrogationRoom + +
    \ No newline at end of file diff --git a/1.5/Defs/Interrogation/InterrogationInteractionsDefs.xml b/1.5/Defs/Interrogation/InterrogationInteractionsDefs.xml new file mode 100644 index 00000000..e94b6e25 --- /dev/null +++ b/1.5/Defs/Interrogation/InterrogationInteractionsDefs.xml @@ -0,0 +1,36 @@ + + + + PL_InterrogateInteraction + + InteractionWorker + True + UI/Icons/Rituals/Trial + + +
  • r_logentry->[INITIATOR_nameDef] asked [RECIPIENT_nameDef] [askPart].
  • +
  • r_logentry->[INITIATOR_nameDef] ordered [RECIPIENT_nameDef] to told about [askPart].
  • +
  • askPart->where is the loot
  • +
  • askPart->why is Gamora
  • +
  • askPart->when finally starts talking
  • +
  • askPart->where is their base
  • +
    +
    +
    + + PL_BeIntrrogatedInteraction + + InteractionWorker + True + UI/Icons/Rituals/TrialDefend + + +
  • r_logentry->[INITIATOR_nameDef] called for mercy.
  • +
  • r_logentry->[INITIATOR_nameDef] begged to spare the face.
  • +
  • r_logentry->[INITIATOR_nameDef] kept silence.
  • +
  • r_logentry->[INITIATOR_nameDef] has no idea.
  • +
  • r_logentry->[INITIATOR_nameDef] told everything.
  • +
    +
    +
    +
    \ No newline at end of file diff --git a/1.5/Defs/Interrogation/InterrogationPatterns.xml b/1.5/Defs/Interrogation/InterrogationPatterns.xml new file mode 100644 index 00000000..44e58003 --- /dev/null +++ b/1.5/Defs/Interrogation/InterrogationPatterns.xml @@ -0,0 +1,191 @@ + + + + PL_Interrogation + + Initiate a prisoner interrogation. Warden will take prisoner and try to get usefull information. Depends on warden's traits and abilities prisoner may end up pretty beat up. + PL_Interrogation + Things/Mote/SpeechSymbols/Speech + Ritual + Precept_Ritual + false + true + false + 1.0 + true + false + true + false + false + + + PL_Interrogation + false + PL_Interrogation + PL_SelectedThing + PL_InterrogationRoom + PL_Interrogation + false + true + + + PL_Interrogation + PrisonLabor.Core.Interrogation.Ritual.RitualOutcomeEffectWorker_Interrogation + false + false + +
  • + + + + PL_InterrogationRoom + PrisonLabor.Core.Interrogation.Ritual.RitualObligationTargetWorker_Interrogation + + + PL_Interrogation + PrisonLabor.Core.Interrogation.Ritual.RitualBehaviorWorker_Interrogation + 5000 + + Spectators are not needed + + +
  • + + an warden + warden + 1 + True + False + false + True +
  • +
  • + + a prisoner + prisoner + 1 + True + False + false +
  • + + +
  • + false + +
  • + warden + prisoner + Convicted prisoner is not reachable. +
  • +
  • + escort asleep + warden +
  • + + +
  • + +
  • prisoner
  • + + +
    + +
  • + warden + PL_DeliverPawnToCell + +
  • + +
  • +
  • + prisoner + Idle +
  • +
    + +
  • + false + +
  • + 1 +
  • + + +
  • + warden + PL_Interrogate + +
  • + false +
  • + + +
  • + prisoner + PL_StandOnCell +
  • +
    + +
    + + + PL_Interrogate + HighPriority + Off + true + + +
  • + 0.6 + +
  • + 50~250 +
  • +
    + +
  • + Speech_Ideoligious_Male + Speech_Ideoligious_Female +
  • + +
    +
    + + PL_DeliverPawnToCell + HighPriority + Off + + + +
  • + true + Jog +
  • +
    +
    +
    + + PL_StandOnCell + + + +
  • + 60 +
  • + +
    +
    +
    + + + PL_SelectedThing + RitualTargetFilter_SelectedThing + + + PL_Interrogate + PrisonLabor.Core.Interrogation.Ritual.JobDriver_Interrogate + talking. + false + +
    \ No newline at end of file diff --git a/1.5/Defs/Interrogation/InterrogationThoughtDefs.xml b/1.5/Defs/Interrogation/InterrogationThoughtDefs.xml new file mode 100644 index 00000000..2dd2e79f --- /dev/null +++ b/1.5/Defs/Interrogation/InterrogationThoughtDefs.xml @@ -0,0 +1,66 @@ + + + + PL_BitMe + Thought_MemorySocial + 10 + 300 + 1 + Baby, Child, Adult + +
  • + + this fricking lunatic bit me during interrogation + -7 +
  • +
    +
    + + PL_KindInterrogation + Thought_MemorySocial + 10 + 300 + 1 + Baby, Child, Adult + +
  • + + Interrogation was kind of... nice? + 2 +
  • +
    +
    + + PL_Interrogated + Thought_MemorySocial + 10 + 300 + 1 + Baby, Child, Adult + +
  • + + -7 +
  • +
    +
    + + PL_BrutallyInterrogated + Thought_MemorySocial + 10 + 300 + 1 + Baby, Child, Adult + +
  • Masochist
  • +
    + +
  • + + they beat me up during interrogation + -7 + -7 +
  • +
    +
    +
    \ No newline at end of file diff --git a/1.5/Defs/JobDef.xml b/1.5/Defs/JobDef.xml new file mode 100644 index 00000000..4880be2c --- /dev/null +++ b/1.5/Defs/JobDef.xml @@ -0,0 +1,29 @@ + + + + PrisonLabor_PrisonerSupervise + PrisonLabor.Core.AI.JobDrivers.JobDriver_Supervise + watching prisoner TargetA. + true + + + PrisonLabor_Arrest + JobDriver_TakeToBed + arresting TargetA. + true + true + false + + + 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/1.5/Defs/MainButton.xml b/1.5/Defs/MainButton.xml new file mode 100644 index 00000000..e8b23b28 --- /dev/null +++ b/1.5/Defs/MainButton.xml @@ -0,0 +1,166 @@ + + + + PL_Prisoners_Menu + + Manage your faction prisoners + PrisonLabor.Core.MainButton_Window.PrisonerButtonWindow + PL_TabIcon + 35 + true + + + + + PL_Overview + + PrisonLabor.Core.MainButton_Window.MainTabWindow_Overview + 10 + + + + PL_LaborWindow + + PrisonLabor.Core.MainButton_Window.MainTabWindow_Labor + 20 + + + + PL_ScheduleWindow + + PrisonLabor.Core.MainButton_Window.MainTabWindow_Schedule + 30 + + + + PL_AssignWindow + + PrisonLabor.Core.MainButton_Window.MainTabWindow_Assign + 40 + + + + PL_DevWindow + + PrisonLabor.Core.MainButton_Window.MainTabWindow_Dev + true + 100 + + + + + PL_Assign + PawnTable_PlayerPawns + +
  • Label
  • +
  • MedicalCare
  • +
  • GapTiny
  • +
  • Outfit
  • +
  • GapTiny
  • +
  • FoodRestriction
  • +
  • GapTiny
  • +
  • DrugPolicy
  • +
  • RemainingSpace
  • +
    +
    + + + PL_Overview + PawnTable_PlayerPawns + +
  • Label
  • +
  • GapTiny
  • +
  • PL_InteractionColumn
  • +
  • GapTiny
  • +
  • PL_IsWorking
  • +
  • GapTiny
  • +
  • PL_MotivationColumn
  • +
  • GapTiny
  • +
  • PL_HasLegcuffs
  • +
  • GapTiny
  • +
  • PL_HasHandcuffs
  • +
  • GapTiny
  • +
  • PL_Resocialization
  • +
  • GapTiny
  • +
  • PL_HasIntel
  • +
  • RemainingSpace
  • +
    +
    + + + PL_DevTable + PawnTable_PlayerPawns + +
  • Label
  • +
  • GapTiny
  • +
  • PL_EscapeColumn
  • +
  • GapTiny
  • +
  • PL_TreatmentColumn
  • +
  • RemainingSpace
  • +
    +
    + + + + PL_InteractionColumn + + Interaction mode + PrisonLabor.Core.MainButton_Window.ColumnWorker_Interaction + true + + + + PL_Resocialization + + Prisoner wants to join to your colony + PrisonLabor.Core.MainButton_Window.ColumnWorker_Resocialization + + + + PL_HasLegcuffs + + PrisonLabor.Core.MainButton_Window.ColumnWorker_HasLegcuffs + true + + + + PL_HasHandcuffs + + PrisonLabor.Core.MainButton_Window.ColumnWorker_HasHandscuffs + true + + + + PL_EscapeColumn + + PrisonLabor.Core.MainButton_Window.ColumnWorker_EscapeTracker + + + + PL_MotivationColumn + + PrisonLabor.Core.MainButton_Window.ColumnWorker_Motivation + true + + + + PL_TreatmentColumn + + PrisonLabor.Core.MainButton_Window.ColumnWorker_Treatment + true + + + + PL_HasIntel + + PrisonLabor.Core.MainButton_Window.ColumnWorker_HasIntel + true + + + PL_IsWorking + + PrisonLabor.Core.MainButton_Window.ColumnWorker_IsWorking + true + + +
    \ No newline at end of file diff --git a/1.5/Defs/Needs.xml b/1.5/Defs/Needs.xml new file mode 100644 index 00000000..c1f6b06f --- /dev/null +++ b/1.5/Defs/Needs.xml @@ -0,0 +1,26 @@ + + + + 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 + Humanlike + true + + + PrisonLabor_Treatment + PrisonLabor.Core.Needs.Need_Treatment + + Treatment happiness represents how prisoners are content of treatment in colony. + 89 + false + false + false + Humanlike + true + + diff --git a/1.5/Defs/PrisonerInteractionModeDef.xml b/1.5/Defs/PrisonerInteractionModeDef.xml new file mode 100644 index 00000000..e686d0ec --- /dev/null +++ b/1.5/Defs/PrisonerInteractionModeDef.xml @@ -0,0 +1,9 @@ + + + + PrisonLabor_workOption + + 4 + true + + diff --git a/1.5/Defs/PrisonerJoyGivers.xml b/1.5/Defs/PrisonerJoyGivers.xml new file mode 100644 index 00000000..e768bc04 --- /dev/null +++ b/1.5/Defs/PrisonerJoyGivers.xml @@ -0,0 +1,33 @@ + + + + PrisonLabor_PrisonersJoy + +
  • ViewArt
  • +
  • Play_Horseshoes
  • +
  • Play_Hoopstone
  • +
  • Play_Billiards
  • +
  • Play_GameOfUr
  • +
  • Play_Chess
  • +
  • Play_Poker
  • +
  • WatchTelevision
  • +
  • UseTelescope
  • +
    +
    + + + PrisonerLabor_RecrationWalk + PrisonLabor.Core.Recreation.JoyGiver_PrisonerRecrationWalking + 1 + PrionLabor_PrisonerGoForWalk + Meditative + + + + PrionLabor_PrisonerGoForWalk + PrisonLabor.Core.Recreation.JobDriver_PrisonerRecrationWalking + going for a recreataion walk. + 8000 + Meditative + +
    \ No newline at end of file diff --git a/1.5/Defs/ThinkTreeDef.xml b/1.5/Defs/ThinkTreeDef.xml new file mode 100644 index 00000000..39037819 --- /dev/null +++ b/1.5/Defs/ThinkTreeDef.xml @@ -0,0 +1,38 @@ + + + + PrisonLabor_WorkThinkTree + Humanlike_PostDuty + 80 + + false + +
  • + +
  • + +
  • +
  • + +
  • + +
  • +
  • + ChangingApparel + +
  • + +
  • +
  • + +
  • +
  • +
  • +
  • +
  • + +
  • +
    +
    +
    +
    diff --git a/1.5/Defs/ThoughtsDef.xml b/1.5/Defs/ThoughtsDef.xml new file mode 100644 index 00000000..4fb5052d --- /dev/null +++ b/1.5/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.5/Defs/WorkGiverDef.xml b/1.5/Defs/WorkGiverDef.xml new file mode 100644 index 00000000..5cb1ab0a --- /dev/null +++ b/1.5/Defs/WorkGiverDef.xml @@ -0,0 +1,31 @@ + + + + PrisonLabor_SupervisePrisonLabor + + PrisonLabor.Core.AI.WorkGivers.WorkGiver_Supervise + PrisonLabor_Jailor + 5 + watch prisoner + watching prisoner + +
  • Manipulation
  • +
    + +
  • Violent
  • +
    +
    + + + PrisonLabor_HandleChains + + PrisonLabor.Core.AI.WorkGivers.WorkGiver_HandleChains + PrisonLabor_Jailor + 5 + handle prisoner's chains + handling prisoner's chains + +
  • Manipulation
  • +
    +
    +
    diff --git a/1.5/Defs/WorkTypes.xml b/1.5/Defs/WorkTypes.xml new file mode 100644 index 00000000..056f766b --- /dev/null +++ b/1.5/Defs/WorkTypes.xml @@ -0,0 +1,16 @@ + + + + PrisonLabor_Jailor + Jailor + Jailor + watching prisoners + Manage prisoners, which includes escort, watching, releasing, and execution of prisoners. + Supervise + 1099 + true + +
  • Violent
  • +
    +
    +
    diff --git a/1.5/Hospitality/Assemblies/PrisonLaborHospitalityCompatibility.dll b/1.5/Hospitality/Assemblies/PrisonLaborHospitalityCompatibility.dll new file mode 100644 index 00000000..643689da Binary files /dev/null and b/1.5/Hospitality/Assemblies/PrisonLaborHospitalityCompatibility.dll differ diff --git a/1.5/Ideology/Defs/PL_Ideology_InterrogationDefs.xml b/1.5/Ideology/Defs/PL_Ideology_InterrogationDefs.xml new file mode 100644 index 00000000..c811234b --- /dev/null +++ b/1.5/Ideology/Defs/PL_Ideology_InterrogationDefs.xml @@ -0,0 +1,55 @@ + + + + PL_InterrogationChair + + Not comfortable chair used to interrogate prisoners. + + Things/Building/Furniture/DiningChair + Graphic_Multi + (1,1) + + (0.25,0.234375,0.5,0.28125) + (0.25,0.234375,0.5,0.28125) + (0.28125,0.25,0.453125,0.25) + (0.28125,0.25,0.453125,0.25) + + + (0.23, 0.26, 0.23) + + + Building + + 100 + 8000 + 5 + 1.0 + 1 + 0.30 + 5 + + true + +
  • Metallic
  • +
  • Woody
  • +
    + 45 + 30 + Misc7 + 0.35 + South + 2410 + + true + true + + 4 + +
  • ComplexFurniture
  • +
    + +
  • +
  • + + + \ No newline at end of file diff --git a/1.5/Ideology/Patches/JailorForSlavesPatch.xml b/1.5/Ideology/Patches/JailorForSlavesPatch.xml new file mode 100644 index 00000000..06935517 --- /dev/null +++ b/1.5/Ideology/Patches/JailorForSlavesPatch.xml @@ -0,0 +1,14 @@ + + + + Normal + +
  • + */WorkGiverDef[defName="ExecuteSlave"]/workType + + PrisonLabor_Jailor + +
  • + + + \ No newline at end of file diff --git a/1.5/Kijin/Assemblies/PrisonLaborKijinCompatibility.dll b/1.5/Kijin/Assemblies/PrisonLaborKijinCompatibility.dll new file mode 100644 index 00000000..cf0af436 Binary files /dev/null and b/1.5/Kijin/Assemblies/PrisonLaborKijinCompatibility.dll differ diff --git a/1.5/Patches/AddPrisonerComp.xml b/1.5/Patches/AddPrisonerComp.xml new file mode 100644 index 00000000..b5b11c5c --- /dev/null +++ b/1.5/Patches/AddPrisonerComp.xml @@ -0,0 +1,25 @@ + + + + /Defs/ThingDef[thingClass = "Pawn"]/comps + + /Defs/ThingDef[thingClass = "Pawn"] + + +
  • + PrisonLabor.Core.Components.PrisonerComp +
  • +
    +
    +
    + + /Defs/ThingDef[thingClass = "Pawn"]/comps + +
  • + PrisonLabor.Core.Components.PrisonerComp +
  • +
    +
    +
    + +
    \ No newline at end of file diff --git a/1.5/Patches/Designators.xml b/1.5/Patches/Designators.xml new file mode 100644 index 00000000..4b696ade --- /dev/null +++ b/1.5/Patches/Designators.xml @@ -0,0 +1,38 @@ + + + + Normal + +
  • + Always + +
  • + /Defs/DesignationCategoryDef[defName = "Zone"]/specialDesignatorClasses[li = "PrisonLabor.Core.LaborArea.Designator_AreaLaborExpand"] + Invert +
  • +
  • + /Defs/DesignationCategoryDef[defName = "Zone"]/specialDesignatorClasses + +
  • PrisonLabor.Core.LaborArea.Designator_AreaLaborExpand
  • + + +
    + +
  • + Always + +
  • + /Defs/DesignationCategoryDef[defName = "Zone"]/specialDesignatorClasses[li = "PrisonLabor.Core.LaborArea.Designator_AreaLaborClear"] + Invert +
  • +
  • + /Defs/DesignationCategoryDef[defName = "Zone"]/specialDesignatorClasses + +
  • PrisonLabor.Core.LaborArea.Designator_AreaLaborClear
  • + + + + + +
    +
    \ No newline at end of file diff --git a/1.5/Patches/SetJailorJobsPatch.xml b/1.5/Patches/SetJailorJobsPatch.xml new file mode 100644 index 00000000..81ab1099 --- /dev/null +++ b/1.5/Patches/SetJailorJobsPatch.xml @@ -0,0 +1,33 @@ + + + + Normal + +
  • + */WorkGiverDef[defName="DoExecution"]/workType + + PrisonLabor_Jailor + +
  • +
  • + */WorkGiverDef[defName="ExecuteGuiltyColonist"]/workType + + PrisonLabor_Jailor + +
  • +
  • + */WorkGiverDef[defName="ReleasePrisoner"]/workType + + PrisonLabor_Jailor + +
  • +
  • + */WorkGiverDef[defName="TakePrisonerToBed"]/workType + + PrisonLabor_Jailor + +
  • +
    +
    + +
    \ No newline at end of file diff --git a/1.5/Quarry/Assemblies/PrisonLaborQuarryCompatibility.dll b/1.5/Quarry/Assemblies/PrisonLaborQuarryCompatibility.dll new file mode 100644 index 00000000..491e7d94 Binary files /dev/null and b/1.5/Quarry/Assemblies/PrisonLaborQuarryCompatibility.dll differ diff --git a/1.5/Therapy/Assemblies/PrisonLaborTherapyCompatibility.dll b/1.5/Therapy/Assemblies/PrisonLaborTherapyCompatibility.dll new file mode 100644 index 00000000..68356a80 Binary files /dev/null and b/1.5/Therapy/Assemblies/PrisonLaborTherapyCompatibility.dll differ diff --git a/About/About.xml b/About/About.xml index b2f9c059..afbc361f 100644 --- a/About/About.xml +++ b/About/About.xml @@ -8,6 +8,7 @@
  • 1.2
  • 1.3
  • 1.4
  • +
  • 1.5
  • avius.prisonlabor @@ -35,7 +36,7 @@ - Version 1.4.9 + Version 1.5.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/Languages/English/Keyed/Keys.xml b/Languages/English/Keyed/Keys.xml index d5f81313..1590052c 100644 --- a/Languages/English/Keyed/Keys.xml +++ b/Languages/English/Keyed/Keys.xml @@ -110,5 +110,7 @@ Mech can work in prison area When disabled mechs will not work in prison labor area - + + Enable 'Force to Work' by default: + When enabled all new prisoners will have enabled `Force to work` interaction mode diff --git a/LoadFolders.xml b/LoadFolders.xml index d52b0e89..54342a3a 100644 --- a/LoadFolders.xml +++ b/LoadFolders.xml @@ -31,4 +31,17 @@
  • 1.4/Quarry
  • 1.4/ColonyGroups
  • + +
  • /
  • +
  • 1.5
  • +
  • 1.5/Ideology
  • +
  • 1.5/Biotech
  • +
  • 1.5/Therapy
  • +
  • 1.5/Hospitality
  • +
  • 1.5/CleaningArea
  • +
  • 1.5/CashRegistry
  • +
  • 1.5/Kijin
  • +
  • 1.5/Quarry
  • +
  • 1.5/ColonyGroups
  • +
    \ No newline at end of file diff --git a/README.md b/README.md index 5a8acb75..bb9030d7 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@

    - v1.4.9 + v1.5.0

    diff --git a/Source/CompatibilityProjects/CashRegistryCompatibility/CashRegistryCompatibility.csproj b/Source/CompatibilityProjects/CashRegistryCompatibility/CashRegistryCompatibility.csproj index 118c86fe..46d871e5 100644 --- a/Source/CompatibilityProjects/CashRegistryCompatibility/CashRegistryCompatibility.csproj +++ b/Source/CompatibilityProjects/CashRegistryCompatibility/CashRegistryCompatibility.csproj @@ -17,7 +17,7 @@ false none false - ..\..\..\1.4\CashRegistry\Assemblies\ + ..\..\..\1.5\CashRegistry\Assemblies\ DEBUG;TRACE prompt 4 diff --git a/Source/CompatibilityProjects/CleaningAreaCompatibility/CleaningAreaCompatibility.csproj b/Source/CompatibilityProjects/CleaningAreaCompatibility/CleaningAreaCompatibility.csproj index 1831e91e..bbb4e4d1 100644 --- a/Source/CompatibilityProjects/CleaningAreaCompatibility/CleaningAreaCompatibility.csproj +++ b/Source/CompatibilityProjects/CleaningAreaCompatibility/CleaningAreaCompatibility.csproj @@ -17,7 +17,7 @@ false none false - ..\..\..\1.4\CleaningArea\Assemblies\ + ..\..\..\1.5\CleaningArea\Assemblies\ DEBUG;TRACE prompt 4 diff --git a/Source/CompatibilityProjects/ColonyGroupsCompatibility/ColonyGroupsCompatibility.csproj b/Source/CompatibilityProjects/ColonyGroupsCompatibility/ColonyGroupsCompatibility.csproj index 5154ce62..f2d350a7 100644 --- a/Source/CompatibilityProjects/ColonyGroupsCompatibility/ColonyGroupsCompatibility.csproj +++ b/Source/CompatibilityProjects/ColonyGroupsCompatibility/ColonyGroupsCompatibility.csproj @@ -15,10 +15,10 @@ - true - full + false + none false - ..\..\..\1.4\ColonyGroups\Assemblies\ + ..\..\..\1.5\ColonyGroups\Assemblies\ DEBUG;TRACE prompt 4 @@ -32,8 +32,8 @@ 4 - - ..\..\packages\Lib.Harmony.2.2.2\lib\net472\0Harmony.dll + + ..\..\packages\Lib.Harmony.2.3.3\lib\net48\0Harmony.dll False diff --git a/Source/CompatibilityProjects/ColonyGroupsCompatibility/packages.config b/Source/CompatibilityProjects/ColonyGroupsCompatibility/packages.config index 6bf55ad6..967537eb 100644 --- a/Source/CompatibilityProjects/ColonyGroupsCompatibility/packages.config +++ b/Source/CompatibilityProjects/ColonyGroupsCompatibility/packages.config @@ -1,4 +1,4 @@  - + \ No newline at end of file diff --git a/Source/CompatibilityProjects/HospitalityCompatibility/HospitalityCompatibility.csproj b/Source/CompatibilityProjects/HospitalityCompatibility/HospitalityCompatibility.csproj index e04b4eb8..c8668304 100644 --- a/Source/CompatibilityProjects/HospitalityCompatibility/HospitalityCompatibility.csproj +++ b/Source/CompatibilityProjects/HospitalityCompatibility/HospitalityCompatibility.csproj @@ -17,7 +17,7 @@ false none false - ..\..\..\1.4\Hospitality\Assemblies\ + ..\..\..\1.5\Hospitality\Assemblies\ DEBUG;TRACE prompt 4 diff --git a/Source/CompatibilityProjects/KijinCompatibility/KijinCompatibility.csproj b/Source/CompatibilityProjects/KijinCompatibility/KijinCompatibility.csproj index 07ed9ba9..3f1293d0 100644 --- a/Source/CompatibilityProjects/KijinCompatibility/KijinCompatibility.csproj +++ b/Source/CompatibilityProjects/KijinCompatibility/KijinCompatibility.csproj @@ -17,7 +17,7 @@ false none false - ..\..\..\1.4\Kijin\Assemblies\ + ..\..\..\1.5\Kijin\Assemblies\ DEBUG;TRACE prompt 4 diff --git a/Source/CompatibilityProjects/QuarryCompatibility/QuarryCompatibility.csproj b/Source/CompatibilityProjects/QuarryCompatibility/QuarryCompatibility.csproj index eda334fb..dad57c88 100644 --- a/Source/CompatibilityProjects/QuarryCompatibility/QuarryCompatibility.csproj +++ b/Source/CompatibilityProjects/QuarryCompatibility/QuarryCompatibility.csproj @@ -17,7 +17,7 @@ false none false - ..\..\..\1.4\Quarry\Assemblies\ + ..\..\..\1.5\Quarry\Assemblies\ DEBUG;TRACE prompt 4 diff --git a/Source/CompatibilityProjects/TeraphyCompatibility/TherapyCompatibility.csproj b/Source/CompatibilityProjects/TeraphyCompatibility/TherapyCompatibility.csproj index 2e43876a..766ad73e 100644 --- a/Source/CompatibilityProjects/TeraphyCompatibility/TherapyCompatibility.csproj +++ b/Source/CompatibilityProjects/TeraphyCompatibility/TherapyCompatibility.csproj @@ -17,7 +17,7 @@ false none false - ..\..\..\1.4\Therapy\Assemblies\ + ..\..\..\1.5\Therapy\Assemblies\ DEBUG;TRACE prompt 4 diff --git a/Source/Constants/PL_DefOf.cs b/Source/Constants/PL_DefOf.cs index 44c9933a..17227f36 100644 --- a/Source/Constants/PL_DefOf.cs +++ b/Source/Constants/PL_DefOf.cs @@ -11,19 +11,6 @@ namespace PrisonLabor.Constants public static class PL_DefOf { public static PrisonerInteractionModeDef PrisonLabor_workOption; - public static PrisonerInteractionModeDef PrisonLabor_workAndRecruitOption; - - [MayRequireIdeology] - public static PrisonerInteractionModeDef PrisonLabor_workAndConvertOption; - - [MayRequireIdeology] - public static PrisonerInteractionModeDef PrisonLabor_workAndEnslaveOption; - - [MayRequireBiotech] - public static PrisonerInteractionModeDef PrisonLabor_workAndBloodfeedOption; - - [MayRequireBiotech] - public static PrisonerInteractionModeDef PrisonLabor_workAndHemogenFarmOption; public static WorkTypeDef PrisonLabor_Jailor; diff --git a/Source/Core/AI/JobGivers/JobGiver_Prisoner_OptimizeApparel.cs b/Source/Core/AI/JobGivers/JobGiver_Prisoner_OptimizeApparel.cs index da0eabbc..3e71f01e 100644 --- a/Source/Core/AI/JobGivers/JobGiver_Prisoner_OptimizeApparel.cs +++ b/Source/Core/AI/JobGivers/JobGiver_Prisoner_OptimizeApparel.cs @@ -45,7 +45,7 @@ protected override Job TryGiveJob(Pawn pawn) debugSb.AppendLine($"Scanning for {pawn} at {pawn.Position}"); } - Outfit currentOutfit = pawn.outfits.CurrentOutfit; + ApparelPolicy currentOutfit = pawn.outfits.CurrentApparelPolicy; List wornApparel = pawn.apparel.WornApparel; if (pawn.IsMotivated()) diff --git a/Source/Core/AI/WorkGivers/WorkGivers_ManipulatePrisoner.cs b/Source/Core/AI/WorkGivers/WorkGivers_ManipulatePrisoner.cs deleted file mode 100644 index a2fb732d..00000000 --- a/Source/Core/AI/WorkGivers/WorkGivers_ManipulatePrisoner.cs +++ /dev/null @@ -1,45 +0,0 @@ -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.WorkGivers -{ - class WorkGivers_ManipulatePrisoner : WorkGiver_Warden - { - public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false) - { - var prisoner = t as Pawn; - - if (prisoner == null) - return null; - if (!ShouldTakeCareOfPrisoner(pawn, prisoner)) - return null; - if (prisoner.Downed || !pawn.CanReserve(t, 1, -1, null, false) || !prisoner.Awake()) - return null; - if (pawn.IsPrisoner || !pawn.health.capacities.CapableOf(PawnCapacityDefOf.Talking)) - return null; - - - if (PrisonLaborUtility.RecruitInLaborEnabled(prisoner)) - { - return new Job(JobDefOf.PrisonerAttemptRecruit, t); - } - if (PrisonLaborUtility.ConvertInLaborEnabled(pawn, prisoner)) - { - return new Job(JobDefOf.PrisonerConvert, t); - } - if (PrisonLaborUtility.EnslaveInLaborEnabled(pawn, prisoner)) - { - return new Job(JobDefOf.PrisonerEnslave, t); - } - - return null; - } - } -} - diff --git a/Source/Core/GameSaves/SaveCleaner.cs b/Source/Core/GameSaves/SaveCleaner.cs index 0fd3d304..f841effa 100644 --- a/Source/Core/GameSaves/SaveCleaner.cs +++ b/Source/Core/GameSaves/SaveCleaner.cs @@ -168,7 +168,7 @@ private static void UpdateData(XmlElement xmlNode) // TODO bills // Interaction Mode - string[] interactions = { PL_DefOf.PrisonLabor_workOption.defName, PL_DefOf.PrisonLabor_workAndRecruitOption.defName, PL_DefOf.PrisonLabor_workAndConvertOption.defName, PL_DefOf.PrisonLabor_workAndEnslaveOption.defName }; + string[] interactions = { PL_DefOf.PrisonLabor_workOption.defName, "PrisonLabor_workAndRecruitOption", "PrisonLabor_workAndConvertOption", "PrisonLabor_workAndEnslaveOption" }; foreach (var guestTracker in gameNode.GetEveryNode("guest")) { @@ -178,7 +178,7 @@ private static void UpdateData(XmlElement xmlNode) foreach (string interaction in interactions) { if (interactionMode.InnerText == interaction) - interactionMode.InnerText = PrisonerInteractionModeDefOf.NoInteraction.defName; + interactionMode.InnerText = PrisonerInteractionModeDefOf.MaintainOnly.defName; } } } diff --git a/Source/Core/Incidents/IncidentWorker_Suicide.cs b/Source/Core/Incidents/IncidentWorker_Suicide.cs index a0c837e5..cd1cee50 100644 --- a/Source/Core/Incidents/IncidentWorker_Suicide.cs +++ b/Source/Core/Incidents/IncidentWorker_Suicide.cs @@ -61,7 +61,7 @@ protected override bool TryExecuteWorker(IncidentParms parms) SendStandardLetter(parms, new TargetInfo(pawn.Position, pawn.Map), pawn.Name.ToStringShort); parms.faction = pawn.Faction; - DamageInfo dinfo = new DamageInfo(DamageDefOf.Cut, 29, 0, 0, pawn, pawn.RaceProps.body.AllParts.Find(p => p.def == BodyPartDefOf.Neck)); + DamageInfo dinfo = new DamageInfo(DamageDefOf.Cut, 29, 0, 0, pawn, pawn.RaceProps.body.AllParts.Find(p => p.def == BodyPartDefOf.Head)); while (!pawn.Dead) pawn.TakeDamage(dinfo); diff --git a/Source/Core/Interrogation/InterrogationDefsOf.cs b/Source/Core/Interrogation/InterrogationDefsOf.cs index 0c52ca76..59d71c2c 100644 --- a/Source/Core/Interrogation/InterrogationDefsOf.cs +++ b/Source/Core/Interrogation/InterrogationDefsOf.cs @@ -28,5 +28,11 @@ public static class InterrogationDefsOf public static InteractionDef PL_InterrogateInteraction; [MayRequireIdeology] public static InteractionDef PL_BeIntrrogatedInteraction; + + public static TraitDef Brawler; + public static TraitDef Masochist; + public static TraitDef TooSmart; + public static TraitDef Nerves; + public static TraitDef Tough; } } diff --git a/Source/Core/Interrogation/Ritual/RitualOutcomeEffectWorker_Interrogation.cs b/Source/Core/Interrogation/Ritual/RitualOutcomeEffectWorker_Interrogation.cs index 46ce8897..4e69a8f4 100644 --- a/Source/Core/Interrogation/Ritual/RitualOutcomeEffectWorker_Interrogation.cs +++ b/Source/Core/Interrogation/Ritual/RitualOutcomeEffectWorker_Interrogation.cs @@ -127,13 +127,13 @@ private float GoBrutal(Pawn warden, Pawn prisoner) { actualChance += 0.1f; } - if (HasTrait(prisoner, TraitDefOf.Tough)) + if (HasTrait(prisoner, InterrogationDefsOf.Tough)) { actualChance -= 0.3f; } - if (HasTrait(prisoner, TraitDefOf.Nerves)) + if (HasTrait(prisoner, InterrogationDefsOf.Nerves)) { - Trait nerves = GetTrait(prisoner, TraitDefOf.Nerves); + Trait nerves = GetTrait(prisoner, InterrogationDefsOf.Nerves); actualChance -= nerves.Degree * 0.1f; } if (HasTrait(prisoner, TraitDefOf.Wimp)) @@ -141,7 +141,7 @@ private float GoBrutal(Pawn warden, Pawn prisoner) //Wimp can't handle beating actualChance = 1f; } - if (HasTrait(prisoner, TraitDefOf.Masochist)) + if (HasTrait(prisoner, InterrogationDefsOf.Masochist)) { //Prisoner likes pain... actualChance = 0f; @@ -161,13 +161,13 @@ private float GoEasy(Pawn warden, Pawn prisoner) { actualChance -= 0.1f; } - if (HasTrait(warden, TraitDefOf.TooSmart)) + if (HasTrait(warden, InterrogationDefsOf.TooSmart)) { actualChance -= 0.1f; } - if (HasTrait(prisoner, TraitDefOf.Nerves)) + if (HasTrait(prisoner, InterrogationDefsOf.Nerves)) { - Trait nerves = GetTrait(prisoner, TraitDefOf.Nerves); + Trait nerves = GetTrait(prisoner, InterrogationDefsOf.Nerves); actualChance -= nerves.Degree * 0.1f; } actualChance += prisoner.relations.OpinionOf(warden) * 0.002f; diff --git a/Source/Core/MainButton_Window/ColumnWorker_Interaction.cs b/Source/Core/MainButton_Window/ColumnWorker_Interaction.cs index 2917afc8..c89421ca 100644 --- a/Source/Core/MainButton_Window/ColumnWorker_Interaction.cs +++ b/Source/Core/MainButton_Window/ColumnWorker_Interaction.cs @@ -11,60 +11,67 @@ namespace PrisonLabor.Core.MainButton_Window { - public class ColumnWorker_Interaction : PawnColumnWorker + public class ColumnWorker_Interaction : PawnColumnWorker + { + public override void DoCell(Rect rect, Pawn pawn, PawnTable table) { - public override void DoCell(Rect rect, Pawn pawn, PawnTable table) - { - if (pawn.guest != null) - { - Widgets.Dropdown(rect, pawn, (Pawn p) => p.guest.interactionMode, Button_GenerateMenu, pawn.guest.interactionMode.LabelCap.Truncate(rect.width), null, pawn.guest.interactionMode.LabelCap, null, null, paintable: true); - } - } - - private IEnumerable> Button_GenerateMenu(Pawn pawn) - { - foreach (PrisonerInteractionModeDef intertaction in DefDatabase.AllDefs - .Where(def => pawn.CanUsePrisonerInteraction(def)) - .OrderBy((PrisonerInteractionModeDef pim) => pim.listOrder)) - { - yield return new Widgets.DropdownMenuElement - { - option = new FloatMenuOption(intertaction.LabelCap, delegate - { - SetInteractionMode(pawn, intertaction); - }), - payload = intertaction - }; - } - } - public void SetInteractionMode(Pawn pawn, PrisonerInteractionModeDef intertaction) - { - pawn.guest.interactionMode = intertaction; - if (intertaction == PrisonerInteractionModeDefOf.Convert || intertaction == PL_DefOf.PrisonLabor_workAndConvertOption) - { - pawn.guest.ideoForConversion = Faction.OfPlayer.ideos.PrimaryIdeo; - } - } + if (pawn.guest != null) + { + Widgets.Dropdown(rect, pawn, (Pawn p) => p.guest.ExclusiveInteractionMode, Button_GenerateMenu, pawn.guest.ExclusiveInteractionMode.LabelCap.Truncate(rect.width), null, pawn.guest.ExclusiveInteractionMode.LabelCap, null, null, paintable: true); + } + } - public override int GetMinWidth(PawnTable table) + private IEnumerable> Button_GenerateMenu(Pawn pawn) + { + foreach (PrisonerInteractionModeDef intertaction in DefDatabase.AllDefs + .Where(def => pawn.CanUsePrisonerInteraction(def) && !def.isNonExclusiveInteraction) + .OrderBy((PrisonerInteractionModeDef pim) => pim.listOrder)) + { + yield return new Widgets.DropdownMenuElement { - return Mathf.Max(base.GetMinWidth(table), Mathf.CeilToInt(194f)); - } + option = new FloatMenuOption(intertaction.LabelCap, delegate + { + SetInteractionMode(pawn, intertaction); + }), + payload = intertaction + }; + } + } + public void SetInteractionMode(Pawn pawn, PrisonerInteractionModeDef intertaction) + { + pawn.guest.SetExclusiveInteraction(intertaction); + if (intertaction == PrisonerInteractionModeDefOf.Enslave && pawn.MapHeld != null && !PrisonLaborUtility.ColonyHasAnyWardenCapableOfEnslavement(pawn.MapHeld)) + { + Messages.Message("MessageNoWardenCapableOfEnslavement".Translate(), pawn, MessageTypeDefOf.CautionInput, historical: false); + } + if (intertaction == PrisonerInteractionModeDefOf.Convert && pawn.guest.ideoForConversion == null) + { + pawn.guest.ideoForConversion = Faction.OfPlayer.ideos.PrimaryIdeo; + } + if (intertaction == PrisonerInteractionModeDefOf.Execution && pawn.MapHeld != null && !PrisonLaborUtility.ColonyHasAnyWardenCapableOfViolence(pawn.MapHeld)) + { + Messages.Message("MessageCantDoExecutionBecauseNoWardenCapableOfViolence".Translate(), pawn, MessageTypeDefOf.CautionInput, historical: false); + } + } - public override int GetOptimalWidth(PawnTable table) - { - return Mathf.Clamp(Mathf.CeilToInt(251f), GetMinWidth(table), GetMaxWidth(table)); - } + public override int GetMinWidth(PawnTable table) + { + return Mathf.Max(base.GetMinWidth(table), Mathf.CeilToInt(194f)); + } - public override int GetMinHeaderHeight(PawnTable table) - { - return Mathf.Max(base.GetMinHeaderHeight(table), 65); - } + public override int GetOptimalWidth(PawnTable table) + { + return Mathf.Clamp(Mathf.CeilToInt(251f), GetMinWidth(table), GetMaxWidth(table)); + } - public override int Compare(Pawn a, Pawn b) - { + public override int GetMinHeaderHeight(PawnTable table) + { + return Mathf.Max(base.GetMinHeaderHeight(table), 65); + } - return a.guest.interactionMode.listOrder.CompareTo(b.guest.interactionMode.listOrder); - } + public override int Compare(Pawn a, Pawn b) + { + return a.guest.ExclusiveInteractionMode.listOrder.CompareTo(b.guest.ExclusiveInteractionMode.listOrder); } + } } diff --git a/Source/Core/MainButton_Window/ColumnWorker_IsWorking.cs b/Source/Core/MainButton_Window/ColumnWorker_IsWorking.cs new file mode 100644 index 00000000..5dd1b339 --- /dev/null +++ b/Source/Core/MainButton_Window/ColumnWorker_IsWorking.cs @@ -0,0 +1,44 @@ +using PrisonLabor.Constants; +using PrisonLabor.Core.Components; +using PrisonLabor.Core.Other; +using PrisonLabor.Core.Trackers; +using RimWorld; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace PrisonLabor.Core.MainButton_Window +{ + public class ColumnWorker_IsWorking : PawnColumnWorker_Checkbox + { + protected override bool GetValue(Pawn pawn) + { + if (pawn == null) + { + DebugLogger.debug("Null pawn in ColumnWorker_IsWorking:GetValue"); + return true; + } + + return pawn.guest.IsInteractionEnabled(PL_DefOf.PrisonLabor_workOption); + } + + protected override void SetValue(Pawn pawn, bool value, PawnTable table) + { + if (pawn == null) + { + DebugLogger.debug("Null pawn in ColumnWorker_IsWorking:SetValue"); + return; + } + pawn.guest.ToggleNonExclusiveInteraction(PL_DefOf.PrisonLabor_workOption, value); + table?.SetDirty(); + } + protected override bool HasCheckbox(Pawn pawn) + { + return pawn.IsPrisonerOfColony; + } + } +} + diff --git a/Source/Core/Meta/Prefs.cs b/Source/Core/Meta/Prefs.cs index 34b6920a..c934d9b7 100644 --- a/Source/Core/Meta/Prefs.cs +++ b/Source/Core/Meta/Prefs.cs @@ -187,6 +187,19 @@ public static bool MechsWorkInLaborZone } } + public static bool EnableWorkByDefault + { + get + { + return data.enable_work_by_default; + } + set + { + data.enable_work_by_default = value; + Apply(); + } + } + public static void Init() { var flag = !new FileInfo(prefsFilePath).Exists; diff --git a/Source/Core/Meta/PrefsData.cs b/Source/Core/Meta/PrefsData.cs index 66348e76..a9c5e001 100644 --- a/Source/Core/Meta/PrefsData.cs +++ b/Source/Core/Meta/PrefsData.cs @@ -17,6 +17,7 @@ public class PrisonLaborPrefsData public bool enable_full_heal_rest = true; public bool enable_debug_logging = false; public bool mechs_work_in_labor_zone = false; + public bool enable_work_by_default = true; public Version last_version = Version.v0_0; public bool show_news = true; diff --git a/Source/Core/Meta/Version.cs b/Source/Core/Meta/Version.cs index e724939f..cce46434 100644 --- a/Source/Core/Meta/Version.cs +++ b/Source/Core/Meta/Version.cs @@ -89,6 +89,7 @@ public enum Version v1_4_6, v1_4_7, v1_4_8, - v1_4_9 + v1_4_9, + v1_5_0 } } diff --git a/Source/Core/Meta/VersionUtility.cs b/Source/Core/Meta/VersionUtility.cs index fb655623..0e31cb37 100644 --- a/Source/Core/Meta/VersionUtility.cs +++ b/Source/Core/Meta/VersionUtility.cs @@ -5,8 +5,8 @@ namespace PrisonLabor.Core.Meta { public class VersionUtility { - public const Version versionNumber = Version.v1_4_9; - public const string versionString = "1.4.9"; + public const Version versionNumber = Version.v1_5_0; + public const string versionString = "1.5.0"; public static Version VersionOfSaveFile { get; set; } diff --git a/Source/Core/Other/CleanPrisonersStatus.cs b/Source/Core/Other/CleanPrisonersStatus.cs index d6febf01..fb1b47c9 100644 --- a/Source/Core/Other/CleanPrisonersStatus.cs +++ b/Source/Core/Other/CleanPrisonersStatus.cs @@ -1,4 +1,5 @@ -using PrisonLabor.Constants; +using HarmonyLib; +using PrisonLabor.Constants; using RimWorld; using System; using System.Collections.Generic; @@ -15,8 +16,8 @@ public static class CleanPrisonersStatus static public void Clean(Pawn prisoner) { prisoner.workSettings = new Pawn_WorkSettings(prisoner); - CleanHediffs(prisoner); - prisoner.playerSettings.AreaRestriction = null; + CleanHediffs(prisoner); + prisoner.playerSettings.AreaRestrictionInPawnCurrentMap = null; if (prisoner.drugs != null) { prisoner.drugs.CurrentPolicy = Current.Game.drugPolicyDatabase.DefaultDrugPolicy(); @@ -29,7 +30,7 @@ static public void Clean(Pawn prisoner) { if (prisoner.guest != null) { - prisoner.guest.interactionMode = PrisonerInteractionModeDefOf.NoInteraction; + prisoner.guest.SetNoInteraction(); } Bill bill = prisoner.BillStack?.Bills?.FirstOrDefault((Bill x) => x.recipe == RecipeDefOf.ExtractHemogenPack); if (bill != null) diff --git a/Source/Core/PrisonLaborUtility.cs b/Source/Core/PrisonLaborUtility.cs index 93b83eca..fe872067 100644 --- a/Source/Core/PrisonLaborUtility.cs +++ b/Source/Core/PrisonLaborUtility.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using HarmonyLib; using PrisonLabor.Constants; using PrisonLabor.Core.LaborArea; using PrisonLabor.Core.LaborWorkSettings; @@ -12,45 +13,12 @@ namespace PrisonLabor.Core { public static class PrisonLaborUtility { - private static readonly List workOptions = new List { - PL_DefOf.PrisonLabor_workOption, PL_DefOf.PrisonLabor_workAndRecruitOption , PL_DefOf.PrisonLabor_workAndConvertOption, - PL_DefOf.PrisonLabor_workAndEnslaveOption, PL_DefOf.PrisonLabor_workAndBloodfeedOption, PL_DefOf.PrisonLabor_workAndHemogenFarmOption - }; - + private static readonly Traverse IsSutiableMethod = Traverse.Create().Method("IsStudiable", new[] { typeof(Pawn) }); public static bool LaborEnabled(this Pawn pawn) { - return pawn.IsPrisoner && workOptions.Contains(pawn.guest.interactionMode); - } - - public static bool RecruitInLaborEnabled(Pawn pawn) - { - if (pawn.guest.interactionMode == PL_DefOf.PrisonLabor_workAndRecruitOption && pawn.guest.ScheduledForInteraction) - { - return true; - } - - return false; - } - - public static bool ConvertInLaborEnabled(Pawn doer, Pawn prisoner) - { - if (prisoner.guest.interactionMode == PL_DefOf.PrisonLabor_workAndConvertOption && prisoner.guest.ScheduledForInteraction - && prisoner.Ideo != doer.Ideo && doer.Ideo == prisoner.guest.ideoForConversion) - { - return true; - } - return false; + return pawn.IsPrisoner && pawn.guest.IsInteractionEnabled(PL_DefOf.PrisonLabor_workOption); } - public static bool EnslaveInLaborEnabled(Pawn doer, Pawn prisoner) - { - if (prisoner.guest.interactionMode == PL_DefOf.PrisonLabor_workAndEnslaveOption && prisoner.guest.ScheduledForInteraction - && new HistoryEvent(HistoryEventDefOf.EnslavedPrisoner, doer.Named(HistoryEventArgsNames.Doer)).Notify_PawnAboutToDo_Job()) - { - return true; - } - return false; - } public static bool WorkTime(Pawn pawn) { if (pawn.timetable == null) @@ -138,39 +106,57 @@ public static bool CanUsePrisonerInteraction(this Pawn prisoner, PrisonerInterac { return false; } + if (ModsConfig.AnomalyActive) + { + if (mode.hideIfNotStudiableAsPrisoner && !IsSutiableMethod.GetValue(prisoner)) + { + return false; + } + if (mode.hideIfGrayFleshNotAppeared && !Find.Anomaly.hasSeenGrayFlesh) + { + return false; + } + } return true; } - private static bool ColonyHasAnyBloodfeeder(Map map) + public static bool ColonyHasAnyBloodfeeder(Map map) { if (ModsConfig.BiotechActive) { - foreach (Pawn item in map.mapPawns.FreeColonistsSpawned) + foreach (Pawn item in map.mapPawns.FreeColonistsAndPrisonersSpawned) { if (item.IsBloodfeeder()) { return true; } } - foreach (Pawn item2 in map.mapPawns.PrisonersOfColony) - { - if (item2.IsBloodfeeder()) - { - return true; - } - } } return false; } - public static bool HemogenFarmInteractionMode(PrisonerInteractionModeDef interaction) + public static bool ColonyHasAnyWardenCapableOfViolence(Map map) { - return interaction == PrisonerInteractionModeDefOf.HemogenFarm || interaction == PL_DefOf.PrisonLabor_workAndHemogenFarmOption; + foreach (Pawn item in map.mapPawns.FreeColonistsSpawned) + { + if (item.workSettings.WorkIsActive(WorkTypeDefOf.Warden) && !item.WorkTagIsDisabled(WorkTags.Violent)) + { + return true; + } + } + return false; } - public static bool BloodFeedInteractionMode(PrisonerInteractionModeDef interaction) + public static bool ColonyHasAnyWardenCapableOfEnslavement(Map map) { - return interaction == PrisonerInteractionModeDefOf.Bloodfeed || interaction == PL_DefOf.PrisonLabor_workAndBloodfeedOption; + foreach (Pawn item in map.mapPawns.FreeColonistsSpawned) + { + if (item.workSettings.WorkIsActive(WorkTypeDefOf.Warden) && new HistoryEvent(HistoryEventDefOf.EnslavedPrisoner, item.Named(HistoryEventArgsNames.Doer)).DoerWillingToDo()) + { + return true; + } + } + return false; } } } \ No newline at end of file diff --git a/Source/Core/Settings/SettingsMenu.cs b/Source/Core/Settings/SettingsMenu.cs index 18ac75b3..3075a732 100644 --- a/Source/Core/Settings/SettingsMenu.cs +++ b/Source/Core/Settings/SettingsMenu.cs @@ -3,6 +3,7 @@ using PrisonLabor.Core.Windows; using RimWorld; using System.Collections.Generic; +using System.Linq; using UnityEngine; using Verse; @@ -24,6 +25,7 @@ internal class SettingsMenu : Mod private static int defaultInteractionMode; private static bool enableDebbuging; private static bool mechsWorkInLaborZone; + private static bool workEnabledByDefault; private static List interactionModeList; @@ -44,8 +46,10 @@ public static void Init() enableFullHealRest = PrisonLaborPrefs.EnableFullHealRest; enableDebbuging = PrisonLaborPrefs.DebugLogs; mechsWorkInLaborZone = PrisonLaborPrefs.MechsWorkInLaborZone; + workEnabledByDefault = PrisonLaborPrefs.EnableWorkByDefault; - interactionModeList = new List(DefDatabase.AllDefs); + + interactionModeList = new List(DefDatabase.AllDefs.Where(interaction => !interaction.isNonExclusiveInteraction)); defaultInteractionMode = interactionModeList.IndexOf(DefDatabase.GetNamed(PrisonLaborPrefs.DefaultInteractionMode)); if (defaultInteractionMode < 0 || defaultInteractionMode > interactionModeList.Count - 1) defaultInteractionMode = 0; @@ -68,6 +72,7 @@ public override void DoSettingsWindowContents(Rect inRect) if (listing_options.ButtonTextLabeled("PrisonLabor_DefaultInterMode".Translate(), interactionModeList[defaultInteractionMode].LabelCap)) defaultInteractionMode = defaultInteractionMode < interactionModeList.Count - 1 ? defaultInteractionMode + 1 : 0; + listing_options.CheckboxLabeled("PrisonLabor_EnableWorkByDefault".Translate(), ref workEnabledByDefault, "PrisonLabor_EnableWorkByDefaultDesc".Translate()); listing_options.GapLine(); @@ -189,6 +194,7 @@ public override void WriteSettings() PrisonLaborPrefs.DefaultInteractionMode = interactionModeList[defaultInteractionMode].defName; PrisonLaborPrefs.DebugLogs = enableDebbuging; PrisonLaborPrefs.MechsWorkInLaborZone = mechsWorkInLaborZone; + PrisonLaborPrefs.EnableWorkByDefault = workEnabledByDefault; PrisonLaborPrefs.Save(); Log.Message("Prison Labor settings saved"); } diff --git a/Source/HarmonyPatches/DevTools.cs b/Source/HarmonyPatches/DevTools.cs index 10aa939d..b81c71a1 100644 --- a/Source/HarmonyPatches/DevTools.cs +++ b/Source/HarmonyPatches/DevTools.cs @@ -1,4 +1,5 @@ using HarmonyLib; +using LudeonTK; using PrisonLabor.Core.Needs; using RimWorld; using System; diff --git a/Source/HarmonyPatches/Patches_Apparel/PrisonerRespectOutfits.cs b/Source/HarmonyPatches/Patches_Apparel/PrisonerRespectOutfits.cs index 24c2edb9..4915a39e 100644 --- a/Source/HarmonyPatches/Patches_Apparel/PrisonerRespectOutfits.cs +++ b/Source/HarmonyPatches/Patches_Apparel/PrisonerRespectOutfits.cs @@ -30,7 +30,7 @@ static Apparel Postfix_FindGarmentSatisfyingTitleRequirement(Apparel __result, P private static Apparel PrisonerWillRespectOutfit(Apparel apparel, Pawn prisoner) { - if (apparel != null && IsMotivatedPrisoner(prisoner) && prisoner.outfits != null && !prisoner.outfits.CurrentOutfit.filter.Allows(apparel.def)) + if (apparel != null && IsMotivatedPrisoner(prisoner) && prisoner.outfits != null && !prisoner.outfits.CurrentApparelPolicy.filter.Allows(apparel.def)) { return null; } diff --git a/Source/HarmonyPatches/Patches_BillAssignation/Patch_BillPrevention.cs b/Source/HarmonyPatches/Patches_BillAssignation/Patch_BillPrevention.cs index 42372a04..b2ec3b5b 100644 --- a/Source/HarmonyPatches/Patches_BillAssignation/Patch_BillPrevention.cs +++ b/Source/HarmonyPatches/Patches_BillAssignation/Patch_BillPrevention.cs @@ -13,7 +13,6 @@ namespace PrisonLabor.HarmonyPatches.Patches_BillAssignation { [HarmonyPatch(typeof(WorkGiver_DoBill))] [HarmonyPatch("StartOrResumeBillJob")] - [HarmonyPatch(new[] { typeof(Pawn), typeof(IBillGiver) })] internal class Patch_BillPrevention { private static IEnumerable Transpiler(ILGenerator gen, MethodBase mBase, diff --git a/Source/HarmonyPatches/Patches_Food/AddCustomFoodReservation.cs b/Source/HarmonyPatches/Patches_Food/AddCustomFoodReservation.cs index df6cc2e2..9cea3ba1 100644 --- a/Source/HarmonyPatches/Patches_Food/AddCustomFoodReservation.cs +++ b/Source/HarmonyPatches/Patches_Food/AddCustomFoodReservation.cs @@ -12,7 +12,7 @@ namespace PrisonLabor.HarmonyPatches.Patches_Food /// Adds check if food is already reserved before trying to bring it /// [HarmonyPatch(typeof(FoodUtility))] - [HarmonyPatch(nameof(FoodUtility.BestFoodSourceOnMap_NewTemp))] + [HarmonyPatch(nameof(FoodUtility.BestFoodSourceOnMap))] static class AddCustomFoodReservation { /* === Orignal code Look-up=== diff --git a/Source/HarmonyPatches/Patches_Food/Patch_EnableRespectingFoodPolicies.cs b/Source/HarmonyPatches/Patches_Food/Patch_EnableRespectingFoodPolicies.cs index f9f30072..f7bc5a6b 100644 --- a/Source/HarmonyPatches/Patches_Food/Patch_EnableRespectingFoodPolicies.cs +++ b/Source/HarmonyPatches/Patches_Food/Patch_EnableRespectingFoodPolicies.cs @@ -13,13 +13,13 @@ namespace PrisonLabor.HarmonyPatches.Patches_Food [HarmonyPatch("GetCurrentRespectedRestriction")] class Patch_EnableRespectingFoodPolicies { - static FoodRestriction Postfix(FoodRestriction __result, Pawn_FoodRestrictionTracker __instance, Pawn getter) + static FoodPolicy Postfix(FoodPolicy __result, Pawn_FoodRestrictionTracker __instance, Pawn getter) { if (__result == null) { if (__instance.pawn.IsPrisonerOfColony && __instance.pawn == getter) { - return __instance.CurrentFoodRestriction; + return __instance.CurrentFoodPolicy; } } return __result; diff --git a/Source/HarmonyPatches/Patches_GUI/GUI_Bill/Patch_RestrictBillToPrisoner.cs b/Source/HarmonyPatches/Patches_GUI/GUI_Bill/Patch_RestrictBillToPrisoner.cs index eb99dd75..ea6785a3 100644 --- a/Source/HarmonyPatches/Patches_GUI/GUI_Bill/Patch_RestrictBillToPrisoner.cs +++ b/Source/HarmonyPatches/Patches_GUI/GUI_Bill/Patch_RestrictBillToPrisoner.cs @@ -50,7 +50,7 @@ static IEnumerable Transpiler_DoWindowContent(IEnumerable Transpiler_DoWindowContent(IEnumerable - /// This patch is adding scroll bar to prisoner tab to ensure all interaction modes are visible - /// - [HarmonyPatch(typeof(ITab_Pawn_Visitor))] - [HarmonyPatch("FillTab")] - [HarmonyPatch(new Type[0])] - internal class Patch_AddScrollToPrisonerTab - { - private static IEnumerable Transpiler(ILGenerator gen, IEnumerable instr) - { - #region fragment>>GUI.BeginGroup(position); - OpCode[] opCodes1 = - { - OpCodes.Call, - OpCodes.Stloc_S, - OpCodes.Ldloc_S, - OpCodes.Call, - }; - String[] operands1 = - { - "UnityEngine.Rect ContractedBy(UnityEngine.Rect, Single)", - "UnityEngine.Rect (8)", - "UnityEngine.Rect (8)", - "Void BeginGroup(UnityEngine.Rect)", - }; - int step1 = 0; - #endregion - - #region fragment>>GUI.EndGroup(); - OpCode[] opCodes2 = - { - OpCodes.Constrained, - OpCodes.Callvirt, - OpCodes.Endfinally, - OpCodes.Call, - }; - String[] operands2 = - { - "System.Collections.Generic.List`1+Enumerator[RimWorld.PrisonerInteractionModeDef]", - "Void Dispose()", - "", - "Void EndGroup()", - }; - int step2 = 0; - #endregion - - #region fragment>>Rect position = rect6.ContractedBy(10f); - OpCode[] opCodes3 = - { - OpCodes.Ldc_R4, - OpCodes.Call, - OpCodes.Stloc_S, - OpCodes.Ldloc_S, - }; - String[] operands3 = - { - "10", - "UnityEngine.Rect ContractedBy(UnityEngine.Rect, Single)", - "UnityEngine.Rect (8)", - "UnityEngine.Rect (8)", - }; - int step3 = 0; - var rect = HPatcher.FindOperandAfter(opCodes3, operands3, instr); - #endregion - foreach (var ci in instr) - { - - // end scroll - if (HPatcher.IsFragment(opCodes2, operands2, ci, ref step2, "AddScrollToPrisonerTab2")) - { - var instruction = new CodeInstruction(OpCodes.Call, typeof(Patch_AddScrollToPrisonerTab).GetMethod(nameof(StopScrolling))); - instruction.labels.AddRange(ci.labels); - ci.labels.Clear(); - yield return instruction; - } - -/* // resize - if (HPatcher.IsFragment(opCodes3, operands3, ci, ref step3, "AddScrollToPrisonerTab3")) - { - - }*/ - - yield return ci; - - // begin scroll - if (HPatcher.IsFragment(opCodes1, operands1, ci, ref step1, "AddScrollToPrisonerTab1")) - { - yield return new CodeInstruction(OpCodes.Ldloc_S, rect); - yield return new CodeInstruction(OpCodes.Call, typeof(Patch_AddScrollToPrisonerTab).GetMethod(nameof(StartScrolling))); - yield return new CodeInstruction(OpCodes.Stloc_S, rect); - } - } - } - - public static Vector2 position; - public static Rect StartScrolling(Rect rect) - { - Rect viewRect = new Rect(0, 0, rect.width - 16, rect.height + 56); - Rect outRect = new Rect(0, 0, rect.width, rect.height); - Widgets.BeginScrollView(outRect, ref position, viewRect, true); - return viewRect; - } - - public static void StopScrolling() - { - Widgets.EndScrollView(); - } - } -} diff --git a/Source/HarmonyPatches/Patches_InteractionMode/BloodFeedInteractionPatches.cs b/Source/HarmonyPatches/Patches_InteractionMode/BloodFeedInteractionPatches.cs deleted file mode 100644 index 3ba84b3d..00000000 --- a/Source/HarmonyPatches/Patches_InteractionMode/BloodFeedInteractionPatches.cs +++ /dev/null @@ -1,60 +0,0 @@ -using HarmonyLib; -using PrisonLabor.Core; -using RimWorld; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection.Emit; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using Verse; - -namespace PrisonLabor.HarmonyPatches.Patches_InteractionMode -{ - [HarmonyPatch()] - class BloodFeedInteractionPatches - { - [HarmonyPatch(typeof(TargetingParameters), nameof(TargetingParameters.ForBloodfeeding))] - [HarmonyPostfix] - public static TargetingParameters TargetingParametersPostFix(TargetingParameters __result, Pawn pawn) - { - __result.validator = delegate (TargetInfo targ) - { - if (!(targ.Thing is Pawn pawn2)) - { - return false; - } - return (pawn2.IsPrisonerOfColony && pawn2.guest.PrisonerIsSecure && PrisonLaborUtility.BloodFeedInteractionMode(pawn2.guest.interactionMode)); - }; - - return __result; - } - - [HarmonyPatch(typeof(JobGiver_GetHemogen), "CanFeedOnPrisoner")] - [HarmonyTranspiler] - static IEnumerable GuestTrackerTickTranspiler(ILGenerator gen, MethodBase mBase, IEnumerable instructions) - { - OpCode[] opCodesToFind = - { - OpCodes.Ldfld, - OpCodes.Ldsfld, - OpCodes.Bne_Un_S - }; - string[] operandsToFind = - { - "RimWorld.PrisonerInteractionModeDef interactionMode", - "RimWorld.PrisonerInteractionModeDef Bloodfeed", - "System.Reflection.Emit.Label" - }; - var label = (Label)HPatcher.FindOperandAfter(opCodesToFind, operandsToFind, instructions); - CodeInstruction[] replacment = - { - new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(Pawn_GuestTracker), nameof(Pawn_GuestTracker.interactionMode))), - new CodeInstruction(OpCodes.Call, typeof(PrisonLaborUtility).GetMethod("BloodFeedInteractionMode")), - new CodeInstruction(OpCodes.Brfalse_S, label) - }; - return HPatcher.ReplaceFragment(opCodesToFind, operandsToFind, instructions, replacment, nameof(JobGiver_GetHemogen) + ": CanFeedOnPrisoner patch"); - } - } -} diff --git a/Source/HarmonyPatches/Patches_InteractionMode/HemogenFarmInteractionPatch.cs b/Source/HarmonyPatches/Patches_InteractionMode/HemogenFarmInteractionPatch.cs deleted file mode 100644 index 50532acc..00000000 --- a/Source/HarmonyPatches/Patches_InteractionMode/HemogenFarmInteractionPatch.cs +++ /dev/null @@ -1,73 +0,0 @@ -using HarmonyLib; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection.Emit; -using System.Reflection; -using System.Text; -using System.Threading.Tasks; -using RimWorld; -using PrisonLabor.Core; - -namespace PrisonLabor.HarmonyPatches.Patches_InteractionMode -{ - [HarmonyPatch()] - class HemogenFarmInteractionPatch - { - - [HarmonyPatch(typeof(Pawn_GuestTracker), "GuestTrackerTick")] - [HarmonyTranspiler] - static IEnumerable GuestTrackerTickTranspiler(ILGenerator gen, MethodBase mBase, IEnumerable instructions) - { - OpCode[] opCodesToFind = - { - OpCodes.Ldfld, - OpCodes.Ldsfld, - OpCodes.Bne_Un - }; - string[] operandsToFind = - { - "RimWorld.PrisonerInteractionModeDef interactionMode", - "RimWorld.PrisonerInteractionModeDef HemogenFarm", - "System.Reflection.Emit.Label" - }; - var label = (Label)HPatcher.FindOperandAfter(opCodesToFind, operandsToFind, instructions); - CodeInstruction[] replacment = - { - new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(Pawn_GuestTracker), nameof(Pawn_GuestTracker.interactionMode))), - new CodeInstruction(OpCodes.Call, typeof(PrisonLaborUtility).GetMethod("HemogenFarmInteractionMode")), - new CodeInstruction(OpCodes.Brfalse_S, label) - }; - return HPatcher.ReplaceFragment(opCodesToFind, operandsToFind, instructions, replacment, nameof(Pawn_GuestTracker) + ": GuestTrackerTick patch"); - } - - [HarmonyPatch(typeof(Alert_AwaitingMedicalOperation), "get_AwaitingMedicalOperation")] - [HarmonyTranspiler] - static IEnumerable Alert_AwaitingMedicalOperationTranspiler(ILGenerator gen, MethodBase mBase, IEnumerable instructions) - { - - OpCode[] opCodesToFind = - { - OpCodes.Ldfld, - OpCodes.Ldsfld, - OpCodes.Beq_S - }; - string[] operandsToFind = - { - "RimWorld.PrisonerInteractionModeDef interactionMode", - "RimWorld.PrisonerInteractionModeDef HemogenFarm", - "System.Reflection.Emit.Label" - }; - var label = (Label)HPatcher.FindOperandAfter(opCodesToFind, operandsToFind, instructions); - CodeInstruction[] replacment = - { - new CodeInstruction(OpCodes.Ldfld, AccessTools.Field(typeof(Pawn_GuestTracker), nameof(Pawn_GuestTracker.interactionMode))), - new CodeInstruction(OpCodes.Call, typeof(PrisonLaborUtility).GetMethod("HemogenFarmInteractionMode")), - new CodeInstruction(OpCodes.Brtrue_S, label) - }; - - return HPatcher.ReplaceFragment(opCodesToFind, operandsToFind, instructions, replacment, nameof(Alert_AwaitingMedicalOperation) + ": get_AwaitingMedicalOperation patch"); ; - } - - } -} diff --git a/Source/HarmonyPatches/Patches_InteractionMode/Patch_DefaultInteractionMode.cs b/Source/HarmonyPatches/Patches_InteractionMode/Patch_DefaultInteractionMode.cs index 84884d20..19e1f1f1 100644 --- a/Source/HarmonyPatches/Patches_InteractionMode/Patch_DefaultInteractionMode.cs +++ b/Source/HarmonyPatches/Patches_InteractionMode/Patch_DefaultInteractionMode.cs @@ -7,24 +7,28 @@ using Verse; using PrisonLabor.Core.Meta; using PrisonLabor.Constants; +using PrisonLabor.Core; namespace PrisonLabor.HarmonyPatches.Patches_InteractionMode { - [HarmonyPatch(typeof(Pawn_GuestTracker))] - [HarmonyPatch("SetGuestStatus")] - public class Patch_DefaultInteractionMode + [HarmonyPatch(typeof(Pawn_GuestTracker))] + [HarmonyPatch("SetGuestStatus")] + public class Patch_DefaultInteractionMode + { + private static void Postfix(Pawn_GuestTracker __instance, Faction newHost, GuestStatus guestStatus) { - private static void Postfix(Pawn_GuestTracker __instance, Faction newHost, GuestStatus guestStatus) + if (guestStatus == GuestStatus.Prisoner && newHost == Faction.OfPlayer) + { + __instance.ToggleNonExclusiveInteraction(PL_DefOf.PrisonLabor_workOption, PrisonLaborPrefs.EnableWorkByDefault); + Pawn prisoner = Traverse.Create(__instance).Field("pawn").GetValue(); + PrisonerInteractionModeDef defaultInteractionDef = DefDatabase.GetNamed(PrisonLaborPrefs.DefaultInteractionMode); + PrisonerInteractionModeDef modeToSet = prisoner.CanUsePrisonerInteraction(defaultInteractionDef) ? defaultInteractionDef : PrisonerInteractionModeDefOf.MaintainOnly; + __instance.SetExclusiveInteraction(modeToSet); + if (__instance.ExclusiveInteractionMode == PrisonerInteractionModeDefOf.Convert) { - if (guestStatus == GuestStatus.Prisoner && newHost == Faction.OfPlayer) - { - __instance.interactionMode = DefDatabase.GetNamed(PrisonLaborPrefs.DefaultInteractionMode); - if(__instance.interactionMode == PL_DefOf.PrisonLabor_workAndConvertOption - || __instance.interactionMode == PrisonerInteractionModeDefOf.Convert) - { - __instance.ideoForConversion = Faction.OfPlayer.ideos.PrimaryIdeo; - } - } + __instance.ideoForConversion = Faction.OfPlayer.ideos.PrimaryIdeo; } + } } + } } diff --git a/Source/HarmonyPatches/Patches_InteractionMode/Patch_VisitorTab_TabDraw.cs b/Source/HarmonyPatches/Patches_InteractionMode/Patch_VisitorTab_TabDraw.cs deleted file mode 100644 index 2ef6b201..00000000 --- a/Source/HarmonyPatches/Patches_InteractionMode/Patch_VisitorTab_TabDraw.cs +++ /dev/null @@ -1,104 +0,0 @@ -using HarmonyLib; -using PrisonLabor.Constants; -using RimWorld; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Reflection; -using System.Reflection.Emit; -using System.Text; -using System.Threading.Tasks; -using Verse; - -namespace PrisonLabor.HarmonyPatches.Patches_InteractionMode -{ - [HarmonyPatch(typeof(ITab_Pawn_Visitor))] - class Patch_VisitorTab_TabDraw - { - [HarmonyPatch("FillTab")] - [HarmonyTranspiler] - static IEnumerable FillTabTranspiler(ILGenerator gen, MethodBase mBase, IEnumerable instructions) - { - OpCode[] opCodesToFind = - { - OpCodes.Call, - OpCodes.Ldfld, - OpCodes.Ldfld, - OpCodes.Ldsfld, - OpCodes.Bne_Un - }; - string[] operandsToFind = - { - "Verse.Pawn get_SelPawn()", - "RimWorld.Pawn_GuestTracker guest", - "RimWorld.PrisonerInteractionModeDef interactionMode", - "RimWorld.PrisonerInteractionModeDef Convert", - "System.Reflection.Emit.Label" - }; - - OpCode[] opCodesToReplace = - { - OpCodes.Call, - OpCodes.Ldfld, - OpCodes.Ldfld, - OpCodes.Ldsfld, - OpCodes.Bne_Un - }; - string[] operandsToReplace = - { - "Verse.Pawn get_SelPawn()", - "RimWorld.Pawn_GuestTracker guest", - "RimWorld.PrisonerInteractionModeDef interactionMode", - "RimWorld.PrisonerInteractionModeDef Convert", - "System.Reflection.Emit.Label" - }; - - var label = (Label)HPatcher.FindOperandAfter(opCodesToFind, operandsToFind, instructions); - CodeInstruction[] replacment = - { - new CodeInstruction(OpCodes.Call, typeof(Patch_VisitorTab_TabDraw).GetMethod(nameof(ShouldDisplayConvertIco))), - new CodeInstruction(OpCodes.Brfalse, label) - }; - return HPatcher.ReplaceFragment(opCodesToReplace, operandsToReplace, instructions, replacment, nameof(ITab_Pawn_Visitor) + ": patch display ideo ico"); - } - - [HarmonyPatch("InteractionModeChanged")] - [HarmonyPostfix] - static void PostfixInteractionModeChanged(ITab_Pawn_Visitor __instance, PrisonerInteractionModeDef oldMode, PrisonerInteractionModeDef newMode) - { - Pawn p = Traverse.Create(__instance).Property("SelPawn").GetValue(); - if (newMode == PL_DefOf.PrisonLabor_workAndConvertOption && p.guest.ideoForConversion == null) - { - p.guest.ideoForConversion = Faction.OfPlayer.ideos.PrimaryIdeo; - } - - if (ModsConfig.BiotechActive) - { - Bill bill = p.BillStack?.Bills?.FirstOrDefault((Bill x) => x.recipe == RecipeDefOf.ExtractHemogenPack); - if (newMode == PL_DefOf.PrisonLabor_workAndHemogenFarmOption) - { - if (bill == null) - { - HealthCardUtility.CreateSurgeryBill(p, RecipeDefOf.ExtractHemogenPack, null); - } - } - else if (oldMode == PL_DefOf.PrisonLabor_workAndHemogenFarmOption && bill != null) - { - p.BillStack.Bills.Remove(bill); - } - } - - } - - public static bool ShouldDisplayConvertIco(ITab_Pawn_Visitor tab) - { - Pawn p = Traverse.Create(tab).Property("SelPawn").GetValue(); - return p.guest.interactionMode == PrisonerInteractionModeDefOf.Convert || p.guest.interactionMode == PL_DefOf.PrisonLabor_workAndConvertOption; - } - - public static bool IsConvert(PrisonerInteractionModeDef interaction) - { - return interaction == PrisonerInteractionModeDefOf.Convert || interaction == PL_DefOf.PrisonLabor_workAndConvertOption; - } - } -} diff --git a/Source/HarmonyPatches/Patches_Work/Patch_CarryToBuilding.cs b/Source/HarmonyPatches/Patches_Work/Patch_CarryToBuilding.cs index 83700353..49b89b40 100644 --- a/Source/HarmonyPatches/Patches_Work/Patch_CarryToBuilding.cs +++ b/Source/HarmonyPatches/Patches_Work/Patch_CarryToBuilding.cs @@ -6,20 +6,39 @@ using System.Text; using System.Threading.Tasks; using Verse; +using Verse.AI; namespace PrisonLabor.HarmonyPatches.Patches_Work { - [HarmonyPatch(typeof(WorkGiver_CarryToBuilding), "FindBuildingFor")] - public class Patch_CarryToBuilding + [HarmonyPatch(typeof(WorkGiver_CarryToBuilding))] + public class Patch_CarryToBuilding + { + [HarmonyPostfix] + [HarmonyPatch("HasJobOnThing")] + static bool HasJobOnThingPostfix(bool __result, Pawn pawn, Thing t, bool forced) { - static Building Postfix(Building __result, Pawn pawn, Pawn traveller, bool forced) - { - if (traveller.IsPrisonerOfColony && pawn.IsPrisonerOfColony && traveller == pawn) - { - return null; - } - return __result; - } + if (shouldChangeReturnValue(__result, pawn, t)) + { + return false; + } + return __result; } + + [HarmonyPostfix] + [HarmonyPatch("JobOnThing")] + static Job JobOnThingPostfix(Job __result, Pawn pawn, Thing t, bool forced) + { + if (shouldChangeReturnValue(__result != null, pawn, t)) + { + return null; + } + return __result; + } + + private static bool shouldChangeReturnValue(bool result, Pawn pawn, Thing t) + { + return result && pawn.IsPrisonerOfColony && t is Building_Enterable building && building.SelectedPawn == pawn; + } + } } diff --git a/Source/HarmonyPatches/Patches_WorkSettings/Patch_TimetableFix.cs b/Source/HarmonyPatches/Patches_WorkSettings/Patch_TimetableFix.cs index 3228a668..6b5d7458 100644 --- a/Source/HarmonyPatches/Patches_WorkSettings/Patch_TimetableFix.cs +++ b/Source/HarmonyPatches/Patches_WorkSettings/Patch_TimetableFix.cs @@ -9,44 +9,18 @@ namespace PrisonLabor.HarmonyPatches.Patches_WorkSettings { - [HarmonyPatch(typeof(Pawn_TimetableTracker))] - [HarmonyPatch("get_CurrentAssignment")] - internal class Patch_TimetableFix + [HarmonyPatch(typeof(Pawn_TimetableTracker))] + [HarmonyPatch("get_CurrentAssignment")] + internal class Patch_TimetableFix + { + static TimeAssignmentDef Postfix(TimeAssignmentDef __result, Pawn_TimetableTracker __instance) { - private static IEnumerable Transpiler(ILGenerator gen, IEnumerable instr) - { - var pawn = HPatcher.FindOperandAfter(new[] { OpCodes.Ldfld }, new[] { "Verse.Pawn pawn" }, instr); - var label = HPatcher.FindOperandAfter(new[] { OpCodes.Brtrue_S }, new[] { "System.Reflection.Emit.Label" }, instr); - - // if (!pawn.IsColonist) - OpCode[] opCodes = - { - OpCodes.Ldarg_0, - OpCodes.Ldfld, - OpCodes.Callvirt, - OpCodes.Brtrue_S, - }; - string[] operands = - { - "", - "Verse.Pawn pawn", - "Boolean get_IsColonist()", - "System.Reflection.Emit.Label", - }; - int step = 0; - - foreach (var ci in instr) - { - yield return ci; - - if(HPatcher.IsFragment(opCodes, operands, ci, ref step, "Patch_TimetableFix")) - { - yield return new CodeInstruction(OpCodes.Ldarg_0); - yield return new CodeInstruction(OpCodes.Ldfld, pawn); - yield return new CodeInstruction(OpCodes.Callvirt, typeof(Pawn).GetMethod("get_IsPrisonerOfColony")); - yield return new CodeInstruction(OpCodes.Brtrue_S, label); - } - } - } + Pawn pawn = Traverse.Create(__instance).Field("pawn").GetValue(); + if (pawn.IsPrisonerOfColony) + { + return __instance.times[GenLocalDate.HourOfDay(pawn)]; + } + return __result; } + } } diff --git a/Source/Organizer/NewsFeed.xml b/Source/Organizer/NewsFeed.xml index 9264a7b6..f879e3a3 100644 --- a/Source/Organizer/NewsFeed.xml +++ b/Source/Organizer/NewsFeed.xml @@ -4,6 +4,18 @@ + + Prison Labor v1.5.0 + + [-] Update for Rimworld 1.5 + [-] Almost all of mod's prisoner interactions were removed + [-] Mod option to enable "Force to work" interaction by default on imprison + [-] May not be compatible with save from 1.4 + [-] Future update will be only for Rimworld 1.5+ version + [gap] + Lots of code was removed/change during migration to 1.5. If bug appear, please share the whole game log! + + Prison Labor v1.4.9 diff --git a/Source/PrisonLabor.csproj b/Source/PrisonLabor.csproj index 8fefef98..f76ed053 100644 --- a/Source/PrisonLabor.csproj +++ b/Source/PrisonLabor.csproj @@ -19,7 +19,7 @@ false none false - ..\1.4\Assemblies\ + ..\1.5\Assemblies\ DEBUG;TRACE prompt 4 @@ -35,13 +35,12 @@ false - - packages\Lib.Harmony.2.2.2\lib\net472\0Harmony.dll + + packages\Lib.Harmony.2.3.3\lib\net472\0Harmony.dll False - - packages\RimWorld.MultiplayerAPI.0.3.0\lib\net472\0MultiplayerAPI.dll - False + + packages\RimWorld.MultiplayerAPI.0.5.0\lib\net472\0MultiplayerAPI.dll False @@ -88,7 +87,6 @@ - @@ -119,6 +117,7 @@ + @@ -176,10 +175,7 @@ - - - @@ -190,7 +186,6 @@ - @@ -267,49 +262,49 @@ - + Patches\AddPrisonerComp.xml - + Patches\Designators.xml - + Patches\SetJailorJobsPatch.xml - + Defs\ConceptDef.xml - + Defs\Hediffs.xml - + Defs\Incidents.xml - + Defs\JobDef.xml - + Defs\MainButton.xml - + Defs\Needs.xml - + Defs\PrisonerInteractionModeDef.xml - + Defs\PrisonerJoyGivers.xml - + Defs\ThinkTreeDef.xml - + Defs\ThoughtsDef.xml - + Defs\WorkGiverDef.xml - + Defs\WorkTypes.xml @@ -319,12 +314,6 @@ Organizer\changelog.txt - - Ideology\Defs\PrisonersInteractionMode.xml - - - Ideology\Patches\JailorForSlavesPatch.xml - Language\Keys.xml Designer diff --git a/Source/packages.config b/Source/packages.config index be74a19b..a40d0a13 100644 --- a/Source/packages.config +++ b/Source/packages.config @@ -1,6 +1,6 @@  - + - + \ No newline at end of file diff --git a/changelog.txt b/changelog.txt index 538bdd7e..42289d2e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,4 +1,10 @@ Changelog: +1.5.0 +- Update for Rimworld 1.5 +- Almost all of mod's prisoner interactions were removed +- Mod option to enable "Force to work" interaction by default on imprison +- May not be compatible with save from 1.4 +- Future update will be only for Rimworld 1.5+ version 1.4.9 - Unfortunately interrogation requires Ideology DLC - Interrogation Chair should load with Ideology DLC. If already placed in your game, one time error may occur.