-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
103 lines (80 loc) · 3.28 KB
/
main.cpp
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
#define STB_IMAGE_IMPLEMENTATION
#include <iostream>
#include <string>
#include <memory>
#include <math.h>
#include <typeinfo>
#include <src/ecs/ECS.hpp>
#include <src/systems/InputSystem.hpp>
#include <src/systems/RenderingSystem.hpp>
#include <src/systems/MovingSystem.hpp>
#include <src/systems/ResourceSystem.hpp>
#include <src/components/Texture.hpp>
#include <src/components/Quad.hpp>
#include <src/components/Selected.hpp>
#include <src/components/Dragged.hpp>
#include <src/components/ResourceStorage.hpp>
#include <src/components/ResourceGenerator.hpp>
#include <src/InputManager.hpp>
#include <src/ui/TestWindow.hpp>
#include <external/pugixml/pugixml.hpp>
using namespace std;
extern Coordinator coordinator;
int main(int argc, char *argv[])
{
coordinator.RegisterComponent<Texture>();
coordinator.RegisterComponent<Quad>();
coordinator.RegisterComponent<ResourceStorage>();
coordinator.RegisterComponent<ResourceGenerator>();
coordinator.RegisterComponent<Selected>();
coordinator.RegisterComponent<Dragged>();
shared_ptr<RenderingSystem> renderingSystem = coordinator.RegisterSystem<RenderingSystem>();
{
Signature<Texture, Quad> signature(&coordinator);
coordinator.SetSystemSignature<RenderingSystem>(signature);
}
renderingSystem->Init("assets/", "src/shaders/");
InputManager inputManager;
shared_ptr<ResourceSystem> resourceSystem = coordinator.RegisterSystem<ResourceSystem>();
{
Signature<ResourceGenerator> signature(&coordinator);
coordinator.SetSystemSignature<ResourceSystem>(signature);
}
shared_ptr<MovingSystem> movingSystem = coordinator.RegisterSystem<MovingSystem>();
{
Signature<Quad, Dragged> signature(&coordinator);
coordinator.SetSystemSignature<MovingSystem>(signature);
}
movingSystem->Init(inputManager.GetEvents());
shared_ptr<InputSystem> inputSystem = coordinator.RegisterSystem<InputSystem>();
{
Signature<Quad> signature(&coordinator);
coordinator.SetSystemSignature<InputSystem>(signature);
}
inputSystem->Init(inputManager.GetEvents());
Entity playerData = coordinator.CreateEntity();
playerData.Assign<ResourceStorage>(ResourceStorage {0, 0, 0});
Entity farm = coordinator.CreateEntity();
farm.Assign<Quad>(Quad {50.0f, 50.0f, 0, 100, 100, 255, 255, 255, 0});
farm.Assign<Texture>(Texture{"wall.jpg", 0});
farm.Assign<ResourceGenerator>(ResourceGenerator {0, 1, 0, 5, playerData.GetId()});
Entity test = coordinator.CreateEntity();
test.Assign<Quad>(Quad {150.0f, 150.0f, 0, 100, 100, 255, 255, 255, 45});
test.Assign<Texture>(Texture{"wall.jpg", 0});
pugi::xml_document doc;
doc.append_child(pugi::node_declaration);
auto root = doc.append_child("root");
coordinator.ArchiveEntity(root, farm.GetId());
doc.save_file("test.xml", PUGIXML_TEXT(" "));
shared_ptr<Window> testWindow = make_shared<TestWindow>(playerData.GetComponent<ResourceStorage>(), inputManager.GetMouseState());
renderingSystem->AddWindow(testWindow);
while(true)
{
inputManager.Update();
inputSystem->Update();
movingSystem->Update();
renderingSystem->Render();
resourceSystem->Update();
}
cout << coordinator.GetEntitiesCount() << endl;
}