DarkflameServer/dGame/dComponents/MultiZoneEntranceComponent.cpp

33 lines
1.3 KiB
C++
Raw Normal View History

#include "MultiZoneEntranceComponent.h"
2023-07-10 03:52:48 +00:00
2022-05-03 20:05:29 +00:00
#include "RocketLaunchpadControlComponent.h"
#include "InventoryComponent.h"
2022-05-03 20:05:29 +00:00
#include "CharacterComponent.h"
2023-07-10 03:52:48 +00:00
#include "GameMessages.h"
2022-05-03 20:05:29 +00:00
2023-07-10 03:52:48 +00:00
void MultiZoneEntranceComponent::LoadConfigData() {
std::string zoneString = GeneralUtils::UTF16ToWTF8(m_ParentEntity->GetVar<std::u16string>(u"MultiZoneIDs"));
2023-07-10 03:52:48 +00:00
const auto zoneSplitStr = GeneralUtils::SplitString(zoneString, ';');
for (const auto& zone : zoneSplitStr) {
uint32_t mapId;
if (GeneralUtils::TryParse(zone, mapId)) m_LUPWorlds.push_back(mapId);
2022-05-03 20:05:29 +00:00
}
}
void MultiZoneEntranceComponent::OnUse(Entity* originator) {
2023-07-10 03:52:48 +00:00
auto* characterComponent = originator->GetComponent<CharacterComponent>();
if (!characterComponent) return;
auto* rocket = characterComponent->RocketEquip(originator);
if (!rocket) return;
2022-05-03 20:05:29 +00:00
2023-07-10 03:52:48 +00:00
// The LUP world menu is just the property menu, the client handles this in flash
GameMessages::SendPropertyEntranceBegin(m_ParentEntity->GetObjectID(), m_ParentEntity->GetSystemAddress());
2022-05-03 20:05:29 +00:00
}
2023-07-10 03:52:48 +00:00
void MultiZoneEntranceComponent::OnSelectWorld(Entity* originator, const uint32_t index) const {
auto* rocketLaunchpadControlComponent = m_ParentEntity->GetComponent<RocketLaunchpadControlComponent>();
2023-07-10 03:52:48 +00:00
if (!rocketLaunchpadControlComponent || index >= m_LUPWorlds.size()) return;
2022-05-03 20:05:29 +00:00
rocketLaunchpadControlComponent->Launch(originator, m_LUPWorlds[index], 0);
2022-05-03 20:05:29 +00:00
}