Zgragselus

Example

Oct 4th, 2025
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.42 KB | None | 0 0
  1. #include "SkyeCuillin.h"
  2.  
  3. class DemoController : public Engine::Component
  4. {
  5. public:
  6.     static std::string mComponentName;
  7.  
  8.     Engine::float4 mFloat4Value;
  9.     Engine::mat4 mMatrixValue;
  10.     float mValue;
  11.     int mIntValue;
  12.     std::string mStringValue;
  13.  
  14.     virtual std::string& GetName() override
  15.     {
  16.         return mComponentName;
  17.     }
  18.  
  19.     virtual bool Editor(std::string& prev, std::string& next)
  20.     {
  21.         SetupContext();
  22.        
  23.         return Engine::Component::DefaultEditor(this, &Reflection, prev, next);
  24.     }
  25.  
  26.     virtual void Init()
  27.     {
  28.         mValue = 0.0f;
  29.     }
  30.  
  31.     virtual void Update(float deltaTime)
  32.     {
  33.         mValue += 1.0f / 60.0f;
  34.         if (mValue > 1.0f)
  35.         {
  36.             mValue -= 1.0f;
  37.         }
  38.  
  39.         printf("%f %f %f\n",
  40.             this->mGameObject->GetEntity()->Transformation().GetTranslation().x,
  41.             this->mGameObject->GetEntity()->Transformation().GetTranslation().y,
  42.             this->mGameObject->GetEntity()->Transformation().GetTranslation().z);
  43.     }
  44.  
  45.     virtual std::string Serialize()
  46.     {
  47.         return Engine::Component::DefaultSerialize(this, &Reflection);
  48.     }
  49.  
  50.     virtual void Deserialize(const std::string& data)
  51.     {
  52.         Engine::Component::DefaultDeserialize(this, &Reflection, data);
  53.     }
  54.  
  55.     REFLECT()
  56. };
  57.  
  58. REFLECT_STRUCT_BEGIN(DemoController)
  59. REFLECT_STRUCT_MEMBER(mValue)
  60. REFLECT_STRUCT_MEMBER(mIntValue)
  61. REFLECT_STRUCT_MEMBER(mFloat4Value)
  62. REFLECT_STRUCT_MEMBER(mMatrixValue)
  63. REFLECT_STRUCT_MEMBER(mStringValue)
  64. REFLECT_STRUCT_END()
  65.  
  66. SKYE_CUILLIN_COMPONENT(DemoController)
Advertisement
Add Comment
Please, Sign In to add comment