TazGraph Project v0.1.0
Loading...
Searching...
No Matches
GECSEntity.h
1#pragma once
2
3#include "CellEntity.h"
4
5class LinkEntity;
6
7class EmptyEntity : public CellEntity {
8protected:
9 Entity* parent_entity = nullptr;
10public:
11
12 EmptyEntity(Manager& mManager) : CellEntity(mManager) {}
13
14 void setComponentEntity(Component* c) override {
15 c->entity = this;
16 }
17
18 Entity* getParentEntity() override {
19 return parent_entity;
20 }
21
22 void setParentEntity(Entity* pEntity) override {
23 parent_entity = pEntity;
24 }
25
26 void removeFromCell() {
27 if (this->ownerCell) {
28 removeEntity();
29 this->ownerCell = nullptr;
30 }
31 }
32
33 void removeEntity() override{
34 ownerCell->emptyEntities.erase(
35 std::remove(this->ownerCell->emptyEntities.begin(), this->ownerCell->emptyEntities.end(),
36 this),
37 this->ownerCell->emptyEntities.end());
38 }
39
40
41};
42
43class NodeEntity : public EmptyEntity {
44protected:
45 std::vector<LinkEntity*> inLinks;
46 std::vector<LinkEntity*> outLinks;
47public:
48
49 NodeEntity(Manager& mManager) : EmptyEntity(mManager) {
50 nodeComponentArray.emplace();
51 nodeComponentBitSet.emplace();
52 }
53 void setComponentEntity(NodeComponent* c) override {
54 c->entity = this;
55
56 }
57
58 void removeEntity() override {
59 ownerCell->nodes.erase(
60 std::remove(this->ownerCell->nodes.begin(), this->ownerCell->nodes.end(),
61 this),
62 this->ownerCell->nodes.end());
63 }
64
65 void addInLink(LinkEntity* link) {
66 inLinks.push_back(link);
67 }
68
69 void addOutLink(LinkEntity* link) {
70 outLinks.push_back(link);
71 }
72
73 const std::vector<LinkEntity*>& getInLinks() const {
74 return inLinks;
75 }
76
77 const std::vector<LinkEntity*>& getOutLinks() const {
78 return outLinks;
79 }
80
81 virtual void addPorts() {}
82
83 virtual void removePorts() {}
84
85 virtual void updatePorts(float deltaTime) {}
86
87};
88
89
91protected:
92 unsigned int fromId = 0;
93 unsigned int toId = 0;
94
95 NodeEntity* from = nullptr;
96 NodeEntity* to = nullptr;
97
98public:
99 std::string fromPort;
100 std::string toPort;
101
102 LinkEntity(Manager& mManager) : MultiCellEntity(mManager) {
103 }
104
105 LinkEntity(Manager& mManager, unsigned int mfromId, unsigned int mtoId)
106 : MultiCellEntity(mManager), fromId(mfromId), toId(mtoId) {
107 }
108
109 LinkEntity(Manager& mManager, NodeEntity* mfrom, NodeEntity* mto)
110 : MultiCellEntity(mManager), from(mfrom), to(mto) {
111 }
112
113 void setComponentEntity(LinkComponent* c) override {
114 c->entity = this;
115 }
116
117 void removeFromCells() {
118 removeEntity();
119 ownerCells.clear();
120 }
121
122 void removeEntity() override {
123 for (auto cell : ownerCells) {
124 cell->links.erase(std::remove(cell->links.begin(), cell->links.end(),
125 this),
126 cell->links.end());
127 }
128 }
129
130 NodeEntity* getFromNode() const {
131 return from;
132 }
133
134 NodeEntity* getToNode() const {
135 return to;
136 }
137
138 EmptyEntity* getFromPort() {
139 return from->children[fromPort];
140 }
141
142 EmptyEntity* getToPort() {
143 return to->children[toPort];
144 }
145
146 virtual void updateLinkToPorts() {}
147
148 virtual void updateLinkToNodes() {}
149
150 virtual void updateArrowHeads() {}
151
152 virtual void addArrowHead() {}
153
154 virtual void removeArrowHead() {}
155};
Definition CellEntity.h:35
Definition GECS.h:123
Definition GECSEntity.h:7
Definition GECS.h:140
Definition GECS.h:133
Definition GECSEntity.h:90
Definition GECSManager.h:14
Definition CellEntity.h:53
Definition GECS.h:128
Definition GECSEntity.h:43