-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSceneManager.h
87 lines (67 loc) · 1.92 KB
/
SceneManager.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
#pragma once
#include "Types.h"
#include "EntityCoordinator.h"
#include "Renderer.h"
// class for storing values to pass around scene manager
struct EntityValues {
std::vector<uint8_t> components;
std::vector<Tag> tags;
const char* spriteName = "";
// - Components ------------------------
//
// Use to add components to entity
bool transformComponent = false;
bool renderComponent = false;
bool physicsComponent = false;
bool animationComponent = false;
bool movementComponent = false;
bool textComponent = false;
bool stateComponent = false;
// - Component Values -----------------------------
// Transform
float xPos = 0.0f;
float yPos = 0.0f;
float xScale = 1.0f;
float yScale = 1.0f;
float rotation = 0.0f;
// RenderComponent
ShaderName shaderName = ShaderName::DEFAULT;
bool flipX = false;
float rowIndex = 0;
float colIndex = 0;
// the colors are shared with the textComponent
int colorR = 1;
int colorG = 1;
int colorB = 1;
// AnimationComponent
bool animIsPlaying = false;
std::string animName = "";
// Physics
float density = 1.0f;
float friction = 0.0f;
b2BodyType bodyType = b2_staticBody;
// TextComponent
// share the colors with the RenderComponent
std::string text = "";
float size = 1.0;
// specify the alignment of the text
TextAlign align = TextAlign::CENTER;
};
// Scene Manager class
class SceneManager
{
private:
Renderer* renderer;
EntityCoordinator* coordinator;
json sceneJsonArray;
json prefabJsonArray;
unordered_map<std::string, json> prefabMap;
void ParseEntityValues(EntityValues& ev, const json& jsonObject);
public:
SceneManager();
void LoadScene(std::string filename);
void LoadPrefabs(std::string filename);
void CreateEntities();
void EmptyEntitiesList();
std::list<EntityID> entities;
};