mirror of
https://github.com/corvax-team/ss14-wl.git
synced 2026-02-14 19:29:57 +01:00
Fix possible bug in my fix of IFF console. Add documentation to HideOnInit. (#42122)
* Refactor OnIFFShow and OnInitIFFConsole by extracting AddAllSupportedIFFFlags method. Fix possible addition of unallowed flags. Fix posible addition of unallowed flags in OnInitIFFConsole by performing AllowedFlags check in the extracted function. * Add documentation to HideOnInit * Update IFFConsoleComponent.cs --------- Co-authored-by: SlamBamActionman <83650252+SlamBamActionman@users.noreply.github.com>
This commit is contained in:
@@ -12,6 +12,9 @@ public sealed partial class IFFConsoleComponent : Component
|
||||
[ViewVariables(VVAccess.ReadWrite), DataField("allowedFlags")]
|
||||
public IFFFlags AllowedFlags = IFFFlags.HideLabel;
|
||||
|
||||
/// <summary>
|
||||
/// If true, automatically applies all supported IFF flags to the console's grid on MapInitEvent.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool HideOnInit = false;
|
||||
}
|
||||
|
||||
@@ -42,28 +42,14 @@ public sealed partial class ShuttleSystem
|
||||
return;
|
||||
}
|
||||
|
||||
// Merged toggle controls both HideLabel and Hide flags
|
||||
if (!args.Show)
|
||||
{
|
||||
if ((component.AllowedFlags & IFFFlags.HideLabel) != 0x0)
|
||||
{
|
||||
AddIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
|
||||
}
|
||||
if ((component.AllowedFlags & IFFFlags.Hide) != 0x0)
|
||||
{
|
||||
AddIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
|
||||
}
|
||||
AddAllSupportedIFFFlags(xform, component);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((component.AllowedFlags & IFFFlags.HideLabel) != 0x0)
|
||||
{
|
||||
RemoveIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
|
||||
}
|
||||
if ((component.AllowedFlags & IFFFlags.Hide) != 0x0)
|
||||
{
|
||||
RemoveIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
|
||||
}
|
||||
RemoveIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
|
||||
RemoveIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,8 +62,7 @@ public sealed partial class ShuttleSystem
|
||||
|
||||
if (component.HideOnInit)
|
||||
{
|
||||
AddIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
|
||||
AddIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
|
||||
AddAllSupportedIFFFlags(xform, component);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -121,4 +106,25 @@ public sealed partial class ShuttleSystem
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Made this method to avoid copy and pasting.
|
||||
/// <summary>
|
||||
/// Adds all IFF flags that are allowed by AllowedFlags to the grid.
|
||||
/// </summary>
|
||||
private void AddAllSupportedIFFFlags(TransformComponent xform, IFFConsoleComponent component)
|
||||
{
|
||||
if (xform.GridUid == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ((component.AllowedFlags & IFFFlags.HideLabel) != 0x0)
|
||||
{
|
||||
AddIFFFlag(xform.GridUid.Value, IFFFlags.HideLabel);
|
||||
}
|
||||
if ((component.AllowedFlags & IFFFlags.Hide) != 0x0)
|
||||
{
|
||||
AddIFFFlag(xform.GridUid.Value, IFFFlags.Hide);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user