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

@@ -6,14 +6,11 @@ namespace Content.Shared.Wires;
public abstract class SharedWiresSystem : EntitySystem
{
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<WiresPanelComponent, ExaminedEvent>(OnExamine);
SubscribeLocalEvent<WiresPanelComponent, WeldableAttemptEvent>(OnWeldableAttempt);
}
private void OnExamine(EntityUid uid, WiresPanelComponent component, ExaminedEvent args)
@@ -26,21 +23,11 @@ public abstract class SharedWiresSystem : EntitySystem
{
args.PushMarkup(Loc.GetString("wires-panel-component-on-examine-open"));
if (_prototypeManager.TryIndex<WiresPanelSecurityLevelPrototype>(component.CurrentSecurityLevelID, out var securityLevelPrototype) &&
securityLevelPrototype.Examine != null)
if (TryComp<WiresPanelSecurityComponent>(uid, out var wiresPanelSecurity) &&
wiresPanelSecurity.Examine != null)
{
args.PushMarkup(Loc.GetString(securityLevelPrototype.Examine));
args.PushMarkup(Loc.GetString(wiresPanelSecurity.Examine));
}
}
}
private void OnWeldableAttempt(EntityUid uid, WiresPanelComponent component, WeldableAttemptEvent args)
{
if (component.Open &&
_prototypeManager.TryIndex<WiresPanelSecurityLevelPrototype>(component.CurrentSecurityLevelID, out var securityLevelPrototype) &&
!securityLevelPrototype.WeldingAllowed)
{
args.Cancel();
}
}
}