Class Entity
A positioned and animated game object.
Inherited Members
Namespace: SadConsole.Entities
Assembly: SadConsole.dll
Syntax
[DataContract]
public class Entity : ScreenObject, IScreenObject, IPositionable, IComponentHost, IHasID
Constructors
Entity(AnimatedScreenObject, int)
Creates a new entity as an animated surface.
Declaration
public Entity(AnimatedScreenObject appearance, int zIndex)
Parameters
Type | Name | Description |
---|---|---|
AnimatedScreenObject | appearance | The surface appearance to use for the entity. |
int | zIndex | The rendering order. Higher values are drawn on top of lower values. |
Entity(ColoredGlyphBase, int)
Creates a new entity, copying the provided appearance to this entity.
Declaration
public Entity(ColoredGlyphBase appearance, int zIndex)
Parameters
Type | Name | Description |
---|---|---|
ColoredGlyphBase | appearance | The appearance of the entity. |
int | zIndex | The rendering order. Lower values are under higher values. |
Entity(Animated, int)
Creates a new entity as an animated surface.
Declaration
public Entity(Entity.Animated appearance, int zIndex)
Parameters
Type | Name | Description |
---|---|---|
Entity.Animated | appearance | The surface appearance to use for the entity. |
int | zIndex | The rendering order. Higher values are drawn on top of lower values. |
Entity(SingleCell, int)
Creates a new entity as a single cell.
Declaration
public Entity(Entity.SingleCell appearance, int zIndex)
Parameters
Type | Name | Description |
---|---|---|
Entity.SingleCell | appearance | The single cell appearance to use for the entity. |
int | zIndex | The rendering order. Higher values are drawn on top of lower values. |
Entity(Color, Color, int, int)
Creates a new entity, copying the provided appearance to this entity.
Declaration
public Entity(Color foreground, Color background, int glyph, int zIndex)
Parameters
Type | Name | Description |
---|---|---|
Color | foreground | The foreground color of the entity. |
Color | background | The background color of the entity. |
int | glyph | The glyph color of the entity. |
int | zIndex | The rendering order. Lower values are under higher values. |
Properties
AppearanceSingle
The appearance of the entity when IsSingleCell is true.
Declaration
public Entity.SingleCell? AppearanceSingle { get; set; }
Property Value
Type | Description |
---|---|
Entity.SingleCell |
AppearanceSurface
The appearance of the entity when IsSingleCell is false.
Declaration
public Entity.Animated? AppearanceSurface { get; set; }
Property Value
IsDirty
Indicates this entity's visual appearance has changed.
Declaration
public bool IsDirty { get; set; }
Property Value
Type | Description |
---|---|
bool |
IsSingleCell
When true, indicates that this entity is a single cell entity; otherwise false and it's an animated surface entity.
Declaration
public bool IsSingleCell { get; set; }
Property Value
Type | Description |
---|---|
bool |
Name
A friendly name of the game object.
Declaration
[DataMember]
public string Name { get; set; }
Property Value
Type | Description |
---|---|
string |
UsePixelPositioning
Treats the Position of the entity as if it is pixels and not cells.
Declaration
public bool UsePixelPositioning { get; set; }
Property Value
Type | Description |
---|---|
bool |
ZIndex
The drawing layer this entity is drawn at
Declaration
[DataMember]
public int ZIndex { get; set; }
Property Value
Type | Description |
---|---|
int |
Methods
Load(string)
Loads a Entity from a file.
Declaration
public static Entity Load(string file)
Parameters
Type | Name | Description |
---|---|---|
string | file | The source file. |
Returns
Type | Description |
---|---|
Entity | The entity. |
OnIsDirtyChanged()
Raises the IsDirtyChanged event.
Declaration
protected virtual void OnIsDirtyChanged()
OnPositionChanged(Point, Point)
Raises the PositionChanged event.
Declaration
protected override void OnPositionChanged(Point oldPosition, Point newPosition)
Parameters
Overrides
Save(string)
Saves the Entity to a file.
Declaration
public void Save(string file)
Parameters
Type | Name | Description |
---|---|---|
string | file | The destination file. |
ToString()
Returns the name of the entity prefixed with "Entity - ".
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
string | The name. |
Overrides
Update(TimeSpan)
If an effect is applied to the cell, updates the effect.
Declaration
public override void Update(TimeSpan delta)
Parameters
Type | Name | Description |
---|---|---|
TimeSpan | delta |
Overrides
UpdateAbsolutePosition()
Sets a value for AbsolutePosition based on the Position of this instance and the Parent instance.
Declaration
public override void UpdateAbsolutePosition()
Overrides
Events
IsDirtyChanged
Raised when the IsDirty property changes value.
Declaration
public event EventHandler? IsDirtyChanged
Event Type
Type | Description |
---|---|
EventHandler |