-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Components): Add new components: NetworkEvent, Collider, and Spa…
…wned
- Loading branch information
1 parent
ce6d10b
commit d045fe3
Showing
10 changed files
with
376 additions
and
3 deletions.
There are no files selected for viewing
41 changes: 41 additions & 0 deletions
41
Flakkari/Engine/EntityComponentSystem/Components/2D/Collider.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
** EPITECH PROJECT, 2024 | ||
** Title: Flakkari | ||
** Author: MasterLaplace | ||
** Created: 2023-01-14 | ||
** File description: | ||
** Collider | ||
*/ | ||
|
||
#ifndef COLLIDER_HPP_ | ||
#define COLLIDER_HPP_ | ||
|
||
#include <string> | ||
#include "../../../Math/Vector.hpp" | ||
|
||
#include "Network/Packed.hpp" | ||
|
||
namespace Flakkari::Engine::ECS::Components::_2D { | ||
PACKED_START | ||
|
||
/** | ||
* @brief Collider component for ECS entities that have a script attached to them | ||
* | ||
* @details This component is used to store the path to the script that will be executed | ||
*/ | ||
struct Collider { | ||
Math::Vector2f _size; | ||
|
||
Collider() : _size() {} | ||
Collider(Math::Vector2f nsize) : _size(nsize) {} | ||
Collider(const Collider &other) : _size(other._size) {} | ||
|
||
std::size_t size() const { | ||
return sizeof(_size); | ||
} | ||
}; | ||
|
||
PACKED_END | ||
} // namespace Flakkari::Engine::ECS::Components::_2D | ||
|
||
#endif /* !COLLIDER_HPP_ */ |
44 changes: 44 additions & 0 deletions
44
Flakkari/Engine/EntityComponentSystem/Components/2D/RigidBody.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* | ||
** EPITECH PROJECT, 2024 | ||
** Title: Flakkari | ||
** Author: MasterLaplace | ||
** Created: 2023-01-14 | ||
** File description: | ||
** RigidBody | ||
*/ | ||
|
||
#ifndef RIGIDBODY_HPP_ | ||
#define RIGIDBODY_HPP_ | ||
|
||
#include "../../../Math/Vector.hpp" | ||
|
||
#include "Network/Packed.hpp" | ||
|
||
namespace Flakkari::Engine::ECS::Components::_2D { | ||
PACKED_START | ||
|
||
/** | ||
* @brief RigidBody represent the physical properties of a rigid body in a game engine | ||
* | ||
*/ | ||
struct RigidBody { | ||
float mass; | ||
float restitution; | ||
float friction; | ||
float gravityScale; | ||
bool isGravityAffected = true; | ||
bool isKinematic = false; | ||
|
||
RigidBody() : mass(0), restitution(0), friction(0), gravityScale(0), isGravityAffected(false), isKinematic(false) {}; | ||
RigidBody(const RigidBody &other) : mass(other.mass), restitution(other.restitution), friction(other.friction), gravityScale(other.gravityScale), isGravityAffected(other.isGravityAffected), isKinematic(other.isKinematic) {}; | ||
RigidBody(float mass, float restitution, float friction, float gravityScale) : mass(mass), restitution(restitution), friction(friction), gravityScale(gravityScale), isGravityAffected(true), isKinematic(false) {}; | ||
|
||
std::size_t size() const { | ||
return sizeof(*this); | ||
} | ||
}; | ||
|
||
PACKED_END | ||
} // namespace Flakkari::Engine::ECS::Components::_2D | ||
|
||
#endif /* !RIGIDBODY_HPP_ */ |
43 changes: 43 additions & 0 deletions
43
Flakkari/Engine/EntityComponentSystem/Components/Common/Health.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
** EPITECH PROJECT, 2024 | ||
** Title: Flakkari | ||
** Author: MasterLaplace | ||
** Created: 2023-01-14 | ||
** File description: | ||
** Health | ||
*/ | ||
|
||
#ifndef Health_HPP_ | ||
#define Health_HPP_ | ||
|
||
#include <cstddef> | ||
|
||
#include "Network/Packed.hpp" | ||
|
||
namespace Flakkari::Engine::ECS::Components::Common { | ||
PACKED_START | ||
|
||
/** | ||
* @brief Health is a structure that represents the life of an "living object" | ||
* | ||
*/ | ||
struct Health { | ||
unsigned int currentHealth; | ||
unsigned int maxHealth = 100; | ||
unsigned int shield = 0; | ||
unsigned int maxShield = 100; | ||
|
||
Health() : currentHealth(100), maxHealth(100), shield(0), maxShield(100) {}; | ||
Health(unsigned int currentHealth, unsigned int maxHealth, unsigned int shield, unsigned int maxShield) : | ||
currentHealth(currentHealth), maxHealth(maxHealth), shield(shield), maxShield(maxShield) {}; | ||
Health(const Health &other) : currentHealth(other.currentHealth), maxHealth(other.maxHealth), shield(other.shield), maxShield(other.maxShield) {}; | ||
|
||
unsigned int size() const { | ||
return sizeof(*this); | ||
} | ||
}; | ||
|
||
PACKED_END | ||
} // namespace Flakkari::Engine::ECS::Components::Common | ||
|
||
#endif /* !Health_HPP_ */ |
51 changes: 51 additions & 0 deletions
51
Flakkari/Engine/EntityComponentSystem/Components/Common/Level.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
** EPITECH PROJECT, 2024 | ||
** Title: Flakkari | ||
** Author: MasterLaplace | ||
** Created: 2023-01-14 | ||
** File description: | ||
** Level | ||
*/ | ||
|
||
#ifndef LEVEL_HPP | ||
#define LEVEL_HPP | ||
|
||
#include <string> | ||
#include <cstring> | ||
|
||
#include "Network/Packed.hpp" | ||
|
||
namespace Flakkari::Engine::ECS::Components::Common { | ||
PACKED_START | ||
|
||
/** | ||
* @brief FontInfo is a structure that holds information about a Font | ||
* | ||
*/ | ||
struct Level { | ||
unsigned int level; | ||
const char *currentWeapon; | ||
unsigned int currentExp; | ||
unsigned int requiredExp; | ||
|
||
Level() : level(1), currentWeapon(""), currentExp(0), requiredExp(100) {} | ||
Level(unsigned int level, std::string currentWeapon, unsigned int currentExp, unsigned int requiredExp) | ||
: level(level), | ||
currentWeapon(currentWeapon.c_str()), | ||
currentExp(currentExp), | ||
requiredExp(requiredExp) {} | ||
Level(const Level &other) | ||
: level(other.level), | ||
currentWeapon(other.currentWeapon), | ||
currentExp(other.currentExp), | ||
requiredExp(other.requiredExp) {} | ||
|
||
std::size_t size() const { | ||
return sizeof(level) + std::strlen(currentWeapon) + sizeof(currentExp) + sizeof(requiredExp); | ||
} | ||
}; | ||
|
||
PACKED_END | ||
} // namespace Flakkari::Engine::ECS::Components::Common | ||
|
||
#endif //LEVEL_HPP |
31 changes: 31 additions & 0 deletions
31
Flakkari/Engine/EntityComponentSystem/Components/Common/NetworkEvent.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
** EPITECH PROJECT, 2024 | ||
** Title: Flakkari | ||
** Author: MasterLaplace | ||
** Created: 2023-01-14 | ||
** File description: | ||
** NetworkEvent | ||
*/ | ||
|
||
#ifndef NETWORKEVENT_HPP_ | ||
#define NETWORKEVENT_HPP_ | ||
|
||
#include <vector> | ||
|
||
namespace Flakkari::Engine::ECS::Components::Common { | ||
|
||
struct NetworkEvent { | ||
std::vector<unsigned short> events; | ||
|
||
NetworkEvent() = default; | ||
NetworkEvent(const NetworkEvent &other) : events(other.events) {}; | ||
NetworkEvent(const std::vector<unsigned short> &events) : events(events) {}; | ||
|
||
std::size_t size() const { | ||
return events.size() * sizeof(unsigned short); | ||
} | ||
}; | ||
|
||
} /* namespace Flakkari::Engine::ECS::Components::Common */ | ||
|
||
#endif /* !NETWORKEVENT_HPP_ */ |
41 changes: 41 additions & 0 deletions
41
Flakkari/Engine/EntityComponentSystem/Components/Common/Spawned.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
** EPITECH PROJECT, 2024 | ||
** Title: Flakkari | ||
** Author: MasterLaplace | ||
** Created: 2023-01-14 | ||
** File description: | ||
** Spawned | ||
*/ | ||
|
||
#ifndef SPAWNED_HPP_ | ||
#define SPAWNED_HPP_ | ||
|
||
#include <string> | ||
#include <cstring> | ||
|
||
#include "Network/Packed.hpp" | ||
|
||
namespace Flakkari::Engine::ECS::Components::Common { | ||
PACKED_START | ||
|
||
/** | ||
* @brief Spawned component for ECS entities that have a script attached to them | ||
* | ||
* @details This component is used to store the path to the script that will be executed | ||
*/ | ||
struct Spawned { | ||
bool has_spawned; | ||
|
||
Spawned() : has_spawned(false) {} | ||
Spawned(bool spawed) : has_spawned(spawed) {} | ||
Spawned(const Spawned &other) : has_spawned(other.has_spawned) {} | ||
|
||
std::size_t size() const { | ||
return sizeof(has_spawned); | ||
} | ||
}; | ||
|
||
PACKED_END | ||
} // namespace Flakkari::Engine::ECS::Components::Common | ||
|
||
#endif /* !SPAWNED_HPP_ */ |
55 changes: 55 additions & 0 deletions
55
Flakkari/Engine/EntityComponentSystem/Components/Common/Weapon.hpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
** EPITECH PROJECT, 2024 | ||
** Title: Flakkari | ||
** Author: MasterLaplace | ||
** Created: 2023-01-14 | ||
** File description: | ||
** Weapon | ||
*/ | ||
|
||
#ifndef WEAPON_HPP_ | ||
#define WEAPON_HPP_ | ||
|
||
#include <string> | ||
#include <cstring> | ||
|
||
#include "Network/Packed.hpp" | ||
|
||
namespace Flakkari::Engine::ECS::Components::Common { | ||
PACKED_START | ||
|
||
/** | ||
* @brief Weapon is a structure that defines the characteristics of a weapon. | ||
* | ||
* @details | ||
* The Weapon structure is used to define the characteristics of a weapon. | ||
* It is used by the WeaponComponent to handle the firing and reloading logic. | ||
* | ||
* @param | ||
* damage: The amount of damage dealt by the weapon. | ||
* fireRate: The rate of fire, shots per second. | ||
* currentAmmo: Current ammunition in the magazine. | ||
* reloadTime: Time it takes to reload the weapon in seconds. | ||
* timeSinceLastShot: Time elapsed since the last shot was fired. | ||
* isReloading: Is the weapon currently reloading. | ||
* maxAmmo: Maximum ammunition the weapon can hold. | ||
*/ | ||
struct Weapon { | ||
unsigned int damage; | ||
float fireRate; | ||
unsigned int level; | ||
|
||
Weapon() = default; | ||
Weapon(const Weapon &other) = default; | ||
Weapon(unsigned int dmg, float rate, unsigned int lvl) | ||
: damage(dmg), fireRate(rate), level(lvl){}; | ||
|
||
unsigned int size() const { | ||
return sizeof(*this); | ||
}; | ||
}; | ||
|
||
PACKED_END | ||
} // namespace Flakkari::Engine::ECS::Components::Common | ||
|
||
#endif /* !WEAPON_HPP_ */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.