Resolves ParticleAcceleratorPartVisualizer is Obsolete (#13897)
This commit is contained in:
@@ -1,62 +0,0 @@
|
|||||||
using System.Linq;
|
|
||||||
using Content.Shared.Singularity.Components;
|
|
||||||
using JetBrains.Annotations;
|
|
||||||
using Robust.Client.GameObjects;
|
|
||||||
|
|
||||||
namespace Content.Client.ParticleAccelerator
|
|
||||||
{
|
|
||||||
[UsedImplicitly]
|
|
||||||
[DataDefinition]
|
|
||||||
public sealed class ParticleAcceleratorPartVisualizer : AppearanceVisualizer
|
|
||||||
{
|
|
||||||
[DataField("baseState", required: true)]
|
|
||||||
private string _baseState = default!;
|
|
||||||
|
|
||||||
private static readonly Dictionary<ParticleAcceleratorVisualState, string> StatesSuffixes = new()
|
|
||||||
{
|
|
||||||
{ParticleAcceleratorVisualState.Powered, "p"},
|
|
||||||
{ParticleAcceleratorVisualState.Level0, "p0"},
|
|
||||||
{ParticleAcceleratorVisualState.Level1, "p1"},
|
|
||||||
{ParticleAcceleratorVisualState.Level2, "p2"},
|
|
||||||
{ParticleAcceleratorVisualState.Level3, "p3"},
|
|
||||||
};
|
|
||||||
|
|
||||||
[Obsolete("Subscribe to your component being initialised instead.")]
|
|
||||||
public override void InitializeEntity(EntityUid entity)
|
|
||||||
{
|
|
||||||
base.InitializeEntity(entity);
|
|
||||||
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent<SpriteComponent?>(entity, out var sprite))
|
|
||||||
{
|
|
||||||
throw new EntityCreationException("No sprite component found in entity that has ParticleAcceleratorPartVisualizer");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!sprite.AllLayers.Any())
|
|
||||||
{
|
|
||||||
throw new EntityCreationException("No Layer set for entity that has ParticleAcceleratorPartVisualizer");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[Obsolete("Subscribe to AppearanceChangeEvent instead.")]
|
|
||||||
public override void OnChangeData(AppearanceComponent component)
|
|
||||||
{
|
|
||||||
base.OnChangeData(component);
|
|
||||||
|
|
||||||
var entities = IoCManager.Resolve<IEntityManager>();
|
|
||||||
if (!entities.TryGetComponent(component.Owner, out SpriteComponent? sprite)) return;
|
|
||||||
if (!component.TryGetData(ParticleAcceleratorVisuals.VisualState, out ParticleAcceleratorVisualState state))
|
|
||||||
{
|
|
||||||
state = ParticleAcceleratorVisualState.Unpowered;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state != ParticleAcceleratorVisualState.Unpowered)
|
|
||||||
{
|
|
||||||
sprite.LayerSetVisible(ParticleAcceleratorVisualLayers.Unlit, true);
|
|
||||||
sprite.LayerSetState(ParticleAcceleratorVisualLayers.Unlit, _baseState + StatesSuffixes[state]);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprite.LayerSetVisible(ParticleAcceleratorVisualLayers.Unlit, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
using Content.Shared.Singularity.Components;
|
||||||
|
|
||||||
|
namespace Content.Client.ParticleAccelerator;
|
||||||
|
|
||||||
|
[RegisterComponent]
|
||||||
|
[Access(typeof(ParticleAcceleratorPartVisualizerSystem))]
|
||||||
|
public sealed class ParticleAcceleratorPartVisualsComponent : Component
|
||||||
|
{
|
||||||
|
[DataField("stateBase", required: true)]
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public string StateBase = default!;
|
||||||
|
|
||||||
|
[DataField("stateSuffixes")]
|
||||||
|
[ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public readonly Dictionary<ParticleAcceleratorVisualState, string> StatesSuffixes = new()
|
||||||
|
{
|
||||||
|
{ParticleAcceleratorVisualState.Powered, "p"},
|
||||||
|
{ParticleAcceleratorVisualState.Level0, "p0"},
|
||||||
|
{ParticleAcceleratorVisualState.Level1, "p1"},
|
||||||
|
{ParticleAcceleratorVisualState.Level2, "p2"},
|
||||||
|
{ParticleAcceleratorVisualState.Level3, "p3"},
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
using System.Linq;
|
||||||
|
using Content.Shared.Singularity.Components;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Client.ParticleAccelerator;
|
||||||
|
|
||||||
|
public sealed class ParticleAcceleratorPartVisualizerSystem : VisualizerSystem<ParticleAcceleratorPartVisualsComponent>
|
||||||
|
{
|
||||||
|
protected override void OnAppearanceChange(EntityUid uid, ParticleAcceleratorPartVisualsComponent comp, ref AppearanceChangeEvent args)
|
||||||
|
{
|
||||||
|
if (args.Sprite == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!AppearanceSystem.TryGetData<ParticleAcceleratorVisualState>(uid, ParticleAcceleratorVisuals.VisualState, out var state, args.Component))
|
||||||
|
{
|
||||||
|
state = ParticleAcceleratorVisualState.Unpowered;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state != ParticleAcceleratorVisualState.Unpowered)
|
||||||
|
{
|
||||||
|
args.Sprite.LayerSetVisible(ParticleAcceleratorVisualLayers.Unlit, true);
|
||||||
|
args.Sprite.LayerSetState(ParticleAcceleratorVisualLayers.Unlit, comp.StateBase + comp.StatesSuffixes[state]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
args.Sprite.LayerSetVisible(ParticleAcceleratorVisualLayers.Unlit, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,9 +14,8 @@
|
|||||||
shader: unshaded
|
shader: unshaded
|
||||||
visible: false
|
visible: false
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
- type: ParticleAcceleratorPartVisuals
|
||||||
- type: ParticleAcceleratorPartVisualizer
|
stateBase: unlit
|
||||||
baseState: unlit
|
|
||||||
- type: ApcPowerReceiver
|
- type: ApcPowerReceiver
|
||||||
powerLoad: 250
|
powerLoad: 250
|
||||||
- type: ExtensionCableReceiver
|
- type: ExtensionCableReceiver
|
||||||
|
|||||||
@@ -14,9 +14,8 @@
|
|||||||
shader: unshaded
|
shader: unshaded
|
||||||
visible: false
|
visible: false
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
- type: ParticleAcceleratorPartVisuals
|
||||||
- type: ParticleAcceleratorPartVisualizer
|
stateBase: unlit
|
||||||
baseState: unlit
|
|
||||||
- type: ParticleAcceleratorPart
|
- type: ParticleAcceleratorPart
|
||||||
- type: ParticleAcceleratorEmitter
|
- type: ParticleAcceleratorEmitter
|
||||||
emitterType: Left
|
emitterType: Left
|
||||||
@@ -43,13 +42,11 @@
|
|||||||
shader: unshaded
|
shader: unshaded
|
||||||
visible: false
|
visible: false
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
- type: ParticleAcceleratorPartVisuals
|
||||||
- type: ParticleAcceleratorPartVisualizer
|
stateBase: unlit
|
||||||
baseState: unlit
|
|
||||||
- type: ParticleAcceleratorPart
|
- type: ParticleAcceleratorPart
|
||||||
- type: ParticleAcceleratorEmitter
|
- type: ParticleAcceleratorEmitter
|
||||||
emitterType: Center
|
emitterType: Center
|
||||||
- type: Construction
|
|
||||||
graph: ParticleAcceleratorEmitterCenter
|
graph: ParticleAcceleratorEmitterCenter
|
||||||
node: completed
|
node: completed
|
||||||
- type: GuideHelp
|
- type: GuideHelp
|
||||||
@@ -71,9 +68,8 @@
|
|||||||
shader: unshaded
|
shader: unshaded
|
||||||
visible: false
|
visible: false
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
- type: ParticleAcceleratorPartVisuals
|
||||||
- type: ParticleAcceleratorPartVisualizer
|
stateBase: unlit
|
||||||
baseState: unlit
|
|
||||||
- type: ParticleAcceleratorPart
|
- type: ParticleAcceleratorPart
|
||||||
- type: ParticleAcceleratorEmitter
|
- type: ParticleAcceleratorEmitter
|
||||||
emitterType: Right
|
emitterType: Right
|
||||||
|
|||||||
@@ -14,9 +14,8 @@
|
|||||||
shader: unshaded
|
shader: unshaded
|
||||||
visible: false
|
visible: false
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
- type: ParticleAcceleratorPartVisuals
|
||||||
- type: ParticleAcceleratorPartVisualizer
|
stateBase: unlit
|
||||||
baseState: unlit
|
|
||||||
- type: ParticleAcceleratorPart
|
- type: ParticleAcceleratorPart
|
||||||
- type: ParticleAcceleratorFuelChamber
|
- type: ParticleAcceleratorFuelChamber
|
||||||
- type: Construction
|
- type: Construction
|
||||||
|
|||||||
@@ -14,9 +14,8 @@
|
|||||||
shader: unshaded
|
shader: unshaded
|
||||||
visible: false
|
visible: false
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
- type: ParticleAcceleratorPartVisuals
|
||||||
- type: ParticleAcceleratorPartVisualizer
|
stateBase: unlit
|
||||||
baseState: unlit
|
|
||||||
- type: ParticleAcceleratorPart
|
- type: ParticleAcceleratorPart
|
||||||
- type: ParticleAcceleratorPowerBox
|
- type: ParticleAcceleratorPowerBox
|
||||||
- type: PowerConsumer
|
- type: PowerConsumer
|
||||||
|
|||||||
Reference in New Issue
Block a user