-
Notifications
You must be signed in to change notification settings - Fork 0
/
level.h
105 lines (75 loc) · 1.83 KB
/
level.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
96
97
98
99
100
101
102
103
104
105
#pragma once
#include <vector>
#include <map>
#include "voxel.h"
#include "mesh.h"
#include "misc.h"
#include "kvstore.h"
class Entity;
class World;
class Level
{
World *m_world;
map_s m_map;
MapMesh m_mesh;
int m_timeMS;
typedef std::vector< Entity* > EntityContainer;
EntityContainer m_entities;
int m_curLevel;
typedef std::vector< Entity* > UpdateContainer;
UpdateContainer m_fixedUpdate;
UpdateContainer m_deltaUpdate;
UpdateContainer m_guiRender;
UpdateContainer m_renderUpdate;
typedef std::vector< Entity* > RemoveContainer;
RemoveContainer m_toRemove;
public:
Level();
~Level();
void SetWorld( World *w ) { m_world = w; }
void Spawn( KVStore const &kv );
void AddFixed( Entity* ent );
void AddDelta( Entity* ent );
void AddGui( Entity* ent );
void AddRender( Entity* ent );
void RemoveFixed( Entity* ent );
void RemoveDelta( Entity* ent );
void RemoveGui( Entity* ent );
void RemoveRender( Entity* ent );
bool Load( const char *filename );
void Clear();
void UpdateBegin();
void UpdateFixed( float dt );
void UpdateDelta( float dt );
void UpdateEnd();
void Render();
void RenderGUI();
void AddEntity( Entity *ent );
void RemoveEntity( Entity *ent );
map_s* GetMap() { return &m_map; }
Entity *FindEntity( const char *name );
int GetTimeMS() const { return m_timeMS; }
void FindEntities( std::vector<Entity*> &ents, const float pos[3], float radius, CoreType const &type );
};
class LevelEntsDef
{
std::vector<KVStore*> m_ents;
std::string m_filename;
public:
virtual bool Load( const char *filename );
virtual void Reload();
virtual void Clear();
unsigned int GetNum() const
{
return m_ents.size();
}
KVStore const & Get( unsigned int i ) const
{
return *m_ents[i];
}
};
class LevelEntsDefMgr : public TypedDefMgr<LevelEntsDef>
{
public:
};
LevelEntsDefMgr *LevelEntsDefManager();