-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathWorldManager.h
95 lines (73 loc) · 2.94 KB
/
WorldManager.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef __WORLD_MANAGER_H__
#define __WORLD_MANAGER_H__
#include "Manager.h"
#include "ObjectList.h"
# define WM df :: WorldManager :: getInstance ()
const int MAX_ALTITUDE = 4;
namespace df {
class WorldManager :
public Manager
{
private:
WorldManager();
WorldManager(WorldManager const&);
void operator=(WorldManager const&);
ObjectList m_updates;
ObjectList m_deletions;
ObjectList m_objects_out;
Box boundary; // World boundary.
Box view; // Player view of game world.
Object* p_view_following;//Object view is following
public:
//Get the one and only instance of the WorldManager
static WorldManager& getInstance();
//Starts the game world and initializes everything to empty
int startUp();
//Shuts down the game world and deletes all world Objects
void shutDown();
//Insert Object into the world
//Return 0 if ok, otherwise -1
int insertObject(Object* p_o);
//Remove Objects from the world
//Return 0 if ok, otherwise -1
int removeObject(Object* p_o);
//Return list of all Objects in the world
ObjectList getAllObjects() const;
//Return list of all Objects in world matching type
ObjectList objectsOfType(std::string type) const;
//Update world
//Delete Objects marked for deletion
void update();
//Indicate Object is to be deleted at end of current game loop
//Return 0 if ok, else -1
int markForDelete(Object* p_o);
//Draws all objects in m_updates
void draw();
//Returns list of Object collided with at position where
//Collisions are only with solid Objects
//Does not consider if p_o is solid or not
ObjectList getCollisions(Object* p_o, Vector where) const;
//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
//Return 0 if move ok, else -1 if collision with solid
int moveObject(Object* p_o, Vector where);
// Set game world boundary.
void setBoundary(Box new_boundary);
// Get game world boundary.
Box getBoundary() const;
// Set player view of game world.
void setView(Box new_view);
// Get player view of game world.
Box getView() const;
// Set view to center window on position view_pos.
// View edge will not go beyond world boundary.
void setViewPosition(Vector view_pos);
// Set view to center window on Object.
// Set to NULL to stop following.
// If p_new_view_following not legit, return -1 else return 0.
int setViewFollowing(Object* p_new_view_following);
};
}
#endif