-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTypes.h
58 lines (45 loc) · 1.43 KB
/
Types.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
#pragma once
#include <bitset>
#include <unordered_map>
#include <string>
#include <iostream>
#include "Transform.h"
#include "renderComponent.h"
#include <nlohmann/json.hpp>
// ECS
using ComponentType = std::uint8_t;
using ComponentSize = std::uint8_t;
const ComponentType MAX_COMPONENTS = 32;
//using Tagset = int;
using ComponentSizeMap = std::unordered_map<ComponentType, ComponentSize>;
using ArchetypeType = std::uint16_t;
using Byte = unsigned char;
// an entity exists as a specific single index in an object pool chunk
// "version" refers to which re-used iteration of that index this specific entity existed in
// version is used to check if an entityID refers to a destroyed entity which is no longer in memory
struct EntityID
{
int chunkID;
int index;
int version;
bool isEqual(const EntityID& other) const
{
return other.chunkID == this->chunkID && other.index == this->index && other.version == this->version;
}
};
inline bool operator==(const EntityID& lhs, const EntityID& rhs)
{
return lhs.isEqual(rhs);
}
using json = nlohmann::json;
// enables us to directly print entityID as a string into cout
inline std::ostream& operator<<(std::ostream& str, EntityID const& ca)
{
str << "chunk: " << ca.chunkID << ", index: " << ca.index << ", ver: " << ca.version;
return str;
}
struct RenderArrays
{
std::vector<Transform*> transforms;
std::vector<RenderComponent*> renderComponents;
};