Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions Content.Client/_NF/Storage/AnchorableStorageVisualSystem.cs
Original file line number Diff line number Diff line change
@@ -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;

/// <summary>
/// Applies anchorable storage world-sprite visibility and draw depth from appearance state.
/// </summary>
public sealed class AnchorableStorageVisualSystem : EntitySystem
{
[Dependency] private AppearanceSystem _appearance = default!;
[Dependency] private SpriteSystem _sprite = default!;

public override void Initialize()
{
base.Initialize();

SubscribeLocalEvent<AppearanceComponent, AppearanceChangeEvent>(OnAppearanceChange);
}

private void OnAppearanceChange(Entity<AppearanceComponent> ent, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;

UpdateVisuals(ent, args.Sprite);
}

private void UpdateVisuals(Entity<AppearanceComponent> ent, SpriteComponent sprite)
{
if (!_appearance.TryGetData<bool>(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
48 changes: 36 additions & 12 deletions Content.Server/_NF/Storage/AnchorableStorageSystem.cs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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

/// <inheritdoc/>
public override void Initialize()
{
base.Initialize(); /// Forge-Change

SubscribeLocalEvent<AnchorableStorageComponent, ComponentStartup>(OnComponentStartup); /// Forge-Change
SubscribeLocalEvent<AnchorableStorageComponent, AnchorStateChangedEvent>(OnAnchorStateChanged);
SubscribeLocalEvent<AnchorableStorageComponent, AnchorAttemptEvent>(OnAnchorAttempt);
SubscribeLocalEvent<AnchorableStorageComponent, ContainerIsInsertingAttemptEvent>(OnInsertAttempt);
}
/// Forge-Change-Start
private void OnComponentStartup(Entity<AnchorableStorageComponent> ent, ref ComponentStartup args)
{
SetAnchoredVisuals(ent.Owner, Transform(ent.Owner).Anchored);
}
/// Forge-Change-End

private void OnAnchorStateChanged(Entity<AnchorableStorageComponent> ent, ref AnchorStateChangedEvent args)
{
Expand All @@ -42,20 +53,33 @@ private void OnAnchorStateChanged(Entity<AnchorableStorageComponent> 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<MindContainerComponent>(storedItem)
|| HasComp<PseudoItemComponent>(storedItem)
).ToList();
// var entsToRemove = storage.StoredItems.Keys.Where(storedItem => /// Forge-Change-Del
// HasComp<MindContainerComponent>(storedItem) /// Forge-Change-Del
// || HasComp<PseudoItemComponent>(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<AnchorableStorageComponent> ent, ref AnchorAttemptEvent args)
{
if (args.Cancelled)
Expand All @@ -75,11 +99,11 @@ private void OnInsertAttempt(Entity<AnchorableStorageComponent> ent, ref Contain
return;

// Check for living things, they should not insert when anchored.
if (!HasComp<MindContainerComponent>(args.EntityUid) && !HasComp<PseudoItemComponent>(args.EntityUid))
return;
// if (!HasComp<MindContainerComponent>(args.EntityUid) && !HasComp<PseudoItemComponent>(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]
Expand Down
12 changes: 12 additions & 0 deletions Content.Shared/_NF/Storage/AnchorableStorageVisuals.cs
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading