5 #include <ThirdParty/cereal/include/cereal/cereal.hpp> 6 #include <ThirdParty/EASTL-master/include/EASTL/shared_ptr.h> 7 #include <ThirdParty/EASTL-master/include/EASTL/vector.h> 24 eastl::weak_ptr<Entity> GetOwner()
const;
35 virtual void InitializeComponent();
40 virtual void Update();
46 virtual void OnComponentAdded(eastl::weak_ptr<Component> addedComponent);
52 virtual void OnComponentRemoved(eastl::weak_ptr<Component> removedComponent);
54 template<
typename ComponentType>
59 eastl::weak_ptr<ComponentType> GetComponent();
61 template<
typename ComponentType>
66 eastl::vector<eastl::weak_ptr<ComponentType>> GetComponents();
72 eastl::vector<eastl::shared_ptr<Component>> GetAllComponents()
const;
74 template <
class ComponentType,
class... Args>
80 eastl::weak_ptr<ComponentType> AddComponent(Args&&... args);
85 template <
class ComponentType,
class... Args>
92 eastl::vector<eastl::weak_ptr<ComponentType>> AddComponents(
size_t count, Args&&... args);
94 template <
typename ComponentType>
99 void RemoveComponent(
size_t amountToRemove = 1)
const;
101 template <
typename ComponentType>
105 void RemoveAllComponents()
const;
111 template <
typename archive>
112 void SaveBaseComponent(archive ar);
118 template <
typename archive>
119 void LoadBaseComponent(archive ar);
121 virtual void OnBeginContact(eastl::weak_ptr<Entity> entity);
122 virtual void OnEndContact(eastl::weak_ptr<Entity> entity);
128 eastl::weak_ptr<Component> GetPointerRefence()
const;
130 template <
typename ComponentType>
135 eastl::weak_ptr<ComponentType> GetPointerRefence();
141 void SetOwner(eastl::weak_ptr<Entity> owner);
143 void SetPointerReference(eastl::weak_ptr<Component> pointerReference);
145 eastl::weak_ptr<Entity> owner;
146 eastl::weak_ptr<Component> pointerReference;
150 template <
typename ComponentType>
153 return owner.lock()->GetComponent<ComponentType>();
156 template <
typename ComponentType>
159 return owner.lock()->GetComponents<ComponentType>();
162 template <
class ComponentType,
class ... Args>
165 return owner.lock()->AddComponent<ComponentType>(&args...);
168 template <
class ComponentType,
class ... Args>
171 return owner.lock()->AddComponents<ComponentType>(count, &args...);
174 template <
typename ComponentType>
177 owner.lock()->RemoveComponent<ComponentType>(amountToRemove);
180 template <
typename ComponentType>
183 owner.lock()->RemoveAllComponents<ComponentType>();
186 template <
typename ComponentType>
189 return eastl::dynamic_pointer_cast<ComponentType,
Component>(pointerReference.lock());
eastl::weak_ptr< ComponentType > GetComponent()
This method allows you to get the first component of the given type.
This is the base class for components. NOTE: only the Entity class is allowed to create this object...
This object is able a holder object for components. NOTE: only the EntitySystem is allowed to create ...
eastl::vector< eastl::weak_ptr< ComponentType > > AddComponents(size_t count, Args &&...args)
Allows you to create X amount of components of the given type.
eastl::vector< eastl::weak_ptr< ComponentType > > GetComponents()
This method allows you to get all of the components of the given type.
void RemoveAllComponents() const
Deletes all the components of the given type.
eastl::weak_ptr< Component > GetPointerRefence() const
This method allows you to get a direct refence to the weak pointer of this component.
eastl::weak_ptr< ComponentType > AddComponent(Args &&...args)
Allows you to create a component of the given type.
void RemoveComponent(size_t amountToRemove=1) const
Allows X amount of components of the given type.