From 8126d4a7e4d284b9276a644c68efb3970e4ef8d8 Mon Sep 17 00:00:00 2001 From: Askou Date: Tue, 15 Jun 2021 09:25:26 +0200 Subject: [PATCH] add timer on noclipBonus --- sources/Component/Bonus/PlayerBonusComponent.hpp | 6 ++++-- sources/Items/Bonus.cpp | 6 ++---- sources/Map/Map.cpp | 3 ++- sources/System/Bonus/PlayerBonusSystem.cpp | 3 +++ 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/sources/Component/Bonus/PlayerBonusComponent.hpp b/sources/Component/Bonus/PlayerBonusComponent.hpp index 548f1158..38622327 100644 --- a/sources/Component/Bonus/PlayerBonusComponent.hpp +++ b/sources/Component/Bonus/PlayerBonusComponent.hpp @@ -24,8 +24,10 @@ namespace BBM std::chrono::nanoseconds rangeBonusRate = 10s; //! @brief The number of nanosecond before the expiration of a range bonus. std::chrono::nanoseconds nextRangeBonusRate = rangeBonusRate; - //! @brief Tell if the bonus no clip is on - bool isNoClipOn = false; + //! @brief The number of seconds before a range bonus expire. This variable is used to reset the nextRangeBonusRate value. + std::chrono::nanoseconds noClipBonusRate = 10s; + //! @brief The number of nanosecond before the expiration of a range bonus. + std::chrono::nanoseconds nextNoClipRate = noClipBonusRate; //! @inherit WAL::Component *clone(WAL::Entity &entity) const override; diff --git a/sources/Items/Bonus.cpp b/sources/Items/Bonus.cpp index 6b30ecd1..fa1f2e77 100644 --- a/sources/Items/Bonus.cpp +++ b/sources/Items/Bonus.cpp @@ -52,9 +52,7 @@ namespace BBM { auto *playerBonus = player.tryGetComponent(); if (!playerBonus) return; - static void SpeedUSpeedUpBonuspBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis); - static void SpeedUpBonus(WAL::Entity &player, const WAL::Entity &bonus, CollisionComponent::CollidedAxis axis); - playerBonus->isNoClipOn = true + playerBonus->nextNoClipRate = playerBonus->nextSpeedBonusRate; } Bonus::BonusType Bonus::getRandomBonusType() @@ -62,7 +60,7 @@ namespace BBM { double rnd = static_cast(std::rand()) / RAND_MAX; if (rnd < 0.8) - return (static_cast(std::rand() % (EXPLOSIONINC - 1) + 1)); + return (static_cast(std::rand() % (NOCLIP - 1) + 1)); return (NOTHING); } } \ No newline at end of file diff --git a/sources/Map/Map.cpp b/sources/Map/Map.cpp index 323fadb1..c711e8e0 100644 --- a/sources/Map/Map.cpp +++ b/sources/Map/Map.cpp @@ -12,6 +12,7 @@ #include "Component/Movable/MovableComponent.hpp" #include #include +#include namespace RAY3D = RAY::Drawables::Drawables3D; using namespace std::chrono_literals; @@ -23,7 +24,7 @@ namespace BBM CollisionComponent::CollidedAxis collidedAxis) { auto *mov = entity.tryGetComponent(); - + auto *playerBonus = entity.tryGetComponent