Dragonfly 4.20
A text-based game engine
|
Public Member Functions | |
int | startUp () override |
void | shutDown () override |
bool | isValid (std::string event_type) const override |
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 | getCollisions (Object *p_o, Vector where) const |
Object * | objectWithId (int id) const |
ObjectList | objectsOfType (std::string type) |
ObjectList | objectsAtPosition (Vector where) const |
ObjectList | objectsInBox (Box box) const |
ObjectList | objectsOnLine (Line line) const |
ObjectList | objectsInCircle (Circle circle) const |
ObjectList | solidObjects () 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) |
Object * | getViewFollowing () const |
void | setViewPosition (Vector view_pos) |
SceneGraph & | getSceneGraph () const |
Public Member Functions inherited from df::Manager | |
std::string | getType () const |
virtual int | startUp () |
virtual void | shutDown () |
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 WorldManager & | getInstance () |
Private Member Functions | |
WorldManager () | |
WorldManager (WorldManager const &) | |
void | operator= (WorldManager const &) |
Private Attributes | |
SceneGraph | m_scene_graph |
ObjectList | m_deletions |
Object * | m_p_view_following |
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) |
|
private |
Private since a singleton.
|
private |
Don't allow copy.
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.
ObjectList df::WorldManager::getCollisions | ( | 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.
|
static |
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.
Vector df::WorldManager::getViewSlack | ( | ) | const |
Get player "slack" for view following.
Units are in fraction of view (0-1).
|
overridevirtual |
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.
Move Object.
If collision with solid, send collision events. If no collision with solid, move ok. If all collided objects soft, move ok. If Object is spectral, move ok. If move ok, move. If moved, adjust view if following this Object. If moved from inside world boundary to outside, generate EventOut. Return 0 if moved, 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 | ) |
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 |
|
private |
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 | ) |
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.
Units are in fraction of view (0-1).
|
overridevirtual |
Shutdown game world (delete all game world Objects).
Reimplemented from df::Manager.
|
overridevirtual |
void df::WorldManager::update | ( | ) |
Update world.
Update positions of Objects based on their velocities. Lastly, delete Objects marked for deletion.
|
private |
World boundary.
|
private |
List of all Objects to delete.
|
private |
Storage for all Objects, game and view.
|
private |
Player view of game world.
|
private |
"Slack" for view following.