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:
Aaron Kimbrell
2026-10-01 07:55:55 -05:00
parent 50bfa623ca
commit 7a0dba22a5
33 changed files with 166 additions and 91 deletions

View File

@@ -1,4 +1,5 @@
#include "PropertyEntranceComponent.h"
#include "ObjectMessages.h"
#include "CDPropertyEntranceComponentTable.h"
@@ -19,6 +20,7 @@
#include "User.h"
PropertyEntranceComponent::PropertyEntranceComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {
RegisterMsg(&PropertyEntranceComponent::OnRequestUse);
this->propertyQueries = {};
auto table = CDClientManager::GetTable<CDPropertyEntranceComponentTable>();
@@ -28,12 +30,14 @@ PropertyEntranceComponent::PropertyEntranceComponent(Entity* parent, const int32
this->m_PropertyName = entry.propertyName;
}
void PropertyEntranceComponent::OnUse(Entity* entity) {
bool PropertyEntranceComponent::OnRequestUse(GameMessages::RequestUseEvent& event) {
if (event.msg.IsMissionChoice()) return false;
auto* const entity = event.user;
auto* characterComponent = entity->GetComponent<CharacterComponent>();
if (!characterComponent) return;
if (!characterComponent) return true;
auto* rocket = entity->GetComponent<CharacterComponent>()->RocketEquip(entity);
if (!rocket) return;
if (!rocket) return true;
GameMessages::PropertyEntranceBegin msg;
msg.target = m_Parent->GetObjectID();
@@ -48,6 +52,7 @@ void PropertyEntranceComponent::OnUse(Entity* entity) {
uiMessage.strMessageName = "pushGameState";
uiMessage.args = std::move(args);
uiMessage.SendToClient(entity->GetSystemAddress());
return true;
}
void PropertyEntranceComponent::OnEnterProperty(Entity* entity, uint32_t index, bool returnToZone, const SystemAddress& sysAddr) {