action refactor proper ecs edition (#27422)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
using Content.Server.NPC.Systems;
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Actions.Components;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Server.NPC.Components;
|
||||
@@ -20,7 +20,7 @@ public sealed partial class NPCUseActionOnTargetComponent : Component
|
||||
/// Action that's going to attempt to be used.
|
||||
/// </summary>
|
||||
[DataField(required: true)]
|
||||
public EntProtoId<EntityWorldTargetActionComponent> ActionId;
|
||||
public EntProtoId<TargetActionComponent> ActionId;
|
||||
|
||||
[DataField]
|
||||
public EntityUid? ActionEnt;
|
||||
|
||||
@@ -28,24 +28,16 @@ public sealed class NPCUseActionOnTargetSystem : EntitySystem
|
||||
if (!Resolve(user, ref user.Comp, false))
|
||||
return false;
|
||||
|
||||
if (!TryComp<EntityWorldTargetActionComponent>(user.Comp.ActionEnt, out var action))
|
||||
if (_actions.GetAction(user.Comp.ActionEnt) is not {} action)
|
||||
return false;
|
||||
|
||||
if (!_actions.ValidAction(action))
|
||||
return false;
|
||||
|
||||
if (action.Event != null)
|
||||
{
|
||||
action.Event.Coords = Transform(target).Coordinates;
|
||||
}
|
||||
_actions.SetEventTarget(action, target);
|
||||
|
||||
_actions.PerformAction(user,
|
||||
null,
|
||||
user.Comp.ActionEnt.Value,
|
||||
action,
|
||||
action.BaseEvent,
|
||||
_timing.CurTime,
|
||||
false);
|
||||
// NPC is serverside, no prediction :(
|
||||
_actions.PerformAction(user.Owner, action, predicted: false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user