Skip to content

EntityManagerZoned Class

Manages a set of entities. Adds a render step and only renders the entities that are in the parent IScreenSurface visible area.

C#
[DataContract]
public class EntityManagerZoned : EntityManager, IList<Entity>, ICollection<Entity>, IEnumerable<Entity>, IEnumerable, IDisposable, IComponent

Inheritance objectUpdateComponentEntityManager

Implements IList<Entity>, ICollection<Entity>, IEnumerable<Entity>, IEnumerable, IDisposable, IComponent

Creates a new manager to handle entity movement within zones.

C#
public EntityManagerZoned()

The zones in this manager.

C#
[DataMember(Name = "Zones")]
protected List<Zone> _zones

The zones associated with this manager.

C#
public IReadOnlyList<Zone> Zones { get; }

Adds a zone to this manager.

C#
public void Add(Zone zone)

zone Zone
The zone to add.

Removes a zone from this manager.

C#
public void Remove(Zone zone)

zone Zone
The hotspot to remove.

Checks if the manager contains the specified zone.

C#
public bool Contains(Zone zone)

zone Zone
The zone to check for.

bool

Returns an entity at the specified position or null if there is no entity. If there are multiple entities at the specified position, only one of them is returned.

C#
public Entity? GetEntityAtPosition(Point position)

position SadRogue.Primitives.Point
The position to get an entity at.

Entity
The entity if it exists; otherwise it returns null.

Returns an enumerator containing the entities, if any, at the specified position.

C#
public ListEnumerator<Entity> GetEntitiesAtPosition(Point position)

position SadRogue.Primitives.Point
The position to get an entity at.

SadRogue.Primitives.ListEnumeratorSadConsole.Entities.Entity
An array of entities if they exist; otherwise null.

Returns true when there is an entity at the specified position; otherwise false.

C#
public bool HasEntityAt(Point position)

position SadRogue.Primitives.Point
The position to check.

bool
A value indicating if an entity exists.

Returns a collection of zones at the specified position.

C#
public Zone[] GetZonesAtPosition(Point position)

position SadRogue.Primitives.Point
The position to check for zones.

Zone[]
Every zone that contains the position.

Returns a list of entities that are located in the specified zone.

C#
public IReadOnlyList<Entity> GetEntitiesInZone(Zone zone)

zone Zone
The zone to filter entities by.

IReadOnlyList<Entity>
A list of entities.

OnEntityChangedPosition(Entity, ValueChangedEventArgs<Point>)

Section titled “OnEntityChangedPosition(Entity, ValueChangedEventArgs<Point>)”

Called when an entity changes position.

C#
protected override void OnEntityChangedPosition(Entity entity, ValueChangedEventArgs<Point> e)

entity Entity
The entity that moved.

e SadRogue.Primitives.ValueChangedEventArgsSadRogue.Primitives.Point
The previous and new values of the position.

Adds entity state information to an entity when it’s added.

C#
protected override void OnEntityAdded(Entity entity)

entity Entity
The entity that was added.

Removes the entity state information of an entity being removed.

C#
protected override void OnEntityRemoved(Entity entity)

entity Entity
The entity that was removed.

OnEntityEnterZone(IScreenSurface, Zone, Entity, Point)

Section titled “OnEntityEnterZone(IScreenSurface, Zone, Entity, Point)”

Called when an entity enters a zone and raises the EnterZone event.

C#
protected virtual void OnEntityEnterZone(IScreenSurface host, Zone zone, Entity entity, Point triggeredPosition)

host IScreenSurface
The host that the zone and entity share.

zone Zone
The zone the entity entered.

entity Entity
The entity that entered the zone.

triggeredPosition SadRogue.Primitives.Point
The position the entity entered.

OnEntityExitZone(IScreenSurface, Zone, Entity, Point)

Section titled “OnEntityExitZone(IScreenSurface, Zone, Entity, Point)”

Called when an entity enters a zone and raises the ExitZone event.

C#
protected virtual void OnEntityExitZone(IScreenSurface host, Zone zone, Entity entity, Point triggeredPosition)

host IScreenSurface
The host that the zone and entity share.

zone Zone
The zone the entity exited.

entity Entity
The entity that exited the zone.

triggeredPosition SadRogue.Primitives.Point
The new position the entity left.

OnEntityMoveZone(IScreenSurface, Zone, Entity, Point, Point)

Section titled “OnEntityMoveZone(IScreenSurface, Zone, Entity, Point, Point)”

Called when an entity moves within a zone.

C#
protected virtual void OnEntityMoveZone(IScreenSurface host, Zone zone, Entity entity, Point newPosition, Point oldPosition)

host IScreenSurface
The host that the zone and entity share.

zone Zone
The zone the entity moved in.

entity Entity
The entity that moved in the zone.

newPosition SadRogue.Primitives.Point
The position the entity moved to.

oldPosition SadRogue.Primitives.Point
The position the entity moved from.

GetZonesAtPosition(in Point, out HashSet<Zone>)

Section titled “GetZonesAtPosition(in Point, out HashSet<Zone>)”

Gets the zones that contain the specified position.

C#
public bool GetZonesAtPosition(in Point point, out HashSet<Zone> zones)

point SadRogue.Primitives.Point
The position to check.

zones HashSet<Zone>
The zones that contain this position.

bool
true when at least one zone was found; otherwise false.

Prevents an entity from being processed with the Zones.

C#
public void DisableEntity(Entity entity)

entity Entity
The entity to disable.

Enables the entity to be processed with with the Zones.

C#
public void EnableEntity(Entity entity)

entity Entity
The entity to disable.

Returns true when the entity has been disabled by DisableEntity(Entity); otherwise false.

C#
public bool IsEntityDisabled(Entity entity)

entity Entity
The entity to check.

bool
true when the entity is disabled.

An event to indicate that an entity entered a zone.

C#
public event EventHandler<EntityManagerZoned.ZoneEventArgs>? EnterZone

EventHandler<EntityManagerZoned.ZoneEventArgs>

An event to indicate that an entity exited a zone.

C#
public event EventHandler<EntityManagerZoned.ZoneEventArgs>? ExitZone

EventHandler<EntityManagerZoned.ZoneEventArgs>