CObject.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #pragma once
  2. #include <nlohmann/json.hpp>
  3. #include <irrlicht/irrlicht.h>
  4. #include "WallpaperEngine/Core/Objects/CEffect.h"
  5. namespace WallpaperEngine::Core::Objects
  6. {
  7. class CEffect;
  8. }
  9. namespace WallpaperEngine::Core
  10. {
  11. using json = nlohmann::json;
  12. class CObject
  13. {
  14. public:
  15. static CObject* fromJSON (json data);
  16. template<class T> const T* As () const { assert (Is<T> ()); return (const T*) this; }
  17. template<class T> T* As () { assert (Is<T> ()); return (T*) this; }
  18. template<class T> bool Is () { return this->m_type == T::Type; }
  19. std::vector<Objects::CEffect*>* getEffects ();
  20. int getId ();
  21. irr::core::vector3df* getOrigin ();
  22. irr::core::vector3df* getScale ();
  23. irr::core::vector3df* getAngles ();
  24. bool isVisible ();
  25. protected:
  26. CObject (
  27. bool visible,
  28. irr::u32 id,
  29. std::string name,
  30. std::string type,
  31. const irr::core::vector3df& origin,
  32. const irr::core::vector3df& scale,
  33. const irr::core::vector3df& angles
  34. );
  35. void insertEffect (Objects::CEffect* effect);
  36. private:
  37. std::string m_type;
  38. bool m_visible;
  39. irr::u32 m_id;
  40. std::string m_name;
  41. irr::core::vector3df m_origin;
  42. irr::core::vector3df m_scale;
  43. irr::core::vector3df m_angles;
  44. std::vector<Objects::CEffect*> m_effects;
  45. };
  46. };