Client handles rocket being unequiped

when closing the dialog
and when launching
This commit is contained in:
Aaron Kimbre 2022-05-04 07:50:05 -05:00
parent bd3e8aee51
commit e81acb4c67
2 changed files with 5 additions and 13 deletions

View File

@ -18,11 +18,7 @@ RocketLaunchLupComponent::RocketLaunchLupComponent(Entity* parent) : Component(p
results.finalize(); results.finalize();
} }
RocketLaunchLupComponent::~RocketLaunchLupComponent() { RocketLaunchLupComponent::~RocketLaunchLupComponent() {}
if (!m_rocket) return;
// when we exit the ui we need to unequip the rocket
m_rocket->UnEquip();
}
void RocketLaunchLupComponent::OnUse(Entity* originator) { void RocketLaunchLupComponent::OnUse(Entity* originator) {
// 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 knows how to handle it
@ -34,16 +30,14 @@ void RocketLaunchLupComponent::OnUse(Entity* originator) {
auto* characterComponent = originator->GetComponent<CharacterComponent>(); auto* characterComponent = originator->GetComponent<CharacterComponent>();
if (!inventoryComponent || !characterComponent) return; if (!inventoryComponent || !characterComponent) return;
Item* rocket = nullptr;
rocket = inventoryComponent->FindItemById(characterComponent->GetLastRocketItemID());
if (!rocket) return;
m_rocket = inventoryComponent->FindItemById(characterComponent->GetLastRocketItemID()); rocket->Equip(true);
if (!m_rocket) return;
m_rocket->Equip(true);
} }
void RocketLaunchLupComponent::OnSelectWorld(Entity* originator, uint32_t index, const SystemAddress& sysAddr) { void RocketLaunchLupComponent::OnSelectWorld(Entity* originator, uint32_t index, const SystemAddress& sysAddr) {
if (m_rocket) m_rocket->UnEquip();
// Add one to index because the actual LUP worlds start at index 1. // Add one to index because the actual LUP worlds start at index 1.
index++; index++;

View File

@ -3,7 +3,6 @@
#include "Entity.h" #include "Entity.h"
#include "GameMessages.h" #include "GameMessages.h"
#include "Component.h" #include "Component.h"
#include "Item.h"
/** /**
* Component that handles the LUP/WBL rocket launchpad that can be interacted with to travel to WBL worlds. * Component that handles the LUP/WBL rocket launchpad that can be interacted with to travel to WBL worlds.
@ -21,5 +20,4 @@ public:
void OnSelectWorld(Entity* originator, uint32_t index, const SystemAddress& sysAddr); void OnSelectWorld(Entity* originator, uint32_t index, const SystemAddress& sysAddr);
private: private:
std::vector<LWOMAPID> m_LUPWorlds {}; std::vector<LWOMAPID> m_LUPWorlds {};
Item* m_rocket = nullptr;
}; };