Dragonfly  4.3
A text-based game engine
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
df::WorldManager Class Reference
Inheritance diagram for df::WorldManager:
Inheritance graph
Collaboration diagram for df::WorldManager:
Collaboration graph

Public Member Functions

int startUp ()
void shutDown ()
bool isValid (std::string event_type) const
int insertObject (Object *p_o)
int removeObject (Object *p_o)
ObjectList getAllObjects (bool inactive=false) const
int markForDelete (Object *p_o)
int markForDelete (ObjectList obj_list)
void update ()
void draw ()
int moveObject (Object *p_o, Vector where)
ObjectList isCollision (const Object *p_o, Vector where) const
ObjectobjectWithId (int id) const
ObjectList objectsOfType (std::string type) const
ObjectList objectsAtPosition (Vector where) const
ObjectList objectsInBox (Box box) const
ObjectList objectsOnLine (Line line) const
ObjectList objectsInCircle (Circle circle) const
Box getBoundary () const
void setBoundary (Box new_boundary)
Box getView () const
void setView (Box new_view)
Vector getViewSlack () const
void setViewSlack (Vector new_slack)
int setViewFollowing (Object *p_new_view_following)
ObjectgetViewFollowing () const
void setViewPosition (Vector view_pos)
SceneGraphgetSceneGraph () const
- Public Member Functions inherited from df::Manager
std::string getType () const
bool isStarted () const
int onEvent (const Event *p_event) const
int registerInterest (Object *p_o, std::string event_type)
int unregisterInterest (Object *p_o, std::string event_type)

Static Public Member Functions

static WorldManagergetInstance ()

Private Member Functions

 WorldManager ()
 WorldManager (WorldManager const &)
void operator= (WorldManager const &)

Private Attributes

SceneGraph m_scene_graph
ObjectList m_deletions
Box m_boundary
Box m_view
Vector m_view_slack

Additional Inherited Members

- Protected Member Functions inherited from df::Manager
void setType (std::string new_type)

Constructor & Destructor Documentation

df::WorldManager::WorldManager ( )

Private since a singleton.

df::WorldManager::WorldManager ( WorldManager const &  )

Don't allow copy.

Member Function Documentation

void df::WorldManager::draw ( )

Draw all Objects in view.

Draw bottom up, from 0 to MAX_ALTITUDE.

ObjectList df::WorldManager::getAllObjects ( bool  inactive = false) const

Return list of all Objects in world.

If inactive is true, include inactive Objects.

Box df::WorldManager::getBoundary ( ) const

Get game world boundary.

static WorldManager& df::WorldManager::getInstance ( )

Get the one and only instance of the WorldManager.

SceneGraph& df::WorldManager::getSceneGraph ( ) const

Return reference to SceneGraph.

Box df::WorldManager::getView ( ) const

Get player view of game world.

Object* df::WorldManager::getViewFollowing ( ) const

Get Object view is following (NULL if none).

Vector df::WorldManager::getViewSlack ( ) const

Get player "slack" for view following.

int df::WorldManager::insertObject ( Object p_o)

Add Object to world.

Return 0 if ok, else -1.

ObjectList df::WorldManager::isCollision ( const Object p_o,
Vector  where 
) const

Return list of Objects collided with at position 'where'.

Collisions only with solid Objects. Does not consider if p_o is solid or not.

bool df::WorldManager::isValid ( std::string  event_type) const

Accept all user-defined events (returns true).

Return false for other engine events.

Reimplemented from df::Manager.

int df::WorldManager::markForDelete ( Object p_o)

Indicate Object is to be deleted at end of current game loop.

Return 0 if ok, else -1.

int df::WorldManager::markForDelete ( ObjectList  obj_list)

Indicate Objects in list are to be deleted at end of current game loop.

Return 0 if ok, else -1.

int df::WorldManager::moveObject ( Object p_o,
Vector  where 

Move Object.

If collision with solid, send collision events. If no collision with solid, move ok else don't move Object. If Object is Spectral, move ok. If move ok, adjust screen if following this Object. If moved from inside world boundary to outside, generate EventOut. Return 0 if move ok, else -1 if collision with solid.

ObjectList df::WorldManager::objectsAtPosition ( Vector  where) const

Return list of all Objects at position 'where'.

Does include bounding boxes. Return empty list if none found.

ObjectList df::WorldManager::objectsInBox ( Box  box) const

Return list of all Objects in Box.

Does include bounding boxes. Return empty list if none found.

ObjectList df::WorldManager::objectsInCircle ( Circle  circle) const

Return a list of all Objects in circle.

Does include bounding boxes. Return empty list if none found.

ObjectList df::WorldManager::objectsOfType ( std::string  type) const

Return list of Objects matching type.

List is empty if none found.

ObjectList df::WorldManager::objectsOnLine ( Line  line) const

Return a list of all Objects on line from point1 to point2.

Does include bounding boxes. Return empty list if none found.

Object* df::WorldManager::objectWithId ( int  id) const

Return Object with indicated id.

NULL if Object is not found.

void df::WorldManager::operator= ( WorldManager const &  )

Don't allow assignment.

int df::WorldManager::removeObject ( Object p_o)

Remove Object from world.

Return 0 if ok, else -1.

void df::WorldManager::setBoundary ( Box  new_boundary)

Set game world boundary.

void df::WorldManager::setView ( Box  new_view)

Set player view of game world.

int df::WorldManager::setViewFollowing ( Object p_new_view_following)

Set view to center screen on Object.

Set to NULL to stop following. If Object not legit, return -1 else return 0.

void df::WorldManager::setViewPosition ( Vector  view_pos)

Set view to center screen on position view_pos.

View edge will not go beyond world boundary.

void df::WorldManager::setViewSlack ( Vector  new_slack)

Set player "slack" for view following.

void df::WorldManager::shutDown ( )

Shutdown game world (delete all game world Objects).

Reimplemented from df::Manager.

int df::WorldManager::startUp ( )

Startup game world (initialize everything to empty).

Return 0.

Reimplemented from df::Manager.

void df::WorldManager::update ( )

Update world.

Update positions of Objects based on their velocities. Lastly, delete Objects marked for deletion.

Member Data Documentation

Box df::WorldManager::m_boundary

World boundary.

ObjectList df::WorldManager::m_deletions

List of all Objects to delete.

Object* df::WorldManager::m_p_view_following

Object view is following.

SceneGraph df::WorldManager::m_scene_graph

Storage for all Objects, game and view.

Box df::WorldManager::m_view

Player view of game world.

Vector df::WorldManager::m_view_slack

"Slack" for view following.