r-type  0.0.0
R-Type main
Loading...
Searching...
No Matches
Component.hpp
Go to the documentation of this file.
1///
2/// @file Component.hpp
3/// @brief This file contains the component definitions
4/// @namespace ecs
5///
6
7#pragma once
8
9#include <string>
10
11namespace ecs
12{
14 {
15 std::string id;
16 };
17 struct Audio final : IComponent
18 {
19 std::string path;
20 float volume;
21 bool loop;
22 bool play;
23 };
24 struct Color final : IComponent
25 {
26 unsigned char r{};
27 unsigned char g{};
28 unsigned char b{};
29 unsigned char a{};
30 };
31 struct Font final : IComponent
32 {
33 std::string path;
34 };
35 struct Player final : IComponent
36 {
37 bool is_cli{};
38 // bool is_alive{};
39 };
40 struct Health final : IComponent
41 {
42 float current;
43 float max;
44 };
45 struct Pixel final : IComponent
46 {
47 };
48 struct Rect final : IComponent
49 { // TODO(bobis33): remove, only used for texture actually
50 float pos_x{}, pos_y{};
51 int size_x{}, size_y{};
52 };
53 struct Scale final : IComponent
54 {
55 float x{}, y{};
56 };
57 struct Text final : IComponent
58 {
59 std::string content;
60 unsigned int font_size;
61 };
62 struct Texture final : IComponent
63 {
64 std::string path;
65 // float rect_pos_x{}, rect_pos_y{};
66 // int rect_size_x{}, rect_size_y{};
67 };
68 struct Transform final : IComponent
69 {
70 float x{}, y{};
71 float rotation{};
72 };
73 struct Velocity final : IComponent
74 {
75 float x{}, y{};
76 };
77 struct Animation final : IComponent
78 {
82 float current_time{};
86 };
87 struct Projectile final : IComponent
88 {
89 enum Type
90 {
93 };
95 float damage;
96 float lifetime;
98 int pierce_remaining; // number of enemies it can still pass through (>=1)
99 };
100
101 struct BeamCharge final : IComponent
102 {
105 };
106
117
118 struct Enemy final : IComponent
119 {
120 float health;
122 float damage;
123 float speed;
126 };
127
140
141 struct Hitbox final : IComponent
142 {
143 float radius;
144 float offsetX = 0.0f;
145 float offsetY = 0.0f;
146 };
147
149 {
155 };
156
157 struct Floor final : IComponent
158 {
159 };
160
161 struct Ceiling final : IComponent
162 {
163 };
164
165 struct Scrolling final : IComponent
166 {
167 float speed_x; // Negative to scroll left
168 float original_width; // Unscaled texture width in pixels
169 float original_height; // Unscaled texture height in pixels
170 bool fit_width; // If true, scale X to fit window width
171 };
172
173 struct Score final : IComponent
174 {
175 int value;
176 };
177 struct Layer final : IComponent
178 {
179 int layer;
180 };
181
182} // namespace ecs
float frame_duration
Definition Component.hpp:81
std::string path
Definition Component.hpp:19
float volume
Definition Component.hpp:20
unsigned char a
Definition Component.hpp:29
unsigned char r
Definition Component.hpp:26
unsigned char g
Definition Component.hpp:27
unsigned char b
Definition Component.hpp:28
float shoot_cooldown
float max_health
float last_shot_time
float current_lifetime
std::string path
Definition Component.hpp:33
float current
Definition Component.hpp:42
std::string id
Definition Component.hpp:15
float current_lifetime
Definition Component.hpp:97
float pos_y
Definition Component.hpp:50
float pos_x
Definition Component.hpp:50
float original_height
unsigned int font_size
Definition Component.hpp:60
std::string content
Definition Component.hpp:59
std::string path
Definition Component.hpp:64