duncan
Mom and Dad were wrong!
Public Types | Public Member Functions | Public Attributes
server::NPC Class Reference

#include <npc.h>

Inheritance diagram for server::NPC:
Inheritance graph
[legend]
Collaboration diagram for server::NPC:
Collaboration graph
[legend]

List of all members.

Public Types

typedef std::vector< std::pair
< size_t, size_t > > 
path_t
 Duplicated with client...!

Public Member Functions

 NPC (std::pair< size_t, size_t >, std::pair< size_t, size_t >)
void update ()
size_t destr ()
size_t destc ()
void set_path (const path_t &)
void set_path (const std::list< std::pair< size_t, size_t > > &)
bool should_snap ()
std::pair< double, double > desired_pos ()
void snapped ()

Public Attributes

double last_path_send

Detailed Description

Represents a non-player character.

Author:
Malcolm Gill

see LICENSE


Constructor & Destructor Documentation

NPC::NPC ( std::pair< size_t, size_t >  start,
std::pair< size_t, size_t >  end 
)

Set the two route waypoints for this NPC.

Parameters:
startinitial waypoint
endfinal waypoint

Member Function Documentation

std::pair< double, double > NPC::desired_pos ( )
Returns:
desired position coordinates (r,c) for this NPC, if should_snap().
size_t NPC::destc ( )
Returns:
column to which this NPC currently wants to get
size_t NPC::destr ( )
Returns:
row to which this NPC currently wants to get
void NPC::set_path ( const path_t path)

Tells this NPC to start following the given path.

void NPC::set_path ( const std::list< std::pair< size_t, size_t > > &  path)

Tells this NPC to start following the given path.

bool NPC::should_snap ( )
Returns:
true iff this npc wants his position to be set specially by the server
void NPC::snapped ( )

Please call this after setting this NPC's position to desired_pos() please.

void NPC::update ( )

Makes this NPC follow his path. Must be called frequently enough to prevent overshooting by >kTolerance, but as long as NPCs are quite slow, this shouldn't be very demanding...


The documentation for this class was generated from the following files:
 All Classes Namespaces Functions Variables Typedefs Enumerations