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

All plyGame characters must have the Actor component. It contains the definitions and general info on the character. More...

Inherits MonoBehaviour, and plyGame.IPersistable.

Public Member Functions

void Save (string key)
 
void Load (string key)
 
void DeleteSaveData (string key)
 
void DisablePersistence ()
 
virtual Skill LearnSkill (UniqueID skillId, bool suppressLog)
 Add Skill to list of known Skills. Return reference to the new Skill object. Returns null on error. More...
 
virtual Skill LearnSkill (Skill skill, bool suppressLog)
 Add Skill to list of known Skills. Return reference to the new Skill object, Returns null on error. More...
 
virtual void UnlearnSkill (UniqueID skillId)
 Remove a skill from the list of skills the actor knows. Will silently fail if error. More...
 
virtual void UnlearnSkill (Skill skill)
 Remove a skill from the list of skills the actor knows. Will silently fail if error. More...
 
virtual bool KnowSkill (UniqueID skillId)
 Return True if Skill is in list of known skills. More...
 
virtual bool KnowSkill (Skill skill)
 Return True if Skill is in list of known skills. More...
 
virtual Skill GetKnownSkill (UniqueID skillId)
 Return the known skill else null if not known. More...
 
virtual Skill GetKnownSkill (Skill skill)
 Return the known skill else null if not known. More...
 
virtual bool QueueSkillForExecution (Skill skill, bool autoLearn)
 Queue Skill to be used as soon as possible. Return false if the Skill is not known. Could still fail to execute the skill if the Actor unlearn it before it is executed. More...
 
virtual bool QueueSkillForExecution (UniqueID skillId, bool autoLearn)
 Queue Skill to be used as soon as possible. Return false if the Skill is not known. Could still fail to execute the skill if the Actor unlearn it before it is executed. More...
 
virtual void QueueSkillForExecution (Skill skill)
 Queue Skill to be used as soon as possible. Does not check if the Actor knows the skill so be sure to check before you queue it. Could still fail to execute the skill if it the Actor unlearn it before it is executed. More...
 
void ClearQueuedSkill ()
 Clear queued skill More...
 
void JoinFaction (UniqueID factionId, bool suppressLog)
 Let Actor Join faction More...
 
void LeaveFaction (UniqueID factionId, bool suppressLog)
 Let Actor Leave faction More...
 
ActorFaction GetActorFaction (UniqueID factionId)
 return reference to faction if actor in it, else null More...
 
StatusTowardsOther HighestStatusToTarget (Actor target)
 Returns the "highest" status of this Actor towards the target via the Factions that both belongs to. Status goes up from Friendly at lowest level, then Neutral, and then Hostile being highest. The check is not two-way, meaning the status of the target Actor's Factions are not test against the Factions of this Actor. This Actor's Faction statuses is only checked against the Factions of the target Actor. So a Faction can be friendly towards another while the other Faction might be Hostile to it. Return Friendly if this Actor or Target is in no Factions. Will also check statusTowardsPlayer if target is player More...
 
void Kill ()
 Call this to kill the Actor. Its HP attribute (if used) will be forced to 0 and it will be set in death state More...
 
void ReceivedMoveCommand ()
 Called by the player controller to inform the Actor that the player pressed some keys used to move the character. This is so the Actor can check whether a queued skill, waiting to execute, might need to be canceled. More...
 
string ObjectPrettyName ()
 
bool IsDead ()
 Return true if the actor is dead. Will only function properly if the Health attribute is configured and the Actor Class has the same attribute in its list of attributes. If Health is not configured then this will always return false. More...
 

Public Attributes

bool persistenceOn = true
 
bool persistActorData = true
 
bool persistClass = false
 
bool persistKnowSkills = false
 
bool persistFactions = false
 
UniqueID id = new UniqueID()
 Unique Id of the Actor. Same for all instances of same Actor/ Character prefab.
 
CommonDefinitionData def = new CommonDefinitionData()
 common data
 
UniqueID classId = new UniqueID()
 Id of the actor class this Actor uses.
 
int startLevel = 1
 Level to initialize this Actor to.
 
bool overwriteStatus = false
 uses statusTowardsPlayer if true
 
StatusTowardsOther statusTowardsPlayer = StatusTowardsOther.Friendly
 Status of the Actor (normally NPC) towards the player.
 
bool essential = false
 set to true to hint that this actor should not be killed
 
List< UniqueIDstartFactions = new List<UniqueID>(0)
 Ids of the faction this Actor is associated with at start.
 
List< UniqueIDstartSkills = new List<UniqueID>(0)
 Ids of the Skills this Actor starts with.
 
bool autoDetectDeath = true
 Should Actor auto handle HP reaching 0?
 
ObjectDestroyerHandler objectDestroyer = new ObjectDestroyerHandler()
 Used to perform object destroy when Kill() is called.
 
List< Component > disableOnDeath = new List<Component>(0)
 What additional components should be disabled? Actor already disable various components related to characters by default.
 

Protected Member Functions

void Reset ()
 
void Awake ()
 
IEnumerator Start ()
 
void Update ()
 
void LateUpdate ()
 

Properties

ActorClass actorClass [get, set]
 Instance of the actor class used by this Actor More...
 
ItemBag bag [get, set]
 Cached reference to Bag so it is quicker to get to without having to lookup the Bag component teach time. Note, can be null. More...
 
CharacterControllerBase character [get]
 Reference to the plyGame character controller of this actor/ character More...
 
List< SkillknownSkills [get, set]
 List of skills (instantiated) this Actor knows. More...
 
List< ActorFactionfactions [get, set]
 The Factions that this Actor is associated with. More...
 
Skill executingSkill [get, set]
 
Skill queuedSkill [get, set]
 

Detailed Description

All plyGame characters must have the Actor component. It contains the definitions and general info on the character.

Member Function Documentation

void plyGame.Actor.ClearQueuedSkill ( )

Clear queued skill

ActorFaction plyGame.Actor.GetActorFaction ( UniqueID  factionId)

return reference to faction if actor in it, else null

virtual Skill plyGame.Actor.GetKnownSkill ( UniqueID  skillId)
virtual

Return the known skill else null if not known.

virtual Skill plyGame.Actor.GetKnownSkill ( Skill  skill)
virtual

Return the known skill else null if not known.

StatusTowardsOther plyGame.Actor.HighestStatusToTarget ( Actor  target)

Returns the "highest" status of this Actor towards the target via the Factions that both belongs to. Status goes up from Friendly at lowest level, then Neutral, and then Hostile being highest. The check is not two-way, meaning the status of the target Actor's Factions are not test against the Factions of this Actor. This Actor's Faction statuses is only checked against the Factions of the target Actor. So a Faction can be friendly towards another while the other Faction might be Hostile to it. Return Friendly if this Actor or Target is in no Factions. Will also check statusTowardsPlayer if target is player

bool plyGame.Actor.IsDead ( )

Return true if the actor is dead. Will only function properly if the Health attribute is configured and the Actor Class has the same attribute in its list of attributes. If Health is not configured then this will always return false.

void plyGame.Actor.JoinFaction ( UniqueID  factionId,
bool  suppressLog 
)

Let Actor Join faction

Parameters
factionIdId of the faction.
suppressLogSet true if no error messages should be printed.
void plyGame.Actor.Kill ( )

Call this to kill the Actor. Its HP attribute (if used) will be forced to 0 and it will be set in death state

virtual bool plyGame.Actor.KnowSkill ( UniqueID  skillId)
virtual

Return True if Skill is in list of known skills.

virtual bool plyGame.Actor.KnowSkill ( Skill  skill)
virtual

Return True if Skill is in list of known skills.

virtual Skill plyGame.Actor.LearnSkill ( UniqueID  skillId,
bool  suppressLog 
)
virtual

Add Skill to list of known Skills. Return reference to the new Skill object. Returns null on error.

virtual Skill plyGame.Actor.LearnSkill ( Skill  skill,
bool  suppressLog 
)
virtual

Add Skill to list of known Skills. Return reference to the new Skill object, Returns null on error.

void plyGame.Actor.LeaveFaction ( UniqueID  factionId,
bool  suppressLog 
)

Let Actor Leave faction

Parameters
factionIdId of the faction.
suppressLogSet true if no error messages should be printed.
virtual bool plyGame.Actor.QueueSkillForExecution ( Skill  skill,
bool  autoLearn 
)
virtual

Queue Skill to be used as soon as possible. Return false if the Skill is not known. Could still fail to execute the skill if the Actor unlearn it before it is executed.

virtual bool plyGame.Actor.QueueSkillForExecution ( UniqueID  skillId,
bool  autoLearn 
)
virtual

Queue Skill to be used as soon as possible. Return false if the Skill is not known. Could still fail to execute the skill if the Actor unlearn it before it is executed.

virtual void plyGame.Actor.QueueSkillForExecution ( Skill  skill)
virtual

Queue Skill to be used as soon as possible. Does not check if the Actor knows the skill so be sure to check before you queue it. Could still fail to execute the skill if it the Actor unlearn it before it is executed.

void plyGame.Actor.ReceivedMoveCommand ( )

Called by the player controller to inform the Actor that the player pressed some keys used to move the character. This is so the Actor can check whether a queued skill, waiting to execute, might need to be canceled.

virtual void plyGame.Actor.UnlearnSkill ( UniqueID  skillId)
virtual

Remove a skill from the list of skills the actor knows. Will silently fail if error.

virtual void plyGame.Actor.UnlearnSkill ( Skill  skill)
virtual

Remove a skill from the list of skills the actor knows. Will silently fail if error.

Property Documentation

ActorClass plyGame.Actor.actorClass
getset

Instance of the actor class used by this Actor

ItemBag plyGame.Actor.bag
getset

Cached reference to Bag so it is quicker to get to without having to lookup the Bag component teach time. Note, can be null.

CharacterControllerBase plyGame.Actor.character
get

Reference to the plyGame character controller of this actor/ character

List<ActorFaction> plyGame.Actor.factions
getset

The Factions that this Actor is associated with.

List<Skill> plyGame.Actor.knownSkills
getset

List of skills (instantiated) this Actor knows.