Plasma Engine  2.0
Loading...
Searching...
No Matches
plStats Class Reference

This class holds a simple map that maps strings (keys) to strings (values), which represent certain stats. More...

#include <Stats.h>

Classes

struct  StatsEventData
 The event data that is broadcast whenever a stat is changed. More...
 

Public Types

using MapType = plMap<plString, plVariant>
 
using plEventStats = plEvent<const StatsEventData&, plMutex>
 

Static Public Member Functions

static void RemoveStat (plStringView sStatName)
 Removes the stat with the given name.
 
static void SetStat (plStringView sStatName, const plVariant &value)
 Sets the value of the given stat, adds it if it did not exist before.
 
static const plVariantGetStat (plStringView sStatName)
 Returns the value of the given stat. Returns an invalid plVariant, if the stat did not exist before.
 
static const MapTypeGetAllStats ()
 Returns the entire map of stats, can be used to display them.
 
static void AddEventHandler (plEventStats::Handler handler)
 Adds an event handler that is called every time a stat is changed.
 
static void RemoveEventHandler (plEventStats::Handler handler)
 Removes a previously added event handler.
 

Detailed Description

This class holds a simple map that maps strings (keys) to strings (values), which represent certain stats.

This can be used by a game to store (and continuously update) information about the internal game state. Other tools can then display this information in a convenient manner. For example the stats can be shown on screen. The data is also transmitted through plTelemetry, and the plInspector tool will display the information.

Member Function Documentation

◆ RemoveStat()

void plStats::RemoveStat ( plStringView sStatName)
static

Removes the stat with the given name.

This will also send a 'remove' message through plTelemetry, such that external tools can remove it from their list.

◆ SetStat()

void plStats::SetStat ( plStringView sStatName,
const plVariant & value )
static

Sets the value of the given stat, adds it if it did not exist before.

szStatName may contain slashes (but not backslashes) to define groups and subgroups, which can be used by tools such as plInspector to display the stats in a hierarchical way. This function will also send the name and value of the stat through plTelemetry, such that tools like plInspector will show the changed value.


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