-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathentity.h
45 lines (36 loc) · 949 Bytes
/
entity.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once
#include <Vortex2D/Vortex2D.h>
#include <Vortex2D/Utils/mapbox/variant.hpp>
#include "rigidbody.h"
struct Circle
{
float mRadius;
};
struct Rectangle
{
glm::vec2 mSize;
};
struct Polygon
{
std::vector<glm::vec2> mVertices;
};
using ShapeType = mapbox::util::variant<Circle, Rectangle, Polygon>;
bool IsValid(const ShapeType& type);
struct Entity
{
float mScale;
ShapeType mShapeType;
std::unique_ptr<Vortex2D::Renderer::Shape> mShape;
Vortex2D::Renderer::RenderCommand mCmd;
std::unique_ptr<Rigidbody> mRigidbody;
Entity(const Vortex2D::Renderer::Device& device,
const glm::ivec2& size,
float scale,
ShapeType type,
std::unique_ptr<Vortex2D::Renderer::Shape> shape,
Vortex2D::Renderer::RenderCommand cmd,
b2World& box2dWorld);
void SetTransform(const glm::vec2& pos, float angle);
void UpdateTransform();
};
using EntityPtr = std::unique_ptr<Entity>;