#include "CollectibleComponent.h" #include "MissionComponent.h" #include "dServer.h" #include "Amf3.h" CollectibleComponent::CollectibleComponent(Entity* parentEntity, const int32_t componentID, const int32_t collectibleId) : Component(parentEntity, componentID), m_CollectibleId(collectibleId) { using namespace GameMessages; RegisterMsg(this, &CollectibleComponent::MsgGetObjectReportInfo); } void CollectibleComponent::Serialize(RakNet::BitStream& outBitStream, bool isConstruction) { outBitStream.Write(GetCollectibleId()); } bool CollectibleComponent::MsgGetObjectReportInfo(GameMessages::GameMsg& msg) { auto& reportMsg = static_cast(msg); auto& cmptType = reportMsg.info->PushDebug("Collectible"); auto collectibleID = static_cast(m_CollectibleId) + static_cast(Game::server->GetZoneID() << 8); cmptType.PushDebug("Component ID") = GetComponentID(); cmptType.PushDebug("Collectible ID") = GetCollectibleId(); cmptType.PushDebug("Mission Tracking ID (for save data)") = collectibleID; auto* localCharEntity = Game::entityManager->GetEntity(reportMsg.clientID); bool collected = false; if (localCharEntity) { auto* missionComponent = localCharEntity->GetComponent(); if (m_CollectibleId != 0) { collected = missionComponent->HasCollectible(collectibleID); } } cmptType.PushDebug("Has been collected") = collected; return true; }