protected override bool GetValue(Pawn pawn) { CuffsTracker cuffsTracker = pawn.Map.GetComponent <CuffsTracker>(); if (cuffsTracker != null && cuffsTracker.legscuffTracker.TryGetValue(pawn, out bool checkboxValue)) { return(checkboxValue); } return(pawn.health.hediffSet.GetFirstHediffOfDef(PL_DefOf.PrisonLabor_RemovedLegscuffs, false) == null); }
public override bool ShouldSkip(Pawn pawn, bool forced = false) { CuffsTracker cuffsTracker = pawn.Map.GetComponent <CuffsTracker>(); if (cuffsTracker == null) { return(true); } return(cuffsTracker != null && cuffsTracker.legscuffTracker.Count == 0 && cuffsTracker.handscuffTracker.Count == 0); }
public void UpdateTracker(bool value, Pawn pawn, CuffsTracker cuffsTracker) { if (value == (pawn.health.hediffSet.GetFirstHediffOfDef(PL_DefOf.PrisonLabor_RemovedLegscuffs, false) == null)) { cuffsTracker.legscuffTracker.Remove(pawn); } else { cuffsTracker.legscuffTracker.Add(pawn, value); } }
protected override bool GetValue(Pawn pawn) { if (pawn == null) { DebugLogger.debug("Null pawn in ColumnWorker_HasLegcuffs:GetValue"); return(true); } CuffsTracker cuffsTracker = GetCuffsTracker(pawn); if (cuffsTracker != null && cuffsTracker.legscuffTracker.TryGetValue(pawn, out bool checkboxValue)) { return(checkboxValue); } return(pawn.health.hediffSet.GetFirstHediffOfDef(PL_DefOf.PrisonLabor_RemovedLegscuffs, false) == null); }
protected override void SetValue(Pawn pawn, bool value, PawnTable table) { if (pawn == null) { DebugLogger.debug("Null pawn in ColumnWorker_HasLegcuffs:SetValue"); return; } CuffsTracker cuffsTracker = GetCuffsTracker(pawn); if (cuffsTracker != null) { UpdateTracker(value, pawn, cuffsTracker); } table?.SetDirty(); }
protected override void SetValue(Pawn pawn, bool value, PawnTable table) { CuffsTracker cuffsTracker = pawn.Map.GetComponent <CuffsTracker>(); if (cuffsTracker != null) { if (value == (pawn.health.hediffSet.GetFirstHediffOfDef(PL_DefOf.PrisonLabor_RemovedLegscuffs, false) == null)) { cuffsTracker.legscuffTracker.Remove(pawn); } else { cuffsTracker.legscuffTracker.Add(pawn, value); } } table.SetDirty(); }
public override Job JobOnThing(Pawn pawn, Thing t, bool forced = false) { if (!ShouldTakeCareOfPrisoner(pawn, t)) { return(null); } if (pawn.IsFreeNonSlaveColonist) { CuffsTracker cuffsTracker = pawn.Map.GetComponent <CuffsTracker>(); if (cuffsTracker != null) { Pawn prisoner = t as Pawn; if (cuffsTracker.legscuffTracker.ContainsKey(prisoner)) { return(new Job(PL_DefOf.PrisonLabor_HandlePrisonersLegChain, prisoner)); } if (cuffsTracker.handscuffTracker.ContainsKey(prisoner)) { return(new Job(PL_DefOf.PrisonLabor_HandlePrisonersHandChain, prisoner)); } } } return(null); }
protected IEnumerable <Toil> 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); } CuffsTracker cuffsTracker = pawn.Map.GetComponent <CuffsTracker>(); if (cuffsTracker != null) { if (hediffDef == PL_DefOf.PrisonLabor_RemovedHandscuffs) { cuffsTracker.handscuffTracker.Remove(pawn); } else { cuffsTracker.legscuffTracker.Remove(pawn); } } 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); }