CCCPaste

Example

#include "SkyeCuillin.h"

class DemoController : public Engine::Component
{
public:
static std::string mComponentName;

Engine::float4 mFloat4Value;
Engine::mat4 mMatrixValue;
float mValue;
int mIntValue;
std::string mStringValue;

virtual std::string& GetName() override
{
return mComponentName;
}

virtual bool Editor(std::string& prev, std::string& next)
{
SetupContext();

return Engine::Component::DefaultEditor(this, &Reflection, prev, next);
}

virtual void Init()
{
mValue = 0.0f;
}

virtual void Update(float deltaTime)
{
mValue += 1.0f / 60.0f;
if (mValue > 1.0f)
{
mValue -= 1.0f;
}

printf("%f %f %f\n",
this->mGameObject->GetEntity()->Transformation().GetTranslation().x,
this->mGameObject->GetEntity()->Transformation().GetTranslation().y,
this->mGameObject->GetEntity()->Transformation().GetTranslation().z);
}

virtual std::string Serialize()
{
return Engine::Component::DefaultSerialize(this, &Reflection);
}

virtual void Deserialize(const std::string& data)
{
Engine::Component::DefaultDeserialize(this, &Reflection, data);
}

REFLECT()
};

REFLECT_STRUCT_BEGIN(DemoController)
REFLECT_STRUCT_MEMBER(mValue)
REFLECT_STRUCT_MEMBER(mIntValue)
REFLECT_STRUCT_MEMBER(mFloat4Value)
REFLECT_STRUCT_MEMBER(mMatrixValue)
REFLECT_STRUCT_MEMBER(mStringValue)
REFLECT_STRUCT_END()

SKYE_CUILLIN_COMPONENT(DemoController)