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 <comedian_vs_clown@hotmail.com>
This commit is contained in:
bryce0110
2021-04-08 07:39:50 -05:00
committed by GitHub
parent 974e60eec1
commit f51d7a9a6d

View File

@@ -121,12 +121,10 @@ namespace Content.Server.GameObjects.Components.Items.Storage
get => _isWeldedShut; get => _isWeldedShut;
set set
{ {
_isWeldedShut = value; if (_isWeldedShut == value) return;
if (Owner.TryGetComponent(out AppearanceComponent? appearance)) _isWeldedShut = value;
{ UpdateAppearance();
appearance.SetData(StorageVisuals.Welded, value);
}
} }
} }
@@ -137,14 +135,10 @@ namespace Content.Server.GameObjects.Components.Items.Storage
get => _canWeldShut; get => _canWeldShut;
set set
{ {
if (_canWeldShut == value) if (_canWeldShut == value) return;
return;
_canWeldShut = value; _canWeldShut = value;
if (Owner.TryGetComponent(out AppearanceComponent? appearance)) UpdateAppearance();
{
appearance.SetData(StorageVisuals.CanWeld, value);
}
} }
} }
@@ -152,7 +146,7 @@ namespace Content.Server.GameObjects.Components.Items.Storage
public override void Initialize() public override void Initialize()
{ {
base.Initialize(); base.Initialize();
Contents = ContainerHelpers.EnsureContainer<Container>(Owner, nameof(EntityStorageComponent)); Contents = Owner.EnsureContainer<Container>(nameof(EntityStorageComponent));
EntityQuery = new IntersectingEntityQuery(Owner); EntityQuery = new IntersectingEntityQuery(Owner);
Contents.ShowContents = _showContents; Contents.ShowContents = _showContents;
@@ -162,6 +156,8 @@ namespace Content.Server.GameObjects.Components.Items.Storage
{ {
placeableSurfaceComponent.IsPlaceable = Open; placeableSurfaceComponent.IsPlaceable = Open;
} }
UpdateAppearance();
} }
public virtual void Activate(ActivateEventArgs eventArgs) public virtual void Activate(ActivateEventArgs eventArgs)
@@ -237,6 +233,15 @@ namespace Content.Server.GameObjects.Components.Items.Storage
SoundSystem.Play(Filter.Pvs(Owner), _openSound, Owner); 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() private void ModifyComponents()
{ {
if (!_isCollidableWhenOpen && Owner.TryGetComponent<IPhysBody>(out var physics)) if (!_isCollidableWhenOpen && Owner.TryGetComponent<IPhysBody>(out var physics))