Files
UwU-Engine/Core/Game/Actors/Actor.cpp
T

62 lines
1.3 KiB
C++

#include "Actor.hpp"
#include "Game/SaveMap/SaveMap.hpp"
#include "Game/World/World.hpp"
void Actor::OnDestroy()
{
}
Actor::Actor() : loc_(new Vector3D), rot_(new Vector3D), scale_(new Vector3D)
{
SetType(Classes::Actor);
}
std::shared_ptr<SaveMap> Actor::save()
{
std::shared_ptr<SaveMap> save = std::make_shared<SaveMap>("Actor");
save->SaveObject("loc", loc_);
save->SaveObject("rot", rot_);
save->SaveObject("scale", scale_);
save->SaveListStrings("tags", std::move(tags_));
return save;
}
void Actor::load(std::shared_ptr<SaveMap> save)
{
loc_ = std::static_pointer_cast<Vector3D>(save->GetObject("loc"));
rot_ = std::static_pointer_cast<Vector3D>(save->GetObject("rot"));
scale_ = std::static_pointer_cast<Vector3D>(save->GetObject("scale"));
tags_ = std::move(save->GetListString("tags"));
}
void Actor::BeginPlay()
{
}
void Actor::Tick(double delta_time)
{
}
void Actor::SetActorLocate(const Vector3D& loc) noexcept
{
*this->loc_ = loc;
OnSetActorLocate.call(loc);
}
void Actor::SetActorRotate(const Vector3D& rot) noexcept
{
*this->rot_ = rot;
OnSetActorRotate.call(rot);
}
void Actor::AddTag(const std::string& tag) noexcept
{
tags_.push_back(tag);
}
void Actor::RemoveTag(const std::string& tag) noexcept
{
tags_.remove(tag);
}