|
R-Type
Distributed multiplayer game engine in C++
|
Client-side storage for game rules synchronized from server. More...
#include <ClientGameRules.hpp>

Public Member Functions | |
| ClientGameRules (const ClientGameRules &)=delete | |
| ClientGameRules & | operator= (const ClientGameRules &)=delete |
| float | get (GameruleKey key, float defaultValue=0.0f) const |
| Get a gamerule value (type-safe with enum) | |
| float | get (const std::string &key, float defaultValue=0.0f) const |
| Get a gamerule value (string version) | |
| void | update (GameruleKey key, float value) |
| Update a gamerule value (type-safe with enum) | |
| void | update (const std::string &key, float value) |
| Update a gamerule value (string version) | |
| void | updateMultiple (const std::unordered_map< std::string, float > &gamerules) |
| Update multiple gamerules at once. | |
| bool | has (GameruleKey key) const |
| Check if a gamerule exists (type-safe with enum) | |
| bool | has (const std::string &key) const |
| Check if a gamerule exists (string version) | |
| void | clear () |
| Clear all gamerules. | |
| size_t | size () const |
| Get the number of stored gamerules. | |
Static Public Member Functions | |
| static ClientGameRules & | getInstance () |
| Get the singleton instance. | |
Private Member Functions | |
| ClientGameRules ()=default | |
| ~ClientGameRules ()=default | |
Private Attributes | |
| std::mutex | mutex_ |
| std::unordered_map< std::string, float > | rules_ |
Client-side storage for game rules synchronized from server.
This class stores game constants that are received from the server. These values are used for client-side prediction and other gameplay features.
The class is thread-safe to allow updates from the network thread while the game loop reads values.
Usage: auto& rules = ClientGameRules::getInstance();
// Type-safe with enum (recommended) float speed = rules.get(GameruleKey::PLAYER_SPEED, 200.0f); rules.update(GameruleKey::PLAYER_SPEED, 250.0f);
// String-based (for custom keys) float customValue = rules.get("custom.value", 0.0f);
Definition at line 37 of file ClientGameRules.hpp.
|
delete |
|
privatedefault |
|
privatedefault |
|
inline |
Clear all gamerules.
Definition at line 122 of file ClientGameRules.hpp.
|
inline |
Get a gamerule value (string version)
| key | The gamerule key (e.g., "player.speed") |
| defaultValue | Value to return if key doesn't exist |
Definition at line 68 of file ClientGameRules.hpp.
|
inline |
Get a gamerule value (type-safe with enum)
| key | The gamerule key enum |
| defaultValue | Value to return if key doesn't exist |
Definition at line 58 of file ClientGameRules.hpp.
References get(), and GameruleKeys::toString().
Referenced by get().

|
inlinestatic |
Get the singleton instance.
Definition at line 43 of file ClientGameRules.hpp.
Referenced by GameLoop::handleGameruleUpdate().
|
inline |
Check if a gamerule exists (string version)
| key | The gamerule key |
Definition at line 114 of file ClientGameRules.hpp.
|
inline |
Check if a gamerule exists (type-safe with enum)
| key | The gamerule key enum |
Definition at line 107 of file ClientGameRules.hpp.
References has(), and GameruleKeys::toString().
Referenced by has().

|
delete |
|
inline |
Get the number of stored gamerules.
Definition at line 131 of file ClientGameRules.hpp.
|
inline |
Update a gamerule value (string version)
| key | The gamerule key |
| value | The new value |
Definition at line 86 of file ClientGameRules.hpp.
|
inline |
Update a gamerule value (type-safe with enum)
| key | The gamerule key enum |
| value | The new value |
Definition at line 79 of file ClientGameRules.hpp.
References GameruleKeys::toString(), and update().
Referenced by update().

|
inline |
Update multiple gamerules at once.
| gamerules | Map of key-value pairs to update |
Definition at line 95 of file ClientGameRules.hpp.
|
mutableprivate |
Definition at line 140 of file ClientGameRules.hpp.
Referenced by clear(), get(), has(), size(), update(), and updateMultiple().
|
private |
Definition at line 141 of file ClientGameRules.hpp.
Referenced by clear(), get(), has(), size(), update(), and updateMultiple().