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,10 +1,12 @@
#include "MultiZoneEntranceComponent.h"
#include "ObjectMessages.h"
#include "PropertyMessages.h"
#include "RocketLaunchpadControlComponent.h"
#include "InventoryComponent.h"
#include "CharacterComponent.h"
MultiZoneEntranceComponent::MultiZoneEntranceComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {
RegisterMsg(&MultiZoneEntranceComponent::OnRequestUse);
m_Parent = parent;
std::string zoneString = GeneralUtils::UTF16ToWTF8(m_Parent->GetVar<std::u16string>(u"MultiZoneIDs"));
std::stringstream ss(zoneString);
@@ -17,17 +19,20 @@ MultiZoneEntranceComponent::MultiZoneEntranceComponent(Entity* parent, const int
MultiZoneEntranceComponent::~MultiZoneEntranceComponent() {}
void MultiZoneEntranceComponent::OnUse(Entity* originator) {
bool MultiZoneEntranceComponent::OnRequestUse(GameMessages::RequestUseEvent& event) {
if (event.msg.IsMissionChoice()) return false;
auto* const originator = event.user;
auto* const characterComponent = originator->GetComponent<CharacterComponent>();
if (!characterComponent) return;
if (!characterComponent) return true;
auto* rocket = characterComponent->RocketEquip(originator);
if (!rocket) return;
if (!rocket) return true;
// the LUP world menu is just the property menu, the client knows how to handle it
GameMessages::PropertyEntranceBegin msg;
msg.target = m_Parent->GetObjectID();
msg.Send(originator->GetSystemAddress());
return true;
}
void MultiZoneEntranceComponent::OnSelectWorld(Entity* originator, uint32_t index) {