private bool TargetDrafted(TM_AutocastCondition con, Pawn p) { if (p.drafter != null && p.Drafted) { return(con.invert ? !p.Drafted : p.Drafted); } return(false); }
private bool AlliesInRange(TM_AutocastCondition con, Pawn caster, IntVec3 cell) { List <Pawn> allies = TM_Calc.FindPawnsNearTarget(caster, (int)con.valueB, cell, false); if (allies != null) { allies.Add(caster); return(con.invert ? allies.Count <= con.valueA : allies.Count > con.valueA); } return(false); }
private bool EnemiesInRange(TM_AutocastCondition con, Pawn caster, IntVec3 cell) { List <Pawn> enemies = TM_Calc.FindPawnsNearTarget(caster, (int)con.valueB, cell, true); if (enemies != null) { //Log.Message(enemies.Count + " found in range of " + cell); return(con.invert ? enemies.Count <= con.valueA : enemies.Count > con.valueA); } return(false); }
//Advanced condition cases private bool DamageTaken(TM_AutocastCondition con, Thing t) { if (t is Pawn) { Pawn p = t as Pawn; if (p != null && p.health != null && p.health.hediffSet != null) { //Log.Message("pawn injured? " + TM_Calc.IsPawnInjured(p, con.valueA) + " invert is " + con.invert); return(con.invert ? !TM_Calc.IsPawnInjured(p, con.valueA) : TM_Calc.IsPawnInjured(p, con.valueA)); } } return(false); }
private bool HasNeed(TM_AutocastCondition con, Pawn p) { if (p != null && p.needs != null) { bool hasAnyNeed = false; foreach (Need n in p.needs.AllNeeds) { if (n != null && con.needDefs.Contains(n.def) && n.CurLevel > con.valueA) { hasAnyNeed = true; } } return(con.invert ? !hasAnyNeed : hasAnyNeed); } return(false); }
private bool HasHediff(TM_AutocastCondition con, Pawn p) { if (p != null && p.health != null && p.health.hediffSet != null) { bool hasAnyHediff = false; foreach (HediffDef hdd in con.hediffDefs) { Hediff hd = p.health.hediffSet.GetFirstHediffOfDef(hdd); if (hd != null && hd.Severity > con.valueA) { hasAnyHediff = true; } } return(con.invert ? !hasAnyHediff : hasAnyHediff); } return(false); }