diff --git a/Content.Client/_NF/Storage/AnchorableStorageVisualSystem.cs b/Content.Client/_NF/Storage/AnchorableStorageVisualSystem.cs new file mode 100644 index 00000000000..8a5518c4b19 --- /dev/null +++ b/Content.Client/_NF/Storage/AnchorableStorageVisualSystem.cs @@ -0,0 +1,40 @@ +/// Forge-Change-Start +using Content.Shared._NF.Storage; +using Robust.Client.GameObjects; +using DrawDepth = Content.Shared.DrawDepth.DrawDepth; + +namespace Content.Client._NF.Storage; + +/// +/// Applies anchorable storage world-sprite visibility and draw depth from appearance state. +/// +public sealed class AnchorableStorageVisualSystem : EntitySystem +{ + [Dependency] private AppearanceSystem _appearance = default!; + [Dependency] private SpriteSystem _sprite = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnAppearanceChange); + } + + private void OnAppearanceChange(Entity ent, ref AppearanceChangeEvent args) + { + if (args.Sprite == null) + return; + + UpdateVisuals(ent, args.Sprite); + } + + private void UpdateVisuals(Entity ent, SpriteComponent sprite) + { + if (!_appearance.TryGetData(ent.Owner, AnchorableStorageVisuals.Anchored, out var anchored, ent.Comp)) + return; + + _sprite.SetDrawDepth((ent.Owner, sprite), anchored ? (int) DrawDepth.ThinWire : (int) DrawDepth.Items); + _sprite.SetVisible((ent.Owner, sprite), !anchored); + } +} +/// Forge-Change-End diff --git a/Content.Server/_NF/Storage/AnchorableStorageSystem.cs b/Content.Server/_NF/Storage/AnchorableStorageSystem.cs index 8fba12c6953..73c9fe207ac 100644 --- a/Content.Server/_NF/Storage/AnchorableStorageSystem.cs +++ b/Content.Server/_NF/Storage/AnchorableStorageSystem.cs @@ -1,5 +1,6 @@ using System.Linq; using Content.Server.Popups; +using Content.Shared._NF.Storage; /// Forge-Change using Content.Shared.Construction.Components; using Content.Shared.Mind.Components; using Content.Shared.Nyanotrasen.Item.PseudoItem; @@ -21,14 +22,24 @@ public sealed partial class AnchorableStorageSystem : EntitySystem [Dependency] private PopupSystem _popup = default!; [Dependency] private TransformSystem _xform = default!; [Dependency] private SharedContainerSystem _container = default!; + [Dependency] private SharedAppearanceSystem _appearance = default!; /// Forge-Change /// public override void Initialize() { + base.Initialize(); /// Forge-Change + + SubscribeLocalEvent(OnComponentStartup); /// Forge-Change SubscribeLocalEvent(OnAnchorStateChanged); SubscribeLocalEvent(OnAnchorAttempt); SubscribeLocalEvent(OnInsertAttempt); } + /// Forge-Change-Start + private void OnComponentStartup(Entity ent, ref ComponentStartup args) + { + SetAnchoredVisuals(ent.Owner, Transform(ent.Owner).Anchored); + } + /// Forge-Change-End private void OnAnchorStateChanged(Entity ent, ref AnchorStateChangedEvent args) { @@ -42,20 +53,33 @@ private void OnAnchorStateChanged(Entity ent, ref An return; } + /// Forge-Change-Start + SetAnchoredVisuals(ent.Owner, args.Anchored); + + if (!args.Anchored) + return; + /// Forge-Change-End // Eject any sapient creatures inside the storage. // Does not recurse down into bags in bags - player characters are the largest concern, and they'll only fit in duffelbags. - if (!TryComp(ent.Owner, out StorageComponent? storage)) - return; + // if (!TryComp(ent.Owner, out StorageComponent? storage)) /// Forge-Change-Del + // return; /// Forge-Change-Del - var entsToRemove = storage.StoredItems.Keys.Where(storedItem => - HasComp(storedItem) - || HasComp(storedItem) - ).ToList(); + // var entsToRemove = storage.StoredItems.Keys.Where(storedItem => /// Forge-Change-Del + // HasComp(storedItem) /// Forge-Change-Del + // || HasComp(storedItem) /// Forge-Change-Del + // ).ToList(); /// Forge-Change-Del - foreach (var removeUid in entsToRemove) - _container.RemoveEntity(ent.Owner, removeUid); + // foreach (var removeUid in entsToRemove) /// Forge-Change-Del + // _container.RemoveEntity(ent.Owner, removeUid); /// Forge-Change-Del } + /// Forge-Change-Start + private void SetAnchoredVisuals(EntityUid uid, bool anchored) + { + _appearance.SetData(uid, AnchorableStorageVisuals.Anchored, anchored); + } + + /// Forge-Change-End private void OnAnchorAttempt(Entity ent, ref AnchorAttemptEvent args) { if (args.Cancelled) @@ -75,11 +99,11 @@ private void OnInsertAttempt(Entity ent, ref Contain return; // Check for living things, they should not insert when anchored. - if (!HasComp(args.EntityUid) && !HasComp(args.EntityUid)) - return; + // if (!HasComp(args.EntityUid) && !HasComp(args.EntityUid)) /// Forge-Change-Del + // return; /// Forge-Change-Del - if (Transform(ent.Owner).Anchored) - args.Cancel(); + // if (Transform(ent.Owner).Anchored) /// Forge-Change-Del + // args.Cancel(); /// Forge-Change-Del } [PublicAPI] diff --git a/Content.Shared/_NF/Storage/AnchorableStorageVisuals.cs b/Content.Shared/_NF/Storage/AnchorableStorageVisuals.cs new file mode 100644 index 00000000000..0c1af27a149 --- /dev/null +++ b/Content.Shared/_NF/Storage/AnchorableStorageVisuals.cs @@ -0,0 +1,12 @@ +/// Forge-Change-Start +using Robust.Shared.Serialization; + +namespace Content.Shared._NF.Storage; + +[Serializable, NetSerializable] +public enum AnchorableStorageVisuals : byte +{ + Anchored, + Layer, +} +/// Forge-Change-End diff --git a/Resources/Prototypes/_NF/Entities/Clothing/Back/base_clothing_backpack.yml b/Resources/Prototypes/_NF/Entities/Clothing/Back/base_clothing_backpack.yml index 322e7bea791..7bd76e089d6 100644 --- a/Resources/Prototypes/_NF/Entities/Clothing/Back/base_clothing_backpack.yml +++ b/Resources/Prototypes/_NF/Entities/Clothing/Back/base_clothing_backpack.yml @@ -3,6 +3,20 @@ abstract: true id: NFBackpackHiddenStash components: + # Forge-Change-Start + - type: Sprite + layers: + - state: icon + map: [ "enum.AnchorableStorageVisuals.Layer" ] + - type: GenericVisualizer + visuals: + enum.AnchorableStorageVisuals.Anchored: + enum.AnchorableStorageVisuals.Layer: + True: { drawdepth: ThinWire, visible: false } + False: { drawdepth: Items, visible: true } + - type: Visibility + layer: 1 + # Forge-Change-End - type: Appearance - type: SubFloorHide - type: Anchorable