Uranus  1.0.1.0
Uranus is a GameEngine written in C++
Loading...
Searching...
No Matches
Components.hpp
1/*
2** EPITECH PROJECT, 2023
3** Components.hpp
4** File description:
5** Components.hpp
6*/
7
8#ifndef URANUS_COMPONENTS_HPP
9#define URANUS_COMPONENTS_HPP
10
11#include "uranus/engine/Clock.hpp"
12#include "uranus/engine/Event.hpp"
13#include "uranus/engine/Manager.hpp"
14#include "uranus/engine/Sprite.hpp"
15
16namespace uranus::ecs::component {
17
18 struct Name {
19 std::string uniqueName;
20 };
21
22 struct Position {
23 float x;
24 float y;
25 };
26
27 struct Velocity {
28 float x;
29 float y;
30 };
31
32 struct Drawable {
33 sf::Shape *shape = nullptr;
34 sf::Color color = sf::Color::White;
35
36 ~Drawable()
37 {
38 if (shape != nullptr) delete shape;
39 }
40 };
41
42 struct Sprite {
43 std::shared_ptr<engine::Sprite> sprite;
44 };
45
47 float x;
48 float y;
49 float width;
50 float height;
51 std::array<bool, LAYER_SIZE> layer;
52 std::array<bool, MASK_SIZE> mask;
53 std::function<void(const size_t, const size_t)> callback;
54 };
55
57 std::function<void(const size_t, const engine::Event)> callback;
58 };
59
60 struct InputMouse {
61 std::function<void(const size_t, const engine::Event)> callback;
62 };
63
64 struct Loop {
65 std::function<void(const size_t)> update;
66 };
67
68 struct FrameData {
69 float frameTime;
70 int frame;
71 };
72
74 std::string name;
75 bool loop;
76 float length;
77 engine::Clock clock;
78 bool isPlaying;
79 std::vector<component::FrameData> frames;
80 };
81
82 struct Animation {
83 int hFrame;
84 int vFrame;
85 std::function<void(const size_t entity, const std::string &animationName)> callback;
86 std::vector<component::AnimationData> animations;
87 };
88
89} // namespace uranus::ecs::component
90
91void deletePosition(size_t entity);
92void deleteVelocity(size_t entity);
93void deleteDrawable(size_t entity);
94void deleteInputKeyboard(size_t entity);
95void deleteInputMouse(size_t entity);
96void deleteSpriteComponent(size_t entity);
97void deleteCollisionable(size_t entity);
98void deleteLoopComponent(size_t entity);
99void deleteAnimationComponent(size_t entity);
100void deleteNameComponent(size_t entity);
101
102#endif // URANUS_COMPONENTS_HPP
Definition: Clock.hpp:14
Definition: Event.hpp:14
Definition: Components.hpp:73
Definition: Components.hpp:82
Definition: Components.hpp:46
Definition: Components.hpp:32
Definition: Components.hpp:68
Definition: Components.hpp:56
Definition: Components.hpp:60
Definition: Components.hpp:64
Definition: Components.hpp:18
Definition: Components.hpp:22
Definition: Components.hpp:42
Definition: Components.hpp:27