Resolves SmokeVisualizer is Obsolete (#13881)
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
using Content.Shared.Smoking;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.Chemistry.Visualizers
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class SmokeVisualizer : AppearanceVisualizer
|
||||
{
|
||||
[Obsolete("Subscribe to AppearanceChangeEvent instead.")]
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (component.TryGetData<Color>(SmokeVisuals.Color, out var color))
|
||||
{
|
||||
if (entities.TryGetComponent(component.Owner, out SpriteComponent? sprite))
|
||||
{
|
||||
sprite.Color = color;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using Content.Shared.Smoking;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.Chemistry.Visualizers;
|
||||
|
||||
/// <summary>
|
||||
/// Ensures entities with <see cref="SmokeVisualsComponent"/> have a color corresponding with their contained reagents.
|
||||
/// </summary>
|
||||
public sealed class SmokeVisualizerSystem : VisualizerSystem<SmokeVisualsComponent>
|
||||
{
|
||||
/// <summary>
|
||||
/// Syncs the color of the smoke with the color of its contained reagents.
|
||||
/// </summary>
|
||||
protected override void OnAppearanceChange(EntityUid uid, SmokeVisualsComponent comp, ref AppearanceChangeEvent args)
|
||||
{
|
||||
if (args.Sprite == null)
|
||||
return;
|
||||
if(!AppearanceSystem.TryGetData<Color>(uid, SmokeVisuals.Color, out var color))
|
||||
return;
|
||||
args.Sprite.Color = color;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace Content.Client.Chemistry.Visualizers;
|
||||
|
||||
/// <summary>
|
||||
/// A component that changes color to match its contained reagents.
|
||||
/// Managed by <see cref="SmokeVisualizerSystem"/>.
|
||||
/// Only functions with smoke at the moment.
|
||||
/// </summary>
|
||||
[RegisterComponent]
|
||||
[Access(typeof(SmokeVisualizerSystem))]
|
||||
public sealed class SmokeVisualsComponent : Component {}
|
||||
Reference in New Issue
Block a user