Table of Contents

Class BaseScene

Namespace
LibGFX.Core
Assembly
LibGFX.dll

Base class for creating a scene

public abstract class BaseScene : IIdentifier, ISerialization
Inheritance
BaseScene
Implements
Derived
Inherited Members

Constructors

BaseScene()

Creates a new scene

protected BaseScene()

Properties

EnqueEntries

Gets or sets the collection of entries to be enqueued.

public List<IEnqueEntry> EnqueEntries { get; }

Property Value

List<IEnqueEntry>

ID

Gets the unique identifier for this instance.

public Guid ID { get; }

Property Value

Guid

LightManager

The light handler of the scene

public virtual ILightManager LightManager { get; set; }

Property Value

ILightManager

Name

Gets or sets the name associated with the object.

public string Name { get; set; }

Property Value

string

PhysicsHandler

The physics handler of the scene

public virtual PhysicsHandler PhysicsHandler { get; set; }

Property Value

PhysicsHandler

RenderStats

The render stats of the scene. It contain the fps, delta time.

public virtual RenderStats RenderStats { get; set; }

Property Value

RenderStats

RenderTarget

Gets the render target associated with this instance.

public abstract IRenderTarget RenderTarget { get; }

Property Value

IRenderTarget

Methods

AddEnqueEntry(IEnqueEntry)

Adds the specified entry to the enqueue queue for processing.

public abstract void AddEnqueEntry(IEnqueEntry entry)

Parameters

entry IEnqueEntry

The entry to add to the enqueue queue. Cannot be null.

AddGameElement(GameElement)

Adds a game element to the current collection or scene.

public abstract void AddGameElement(GameElement element)

Parameters

element GameElement

The game element to add. Cannot be null.

AddLight<T>(T)

Adds a light object to the collection of managed lights.

public abstract void AddLight<T>(T light) where T : Light

Parameters

light T

The light instance to add. Cannot be null.

Type Parameters

T

The type of light to add. Must derive from Light.

ClearElements()

Clears all elements in the scene

public abstract void ClearElements()

Deserialize(JObject, SerializationContext, Func<JObject, bool>)

Deserializes the object from the provided JSON representation using the specified serialization context.

public virtual void Deserialize(JObject obj, SerializationContext serializationContext, Func<JObject, bool> callback = null)

Parameters

obj JObject
serializationContext SerializationContext
callback Func<JObject, bool>

DisposeScene(IRenderDevice)

Disposes the scene

public abstract void DisposeScene(IRenderDevice renderer)

Parameters

renderer IRenderDevice

EnqueElements()

Enqueues elements to be added to the scene at the end of the update cycle

public abstract void EnqueElements()

FindElement<T>(string)

Finds an element by name

public abstract T? FindElement<T>(string name) where T : GameElement

Parameters

name string

Returns

T

Type Parameters

T

FindElementsWithBehavior<T>()

Finds all elements with a specific behavior Uses parallel processing to speed up the search

public abstract ICollection<GameElement> FindElementsWithBehavior<T>() where T : IGameBehavior

Returns

ICollection<GameElement>

Type Parameters

T

FindElementsWithTag(string)

Finds all elements with a specific tag

public abstract ICollection<GameElement> FindElementsWithTag(string tag)

Parameters

tag string

Returns

ICollection<GameElement>

ForEachElement(Action<GameElement>)

Invokes the specified action for each element in the collection.

public abstract void ForEachElement(Action<GameElement> action)

Parameters

action Action<GameElement>

The action to perform on each GameElement in the collection. Cannot be null.

Remarks

The order in which elements are processed is implementation-dependent. The method will throw an exception if action is null.

FreeScene(IRenderDevice)

Releases all resources associated with the scene and its layers using the specified renderer.

public abstract void FreeScene(IRenderDevice renderer)

Parameters

renderer IRenderDevice

The rendering device used to release resources for each layer. Cannot be null.

Remarks

After calling this method, the scene's layers are cleared and cannot be used unless reinitialized.

GetAllElements()

Gets all elements in the scene

public abstract IEnumerable<GameElement> GetAllElements()

Returns

IEnumerable<GameElement>

GetElementByID(string)

Retrieves the game element associated with the specified unique identifier.

public abstract GameElement? GetElementByID(string uuid)

Parameters

uuid string

The unique identifier of the game element to retrieve. Cannot be null or empty.

Returns

GameElement

The GameElement with the specified unique identifier, or null if no such element exists.

GetElements<T>()

Retrieves a collection of game elements of the specified type.

public abstract ICollection<GameElement> GetElements<T>() where T : GameElement

Returns

ICollection<GameElement>

A collection containing all game elements of type T. The collection is empty if no elements of the specified type exist.

Type Parameters

T

The type of game element to retrieve. Must derive from GameElement.

GetLight<T>()

Retrieves an instance of a light of the specified type.

public abstract T GetLight<T>() where T : Light

Returns

T

An instance of type T representing the requested light.

Type Parameters

T

The type of light to retrieve. Must inherit from Light.

Init(Viewport, IRenderDevice)

Initializes the scene

public abstract void Init(Viewport viewport, IRenderDevice renderer)

Parameters

viewport Viewport
renderer IRenderDevice

InitializeElements(Viewport, IRenderDevice)

Initializes all elements in the collection using the specified viewport and render device.

public abstract void InitializeElements(Viewport viewport, IRenderDevice renderer)

Parameters

viewport Viewport

The viewport that defines the rendering area for the elements.

renderer IRenderDevice

The render device used to initialize the elements.

RemoveElement(GameElement)

Removes an element from the scene

public abstract void RemoveElement(GameElement element)

Parameters

element GameElement

RemoveLight<T>(T)

Removes the specified light from the collection of managed lights.

public abstract void RemoveLight<T>(T light) where T : Light

Parameters

light T

The light instance to remove from the collection. Cannot be null.

Type Parameters

T

The type of light to remove. Must derive from Light.

Render(Viewport, IRenderDevice, Camera)

Renders the scene

public abstract void Render(Viewport viewport, IRenderDevice renderer, Camera camera)

Parameters

viewport Viewport
renderer IRenderDevice
camera Camera

RenderShadowMaps(Viewport, IRenderDevice, Camera)

Renders the shadow maps for the scene

public abstract void RenderShadowMaps(Viewport viewport, IRenderDevice renderer, Camera camera)

Parameters

viewport Viewport
renderer IRenderDevice
camera Camera

Serialize(JsonWriter, SerializationContext, Action<JsonWriter>)

Serializes the current object to a JSON representation using the specified serialization context.

public virtual void Serialize(JsonWriter writer, SerializationContext serializationContext, Action<JsonWriter> callback = null)

Parameters

writer JsonWriter
serializationContext SerializationContext

The context that provides configuration and state information for the serialization process.

callback Action<JsonWriter>

Exceptions

NotImplementedException

Thrown in all cases as the method is not yet implemented.

Update(float)

Updates the scene

public abstract void Update(float dt)

Parameters

dt float

UpdatePhysics(float)

Updates the physics of the scene

public abstract void UpdatePhysics(float dt)

Parameters

dt float

Events

AfterLightCulling

Called after light culling has been performed

public abstract event Action<BaseScene, Viewport, IRenderDevice, Camera> AfterLightCulling

Event Type

Action<BaseScene, Viewport, IRenderDevice, Camera>

AfterRenderTargetCreation

Called after the render target for the scene has been created

public abstract event Action<BaseScene, Viewport, IRenderDevice> AfterRenderTargetCreation

Event Type

Action<BaseScene, Viewport, IRenderDevice>

OnDispose

Called when the scene gets disposed

public abstract event Action<BaseScene, IRenderDevice> OnDispose

Event Type

Action<BaseScene, IRenderDevice>

OnDisposeEnd

Called after the scene has been disposed

public abstract event Action<BaseScene, IRenderDevice> OnDisposeEnd

Event Type

Action<BaseScene, IRenderDevice>

OnDisposeStart

Called before the scene is disposed

public abstract event Action<BaseScene, IRenderDevice> OnDisposeStart

Event Type

Action<BaseScene, IRenderDevice>

OnInitEnd

Called when the scene has been initialized

public abstract event Action<BaseScene, Viewport, IRenderDevice> OnInitEnd

Event Type

Action<BaseScene, Viewport, IRenderDevice>

OnInitStart

Called when the scene is initializing

public abstract event Action<BaseScene, Viewport, IRenderDevice> OnInitStart

Event Type

Action<BaseScene, Viewport, IRenderDevice>

OnPhysicsUpdateEnd

Called when the physics update ends

public abstract event Action<BaseScene, float> OnPhysicsUpdateEnd

Event Type

Action<BaseScene, float>

OnPhysicsUpdateStart

Called when the physics update starts

public abstract event Action<BaseScene, float> OnPhysicsUpdateStart

Event Type

Action<BaseScene, float>

OnRenderEnd

Called at the end of the render process

public abstract event Action<BaseScene, Viewport, IRenderDevice, Camera> OnRenderEnd

Event Type

Action<BaseScene, Viewport, IRenderDevice, Camera>

OnRenderPassBegin

Called before the game elements get rendered

public abstract event Action<BaseScene, Viewport, IRenderDevice, Camera> OnRenderPassBegin

Event Type

Action<BaseScene, Viewport, IRenderDevice, Camera>

OnRenderPassEnd

Called when all game elements have been rendered before the render target blitting

public abstract event Action<BaseScene, Viewport, IRenderDevice, Camera> OnRenderPassEnd

Event Type

Action<BaseScene, Viewport, IRenderDevice, Camera>

OnRenderStart

Called immediately on the start of the render process

public abstract event Action<BaseScene, Viewport, IRenderDevice, Camera> OnRenderStart

Event Type

Action<BaseScene, Viewport, IRenderDevice, Camera>

OnShadowPassEnd

Called when the shadow pass ends

public abstract event Action<BaseScene, Viewport, IRenderDevice, Camera> OnShadowPassEnd

Event Type

Action<BaseScene, Viewport, IRenderDevice, Camera>

OnShadowPassStart

Called when the shadow pass starts

public abstract event Action<BaseScene, Viewport, IRenderDevice, Camera> OnShadowPassStart

Event Type

Action<BaseScene, Viewport, IRenderDevice, Camera>

OnUpdateEnd

Called when the scene has been updated

public abstract event Action<BaseScene, float> OnUpdateEnd

Event Type

Action<BaseScene, float>

OnUpdateStart

Called when the scene is updating

public abstract event Action<BaseScene, float> OnUpdateStart

Event Type

Action<BaseScene, float>