Skip to content

Commit

Permalink
Merge branch 'feat/all-command' of github.com:maelbecel/R-Type into f…
Browse files Browse the repository at this point in the history
…eat/all-command
  • Loading branch information
thomasjuin1 committed Jan 9, 2024
2 parents 391550f + 5b41a1c commit 7c3afcb
Show file tree
Hide file tree
Showing 9 changed files with 69 additions and 10 deletions.
1 change: 1 addition & 0 deletions Client/src/Layer/RTypeLayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ namespace RType {
Scenes[GAME]->RegisterSystem(new AnimationSystem());
Scenes[GAME]->RegisterSystem(new MovingSystem(1.5f));
Scenes[GAME]->RegisterSystem(collisionSystem);
Scenes[GAME]->RegisterSystem(new ClockSystem());
// Scenes[GAME]->Subscribe<Events::OnEntityCreated>(subscribe);
// Scenes[GAME]->Subscribe<Events::OnEntityDestroyed>(subscribe);
Scenes[GAME]->Subscribe<Exodia::Events::OnCollisionEntered>(collisionSystem);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ namespace Exodia {
buffer.Write(&hasTexture, sizeof(bool));

if (Texture) {
EXODIA_CORE_ERROR("Has texture {0}", hasTexture);
buffer.Resize(buffer.Size + sizeof(Texture->GetAssetHandle()) + sizeof(Texture->GetCoords()) +
sizeof(Texture->GetTextureCellSize()) + sizeof(Texture->GetTextureSpriteSize()));

Expand Down Expand Up @@ -147,10 +146,8 @@ namespace Exodia {
else
hasTexture = false;
offset += sizeof(bool);
std::cout << "Has texture " << hasTexture << std::endl;

if (!hasTexture) {
EXODIA_CORE_ERROR("Hasnt texture");
return;
}
Exodia::AssetHandle assetHandle;
Expand Down
1 change: 1 addition & 0 deletions R-Type/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ set(SOURCES_GAME_ENGINE
# -- System source files

src/System/AnimationSystem.cpp
src/System/ClockSystem.cpp

# -- Script source files

Expand Down
1 change: 1 addition & 0 deletions R-Type/R-Type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "src/Scripts/Star/Star.hpp"

#include "src/System/AnimationSystem.hpp"
#include "src/System/ClockSystem.hpp"

#include "src/Event/EntityEventSubscriber.hpp"
#include "src/Event/TakeDamage.hpp"
Expand Down
1 change: 0 additions & 1 deletion R-Type/src/Scripts/Pata-pata/Pata-pata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ namespace RType {
float &mytime = clock.Get().ElapsedTime;

if (_State == State::ALIVE) {
mytime += ts.GetSeconds();
body.Get().Velocity.y = (float)(amplitude * sin(frequency * mytime * PI));
}
}
Expand Down
8 changes: 2 additions & 6 deletions R-Type/src/Scripts/Star/Star.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,16 +64,14 @@ namespace RType {
}

void Star::OnUpdate(Timestep ts) {
ComponentHandle<Clock> clock = GetComponent<Clock>();
ComponentHandle<TransformComponent> transform = GetComponent<TransformComponent>();
ComponentHandle<CircleRendererComponent> circle = GetComponent<CircleRendererComponent>();
World *world = HandleEntity->GetWorld();
if (!transform || !circle || !clock || !world) {
EXODIA_WARN("No transform, circle, clock or world");
if (!transform || !circle || !world) {
EXODIA_WARN("No transform, circle or world");
return;
}

float &mytime = clock.Get().ElapsedTime;
Entity *camera = world->GetEntityByTag("Camera");
if (!camera) {
EXODIA_WARN("No camera");
Expand All @@ -86,8 +84,6 @@ namespace RType {
return;
}

mytime += ts.GetMilliseconds();

CircleRendererComponent &cc = circle.Get();

float seconds = ts.GetSeconds();
Expand Down
29 changes: 29 additions & 0 deletions R-Type/src/System/ClockSystem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
** EPITECH PROJECT, 2023
** R-Type
** File description:
** ClockSystem
*/

#include "ClockSystem.hpp"
#include "Component/Clock.hpp"

namespace RType {

using namespace Exodia;

/////////////
// Methods //
/////////////

void ClockSystem::Update(World *world, Timestep ts) {

world->LockMutex();
world->ForEach<Clock>([&](Entity *entity, auto clock) {
clock->ElapsedTime += ts;
EXODIA_INFO("ClockSystem: ElapsedTime: {0} from entity {1}", clock->ElapsedTime,
entity->GetComponent<TagComponent>().Get().Tag);
});
world->UnlockMutex();
}
}; // namespace RType
33 changes: 33 additions & 0 deletions R-Type/src/System/ClockSystem.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
** EPITECH PROJECT, 2023
** R-Type
** File description:
** AnimationSystem
*/

#ifndef CLOCKSYSTEM_HPP_
#define CLOCKSYSTEM_HPP_

// R-Type Events includes
#include "Event/AnimationEvent.hpp"

namespace RType {

class ClockSystem : public Exodia::EntitySystem {

//////////////////////////////
// Constructor & Destructor //
//////////////////////////////
public:
ClockSystem() = default;
~ClockSystem() = default;

/////////////
// Methods //
/////////////
public:
void Update(Exodia::World *world, Exodia::Timestep ts) override;
};
}; // namespace RType

#endif /* !CLOCKSYSTEM_HPP_ */
2 changes: 2 additions & 0 deletions Server/src/Server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,10 @@ namespace Exodia {
RType::EntityEventSubscriber *subscribe = new RType::EntityEventSubscriber(_Network);
CollisionSystem *collisionSystem = new CollisionSystem();
RType::TakeDamageSubscriber *takeDamage = new RType::TakeDamageSubscriber();
ClockSystem *clockSystem = new ClockSystem();

systems.push_back(collisionSystem);
systems.push_back(clockSystem);

InitScene(GAME, systems);

Expand Down

0 comments on commit 7c3afcb

Please sign in to comment.