]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Rollerbed / foldable strap fixes. (#16106)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Fri, 5 May 2023 07:27:15 +0000 (19:27 +1200)
committerGitHub <noreply@github.com>
Fri, 5 May 2023 07:27:15 +0000 (17:27 +1000)
Content.Client/Rotation/RotationVisualizerSystem.cs
Content.Client/Storage/ClientStorageComponent.cs
Content.Server/Foldable/FoldableSystem.cs
Content.Shared/Buckle/Components/StrapComponent.cs
Content.Shared/Buckle/SharedBuckleSystem.Buckle.cs
Content.Shared/Buckle/SharedBuckleSystem.Strap.cs
Content.Shared/Foldable/SharedFoldableSystem.cs
Content.Shared/Rotation/SharedRotationComponent.cs

index 892a93eb51a3dcd6100f39494ff8d36e315f22bd..106bd797110121fbbe7a84a0b071ac5273910fad 100644 (file)
@@ -23,11 +23,11 @@ public sealed class RotationVisualizerSystem : VisualizerSystem<RotationVisualsC
     {
         base.OnAppearanceChange(uid, component, ref args);
 
-        if (!AppearanceSystem.TryGetData<RotationState>(uid, RotationVisuals.RotationState, out var state, args.Component) ||
-            args.Sprite == null)
-        {
+        if (args.Sprite == null)
             return;
-        }
+
+        // If not defined, defaults to standing.
+        AppearanceSystem.TryGetData<RotationState>(uid, RotationVisuals.RotationState, out var state, args.Component);
 
         switch (state)
         {
index 122d2e99000cebceef219409cd3e86cf827be167..dfd0f26c1a3082c06d8d2cce62f8823847b11fa1 100644 (file)
@@ -8,6 +8,7 @@ namespace Content.Client.Storage
     /// Client version of item storage containers, contains a UI which displays stored entities and their size
     /// </summary>
     [RegisterComponent]
+    [ComponentReference(typeof(SharedStorageComponent))]
     public sealed class ClientStorageComponent : SharedStorageComponent
     {
         [Dependency] private readonly IEntityManager _entityManager = default!;
index e21ac657278e715116794fd42e20a7a42b66fc55..7b5b2577dd667ae10515f2a5762a3a81337492a4 100644 (file)
@@ -13,7 +13,6 @@ namespace Content.Server.Foldable
     [UsedImplicitly]
     public sealed class FoldableSystem : SharedFoldableSystem
     {
-        [Dependency] private readonly SharedBuckleSystem _buckle = default!;
         [Dependency] private readonly SharedContainerSystem _container = default!;
 
         public override void Initialize()
@@ -65,20 +64,6 @@ namespace Content.Server.Foldable
             return true;
         }
 
-        /// <summary>
-        /// Set the folded state of the given <see cref="FoldableComponent"/>
-        /// </summary>
-        /// <param name="uid"></param>
-        /// <param name="component"></param>
-        /// <param name="folded">If true, the component will become folded, else unfolded</param>
-        public override void SetFolded(EntityUid uid, FoldableComponent component, bool folded)
-        {
-            base.SetFolded(uid, component, folded);
-
-            // You can't buckle an entity to a folded object
-            _buckle.StrapSetEnabled(uid, !component.IsFolded);
-        }
-
         #region Verb
 
         private void AddFoldVerb(EntityUid uid, FoldableComponent component, GetVerbsEvent<AlternativeVerb> args)
index 5d19cb5883004e7efb7817bce1d2e7891dfea277..8d2515de6d8d012a2d192cd74d12593ee59a5abf 100644 (file)
@@ -14,7 +14,7 @@ public sealed class StrapComponent : Component
     /// <summary>
     /// The entities that are currently buckled
     /// </summary>
-    [ViewVariables]
+    [ViewVariables] // TODO serialization
     public readonly HashSet<EntityUid> BuckledEntities = new();
 
     /// <summary>
index cd50ee0991a5bf000aadf85d1082667e26107177..8a2af7996a68c90b700aeccf98e908c74a696441 100644 (file)
@@ -169,6 +169,7 @@ public abstract partial class SharedBuckleSystem
     /// <param name="strapComp"> strap component of the thing we are strapping to </param>
     private void UpdateBuckleStatus(EntityUid uid, BuckleComponent buckleComp, StrapComponent? strapComp = null)
     {
+        AppearanceSystem.SetData(uid, StrapVisuals.State, buckleComp.Buckled);
         if (buckleComp.BuckledTo != null)
         {
             if (!Resolve(buckleComp.BuckledTo.Value, ref strapComp))
@@ -471,8 +472,6 @@ public abstract partial class SharedBuckleSystem
         {
             _standingSystem.Down(buckleUid);
         }
-        // Sync StrapComponent data
-        AppearanceSystem.SetData(strapUid, StrapVisuals.State, false);
         if (strapComp.BuckledEntities.Remove(buckleUid))
         {
             strapComp.OccupiedSize -= buckleComp.Size;
@@ -480,6 +479,7 @@ public abstract partial class SharedBuckleSystem
             Dirty(strapComp);
         }
 
+        AppearanceSystem.SetData(strapUid, StrapVisuals.State, strapComp.BuckledEntities.Count != 0);
         _audioSystem.PlayPredicted(strapComp.UnbuckleSound, strapUid, buckleUid);
 
         var ev = new BuckleChangeEvent(strapUid, buckleUid, false);
index a87f9fea149f6760b8d14f7e22c268cbecf4e592..44670fd18f0fb3663446e90f2a24c7e583279138 100644 (file)
@@ -14,6 +14,7 @@ public abstract partial class SharedBuckleSystem
 {
     private void InitializeStrap()
     {
+        SubscribeLocalEvent<StrapComponent, ComponentStartup>(OnStrapStartup);
         SubscribeLocalEvent<StrapComponent, ComponentShutdown>(OnStrapShutdown);
         SubscribeLocalEvent<StrapComponent, ComponentRemove>((_, c, _) => StrapRemoveAll(c));
 
@@ -34,6 +35,11 @@ public abstract partial class SharedBuckleSystem
         SubscribeLocalEvent<StrapComponent, MoveEvent>(OnStrapMoveEvent);
     }
 
+    private void OnStrapStartup(EntityUid uid, StrapComponent component, ComponentStartup args)
+    {
+        AppearanceSystem.SetData(uid, StrapVisuals.State, component.BuckledEntities.Count != 0);
+    }
+
     private void OnStrapShutdown(EntityUid uid, StrapComponent component, ComponentShutdown args)
     {
         if (LifeStage(uid) > EntityLifeStage.MapInitialized)
index da94da686d0b18b21541c4852eb747779260dac7..2b2b6423d01f59a6d03ccf621a7f29394bf78aaf 100644 (file)
@@ -1,3 +1,4 @@
+using Content.Shared.Buckle;
 using Content.Shared.Storage.Components;
 using JetBrains.Annotations;
 using Robust.Shared.Containers;
@@ -10,6 +11,7 @@ namespace Content.Shared.Foldable;
 public abstract class SharedFoldableSystem : EntitySystem
 {
     [Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
+    [Dependency] private readonly SharedBuckleSystem _buckle = default!;
 
     public override void Initialize()
     {
@@ -65,6 +67,7 @@ public abstract class SharedFoldableSystem : EntitySystem
         component.IsFolded = folded;
         Dirty(component);
         Appearance.SetData(uid, FoldedVisuals.State, folded);
+        _buckle.StrapSetEnabled(uid, !component.IsFolded);
     }
 
     private void OnInsertEvent(EntityUid uid, FoldableComponent component, ContainerGettingInsertedAttemptEvent args)
index 99ffd6dd8412e24c86287a1e5c9448b2f9fa8874..ce1fd374b3a97c2ff25bb56cf1cb5db3a1e46ad2 100644 (file)
@@ -12,9 +12,9 @@ namespace Content.Shared.Rotation
     public enum RotationState
     {
         /// <summary>
-        ///     Standing up
+        ///     Standing up. This is the default value.
         /// </summary>
-        Vertical,
+        Vertical = 0,
 
         /// <summary>
         ///     Laying down