GPR5100 - Rollback
Loading...
Searching...
No Matches
transform.h
1#pragma once
2#include "component.h"
3#include "maths/angle.h"
4#include "maths/vec2.h"
5
6#include <engine/entity.h>
7
8namespace core
9{
14class PositionManager : public ComponentManager<Vec2f, static_cast<Component>(ComponentType::POSITION)>
15{
16public:
17 using ComponentManager::ComponentManager;
18};
19
24class ScaleManager : public ComponentManager<Vec2f, static_cast<Component>(ComponentType::SCALE)>
25{
26public:
27 using ComponentManager::ComponentManager;
28 void AddComponent(Entity entity) override;
29};
30
34class RotationManager : public ComponentManager<Degree, static_cast<Component>(ComponentType::ROTATION)>
35{
36public:
37 using ComponentManager::ComponentManager;
38};
39
44{
45public:
46 TransformManager(EntityManager& entityManager);
47
48 [[nodiscard]] Vec2f GetPosition(Entity entity) const;
49 [[nodiscard]] const std::vector<Vec2f>& GetAllPositions() const;
50 void SetPosition(Entity entity, Vec2f position);
51
52 [[nodiscard]] Vec2f GetScale(Entity entity) const;
53 [[nodiscard]] const std::vector<Vec2f>& GetAllScales() const;
54 void SetScale(Entity entity, Vec2f scale);
55
56 [[nodiscard]] Degree GetRotation(Entity entity) const;
57 [[nodiscard]] const std::vector<Degree>& GetAllRotations() const;
58 void SetRotation(Entity entity, Degree rotation);
59
60 void AddComponent(Entity entity);
61 void RemoveComponent(Entity entity);
62
63private:
64 PositionManager positionManager_;
65 ScaleManager scaleManager_;
66 RotationManager rotationManager_;
67};
68
69}
ComponentManager is a class that owns Component in a contiguous array. Component indexing is done wit...
Definition: component.h:33
Degree is an utility class that describes degree angles (0 to 360). It can be easily converted to Rad...
Definition: angle.h:56
Manages the entities in an array using bitwise operations to know if it has components.
Definition: entity.h:35
PositionManager is a ComponentManager that holds positions in 2d space. Positions are in physics spac...
Definition: transform.h:15
RotationManager is a ComponentManager that holds the Degree angle.
Definition: transform.h:35
ScaleManager is a ComponentManager that holds the scale ratio in x and y. By default,...
Definition: transform.h:25
void AddComponent(Entity entity) override
AddComponent is a method that sets the flag C in the EntityManager and resize if need the components_...
Definition: transform.cpp:5
TransformManager is a class combining a PositionManager, a ScaleManager and a RotationManager in one.
Definition: transform.h:44
std::uint32_t Entity
Entity is the type used to define an game world entity. An Entity is just an index,...
Definition: entity.h:17
Vec2f is a utility class that represents a mathematical 2d vector.
Definition: vec2.h:12