Added sprite component

This commit is contained in:
Antoine Pilote
2023-08-01 15:15:27 -04:00
parent f5c47ee045
commit f54d64c6dd
7 changed files with 188 additions and 22 deletions

View File

@@ -0,0 +1,53 @@
#include "SpriteComponent.h"
#include "src/Rendering/Textures/TextureManager.h"
namespace Nuake
{
SpriteComponent::SpriteComponent() :
Billboard(false),
LockYRotation(false),
SpritePath("")
{
}
bool SpriteComponent::LoadSprite()
{
const auto texture = TextureManager::Get()->GetTexture(SpritePath);
Sprite = texture;
return true;
}
json SpriteComponent::Serialize()
{
BEGIN_SERIALIZE();
SERIALIZE_VAL(Billboard)
SERIALIZE_VAL(LockYRotation)
SERIALIZE_VAL(SpritePath)
END_SERIALIZE();
}
bool SpriteComponent::Deserialize(const std::string& str)
{
BEGIN_DESERIALIZE();
if (j.contains("Billboard"))
{
Billboard = j["Billboard"];
}
if (j.contains("LockYRotation"))
{
LockYRotation = j["LockYRotation"];
}
if (j.contains("SpritePath"))
{
SpritePath = j["SpritePath"];
LoadSprite();
}
return true;
}
}