Mind Action Container (#21336)

This commit is contained in:
keronshb
2023-11-03 19:55:32 -04:00
committed by GitHub
parent d218fa3d2c
commit 3a788dd8d4
5 changed files with 42 additions and 4 deletions

View File

@@ -7,6 +7,7 @@ using Content.Shared.Database;
using Content.Shared.Hands;
using Content.Shared.Interaction;
using Content.Shared.Inventory.Events;
using Content.Shared.Mind;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
@@ -221,7 +222,6 @@ public abstract class SharedActionsSystem : EntitySystem
return;
DebugTools.Assert(action.AttachedEntity == user);
if (!action.Enabled)
return;
@@ -369,7 +369,7 @@ public abstract class SharedActionsSystem : EntitySystem
var toggledBefore = action.Toggled;
// Note that attached entity is allowed to be null here.
// Note that attached entity and attached container are allowed to be null here.
if (action.AttachedEntity != null && action.AttachedEntity != performer)
{
Log.Error($"{ToPrettyString(performer)} is attempting to perform an action {ToPrettyString(actionId)} that is attached to another entity {ToPrettyString(action.AttachedEntity.Value)}");
@@ -380,7 +380,12 @@ public abstract class SharedActionsSystem : EntitySystem
{
// This here is required because of client-side prediction (RaisePredictiveEvent results in event re-use).
actionEvent.Handled = false;
RaiseLocalEvent(action.Container ?? performer, (object) actionEvent, broadcast: true);
var target = performer;
if (!action.RaiseOnUser && action.Container != null && !HasComp<MindComponent>(action.Container))
target = action.Container.Value;
RaiseLocalEvent(target, (object) actionEvent, broadcast: true);
handled = actionEvent.Handled;
}