Otter  0.9.88
2d Game Development Framework based on SFML.Net
 All Classes Namespaces Functions Variables Enumerations Properties
Otter.Scene Class Reference

Class used to manage Entities. The active Game should update the active Scene, which then updates all of the contained Entities. More...

Public Member Functions

 Scene (int width=0, int height=0)
 Create a Scene with a specified width and height. If the width and height are not defined they will be inferred by the Game class that uses the Scene. More...
 
As< T > ()
 A handy shortcut for casting the Scene as a specific scene type. For some reason I just like this better than doing (Scene as Type).Whatever(); More...
 
void CenterCamera (float x, float y)
 Centers the camera of the scene. More...
 
Add< T > (T e)
 Add an entity to the scene. More...
 
Add< T > (params object[] constructorArgs)
 Create and add a new Entity to the Scene. More...
 
List< T > Add< T > (List< T > entities)
 Add a list of Entities to the scene. More...
 
AddUnique< T > (T e)
 Adds an Entity only if no other Entities of that type exist in the Scene already. More...
 
AddUnique< T > (params object[] constructorArgs)
 Creates an adds an Entity to the Scene if there is no Entity of that type in the Scene already. More...
 
List< T > AddUnique< T > (List< T > entities)
 Adds a list of Entities to the Scene if there is no Entity of that type added already. More...
 
List< EntityAddMultiple (params Entity[] entities)
 Add multiple entities to the scene. More...
 
SetGraphic< T > (T g)
 Set the only graphic of the scene. More...
 
AddGraphic< T > (T g)
 Adds a Graphic to the scene. More...
 
AddGraphic< T > (T g, float x, float y)
 Adds a Graphic to the Scene. More...
 
List< GraphicAddGraphics (params Graphic[] graphics)
 Add multiple graphics to the scene. More...
 
RemoveGraphic< T > (T g)
 Removes a Graphic from the scene. More...
 
void ClearGraphics ()
 Removes all Graphics from the scene. More...
 
AddGraphicGUI< T > (T g)
 Adds a Graphic to the Scene and sets its Scroll value to 0. More...
 
AddGraphicGUI< T > (T g, float x, float y)
 Adds a Graphic to the Scene and sets its Scroll value to 0. More...
 
List< GraphicAddGraphicsGUI (params Graphic[] graphics)
 Adds graphics to the Scene and sets their Scroll values to 0. More...
 
Remove< T > (T e)
 Removes an entity from the scene. More...
 
Remove< T > ()
 Removes the first Entity of type T from the Scene. More...
 
void RemoveAll ()
 Remove all entities from the scene. More...
 
RemoveNextFrame< T > (T e)
 
void AddSurface (Surface target)
 Add a surface to the list of surfaces that the scene should render to. This only applies to the Scene's graphics, NOT the entities in the scene. More...
 
void RemoveSurface (Surface target)
 Remove a surface from the list of targets that the scene should render to. More...
 
void ClearSurfaces ()
 Remove all surface targets and revert back to the default game surface. More...
 
void SendToBack (Entity e)
 Sends an Entity to the back of its layer. Probably don't use this and change the Entity's layer in the same update. More...
 
void SendBackward (Entity e)
 Sends an Entity further back in its layer. Probably don't use this and change the Entity's layer in the same update. More...
 
void BringForward (Entity e)
 Brings an Entity further forward in its layer. Probably don't use this and change the Entity's layer in the same update. More...
 
void BringToFront (Entity e)
 Brings an Entity to the front of its layer. Probably don't use this and change the Entity's layer in the same update. More...
 
virtual void Begin ()
 Called when the scene begins after being switched to, or added to the stack. More...
 
virtual void End ()
 Called when the scene ends after being switched away from, or removed from the stack. More...
 
virtual void Pause ()
 Called when the scene is paused because a new scene is stacked on it. More...
 
virtual void Resume ()
 Called when the scene resumes after a scene is added above it. More...
 
virtual void UpdateFirst ()
 The first update of the scene. More...
 
virtual void UpdateLast ()
 The last update of the scene. More...
 
virtual void Update ()
 The main update loop of the scene. More...
 
virtual void Render ()
 Renders the scene. Graphics added to the scene render first. Graphics drawn in Render() will render on top of all entities. More...
 
void UpdateLists ()
 Update the internal lists stored by the scene. The engine will usually take care of this! More...
 
Tween Tween (object target, object values, float duration, float delay=0)
 Tweens a set of numeric properties on an object. More...
 
void PauseGroup (int group)
 Pause a group of entities. More...
 
void ResumeGroup (int group)
 Resume a paused group of entities. More...
 
void PauseGroupToggle (int group)
 Pause or resume a group of entities. If paused, resume. If running, pause. More...
 
bool IsGroupPaused (int group)
 If a group of entities is currently paused. Note that pausing wont happen until the next update aftering calling pause. More...
 
List< EntityGetEntitiesInGroup (int group)
 Returns a list of all the entities in the given group. More...
 
List< EntityGetEntitiesInLayer (int layer)
 Returns a list of all the Entities in the given layer. More...
 
List< T > GetEntities< T > ()
 Get a list of entities of type T from the Scene. More...
 
List< EntityGetEntities (Type t)
 Get a list of Entities of a type from the Scene. More...
 
GetEntity< T > ()
 Get the first instance of an Entity of type T. More...
 
List< EntityGetEntities (int colliderTag)
 Get a list of Entities that have a Collider that matches a specified tag. More...
 
List< EntityGetEntities (Enum colliderTag)
 Get a list of Entities that have a Collider that matches a specified tag. More...
 
List< EntityGetEntitiesWith< T1 > ()
 
List< EntityGetEntitiesWith< T1, T2 > ()
 
List< EntityGetEntitiesWith< T1, T2, T3 > ()
 
List< EntityGetEntitiesWith< T1, T2, T3, T4 > ()
 
List< EntityGetEntitiesWith< T1, T2, T3, T4, T5 > ()
 
List< EntityGetEntitiesWith< T1, T2, T3, T4, T5, T6 > ()
 
List< ColliderGetColliders (int tag)
 Get a list of Colliders that match a specified tag. More...
 
List< ColliderGetColliders (Enum tag)
 Get a list of Colliders that match a specified tag. More...
 
Entity GetTopEntity (params Entity[] entities)
 Get the top most Entity in the rendering order from a set of Entities. More...
 
Entity GetBottomEntity (params Entity[] entities)
 Get the bottom most Entity in the rendering order from a set of Entities. More...
 
int GetCount< T > ()
 Count how many entities of type T are in this Scene. More...
 

Public Attributes

Tweener Tweener = new Tweener()
 The Glide instance for this Scene to control all tweens. More...
 
float Timer
 The current time since this Scene has started. More...
 
Action OnUpdate = delegate { }
 An action that triggers during Update(). More...
 
Action OnUpdateFirst = delegate { }
 An action that triggers during UpdateFirst(). More...
 
Action OnUpdateLast = delegate { }
 An action that triggers during UpdateLast(). More...
 
Action OnRender = delegate { }
 An action that triggers during Render(), after all entities have been rendered. More...
 
Action OnBegin = delegate { }
 An action that triggers during Begin(). More...
 
Action OnEnd = delegate { }
 An action that triggers during End(). More...
 
Action OnAdd = delegate { }
 An action that triggers when an entity is Added. More...
 
Action OnRemove = delegate { }
 An action that triggers when an entity is removed. More...
 
Action OnPause = delegate { }
 An action that triggers when the Scene is paused because a Scene is stacked on top of it. More...
 
Action OnResume = delegate { }
 An action that triggers when the Scene is resumed because the active Scene on top of it was popped. More...
 
Action OnCameraUpdate = delegate { }
 An action that triggers after the Scene has updated the camera positions for the Game's Surfaces. More...
 
float CameraAngle
 The angle of the camera. More...
 
float CameraZoom = 1f
 The zoom of the camera. More...
 
int Width
 The width of the scene. More...
 
int Height
 The height of the scene. More...
 
bool ApplyCamera = true
 Determines if the scene will control the game surface's camera. More...
 
bool DrawScenesBelow = true
 Determines if scenes below this scene on the stack are allowed to render. More...
 
Rectangle CameraBounds
 The bounds that the camera should be clamped inside. More...
 
bool UseCameraBounds = false
 Determines if the camera will be clamped inside the CameraBounds rectangle. More...
 
Entity CameraFocus
 The Entity that the Scene's camera will follow. More...
 
bool Visible = true
 Determines if the scene will render its graphics or not. More...
 

Static Public Attributes

static Scene Instance
 A reference back to the current scene being run by the game. More...
 

Properties

Game Game [get, set]
 A reference to the Game that owns this Scene. More...
 
Surface Surface [get, set]
 The default surface to render the scene's graphics to. If null then render to the default game surface. More...
 
List< SurfaceSurfaces [get, set]
 The list of surfaces the Scene should render to. More...
 
float HalfWidth [get, set]
 Half of the scene's width. More...
 
float HalfHeight [get, set]
 Half of the scene's height. More...
 
Vector2 Center [get]
 
Input Input [get]
 A reference to the Input from the Game controlling this scene. More...
 
int EntityCount [get]
 The current number of entities in the scene. More...
 
float MouseX [get]
 The current mouse X position in relation to the scene space. More...
 
float MouseY [get]
 The current mouse Y position in relation to the scene space. More...
 
float MouseRawX [get]
 The current raw mouse X position in relation to the scene space. More...
 
float MouseRawY [get]
 The current raw mouse Y position in relation to the scene space. More...
 
float CameraX [get, set]
 The X position of the camera in the scene. More...
 
float CameraCenterX [get]
 The X position of the center of the camera. More...
 
float CameraCenterY [get]
 The Y position of the center of the camera. More...
 
float CameraY [get, set]
 The Y position of the camera in the scene. More...
 
float CameraWidth [get]
 The width in pixels that the camera is showing with the current zoom. More...
 
float CameraHeight [get]
 The height in pixels that the camera is showing with the current zoom. More...
 
Rectangle Bounds [get]
 The bounds of the Scene as a Rectangle. More...
 
Debugger Debugger [get]
 A reference to the debugger object from the game that owns this scene. More...
 

Detailed Description

Class used to manage Entities. The active Game should update the active Scene, which then updates all of the contained Entities.

Constructor & Destructor Documentation

Otter.Scene.Scene ( int  width = 0,
int  height = 0 
)

Create a Scene with a specified width and height. If the width and height are not defined they will be inferred by the Game class that uses the Scene.

Parameters
widthThe width of the scene.
heightThe height of the scene.

Member Function Documentation

T Otter.Scene.Add< T > ( e)

Add an entity to the scene.

Parameters
eAdds a new entity
Returns
The added Entity.
Type Constraints
T :Entity 
T Otter.Scene.Add< T > ( params object[]  constructorArgs)

Create and add a new Entity to the Scene.

Template Parameters
TThe Type of entity to add.
Parameters
constructorArgsThe constructor arguments for creating the Entity.
Returns
The created Entity.
Type Constraints
T :Entity 
List<T> Otter.Scene.Add< T > ( List< T >  entities)

Add a list of Entities to the scene.

Template Parameters
TThe type of Entity.
Parameters
entitiesThe list of Entities.
Returns
The list of Entities.
Type Constraints
T :Entity 
T Otter.Scene.AddGraphic< T > ( g)

Adds a Graphic to the scene.

Parameters
gThe Graphic.
Returns
The Graphic.
Type Constraints
T :Graphic 
T Otter.Scene.AddGraphic< T > ( g,
float  x,
float  y 
)

Adds a Graphic to the Scene.

Template Parameters
T
Parameters
gThe Graphic to add.
xThe X position to place the Graphic.
yThe Y position to add the Graphic.
Returns
The added Graphic.
Type Constraints
T :Graphic 
T Otter.Scene.AddGraphicGUI< T > ( g)

Adds a Graphic to the Scene and sets its Scroll value to 0.

Template Parameters
T
Parameters
gThe Graphic to add.
Returns
The added Graphic.
Type Constraints
T :Graphic 
T Otter.Scene.AddGraphicGUI< T > ( g,
float  x,
float  y 
)

Adds a Graphic to the Scene and sets its Scroll value to 0.

Template Parameters
T
Parameters
gThe Graphic to add.
xThe X position to place the Graphic.
yThe Y position to add the Graphic.
Returns
The added Graphic.
Type Constraints
T :Graphic 
List<Graphic> Otter.Scene.AddGraphics ( params Graphic[]  graphics)

Add multiple graphics to the scene.

Parameters
graphicsThe graphics.
Returns
A list of the graphics added.
List<Graphic> Otter.Scene.AddGraphicsGUI ( params Graphic[]  graphics)

Adds graphics to the Scene and sets their Scroll values to 0.

Template Parameters
T
Parameters
graphicsThe graphics to add.
Returns
The added graphics.
List<Entity> Otter.Scene.AddMultiple ( params Entity[]  entities)

Add multiple entities to the scene.

Parameters
entitiesThe entities to add.
Returns
A list of the entities.
void Otter.Scene.AddSurface ( Surface  target)

Add a surface to the list of surfaces that the scene should render to. This only applies to the Scene's graphics, NOT the entities in the scene.

Parameters
target
T Otter.Scene.AddUnique< T > ( e)

Adds an Entity only if no other Entities of that type exist in the Scene already.

Template Parameters
TThe type of Entity.
Parameters
eThe Entity to add.
Returns
The added Entity, or the Entity of type T that exists in the Scene already.
Type Constraints
T :Entity 
T Otter.Scene.AddUnique< T > ( params object[]  constructorArgs)

Creates an adds an Entity to the Scene if there is no Entity of that type in the Scene already.

Template Parameters
TThe type of Entity to create and Add.
Parameters
constructorArgsThe constructor arguments for creating the Entity.
Returns
The added Entity, or the Entity of type T that exists in the Scene already.
Type Constraints
T :Entity 
List<T> Otter.Scene.AddUnique< T > ( List< T >  entities)

Adds a list of Entities to the Scene if there is no Entity of that type added already.

Template Parameters
TThe type of Entity
Parameters
entitiesThe list of Entities to AddUnique.
Returns
A list of the Entities that were successfully added.
Type Constraints
T :Entity 
T Otter.Scene.As< T > ( )

A handy shortcut for casting the Scene as a specific scene type. For some reason I just like this better than doing (Scene as Type).Whatever();

Template Parameters
TThe type of scene.
Returns
The scene as that type.
Type Constraints
T :Scene 
virtual void Otter.Scene.Begin ( )
virtual

Called when the scene begins after being switched to, or added to the stack.

void Otter.Scene.BringForward ( Entity  e)

Brings an Entity further forward in its layer. Probably don't use this and change the Entity's layer in the same update.

Parameters
eThe Entity to modify.
void Otter.Scene.BringToFront ( Entity  e)

Brings an Entity to the front of its layer. Probably don't use this and change the Entity's layer in the same update.

Parameters
eThe Entity to modify.
void Otter.Scene.CenterCamera ( float  x,
float  y 
)

Centers the camera of the scene.

Parameters
xThe x coordinate to be the center of the scene.
yThe y coordinate to be the center of the scene.
void Otter.Scene.ClearGraphics ( )

Removes all Graphics from the scene.

void Otter.Scene.ClearSurfaces ( )

Remove all surface targets and revert back to the default game surface.

virtual void Otter.Scene.End ( )
virtual

Called when the scene ends after being switched away from, or removed from the stack.

Entity Otter.Scene.GetBottomEntity ( params Entity[]  entities)

Get the bottom most Entity in the rendering order from a set of Entities.

Parameters
entitiesThe set of Entities to evaluate.
Returns
The bottom most Entity in the set.
List<Collider> Otter.Scene.GetColliders ( int  tag)

Get a list of Colliders that match a specified tag.

Parameters
tagThe tag to search for.
Returns
Colliders that have the specified tag.
List<Collider> Otter.Scene.GetColliders ( Enum  tag)

Get a list of Colliders that match a specified tag.

Parameters
tagThe tag to search for.
Returns
Colliders that have the specified tag.
int Otter.Scene.GetCount< T > ( )

Count how many entities of type T are in this Scene.

Template Parameters
TThe type of entity to count.
Returns
The number of entities of type T.
Type Constraints
T :Entity 
List<Entity> Otter.Scene.GetEntities ( Type  t)

Get a list of Entities of a type from the Scene.

Parameters
tThe type of Entity to list.
Returns
A list of Entities of type t.
List<Entity> Otter.Scene.GetEntities ( int  colliderTag)

Get a list of Entities that have a Collider that matches a specified tag.

Parameters
colliderTagThe tag to search for.
Returns
Entities that have a Collider with that tag.
List<Entity> Otter.Scene.GetEntities ( Enum  colliderTag)

Get a list of Entities that have a Collider that matches a specified tag.

Parameters
colliderTagThe tag to search for.
Returns
Entities that have a Collider with that tag.
List<T> Otter.Scene.GetEntities< T > ( )

Get a list of entities of type T from the Scene.

Template Parameters
TThe type of entity to collect.
Returns
A list of entities of type T.
Type Constraints
T :Entity 
List<Entity> Otter.Scene.GetEntitiesInGroup ( int  group)

Returns a list of all the entities in the given group.

Parameters
groupThe group to get.
Returns
All of the entities in the group.
List<Entity> Otter.Scene.GetEntitiesInLayer ( int  layer)

Returns a list of all the Entities in the given layer.

Parameters
layerThe layer to get.
Returns
All of the entities in the group.
T Otter.Scene.GetEntity< T > ( )

Get the first instance of an Entity of type T.

Template Parameters
TThe entity type to search for.
Returns
The first entity of that type in the scene.
Type Constraints
T :Entity 
Entity Otter.Scene.GetTopEntity ( params Entity[]  entities)

Get the top most Entity in the rendering order from a set of Entities.

Parameters
entitiesThe set of Entities to evaluate.
Returns
The top most Entity in the set.
bool Otter.Scene.IsGroupPaused ( int  group)

If a group of entities is currently paused. Note that pausing wont happen until the next update aftering calling pause.

Parameters
groupThe group to check.
Returns
True if the group is paused.
virtual void Otter.Scene.Pause ( )
virtual

Called when the scene is paused because a new scene is stacked on it.

void Otter.Scene.PauseGroup ( int  group)

Pause a group of entities.

Parameters
groupThe group to pause.
void Otter.Scene.PauseGroupToggle ( int  group)

Pause or resume a group of entities. If paused, resume. If running, pause.

Parameters
groupThe group to toggle.
T Otter.Scene.Remove< T > ( e)

Removes an entity from the scene.

Template Parameters
TThe type (inferred from the parameter.)
Parameters
eThe entity to remove.
Returns
The entity.
Type Constraints
T :Entity 
T Otter.Scene.Remove< T > ( )

Removes the first Entity of type T from the Scene.

Template Parameters
TThe type of Entity to remove.
Returns
The removed Entity.
Type Constraints
T :Entity 
void Otter.Scene.RemoveAll ( )

Remove all entities from the scene.

T Otter.Scene.RemoveGraphic< T > ( g)

Removes a Graphic from the scene.

Template Parameters
TThe type (inferred from the parameter.)
Parameters
gThe Graphic to remove.
Returns
The Graphic.
Type Constraints
T :Graphic 
void Otter.Scene.RemoveSurface ( Surface  target)

Remove a surface from the list of targets that the scene should render to.

Parameters
target
virtual void Otter.Scene.Render ( )
virtual

Renders the scene. Graphics added to the scene render first. Graphics drawn in Render() will render on top of all entities.

virtual void Otter.Scene.Resume ( )
virtual

Called when the scene resumes after a scene is added above it.

void Otter.Scene.ResumeGroup ( int  group)

Resume a paused group of entities.

Parameters
groupThe group to resume.
void Otter.Scene.SendBackward ( Entity  e)

Sends an Entity further back in its layer. Probably don't use this and change the Entity's layer in the same update.

Parameters
eThe Entity to modify.
void Otter.Scene.SendToBack ( Entity  e)

Sends an Entity to the back of its layer. Probably don't use this and change the Entity's layer in the same update.

Parameters
eThe Entity to modify.
T Otter.Scene.SetGraphic< T > ( g)

Set the only graphic of the scene.

Parameters
gThe graphic.
Returns
The graphic.
Type Constraints
T :Graphic 
Tween Otter.Scene.Tween ( object  target,
object  values,
float  duration,
float  delay = 0 
)

Tweens a set of numeric properties on an object.

Parameters
targetThe object to tween.
valuesThe values to tween to, in an anonymous type ( new { prop1 = 100, prop2 = 0} ).
durationDuration of the tween in seconds.
delayDelay before the tween starts, in seconds.
Returns
The tween created, for setting properties on.
virtual void Otter.Scene.Update ( )
virtual

The main update loop of the scene.

virtual void Otter.Scene.UpdateFirst ( )
virtual

The first update of the scene.

virtual void Otter.Scene.UpdateLast ( )
virtual

The last update of the scene.

void Otter.Scene.UpdateLists ( )

Update the internal lists stored by the scene. The engine will usually take care of this!

Member Data Documentation

bool Otter.Scene.ApplyCamera = true

Determines if the scene will control the game surface's camera.

float Otter.Scene.CameraAngle

The angle of the camera.

Rectangle Otter.Scene.CameraBounds

The bounds that the camera should be clamped inside.

Entity Otter.Scene.CameraFocus

The Entity that the Scene's camera will follow.

float Otter.Scene.CameraZoom = 1f

The zoom of the camera.

bool Otter.Scene.DrawScenesBelow = true

Determines if scenes below this scene on the stack are allowed to render.

int Otter.Scene.Height

The height of the scene.

Scene Otter.Scene.Instance
static

A reference back to the current scene being run by the game.

Action Otter.Scene.OnAdd = delegate { }

An action that triggers when an entity is Added.

Action Otter.Scene.OnBegin = delegate { }

An action that triggers during Begin().

Action Otter.Scene.OnCameraUpdate = delegate { }

An action that triggers after the Scene has updated the camera positions for the Game's Surfaces.

Action Otter.Scene.OnEnd = delegate { }

An action that triggers during End().

Action Otter.Scene.OnPause = delegate { }

An action that triggers when the Scene is paused because a Scene is stacked on top of it.

Action Otter.Scene.OnRemove = delegate { }

An action that triggers when an entity is removed.

Action Otter.Scene.OnRender = delegate { }

An action that triggers during Render(), after all entities have been rendered.

Action Otter.Scene.OnResume = delegate { }

An action that triggers when the Scene is resumed because the active Scene on top of it was popped.

Action Otter.Scene.OnUpdate = delegate { }

An action that triggers during Update().

Action Otter.Scene.OnUpdateFirst = delegate { }

An action that triggers during UpdateFirst().

Action Otter.Scene.OnUpdateLast = delegate { }

An action that triggers during UpdateLast().

float Otter.Scene.Timer

The current time since this Scene has started.

Tweener Otter.Scene.Tweener = new Tweener()

The Glide instance for this Scene to control all tweens.

bool Otter.Scene.UseCameraBounds = false

Determines if the camera will be clamped inside the CameraBounds rectangle.

bool Otter.Scene.Visible = true

Determines if the scene will render its graphics or not.

int Otter.Scene.Width

The width of the scene.

Property Documentation

Rectangle Otter.Scene.Bounds
get

The bounds of the Scene as a Rectangle.

float Otter.Scene.CameraCenterX
get

The X position of the center of the camera.

float Otter.Scene.CameraCenterY
get

The Y position of the center of the camera.

float Otter.Scene.CameraHeight
get

The height in pixels that the camera is showing with the current zoom.

float Otter.Scene.CameraWidth
get

The width in pixels that the camera is showing with the current zoom.

float Otter.Scene.CameraX
getset

The X position of the camera in the scene.

float Otter.Scene.CameraY
getset

The Y position of the camera in the scene.

Debugger Otter.Scene.Debugger
get

A reference to the debugger object from the game that owns this scene.

int Otter.Scene.EntityCount
get

The current number of entities in the scene.

Game Otter.Scene.Game
getset

A reference to the Game that owns this Scene.

float Otter.Scene.HalfHeight
getset

Half of the scene's height.

float Otter.Scene.HalfWidth
getset

Half of the scene's width.

Input Otter.Scene.Input
get

A reference to the Input from the Game controlling this scene.

float Otter.Scene.MouseRawX
get

The current raw mouse X position in relation to the scene space.

float Otter.Scene.MouseRawY
get

The current raw mouse Y position in relation to the scene space.

float Otter.Scene.MouseX
get

The current mouse X position in relation to the scene space.

float Otter.Scene.MouseY
get

The current mouse Y position in relation to the scene space.

Surface Otter.Scene.Surface
getset

The default surface to render the scene's graphics to. If null then render to the default game surface.

List<Surface> Otter.Scene.Surfaces
getset

The list of surfaces the Scene should render to.


The documentation for this class was generated from the following file: