Tramway SDK
worldcell.h
Go to the documentation of this file.
1// Tramway Drifting and Dungeon Exploration Simulator SDK Runtime
2
3#ifndef TRAM_SDK_FRAMEWORK_WORLDCELL_H
4#define TRAM_SDK_FRAMEWORK_WORLDCELL_H
5
6#include <vector>
7
8#include <framework/uid.h>
9#include <framework/math.h>
10
11namespace tram {
12
13class Entity;
14class Transition;
15
16class WorldCell {
17public:
18 WorldCell(name_t name) { this->name = name; }
19
20 inline name_t GetName() { return name; }
21
22 inline bool IsLoaded() { return flags & LOADED; }
23 inline bool IsInterior() { return flags & INTERIOR; }
24 inline bool HasInteriorLighting() { return flags & INTERIOR_LIGHTING; }
25 inline bool IsDebugDraw() { return flags & DEBUG_DRAW; }
26 inline bool HasAutomaticLoading() { return flags & AUTOMATIC_LOADING; }
27
28 inline void SetInterior(bool is) { SetFlag(INTERIOR, is); }
29 inline void SetInteriorLights(bool is) { SetFlag(INTERIOR_LIGHTING, is); }
30 inline void SetDebugDraw(bool is) { SetFlag(DEBUG_DRAW, is); }
31 inline void SetAutomaticLoading(bool is) { SetFlag(AUTOMATIC_LOADING, is); }
32
33 void Load();
34 void Unload();
35
36 void LoadFromDisk();
37
38 void Add(Entity* entity);
39 void Remove(Entity* entity);
40
41 size_t GetEntityCount() { return entities.size(); }
42
43 void Add(Transition* transition);
44
45 void Link(WorldCell* other);
46
48
49 inline const std::vector<Entity*>& GetEntities() { return entities; }
50 inline const std::vector<Transition*>& GetTransitions() { return transitions; }
51 inline const std::vector<Transition*>& GetVolume() { return volume; }
52
53
54 bool IsInside(vec3 point);
55
56 static WorldCell* Find (vec3 point);
57 static WorldCell* Find (name_t name);
58 static WorldCell* Make (name_t name);
59
60protected:
61 enum {
62 LOADED = 1,
68 };
69
70 inline void SetFlag(uint32_t flag, bool value) { flags = value ? flags | flag : flags & ~flag; };
71
74 std::vector<Entity*> entities;
75 std::vector<Transition*> transitions;
76 std::vector<Transition*> volume;
77};
78
79}
80
81#endif // TRAM_SDK_FRAMEWORK_WORLDCELL_H
Entity base class.
Definition: entity.h:23
Connects WorldCells together.
Definition: transition.h:15
World streaming unit.
Definition: worldcell.h:16
void Add(Entity *entity)
Adds an entity to the worldcell.
Definition: worldcell.cpp:191
std::vector< Entity * > entities
Definition: worldcell.h:74
const std::vector< Transition * > & GetTransitions()
Definition: worldcell.h:50
void SetInterior(bool is)
Definition: worldcell.h:28
uint32_t flags
Definition: worldcell.h:73
std::vector< Transition * > transitions
Definition: worldcell.h:75
bool IsInterior()
Definition: worldcell.h:23
void Load()
Loads the cell.
Definition: worldcell.cpp:83
const std::vector< Transition * > & GetVolume()
Definition: worldcell.h:51
bool IsInside(vec3 point)
Checks if point is inside the worldcell.
Definition: worldcell.cpp:168
void LoadFromDisk()
Loads worldcell data from disk.
Definition: worldcell.cpp:248
void SetFlag(uint32_t flag, bool value)
Definition: worldcell.h:70
std::vector< Transition * > volume
Definition: worldcell.h:76
size_t GetEntityCount()
Definition: worldcell.h:41
void SetInteriorLights(bool is)
Definition: worldcell.h:29
bool HasAutomaticLoading()
Definition: worldcell.h:26
bool IsDebugDraw()
Definition: worldcell.h:25
@ DEBUG_DRAW
Definition: worldcell.h:65
@ AUTOMATIC_LOADING
Definition: worldcell.h:66
@ LOADED_FROM_DISK
Definition: worldcell.h:67
@ INTERIOR
Definition: worldcell.h:63
@ LOADED
Definition: worldcell.h:62
@ INTERIOR_LIGHTING
Definition: worldcell.h:64
const std::vector< Entity * > & GetEntities()
Definition: worldcell.h:49
name_t name
Definition: worldcell.h:70
void Remove(Entity *entity)
Removes an entity from the worldcell.
Definition: worldcell.cpp:226
WorldCell(name_t name)
Definition: worldcell.h:18
static WorldCell * Find(vec3 point)
Finds the WorldCell which contains a given point.
Definition: worldcell.cpp:67
static WorldCell * Make(name_t name)
Creates a WorldCell by name.
Definition: worldcell.cpp:49
name_t GetName()
Definition: worldcell.h:20
void Link(WorldCell *other)
Links a worldcell.
Definition: worldcell.cpp:179
void Unload()
Unloads the cell.
Definition: worldcell.cpp:101
WorldCell * FindTransition(vec3 point)
Finds a transition from a position.
Definition: worldcell.cpp:132
void SetDebugDraw(bool is)
Definition: worldcell.h:30
bool HasInteriorLighting()
Definition: worldcell.h:24
bool IsLoaded()
Definition: worldcell.h:22
void SetAutomaticLoading(bool is)
Definition: worldcell.h:31
Serialization, i.e.
glm::vec3 vec3
Definition: math.h:11
Interned string type.
Definition: uid.h:10