public void Prioritize() { Search(); KnownItems.OrderBy(i => i.Location.DistanceTo(this.Location)) .ThenByDescending(i => i is Consumable); KnownEntities.OrderBy(e => e.Team == this.Team) // nonsentient npcs are only interested in enemies .ThenBy(e => e.Location.DistanceTo(this.Location)) // especially ones that are closest .ThenBy(e => e.CurrentHp.Value) // and have less hp remaining .ThenByDescending(e => hasLineOfSightTo(e)); // and are in line of sight var enemies = KnownEntities.Where(e => e.Team != Team); }
public void Prioritize() { if (KnownItems.Count > 0) { KnownItems.OrderBy(i => i.Location.DistanceTo(this.Location)) // order items by closest .ThenByDescending(i => i is Consumable); // give priority to consumables } if (KnownEntities.Count > 0) { KnownEntities.OrderBy(e => e.Location.DistanceTo(this.Location)) // order enemies by closest .ThenBy(e => e.CurrentHp.Value) // and those that have less hp remaining .ThenByDescending(e => hasLineOfSightTo(e)); // and are in line of sight } }