add RemoveMobPacket
This commit is contained in:
@@ -27,6 +27,7 @@ public:
|
||||
virtual void HandlePacket(const PlayerLeavePacket* packet) {}
|
||||
virtual void HandlePacket(const PlayerListPacket* packet) {}
|
||||
virtual void HandlePacket(const PlayerLoginPacket* packet) {}
|
||||
virtual void HandlePacket(const RemoveMobPacket* packet) {}
|
||||
virtual void HandlePacket(const RemoveTowerPacket* packet) {}
|
||||
virtual void HandlePacket(const SelectTeamPacket* packet) {}
|
||||
virtual void HandlePacket(const SendMobsPacket* packet) {}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "packets/PlayerLeavePacket.h"
|
||||
#include "packets/PlayerListPacket.h"
|
||||
#include "packets/PlayerLoginPacket.h"
|
||||
#include "packets/RemoveMobPacket.h"
|
||||
#include "packets/RemoveTowerPacket.h"
|
||||
#include "packets/SelectTeamPacket.h"
|
||||
#include "packets/SendMobsPacket.h"
|
||||
|
||||
@@ -29,6 +29,7 @@ class UpdateCastleLifePacket;
|
||||
class UpdateMobStatesPacket;
|
||||
class PlayerBuyItemPacket;
|
||||
class PlayerBuyMobUpgradePacket;
|
||||
class RemoveMobPacket;
|
||||
|
||||
} // namespace protocol
|
||||
} // namespace td
|
||||
|
||||
@@ -33,6 +33,7 @@ enum class PacketType : std::uint8_t {
|
||||
WorldAddTower,
|
||||
UpdateMobStates,
|
||||
UpdateCastleLife,
|
||||
RemoveMob,
|
||||
|
||||
// client <--> server
|
||||
KeepAlive,
|
||||
|
||||
27
include/td/protocol/packets/RemoveMobPacket.h
Normal file
27
include/td/protocol/packets/RemoveMobPacket.h
Normal file
@@ -0,0 +1,27 @@
|
||||
#pragma once
|
||||
|
||||
#include "td/protocol/Protocol.h"
|
||||
#include "td/game/BaseGame.h"
|
||||
|
||||
namespace td {
|
||||
namespace protocol {
|
||||
|
||||
class RemoveMobPacket : public Packet {
|
||||
private:
|
||||
game::MobID m_MobID;
|
||||
public:
|
||||
RemoveMobPacket() {}
|
||||
RemoveMobPacket(game::MobID id) : m_MobID(id) {}
|
||||
virtual ~RemoveMobPacket() {}
|
||||
|
||||
virtual DataBuffer Serialize(bool packetID = true) const;
|
||||
virtual void Deserialize(DataBuffer& data);
|
||||
virtual void Dispatch(PacketHandler* handler) const;
|
||||
|
||||
game::MobID GetMobID() const { return m_MobID; }
|
||||
|
||||
virtual PacketType GetType() const { return PacketType::RemoveMob; }
|
||||
};
|
||||
|
||||
} // namespace protocol
|
||||
} // namespace td
|
||||
@@ -36,6 +36,7 @@ static std::map<PacketType, PacketCreator> packets = {
|
||||
{PacketType::UpdateMobStates, []() -> PacketPtr {return std::make_unique<UpdateMobStatesPacket>(); } },
|
||||
{PacketType::PlayerBuyItem, []() -> PacketPtr {return std::make_unique<PlayerBuyItemPacket>(); } },
|
||||
{PacketType::PlayerBuyMobUpgrade, []() -> PacketPtr {return std::make_unique<PlayerBuyMobUpgradePacket>(); } },
|
||||
{PacketType::RemoveMob, []() -> PacketPtr {return std::make_unique<RemoveMobPacket>(); } },
|
||||
};
|
||||
|
||||
PacketPtr CreatePacket(PacketType type, DataBuffer& buffer) {
|
||||
|
||||
@@ -39,6 +39,7 @@ REGISTER_DISPATCH_CLASS(UpdateCastleLifePacket)
|
||||
REGISTER_DISPATCH_CLASS(UpdateMobStatesPacket)
|
||||
REGISTER_DISPATCH_CLASS(PlayerBuyItemPacket)
|
||||
REGISTER_DISPATCH_CLASS(PlayerBuyMobUpgradePacket)
|
||||
REGISTER_DISPATCH_CLASS(RemoveMobPacket)
|
||||
|
||||
} // namespace protocol
|
||||
} // namespace td
|
||||
19
src/td/protocol/packets/RemoveMobPacket.cpp
Normal file
19
src/td/protocol/packets/RemoveMobPacket.cpp
Normal file
@@ -0,0 +1,19 @@
|
||||
#include "td/protocol/packets/RemoveMobPacket.h"
|
||||
|
||||
namespace td {
|
||||
namespace protocol {
|
||||
|
||||
DataBuffer RemoveMobPacket::Serialize(bool packetID) const {
|
||||
DataBuffer data;
|
||||
|
||||
WritePacketID(data, packetID);
|
||||
data << m_MobID;
|
||||
return data;
|
||||
}
|
||||
|
||||
void RemoveMobPacket::Deserialize(DataBuffer& data) {
|
||||
data >> m_MobID;
|
||||
}
|
||||
|
||||
} // namespace protocol
|
||||
} // namespace td
|
||||
Reference in New Issue
Block a user