/// <summary> /// /// </summary> /// <param name="actorMap"></param> public void Tick(ActorMap actorMap) { if (!Dirty) { return; } var oldActors = currentActors; currentActors = Footprint.SelectMany(actorMap.GetActorsAt).ToList(); var entered = currentActors.Except(oldActors); var exited = oldActors.Except(currentActors); if (onActorEntered != null) { foreach (var a in entered) { onActorEntered(a); } } if (onActorExited != null) { foreach (var a in exited) { onActorExited(a); } } Dirty = false; }
public void Tick(ActorMap am) { if (!Dirty) { return; } var oldActors = currentActors; var delta = new WVec(rang, rang, WDist.Zero); currentActors = am.ActorsInBox(position - delta, position + delta).Where(a => (a.CenterPosition - position).HorizontalLengthSquared < rang.LengthSquared && (vRange.Length == 0 || (a.World.Map.DistanceAboveTerrain(a.CenterPosition).LengthSquared <= vRange.LengthSquared))).ToList(); var entered = currentActors.Except(oldActors); var exited = oldActors.Except(currentActors); if (onActorEntered != null) { foreach (var a in entered) { onActorEntered(a); } } if (onActorExited != null) { foreach (var a in exited) { onActorExited(a); } } }