Remove string appearance keys (#10114)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using Content.Shared.Atmos.Monitor;
|
||||
using Content.Shared.Power;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -40,7 +41,7 @@ namespace Content.Client.Atmos.Monitor
|
||||
if (!sprite.LayerMapTryGet(_layerMap, out int layer))
|
||||
return;
|
||||
|
||||
if (component.TryGetData<bool>("powered", out var powered))
|
||||
if (component.TryGetData<bool>(PowerDeviceVisuals.Powered, out var powered))
|
||||
{
|
||||
if (_hideOnDepowered != null)
|
||||
foreach (var visLayer in _hideOnDepowered)
|
||||
@@ -53,12 +54,12 @@ namespace Content.Client.Atmos.Monitor
|
||||
sprite.LayerSetState(setStateLayer, new RSI.StateId(state));
|
||||
}
|
||||
|
||||
if (component.TryGetData<Vector2>("offset", out Vector2 offset))
|
||||
if (component.TryGetData<Vector2>(AtmosMonitorVisuals.Offset, out Vector2 offset))
|
||||
{
|
||||
sprite.Offset = offset;
|
||||
}
|
||||
|
||||
if (component.TryGetData<AtmosMonitorAlarmType>("alarmType", out var alarmType)
|
||||
if (component.TryGetData<AtmosMonitorAlarmType>(AtmosMonitorVisuals.AlarmType, out var alarmType)
|
||||
&& powered)
|
||||
if (_alarmStates.TryGetValue(alarmType, out var state))
|
||||
sprite.LayerSetState(layer, new RSI.StateId(state));
|
||||
|
||||
@@ -82,7 +82,7 @@ namespace Content.Client.Damage
|
||||
/// completely invisible.
|
||||
/// </remarks>
|
||||
[DataField("targetLayers")]
|
||||
private List<string>? _targetLayers;
|
||||
private List<Enum>? _targetLayers;
|
||||
|
||||
/// <summary>
|
||||
/// The actual sprites for every damage group
|
||||
@@ -383,18 +383,8 @@ namespace Content.Client.Damage
|
||||
//
|
||||
// If the layer doesn't have a base state, or
|
||||
// the layer key just doesn't exist, we skip it.
|
||||
foreach (var keyString in _targetLayers)
|
||||
foreach (var key in _targetLayers)
|
||||
{
|
||||
object key;
|
||||
if (IoCManager.Resolve<IReflectionManager>().TryParseEnumReference(keyString, out var @enum))
|
||||
{
|
||||
key = @enum;
|
||||
}
|
||||
else
|
||||
{
|
||||
key = keyString;
|
||||
}
|
||||
|
||||
if (!spriteComponent.LayerMapTryGet(key, out int index)
|
||||
|| spriteComponent.LayerGetState(index).ToString() == null)
|
||||
{
|
||||
@@ -562,20 +552,11 @@ namespace Content.Client.Damage
|
||||
/// </summary>
|
||||
private void UpdateDisabledLayers(SpriteComponent spriteComponent, AppearanceComponent component, DamageVisualizerDataComponent damageData)
|
||||
{
|
||||
foreach (object layer in damageData.TargetLayerMapKeys)
|
||||
foreach (var layer in damageData.TargetLayerMapKeys)
|
||||
{
|
||||
bool? layerStatus = null;
|
||||
switch (layer)
|
||||
{
|
||||
case Enum layerEnum:
|
||||
if (component.TryGetData<bool>(layerEnum, out var layerStateEnum))
|
||||
layerStatus = layerStateEnum;
|
||||
break;
|
||||
case string layerString:
|
||||
if (component.TryGetData<bool>(layerString, out var layerStateString))
|
||||
layerStatus = layerStateString;
|
||||
break;
|
||||
}
|
||||
if (component.TryGetData<bool>(layer, out var layerStateEnum))
|
||||
layerStatus = layerStateEnum;
|
||||
|
||||
if (layerStatus == null)
|
||||
continue;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Content.Client.Damage
|
||||
[RegisterComponent]
|
||||
public sealed class DamageVisualizerDataComponent : Component
|
||||
{
|
||||
public List<object> TargetLayerMapKeys = new();
|
||||
public List<Enum> TargetLayerMapKeys = new();
|
||||
public bool Disabled = false;
|
||||
public bool Valid = true;
|
||||
public FixedPoint2 LastDamageThreshold = FixedPoint2.Zero;
|
||||
|
||||
@@ -2,6 +2,7 @@ using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
using static Content.Shared.Foldable.SharedFoldableSystem;
|
||||
|
||||
namespace Content.Client.Visualizer;
|
||||
|
||||
@@ -19,7 +20,7 @@ public sealed class FoldableVisualizer : AppearanceVisualizer
|
||||
|
||||
if (!entManager.TryGetComponent(appearance.Owner, out SpriteComponent? sprite)) return;
|
||||
|
||||
if (appearance.TryGetData("FoldedState", out bool folded) && folded)
|
||||
if (appearance.TryGetData(FoldedVisuals.State, out bool folded) && folded)
|
||||
{
|
||||
sprite.LayerSetState(FoldableVisualLayers.Base, $"{_key}_folded");
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using JetBrains.Annotations;
|
||||
using Content.Shared.Buckle.Components;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -20,7 +21,7 @@ namespace Content.Client.Visualizer
|
||||
|
||||
if (!entManager.TryGetComponent(appearance.Owner, out SpriteComponent? sprite)) return;
|
||||
|
||||
if (appearance.TryGetData("StrapState", out bool strapped) && strapped)
|
||||
if (appearance.TryGetData(StrapVisuals.State, out bool strapped) && strapped)
|
||||
{
|
||||
sprite.LayerSetState(0, $"{_key}_buckled");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user