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 ; }
private void _upgrade(ObjectiveAI ai) { if (null == pt_path) { return; } loc_path = _upgrade(HomeMap(ai), pt_path); pt_path = null; }
private Map?HomeMap(ObjectiveAI ai) { if (null == pt_path) { return(null); } if (0 < reasons.Count) { return(reasons.First().Key.Map); } return(ai.ControlledActor.Location.Map); }
public void Install(Map m, List <List <Point> >?src, ObjectiveAI ai) { if (null == src || 0 >= src.Count) { ForgetStaging(); return; } if (null != pt_path && m != HomeMap(ai)) { _upgrade(ai); } if (null != loc_path) // merging into location path { Install(_upgrade(m, src), ai); return; } if (null == pt_path) { pt_path = src; } else { int merge_ub = pt_path.Count; int ub = src.Count; int i = -1; while (++i < ub) { if (merge_ub <= i) { pt_path.Add(src[i]); } else { var step = pt_path[i]; foreach (var pt in src[i]) { if (!step.Contains(pt)) { step.Add(pt); } } } } } _merge_reasons(ai); _expired = false; }
public void Install(List <List <Location> >?src, ObjectiveAI ai) { if (null == src || 0 >= src.Count) { ForgetStaging(); return; } if (null != pt_path) { _upgrade(ai); } if (null == loc_path) { loc_path = src; } else { int merge_ub = loc_path.Count; int ub = src.Count; int i = -1; while (++i < ub) { if (merge_ub <= i) { loc_path.Add(src[i]); } else { var step = loc_path[i]; foreach (var pt in src[i]) { if (!step.Contains(pt)) { step.Add(pt); } } } } } _merge_reasons(ai); _expired = false; }
private void _merge_reasons(ObjectiveAI ai) { if (0 < stage_view.Count) { foreach (var x in stage_view) { reasons[x] = (int)What.VIEW; } stage_view.Clear(); } if (0 < stage_inventory.Count) { var items = ai.ItemMemory; if (null != items) { var need = ai.WhatDoINeedNow(); var want = ai.WhatDoIWantNow(); int code(in Location loc) { var think_is_there = items.WhatIsAt(loc); if (null != think_is_there) { // \todo duplicate cheating postfilters from ActorController::WhereIs foreach (var it in need) { if (think_is_there.Contains(it)) { return((int)What.INVENTORY - (int)it); } } foreach (var it in want) { if (think_is_there.Contains(it)) { return((int)What.INVENTORY - (int)it); } } } return(0); } int test; foreach (var x in stage_inventory) { if (0 != (test = code(in x))) { reasons[x] = test; } } } stage_inventory.Clear(); } if (0 < stage_generators.Count) { foreach (var x in stage_generators) { reasons[x.Location] = (int)What.GENERATOR_OFF; // will downgrade to real reason on update } stage_generators.Clear(); } }
[OnDeserialized] private void OnDeserialized(StreamingContext context) { oai = (m_Actor.Controller as ObjectiveAI) !; }