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
@@ -4,6 +4,7 @@
|
||||
|
||||
#include "game/entities/entity_factory.hpp"
|
||||
#include "game/entities/event_bus.hpp"
|
||||
#include "game/entities/player.hpp"
|
||||
#include "game/map/map.hpp"
|
||||
|
||||
namespace {
|
||||
@@ -60,8 +61,14 @@ void RollingRock::step(float delta_time) {
|
||||
setDirection(0.0F, 0.0F);
|
||||
}
|
||||
|
||||
void RollingRock::onPlayerContact(Player* /*player*/) {
|
||||
if (bus_ != nullptr) { bus_->publish("player_hit", getDamage()); }
|
||||
void RollingRock::onPlayerContact(Player* player) {
|
||||
if (bus_ != nullptr) {
|
||||
bus_->publish(Event{
|
||||
.name = "player_hit",
|
||||
.payload = getDamage(),
|
||||
.player_id = (player != nullptr) ? player->getId() : -1,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
REGISTER_ENTITY("rolling_rock", RollingRock)
|
||||
Reference in new issue
Block a user