]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix action icons not showing up (#15746)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Mon, 24 Apr 2023 19:29:47 +0000 (07:29 +1200)
committerGitHub <noreply@github.com>
Mon, 24 Apr 2023 19:29:47 +0000 (05:29 +1000)
Content.Client/Actions/ActionsSystem.cs
Content.Shared/Actions/ActionTypes/ActionType.cs
Content.Shared/Actions/SharedActionsSystem.cs

index f2be7be2258877e5cfefde1a59f4a299f543c542..a31f23573af48a3c1c5975479993ad8348e56df4 100644 (file)
@@ -28,6 +28,7 @@ namespace Content.Client.Actions
         [Dependency] private readonly IPlayerManager _playerManager = default!;
         [Dependency] private readonly IResourceManager _resources = default!;
         [Dependency] private readonly ISerializationManager _serialization = default!;
+        [Dependency] private readonly SharedAudioSystem _audio = default!;
 
         [Dependency] private readonly PopupSystem _popupSystem = default!;
 
@@ -50,6 +51,15 @@ namespace Content.Client.Actions
             SubscribeLocalEvent<ActionsComponent, ComponentHandleState>(HandleComponentState);
         }
 
+        public override void Dirty(ActionType action)
+        {
+            if (_playerManager.LocalPlayer?.ControlledEntity != action.AttachedEntity)
+                return;
+
+            base.Dirty(action);
+            ActionsUpdated?.Invoke();
+        }
+
         private void HandleComponentState(EntityUid uid, ActionsComponent component, ref ComponentHandleState args)
         {
             if (args.Current is not ActionsComponentState state)
@@ -119,31 +129,36 @@ namespace Content.Client.Actions
 
         public override void AddAction(EntityUid uid, ActionType action, EntityUid? provider, ActionsComponent? comp = null, bool dirty = true)
         {
+            if (uid != _playerManager.LocalPlayer?.ControlledEntity)
+                return;
+
+            if (GameTiming.ApplyingState && !action.ClientExclusive)
+                return;
+
             if (!Resolve(uid, ref comp, false))
                 return;
 
+            dirty &= !action.ClientExclusive;
             base.AddAction(uid, action, provider, comp, dirty);
-
-            if (uid == _playerManager.LocalPlayer?.ControlledEntity)
-                ActionAdded?.Invoke(action);
+            ActionAdded?.Invoke(action);
         }
 
-        public override void RemoveActions(EntityUid uid, IEnumerable<ActionType> actions, ActionsComponent? comp = null, bool dirty = true)
+        public override void RemoveAction(EntityUid uid, ActionType action, ActionsComponent? comp = null, bool dirty = true)
         {
             if (uid != _playerManager.LocalPlayer?.ControlledEntity)
                 return;
 
+            if (GameTiming.ApplyingState && !action.ClientExclusive)
+                return;
+
             if (!Resolve(uid, ref comp, false))
                 return;
 
-            var actionList = actions.ToList();
-            base.RemoveActions(uid, actionList, comp, dirty);
+            dirty &= !action.ClientExclusive;
+            base.RemoveAction(uid, action, comp, dirty);
 
-            foreach (var act in actionList)
-            {
-                if (act.AutoRemove)
-                    ActionRemoved?.Invoke(act);
-            }
+            if (action.AutoRemove)
+                ActionRemoved?.Invoke(action);
         }
 
         /// <summary>
@@ -175,9 +190,7 @@ namespace Content.Client.Actions
                 _popupSystem.PopupEntity(msg, user);
             }
 
-            if (action.Sound != null)
-                SoundSystem.Play(action.Sound.GetSound(), Filter.Local(), user, action.AudioParams);
-
+            _audio.Play(action.Sound, Filter.Local(), user, false);
             return performedAction;
         }
 
index 5681be17aa2026a745ded0b7586446f95b23b954..566c02d12f26c25e169e4d08c7470b2d7ebb1fe1 100644 (file)
@@ -148,6 +148,8 @@ public abstract class ActionType : IEquatable<ActionType>, IComparable, ICloneab
     /// </remarks>
     [DataField("temporary")]
     public bool Temporary;
+    // TODO re-add support for this
+    // UI refactor seems to have just broken it.
 
     /// <summary>
     ///     Determines the appearance of the entity-icon for actions that are enabled via some entity.
@@ -168,9 +170,6 @@ public abstract class ActionType : IEquatable<ActionType>, IComparable, ICloneab
     [DataField("sound")]
     public SoundSpecifier? Sound;
 
-    [DataField("audioParams")]
-    public AudioParams? AudioParams;
-
     /// <summary>
     ///     A pop-up to show the user when performing this action. Gets passed through localization.
     /// </summary>
@@ -260,7 +259,6 @@ public abstract class ActionType : IEquatable<ActionType>, IComparable, ICloneab
         Speech = toClone.Speech;
         UseDelay = toClone.UseDelay;
         Sound = toClone.Sound;
-        AudioParams = toClone.AudioParams;
         UserPopup = toClone.UserPopup;
         Popup = toClone.Popup;
         PopupToggleSuffix = toClone.PopupToggleSuffix;
index c94d914b977793c200fccc1b8a514000c354a105..558b87853660889557637e80fb0b41782e1da255 100644 (file)
@@ -323,7 +323,7 @@ public abstract class SharedActionsSystem : EntitySystem
 
         var filter = predicted ? Filter.PvsExcept(performer) : Filter.Pvs(performer);
 
-        _audio.Play(action.Sound, filter, performer, true, action.AudioParams);
+        _audio.Play(action.Sound, filter, performer, true);
 
         if (string.IsNullOrWhiteSpace(action.Popup))
             return true;
@@ -356,12 +356,10 @@ public abstract class SharedActionsSystem : EntitySystem
 
         comp ??= EnsureComp<ActionsComponent>(uid);
         action.Provider = provider;
-        action.AttachedEntity = comp.Owner;
+        action.AttachedEntity = uid;
         AddActionInternal(comp, action);
 
-        // for client-exclusive actions, the client shouldn't mark the comp as dirty. Otherwise that just leads to
-        // unnecessary prediction resetting and state handling.
-        if (dirty && !action.ClientExclusive)
+        if (dirty)
             Dirty(comp);
     }
 
@@ -400,29 +398,26 @@ public abstract class SharedActionsSystem : EntitySystem
         if (!Resolve(uid, ref comp, false))
             return;
 
-        var provided = comp.Actions.Where(act => act.Provider == provider).ToList();
-
-        if (provided.Count > 0)
-            RemoveActions(uid, provided, comp);
+        foreach (var act in comp.Actions.ToArray())
+        {
+            if (act.Provider == provider)
+                RemoveAction(uid, act, comp, dirty: false);
+        }
+        Dirty(comp);
     }
 
-    public virtual void RemoveActions(EntityUid uid, IEnumerable<ActionType> actions, ActionsComponent? comp = null, bool dirty = true)
+    public virtual void RemoveAction(EntityUid uid, ActionType action, ActionsComponent? comp = null, bool dirty = true)
     {
         if (!Resolve(uid, ref comp, false))
             return;
 
-        foreach (var action in actions)
-        {
-            comp.Actions.Remove(action);
-            action.AttachedEntity = null;
-        }
+        comp.Actions.Remove(action);
+        action.AttachedEntity = null;
 
         if (dirty)
             Dirty(comp);
     }
 
-    public void RemoveAction(EntityUid uid, ActionType action, ActionsComponent? comp = null)
-        => RemoveActions(uid, new[] { action }, comp);
     #endregion
 
     #region EquipHandlers