Loading...
Searching...
No Matches
AdventureCore.AttributePool Class Reference

Detailed Description

manages the modification and observation of a defined set of attributes and stats
has built in support for stats that define a resources maximum(max health, max stamine, ...)

https://adventure.softleitner.com/manual/attribute

Inheritance diagram for AdventureCore.AttributePool:

Classes

struct  AttributeData
 
class  ResourceMaximum
 
struct  ValueData
 

Public Member Functions

void Add (AttributeType type, int quantity)
 adds to the value of an attribute
 
void Remove (AttributeType type, int quantity)
 removes from the value of an attribute
 
bool HasValue (AttributeValue attributeValue)
 checks if the current value of an attribute is at least as large as the one passed
 
bool HasValues (IEnumerable< AttributeValue > attributeValues)
 
bool HasValue (AttributeStatValue attributeStatValue)
 
bool HasValues (IEnumerable< AttributeStatValue > attributeStatValues)
 
IEnumerable< AttributeValueGetValues ()
 
int GetValue (AttributeType attribute)
 applies all modifiers and returns the attribute value
 
int GetValue (AttributeStat stat)
 applies all modifiers and returns the stat value
 
void AddObserver (AttributeType attribute, Action< int > callback)
 add a callback that will be called whenever an attribute changes
changes can occur when the value changes or modifiers are added or removed
 
void RemoveObserver (AttributeType attribute, Action< int > callback)
 removes an observing action that was added in AddObserver(AttributeType, Action<int>)
 
void AddObserver (AttributeStat stat, Action< int > callback)
 add a callback that will be called whenever a stat changes
changes can occur when the attribute changes or modifiers are added or removed
 
void RemoveObserver (AttributeStat stat, Action< int > callback)
 removes an observing action that was added in AddObserver(AttributeStat, Action<int>)
 
void AddModifier (IAttributeModifier attributeModifier)
 adds a modifier for attributes, observers will be notified
 
void RemoveModifier (IAttributeModifier attributeModifier)
 removes a modifier for attributes, observers will be notified
 
void AddModifier (IStatModifier statModifier)
 adds a modifier for stats, observers will be notified
 
void RemoveModifier (IStatModifier statModifier)
 removes a modifier for stats, observers will be notified
 
AttributeData GetData ()
 collects all the state from attributes and puts it into a AttributeData that can be serialized
may be used from outside when attributedata is put into a larger structure that is persisted and no persister is set up here
 
void Persist ()
 

Public Attributes

PersisterBase Persister
 
AttributeValue[] Attributes
 
AttributeStatValue[] BaseStats
 
ResourceMaximum[] ResourceMaximums
 
UnityEvent< AttributeType, int > AttributeChanged
 

Static Public Attributes

const string PERSISTENCE_SUB_KEY = "ATT"
 

Member Function Documentation

◆ Add()

void AdventureCore.AttributePool.Add ( AttributeType type,
int quantity )

adds to the value of an attribute

Parameters
type
quantity

◆ AddModifier() [1/2]

void AdventureCore.AttributePool.AddModifier ( IAttributeModifier attributeModifier)
inline

adds a modifier for attributes, observers will be notified

Parameters
attributeModifier

◆ AddModifier() [2/2]

void AdventureCore.AttributePool.AddModifier ( IStatModifier statModifier)
inline

adds a modifier for stats, observers will be notified

Parameters
statModifier

◆ AddObserver() [1/2]

void AdventureCore.AttributePool.AddObserver ( AttributeStat stat,
Action< int > callback )
inline

add a callback that will be called whenever a stat changes
changes can occur when the attribute changes or modifiers are added or removed

Parameters
attribute
callback

◆ AddObserver() [2/2]

void AdventureCore.AttributePool.AddObserver ( AttributeType attribute,
Action< int > callback )
inline

add a callback that will be called whenever an attribute changes
changes can occur when the value changes or modifiers are added or removed

Parameters
attribute
callback

◆ GetData()

AttributeData AdventureCore.AttributePool.GetData ( )
inline

collects all the state from attributes and puts it into a AttributeData that can be serialized
may be used from outside when attributedata is put into a larger structure that is persisted and no persister is set up here

Returns

◆ GetValue() [1/2]

int AdventureCore.AttributePool.GetValue ( AttributeStat stat)
inline

applies all modifiers and returns the stat value

Parameters
attribute
Returns
current value of the stat

◆ GetValue() [2/2]

int AdventureCore.AttributePool.GetValue ( AttributeType attribute)
inline

applies all modifiers and returns the attribute value

Parameters
attribute
Returns
current value of the attribute

◆ HasValue()

bool AdventureCore.AttributePool.HasValue ( AttributeValue attributeValue)

checks if the current value of an attribute is at least as large as the one passed

Parameters
attributeValue
Returns
if current >= passed value

◆ Remove()

void AdventureCore.AttributePool.Remove ( AttributeType type,
int quantity )

removes from the value of an attribute

Parameters
type
quantity

◆ RemoveModifier() [1/2]

void AdventureCore.AttributePool.RemoveModifier ( IAttributeModifier attributeModifier)
inline

removes a modifier for attributes, observers will be notified

Parameters
attributeModifier

◆ RemoveModifier() [2/2]

void AdventureCore.AttributePool.RemoveModifier ( IStatModifier statModifier)
inline

removes a modifier for stats, observers will be notified

Parameters
statModifier

◆ RemoveObserver() [1/2]

void AdventureCore.AttributePool.RemoveObserver ( AttributeStat stat,
Action< int > callback )
inline

removes an observing action that was added in AddObserver(AttributeStat, Action<int>)

Parameters
attribute
callback

◆ RemoveObserver() [2/2]

void AdventureCore.AttributePool.RemoveObserver ( AttributeType attribute,
Action< int > callback )
inline

removes an observing action that was added in AddObserver(AttributeType, Action<int>)

Parameters
attribute
callback