Skip to content

Commit

Permalink
feat: add Timer component for ECS entities and update includes
Browse files Browse the repository at this point in the history
  • Loading branch information
MasterLaplace committed Nov 22, 2024
1 parent 448368b commit 6f0bf1b
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 2 deletions.
52 changes: 52 additions & 0 deletions Flakkari/Engine/EntityComponentSystem/Components/Common/Timer.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
** EPITECH PROJECT, 2024
** Title: Flakkari
** Author: MasterLaplace
** Created: 2024-11-17
** File description:
** Timer
*/

#ifndef Timer_HPP_
#define Timer_HPP_

#include <cstring>
#include <string>
#include <chrono>

#include "config.h.in"

namespace Flakkari::Engine::ECS::Components::Common {
LPL_PACKED_START

/**
* @brief Timer component for ECS entities that have a timer attached to them
*
* @details This component is used to store the current time and the maximum time
*/
struct Timer {
std::chrono::steady_clock::time_point lastTime = std::chrono::steady_clock::now();
float maxTime;

Timer() : maxTime(0) {}
Timer(bool spawed) : maxTime(spawed) {}
Timer(const Timer &other) : maxTime(other.maxTime) {}

Timer &operator=(const Timer &other)
{
if (this != &other)
{
lastTime = other.lastTime;
maxTime = other.maxTime;
}

return *this;
}

std::size_t size() const { return sizeof(*this); }
};

LPL_PACKED_END
} // namespace Flakkari::Engine::ECS::Components::Common

#endif /* !Timer_HPP_ */
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#define FLAKKARI_COMPONENTS3D_HPP_

#include "3D/BoxCollider.hpp" // Collider component (center, size)
#include "3D/Control.hpp" // Control component (up, down, left, right, shoot)
#include "3D/Movable.hpp" // Movable component (velocity, acceleration)
#include "3D/Control.hpp" // Control component (move_[up, down, left, right, ...], look_[*] shoot)
#include "3D/Movable.hpp" // Movable component (velocity, acceleration, minSpeed, maxSpeed)
#include "3D/RigidBody.hpp" // RigidBody component (mass, drag, angularDrag, useGravity, isKinematic)
#include "3D/SphereCollider.hpp" // Collider component (center, radius)
#include "3D/Transform.hpp" // Transform component (position, rotation, scale)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "Common/Spawned.hpp" // Spawned component (spawned)
#include "Common/Tag.hpp" // Tag component (tag)
#include "Common/Template.hpp" // Template component (name)
#include "Common/Timer.hpp" // Timer component (time)
#include "Common/Weapon.hpp" // Weapon component (name)

#include "Common/NetworkEvent.hpp" // NetworkEvent component (event)
Expand Down

0 comments on commit 6f0bf1b

Please sign in to comment.