Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Source/1.6/Comps/Comp_Guard.cs
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ public void ReassureSurroundingPawns()
if (!cp.health.capacities.CapableOf(PawnCapacityDefOf.Sight))
continue;

cp.needs.mood.thoughts.memories.TryGainMemory(Utils.SawnGuard, null);
if (cp.needs?.mood?.thoughts?.memories != null)
cp.needs.mood.thoughts.memories.TryGainMemory(Utils.SawnGuard, null);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public static bool ShouldSearchAndKill(Pawn pawn)
}*/

if (comp == null || !comp.DeathSquadMode()
|| (pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Joy)
|| (pawn.timetable != null && pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Joy)
|| (pawn.health != null && pawn.health.summaryHealth.SummaryHealthPercent <= 0.55f && !GenAI.EnemyIsNear(pawn, 55f))
|| Utils.guardNeedFood(pawn)
|| Utils.guardNeedJoy(pawn)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ public override ThinkNode DeepCopy(bool resolve = true)

protected override bool Satisfied(Pawn pawn)
{
return pawn.needs.TryGetNeed(this.need).CurLevelPercentage < this.threshold;
if (pawn.needs == null) return false;
Need need = pawn.needs.TryGetNeed(this.need);
return need != null && need.CurLevelPercentage < this.threshold;
}

private NeedDef need;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public static bool ShouldGuardSpot(Pawn pawn)
Comp_Guard comp = pawn.TryGetComp<Comp_Guard>();

if (comp == null || !comp.GuardMode()
|| (pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Joy)
|| (pawn.timetable != null && pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Joy)
|| (pawn.health != null && pawn.health.summaryHealth != null && pawn.health.summaryHealth.SummaryHealthPercent <= 0.55f && !GenAI.EnemyIsNear(pawn, 55f))
|| ThinkNode_ConditionalShouldSearchAndKill.ShouldSearchAndKill(pawn)
|| Utils.guardNeedFood(pawn)
Expand Down
2 changes: 1 addition & 1 deletion Source/1.6/Patrol/ThinkNode_ConditionalShouldPatrol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static bool ShouldPatrol(Pawn pawn)
Comp_Guard comp = pawn.TryGetComp<Comp_Guard>();

if (comp == null || comp.affectedPatrol == ""
|| (pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Joy)
|| (pawn.timetable != null && pawn.timetable.CurrentAssignment == TimeAssignmentDefOf.Joy)
|| (pawn.health != null && pawn.health.summaryHealth.SummaryHealthPercent <= 0.55f && !GenAI.EnemyIsNear(pawn, 55f))
|| Utils.guardNeedFood(pawn)
|| Utils.guardNeedJoy(pawn)
Expand Down
7 changes: 7 additions & 0 deletions Source/1.6/Utils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,36 +42,43 @@ public static string TranslateTicksToTextIRLSeconds(int ticks)

public static bool guardNeedRest(Pawn pawn)
{
if (pawn.needs == null) return false;
return (pawn.needs.rest != null && pawn.needs.rest.CurLevelPercentage < Settings.minRestStopJob) || (ANDROIDLOADED && chjDroidNeedRest(pawn));
}

public static bool guardNeedFood(Pawn pawn)
{
if (pawn.needs == null) return false;
return (pawn.needs.food != null && pawn.needs.food.CurLevelPercentage < Settings.minFoodStopJob);
}

public static bool guardNeedJoy(Pawn pawn)
{
if (pawn.needs == null) return false;
return (pawn.needs.joy != null && pawn.needs.joy.CurLevelPercentage < Settings.minJoyStopJob);
}

public static bool guardNeedMood(Pawn pawn)
{
if (pawn.needs == null) return false;
return (pawn.needs.mood != null && pawn.needs.mood.CurLevelPercentage < Settings.minMoodStopJob);
}

public static bool guardNeedHygiene(Pawn pawn)
{
if (pawn.needs == null) return false;
return (needHygiene != null && pawn.needs.TryGetNeed(needHygiene) != null && pawn.needs.TryGetNeed(needHygiene).CurLevelPercentage < Settings.minHygieneStopJob);
}

public static bool guardNeedBladder(Pawn pawn)
{
if (pawn.needs == null) return false;
return (needBladder != null && pawn.needs.TryGetNeed(needBladder) != null && pawn.needs.TryGetNeed(needBladder).CurLevelPercentage < Settings.minBladderStopJob);
}

public static bool chjDroidNeedRest(Pawn pawn)
{
if (pawn.needs == null) return false;
foreach (Need need in pawn.needs.AllNeeds)
{
if (need != null && need.def.defName == "ChJEnergy")
Expand Down