Planeshift
Public Member Functions | Protected Attributes

Perception Class Reference

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

#include <perceptions.h>

List of all members.

Public Member Functions

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

Protected Attributes

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

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 58 of file perceptions.h.


Constructor & Destructor Documentation

Perception::Perception ( const char *  name) [inline]

Constructor.

Parameters:
nameThe name of the perception.

Definition at line 71 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 79 of file perceptions.h.

virtual Perception::~Perception ( ) [inline, virtual]

Destructor.

Definition at line 84 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 FactionPerception, AttackPerception, GroupAttackPerception, DamagePerception, SpellPerception, DeathPerception, OwnerCmdPerception, and OwnerActionPerception.

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 LocationPerception, PositionPerception, and InventoryPerception.

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 [inline, virtual]

Get the radius of the perception.

Reimplemented in LocationPerception, PositionPerception, and InventoryPerception.

Definition at line 163 of file perceptions.h.

virtual gemNPCObject* Perception::GetTarget ( ) [inline, virtual]

Some perception has a target/source.

See also:
DamagePerception
Returns:
the target of this perception.

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

Definition at line 118 of file perceptions.h.

const csString& Perception::GetType ( ) const

Get the type of the perception.

Returns:
the type of the perception.
virtual Perception* Perception::MakeCopy ( ) [virtual]
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 TimePerception, FactionPerception, SpellPerception, OwnerCmdPerception, OwnerActionPerception, and NPCCmdPerception.

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 61 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 63 of file perceptions.h.


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