GPR5100 - Rollback
Loading...
Searching...
No Matches
Public Member Functions | List of all members
game::RollbackManager Class Referencefinal

RollbackManager is a class that manages all the rollback mechanisms of the game. It contains two copies of the world (PhysicsManager, TransformManager, etc...), the current one and the validated one. When receiving new information, it can reupdate the current copy of the world. More...

#include <rollback_manager.h>

Inheritance diagram for game::RollbackManager:
Inheritance graph
[legend]
Collaboration diagram for game::RollbackManager:
Collaboration graph
[legend]

Public Member Functions

 RollbackManager (GameManager &gameManager, core::EntityManager &entityManager)
 
void SimulateToCurrentFrame ()
 SimulateToCurrentFrame is a method that simulates all players with new inputs, method call only by the clients to update the current state of the visuals.
 
void SetPlayerInput (PlayerNumber playerNumber, PlayerInput playerInput, Frame inputFrame)
 SetPlayerInput is a method that set the input of a certain player on a certain game frame. It can change an input between the last validated frame and the current frame. It is called by the GameManager when receiving new inputs from packets. More...
 
void StartNewFrame (Frame newFrame)
 
void ValidateFrame (Frame newValidateFrame)
 ValidateFrame is a method that validates all the frames from lastValidateFrame_ to newValidateFrame. It changes lastValidateFrame_ to be newValidateFrame. More...
 
void ConfirmFrame (Frame newValidatedFrame, const std::array< PhysicsState, maxPlayerNmb > &serverPhysicsState)
 ConfirmFrame is a method that confirms the new validate frame by checking the Physics State checksums It is called by the clients when receiving Confirm Frame packet. More...
 
PhysicsState GetValidatePhysicsState (PlayerNumber playerNumber) const
 
Frame GetLastValidateFrame () const
 
Frame GetLastReceivedFrame (PlayerNumber playerNumber) const
 
Frame GetCurrentFrame () const
 
const core::TransformManagerGetTransformManager () const
 
const PlayerCharacterManagerGetPlayerCharacterManager () const
 
void SpawnPlayer (PlayerNumber playerNumber, core::Entity entity, core::Vec2f position, core::Degree rotation)
 
void SpawnBullet (PlayerNumber playerNumber, core::Entity entity, core::Vec2f position, core::Vec2f velocity)
 
void DestroyEntity (core::Entity entity)
 DestroyEntity is a method that does not destroy the entity definitely, but puts the DESTROY flag on. An entity is truly destroyed when the destroy frame is validated. More...
 
void OnTrigger (core::Entity entity1, core::Entity entity2) override
 
const std::array< PlayerInput, windowBufferSize > & GetInputs (PlayerNumber playerNumber) const
 
virtual void OnTrigger (core::Entity entity1, core::Entity entity2)=0
 

Detailed Description

RollbackManager is a class that manages all the rollback mechanisms of the game. It contains two copies of the world (PhysicsManager, TransformManager, etc...), the current one and the validated one. When receiving new information, it can reupdate the current copy of the world.

Member Function Documentation

◆ ConfirmFrame()

void game::RollbackManager::ConfirmFrame ( Frame  newValidatedFrame,
const std::array< PhysicsState, maxPlayerNmb > &  serverPhysicsState 
)

ConfirmFrame is a method that confirms the new validate frame by checking the Physics State checksums It is called by the clients when receiving Confirm Frame packet.

Parameters
newValidatedFrameis the new frame that is validated
serverPhysicsStateis the physics state given by the server through a packet

◆ DestroyEntity()

void game::RollbackManager::DestroyEntity ( core::Entity  entity)

DestroyEntity is a method that does not destroy the entity definitely, but puts the DESTROY flag on. An entity is truly destroyed when the destroy frame is validated.

Parameters
entityis the entity to be "destroyed"

◆ OnTrigger()

void game::RollbackManager::OnTrigger ( core::Entity  entity1,
core::Entity  entity2 
)
overridevirtual

◆ SetPlayerInput()

void game::RollbackManager::SetPlayerInput ( PlayerNumber  playerNumber,
PlayerInput  playerInput,
Frame  inputFrame 
)

SetPlayerInput is a method that set the input of a certain player on a certain game frame. It can change an input between the last validated frame and the current frame. It is called by the GameManager when receiving new inputs from packets.

Parameters
playerNumberis the player number whose input will change
playerInputis the new input
inputFrameis the game frame of the new input

◆ ValidateFrame()

void game::RollbackManager::ValidateFrame ( Frame  newValidateFrame)

ValidateFrame is a method that validates all the frames from lastValidateFrame_ to newValidateFrame. It changes lastValidateFrame_ to be newValidateFrame.

Parameters
newValidateFrameis the new value of lastValidateFrame_

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