mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-20 10:45:27 +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:
@@ -250,22 +250,7 @@ namespace GameMessages {
|
||||
entity.GetCharacter()->SetBuildMode(true);
|
||||
}
|
||||
|
||||
if (bIsMultiInteractUse) {
|
||||
if (multiInteractType == 0) {
|
||||
auto* missionOfferComponent = static_cast<MissionOfferComponent*>(interactedObject->GetComponent(eReplicaComponentType::MISSION_OFFER));
|
||||
|
||||
if (missionOfferComponent != nullptr) {
|
||||
missionOfferComponent->OfferMissions(&entity, multiInteractID);
|
||||
}
|
||||
} else {
|
||||
interactedObject->OnUse(&entity);
|
||||
}
|
||||
} else {
|
||||
interactedObject->OnUse(&entity);
|
||||
}
|
||||
|
||||
RequestUseEvent event(*this);
|
||||
interactedObject->HandleMsg(event);
|
||||
interactedObject->RequestUse(*this, entity);
|
||||
|
||||
//Perform use task if possible:
|
||||
auto missionComponent = entity.GetComponent<MissionComponent>();
|
||||
|
||||
@@ -168,8 +168,19 @@ namespace GameMessages {
|
||||
LWOOBJID object{};
|
||||
|
||||
bool secondary{ false };
|
||||
|
||||
// The mission choice of a multi-interact use: only the mission offer handles it.
|
||||
bool IsMissionChoice() const { return bIsMultiInteractUse && multiInteractType == 0; }
|
||||
};
|
||||
|
||||
// A use of an object, delivered to its components' RequestUse handlers. user is who used it: the sender of the
|
||||
// RequestUse, or whoever the server makes use it. Only dispatch RequestUse locally as this event.
|
||||
struct RequestUseEvent : public NetGameMsgEvent<RequestUse> {
|
||||
RequestUseEvent() = default;
|
||||
RequestUseEvent(const RequestUse& message, Entity& user) : NetGameMsgEvent(message), user{ &user } {}
|
||||
|
||||
Entity* user{};
|
||||
};
|
||||
using RequestUseEvent = NetGameMsgEvent<RequestUse>;
|
||||
|
||||
// Client -> server. Developer only.
|
||||
struct RequestServerObjectInfo : public NetGameMsg {
|
||||
|
||||
Reference in New Issue
Block a user