Planeshift
Perception Class Reference

This embodies any perception an NPC might have, or any game event of interest. More...

#include <perceptions.h>

Public Member Functions

virtual void ExecutePerception (NPC *npc, float weight)
 All preconditions has been checked, now excecute the perception. More...
 
virtual bool GetLocation (csVector3 &pos, iSector *&sector)
 Get a location assosiated with the perception. More...
 
virtual const csString & GetName () const
 Get the name of the perception. More...
 
virtual float GetRadius () const
 Get the radius of the perception. More...
 
virtual gemNPCObjectGetTarget ()
 Some perception has a target/source. More...
 
const csString & GetType () const
 Get the type of the perception. More...
 
virtual PerceptionMakeCopy ()
 Make a copy of this perception. More...
 
 Perception (const char *name)
 Constructor. More...
 
 Perception (const char *name, const char *type)
 Constructor. More...
 
void SetType (const char *type)
 Set the type of the perception. More...
 
virtual bool ShouldReact (Reaction *reaction, NPC *npc)
 Check if this perception should react to a reaction. More...
 
virtual csString ToString (NPC *npc)
 Get a text description of the perception. More...
 
virtual ~Perception ()
 Destructor. More...
 

Protected Attributes

csString name
 The name of this perception. More...
 
csString type
 Type used by perceptions. Usally they correspond to the same value in a reaction. More...
 

Detailed Description

This embodies any perception an NPC might have, or any game event of interest.

Reaction objects below will subscribe to these events, and the networking system will publish them. Examples would be "attacked", "collided", "talked to", "hear cry".

Definition at line 55 of file perceptions.h.

Constructor & Destructor Documentation

Perception::Perception ( const char *  name)
inline

Constructor.

Parameters
nameThe name of the perception.

Definition at line 68 of file perceptions.h.

Perception::Perception ( const char *  name,
const char *  type 
)
inline

Constructor.

Parameters
nameThe name of the perception.
typeThe type for this perception.

Definition at line 76 of file perceptions.h.

virtual Perception::~Perception ( )
inlinevirtual

Destructor.

Definition at line 81 of file perceptions.h.

Member Function Documentation

virtual void Perception::ExecutePerception ( NPC npc,
float  weight 
)
virtual

All preconditions has been checked, now excecute the perception.

Parameters
npcThe target of the percpetion.
weightIndicate how much the HateList of the npc should be changed. Value comes from the reaction.

Reimplemented in OwnerActionPerception, OwnerCmdPerception, DeathPerception, SpellPerception, DamagePerception, GroupAttackPerception, AttackPerception, and FactionPerception.

virtual bool Perception::GetLocation ( csVector3 &  pos,
iSector *&  sector 
)
virtual

Get a location assosiated with the perception.

Some perception might hold a location. Default impl get location from target if there is one.

Parameters
posThe position of the location.
sectorThe sector of the location.
Returns
true if there where a location.

Reimplemented in InventoryPerception, PositionPerception, and LocationPerception.

virtual const csString& Perception::GetName ( ) const
virtual

Get the name of the perception.

This name has to be const since it is used in the registered reaction chache to find the reactions and npcs that should have this perception.

Returns
the name of the perception.
virtual float Perception::GetRadius ( ) const
inlinevirtual

Get the radius of the perception.

Reimplemented in InventoryPerception, PositionPerception, and LocationPerception.

Definition at line 160 of file perceptions.h.

virtual gemNPCObject* Perception::GetTarget ( )
inlinevirtual

Some perception has a target/source.

See also
DamagePerception
Returns
the target of this perception.

Reimplemented in OwnerCmdPerception, SpellPerception, DamagePerception, AttackPerception, ItemPerception, and FactionPerception.

Definition at line 115 of file perceptions.h.

const csString& Perception::GetType ( ) const

Get the type of the perception.

Returns
the type of the perception.
void Perception::SetType ( const char *  type)

Set the type of the perception.

In most cases this can be done through the constructor Perception::Perception(const char*,const char*).

virtual bool Perception::ShouldReact ( Reaction reaction,
NPC npc 
)
virtual

Check if this perception should react to a reaction.

Parameters
reactionThe reaction to check for.
npcThe NPC that might receive this.
Returns
true if reaction should be reacted to.

Reimplemented in NPCCmdPerception, OwnerActionPerception, OwnerCmdPerception, SpellPerception, FactionPerception, and TimePerception.

virtual csString Perception::ToString ( NPC npc)
virtual

Get a text description of the perception.

Reimplemented in TimePerception.

Member Data Documentation

csString Perception::name
protected

The name of this perception.

Definition at line 58 of file perceptions.h.

csString Perception::type
protected

Type used by perceptions. Usally they correspond to the same value in a reaction.

Definition at line 60 of file perceptions.h.


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