Capycore Engine  0.1.0
A simple and lightweight game engine written in C++ based on the Unity API architecture.
Loading...
Searching...
No Matches
GameplaySpeedService Class Referencefinal

Service for managing and modifying the gameplay simulation speed. More...

#include <gameplay_speed_service.h>

Inheritance diagram for GameplaySpeedService:
[legend]

Public Member Functions

 GameplaySpeedService (const IInputProvider &input_provider)
 Constructs the GameplaySpeedService.
 
 ~GameplaySpeedService () override=default
 
void update ()
 Updates the service state based on user input.
 
float step () const
 Returns the current speed adjustment increment.
 
float max_speed () const
 Returns the maximum allowable gameplay speed.
 
float min_speed () const
 Returns the minimum allowable gameplay speed.
 
float speed () const
 Returns the current gameplay speed multiplier.
 
Config & config ()
 Provides mutable access to the service configuration.
 
void set_step (float value)
 Sets the speed adjustment increment.
 
void increase_speed (float step)
 Increases the gameplay speed by the specified step.
 
void decrease_speed (float step)
 Decreases the gameplay speed by the specified step.
 
- Public Member Functions inherited from IEngineService
virtual ~IEngineService ()=default
 

Detailed Description

Service for managing and modifying the gameplay simulation speed.

Allows dynamic adjustment of the game's time scale, enabling features like fast-forwarding, slowing down time, or resetting to default speed via input.

Usage:

  • Use the set keys to increase, decrease, or reset the gameplay speed. The default keys are Page Up, Page Down, and Home respectively.

Constructor & Destructor Documentation

◆ GameplaySpeedService()

GameplaySpeedService::GameplaySpeedService ( const IInputProvider input_provider)
explicit

Constructs the GameplaySpeedService.

Parameters
input_providerThe provider used to listen for speed control key inputs.

◆ ~GameplaySpeedService()

GameplaySpeedService::~GameplaySpeedService ( )
overridedefault

Member Function Documentation

◆ config()

Config & GameplaySpeedService::config ( )

Provides mutable access to the service configuration.

Allows runtime modification of speed limits, steps, and key bindings.

◆ decrease_speed()

void GameplaySpeedService::decrease_speed ( float  step)

Decreases the gameplay speed by the specified step.

The resulting speed is clamped to the minimum speed limit.

Parameters
stepThe amount to subtract from the current speed.

◆ increase_speed()

void GameplaySpeedService::increase_speed ( float  step)

Increases the gameplay speed by the specified step.

The resulting speed is clamped to the maximum speed limit.

Parameters
stepThe amount to add to the current speed.

◆ max_speed()

float GameplaySpeedService::max_speed ( ) const

Returns the maximum allowable gameplay speed.

◆ min_speed()

float GameplaySpeedService::min_speed ( ) const

Returns the minimum allowable gameplay speed.

◆ set_step()

void GameplaySpeedService::set_step ( float  value)

Sets the speed adjustment increment.

Parameters
valueThe new step size for speed changes.

◆ speed()

float GameplaySpeedService::speed ( ) const

Returns the current gameplay speed multiplier.

A value of 1.0 represents normal speed.

◆ step()

float GameplaySpeedService::step ( ) const

Returns the current speed adjustment increment.

The amount by which speed is increased or decreased per step.

◆ update()

void GameplaySpeedService::update ( )

Updates the service state based on user input.

Checks for speed adjustment keys (increase, decrease, reset) and modifies the current gameplay speed accordingly.


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