public static Thing FindTarget(Pawn pawn) { List <Pawn> allPawns = pawn.Map.mapPawns.AllPawnsSpawned; if (allPawns == null || !allPawns.Any()) { return(null); } if (BetterInfestationsMod.settings == null) { return(null); } List <Thing> targets = new List <Thing>(); foreach (Pawn target in allPawns) { if (!target.DestroyedOrNull() && !target.Downed) { if (target.Faction == null || (target.Faction != null && target.Faction != pawn.Faction)) { bool recentAttack = target.mindState != null && target.mindState.lastAttackedTarget == pawn && target.mindState.lastAttackTargetTick <= Find.TickManager.TicksGame && target.mindState.lastAttackTargetTick > Find.TickManager.TicksGame - ticksInAttackMode; bool withinHiveAndInVisual = JobGiver_InsectGather.WithinHive(pawn, target as Thing, false) && GenSight.LineOfSight(pawn.Position, target.Position, pawn.Map, true, null, 0, 0); if (recentAttack || withinHiveAndInVisual) { if (!BetterInfestationsMod.settings.disabledDefList.Contains(target.def.defName)) { targets.Add(target as Thing); } } } } } return(JobGiver_InsectGather.GetClosest(pawn, targets)); }
public static Thing FindTarget(Pawn pawn) { List<Pawn> allPawns = pawn.Map.mapPawns.AllPawnsSpawned; if (allPawns == null || !allPawns.Any()) { return null; } if (BetterInfestationsMod.settings == null) { return null; } List<Thing> targetList = new List<Thing>(); foreach (Pawn target in allPawns) { if (target.DestroyedOrNull()) { continue; } if (target.Faction != null && target.Faction == pawn.Faction) { continue; } if (target.Downed && JobGiver_InsectGather.WithinHive(pawn, target, true)) { continue; } if (!BetterInfestationsMod.settings.disabledDefList.Contains(target.def.defName)) { targetList.Add(target as Thing); } } return JobGiver_InsectGather.GetClosest(pawn, targetList); }
public static Thing FindTarget(Pawn pawn) { List <Thing> allThings = pawn.Map.listerThings.ThingsOfDef(ThingDefOf.InsectJelly); if (allThings == null || !allThings.Any()) { return(null); } List <Thing> targetList = new List <Thing>(); foreach (Thing thing in allThings) { if (JobGiver_InsectGather.WithinHive(pawn, thing, false)) { targetList.Add(thing); } } return(JobGiver_InsectGather.GetClosest(pawn, targetList)); }