feat(players): suport del segon jugador amb events amb player_id
This commit is contained in:
1 parent
74dad71cc2
commit
4e9d5df872
21 files changed
+309
-49
No files matched your search
@@ -5,6 +5,7 @@
|
||||
|
||||
#include "game/entities/entity_factory.hpp"
|
||||
#include "game/entities/event_bus.hpp"
|
||||
#include "game/entities/player.hpp"
|
||||
|
||||
namespace {
|
||||
|
||||
@@ -63,9 +64,15 @@ void Door::update(float delta_time) {
|
||||
}
|
||||
}
|
||||
|
||||
void Door::onPlayerContact(Player* /*player*/) {
|
||||
void Door::onPlayerContact(Player* player) {
|
||||
if (state_ != State::OPEN || level_complete_emitted_) { return; }
|
||||
if (bus_ != nullptr) { bus_->publish("level_complete"); }
|
||||
if (bus_ != nullptr) {
|
||||
bus_->publish(Event{
|
||||
.name = "level_complete",
|
||||
.payload = std::monostate{},
|
||||
.player_id = (player != nullptr) ? player->getId() : -1,
|
||||
});
|
||||
}
|
||||
level_complete_emitted_ = true;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user