Allow other behavior nodes to run on failed interaction

This commit is contained in:
Maxicarlos08 2023-10-02 16:22:46 +02:00
parent 1b07c198ad
commit 8116e5be2c
No known key found for this signature in database

View File

@ -559,20 +559,20 @@ pub fn handle_inbox_cancel_interactions(bdata: &mut BehaviorData) -> bool {
if let Some(msg) = agent.inbox.front() {
let used = match msg {
AgentEvent::Talk(by, _) | AgentEvent::TradeAccepted(by) => {
if let (Some(target), Some(speaker)) =
(agent.target, get_entity_by_id(*by, bdata.read_data))
{
if agent
.target
.zip(get_entity_by_id(*by, bdata.read_data))
// in combat, speak to players that aren't the current target
if !target.hostile || target.target != speaker {
agent_data.chat_npc_if_allowed_to_speak(
Content::localized("npc-speech-villager_busy"),
agent,
event_emitter,
);
}
.map_or(false, |(target, speaker)| !target.hostile || target.target != speaker)
{
agent_data.chat_npc_if_allowed_to_speak(
Content::localized("npc-speech-villager_busy"),
agent,
event_emitter,
);
}
true
false
},
AgentEvent::TradeInvite(by) => {
controller.push_invite_response(InviteResponse::Decline);