DarkflameServer/dGame/dComponents/MultiZoneEntranceComponent.cpp

33 lines
1.2 KiB
C++
Raw Normal View History

#include "MultiZoneEntranceComponent.h"
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"
MultiZoneEntranceComponent::MultiZoneEntranceComponent(Entity* parent) : Component(parent) {
2022-05-03 20:05:29 +00:00
m_Parent = parent;
2022-05-17 15:18:50 +00:00
std::string zoneString = GeneralUtils::UTF16ToWTF8(m_Parent->GetVar<std::u16string>(u"MultiZoneIDs"));
std::stringstream ss(zoneString);
for (int i; ss >> i;) {
m_LUPWorlds.push_back(i);
if (ss.peek() == ';')
ss.ignore();
2022-05-03 20:05:29 +00:00
}
}
MultiZoneEntranceComponent::~MultiZoneEntranceComponent() {}
2022-05-03 20:05:29 +00:00
void MultiZoneEntranceComponent::OnUse(Entity* originator) {
auto* rocket = originator->GetComponent<CharacterComponent>()->RocketEquip(originator);
if (!rocket) return;
2022-05-03 20:05:29 +00:00
// the LUP world menu is just the property menu, the client knows how to handle it
2023-09-19 10:59:02 +00:00
GameMessages::SendPropertyEntranceBegin(m_Parent->GetObjectID(), originator->GetSystemAddress());
2022-05-03 20:05:29 +00:00
}
void MultiZoneEntranceComponent::OnSelectWorld(Entity* originator, uint32_t index) {
2022-05-03 20:05:29 +00:00
auto* rocketLaunchpadControlComponent = m_Parent->GetComponent<RocketLaunchpadControlComponent>();
if (!rocketLaunchpadControlComponent) return;
rocketLaunchpadControlComponent->Launch(originator, m_LUPWorlds[index], 0);
2022-05-03 20:05:29 +00:00
}