From f51d7a9a6dbb38a8bd8c8ce66f40526bf864373a Mon Sep 17 00:00:00 2001 From: bryce0110 Date: Thu, 8 Apr 2021 07:39:50 -0500 Subject: [PATCH] Crate and Locker welded sprite now appears (#3606) * Crate and Locker welded sprite now appears * Address requested changes * UpdateAppearance method * Make all appearance updates common Co-authored-by: metalgearsloth --- .../Items/Storage/EntityStorageComponent.cs | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/Content.Server/GameObjects/Components/Items/Storage/EntityStorageComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/EntityStorageComponent.cs index bc894bc7cd..44bb4b4f50 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/EntityStorageComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/EntityStorageComponent.cs @@ -121,12 +121,10 @@ namespace Content.Server.GameObjects.Components.Items.Storage get => _isWeldedShut; set { - _isWeldedShut = value; + if (_isWeldedShut == value) return; - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) - { - appearance.SetData(StorageVisuals.Welded, value); - } + _isWeldedShut = value; + UpdateAppearance(); } } @@ -137,14 +135,10 @@ namespace Content.Server.GameObjects.Components.Items.Storage get => _canWeldShut; set { - if (_canWeldShut == value) - return; + if (_canWeldShut == value) return; _canWeldShut = value; - if (Owner.TryGetComponent(out AppearanceComponent? appearance)) - { - appearance.SetData(StorageVisuals.CanWeld, value); - } + UpdateAppearance(); } } @@ -152,7 +146,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage public override void Initialize() { base.Initialize(); - Contents = ContainerHelpers.EnsureContainer(Owner, nameof(EntityStorageComponent)); + Contents = Owner.EnsureContainer(nameof(EntityStorageComponent)); EntityQuery = new IntersectingEntityQuery(Owner); Contents.ShowContents = _showContents; @@ -162,6 +156,8 @@ namespace Content.Server.GameObjects.Components.Items.Storage { placeableSurfaceComponent.IsPlaceable = Open; } + + UpdateAppearance(); } public virtual void Activate(ActivateEventArgs eventArgs) @@ -237,6 +233,15 @@ namespace Content.Server.GameObjects.Components.Items.Storage SoundSystem.Play(Filter.Pvs(Owner), _openSound, Owner); } + private void UpdateAppearance() + { + if (Owner.TryGetComponent(out AppearanceComponent? appearance)) + { + appearance.SetData(StorageVisuals.CanWeld, _canWeldShut); + appearance.SetData(StorageVisuals.Welded, _isWeldedShut); + } + } + private void ModifyComponents() { if (!_isCollidableWhenOpen && Owner.TryGetComponent(out var physics))