Skip to content

Entity Class

A positioned and animated game object.

C#
[DataContract]
public class Entity : ScreenObject, IScreenObject, IPositionable, IComponentHost, IHasID

Inheritance objectScreenObject

Implements IScreenObject, SadRogue.Primitives.IPositionable, IComponentHost, SadRogue.Primitives.IHasID

Creates a new entity as an animated surface.

C#
public Entity(Entity.Animated appearance, int zIndex)

appearance Entity.Animated
The surface appearance to use for the entity.

zIndex int
The rendering order. Higher values are drawn on top of lower values.

Creates a new entity as an animated surface.

C#
public Entity(AnimatedScreenObject appearance, int zIndex)

appearance AnimatedScreenObject
The surface appearance to use for the entity.

zIndex int
The rendering order. Higher values are drawn on top of lower values.

Creates a new entity as a single cell.

C#
public Entity(Entity.SingleCell appearance, int zIndex)

appearance Entity.SingleCell
The single cell appearance to use for the entity.

zIndex int
The rendering order. Higher values are drawn on top of lower values.

Creates a new entity, copying the provided appearance to this entity.

C#
public Entity(ColoredGlyphBase appearance, int zIndex)

appearance ColoredGlyphBase
The appearance of the entity.

zIndex int
The rendering order. Lower values are under higher values.

Creates a new entity, copying the provided appearance to this entity.

C#
public Entity(Color foreground, Color background, int glyph, int zIndex)

foreground SadRogue.Primitives.Color
The foreground color of the entity.

background SadRogue.Primitives.Color
The background color of the entity.

glyph int
The glyph color of the entity.

zIndex int
The rendering order. Lower values are under higher values.

A friendly name of the game object.

C#
[DataMember]
public string Name { get; set; }

The drawing layer this entity is drawn at

C#
[DataMember]
public int ZIndex { get; set; }

Indicates this entity’s visual appearance has changed.

C#
public bool IsDirty { get; set; }

Treats the SadRogue.Primitives.IPositionable.Position of the entity as if it is pixels and not cells.

C#
public bool UsePixelPositioning { get; set; }

The appearance of the entity when IsSingleCell is true.

C#
public Entity.SingleCell? AppearanceSingle { get; set; }

The appearance of the entity when IsSingleCell is false.

C#
public Entity.Animated? AppearanceSurface { get; set; }

When true, indicates that this entity is a single cell entity; otherwise false and it’s an animated surface entity.

C#
public bool IsSingleCell { get; set; }

Raises the PositionChanged event.

C#
protected override void OnPositionChanged(Point oldPosition, Point newPosition)

oldPosition SadRogue.Primitives.Point
The previous position.

newPosition SadRogue.Primitives.Point
The new position.

Raises the IsDirtyChanged event.

C#
protected virtual void OnIsDirtyChanged()

Sets a value for AbsolutePosition based on the SadRogue.Primitives.IPositionable.Position of this instance and the Parent instance.

C#
public override void UpdateAbsolutePosition()

If an effect is applied to the cell, updates the effect.

C#
public override void Update(TimeSpan delta)

delta TimeSpan

Returns the name of the entity prefixed with “Entity - ”.

C#
public override string ToString()

string
The name.

Saves the Entity to a file.

C#
public void Save(string file)

file string
The destination file.

Loads a Entity from a file.

C#
public static Entity Load(string file)

file string
The source file.

Entity
The entity.

Raised when the IsDirty property changes value.

C#
public event EventHandler? IsDirtyChanged

EventHandler