Advertisement
Zgragselus

Reflection - Demo Controller

Jan 2nd, 2022
1,358
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include "Game/Entity/Component.h"
  2. #include "Core/Plugin/Reflection.h"
  3.  
  4. char mName[] = "DemoController";
  5.  
  6. class DemoController : public Engine::Component
  7. {
  8. public:
  9.     float mValue;
  10.  
  11.     virtual bool Editor(std::string& prev, std::string& next)
  12.     {
  13.         return false;
  14.     }
  15.  
  16.     virtual void Start()
  17.     {
  18.         mValue = 0.0f;
  19.     }
  20.  
  21.     virtual void Update()
  22.     {
  23.         mValue += 1.0f / 60.0f;
  24.         if (mValue > 1.0f)
  25.         {
  26.             mValue -= 1.0f;
  27.         }
  28.     }
  29.  
  30.     virtual std::string Serialize()
  31.     {
  32.         return "";
  33.     }
  34.  
  35.     virtual void Deserialize(const std::string& data)
  36.     {
  37.  
  38.     }
  39.  
  40.     REFLECT()
  41. };
  42.  
  43. REFLECT_STRUCT_BEGIN(DemoController)
  44. REFLECT_STRUCT_MEMBER(mValue)
  45. REFLECT_STRUCT_END()
  46.  
  47. extern "C" __declspec(dllexport) Engine::Component* CreateBehavior()
  48. {
  49.     Engine::Component* component = new DemoController();
  50.     return component;
  51. }
  52.  
  53. extern "C" __declspec(dllexport) const char* GetName()
  54. {
  55.     return mName;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement