EntityStorage ECS (#9291)
This commit is contained in:
6
Content.Client/Morgue/Visualizers/BodyBagVisualLayers.cs
Normal file
6
Content.Client/Morgue/Visualizers/BodyBagVisualLayers.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Content.Client.Morgue.Visualizers;
|
||||
|
||||
public enum BodyBagVisualLayers : byte
|
||||
{
|
||||
Label,
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
using Content.Shared.Labels;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.Morgue.Visualizers
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class BodyBagVisualizer : AppearanceVisualizer
|
||||
{
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent(component.Owner, out ISpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (component.TryGetData(PaperLabelVisuals.HasLabel, out bool labelVal))
|
||||
{
|
||||
sprite.LayerSetVisible(BodyBagVisualLayers.Label, labelVal);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite.LayerSetVisible(BodyBagVisualLayers.Label, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum BodyBagVisualLayers : byte
|
||||
{
|
||||
Label,
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
using Content.Shared.Morgue;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Morgue.Visualizers
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public sealed class CrematoriumVisualizer : AppearanceVisualizer
|
||||
{
|
||||
[DataField("state_open")]
|
||||
private string _stateOpen = "";
|
||||
[DataField("state_closed")]
|
||||
private string _stateClosed = "";
|
||||
|
||||
[DataField("light_contents")]
|
||||
private string _lightContents = "";
|
||||
[DataField("light_burning")]
|
||||
private string _lightBurning = "";
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent(component.Owner, out ISpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (component.TryGetData(MorgueVisuals.Open, out bool open))
|
||||
{
|
||||
sprite.LayerSetState(CrematoriumVisualLayers.Base, open ? _stateOpen : _stateClosed);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite.LayerSetState(CrematoriumVisualLayers.Base, _stateClosed);
|
||||
}
|
||||
|
||||
var lightState = "";
|
||||
if (component.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents) lightState = _lightContents;
|
||||
if (component.TryGetData(CrematoriumVisuals.Burning, out bool isBurning) && isBurning) lightState = _lightBurning;
|
||||
|
||||
if (!string.IsNullOrEmpty(lightState))
|
||||
{
|
||||
sprite.LayerSetState(CrematoriumVisualLayers.Light, lightState);
|
||||
sprite.LayerSetVisible(CrematoriumVisualLayers.Light, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite.LayerSetVisible(CrematoriumVisualLayers.Light, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum CrematoriumVisualLayers : byte
|
||||
{
|
||||
Base,
|
||||
Light,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
using Content.Shared.Morgue;
|
||||
using Content.Shared.Storage;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.Morgue.Visualizers;
|
||||
|
||||
public sealed class CrematoriumVisualizerSystem : VisualizerSystem<CrematoriumVisualsComponent>
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
protected override void OnAppearanceChange(EntityUid uid, CrematoriumVisualsComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
if (args.Sprite == null)
|
||||
return;
|
||||
|
||||
string? lightState = null;
|
||||
if (args.Component.TryGetData(CrematoriumVisuals.Burning, out bool isBurning) && isBurning)
|
||||
lightState = component.LightBurning;
|
||||
else if (args.Component.TryGetData(StorageVisuals.HasContents, out bool hasContents) && hasContents)
|
||||
lightState = component.LightContents;
|
||||
|
||||
if (lightState != null)
|
||||
{
|
||||
args.Sprite.LayerSetState(CrematoriumVisualLayers.Light, lightState);
|
||||
args.Sprite.LayerSetVisible(CrematoriumVisualLayers.Light, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Sprite.LayerSetVisible(CrematoriumVisualLayers.Light, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
namespace Content.Client.Morgue.Visualizers;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed class CrematoriumVisualsComponent : Component
|
||||
{
|
||||
[DataField("lightContents", required: true)]
|
||||
public string LightContents = default!;
|
||||
[DataField("lightBurning", required: true)]
|
||||
public string LightBurning = default!;
|
||||
}
|
||||
|
||||
public enum CrematoriumVisualLayers : byte
|
||||
{
|
||||
Base,
|
||||
Light,
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
using Content.Shared.Morgue;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Morgue.Visualizers
|
||||
{
|
||||
public sealed class MorgueVisualizer : AppearanceVisualizer
|
||||
{
|
||||
[DataField("state_open")]
|
||||
private string _stateOpen = "";
|
||||
[DataField("state_closed")]
|
||||
private string _stateClosed = "";
|
||||
|
||||
[DataField("light_contents")]
|
||||
private string _lightContents = "";
|
||||
[DataField("light_mob")]
|
||||
private string _lightMob = "";
|
||||
[DataField("light_soul")]
|
||||
private string _lightSoul = "";
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent(component.Owner, out ISpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (component.TryGetData(MorgueVisuals.Open, out bool open))
|
||||
{
|
||||
sprite.LayerSetState(MorgueVisualLayers.Base, open ? _stateOpen : _stateClosed);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite.LayerSetState(MorgueVisualLayers.Base, _stateClosed);
|
||||
}
|
||||
|
||||
var lightState = "";
|
||||
if (component.TryGetData(MorgueVisuals.HasContents, out bool hasContents) && hasContents) lightState = _lightContents;
|
||||
if (component.TryGetData(MorgueVisuals.HasMob, out bool hasMob) && hasMob) lightState = _lightMob;
|
||||
if (component.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul) lightState = _lightSoul;
|
||||
|
||||
if (!string.IsNullOrEmpty(lightState))
|
||||
{
|
||||
sprite.LayerSetState(MorgueVisualLayers.Light, lightState);
|
||||
sprite.LayerSetVisible(MorgueVisualLayers.Light, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
sprite.LayerSetVisible(MorgueVisualLayers.Light, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public enum MorgueVisualLayers : byte
|
||||
{
|
||||
Base,
|
||||
Light,
|
||||
}
|
||||
}
|
||||
37
Content.Client/Morgue/Visualizers/MorgueVisualizerSystem.cs
Normal file
37
Content.Client/Morgue/Visualizers/MorgueVisualizerSystem.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using Content.Shared.Morgue;
|
||||
using Content.Shared.Storage;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.Morgue.Visualizers;
|
||||
|
||||
public sealed class MorgueVisualizerSystem : VisualizerSystem<MorgueVisualsComponent>
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
}
|
||||
|
||||
protected override void OnAppearanceChange(EntityUid uid, MorgueVisualsComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
if (args.Sprite == null)
|
||||
return;
|
||||
|
||||
string? lightState = null;
|
||||
if (args.Component.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul)
|
||||
lightState = component.LightSoul;
|
||||
else if (args.Component.TryGetData(MorgueVisuals.HasMob, out bool hasMob) && hasMob)
|
||||
lightState = component.LightMob;
|
||||
else if (args.Component.TryGetData(StorageVisuals.HasContents, out bool hasContents) && hasContents)
|
||||
lightState = component.LightContents;
|
||||
|
||||
if (lightState != null)
|
||||
{
|
||||
args.Sprite.LayerSetState(MorgueVisualLayers.Light, lightState);
|
||||
args.Sprite.LayerSetVisible(MorgueVisualLayers.Light, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
args.Sprite.LayerSetVisible(MorgueVisualLayers.Light, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
18
Content.Client/Morgue/Visualizers/MorgueVisualsComponent.cs
Normal file
18
Content.Client/Morgue/Visualizers/MorgueVisualsComponent.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
namespace Content.Client.Morgue.Visualizers;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed class MorgueVisualsComponent : Component
|
||||
{
|
||||
[DataField("lightContents", required: true)]
|
||||
public string LightContents = default!;
|
||||
[DataField("lightMob", required: true)]
|
||||
public string LightMob = default!;
|
||||
[DataField("lightSoul", required: true)]
|
||||
public string LightSoul = default!;
|
||||
}
|
||||
|
||||
public enum MorgueVisualLayers : byte
|
||||
{
|
||||
Base,
|
||||
Light,
|
||||
}
|
||||
@@ -15,6 +15,8 @@ namespace Content.Client.Storage.Visualizers
|
||||
/// </summary>
|
||||
[DataField("state")]
|
||||
private string? _stateBase;
|
||||
[DataField("state_alt")]
|
||||
private string? _stateBaseAlt;
|
||||
[DataField("state_open")]
|
||||
private string? _stateOpen;
|
||||
[DataField("state_closed")]
|
||||
@@ -31,6 +33,11 @@ namespace Content.Client.Storage.Visualizers
|
||||
{
|
||||
sprite.LayerSetState(0, _stateBase);
|
||||
}
|
||||
|
||||
if (_stateBaseAlt == null)
|
||||
{
|
||||
_stateBaseAlt = _stateBase;
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
@@ -49,13 +56,28 @@ namespace Content.Client.Storage.Visualizers
|
||||
{
|
||||
sprite.LayerSetVisible(StorageVisualLayers.Door, true);
|
||||
|
||||
if (open && _stateOpen != null)
|
||||
if (open)
|
||||
{
|
||||
sprite.LayerSetState(StorageVisualLayers.Door, _stateOpen);
|
||||
if (_stateOpen != null)
|
||||
{
|
||||
sprite.LayerSetState(StorageVisualLayers.Door, _stateOpen);
|
||||
sprite.LayerSetVisible(StorageVisualLayers.Door, true);
|
||||
}
|
||||
|
||||
if (_stateBaseAlt != null)
|
||||
sprite.LayerSetState(0, _stateBaseAlt);
|
||||
}
|
||||
else if (!open && _stateClosed != null)
|
||||
else if (!open)
|
||||
{
|
||||
sprite.LayerSetState(StorageVisualLayers.Door, _stateClosed);
|
||||
if (_stateClosed != null)
|
||||
sprite.LayerSetState(StorageVisualLayers.Door, _stateClosed);
|
||||
else
|
||||
{
|
||||
sprite.LayerSetVisible(StorageVisualLayers.Door, false);
|
||||
}
|
||||
|
||||
if (_stateBase != null)
|
||||
sprite.LayerSetState(0, _stateBase);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user