mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-14 15:57:13 +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:
@@ -32,6 +32,7 @@
|
||||
#include "EconomyLedger.h"
|
||||
|
||||
QuickBuildComponent::QuickBuildComponent(Entity* const entity, const int32_t componentID) : Component{ entity, componentID } {
|
||||
RegisterMsg(&QuickBuildComponent::OnRequestUse);
|
||||
std::u16string checkPreconditions = entity->GetVar<std::u16string>(u"CheckPrecondition");
|
||||
|
||||
if (!checkPreconditions.empty()) {
|
||||
@@ -246,16 +247,19 @@ void QuickBuildComponent::Run(float deltaTime) {
|
||||
}
|
||||
}
|
||||
|
||||
void QuickBuildComponent::OnUse(Entity* originator) {
|
||||
bool QuickBuildComponent::OnRequestUse(GameMessages::RequestUseEvent& event) {
|
||||
if (event.msg.IsMissionChoice()) return false;
|
||||
auto* const originator = event.user;
|
||||
if (GetBuilder() != nullptr || m_State == eQuickBuildState::COMPLETED) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (m_Precondition != nullptr && !m_Precondition->Check(originator)) {
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
StartQuickBuild(originator);
|
||||
return true;
|
||||
}
|
||||
|
||||
void QuickBuildComponent::SpawnActivator() {
|
||||
|
||||
Reference in New Issue
Block a user