Ejemplo n.º 1
0
            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;
            }
Ejemplo n.º 2
0
            public void Tick(ActorMap am)
            {
                if (!Dirty)
                {
                    return;
                }

                // PERF: Reuse collection to avoid allocations.
                oldActors.Clear();
                oldActors.UnionWith(currentActors);

                var delta = new WVec(range, range, WDist.Zero);

                currentActors.Clear();
                currentActors.UnionWith(
                    am.ActorsInBox(position - delta, position + delta)
                    .Where(a => (a.CenterPosition - position).HorizontalLengthSquared < range.LengthSquared &&
                           (vRange.Length == 0 || (a.World.Map.DistanceAboveTerrain(a.CenterPosition).LengthSquared <= vRange.LengthSquared))));

                if (onActorEntered != null)
                {
                    foreach (var a in currentActors)
                    {
                        if (!oldActors.Contains(a))
                        {
                            onActorEntered(a);
                        }
                    }
                }

                if (onActorExited != null)
                {
                    foreach (var a in oldActors)
                    {
                        if (!currentActors.Contains(a))
                        {
                            onActorExited(a);
                        }
                    }
                }

                Dirty = false;
            }
Ejemplo n.º 3
0
            public void Tick(ActorMap actorMap)
            {
                if (!Dirty)
                {
                    return;
                }

                // PERF: Reuse collection to avoid allocations.
                oldActors.Clear();
                oldActors.UnionWith(currentActors);

                currentActors.Clear();
                currentActors.UnionWith(Footprint.SelectMany(actorMap.GetActorsAt));

                if (onActorEntered != null)
                {
                    foreach (var a in currentActors)
                    {
                        if (!oldActors.Contains(a))
                        {
                            onActorEntered(a);
                        }
                    }
                }

                if (onActorExited != null)
                {
                    foreach (var a in oldActors)
                    {
                        if (!currentActors.Contains(a))
                        {
                            onActorExited(a);
                        }
                    }
                }

                Dirty = false;
            }
Ejemplo n.º 4
0
            public void Tick(ActorMap am)
            {
                if (!Dirty)
                {
                    return;
                }

                var oldActors = currentActors;
                var delta     = new WVec(range, range, WDist.Zero);

                currentActors = am.ActorsInBox(position - delta, position + delta)
                                .Where(a => (a.CenterPosition - position).HorizontalLengthSquared < range.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);
                    }
                }

                Dirty = false;
            }