#include "td/protocol/packets/UpdateMobStatesPacket.h"

namespace td {
namespace protocol {

DataBuffer UpdateMobStatesPacket::Serialize(bool packetID) const {
	DataBuffer data;

	WritePacketID(data, packetID);
	data << static_cast<std::uint64_t>(m_MobStates.size());

	data.WriteSome(reinterpret_cast<const std::uint8_t*>(m_MobStates.data()), m_MobStates.size() * sizeof(MobState));
	return data;
}

void UpdateMobStatesPacket::Deserialize(DataBuffer& data) {
	std::uint64_t mobCount;
	data >> mobCount;
	m_MobStates.resize(mobCount);

	data.ReadSome(reinterpret_cast<std::uint8_t*>(m_MobStates.data()), mobCount * sizeof(MobState));
}

} // namespace protocol
} // namespace td
