Arcade
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties Events
GameAPI.BudgetBoy.Entity Class Reference

Base class for game objects that may have attached Sprite graphics and update logic. More...

Inheritance diagram for GameAPI.BudgetBoy.Entity:
GameAPI.BudgetBoy.CoroutineContainer GameAPI.BudgetBoy.IRenderable GameAPI.BudgetBoy.IUpdatable

Public Member Functions

 Entity ()
 Constructs a new Entity. More...
 
Add< T > (T sprite, int layer=0)
 Adds a Sprite to the given layer of this entity. More...
 
void Remove (Sprite sprite)
 Removes the given Sprite if it exists. More...
 
void SetSpriteLayer (Sprite sprite, int layer)
 Removes the given Sprite if it exists. More...
 
int GetSpriteLayer (Sprite sprite)
 Gets the rendering layer of the given Sprite. More...
 
void CalculateBounds ()
 Calculates the smallest bounds that contains every Sprite on this entity. More...
 
void SetFlags (params Enum[] flags)
 Sets flags to identify this entity with. More...
 
void ClearFlags (params Enum[] flags)
 Removes any flags set for this entity. More...
 
bool HasAllFlags (params Enum[] flags)
 Does this entity have all the given flags? More...
 
bool HasAnyFlags (params Enum[] flags)
 Does this entity have any of the given flags? More...
 
TEnum GetFlags< TEnum > ()
 Gets the combined value of all set flags of the given enumeration type associated with this Entity. More...
 
void LoadGraphics (Graphics graphics)
 Called automatically for entities added to a Stage as soon as it is appropriate for them to load graphical resources. More...
 
void LoadAudio (Audio audio)
 Called automatically for entities added to a Stage as soon as it is appropriate for them to load audio resources. More...
 
void Update (double dt)
 Updates this entity, this already gets called every tick but it can be called again if needed. More...
 
void Render (Graphics graphics)
 Renders this entity, this already gets called every tick but it can be called again if needed. More...
 
IEnumerator< SpriteGetEnumerator ()
 

Protected Member Functions

virtual void OnEnterStage (Stage stage)
 Called when this entity enters a Stage. More...
 
virtual void OnLeaveStage (Stage stage)
 Called when this entity leaves a Stage. More...
 
override Stage GetStage ()
 Should return the Stage containing this instance, used to find things like the time step to use for Delay awaitables. More...
 
virtual void OnLoadGraphics (Graphics graphics)
 Called when this entity should load any required graphics resources. More...
 
virtual void OnLoadAudio (Audio audio)
 Called when this entity should load any required audio resources. More...
 
virtual void OnReady ()
 Called when both graphics and audio have finished loading. More...
 
virtual void OnUpdate (double dt)
 Called every tick to update this entity. More...
 
virtual void OnRender (Graphics graphics)
 Called every tick to draw a frame of this entity. More...
 
- Protected Member Functions inherited from GameAPI.BudgetBoy.CoroutineContainer
 CoroutineContainer ()
 Base constructor for a CoroutineContainer with an empty CoroutineCollection. More...
 
Awaitable Delay (double seconds)
 Creates a Delay Awaitable representing a pause of execution for the given duration. More...
 
Awaitable While (Func< bool > predicate)
 Creates a While Awaitable representing a pause of execution while the given predicate evaluates as true, where evaluation occurs each update. More...
 
Awaitable Until (Func< bool > predicate)
 Creates an Until Awaitable representing a pause of execution until the given predicate evaluates as true, where evaluation occurs each update. More...
 
Awaitable Sequential (params Awaitable[] inner)
 Creates a Sequential Awaitable representing a pause of execution until all elements of the given array of Awaitables have been executed in sequence. More...
 
Awaitable Parallel (params Awaitable[] inner)
 Creates a Parallel Awaitable representing a pause of execution until all elements of the given array of Awaitables have been executed concurrently. More...
 
Awaitable PlayAnimation (Animation anim)
 Creates a PlayAnimation Awaitable representing a pause of execution until the given Animation has completed. The animation will be advanced automatically. More...
 
Awaitable PlayAnimation (Animation anim, Awaitable @while)
 Creates a PlayAnimation Awaitable representing a pause of execution until either the given Animation or Awaitable has completed. The animation will be advanced automatically. Used for looping animations that would otherwise never terminate. More...
 
Awaitable WaitForAnimation (Animation anim)
 Creates a PlayAnimation Awaitable representing a pause of execution until the given Animation has completed. The animation will not be advanced automatically. More...
 
Awaitable WaitForAnimation (Animation anim, Awaitable @while)
 Creates a PlayAnimation Awaitable representing a pause of execution until either the given Animation or Awaitable has completed. The animation will not be advanced automatically. Used for looping animations that would otherwise never terminate. More...
 
Coroutine StartCoroutine (params Object[] awaitables)
 Starts a coroutine from a sequence of objects that can be converted to Awaitable instances. More...
 
Coroutine StartCoroutine (IEnumerator routine)
 Starts a coroutine from an IEnumerator that is expected to yeild Awaitable instances, null references (to delay until next the update), or other IEnumerator coroutines. When another IEnumerator is yielded the parent IEnumerator will pause execution until the child IEnumerator has finished. More...
 
Coroutine StartCoroutine (Func< IEnumerator > routine)
 Starts a coroutine from a function returning IEnumerator that is expected to yeild Awaitable instances, null references (to delay until next the update), or other IEnumerator coroutines. When another IEnumerator is yielded the parent IEnumerator will pause execution until the child IEnumerator has finished. More...
 
void UpdateCoroutines ()
 Causes all active Coroutine instances attached to this CoroutineContainer to execute one step. More...
 

Properties

bool HasLoadedGraphics [get]
 Has the graphics for this entity loaded yet? More...
 
bool HasLoadedAudio [get]
 Has the audio for this entity loaded yet? More...
 
Vector2F Position [get, set]
 Local position. More...
 
float X [get, set]
 Local x-position. More...
 
float Y [get, set]
 Local y-position. More...
 
float PanValue [get]
 Pan value that can be used to set the panning for audio sources emitted from this entity. More...
 
bool IsVisible [get, set]
 Does this entity get rendered? More...
 
bool IsActive [get, set]
 Does this entity get updated? More...
 
bool AutoCalculateBounds [get]
 Does this entity automatically calculate its bounds from those of attached sprites? More...
 
RectF LocalBounds [get, set]
 Local rectangle bounds. Setting this will disable auto bounds calculation. More...
 
RectF Bounds [get]
 Local rectangle bounds. More...
 
Stage Stage [get, set]
 The Stage this entity is currently added to. More...
 
Game Game [get]
 The Game this entity's Stage is a part of. More...
 

Detailed Description

Base class for game objects that may have attached Sprite graphics and update logic.

Constructor & Destructor Documentation

GameAPI.BudgetBoy.Entity.Entity ( )
inline

Constructs a new Entity.

Member Function Documentation

T GameAPI.BudgetBoy.Entity.Add< T > ( sprite,
int  layer = 0 
)
inline

Adds a Sprite to the given layer of this entity.

Parameters
spriteThe Sprite to add.
layerThe render layer of the added Sprite (higher layers are drawn above lower layers).
Type Constraints
T :Sprite 
void GameAPI.BudgetBoy.Entity.CalculateBounds ( )
inline

Calculates the smallest bounds that contains every Sprite on this entity.

void GameAPI.BudgetBoy.Entity.ClearFlags ( params Enum[]  flags)
inline

Removes any flags set for this entity.

IEnumerator<Sprite> GameAPI.BudgetBoy.Entity.GetEnumerator ( )
inline
TEnum GameAPI.BudgetBoy.Entity.GetFlags< TEnum > ( )
inline

Gets the combined value of all set flags of the given enumeration type associated with this Entity.

Template Parameters
TEnumEnumeration type to retrieve the value of.
Type Constraints
TEnum :struct 
TEnum :IComparable 
TEnum :IConvertible 
TEnum :IFormattable 
int GameAPI.BudgetBoy.Entity.GetSpriteLayer ( Sprite  sprite)
inline

Gets the rendering layer of the given Sprite.

Parameters
spriteThe Sprite whose layer we want to get.
override Stage GameAPI.BudgetBoy.Entity.GetStage ( )
inlineprotectedvirtual

Should return the Stage containing this instance, used to find things like the time step to use for Delay awaitables.

Returns
The Stage containing this instance.

Implements GameAPI.BudgetBoy.CoroutineContainer.

bool GameAPI.BudgetBoy.Entity.HasAllFlags ( params Enum[]  flags)
inline

Does this entity have all the given flags?

Parameters
flagsOne or more enum flags.
bool GameAPI.BudgetBoy.Entity.HasAnyFlags ( params Enum[]  flags)
inline

Does this entity have any of the given flags?

Parameters
flagsOne or more enum flags.
void GameAPI.BudgetBoy.Entity.LoadAudio ( Audio  audio)
inline

Called automatically for entities added to a Stage as soon as it is appropriate for them to load audio resources.

Parameters
graphicsThe current Audio context of the Game.
void GameAPI.BudgetBoy.Entity.LoadGraphics ( Graphics  graphics)
inline

Called automatically for entities added to a Stage as soon as it is appropriate for them to load graphical resources.

Parameters
graphicsThe current Graphics context of the Game.
virtual void GameAPI.BudgetBoy.Entity.OnEnterStage ( Stage  stage)
inlineprotectedvirtual

Called when this entity enters a Stage.

Parameters
stageThe Stage entered.
virtual void GameAPI.BudgetBoy.Entity.OnLeaveStage ( Stage  stage)
inlineprotectedvirtual

Called when this entity leaves a Stage.

Parameters
stageThe Stage left.
virtual void GameAPI.BudgetBoy.Entity.OnLoadAudio ( Audio  audio)
inlineprotectedvirtual

Called when this entity should load any required audio resources.

Parameters
audioThe current Audio context of the Game.
virtual void GameAPI.BudgetBoy.Entity.OnLoadGraphics ( Graphics  graphics)
inlineprotectedvirtual

Called when this entity should load any required graphics resources.

Parameters
graphicsThe current Graphics context of the Game.
virtual void GameAPI.BudgetBoy.Entity.OnReady ( )
inlineprotectedvirtual

Called when both graphics and audio have finished loading.

virtual void GameAPI.BudgetBoy.Entity.OnRender ( Graphics  graphics)
inlineprotectedvirtual

Called every tick to draw a frame of this entity.

Parameters
graphicsThe Graphics context that will render this entity.
virtual void GameAPI.BudgetBoy.Entity.OnUpdate ( double  dt)
inlineprotectedvirtual

Called every tick to update this entity.

Parameters
dtThe time since last update.
void GameAPI.BudgetBoy.Entity.Remove ( Sprite  sprite)
inline

Removes the given Sprite if it exists.

Parameters
spriteThe Sprite to remove.
void GameAPI.BudgetBoy.Entity.Render ( Graphics  graphics)
inline

Renders this entity, this already gets called every tick but it can be called again if needed.

Implements GameAPI.BudgetBoy.IRenderable.

void GameAPI.BudgetBoy.Entity.SetFlags ( params Enum[]  flags)
inline

Sets flags to identify this entity with.

Parameters
flagsOne or more enum flags to set.
void GameAPI.BudgetBoy.Entity.SetSpriteLayer ( Sprite  sprite,
int  layer 
)
inline

Removes the given Sprite if it exists.

Parameters
spriteThe Sprite whose layer we want to switch.
layerThe new rendering layer for the given Sprite.
void GameAPI.BudgetBoy.Entity.Update ( double  dt)
inline

Updates this entity, this already gets called every tick but it can be called again if needed.

Implements GameAPI.BudgetBoy.IUpdatable.

Property Documentation

bool GameAPI.BudgetBoy.Entity.AutoCalculateBounds
get

Does this entity automatically calculate its bounds from those of attached sprites?

RectF GameAPI.BudgetBoy.Entity.Bounds
get

Local rectangle bounds.

Game GameAPI.BudgetBoy.Entity.Game
get

The Game this entity's Stage is a part of.

bool GameAPI.BudgetBoy.Entity.HasLoadedAudio
get

Has the audio for this entity loaded yet?

bool GameAPI.BudgetBoy.Entity.HasLoadedGraphics
get

Has the graphics for this entity loaded yet?

bool GameAPI.BudgetBoy.Entity.IsActive
getset

Does this entity get updated?

bool GameAPI.BudgetBoy.Entity.IsVisible
getset

Does this entity get rendered?

RectF GameAPI.BudgetBoy.Entity.LocalBounds
getset

Local rectangle bounds. Setting this will disable auto bounds calculation.

float GameAPI.BudgetBoy.Entity.PanValue
get

Pan value that can be used to set the panning for audio sources emitted from this entity.

Vector2F GameAPI.BudgetBoy.Entity.Position
getset

Local position.

Stage GameAPI.BudgetBoy.Entity.Stage
getset

The Stage this entity is currently added to.

float GameAPI.BudgetBoy.Entity.X
getset

Local x-position.

float GameAPI.BudgetBoy.Entity.Y
getset

Local y-position.