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 "BuildBorderComponent.h"
#include "ObjectMessages.h"
#include "EntityManager.h"
#include "GameMessages.h"
@@ -11,12 +12,15 @@
#include "PropertyManagementComponent.h"
BuildBorderComponent::BuildBorderComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {
RegisterMsg(&BuildBorderComponent::OnRequestUse);
}
BuildBorderComponent::~BuildBorderComponent() {
}
void BuildBorderComponent::OnUse(Entity* originator) {
bool BuildBorderComponent::OnRequestUse(GameMessages::RequestUseEvent& event) {
if (event.msg.IsMissionChoice()) return false;
auto* const originator = event.user;
if (originator->GetCharacter()) {
const auto& entities = Game::entityManager->GetEntitiesInGroup("PropertyPlaque");
@@ -31,13 +35,13 @@ void BuildBorderComponent::OnUse(Entity* originator) {
auto* inventoryComponent = originator->GetComponent<InventoryComponent>();
if (inventoryComponent == nullptr) {
return;
return true;
}
auto* thinkingHat = inventoryComponent->FindItemByLot(6086);
if (thinkingHat == nullptr) {
return;
return true;
}
inventoryComponent->PushEquippedItems();
@@ -69,7 +73,8 @@ void BuildBorderComponent::OnUse(Entity* originator) {
}
InventoryComponent* inv = m_Parent->GetComponent<InventoryComponent>();
if (!inv) return;
if (!inv) return true;
inv->PushEquippedItems(); // technically this is supposed to happen automatically... but it doesnt? so just keep this here
}
return true;
}