Class LayeredSurface
Manages a set of surface layers.
Implements
Inherited Members
Namespace: SadConsole.Components
Assembly: SadConsole.dll
Syntax
[DataContract]
public class LayeredSurface : UpdateComponent, IComponent, IList<ICellSurface>, ICollection<ICellSurface>, IEnumerable<ICellSurface>, IEnumerable
Constructors
LayeredSurface()
Declaration
public LayeredSurface()
Fields
RenderStep
Internal use only
Declaration
public IRenderStep? RenderStep
Field Value
Type | Description |
---|---|
IRenderStep |
_layers
The entities to process.
Declaration
[DataMember(Name = "Layers")]
protected List<ICellSurface> _layers
Field Value
Type | Description |
---|---|
List<ICellSurface> |
_screen
The parent screen hosting this component.
Declaration
protected IScreenSurface? _screen
Field Value
Type | Description |
---|---|
IScreenSurface |
_screenCachedView
A cached copy of the View of the hosting screen surface.
Declaration
protected Rectangle _screenCachedView
Field Value
Type | Description |
---|---|
Rectangle |
Properties
Count
The numbers of layers.
Declaration
public int Count { get; }
Property Value
Type | Description |
---|---|
int |
DefaultBackground
The default color to clear the rendering surface. This is used instead of the individual layer's default background.
Declaration
public Color DefaultBackground { get; set; }
Property Value
Type | Description |
---|---|
Color |
IsAttached
Indicates that the entity renderer has been added to a parent object.
Declaration
protected bool IsAttached { get; set; }
Property Value
Type | Description |
---|---|
bool |
IsReadOnly
Always returns false.
Declaration
public bool IsReadOnly { get; }
Property Value
Type | Description |
---|---|
bool |
this[int]
Gets or sets a layer by index.
Declaration
public ICellSurface this[int index] { get; set; }
Parameters
Type | Name | Description |
---|---|---|
int | index | The index of the layer to get or set. |
Property Value
Type | Description |
---|---|
ICellSurface | The layer. |
View
The visible portion of the surface layers.
Declaration
public Rectangle View { get; set; }
Property Value
Type | Description |
---|---|
Rectangle |
Methods
Add(ICellSurface)
Adds a layer to this component.
Declaration
public void Add(ICellSurface layer)
Parameters
Type | Name | Description |
---|---|---|
ICellSurface | layer | The layer to add. |
AddRange(IEnumerable<ICellSurface>)
Adds a collection if layers to this component.
Declaration
public void AddRange(IEnumerable<ICellSurface> layers)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<ICellSurface> | layers | The layers to add. |
Clear()
Removes all layers.
Declaration
public void Clear()
Clear(ICellSurface)
Removes all layers and adds the initialLayer
parameter as the first layer.
Declaration
public void Clear(ICellSurface initialLayer)
Parameters
Type | Name | Description |
---|---|---|
ICellSurface | initialLayer | The new first layer. |
Contains(ICellSurface)
Declaration
public bool Contains(ICellSurface layer)
Parameters
Type | Name | Description |
---|---|---|
ICellSurface | layer |
Returns
Type | Description |
---|---|
bool |
CopyTo(ICellSurface[], int)
Declaration
public void CopyTo(ICellSurface[] array, int arrayIndex)
Parameters
Type | Name | Description |
---|---|---|
ICellSurface[] | array | |
int | arrayIndex |
Create()
Adds a new layer. The layer is based on the first layer's width and height.
Declaration
public CellSurface Create()
Returns
Type | Description |
---|---|
CellSurface |
Exceptions
Type | Condition |
---|---|
Exception |
GetEnumerator()
Declaration
public IEnumerator<ICellSurface> GetEnumerator()
Returns
Type | Description |
---|---|
IEnumerator<ICellSurface> |
IndexOf(ICellSurface)
Returns the index of the specified layer.
Declaration
public int IndexOf(ICellSurface layer)
Parameters
Type | Name | Description |
---|---|---|
ICellSurface | layer | The layer to search for. |
Returns
Type | Description |
---|---|
int | The index of the layer. |
Insert(int, ICellSurface)
Inserts the layer at the specified index.
Declaration
public void Insert(int index, ICellSurface layer)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index to insert at. |
ICellSurface | layer | The layer to insert. |
OnAdded(IScreenObject)
Called when the component is added to a host.
Declaration
public override void OnAdded(IScreenObject host)
Parameters
Type | Name | Description |
---|---|---|
IScreenObject | host | The host that added the component. |
Overrides
OnRemoved(IScreenObject)
Called when the component is removed from the host.
Declaration
public override void OnRemoved(IScreenObject host)
Parameters
Type | Name | Description |
---|---|---|
IScreenObject | host | The host that removed the component. |
Overrides
Remove(ICellSurface)
Removes a layer from this component.
Declaration
public bool Remove(ICellSurface layer)
Parameters
Type | Name | Description |
---|---|---|
ICellSurface | layer | The layer to remove. |
Returns
Type | Description |
---|---|
bool |
RemoveAt(int)
Removes a layer at the specified index.
Declaration
public void RemoveAt(int index)
Parameters
Type | Name | Description |
---|---|---|
int | index | The index of the layer to remove. |
Replace(ICellSurface, ICellSurface)
Replaces a layer with a new instance.
Declaration
public void Replace(ICellSurface oldLayer, ICellSurface newLayer)
Parameters
Type | Name | Description |
---|---|---|
ICellSurface | oldLayer | The layer to remove. |
ICellSurface | newLayer | The layer to add. |
Exceptions
Type | Condition |
---|---|
ArgumentException | Thrown when the old layer doesn't exist in this collection. - or - Thrown when the new layer already exists in this collection. - or - Thrown when the new layer isn't the same size as the other layers. |
Update(IScreenObject, TimeSpan)
Called by a host on the update frame.
Declaration
public override void Update(IScreenObject host, TimeSpan delta)
Parameters
Type | Name | Description |
---|---|---|
IScreenObject | host | The host calling the component. |
TimeSpan | delta | The time that has elapsed since this method was last called. |