Planeshift
Public Member Functions | Protected Attributes

BehaviorSet Class Reference

This is the set of Behaviors available for an NPC. More...

#include <npcbehave.h>

List of all members.

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.
BehaviorFind (const char *name)
 Find a behavior in the set.
BehaviorGetCurrentBehavior ()
 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.
BehaviorSchedule (NPC *npc)
 Rearrange the behavior set based on need.
void UpdateNeeds (float delta, NPC *npc)
 Update needs for all behaviors.

Protected Attributes

Behavioractive
 Points to the current active behavior.
csPDelArray< Behaviorbehaviors
 The set of behavoirs for this NPCType.

Detailed Description

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.


Constructor & Destructor Documentation

BehaviorSet::BehaviorSet ( )

Constructor.


Member Function Documentation

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.

Parameters:
behaviorThe new behavior to be added to this BehaviorSet.
Returns:
Returns true if the behavior didn't already exist. Otherwise returns false and substitude the existing duplicate behavior.
void BehaviorSet::Advance ( csTicks  delta,
NPC npc 
)

Advances the behaviors.

Will calculate the need and select the active behavior.

Parameters:
deltaThe numbers of ticks to advance this set.
npcThe 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.

Parameters:
npcThe 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.

Parameters:
otherThe source to be copied into this set.
void BehaviorSet::DumpBehaviorList ( csString &  output,
NPC npc 
)

Dump the behavior list for debug.

Parameters:
npcThe 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.

Parameters:
npcThe NPC that own this BehaviorSet.
forceRunScriptForce 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.

Parameters:
nameThe name of the behavior to find.
Returns:
The found behavior or NULL if no behavior is found.
Behavior* BehaviorSet::GetCurrentBehavior ( ) [inline]

Return current active behavior.

Definition at line 167 of file npcbehave.h.

float BehaviorSet::GetHighestNeed ( NPC npc)

Return hight current or new need.

csString BehaviorSet::InfoBehaviors ( NPC npc)

Info about the behavior list for debug.

Parameters:
npcThe 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.

Parameters:
npcThe NPC that own this BehaviorSet.
Behavior* BehaviorSet::Schedule ( NPC npc)

Rearrange the behavior set based on need.

Parameters:
npcThe NPC that own this BehaviorSet.
void BehaviorSet::UpdateNeeds ( float  delta,
NPC npc 
)

Update needs for all behaviors.

Increase or decrease needs depended on the behaviors active state.

Parameters:
deltaThe delta to add to the need for this behavior.
npcThe NPC that own this BehaviorSet.

Member Data Documentation

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.


The documentation for this class was generated from the following file: