Gorilla.Utils.SkillSystem
Unit Gorilla.Utils.SkillSystem.pasClasses
- TGorillaCustomSkillEntity = class ( TCollectionItem )
- TGorillaCustomSkillCollection = class ( TOwnedCollection )
- TGorillaSkillCollection = class ( TGorillaCustomSkillCollection )
- TGorillaSkillGroup = class ( TGorillaCustomSkillEntity )
- TGorillaSkillGroupCollection = class ( TGorillaCustomSkillCollection )
- TGorillaSkill = class ( TGorillaSkillGroup )
- TGorillaSkillProcess = class ( TObject )
- TGorillaSkillProcessThread = class ( TThread )
- TGorillaSkillSystem = class ( TComponent )
Enumerations
- enum TGorillaSkillLevelInterpolation = ( LinearInterpolation, LogarithmicInterpolation, ExponentialInterpolation, ExponentialMinus1Interpolation ) ;
Constants
TGorillaCustomSkillEntity
A custom entity of the skill system. This is the basis for TGorillaSkill and TGorillaSkillGroup.
Ancestors
Members
Fields
- protected FGUID :
TGUID
- protected FEnabled :
Boolean
- protected FName :
TGorillaLanguageMap
- protected FIcon :
Integer
- protected FPosition :
TPointF
Methods
- public constructor Create ( ACollection : TCollection ) ;
- public destructor Destroy ( ) ;
- protected function GetName ( ) : string ; virtual;
- protected procedure SetName ( const AValue : string ) ; virtual;
- protected function GetNames ( AIndex : string ) : string ; virtual;
- protected procedure SetNames ( AIndex : string; const AValue : string ) ; virtual;
- protected function GetSkillSystem ( ) : TGorillaSkillSystem ; virtual;
- protected procedure DoOnFromXmlProperty
(
const
ANode :
TMz_XmlElement
)
;
virtual;
Used to react on property nodes of a parent xml element.
- public procedure Assign ( ASrc : TPersistent ) ; override;
- public function GetIdentifier ( ) : string ; class abstract virtual;
- public procedure FromXml
(
const
ANode :
TMz_XmlElement
)
;
virtual;
Read entity properties and attributes from a specific xml element.
- public function ToXml
(
const
AParent :
TMz_XmlElement
)
: TMz_XmlElement
;
virtual;
Write entity properties and attributes to a specific xml element.
Properties
- public GUID : TGUID
Defines a unique identifier for this entity. This guid is useful to find an entity in global context.
read FGUID - public Name : string
- public Names[Index] : string
- public NameMap : TGorillaLanguageMap
- public SkillSystem : TGorillaSkillSystem
- published Enabled : Boolean
- published Icon : Integer
- published Position : TPointF
TGorillaCustomSkillCollection
A custom skill collection. This collection is used as basis for the TGorillaSkillCollection and TGorillaSkillGroupCollection.
Ancestors
Members
TGorillaSkillCollection
Represents a collection of skill entities.
Ancestors
Members
Properties
TGorillaSkillGroup
Representing a skill group or category. It's possible to add skill entities to this collection.
Ancestors
Members
Fields
Methods
- public constructor Create ( ACollection : TCollection ) ;
- public destructor Destroy ( ) ;
- protected procedure SetSkills ( const AValue : TGorillaSkillCollection ) ;
- protected procedure DoOnFromXmlProperty ( const ANode : TMz_XmlElement ) ; override;
- public procedure Assign ( ASrc : TPersistent ) ; override;
- public function GetIdentifier ( ) : string ; class override;
- public function ToXml ( const AParent : TMz_XmlElement ) : TMz_XmlElement ; override;
- public function AddSkill
(
)
: TGorillaSkill
;
virtual;
Adds a new and empty skill instance to the specific group and returns the newly created instance.
- public function FindSkillByName
(
const
ASkillName :
string
)
: TGorillaSkill
;
virtual;
Tries to find a specific skill by its display name. If the method cannot find a skill, it returns nil.
- public function FindSkillByGUID
(
const
AGUID :
TGUID
)
: TGorillaSkill
;
virtual;
Tries to find a specific skill by its GUID. If the method cannot find a skill, it returns nil.
- public procedure GetActivatedSkills
(
var
AMap :
TGorillaSkillMap
)
;
virtual;
Searches and returns all activated skills as flat list. All skills and sub skills will be enumerated and activated skills will be returned.
Properties
TGorillaSkillGroupCollection
Represents a skilling group to organize skill in categories.
Ancestors
TGorillaSkill
Represents a single skill entity, which is able to hold multiple sub skills to setup a skill hierarchy.
Ancestors
Members
Fields
- protected FActivated :
Boolean
- protected FValue :
Single
- protected FFactor :
Single
- protected FInterpolation :
TGorillaSkillLevelInterpolation
- protected FLevel :
Integer
- protected FMaxLevel :
Integer
- protected FLevelingTime :
Integer
- protected FData :
TValue
Methods
- public constructor Create ( ACollection : TCollection ) ;
- public destructor Destroy ( ) ;
- protected function GetSkillGroup ( ) : TGorillaSkillGroup ; virtual;
- protected procedure DoLevelUp ( const ALevel : Integer; AValue : Single; ADest : TGorillaSkill ) ; overload virtual;
- protected procedure DoLevelUp ( const AProcess : TGorillaSkillProcess ) ; overload virtual;
- protected function DoInterpolateValue ( const ALevel : Integer; const ACurrentValue : Single; const AFactor : Single ) : Single ; virtual;
- protected procedure DoOnFromXmlProperty ( const ANode : TMz_XmlElement ) ; override;
- protected function IsSkillSwitchingAllowed ( ADest : TGorillaSkill ) : Boolean ;
- public procedure Assign ( ASrc : TPersistent ) ; override;
- public function GetIdentifier ( ) : string ; class override;
- public function ToXml ( const AParent : TMz_XmlElement ) : TMz_XmlElement ; override;
- public function StartLevelingUp
(
)
: TGorillaSkillProcess
;
overload virtual;
Starts an up-leveling async process. This routine selects the first sub-skill as destination.
- public function StartLevelingUp
(
ADest :
TGorillaSkill
)
: TGorillaSkillProcess
;
overload virtual;
Starts an up-leveling async process to aim a specific skill in sub-skills.
Properties
- public Group : TGorillaSkillGroup
- published Activated : Boolean
Defines if the skill is activated for use. It is different to "Enabled" which only unlocks the skill for activation.
read FActivated
write FActivated - published Value : Single
- published Factor : Single
- published Interpolation : TGorillaSkillLevelInterpolation
Defines an interpolation function by which a new value is computed, in dependency to the level.
read FInterpolation
write FInterpolation - published Level : Integer
- published MaxLevel : Integer
- published LevelingTime : Integer
Defines the time for leveling up this skill. By default this value is set to 1000ms.
read FLevelingTime
write FLevelingTime - published Data : TValue
TGorillaSkillProcess
Represents a asynchronous development process. This component is used to simulate leveling up in a specific time.
Ancestors
Members
Fields
- protected FSkill :
TGorillaSkill
- protected FDestination :
TGorillaSkill
- protected FToLevel :
Integer
- protected FNewValue :
Single
- protected FStartTime :
Int64
- protected FTotalTime :
Integer
Methods
- public constructor Create ( const ASkill : TGorillaSkill; const ADestination : TGorillaSkill; const ATotalTime : Integer; const AToLevel : Integer; const ANewValue : Single ) ;
- protected function GetIsStarted ( ) : Boolean ;
- protected function GetIsElapsed ( ) : Boolean ;
- public procedure Start
(
)
;
virtual;
Explicitly starts the leveling process. If a process was already started this method ignores the action.
- public procedure FromXml ( const ASkillSystem : TGorillaSkillSystem; const ANode : TMz_XmlElement ) ; virtual;
- public procedure ToXml ( const AParent : TMz_XmlElement ) ; virtual;
Properties
- public Skill : TGorillaSkill
- public Destination : TGorillaSkill
Referenced skill on which this leveling process will aim for. If destination reference is not set, upgrading to another skill is disabled.
read FDestination - public ToLevel : Integer
- public NewValue : Single
- public StartTime : Int64
Returns the starting time of the process. The start time is only set by a call of Start() method.
read FStartTime - public TotalTime : Integer
- public IsStarted : Boolean
- public IsElapsed : Boolean
TGorillaSkillProcessThread
Manages skill leveling process asynchronously. Processes will be added by the <TGorillaSkill>.StartLevelUp() method automatically. On execution process will be started, if they were not already. The thread checks every 500ms if processes need to be started or are finished. On completion processes will be destroyed and the skill will be updated.
Ancestors
Members
Fields
Methods
- public constructor Create ( ASuspended : Boolean ) ;
- public destructor Destroy ( ) ;
- protected procedure Execute ( ) ; override;
- protected procedure DoOnProcessListNotify ( ASender : TObject; const AItem : TGorillaSkillProcess; AAction : TCollectionNotification ) ; virtual;
- public procedure AddProcess
(
const
AProcess :
TGorillaSkillProcess
)
;
virtual;
Adds a leveling process to the thread.
- public procedure ClearProcesses
(
)
;
virtual;
Clears all available process.
Properties
TGorillaSkillSystem
Defines a skilling system with categorization in groups. Each group contains a variable number of skill entities.
Ancestors
Members
Fields
- protected FLanguage :
Integer
- protected FGroups :
TGorillaSkillGroupCollection
- protected FPosition :
TPointF
- protected FLeveling :
TGorillaSkillProcessThread
Methods
- public constructor Create ( AOwner : TComponent ) ;
- public destructor Destroy ( ) ;
- protected procedure SetGroups ( const AValue : TGorillaSkillGroupCollection ) ;
- public procedure SaveToStream
(
const
AStream :
TStream
)
;
virtual;
Stores the current skill system to stream as xml-format. Including all groups with skills and currently active leveling processes.
- public procedure SaveToFile
(
const
AFilename :
string
)
;
virtual;
Stores the current skill system to file as xml-format. Including all groups with skills and currently active leveling processes.
- public procedure LoadFromStream
(
const
AStream :
TStream
)
;
virtual;
Loads the skill system from xml formatted stream. Including all groups with skills and currently active leveling processes.
- public procedure LoadFromFile
(
const
AFilename :
string
)
;
virtual;
Loads the skill system from xml file. Including all groups with skills and currently active leveling processes.
- public function GetCurrentLanguageId
(
)
: string
;
virtual;
Returns the current language id depending on the set language value.
- public function AddGroup
(
)
: TGorillaSkillGroup
;
virtual;
Adds and returns a new skill group to the system.
- public procedure RemoveGroup
(
const
AGroup :
TGorillaSkillGroup
)
;
virtual;
Removes an existing skill group from system.
- public function FindSkillByGUID
(
const
AGUID :
TGUID
)
: TGorillaSkill
;
virtual;
Tries to find a specific skill by its unique guid. If no skill with this guid could be found, the method returns null.