IGameContext¶
-
interface
IGameContext
Represents the state of the game at runtime. This interface is frequently used, and is passed in to Render and Update methods of all worlds and entities.
-
int
FPS
Gets the frames-per-second of the current game.
Value: The FPS.
-
int
FrameCount
Gets the number of frames that have been rendered in total during the game.
Value: The total number of frames rendered.
-
readonly Protogame.ICoreGame
Game
Gets the game instance.
Value: The game instance.
-
GameTime
GameTime
Gets the amount of game time elapsed since the last update or render step.
Value: The elapsed game time since the last update or render step.
-
readonly Protogame.IGameWindow
Window
Gets the game window.
Value: The window the game is rendering in.
-
readonly IWorld
World
Gets the current world.
Value: The current active world in the game.
-
readonly IWorldManager
WorldManager
Gets the world manager.
Value: The world manager.
-
readonly IHierarchy
Hierarchy
Gets the dependency injection hierarchy, which contains all worlds, entities and components.
Value: The dependency injection hierarchy, which contains all worlds, entities and components.
-
Ray
MouseRay
Gets or sets the ray representing the mouse cursor in 3D space. This is updated automatically by DefaultRenderContext based on the World, View and Projection properties of the current render context.
Value: The ray representing the mouse cursor in 3D space.
-
Plane
MouseHorizontalPlane
Gets or sets the plane representing the mouse cursor’s Y position in 3D space. This forms a plane such that if it were projected back to the screen it would intersect the mouse’s Y position along the X axis of the screen. This is updated automatically by DefaultRenderContext based on the World, View and Projection properties of the current render context.
Value: The plane representing the mouse cursor’s Y position in 3D space.
-
Plane
MouseVerticalPlane
Gets or sets the plane representing the mouse cursor’s X position in 3D space. This forms a plane such that if it were projected back to the screen it would intersect the mouse’s X position along the Y axis of the screen. This is updated automatically by DefaultRenderContext based on the World, View and Projection properties of the current render context.
Value: The plane representing the mouse cursor’s X position in 3D space.
-
void
Begin
() Called by the game at the beginning of a frame, immediately before any update logic is processed. This method is used by the engine, and should not be called from user code.
-
IWorld
CreateWorld<T>
() Creates the specified world and returns it.
Type Parameters: - T – The type of the world to create.
Returns: The T:Protogame.IWorld.
-
IWorld
CreateWorld<TFactory>
(System.Func<TFactory, IWorld> creator) Creates the specified world using a given factory and returns it.
Type Parameters: - TFactory – The type of the world to create.
Parameters: - IWorld> creator (System.Func<TFactory,) – The method used to create the world.
Returns: The T:Protogame.IWorld.
-
void
ResizeWindow
(int width, int height) Resizes the game window to the specified width and height. This method can only be called during the update step (not during rendering).
Parameters: - width (int) – The desired width of the game window.
- height (int) – The desired height of the game window.
-
void
SwitchWorld<T>
() Asynchronously switches the current active world to a new instance of the world, as specified by the given type.
Type Parameters: - T – The type of world to create and switch to.
-
void
SwitchWorld<TFactory>
(System.Func<TFactory, IWorld> creator) Switches the current active world to a new instance of the world, using the specified factory method to create the instance of the world.
Type Parameters: - TFactory – The type of world to create and switch to.
Parameters: - IWorld> creator (System.Func<TFactory,) – The factory method used to create the world.
-
void
SwitchWorld<TFactory>
(System.Func<TFactory, Task`1> creator) Asynchronously switches the current active world to a new instance of the world, using the specified factory method to create the instance of the world.
Type Parameters: - TFactory – The type of world to create and switch to.
Parameters: - Task`1> creator (System.Func<TFactory,) – The factory method used to create the world.
-
void
SwitchWorld<T>
(Protogame.T world) Type Parameters: - T –
Parameters: - world (Protogame.T) –
-
int