Class BaseScene
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
ID
Gets the unique identifier for this instance.
public Guid ID { get; }
Property Value
LightManager
The light handler of the scene
public virtual ILightManager LightManager { get; set; }
Property Value
Name
Gets or sets the name associated with the object.
public string Name { get; set; }
Property Value
PhysicsHandler
The physics handler of the scene
public virtual PhysicsHandler PhysicsHandler { get; set; }
Property Value
RenderStats
The render stats of the scene. It contain the fps, delta time.
public virtual RenderStats RenderStats { get; set; }
Property Value
RenderTarget
Gets the render target associated with this instance.
public abstract IRenderTarget RenderTarget { get; }
Property Value
Methods
AddEnqueEntry(IEnqueEntry)
Adds the specified entry to the enqueue queue for processing.
public abstract void AddEnqueEntry(IEnqueEntry entry)
Parameters
entryIEnqueEntryThe 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
elementGameElementThe 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
lightTThe light instance to add. Cannot be null.
Type Parameters
TThe 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
objJObjectserializationContextSerializationContextcallbackFunc<JObject, bool>
DisposeScene(IRenderDevice)
Disposes the scene
public abstract void DisposeScene(IRenderDevice renderer)
Parameters
rendererIRenderDevice
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
namestring
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
Type Parameters
T
FindElementsWithTag(string)
Finds all elements with a specific tag
public abstract ICollection<GameElement> FindElementsWithTag(string tag)
Parameters
tagstring
Returns
ForEachElement(Action<GameElement>)
Invokes the specified action for each element in the collection.
public abstract void ForEachElement(Action<GameElement> action)
Parameters
actionAction<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
rendererIRenderDeviceThe 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
GetElementByID(string)
Retrieves the game element associated with the specified unique identifier.
public abstract GameElement? GetElementByID(string uuid)
Parameters
uuidstringThe 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
TThe 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
Trepresenting the requested light.
Type Parameters
TThe type of light to retrieve. Must inherit from Light.
Init(Viewport, IRenderDevice)
Initializes the scene
public abstract void Init(Viewport viewport, IRenderDevice renderer)
Parameters
viewportViewportrendererIRenderDevice
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
viewportViewportThe viewport that defines the rendering area for the elements.
rendererIRenderDeviceThe render device used to initialize the elements.
RemoveElement(GameElement)
Removes an element from the scene
public abstract void RemoveElement(GameElement element)
Parameters
elementGameElement
RemoveLight<T>(T)
Removes the specified light from the collection of managed lights.
public abstract void RemoveLight<T>(T light) where T : Light
Parameters
lightTThe light instance to remove from the collection. Cannot be null.
Type Parameters
TThe 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
viewportViewportrendererIRenderDevicecameraCamera
RenderShadowMaps(Viewport, IRenderDevice, Camera)
Renders the shadow maps for the scene
public abstract void RenderShadowMaps(Viewport viewport, IRenderDevice renderer, Camera camera)
Parameters
viewportViewportrendererIRenderDevicecameraCamera
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
writerJsonWriterserializationContextSerializationContextThe context that provides configuration and state information for the serialization process.
callbackAction<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
dtfloat
UpdatePhysics(float)
Updates the physics of the scene
public abstract void UpdatePhysics(float dt)
Parameters
dtfloat
Events
AfterLightCulling
Called after light culling has been performed
public abstract event Action<BaseScene, Viewport, IRenderDevice, Camera> AfterLightCulling
Event Type
AfterRenderTargetCreation
Called after the render target for the scene has been created
public abstract event Action<BaseScene, Viewport, IRenderDevice> AfterRenderTargetCreation
Event Type
OnDispose
Called when the scene gets disposed
public abstract event Action<BaseScene, IRenderDevice> OnDispose
Event Type
OnDisposeEnd
Called after the scene has been disposed
public abstract event Action<BaseScene, IRenderDevice> OnDisposeEnd
Event Type
OnDisposeStart
Called before the scene is disposed
public abstract event Action<BaseScene, IRenderDevice> OnDisposeStart
Event Type
OnInitEnd
Called when the scene has been initialized
public abstract event Action<BaseScene, Viewport, IRenderDevice> OnInitEnd
Event Type
OnInitStart
Called when the scene is initializing
public abstract event Action<BaseScene, Viewport, IRenderDevice> OnInitStart
Event Type
OnPhysicsUpdateEnd
Called when the physics update ends
public abstract event Action<BaseScene, float> OnPhysicsUpdateEnd
Event Type
OnPhysicsUpdateStart
Called when the physics update starts
public abstract event Action<BaseScene, float> OnPhysicsUpdateStart
Event Type
OnRenderEnd
Called at the end of the render process
public abstract event Action<BaseScene, Viewport, IRenderDevice, Camera> OnRenderEnd
Event Type
OnRenderPassBegin
Called before the game elements get rendered
public abstract event Action<BaseScene, Viewport, IRenderDevice, Camera> OnRenderPassBegin
Event Type
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
OnRenderStart
Called immediately on the start of the render process
public abstract event Action<BaseScene, Viewport, IRenderDevice, Camera> OnRenderStart
Event Type
OnShadowPassEnd
Called when the shadow pass ends
public abstract event Action<BaseScene, Viewport, IRenderDevice, Camera> OnShadowPassEnd
Event Type
OnShadowPassStart
Called when the shadow pass starts
public abstract event Action<BaseScene, Viewport, IRenderDevice, Camera> OnShadowPassStart
Event Type
OnUpdateEnd
Called when the scene has been updated
public abstract event Action<BaseScene, float> OnUpdateEnd
Event Type
OnUpdateStart
Called when the scene is updating
public abstract event Action<BaseScene, float> OnUpdateStart