|
|
|
|
/******************************************************************************
|
|
|
|
|
* File - components.h
|
|
|
|
|
* Author - Joey Pollack
|
|
|
|
|
* Date - 2022/05/24 (y/m/d)
|
|
|
|
|
* Mod Date - 2022/05/24 (y/m/d)
|
|
|
|
|
* Description - ECS component declarations
|
|
|
|
|
******************************************************************************/
|
|
|
|
|
|
|
|
|
|
#ifndef LUNARIUM_COMPONENTS_H_
|
|
|
|
|
#define LUNARIUM_COMPONENTS_H_
|
|
|
|
|
|
|
|
|
|
#include <core/common_defs.h>
|
|
|
|
|
#include <glm/glm.hpp>
|
|
|
|
|
#include <glm/gtc/matrix_transform.hpp>
|
|
|
|
|
|
|
|
|
|
#define GLM_ENABLE_EXPERIMENTAL
|
|
|
|
|
#include <glm/gtx/quaternion.hpp>
|
|
|
|
|
|
|
|
|
|
#include <renderer/orthographic_camera.h>
|
|
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
namespace lunarium
|
|
|
|
|
{
|
|
|
|
|
struct TagComponent
|
|
|
|
|
{
|
|
|
|
|
std::string Info;
|
|
|
|
|
|
|
|
|
|
TagComponent(std::string _info = "")
|
|
|
|
|
{
|
|
|
|
|
Info.reserve(256);
|
|
|
|
|
Info.insert(0, _info);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TagComponent(const TagComponent&) = default;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct TransformComponent
|
|
|
|
|
{
|
|
|
|
|
glm::vec3 Position = { 0.0f, 0.0f, 0.0f };
|
|
|
|
|
glm::vec3 Rotation = { 0.0f, 0.0f, 0.0f };
|
|
|
|
|
glm::vec3 Scale = { 1.0f, 1.0f, 1.0f };
|
|
|
|
|
|
|
|
|
|
TransformComponent(glm::vec3 p = glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3 r = glm::vec3(0.0f, 0.0f, 0.0f), glm::vec3 s = glm::vec3(1.0f, 1.0f, 1.0f))
|
|
|
|
|
: Position(p), Rotation(r), Scale(s)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TransformComponent(const TransformComponent&) = default;
|
|
|
|
|
|
|
|
|
|
glm::mat4 GetTransform()
|
|
|
|
|
{
|
|
|
|
|
// Quaternion code taken from Hazel engine
|
|
|
|
|
// https://github.com/TheCherno/Hazel/blob/dev/Hazel/src/Hazel/Scene/Components.h
|
|
|
|
|
return (glm::translate(glm::mat4(1.0f), Position) * glm::toMat4(glm::quat(Rotation)) * glm::scale(glm::mat4(1.0f), Scale ));
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct VelocityComponent
|
|
|
|
|
{
|
|
|
|
|
glm::vec3 Velocity = { 0.0f, 0.0f, 0.0f};
|
|
|
|
|
|
|
|
|
|
VelocityComponent() = default;
|
|
|
|
|
VelocityComponent(const VelocityComponent&) = default;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct CameraComponent
|
|
|
|
|
{
|
|
|
|
|
OrthographicCamera Camera;
|
|
|
|
|
|
|
|
|
|
CameraComponent() = default;
|
|
|
|
|
CameraComponent(const CameraComponent&) = default;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct BlockOutComponent
|
|
|
|
|
{
|
|
|
|
|
glm::vec4 Color;
|
|
|
|
|
glm::vec2 Size;
|
|
|
|
|
int RenderLayer;
|
|
|
|
|
|
|
|
|
|
BlockOutComponent() = default;
|
|
|
|
|
BlockOutComponent(const BlockOutComponent&) = default;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct SpriteRendererComponent
|
|
|
|
|
{
|
|
|
|
|
LUUID ImageID;
|
|
|
|
|
int RenderLayer;
|
|
|
|
|
glm::vec2 FrameSize;
|
|
|
|
|
glm::vec2 FramePos;
|
|
|
|
|
Color TintColor;
|
|
|
|
|
|
|
|
|
|
SpriteRendererComponent() = default;
|
|
|
|
|
SpriteRendererComponent(const SpriteRendererComponent&) = default;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ScriptComponent
|
|
|
|
|
{
|
|
|
|
|
LUUID ScriptID;
|
|
|
|
|
|
|
|
|
|
ScriptComponent() = default;
|
|
|
|
|
ScriptComponent(const ScriptComponent&) = default;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
// UTILITY COMPONENTS
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
// These components are for internal use only. They do not show up in the editor.
|
|
|
|
|
|
|
|
|
|
struct UUIDComponent
|
|
|
|
|
{
|
|
|
|
|
LUUID UUID;
|
|
|
|
|
|
|
|
|
|
UUIDComponent() = default;
|
|
|
|
|
UUIDComponent(const UUIDComponent&) = default;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ParentEntityComponent
|
|
|
|
|
{
|
|
|
|
|
LUUID Parent;
|
|
|
|
|
|
|
|
|
|
ParentEntityComponent() = default;
|
|
|
|
|
ParentEntityComponent(const ParentEntityComponent&) = default;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct ChildrenComponent
|
|
|
|
|
{
|
|
|
|
|
std::vector<LUUID> Children;
|
|
|
|
|
|
|
|
|
|
ChildrenComponent() = default;
|
|
|
|
|
ChildrenComponent(const ChildrenComponent&) = default;
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#endif // LUNARIUM_COMPONENTS_H_
|