Planeshift
|
This is the set of Behaviors available for an NPC. More...
#include <npcbehave.h>
Public Member Functions | |
bool | Add (Behavior *behavior) |
Add a behavior to the brain. | |
void | Advance (csTicks delta, NPC *npc) |
Advances the behaviors. | |
BehaviorSet () | |
Constructor. | |
void | ClearState (NPC *npc) |
Prepare the set after use. | |
void | DeepCopy (BehaviorSet &other) |
Do a deap copy. | |
void | DumpBehaviorList (csString &output, NPC *npc) |
Dump the behavior list for debug. | |
void | Execute (NPC *npc, bool forceRunScript) |
Execute script operations. | |
Behavior * | Find (const char *name) |
Find a behavior in the set. | |
Behavior * | GetCurrentBehavior () |
Return current active behavior. | |
float | GetHighestNeed (NPC *npc) |
Return hight current or new need. | |
csString | InfoBehaviors (NPC *npc) |
Info about the behavior list for debug. | |
void | Interrupt (NPC *npc) |
Interrupt the current active behavior. | |
Behavior * | Schedule (NPC *npc) |
Rearrange the behavior set based on need. | |
void | UpdateNeeds (float delta, NPC *npc) |
Update needs for all behaviors. | |
Protected Attributes | |
Behavior * | active |
Points to the current active behavior. | |
csPDelArray< Behavior > | behaviors |
The set of behavoirs for this NPCType. |
This is the set of Behaviors available for an NPC.
This is a collection of behaviors for a particular type of NPC. They represents the behaviors that this NPC is capable of.
Definition at line 69 of file npcbehave.h.
BehaviorSet::BehaviorSet | ( | ) |
Constructor.
bool BehaviorSet::Add | ( | Behavior * | behavior | ) |
Add a behavior to the brain.
Add a new behavior to the set. If a behavior with the same name exists, than the new behavior will substitude the existing behavior. This to support the nested structure of the behavoir scripts.
behavior | The new behavior to be added to this BehaviorSet. |
void BehaviorSet::Advance | ( | csTicks | delta, |
NPC * | npc | ||
) |
Advances the behaviors.
Will calculate the need and select the active behavior.
delta | The numbers of ticks to advance this set. |
npc | The NPC that own this BehaviorSet. |
void BehaviorSet::ClearState | ( | NPC * | npc | ) |
Prepare the set after use.
Called when the npc actor is deleted. Should reset all session depended stats. So that a new instance of the actor for the npc can start with a fresh brain.
npc | The NPC that own this BehaviorSet. |
void BehaviorSet::DeepCopy | ( | BehaviorSet & | other | ) |
Do a deap copy.
Will do a deap copy of the BehaviorSet. The NPCType will contain a complete BehaviorSet for each type. When a new NPC is instantiated a deap copy of the set will be done before assigning it to the new NPC.
other | The source to be copied into this set. |
void BehaviorSet::DumpBehaviorList | ( | csString & | output, |
NPC * | npc | ||
) |
Dump the behavior list for debug.
npc | The NPC that own this BehaviorSet. |
void BehaviorSet::Execute | ( | NPC * | npc, |
bool | forceRunScript | ||
) |
Execute script operations.
Will run script operations until they loop, fail, or need more time.
npc | The NPC that own this BehaviorSet. |
forceRunScript | Force running the script. |
Behavior* BehaviorSet::Find | ( | const char * | name | ) |
Find a behavior in the set.
Search the set for a behavior maching the given name.
name | The name of the behavior to find. |
Behavior* BehaviorSet::GetCurrentBehavior | ( | ) | [inline] |
Return current active behavior.
Definition at line 167 of file npcbehave.h.
csString BehaviorSet::InfoBehaviors | ( | NPC * | npc | ) |
Info about the behavior list for debug.
npc | The NPC that own this BehaviorSet. |
void BehaviorSet::Interrupt | ( | NPC * | npc | ) |
Interrupt the current active behavior.
If there is an active behavior in this set that behavior will be interrupted by calling this function.
npc | The NPC that own this BehaviorSet. |
Rearrange the behavior set based on need.
npc | The NPC that own this BehaviorSet. |
Update needs for all behaviors.
Increase or decrease needs depended on the behaviors active state.
delta | The delta to add to the need for this behavior. |
npc | The NPC that own this BehaviorSet. |
Behavior* BehaviorSet::active [protected] |
Points to the current active behavior.
Definition at line 73 of file npcbehave.h.
csPDelArray<Behavior> BehaviorSet::behaviors [protected] |
The set of behavoirs for this NPCType.
Definition at line 72 of file npcbehave.h.