|
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. More... | |
| void | Advance (csTicks delta, NPC *npc) |
| Advances the behaviors. More... | |
| BehaviorSet () | |
| Constructor. More... | |
| void | ClearState (NPC *npc) |
| Prepare the set after use. More... | |
| void | DeepCopy (BehaviorSet &other) |
| Do a deap copy. More... | |
| void | DumpBehaviorList (csString &output, NPC *npc) |
| Dump the behavior list for debug. More... | |
| void | Execute (NPC *npc, bool forceRunScript) |
| Execute script operations. More... | |
| Behavior * | Find (const char *name) |
| Find a behavior in the set. More... | |
| Behavior * | GetCurrentBehavior () |
| Return current active behavior. More... | |
| float | GetHighestNeed (NPC *npc) |
| Return hight current or new need. More... | |
| csString | InfoBehaviors (NPC *npc) |
| Info about the behavior list for debug. More... | |
| void | Interrupt (NPC *npc) |
| Interrupt the current active behavior. More... | |
| Behavior * | Schedule (NPC *npc) |
| Rearrange the behavior set based on need. More... | |
| void | UpdateNeeds (float delta, NPC *npc) |
| Update needs for all behaviors. More... | |
Protected Attributes | |
| Behavior * | active |
| Points to the current active behavior. More... | |
| csPDelArray< Behavior > | behaviors |
| The set of behavoirs for this NPCType. More... | |
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. |
|
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. |
|
protected |
Points to the current active behavior.
Definition at line 73 of file npcbehave.h.
|
protected |
The set of behavoirs for this NPCType.
Definition at line 72 of file npcbehave.h.