RType
Drawable.hpp
Go to the documentation of this file.
1 /*
2 ** EPITECH PROJECT, 2023
3 ** RType
4 ** File description:
5 ** Drawable.hpp
6 */
7 
8 #pragma once
9 
10 #include "../networking/shared/USocket.hpp"
11 #include "IComponent.hpp"
12 #include <iostream>
13 #include <memory>
14 #include <tuple>
15 #include <vector>
16 
17 typedef std::tuple<float, float> Position;
18 typedef std::tuple<float, float> Size;
19 typedef std::tuple<int, int, int, int> Rect;
20 
21 class Drawable : public IComponentRType
22 {
23  public:
24 
25  /**
26  * @brief Construct a new Drawable:: Drawable object
27  */
28  Drawable();
29 
30  /**
31  * @brief getAttribute, get the attribute
32  *
33  * @return attribute (char *)
34  */
35  [[nodiscard]] char *getAttribute() const;
36 
37  /**
38  * @brief setAttribute, set the attribute
39  *
40  * @param attribute
41  */
42  void setAttribute(std::string attribute);
43 
44 
45  /**
46  * @brief getPosition, get the position
47  *
48  * @return position (std::tuple<float, float>)
49  */
50  [[nodiscard]] Position getPosition() const;
51 
52  /**
53  * @brief setPosition, set the position
54  *
55  * @param position
56  */
57  void setPosition(std::tuple<float, float> position);
58 
59 
60  /**
61  * @brief getSize, get the size
62  *
63  * @return size (std::tuple<float, float>)
64  */
65  [[nodiscard]] Size getSize() const;
66 
67  /**
68  * @brief setSize, set the size
69  *
70  * @param size
71  */
72  void setSize(std::tuple<float, float> size);
73 
74  /**
75  * @brief getScale, get the scale
76  *
77  * @return scale (float)
78  */
79  [[nodiscard]] float getScale() const;
80 
81  /**
82  * @brief setScale, set the scale
83  *
84  * @param scale
85  */
86  void setScale(float scale);
87 
88 
89  /**
90  * @brief getRect, get the rect
91  *
92  * @return rect (std::tuple<int, int, int, int>)
93  */
94  [[nodiscard]] Rect getRect() const;
95 
96  /**
97  * @brief setRect, set the rect
98  *
99  * @param rect
100  */
101  void setRect(std::tuple<int, int, int, int> rect);
102 
103 
104  /**
105  * @brief getPacket, get the packet
106  *
107  * @return packet (std::shared_ptr<Packet>)
108  */
109  [[nodiscard]]
110  std::shared_ptr<Packet> getPacket();
111 
112 
113  /**
114  * @brief setHasChanged, set if the drawable has changed
115  *
116  * @param hasChanged
117  */
118  void setHasChanged(bool hasChanged);
119 
120  /**
121  * @brief getHasChanged, get if the drawable has changed
122  *
123  * @return hasChanged (bool)
124  */
125  [[nodiscard]]
126  bool getHasChanged() const;
127 
128 
129  /**
130  * @brief addDrawableCollision, add a drawable collision
131  *
132  * @param drawableCollision
133  */
134  void addDrawableCollision(std::shared_ptr<Drawable> drawableCollision);
135 
136  /**
137  * @brief getDrawablesCollision, get the drawables collision
138  *
139  * @return drawablesCollision (std::vector<std::shared_ptr<Drawable>>)
140  */
142 
144  bool _toDelete = false;
145  int _score = 0;
146 
147  protected:
151  float _scale;
152  bool hasChanged = false;
154 };