Last change
on this file since 2101 was
2101,
checked in by chris, 20 years ago
|
orxonox/branches/chris: Finished the "GETITTOCOMPILE" project… compiling should work now, but linking is a different story
|
File size:
1.5 KB
|
Line | |
---|
1 | |
---|
2 | #ifndef WORLD_H |
---|
3 | #define WORLD_H |
---|
4 | |
---|
5 | #include "stdincl.h" |
---|
6 | |
---|
7 | class Track; |
---|
8 | class WorldEntity; |
---|
9 | |
---|
10 | class World { |
---|
11 | |
---|
12 | public: |
---|
13 | World (); |
---|
14 | ~World (); |
---|
15 | |
---|
16 | template<typename T> |
---|
17 | T* spawn(Location* loc, WorldEntity* owner); // template to be able to spawn any derivation of WorldEntity |
---|
18 | template<typename T> |
---|
19 | T* spawn(Placement* plc, WorldEntity* owner); |
---|
20 | |
---|
21 | void time_slice (Uint32 deltaT); |
---|
22 | void collide (); |
---|
23 | void draw (); |
---|
24 | void update (); // maps Locations to Placements |
---|
25 | void calc_camera_pos (Location* loc, Placement* plc); |
---|
26 | |
---|
27 | void unload (); |
---|
28 | |
---|
29 | void load_debug_level (); |
---|
30 | |
---|
31 | private: |
---|
32 | |
---|
33 | List<WorldEntity>* entities; |
---|
34 | |
---|
35 | // base level data |
---|
36 | Track* track; |
---|
37 | Uint32 tracklen; |
---|
38 | Vector* pathnodes; |
---|
39 | |
---|
40 | }; |
---|
41 | |
---|
42 | template<typename T> T* World::spawn(Location* loc = NULL, WorldEntity* owner = NULL) |
---|
43 | { |
---|
44 | Location zeroloc; |
---|
45 | T* entity = new T(); |
---|
46 | entities->add ((WorldEntity*)entity, LIST_ADD_NEXT); |
---|
47 | if( loc == NULL) |
---|
48 | { |
---|
49 | zeroloc.dist = 0; |
---|
50 | zeroloc.part = 0; |
---|
51 | zeroloc.pos = Vector(); |
---|
52 | zeroloc.rot = Rotation(); |
---|
53 | loc = &zeroloc; |
---|
54 | } |
---|
55 | entity->init (loc, owner); |
---|
56 | if (entity->bFree) |
---|
57 | { |
---|
58 | track[loc->part].map_coords( loc, entity->get_placement()); |
---|
59 | } |
---|
60 | entity->post_spawn (); |
---|
61 | return entity; |
---|
62 | } |
---|
63 | |
---|
64 | template<typename T> T* World::spawn(Placement* plc, WorldEntity* owner = NULL) |
---|
65 | { |
---|
66 | T* entity = new T(); |
---|
67 | entities->add ((WorldEntity*)entity, LIST_ADD_NEXT); |
---|
68 | entity->init (plc, owner); |
---|
69 | if (!entity->bFree) |
---|
70 | { |
---|
71 | printf("Can't spawn unfree entity with placement\n"); |
---|
72 | entities->remove( (WorldEntity*)entity, LIST_FIND_FW); |
---|
73 | return NULL; |
---|
74 | } |
---|
75 | entity->post_spawn (); |
---|
76 | return entity; |
---|
77 | } |
---|
78 | |
---|
79 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.