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 private:
32  GroupId getGroup() override;
33 };
34 
36 {
37 public:
38  typedef std::vector<std::unique_ptr<BaseComponent>> Container;
39 
40  ComponentGroup &add(std::unique_ptr<BaseComponent> &&component);
41  Container::iterator begin();
42  Container::iterator end();
43 
44 private:
45  Container components_;
46 };
47 
48 template <typename T>
50 {
51  static GroupId group_id = group_id_counter_++;
52  return group_id;
53 }
54 
55 } // namespace yage
Container::iterator begin()
Definition: component.cpp:16
Definition: component.h:18
Has to keep track of all the different entities and their current state.
Definition: entity.h:24
unsigned int GroupId
Definition: component.h:16
virtual GroupId getGroup()=0
Container::iterator end()
Definition: component.cpp:20
ComponentGroup & add(std::unique_ptr< BaseComponent > &&component)
Definition: component.cpp:10
std::vector< std::unique_ptr< BaseComponent > > Container
Definition: component.h:38
Definition: component.h:35
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