EntityManagerZoned Class
Definition
Section titled “Definition”Manages a set of entities. Adds a render step and only renders the entities that are in the parent IScreenSurface visible area.
[DataContract]public class EntityManagerZoned : EntityManager, IList<Entity>, ICollection<Entity>, IEnumerable<Entity>, IEnumerable, IDisposable, IComponentInheritance object → UpdateComponent → EntityManager
Implements IList<Entity>, ICollection<Entity>, IEnumerable<Entity>, IEnumerable, IDisposable, IComponent
Constructors
Section titled “Constructors”EntityManagerZoned()
Section titled “EntityManagerZoned()”Creates a new manager to handle entity movement within zones.
public EntityManagerZoned()Fields
Section titled “Fields”_zones
Section titled “_zones”The zones in this manager.
[DataMember(Name = "Zones")]protected List<Zone> _zonesProperties
Section titled “Properties”The zones associated with this manager.
public IReadOnlyList<Zone> Zones { get; }Methods
Section titled “Methods”Add(Zone)
Section titled “Add(Zone)”Adds a zone to this manager.
public void Add(Zone zone)Parameters
Section titled “Parameters”zone Zone
The zone to add.
Remove(Zone)
Section titled “Remove(Zone)”Removes a zone from this manager.
public void Remove(Zone zone)Parameters
Section titled “Parameters”zone Zone
The hotspot to remove.
Contains(Zone)
Section titled “Contains(Zone)”Checks if the manager contains the specified zone.
public bool Contains(Zone zone)Parameters
Section titled “Parameters”zone Zone
The zone to check for.
Returns
Section titled “Returns”GetEntityAtPosition(Point)
Section titled “GetEntityAtPosition(Point)”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.
public Entity? GetEntityAtPosition(Point position)Parameters
Section titled “Parameters”position SadRogue.Primitives.Point
The position to get an entity at.
Returns
Section titled “Returns”Entity
The entity if it exists; otherwise it returns null.
GetEntitiesAtPosition(Point)
Section titled “GetEntitiesAtPosition(Point)”Returns an enumerator containing the entities, if any, at the specified position.
public ListEnumerator<Entity> GetEntitiesAtPosition(Point position)Parameters
Section titled “Parameters”position SadRogue.Primitives.Point
The position to get an entity at.
Returns
Section titled “Returns”SadRogue.Primitives.ListEnumeratorSadConsole.Entities.Entity
An array of entities if they exist; otherwise null.
HasEntityAt(Point)
Section titled “HasEntityAt(Point)”Returns true when there is an entity at the specified position; otherwise false.
public bool HasEntityAt(Point position)Parameters
Section titled “Parameters”position SadRogue.Primitives.Point
The position to check.
Returns
Section titled “Returns”bool
A value indicating if an entity exists.
GetZonesAtPosition(Point)
Section titled “GetZonesAtPosition(Point)”Returns a collection of zones at the specified position.
public Zone[] GetZonesAtPosition(Point position)Parameters
Section titled “Parameters”position SadRogue.Primitives.Point
The position to check for zones.
Returns
Section titled “Returns”Zone[]
Every zone that contains the position.
GetEntitiesInZone(Zone)
Section titled “GetEntitiesInZone(Zone)”Returns a list of entities that are located in the specified zone.
public IReadOnlyList<Entity> GetEntitiesInZone(Zone zone)Parameters
Section titled “Parameters”zone Zone
The zone to filter entities by.
Returns
Section titled “Returns”IReadOnlyList<Entity>
A list of entities.
OnEntityChangedPosition(Entity, ValueChangedEventArgs<Point>)
Section titled “OnEntityChangedPosition(Entity, ValueChangedEventArgs<Point>)”Called when an entity changes position.
protected override void OnEntityChangedPosition(Entity entity, ValueChangedEventArgs<Point> e)Parameters
Section titled “Parameters”entity Entity
The entity that moved.
e SadRogue.Primitives.ValueChangedEventArgsSadRogue.Primitives.Point
The previous and new values of the position.
OnEntityAdded(Entity)
Section titled “OnEntityAdded(Entity)”Adds entity state information to an entity when it’s added.
protected override void OnEntityAdded(Entity entity)Parameters
Section titled “Parameters”entity Entity
The entity that was added.
OnEntityRemoved(Entity)
Section titled “OnEntityRemoved(Entity)”Removes the entity state information of an entity being removed.
protected override void OnEntityRemoved(Entity entity)Parameters
Section titled “Parameters”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.
protected virtual void OnEntityEnterZone(IScreenSurface host, Zone zone, Entity entity, Point triggeredPosition)Parameters
Section titled “Parameters”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.
protected virtual void OnEntityExitZone(IScreenSurface host, Zone zone, Entity entity, Point triggeredPosition)Parameters
Section titled “Parameters”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.
protected virtual void OnEntityMoveZone(IScreenSurface host, Zone zone, Entity entity, Point newPosition, Point oldPosition)Parameters
Section titled “Parameters”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.
public bool GetZonesAtPosition(in Point point, out HashSet<Zone> zones)Parameters
Section titled “Parameters”point SadRogue.Primitives.Point
The position to check.
zones HashSet<Zone>
The zones that contain this position.
Returns
Section titled “Returns”bool
true when at least one zone was found; otherwise false.
DisableEntity(Entity)
Section titled “DisableEntity(Entity)”Prevents an entity from being processed with the Zones.
public void DisableEntity(Entity entity)Parameters
Section titled “Parameters”entity Entity
The entity to disable.
EnableEntity(Entity)
Section titled “EnableEntity(Entity)”Enables the entity to be processed with with the Zones.
public void EnableEntity(Entity entity)Parameters
Section titled “Parameters”entity Entity
The entity to disable.
IsEntityDisabled(Entity)
Section titled “IsEntityDisabled(Entity)”Returns true when the entity has been disabled by DisableEntity(Entity); otherwise false.
public bool IsEntityDisabled(Entity entity)Parameters
Section titled “Parameters”entity Entity
The entity to check.
Returns
Section titled “Returns”bool
true when the entity is disabled.
Events
Section titled “Events”EnterZone
Section titled “EnterZone”An event to indicate that an entity entered a zone.
public event EventHandler<EntityManagerZoned.ZoneEventArgs>? EnterZoneEvent Type
Section titled “Event Type”EventHandler<EntityManagerZoned.ZoneEventArgs>
ExitZone
Section titled “ExitZone”An event to indicate that an entity exited a zone.
public event EventHandler<EntityManagerZoned.ZoneEventArgs>? ExitZone