public override bool UrgentAction(out ActorAction?ret) { ret = null; Predicate <Point>?is_cleared = null; var threats_at = threats.ThreatWhere(m_Zone.m); // should have both of these null or non-null; other cases are formal completeness if (0 < threats_at.Count) { is_cleared = pt => !threats_at.Contains(pt); } var tourism_at = tourism.In(m_Zone.m); if (0 < tourism_at.Count) { is_cleared = is_cleared.And(pt => !tourism_at.Contains(pt)); } else if (null == is_cleared) { _isExpired = true; return(true); } m_Unverified.RemoveWhere(is_cleared); m_Unverified.Remove(m_Actor.Location.Position); if (0 >= m_Unverified.Count) { _isExpired = true; return(true); } if (0 < oai.InterruptLongActivity()) { return(false); } ret = Pathing(); return(true); }
public ClearZone(int t0, Actor who, ZoneLoc dest) : base(t0, who) { m_Zone = dest; threats = who.Threats // these two should agree on whether they're null or not #if DEBUG ?? throw new ArgumentNullException("who.Threats") #endif ; tourism = who.InterestingLocs #if DEBUG ?? throw new ArgumentNullException("who.InterestingLocs") #endif ; Func <Point, bool> ok = pt => m_Zone.Rect.Contains(pt); m_Unverified.UnionWith(threats.ThreatWhere(dest.m).Where(ok)); m_Unverified.UnionWith(tourism.In(dest.m).Where(ok)); #if OBSOLETE // the civilian case if (null == threats && null == sights_to_see) { m_Unverified.UnionWith(m_Zone.Rect.Where(pt => who.CanEnter(new Location(m_Zone.m, pt)))); // \todo? eliminate GC thrashing } #endif // nonserialized fields oai = (m_Actor.Controller as ObjectiveAI) #if DEBUG ?? throw new ArgumentNullException("who.Controller is ObjectiveAI") #endif ; }