Add multipart machines system (#35969)
This commit is contained in:
@@ -268,6 +268,7 @@ public sealed class PASegmentControl : Control
|
||||
private RSI? _rsi;
|
||||
|
||||
public string BaseState { get; set; } = "control_box";
|
||||
public bool DefaultVisible { get; set; } = false;
|
||||
|
||||
public PASegmentControl()
|
||||
{
|
||||
@@ -283,12 +284,14 @@ public sealed class PASegmentControl : Control
|
||||
_rsi = IoCManager.Resolve<IResourceCache>().GetResource<RSIResource>($"/Textures/Structures/Power/Generation/PA/{BaseState}.rsi").RSI;
|
||||
MinSize = _rsi.Size;
|
||||
_base.Texture = _rsi["completed"].Frame0;
|
||||
|
||||
SetVisible(DefaultVisible);
|
||||
_unlit.Visible = DefaultVisible;
|
||||
}
|
||||
|
||||
public void SetPowerState(ParticleAcceleratorUIState state, bool exists)
|
||||
{
|
||||
_base.ShaderOverride = exists ? null : _greyScaleShader;
|
||||
_base.ModulateSelfOverride = exists ? null : new Color(127, 127, 127);
|
||||
SetVisible(exists);
|
||||
|
||||
if (!state.Enabled || !exists)
|
||||
{
|
||||
@@ -319,4 +322,23 @@ public sealed class PASegmentControl : Control
|
||||
|
||||
_unlit.Texture = rState.Frame0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds/Removes the shading to the part in the control menu based on the
|
||||
/// input state.
|
||||
/// </summary>
|
||||
/// <param name="state">True if the part exists, false otherwise</param>
|
||||
private void SetVisible(bool state)
|
||||
{
|
||||
if (state)
|
||||
{
|
||||
_base.ShaderOverride = null;
|
||||
_base.ModulateSelfOverride = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
_base.ShaderOverride = _greyScaleShader;
|
||||
_base.ModulateSelfOverride = new Color(127, 127, 127);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user