]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Allow actions to specify if they want to rotate the user when targeting (#37958)
authorDrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com>
Fri, 30 May 2025 12:56:16 +0000 (05:56 -0700)
committerGitHub <noreply@github.com>
Fri, 30 May 2025 12:56:16 +0000 (08:56 -0400)
Content.Shared/Actions/Components/EntityTargetActionComponent.cs
Content.Shared/Actions/Components/WorldTargetActionComponent.cs
Content.Shared/Actions/SharedActionsSystem.cs

index d32205d157b9af0789a2375285ddd562f4cc388f..82289364b4d5fa38c55057d5e0e39c749cea8866 100644 (file)
@@ -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;
 }
index 6ec201dcb89b5c8df7b6c18753b7e2ccac107f37..87e3220e37db6181ebf22bb0ded74d4e1eb545ba 100644 (file)
@@ -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;
 }
index d32bd23da0e5b9281adadc131d092d772f4e4cfa..948d655d4a29a2a5e1eb4f236a38b1715f10afef 100644 (file)
@@ -348,7 +348,9 @@ public abstract class SharedActionsSystem : EntitySystem
         var target = GetEntity(netTarget);
 
         var targetWorldPos = _transform.GetWorldPosition(target);
-        _rotateToFace.TryFaceCoordinates(user, targetWorldPos);
+
+        if (ent.Comp.RotateOnUse)
+            _rotateToFace.TryFaceCoordinates(user, targetWorldPos);
 
         if (!ValidateEntityTarget(user, target, ent))
             return;
@@ -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,