Nebula
Loading...
Searching...
No Matches
Nebula.Game.ActionQueue Class Reference

Detailed Description

A queue of actions that an runs one after the other.

The queue should be executed once per frame. An action that names a property runs for as long as that property is running (until ShouldDeactivate returns true).

A queue does not survive a hot reload. The reload walks the plugin's object graph, and the queue is an engine object held by the entity, so nothing walks it, and the unload detaches every property from every entity before the reattach, which empties the queue. An action that was running is gone after the reload, and the property comes back on its entity as an ordinary property.

Classes

struct  Action
 One entry of the queue. More...

Public Types

enum  ActionType {
  None , Idle , Event , Duration ,
  Property , Loop
}

Public Member Functions

delegate void EventCallback (float delta)
delegate bool LoopCallback (float delta)
 ActionQueue (int capacity=DefaultCapacity)
bool IsEmpty ()
 The actions that are still waiting.
void Idle (Entity owner, float seconds)
 Does nothing for seconds.
void Event (Entity owner, EventCallback callback)
 Runs the callback once.
void Duration (float seconds, Entity owner, EventCallback callback)
 Runs the callback every frame for seconds.
void Property (Entity owner, ActionProperty property)
 Runs a property for as long as it is running.
void Loop (Entity owner, LoopCallback callback)
 Runs the callback every frame until it answers false.
void BeginExecution ()
 Loads the first action when nothing is running.
void Execute (float delta)
 Advances one step of the queue.
void Clear ()
 Takes everything out of the queue, including the action that is running.

Properties

ActionType CurrentType [get]
 The type of the action that is running, or None when nothing is.
ActionProperty CurrentProperty [get]
 The property the action that is running names, or null when it is not a property action.

Private Member Functions

void Enqueue (Action action)
bool TryDequeue (out Action action)

Private Attributes

readonly List< Action > actions
int head
Action current
bool hasCurrent

Static Private Attributes

const int DefaultCapacity = 16

Member Enumeration Documentation

◆ ActionType

Enumerator
None 
Idle 
Event 
Duration 
Property 
Loop 

Constructor & Destructor Documentation

◆ ActionQueue()

Nebula.Game.ActionQueue.ActionQueue ( int capacity = DefaultCapacity)
inline

Member Function Documentation

◆ BeginExecution()

void Nebula.Game.ActionQueue.BeginExecution ( )
inline

Loads the first action when nothing is running.

Call this after adding an action to a queue that was empty, or the queue does not start until the next Execute.

◆ Clear()

void Nebula.Game.ActionQueue.Clear ( )
inline

Takes everything out of the queue, including the action that is running.

◆ Duration()

void Nebula.Game.ActionQueue.Duration ( float seconds,
Entity owner,
EventCallback callback )
inline

Runs the callback every frame for seconds.

◆ Enqueue()

void Nebula.Game.ActionQueue.Enqueue ( Action action)
inlineprivate

◆ Event()

void Nebula.Game.ActionQueue.Event ( Entity owner,
EventCallback callback )
inline

Runs the callback once.

◆ EventCallback()

delegate void Nebula.Game.ActionQueue.EventCallback ( float delta)

◆ Execute()

void Nebula.Game.ActionQueue.Execute ( float delta)
inline

Advances one step of the queue.

◆ Idle()

void Nebula.Game.ActionQueue.Idle ( Entity owner,
float seconds )
inline

Does nothing for seconds.

◆ IsEmpty()

bool Nebula.Game.ActionQueue.IsEmpty ( )
inline

The actions that are still waiting.

The action that is running is not one of them.

◆ Loop()

void Nebula.Game.ActionQueue.Loop ( Entity owner,
LoopCallback callback )
inline

Runs the callback every frame until it answers false.

◆ LoopCallback()

delegate bool Nebula.Game.ActionQueue.LoopCallback ( float delta)

◆ Property()

void Nebula.Game.ActionQueue.Property ( Entity owner,
ActionProperty property )
inline

Runs a property for as long as it is running.

The property is only active while it is the front of this queue, which is what an ActionProperty's ShouldActivate answers with.

◆ TryDequeue()

bool Nebula.Game.ActionQueue.TryDequeue ( out Action action)
inlineprivate

Member Data Documentation

◆ actions

readonly List<Action> Nebula.Game.ActionQueue.actions
private

◆ current

Action Nebula.Game.ActionQueue.current
private

◆ DefaultCapacity

const int Nebula.Game.ActionQueue.DefaultCapacity = 16
staticprivate

◆ hasCurrent

bool Nebula.Game.ActionQueue.hasCurrent
private

◆ head

int Nebula.Game.ActionQueue.head
private

Property Documentation

◆ CurrentProperty

ActionProperty Nebula.Game.ActionQueue.CurrentProperty
get

The property the action that is running names, or null when it is not a property action.

◆ CurrentType

ActionType Nebula.Game.ActionQueue.CurrentType
get

The type of the action that is running, or None when nothing is.


The documentation for this class was generated from the following file:
  • /github/workspace/code/addons/nsharp/NebulaEngine/engine/ActionQueue.cs