DummyIcon test (#2515)

* DummyIcon test

Also the relevant fixes.

* Unbox this

* 3rd string

* Update Content.Client/GameObjects/Components/Kitchen/MicrowaveVisualizer.cs

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
metalgearsloth
2020-11-14 00:27:13 +11:00
committed by GitHub
parent baa71e4ff0
commit 4f03c81ddc
4 changed files with 71 additions and 23 deletions

View File

@@ -1,4 +1,5 @@
using Content.Client.GameObjects.Components.Sound;
#nullable enable
using Content.Client.GameObjects.Components.Sound;
using Content.Shared.GameObjects.Components.Power;
using Content.Shared.GameObjects.Components.Sound;
using Content.Shared.Kitchen;
@@ -11,13 +12,13 @@ namespace Content.Client.GameObjects.Components.Kitchen
{
public sealed class MicrowaveVisualizer : AppearanceVisualizer
{
private LoopingSoundComponent _loopingSoundComponent;
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
var sprite = component.Owner.GetComponent<ISpriteComponent>();
_loopingSoundComponent ??= component.Owner.GetComponent<LoopingSoundComponent>();
var loopingSoundComponent = component.Owner.GetComponentOrNull<LoopingSoundComponent>();
if (!component.TryGetData(PowerDeviceVisuals.VisualState, out MicrowaveVisualState state))
{
state = MicrowaveVisualState.Idle;
@@ -27,7 +28,7 @@ namespace Content.Client.GameObjects.Components.Kitchen
case MicrowaveVisualState.Idle:
sprite.LayerSetState(MicrowaveVisualizerLayers.Base, "mw");
sprite.LayerSetState(MicrowaveVisualizerLayers.BaseUnlit, "mw_unlit");
_loopingSoundComponent.StopAllSounds();
loopingSoundComponent?.StopAllSounds();
break;
case MicrowaveVisualState.Cooking:
@@ -38,8 +39,8 @@ namespace Content.Client.GameObjects.Components.Kitchen
var scheduledSound = new ScheduledSound();
scheduledSound.Filename = "/Audio/Machines/microwave_loop.ogg";
scheduledSound.AudioParams = audioParams;
_loopingSoundComponent.StopAllSounds();
_loopingSoundComponent.AddScheduledSound(scheduledSound);
loopingSoundComponent?.StopAllSounds();
loopingSoundComponent?.AddScheduledSound(scheduledSound);
break;
default: