Added sprite component
This commit is contained in:
53
Nuake/src/Scene/Components/SpriteComponent.cpp
Normal file
53
Nuake/src/Scene/Components/SpriteComponent.cpp
Normal 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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user