remove mobs on player leave

This commit is contained in:
Simon Pribylski
2023-08-26 10:46:20 +02:00
parent 8e7b446003
commit 5631efcf9e
5 changed files with 39 additions and 2 deletions

View File

@@ -8,6 +8,7 @@
#include "td/protocol/packets/WorldDataPacket.h"
#include "td/protocol/packets/SpawnMobPacket.h"
#include "td/protocol/packets/UpgradeTowerPacket.h"
#include "td/protocol/packets/RemoveMobPacket.h"
#include "td/protocol/packets/RemoveTowerPacket.h"
#include "td/protocol/packets/UpdateCastleLifePacket.h"
#include "td/protocol/packets/UpdateMobStatesPacket.h"
@@ -21,6 +22,7 @@ WorldClient::WorldClient(ClientGame* game) : game::World(game), protocol::Packet
GetDispatcher()->RegisterHandler(protocol::PacketType::WorldData, this);
GetDispatcher()->RegisterHandler(protocol::PacketType::SpawnMob, this);
GetDispatcher()->RegisterHandler(protocol::PacketType::UpgradeTower, this);
GetDispatcher()->RegisterHandler(protocol::PacketType::RemoveMob, this);
GetDispatcher()->RegisterHandler(protocol::PacketType::RemoveTower, this);
GetDispatcher()->RegisterHandler(protocol::PacketType::UpdateCastleLife, this);
GetDispatcher()->RegisterHandler(protocol::PacketType::UpdateMobStates, this);
@@ -70,6 +72,14 @@ void WorldClient::HandlePacket(const protocol::RemoveTowerPacket* packet) {
GetWorldNotifier().NotifyListeners(&WorldListener::OnTowerRemove, tower);
}
void WorldClient::HandlePacket(const protocol::RemoveMobPacket* packet) {
game::MobPtr mob = RemoveMob(packet->GetMobID());
SAFE_CHECK(mob);
//GetWorldNotifier().NotifyListeners(&MobListener::OnMobDie, mob.get());
}
void WorldClient::HandlePacket(const protocol::UpdateMobStatesPacket* packet) {
for (auto mobState : packet->GetMobStates()) {
game::MobID mobId = mobState.GetMobId();