Use construction graphs for hacking protections (#20265)

This commit is contained in:
chromiumboy
2023-10-05 22:15:03 -05:00
committed by GitHub
parent 8eeedb2427
commit acc9c8940b
20 changed files with 363 additions and 581 deletions

View File

@@ -1,27 +0,0 @@
using Content.Server.Wires;
using Content.Shared.Construction;
using Content.Shared.Wires;
using JetBrains.Annotations;
namespace Content.Server.Construction.Completions;
[UsedImplicitly]
[DataDefinition]
public sealed partial class ChangeWiresPanelSecurityLevel : IGraphAction
{
[DataField("level")]
[ValidatePrototypeId<WiresPanelSecurityLevelPrototype>]
public string WiresPanelSecurityLevelID = "Level0";
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
{
if (WiresPanelSecurityLevelID == null)
return;
if (entityManager.TryGetComponent(uid, out WiresPanelComponent? wiresPanel)
&& entityManager.TrySystem(out WiresSystem? wiresSystem))
{
wiresSystem.SetWiresPanelSecurityData(uid, wiresPanel, WiresPanelSecurityLevelID);
}
}
}

View File

@@ -0,0 +1,35 @@
using Content.Shared.Construction;
using Content.Shared.Wires;
using JetBrains.Annotations;
namespace Content.Server.Construction.Completions;
/// <summary>
/// This graph action is used to set values on entities with the <see cref="WiresPanelSecurityComponent"/>
/// </summary>
[UsedImplicitly]
[DataDefinition]
public sealed partial class SetWiresPanelSecurity : IGraphAction
{
/// <summary>
/// Sets the Examine field on the entity's <see cref="WiresPanelSecurityComponent"/>
/// </summary>
[DataField("examine")]
public string Examine = string.Empty;
/// <summary>
/// Sets the WiresAccessible field on the entity's <see cref="WiresPanelSecurityComponent"/>
/// </summary>
[DataField("wiresAccessible")]
public bool WiresAccessible = true;
public void PerformAction(EntityUid uid, EntityUid? userUid, IEntityManager entityManager)
{
if (entityManager.TryGetComponent(uid, out WiresPanelSecurityComponent? _))
{
var ev = new WiresPanelSecurityEvent(Examine, WiresAccessible);
entityManager.EventBus.RaiseLocalEvent(uid, ev);
}
}
}