mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-17 01:05: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:
@@ -5,6 +5,7 @@
|
||||
|
||||
#include <sstream>
|
||||
#include "MissionOfferComponent.h"
|
||||
#include "ObjectMessages.h"
|
||||
#include "CDClientManager.h"
|
||||
#include "CDMissionsTable.h"
|
||||
#include "CDMissionNPCComponentTable.h"
|
||||
@@ -41,6 +42,7 @@ bool OfferedMission::GetAcceptsMission() const {
|
||||
//------------------------ MissionOfferComponent below ------------------------
|
||||
|
||||
MissionOfferComponent::MissionOfferComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {
|
||||
RegisterMsg(&MissionOfferComponent::OnRequestUse);
|
||||
if (componentID != -1) {
|
||||
// Now lookup the missions in the MissionNPCComponent table
|
||||
auto* missionNpcComponentTable = CDClientManager::GetTable<CDMissionNPCComponentTable>();
|
||||
@@ -73,8 +75,10 @@ namespace {
|
||||
}
|
||||
}
|
||||
|
||||
void MissionOfferComponent::OnUse(Entity* originator) {
|
||||
OfferMissions(originator);
|
||||
bool MissionOfferComponent::OnRequestUse(GameMessages::RequestUseEvent& event) {
|
||||
if (event.msg.IsMissionChoice()) OfferMissions(event.user, event.msg.multiInteractID);
|
||||
else OfferMissions(event.user);
|
||||
return true;
|
||||
}
|
||||
|
||||
void MissionOfferComponent::OfferMissions(Entity* entity, const uint32_t specifiedMissionId) {
|
||||
|
||||
Reference in New Issue
Block a user