All Classes Namespaces Functions Variables Enumerations Enumerator Properties
plyGame.ActorAttribute Class Reference

The Actor Attribute defines a property an actor may have. Attributes are linked to Actors via the Actor Class assigned to an Actor. More...

Public Types

enum  ValueType { ValueType.Value, ValueType.ConsumableValue, ValueType.Bonus }
 Attribute Value Types More...
 

Public Member Functions

override string ToString ()
 
ActorAttribute Copy ()
 
void CopyTo (ActorAttribute o)
 
void Save (string key)
 
void Load (string key)
 
void DeleteSaveData (string key)
 
void Init (ActorClass owner, int currLevel)
 Init the Value and ConsumableValue without triggering callbacks. Used by Actor Class when it creates the Attribute. More...
 
void Recalc (bool withCallbacks)
 Call this to force a recalculate of the Value. ConsumableValue will be updated to not be more than Value. More...
 
void RegisterBonusCalculator (ResultCallback callback)
 Register a Callback that should return a Float value which will be added to bonusValue when recalculating what the Value of the attribute should be. More...
 
void RemoveBonusCalculator (ResultCallback callback)
 Removes the bonus calculator described by callback. More...
 
void RegisterChangeListener (GeneralCallback callback)
 Registers a callback that should be informed when the Value or ConsumableValue changes. More...
 
void RemoveChangeListener (GeneralCallback callback)
 Removes the change listener described by callback. More...
 
void SetConsumableValue (float v, GameObject influence)
 Set the consumable value. You can optionally set an 'influence'. This is the object that was the reason for the change in value. Useful when tagging who was the attacker when Hp decreased. More...
 
void SetBaseValue (int v)
 Sets the attribute's 'Value' and call recalculate to make sure ConsumableValue is the same or less. More...
 
void ChangeBaseValueBy (int v)
 Change base value and call Recalculate to update 'Value' and to make sure ConsumableValue is the same or less. More...
 
void LevelChanged (int newLevel)
 Tell the Attribute that the level changed. It will act on that if it is an attribute that is linked to the leveling system. More...
 
void ChangeSimpleBonus (int val)
 Pass positive or negative value to influence bonus value. This can push bonus to negative and this negatively influence the final Value calculation. More...
 
void SetSimpleBonus (int val)
 Set simple bonus value to this exact value. More...
 

Public Attributes

UniqueID id = new UniqueID()
 Unique Id of the Attribute.
 
CommonDefinitionData def = new CommonDefinitionData()
 common data
 

Properties

ActorClass owner [get, set]
 Owner (ActorClass) of this Attribute. Only valid at run-time. More...
 
ActorAttributeData data [get, set]
 Data contains the base, max, etc type data for the Attribute. Initialised by the Actor class at runtime More...
 
float Value [get, set]
 (baseValue + bonusValue) This is the real value of the attribute. This is the value to read when you want to see what STR, INT, etc is, or if you want to know what MAX is that Health or Mana type attributes can reach. More...
 
float ConsumableValue [get]
 This is the variable/ consumable value of the attribute. Used to tract the CURRENT value of an attribute like Health or Mana. Not used with attributes that do not get consumed, like Strength or Intelligence. More...
 
float lastValue [get, set]
 what it was before the last change
 
float lastConsumableValue [get, set]
 what it was before the last change
 
GameObject lastInfluence [get, set]
 what object was associated with the change in attribute value, if any. Normally use when there is an attacker decreasing the Health ConsumableValue
 
float BonusValue [get, set]
 

Detailed Description

The Actor Attribute defines a property an actor may have. Attributes are linked to Actors via the Actor Class assigned to an Actor.

Member Enumeration Documentation

Attribute Value Types

Enumerator
Value 

'Value' value type. Used as the max that consumable types can reach. Also used with attributes like Wisdom, Strength, Intelligence, etc.

ConsumableValue 

'Consumable' value type. Used where the attribute can be 'consumed, for example Health or Mana points.

Bonus 

The Bonus value. When used to "set" then UpdateSimpleBonus() is used. When reading then value of bonusValue is returned.

Member Function Documentation

void plyGame.ActorAttribute.ChangeBaseValueBy ( int  v)

Change base value and call Recalculate to update 'Value' and to make sure ConsumableValue is the same or less.

void plyGame.ActorAttribute.ChangeSimpleBonus ( int  val)

Pass positive or negative value to influence bonus value. This can push bonus to negative and this negatively influence the final Value calculation.

void plyGame.ActorAttribute.Init ( ActorClass  owner,
int  currLevel 
)

Init the Value and ConsumableValue without triggering callbacks. Used by Actor Class when it creates the Attribute.

void plyGame.ActorAttribute.LevelChanged ( int  newLevel)

Tell the Attribute that the level changed. It will act on that if it is an attribute that is linked to the leveling system.

void plyGame.ActorAttribute.Recalc ( bool  withCallbacks)

Call this to force a recalculate of the Value. ConsumableValue will be updated to not be more than Value.

void plyGame.ActorAttribute.RegisterBonusCalculator ( ResultCallback  callback)

Register a Callback that should return a Float value which will be added to bonusValue when recalculating what the Value of the attribute should be.

void plyGame.ActorAttribute.RegisterChangeListener ( GeneralCallback  callback)

Registers a callback that should be informed when the Value or ConsumableValue changes.

void plyGame.ActorAttribute.RemoveBonusCalculator ( ResultCallback  callback)

Removes the bonus calculator described by callback.

void plyGame.ActorAttribute.RemoveChangeListener ( GeneralCallback  callback)

Removes the change listener described by callback.

void plyGame.ActorAttribute.SetBaseValue ( int  v)

Sets the attribute's 'Value' and call recalculate to make sure ConsumableValue is the same or less.

void plyGame.ActorAttribute.SetConsumableValue ( float  v,
GameObject  influence 
)

Set the consumable value. You can optionally set an 'influence'. This is the object that was the reason for the change in value. Useful when tagging who was the attacker when Hp decreased.

void plyGame.ActorAttribute.SetSimpleBonus ( int  val)

Set simple bonus value to this exact value.

Property Documentation

float plyGame.ActorAttribute.ConsumableValue
get

This is the variable/ consumable value of the attribute. Used to tract the CURRENT value of an attribute like Health or Mana. Not used with attributes that do not get consumed, like Strength or Intelligence.

ActorAttributeData plyGame.ActorAttribute.data
getset

Data contains the base, max, etc type data for the Attribute. Initialised by the Actor class at runtime

ActorClass plyGame.ActorAttribute.owner
getset

Owner (ActorClass) of this Attribute. Only valid at run-time.

float plyGame.ActorAttribute.Value
getset

(baseValue + bonusValue) This is the real value of the attribute. This is the value to read when you want to see what STR, INT, etc is, or if you want to know what MAX is that Health or Mana type attributes can reach.