Merge pull request #541 Implement the LUP Rocket Launch Component

Implemented the LUP Rocket Launch Component and makes its UI live accurate
This commit is contained in:
David Markowitz
2022-05-06 11:54:32 -07:00
committed by GitHub
8 changed files with 102 additions and 208 deletions

View File

@@ -22,6 +22,7 @@
#include "Component.h"
#include "ControllablePhysicsComponent.h"
#include "RenderComponent.h"
#include "RocketLaunchLupComponent.h"
#include "CharacterComponent.h"
#include "DestroyableComponent.h"
#include "BuffComponent.h"
@@ -456,9 +457,10 @@ void Entity::Initialize()
else comp = new InventoryComponent(this);
m_Components.insert(std::make_pair(COMPONENT_TYPE_INVENTORY, comp));
}
if (compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_ROCKET_LAUNCH_LUP) > 0) {
m_Components.insert(std::make_pair(COMPONENT_TYPE_ROCKET_LAUNCH_LUP, nullptr));
// if this component exists, then we initialize it. it's value is always 0
if (compRegistryTable->GetByIDAndType(m_TemplateID, COMPONENT_TYPE_ROCKET_LAUNCH_LUP, -1) != -1) {
auto comp = new RocketLaunchLupComponent(this);
m_Components.insert(std::make_pair(COMPONENT_TYPE_ROCKET_LAUNCH_LUP, comp));
}
/**
@@ -495,13 +497,6 @@ void Entity::Initialize()
std::string customScriptServer;
bool hasCustomServerScript = false;
// Custom script for the LUP teleporter
if (m_TemplateID == 14333)
{
hasCustomServerScript = true;
customScriptServer = "scripts\\02_server\\DLU\\L_SB_LUP_TELEPORT.lua";
}
const auto customScriptServerName = GetVarAsString(u"custom_script_server");
const auto customScriptClientName = GetVarAsString(u"custom_script_client");

View File

@@ -0,0 +1,49 @@
#include "RocketLaunchLupComponent.h"
#include "CDClientDatabase.h"
#include "RocketLaunchpadControlComponent.h"
#include "CharacterComponent.h"
#include "Item.h"
RocketLaunchLupComponent::RocketLaunchLupComponent(Entity* parent) : Component(parent) {
m_Parent = parent;
// get the lup worlds from the cdclient
std::string query = "SELECT * FROM LUPZoneIDs;";
auto results = CDClientDatabase::ExecuteQuery(query);
while (!results.eof()) {
// fallback to 1600 incase there is an issue
m_LUPWorlds.push_back(results.getIntField(0, 1600));
results.nextRow();
}
results.finalize();
}
RocketLaunchLupComponent::~RocketLaunchLupComponent() {}
void RocketLaunchLupComponent::OnUse(Entity* originator) {
// the LUP world menu is just the property menu, the client knows how to handle it
GameMessages::SendPropertyEntranceBegin(m_Parent->GetObjectID(), m_Parent->GetSystemAddress());
// get the rocket to "equip" it so we are holding it
// taken from the RocketLaunchControlComponent
auto* inventoryComponent = originator->GetComponent<InventoryComponent>();
auto* characterComponent = originator->GetComponent<CharacterComponent>();
if (!inventoryComponent || !characterComponent) return;
Item* rocket = inventoryComponent->FindItemById(characterComponent->GetLastRocketItemID());
if (!rocket) return;
rocket->Equip(true);
}
void RocketLaunchLupComponent::OnSelectWorld(Entity* originator, uint32_t index) {
// Add one to index because the actual LUP worlds start at index 1.
index++;
auto* rocketLaunchpadControlComponent = m_Parent->GetComponent<RocketLaunchpadControlComponent>();
if (!rocketLaunchpadControlComponent) return;
rocketLaunchpadControlComponent->Launch(originator, LWOOBJID_EMPTY, m_LUPWorlds[index], 0);
}

View File

@@ -0,0 +1,39 @@
#pragma once
#include "Entity.h"
#include "GameMessages.h"
#include "Component.h"
/**
* Component that handles the LUP/WBL rocket launchpad that can be interacted with to travel to WBL worlds.
*
*/
class RocketLaunchLupComponent : public Component {
public:
static const uint32_t ComponentType = eReplicaComponentType::COMPONENT_TYPE_ROCKET_LAUNCH_LUP;
/**
* Constructor for this component, builds the m_LUPWorlds vector
* @param parent parent that contains this component
*/
RocketLaunchLupComponent(Entity* parent);
~RocketLaunchLupComponent() override;
/**
* Handles an OnUse event from some entity, preparing it for launch to some other world
* @param originator the entity that triggered the event
*/
void OnUse(Entity* originator) override;
/**
* Handles an OnUse event from some entity, preparing it for launch to some other world
* @param originator the entity that triggered the event
* @param index index of the world that was selected
*/
void OnSelectWorld(Entity* originator, uint32_t index);
private:
/**
* vector of the LUP World Zone IDs, built from CDServer's LUPZoneIDs table
*/
std::vector<LWOMAPID> m_LUPWorlds {};
};

View File

@@ -26,6 +26,7 @@
#include "TeamManager.h"
#include "ChatPackets.h"
#include "GameConfig.h"
#include "RocketLaunchLupComponent.h"
#include <sstream>
#include <future>
@@ -2726,10 +2727,15 @@ void GameMessages::HandleEnterProperty(RakNet::BitStream* inStream, Entity* enti
auto* player = Player::GetPlayer(sysAddr);
auto* entranceComponent = entity->GetComponent<PropertyEntranceComponent>();
if (entranceComponent != nullptr) {
entranceComponent->OnEnterProperty(player, index, returnToZone, sysAddr);
return;
}
if (entranceComponent == nullptr) return;
entranceComponent->OnEnterProperty(player, index, returnToZone, sysAddr);
auto rocketLaunchLupComponent = entity->GetComponent<RocketLaunchLupComponent>();
if (rocketLaunchLupComponent != nullptr) {
rocketLaunchLupComponent->OnSelectWorld(player, index);
}
}
void GameMessages::HandleSetConsumableItem(RakNet::BitStream* inStream, Entity* entity, const SystemAddress& sysAddr)