Yet Another Game Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
component.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <bitset>
4 #include <memory>
5 #include <vector>
6 
7 namespace yage
8 {
9 
14 typedef std::bitset<64> ComponentMask;
15 
16 typedef unsigned int GroupId;
17 
19 {
20 protected:
21  virtual GroupId getGroup() = 0;
23 
24 private:
25  friend class EntityManager;
26 };
27 
28 template <typename T>
29 class Component : public BaseComponent
30 {
31  GroupId getGroup() override;
32 };
33 
35 {
36 public:
37  std::vector<std::unique_ptr<BaseComponent>> components_;
38 };
39 
40 template <typename T>
42 {
43  static GroupId group_id = group_id_counter_++;
44  return group_id;
45 }
46 
47 } // namespace yage
Definition: component.h:18
Has to keep track of all the different entities and their current state.
Definition: entity.h:21
unsigned int GroupId
Definition: component.h:16
virtual GroupId getGroup()=0
std::vector< std::unique_ptr< BaseComponent > > components_
Definition: component.h:37
Definition: component.h:34
static GroupId group_id_counter_
Definition: component.h:22
Definition: component.h:29
std::bitset< 64 > ComponentMask
The component mask represents all the components that the entity is currently attached to...
Definition: component.h:14