Allow actions to specify if they want to rotate the user when targeting (#37958)
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using Content.Shared.Actions;
|
||||
using Content.Shared.Whitelist;
|
||||
using Content.Shared.Whitelist;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -45,4 +44,10 @@ public sealed partial class EntityTargetActionComponent : Component
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public bool CanTargetSelf = true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to make the user face towards the direction where they targeted this action.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public bool RotateOnUse = true;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Content.Shared.Actions;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.Actions.Components;
|
||||
@@ -13,6 +12,7 @@ namespace Content.Shared.Actions.Components;
|
||||
/// </remarks>
|
||||
[RegisterComponent, NetworkedComponent, Access(typeof(SharedActionsSystem))]
|
||||
[EntityCategory("Actions")]
|
||||
[AutoGenerateComponentState]
|
||||
public sealed partial class WorldTargetActionComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
@@ -20,4 +20,10 @@ public sealed partial class WorldTargetActionComponent : Component
|
||||
/// </summary>
|
||||
[DataField(required: true), NonSerialized]
|
||||
public WorldTargetActionEvent? Event;
|
||||
|
||||
/// <summary>
|
||||
/// Whether to make the user face towards the direction where they targeted this action.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public bool RotateOnUse = true;
|
||||
}
|
||||
|
||||
@@ -348,6 +348,8 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
var target = GetEntity(netTarget);
|
||||
|
||||
var targetWorldPos = _transform.GetWorldPosition(target);
|
||||
|
||||
if (ent.Comp.RotateOnUse)
|
||||
_rotateToFace.TryFaceCoordinates(user, targetWorldPos);
|
||||
|
||||
if (!ValidateEntityTarget(user, target, ent))
|
||||
@@ -369,7 +371,9 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
|
||||
var user = args.User;
|
||||
var target = GetCoordinates(netTarget);
|
||||
_rotateToFace.TryFaceCoordinates(user, target.ToMapPos(EntityManager, _transform));
|
||||
|
||||
if (ent.Comp.RotateOnUse)
|
||||
_rotateToFace.TryFaceCoordinates(user, _transform.ToMapCoordinates(target).Position);
|
||||
|
||||
if (!ValidateWorldTarget(user, target, ent))
|
||||
return;
|
||||
@@ -604,7 +608,7 @@ public abstract class SharedActionsSystem : EntitySystem
|
||||
return AddAction(performer, ref actionId, out _, actionPrototypeId, container, component);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="AddAction(Robust.Shared.GameObjects.EntityUid,ref System.Nullable{Robust.Shared.GameObjects.EntityUid},string?,Robust.Shared.GameObjects.EntityUid,Content.Shared.Actions.ActionsComponent?)"/>
|
||||
/// <inheritdoc cref="AddAction(Robust.Shared.GameObjects.EntityUid,ref System.Nullable{Robust.Shared.GameObjects.EntityUid},string?,Robust.Shared.GameObjects.EntityUid,ActionsComponent?)"/>
|
||||
public bool AddAction(EntityUid performer,
|
||||
[NotNullWhen(true)] ref EntityUid? actionId,
|
||||
[NotNullWhen(true)] out ActionComponent? action,
|
||||
|
||||
Reference in New Issue
Block a user