-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/rb 56 check deads #38
Merged
Merged
Changes from all commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
fb9a775
GAME-LOGIC: Modify screen size
TTENSHII 0bd76aa
GAME-LOGIC: Add deathChecker func
TTENSHII 6c4a7f0
GAME-LOGIC: Add begin of client side system
TTENSHII 6f72625
GAME-LOGIC: Add v1 of setEntityDeathFunction
TTENSHII d8c3ffd
Merge branch 'dev' into feature/RB-56-checkDeads
TTENSHII e562010
FORMAT-AUTO: automatic format on pull request #38
github-actions[bot] 1d96a5b
GAME-LOGIC: Add character run
TTENSHII 884b448
Merge branch 'feature/RB-56-checkDeads' of github.com:X-R-G-B/R-Bus i…
TTENSHII eb80397
GAME-LOGIC: Fix deathSystems return value
TTENSHII 3c2d55a
Merge branch 'dev' into feature/RB-56-checkDeads
TTENSHII 30277f8
GAME-LOGIC: Fix ternary
TTENSHII e80cd94
GAME-LOGIC: Add funcitonnal EntityDeathFunction
TTENSHII d58aad4
FORMAT-AUTO: automatic format on pull request #38
github-actions[bot] cf12c46
GAME-LOGIC: Add test
TTENSHII c99020e
CLIENT-GAME: Fix test func
TTENSHII b10872d
FORMAT-AUTO: automatic format on pull request #38
github-actions[bot] 10d5d6c
GAME-LOGIC: Add enemy test
TTENSHII 9b7614b
Merge branch 'feature/RB-56-checkDeads' of github.com:X-R-G-B/R-Bus i…
TTENSHII 67ad627
FORMAT-AUTO: automatic format on pull request #38
github-actions[bot] cf6bf99
GAME-LOGIC: Add debug
TTENSHII e883a93
FORMAT-AUTO: automatic format on pull request #38
github-actions[bot] e623b10
Merge branch 'dev' into feature/RB-56-checkDeads
guillaumeAbel 1a778a6
Merge branch 'dev' into feature/RB-56-checkDeads
TTENSHII 98a7736
Merge branch 'feature/RB-56-checkDeads' of github.com:X-R-G-B/R-Bus i…
TTENSHII d751c66
CLIENT-GAME: Add tests for debug
TTENSHII 63fcc33
FORMAT-AUTO: automatic format on pull request #38
github-actions[bot] 225cfcb
GAME-LOGIC: Fix sparse bug
TTENSHII 67f2c43
GAME-LOGIC: Fix merge requests
TTENSHII 71c9419
GAME-LOGIC: Fix animation rect
TTENSHII eb01dd8
FORMAT-AUTO: automatic format on pull request #38
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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,67 @@ | ||
/* | ||
** EPITECH PROJECT, 2023 | ||
** R-Bus | ||
** File description: | ||
** Death systems implementation | ||
*/ | ||
|
||
#include "DeathSystems.hpp" | ||
#include <optional> | ||
#include <unordered_map> | ||
#include "CustomTypes.hpp" | ||
#include "Registry.hpp" | ||
|
||
namespace Systems { | ||
|
||
const std::function<void(std::size_t)> setPlayerAnimRectDeath = | ||
[](std::size_t id) { | ||
Registry::components<Types::AnimRect> arrAnimRect = | ||
Registry::getInstance().getComponents<Types::AnimRect>(); | ||
|
||
if (arrAnimRect.exist(id)) { | ||
Types::AnimRect& anim = arrAnimRect[id]; | ||
if (anim.currentRectList != Types::RectListType::DEAD) { | ||
anim.changeRectList(Types::RectListType::DEAD); | ||
} | ||
} | ||
}; | ||
|
||
const std::function<void(std::size_t)> setEnemyDeathFunc = | ||
[](std::size_t id) { | ||
Registry::getInstance().removeEntity(id); | ||
}; | ||
|
||
// MAP FOR DEATH FUNCTIONS FOR EACH ENTITY | ||
const std::unordered_map<std::type_index, std::function<void(std::size_t)>> | ||
deathFunctions = { | ||
{std::type_index(typeid(Types::Player)), setPlayerAnimRectDeath}, | ||
{std::type_index(typeid(Types::Enemy)), setEnemyDeathFunc }, | ||
}; | ||
|
||
void DeathSystems::setEntityDeathFunction( | ||
std::size_t /*unused*/, | ||
std::size_t /*unused*/) | ||
{ | ||
Registry::components<Types::Dead> arrDead = | ||
Registry::getInstance().getComponents<Types::Dead>(); | ||
|
||
std::vector<std::size_t> ids = arrDead.getExistingsId(); | ||
|
||
for (const auto& [typeIndex, function] : deathFunctions) { | ||
std::vector<std::size_t> entities = | ||
Registry::getInstance().getEntitiesByComponents({typeIndex}); | ||
for (std::size_t id : entities) { | ||
if (arrDead.exist(id) | ||
&& arrDead[id].deathFunction == std::nullopt) { | ||
arrDead[id].deathFunction = function; | ||
} | ||
} | ||
} | ||
} | ||
|
||
std::vector<std::function<void(std::size_t, std::size_t)>> | ||
DeathSystems::getDeathSystems() | ||
{ | ||
return {setEntityDeathFunction}; | ||
} | ||
} // namespace Systems |
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,21 @@ | ||
/* | ||
** EPITECH PROJECT, 2023 | ||
** R-Bus | ||
** File description: | ||
** DeathSystems | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include <functional> | ||
#include <vector> | ||
|
||
namespace Systems { | ||
namespace DeathSystems { | ||
std::vector<std::function<void(std::size_t, std::size_t)>> | ||
getDeathSystems(); | ||
void setEntityDeathFunction( | ||
std::size_t /*unused*/, | ||
std::size_t /*unused*/); | ||
} // namespace DeathSystems | ||
} // namespace Systems |
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pourquoi supprimer ?