mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-11-22 13:37:22 +00:00
MultiZoneEntranceComponent pass
This commit is contained in:
parent
d2a7e147cc
commit
7ca9e59ef2
@ -1,32 +1,32 @@
|
||||
#include "MultiZoneEntranceComponent.h"
|
||||
|
||||
#include "RocketLaunchpadControlComponent.h"
|
||||
#include "InventoryComponent.h"
|
||||
#include "CharacterComponent.h"
|
||||
#include "GameMessages.h"
|
||||
|
||||
MultiZoneEntranceComponent::MultiZoneEntranceComponent(Entity* parent) : Component(parent) {
|
||||
m_ParentEntity = parent;
|
||||
void MultiZoneEntranceComponent::LoadConfigData() {
|
||||
std::string zoneString = GeneralUtils::UTF16ToWTF8(m_ParentEntity->GetVar<std::u16string>(u"MultiZoneIDs"));
|
||||
std::stringstream ss(zoneString);
|
||||
for (int i; ss >> i;) {
|
||||
m_LUPWorlds.push_back(i);
|
||||
if (ss.peek() == ';')
|
||||
ss.ignore();
|
||||
const auto zoneSplitStr = GeneralUtils::SplitString(zoneString, ';');
|
||||
for (const auto& zone : zoneSplitStr) {
|
||||
uint32_t mapId;
|
||||
if (GeneralUtils::TryParse(zone, mapId)) m_LUPWorlds.push_back(mapId);
|
||||
}
|
||||
}
|
||||
|
||||
MultiZoneEntranceComponent::~MultiZoneEntranceComponent() {}
|
||||
|
||||
void MultiZoneEntranceComponent::OnUse(Entity* originator) {
|
||||
auto* rocket = originator->GetComponent<CharacterComponent>()->RocketEquip(originator);
|
||||
auto* characterComponent = originator->GetComponent<CharacterComponent>();
|
||||
if (!characterComponent) return;
|
||||
auto* rocket = characterComponent->RocketEquip(originator);
|
||||
if (!rocket) return;
|
||||
|
||||
// the LUP world menu is just the property menu, the client knows how to handle it
|
||||
// The LUP world menu is just the property menu, the client handles this in flash
|
||||
GameMessages::SendPropertyEntranceBegin(m_ParentEntity->GetObjectID(), m_ParentEntity->GetSystemAddress());
|
||||
}
|
||||
|
||||
void MultiZoneEntranceComponent::OnSelectWorld(Entity* originator, uint32_t index) {
|
||||
void MultiZoneEntranceComponent::OnSelectWorld(Entity* originator, const uint32_t index) const {
|
||||
auto* rocketLaunchpadControlComponent = m_ParentEntity->GetComponent<RocketLaunchpadControlComponent>();
|
||||
if (!rocketLaunchpadControlComponent) return;
|
||||
if (!rocketLaunchpadControlComponent || index >= m_LUPWorlds.size()) return;
|
||||
|
||||
rocketLaunchpadControlComponent->Launch(originator, m_LUPWorlds[index], 0);
|
||||
}
|
||||
|
@ -1,15 +1,13 @@
|
||||
#pragma once
|
||||
|
||||
#include "Entity.h"
|
||||
#include "GameMessages.h"
|
||||
#include "Component.h"
|
||||
#include "eReplicaComponentType.h"
|
||||
|
||||
/**
|
||||
* Component that handles the LUP/WBL rocket launchpad that can be interacted with to travel to WBL worlds.
|
||||
*
|
||||
*/
|
||||
class MultiZoneEntranceComponent : public Component {
|
||||
class MultiZoneEntranceComponent final : public Component {
|
||||
public:
|
||||
inline static const eReplicaComponentType ComponentType = eReplicaComponentType::MULTI_ZONE_ENTRANCE;
|
||||
|
||||
@ -17,8 +15,9 @@ public:
|
||||
* Constructor for this component, builds the m_LUPWorlds vector
|
||||
* @param parent parent that contains this component
|
||||
*/
|
||||
MultiZoneEntranceComponent(Entity* parent);
|
||||
~MultiZoneEntranceComponent() override;
|
||||
MultiZoneEntranceComponent(Entity* parent) : Component(parent) {};
|
||||
|
||||
void LoadConfigData() override;
|
||||
|
||||
/**
|
||||
* Handles an OnUse event from some entity, preparing it for launch to some other world
|
||||
@ -31,10 +30,10 @@ public:
|
||||
* @param originator the entity that triggered the event
|
||||
* @param index index of the world that was selected
|
||||
*/
|
||||
void OnSelectWorld(Entity* originator, uint32_t index);
|
||||
void OnSelectWorld(Entity* originator, const uint32_t index) const;
|
||||
private:
|
||||
/**
|
||||
* vector of the LUP World Zone IDs, built from CDServer's LUPZoneIDs table
|
||||
*/
|
||||
std::vector<LWOMAPID> m_LUPWorlds{};
|
||||
std::vector<LWOMAPID> m_LUPWorlds;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user