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:
AdventureCore.AttributePoolSurrogate

Classes

struct  AttributeData
 
class  ResourceMaximum
 
struct  ValueData
 

Public Member Functions

void Initialize ()
 
virtual void Add (AttributeType type, int quantity)
 adds to the value of an attribute
 
virtual void Remove (AttributeType type, int quantity)
 removes from the value of an attribute
 
virtual void Set (AttributeType type, int quantity)
 sets value of an attribute
 
virtual bool HasValue (AttributeValue attributeValue)
 checks if the current value of an attribute is at least as large as the one passed
 
virtual bool HasValues (IEnumerable< AttributeValue > attributeValues)
 
virtual bool HasValue (AttributeStatValue attributeStatValue)
 
virtual bool HasValues (IEnumerable< AttributeStatValue > attributeStatValues)
 
virtual IEnumerable< AttributeValueGetValues ()
 
virtual int GetValue (AttributeType attribute)
 applies all modifiers and returns the attribute value
 
virtual int GetRawValue (AttributeType attribute)
 returns the attribute value without modifiers
 
virtual int GetValue (AttributeStat stat)
 applies all modifiers and returns the stat value
 
virtual 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
 
virtual void RemoveObserver (AttributeType attribute, Action< int > callback)
 removes an observing action that was added in AddObserver(AttributeType, Action<int>)
 
virtual 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
 
virtual void RemoveObserver (AttributeStat stat, Action< int > callback)
 removes an observing action that was added in AddObserver(AttributeStat, Action<int>)
 
virtual void AddModifier (IAttributeModifier attributeModifier)
 adds a modifier for attributes, observers will be notified
 
virtual void RemoveModifier (IAttributeModifier attributeModifier)
 removes a modifier for attributes, observers will be notified
 
virtual void AddModifier (IStatModifier statModifier)
 adds a modifier for stats, observers will be notified
 
virtual void RemoveModifier (IStatModifier statModifier)
 removes a modifier for stats, observers will be notified
 
virtual 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 Retrieve ()
 
virtual 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"
 

Properties

bool IsInitialized [get]
 

Member Function Documentation

◆ Add()

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

adds to the value of an attribute

Parameters
type
quantity

Reimplemented in AdventureCore.AttributePoolSurrogate.

◆ AddModifier() [1/2]

virtual void AdventureCore.AttributePool.AddModifier ( IAttributeModifier attributeModifier)
inlinevirtual

adds a modifier for attributes, observers will be notified

Parameters
attributeModifier

Reimplemented in AdventureCore.AttributePoolSurrogate.

◆ AddModifier() [2/2]

virtual void AdventureCore.AttributePool.AddModifier ( IStatModifier statModifier)
inlinevirtual

adds a modifier for stats, observers will be notified

Parameters
statModifier

Reimplemented in AdventureCore.AttributePoolSurrogate.

◆ AddObserver() [1/2]

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

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

Reimplemented in AdventureCore.AttributePoolSurrogate.

◆ AddObserver() [2/2]

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

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

Reimplemented in AdventureCore.AttributePoolSurrogate.

◆ GetData()

virtual AttributeData AdventureCore.AttributePool.GetData ( )
inlinevirtual

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

Reimplemented in AdventureCore.AttributePoolSurrogate.

◆ GetRawValue()

virtual int AdventureCore.AttributePool.GetRawValue ( AttributeType attribute)
inlinevirtual

returns the attribute value without modifiers

Parameters
attribute
Returns
current value of the attribute

Reimplemented in AdventureCore.AttributePoolSurrogate.

◆ GetValue() [1/2]

virtual int AdventureCore.AttributePool.GetValue ( AttributeStat stat)
inlinevirtual

applies all modifiers and returns the stat value

Parameters
attribute
Returns
current value of the stat

Reimplemented in AdventureCore.AttributePoolSurrogate.

◆ GetValue() [2/2]

virtual int AdventureCore.AttributePool.GetValue ( AttributeType attribute)
inlinevirtual

applies all modifiers and returns the attribute value

Parameters
attribute
Returns
current value of the attribute

Reimplemented in AdventureCore.AttributePoolSurrogate.

◆ HasValue()

virtual bool AdventureCore.AttributePool.HasValue ( AttributeValue attributeValue)
virtual

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

Parameters
attributeValue
Returns
if current >= passed value

Reimplemented in AdventureCore.AttributePoolSurrogate.

◆ Remove()

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

removes from the value of an attribute

Parameters
type
quantity

Reimplemented in AdventureCore.AttributePoolSurrogate.

◆ RemoveModifier() [1/2]

virtual void AdventureCore.AttributePool.RemoveModifier ( IAttributeModifier attributeModifier)
inlinevirtual

removes a modifier for attributes, observers will be notified

Parameters
attributeModifier

Reimplemented in AdventureCore.AttributePoolSurrogate.

◆ RemoveModifier() [2/2]

virtual void AdventureCore.AttributePool.RemoveModifier ( IStatModifier statModifier)
inlinevirtual

removes a modifier for stats, observers will be notified

Parameters
statModifier

Reimplemented in AdventureCore.AttributePoolSurrogate.

◆ RemoveObserver() [1/2]

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

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

Parameters
attribute
callback

Reimplemented in AdventureCore.AttributePoolSurrogate.

◆ RemoveObserver() [2/2]

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

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

Parameters
attribute
callback

Reimplemented in AdventureCore.AttributePoolSurrogate.

◆ Set()

virtual void AdventureCore.AttributePool.Set ( AttributeType type,
int quantity )
inlinevirtual

sets value of an attribute

Parameters
type
quantity