SDL SPOOKY PLATFORMER ENGINE  0.2.0
An implementation of a platformer using sdl, implemented using an entity component system and efficient collision management.
ComponentUtils.hpp
Go to the documentation of this file.
1 #ifndef COMPONENT_UTILS_CPP
2 #define COMPONENT_UTILS_CPP
3 
4 #include "GameObject.hpp"
5 #include "Component.hpp"
6 
7 template <typename C>
8 C* SafeGetComponentField(C* field, const GameObject& entity) {
9  if (!field) {
10  return entity.GetComponent<C>();
11  }
12  return field;
13 }
14 
15 #endif
C * GetComponent() const
Get a component.
Definition: GameObject.hpp:12
C * SafeGetComponentField(C *field, const GameObject &entity)
Definition: ComponentUtils.hpp:8