mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-18 09:45:28 +00:00
refactor(component): use is a RequestUse message handler
Components no longer have a virtual OnUse; each component that reacts to a use registers a RequestUse handler, like the client's components. The entity runs the INTERACT trigger and the script, then delivers a RequestUseEvent (carrying the user) to the handlers. The mission choice of a multi-interact use goes only to the mission offer, as before. Switches keep a direct EnterIfResponding for touches and pets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#include <algorithm>
|
||||
#include "RailActivatorComponent.h"
|
||||
#include "ObjectMessages.h"
|
||||
#include "CDClientManager.h"
|
||||
#include "CDRailActivatorComponent.h"
|
||||
#include "Entity.h"
|
||||
@@ -15,6 +16,7 @@
|
||||
#include "eStateChangeType.h"
|
||||
|
||||
RailActivatorComponent::RailActivatorComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {
|
||||
RegisterMsg(&RailActivatorComponent::OnRequestUse);
|
||||
const auto tableData = CDClientManager::GetTable<CDRailActivatorComponentTable>()->GetEntryByID(componentID);
|
||||
|
||||
m_Path = parent->GetVar<std::u16string>(u"rail_path");
|
||||
@@ -51,10 +53,12 @@ RailActivatorComponent::RailActivatorComponent(Entity* parent, const int32_t com
|
||||
|
||||
RailActivatorComponent::~RailActivatorComponent() = default;
|
||||
|
||||
void RailActivatorComponent::OnUse(Entity* originator) {
|
||||
bool RailActivatorComponent::OnRequestUse(GameMessages::RequestUseEvent& event) {
|
||||
if (event.msg.IsMissionChoice()) return false;
|
||||
auto* const originator = event.user;
|
||||
auto* quickBuildComponent = m_Parent->GetComponent<QuickBuildComponent>();
|
||||
if (quickBuildComponent != nullptr && quickBuildComponent->GetState() != eQuickBuildState::COMPLETED)
|
||||
return;
|
||||
return true;
|
||||
|
||||
if (quickBuildComponent != nullptr) {
|
||||
// Don't want it to be destroyed while a player is using it
|
||||
@@ -101,6 +105,7 @@ void RailActivatorComponent::OnUse(Entity* originator) {
|
||||
startRail.railActivatorObjectID = m_Parent->GetObjectID();
|
||||
startRail.Send(originator->GetSystemAddress());
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
void RailActivatorComponent::OnRailMovementReady(Entity* originator) const {
|
||||
|
||||
Reference in New Issue
Block a user