R-Type  1.0.1.0
Rewrite of the R-Type game with networking ability
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/Core.hpp"
12#include "uranus/engine/components/Clock.hpp"
13#include "uranus/engine/components/Event.hpp"
14#include "uranus/engine/components/Sprite.hpp"
15#include "uranus/engine/manager/Manager.hpp"
16#include <bitset>
17
22
23 struct NetworkId {
24 std::uint32_t uniqueId;
25 };
26
27 struct Name {
28 std::string uniqueName;
29 };
30
31 struct Position {
32 float x;
33 float y;
34 };
35
36 struct Velocity {
37 float x;
38 float y;
39 };
40
41 struct Drawable {
42 size_t zIndex = 0;
43 bool visible = true;
44 protected:
45 explicit Drawable(size_t zIndex, bool visible) : zIndex(zIndex), visible(visible) {};
46 };
47
48 struct Sprite : public Drawable {
49 std::shared_ptr<engine::Sprite> sprite;
50 explicit Sprite(const std::shared_ptr<engine::Sprite> &sprite, size_t zIndex = 0, bool visible = true) : Drawable(zIndex, visible), sprite(sprite) {};
51 };
52
53 struct Shape : public Drawable {
54 std::shared_ptr<sf::Shape> shape;
55 explicit Shape(const std::shared_ptr<sf::Shape> &shape, size_t zIndex = 0, bool visible = true) : Drawable(zIndex, visible), shape(shape) {};
56 };
57
59 float x;
60 float y;
61 float width;
62 float height;
63 std::bitset<LAYER_MASK_SIZE> layer;
64 std::bitset<LAYER_MASK_SIZE> mask;
65 std::function<void(const size_t, const size_t)> callback;
66 };
67
69 std::function<void(const size_t, const engine::Event)> callback;
70 };
71
72 struct InputMouse {
73 std::function<void(const size_t, const engine::Event)> callback;
74 };
75
76 struct Loop {
77 std::function<void(const size_t, float delta)> update;
78 };
79
80 struct FrameData {
81 float frameTime;
82 int frame;
83 };
84
86 std::string name;
87 bool loop;
88 float length;
89 engine::Clock clock;
90 bool isPlaying;
91 std::vector<component::FrameData> frames;
92 };
93
94 struct Animation {
95 int hFrame;
96 int vFrame;
97 std::function<void(const size_t entity, const std::string &animationName)> callback;
98 std::vector<component::AnimationData> animations;
99 };
100
101 struct Dead {
102 bool isDead = true;
103 };
104
105} // namespace uranus::ecs::component
106
107void deletePosition(size_t entity);
108void deleteVelocity(size_t entity);
109void deleteDrawable(size_t entity);
110void deleteInputKeyboard(size_t entity);
111void deleteInputMouse(size_t entity);
112void deleteSpriteComponent(size_t entity);
113void deleteCollisionable(size_t entity);
114void deleteLoopComponent(size_t entity);
115void deleteAnimationComponent(size_t entity);
116void deleteNameComponent(size_t entity);
117void deleteShapeComponent(size_t entity);
118void deleteNetworkIdComponent(size_t entity);
119void deleteDeadComponent(size_t entity);
120
121#endif // URANUS_COMPONENTS_HPP
This file is used to include some core files of the engine.
Definition: Clock.hpp:14
Definition: Event.hpp:14
Namespace containing all the base components.
Definition: Components.hpp:21
Definition: Components.hpp:94
Definition: Components.hpp:85
Definition: Components.hpp:58
Definition: Components.hpp:101
Definition: Components.hpp:80
Definition: Components.hpp:68
Definition: Components.hpp:72
Definition: Components.hpp:76
Definition: Components.hpp:27
Definition: Components.hpp:23
Definition: Components.hpp:31
Definition: Components.hpp:36
Definition: Components.hpp:41
Definition: Components.hpp:53
Definition: Components.hpp:48