Replace SpriteStateChange construction action with AppearanceChange (#15914)

This commit is contained in:
Leon Friedrich
2023-04-30 09:04:31 +12:00
committed by GitHub
parent fe3ebd0157
commit b45bc4ae4a
58 changed files with 293 additions and 287 deletions

View File

@@ -10,7 +10,10 @@ public sealed class ParticleAcceleratorPartVisualizerSystem : VisualizerSystem<P
{
if (args.Sprite == null)
return;
if (!args.Sprite.LayerMapTryGet(ParticleAcceleratorVisualLayers.Unlit, out var index))
return;
if (!AppearanceSystem.TryGetData<ParticleAcceleratorVisualState>(uid, ParticleAcceleratorVisuals.VisualState, out var state, args.Component))
{
state = ParticleAcceleratorVisualState.Unpowered;
@@ -18,12 +21,12 @@ public sealed class ParticleAcceleratorPartVisualizerSystem : VisualizerSystem<P
if (state != ParticleAcceleratorVisualState.Unpowered)
{
args.Sprite.LayerSetVisible(ParticleAcceleratorVisualLayers.Unlit, true);
args.Sprite.LayerSetState(ParticleAcceleratorVisualLayers.Unlit, comp.StateBase + comp.StatesSuffixes[state]);
args.Sprite.LayerSetVisible(index, true);
args.Sprite.LayerSetState(index, comp.StateBase + comp.StatesSuffixes[state]);
}
else
{
args.Sprite.LayerSetVisible(ParticleAcceleratorVisualLayers.Unlit, false);
args.Sprite.LayerSetVisible(index, false);
}
}
}

View File

@@ -259,17 +259,17 @@ namespace Content.Client.ParticleAccelerator.UI
Children =
{
new Control {MinSize = imgSize},
(_endCapTexture = Segment("end_cap", "capc")),
(_endCapTexture = Segment("end_cap")),
new Control {MinSize = imgSize},
(_controlBoxTexture = Segment("control_box", "boxc")),
(_fuelChamberTexture = Segment("fuel_chamber", "chamberc")),
(_controlBoxTexture = Segment("control_box")),
(_fuelChamberTexture = Segment("fuel_chamber")),
new Control {MinSize = imgSize},
new Control {MinSize = imgSize},
(_powerBoxTexture = Segment("power_box", "boxc")),
(_powerBoxTexture = Segment("power_box")),
new Control {MinSize = imgSize},
(_emitterLeftTexture = Segment("emitter_left", "leftc")),
(_emitterCenterTexture = Segment("emitter_center", "centerc")),
(_emitterRightTexture = Segment("emitter_right", "rightc")),
(_emitterLeftTexture = Segment("emitter_left")),
(_emitterCenterTexture = Segment("emitter_center")),
(_emitterRightTexture = Segment("emitter_right")),
}
}
}
@@ -326,9 +326,9 @@ namespace Content.Client.ParticleAccelerator.UI
}
};
PASegmentControl Segment(string name, string state)
PASegmentControl Segment(string name)
{
return new(this, resourceCache, name, state);
return new(this, resourceCache, name);
}
UpdateUI(false, false, false, false);
@@ -470,13 +470,13 @@ namespace Content.Client.ParticleAccelerator.UI
private readonly TextureRect _unlit;
private readonly RSI _rsi;
public PASegmentControl(ParticleAcceleratorControlMenu menu, IResourceCache cache, string name, string state)
public PASegmentControl(ParticleAcceleratorControlMenu menu, IResourceCache cache, string name)
{
_menu = menu;
_baseState = name;
_rsi = cache.GetResource<RSIResource>($"/Textures/Structures/Power/Generation/PA/{name}.rsi").RSI;
AddChild(_base = new TextureRect {Texture = _rsi[$"{state}"].Frame0});
AddChild(_base = new TextureRect {Texture = _rsi[$"completed"].Frame0});
AddChild(_unlit = new TextureRect());
MinSize = _rsi.Size;
}