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:
@@ -13,13 +13,20 @@ namespace Content.Client.GameObjects.Components.Crayon
|
|||||||
|
|
||||||
var sprite = component.Owner.GetComponent<SpriteComponent>();
|
var sprite = component.Owner.GetComponent<SpriteComponent>();
|
||||||
|
|
||||||
var state = component.GetData<string>(CrayonVisuals.State);
|
if (component.TryGetData(CrayonVisuals.State, out string state))
|
||||||
var color = component.GetData<Color>(CrayonVisuals.Color);
|
{
|
||||||
var rotation = component.GetData<Angle>(CrayonVisuals.Rotation);
|
sprite.LayerSetState(0, state);
|
||||||
|
}
|
||||||
|
|
||||||
sprite.LayerSetState(0, state);
|
if (component.TryGetData(CrayonVisuals.Color, out Color color))
|
||||||
sprite.LayerSetColor(0, color);
|
{
|
||||||
sprite.Rotation = rotation;
|
sprite.LayerSetColor(0, color);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (component.TryGetData(CrayonVisuals.Rotation, out Angle rotation))
|
||||||
|
{
|
||||||
|
sprite.Rotation = rotation;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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.Power;
|
||||||
using Content.Shared.GameObjects.Components.Sound;
|
using Content.Shared.GameObjects.Components.Sound;
|
||||||
using Content.Shared.Kitchen;
|
using Content.Shared.Kitchen;
|
||||||
@@ -11,13 +12,13 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
|||||||
{
|
{
|
||||||
public sealed class MicrowaveVisualizer : AppearanceVisualizer
|
public sealed class MicrowaveVisualizer : AppearanceVisualizer
|
||||||
{
|
{
|
||||||
private LoopingSoundComponent _loopingSoundComponent;
|
|
||||||
|
|
||||||
public override void OnChangeData(AppearanceComponent component)
|
public override void OnChangeData(AppearanceComponent component)
|
||||||
{
|
{
|
||||||
base.OnChangeData(component);
|
base.OnChangeData(component);
|
||||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
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))
|
if (!component.TryGetData(PowerDeviceVisuals.VisualState, out MicrowaveVisualState state))
|
||||||
{
|
{
|
||||||
state = MicrowaveVisualState.Idle;
|
state = MicrowaveVisualState.Idle;
|
||||||
@@ -27,7 +28,7 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
|||||||
case MicrowaveVisualState.Idle:
|
case MicrowaveVisualState.Idle:
|
||||||
sprite.LayerSetState(MicrowaveVisualizerLayers.Base, "mw");
|
sprite.LayerSetState(MicrowaveVisualizerLayers.Base, "mw");
|
||||||
sprite.LayerSetState(MicrowaveVisualizerLayers.BaseUnlit, "mw_unlit");
|
sprite.LayerSetState(MicrowaveVisualizerLayers.BaseUnlit, "mw_unlit");
|
||||||
_loopingSoundComponent.StopAllSounds();
|
loopingSoundComponent?.StopAllSounds();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MicrowaveVisualState.Cooking:
|
case MicrowaveVisualState.Cooking:
|
||||||
@@ -38,8 +39,8 @@ namespace Content.Client.GameObjects.Components.Kitchen
|
|||||||
var scheduledSound = new ScheduledSound();
|
var scheduledSound = new ScheduledSound();
|
||||||
scheduledSound.Filename = "/Audio/Machines/microwave_loop.ogg";
|
scheduledSound.Filename = "/Audio/Machines/microwave_loop.ogg";
|
||||||
scheduledSound.AudioParams = audioParams;
|
scheduledSound.AudioParams = audioParams;
|
||||||
_loopingSoundComponent.StopAllSounds();
|
loopingSoundComponent?.StopAllSounds();
|
||||||
_loopingSoundComponent.AddScheduledSound(scheduledSound);
|
loopingSoundComponent?.AddScheduledSound(scheduledSound);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
using System;
|
#nullable enable
|
||||||
|
using System;
|
||||||
using Content.Shared.GameObjects.Components;
|
using Content.Shared.GameObjects.Components;
|
||||||
using Content.Shared.Utility;
|
using Content.Shared.Utility;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Robust.Client.GameObjects;
|
using Robust.Client.GameObjects;
|
||||||
using Robust.Client.Interfaces.GameObjects.Components;
|
using Robust.Client.Interfaces.GameObjects.Components;
|
||||||
using Robust.Shared.GameObjects.Components.Transform;
|
using Robust.Shared.GameObjects.Components.Transform;
|
||||||
using Robust.Shared.Interfaces.GameObjects;
|
|
||||||
|
|
||||||
namespace Content.Client.GameObjects.Components
|
namespace Content.Client.GameObjects.Components
|
||||||
{
|
{
|
||||||
@@ -17,24 +17,29 @@ namespace Content.Client.GameObjects.Components
|
|||||||
base.OnChangeData(component);
|
base.OnChangeData(component);
|
||||||
|
|
||||||
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
||||||
var snapGrid = component.Owner.GetComponent<SnapGridComponent>();
|
if (!component.Owner.TryGetComponent(out SnapGridComponent? snapGrid))
|
||||||
|
return;
|
||||||
|
|
||||||
var lowWall = FindLowWall(snapGrid);
|
var lowWall = FindLowWall(snapGrid);
|
||||||
if (lowWall == null) return;
|
if (lowWall == null)
|
||||||
|
return;
|
||||||
|
|
||||||
if (component.TryGetData(WindowVisuals.Damage, out float fraction))
|
if (component.TryGetData(WindowVisuals.Damage, out float fraction))
|
||||||
{
|
{
|
||||||
var level = Math.Min(ContentHelpers.RoundToLevels(fraction, 1, 7), 5);
|
var level = Math.Min(ContentHelpers.RoundToLevels(fraction, 1, 7), 5);
|
||||||
if (level == 0)
|
if (level == 0)
|
||||||
{
|
{
|
||||||
foreach (WindowDamageLayers val in Enum.GetValues(typeof(WindowDamageLayers)))
|
foreach (var val in Enum.GetValues(typeof(WindowDamageLayers)))
|
||||||
{
|
{
|
||||||
sprite.LayerSetVisible(val, false);
|
if (val == null) continue;
|
||||||
|
sprite.LayerSetVisible((WindowDamageLayers) val, false);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
foreach (WindowDamageLayers val in Enum.GetValues(typeof(WindowDamageLayers)))
|
foreach (var val in Enum.GetValues(typeof(WindowDamageLayers)))
|
||||||
{
|
{
|
||||||
sprite.LayerSetVisible(val, true);
|
if (val == null) continue;
|
||||||
|
sprite.LayerSetVisible((WindowDamageLayers) val, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
sprite.LayerSetState(WindowDamageLayers.DamageNE, $"{(int) lowWall.LastCornerNE}_{level}");
|
sprite.LayerSetState(WindowDamageLayers.DamageNE, $"{(int) lowWall.LastCornerNE}_{level}");
|
||||||
@@ -45,11 +50,11 @@ namespace Content.Client.GameObjects.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static LowWallComponent FindLowWall(SnapGridComponent snapGrid)
|
private static LowWallComponent? FindLowWall(SnapGridComponent snapGrid)
|
||||||
{
|
{
|
||||||
foreach (var entity in snapGrid.GetLocal())
|
foreach (var entity in snapGrid.GetLocal())
|
||||||
{
|
{
|
||||||
if (entity.TryGetComponent(out LowWallComponent lowWall))
|
if (entity.TryGetComponent(out LowWallComponent? lowWall))
|
||||||
{
|
{
|
||||||
return lowWall;
|
return lowWall;
|
||||||
}
|
}
|
||||||
|
|||||||
35
Content.IntegrationTests/Tests/DummyIconTest.cs
Normal file
35
Content.IntegrationTests/Tests/DummyIconTest.cs
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
#nullable enable
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
|
using Robust.Client.Interfaces.ResourceManagement;
|
||||||
|
using Robust.Shared.GameObjects;
|
||||||
|
using Robust.Shared.Prototypes;
|
||||||
|
|
||||||
|
namespace Content.IntegrationTests.Tests
|
||||||
|
{
|
||||||
|
[TestFixture]
|
||||||
|
public class DummyIconTest : ContentIntegrationTest
|
||||||
|
{
|
||||||
|
[Test]
|
||||||
|
public async Task Test()
|
||||||
|
{
|
||||||
|
var client = StartClient();
|
||||||
|
await client.WaitIdleAsync();
|
||||||
|
|
||||||
|
var prototypeManager = client.ResolveDependency<IPrototypeManager>();
|
||||||
|
var resourceCache = client.ResolveDependency<IResourceCache>();
|
||||||
|
|
||||||
|
await client.WaitAssertion(() =>
|
||||||
|
{
|
||||||
|
foreach (var proto in prototypeManager.EnumeratePrototypes<EntityPrototype>())
|
||||||
|
{
|
||||||
|
if (!proto.Components.ContainsKey("Sprite")) continue;
|
||||||
|
|
||||||
|
SpriteComponent.GetPrototypeTextures(proto, resourceCache).ToList();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user