using Content.Shared.Interaction;
using Robust.Server.GameObjects;
using Content.Shared.Wires;
+using Robust.Shared.Prototypes;
namespace Content.Server.Doors.Systems;
[Dependency] private readonly WiresSystem _wiresSystem = default!;
[Dependency] private readonly PowerReceiverSystem _power = default!;
[Dependency] private readonly DoorBoltSystem _bolts = default!;
+ [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
public override void Initialize()
{
private void OnActivate(EntityUid uid, AirlockComponent component, ActivateInWorldEvent args)
{
- if (TryComp<WiresPanelComponent>(uid, out var panel) && panel.Open && panel.WiresAccessible
- && TryComp<ActorComponent>(args.User, out var actor))
+ if (TryComp<WiresPanelComponent>(uid, out var panel) &&
+ panel.Open &&
+ _prototypeManager.TryIndex<WiresPanelSecurityLevelPrototype>(panel.CurrentSecurityLevelID, out var securityLevelPrototype) &&
+ securityLevelPrototype.WiresAccessible &&
+ TryComp<ActorComponent>(args.User, out var actor))
{
_wiresSystem.OpenUserInterface(uid, actor.PlayerSession);
args.Handled = true;
SubscribeLocalEvent<ActivatableUIRequiresPanelComponent, ActivatableUIOpenAttemptEvent>(OnAttemptOpenActivatableUI);
SubscribeLocalEvent<ActivatableUIRequiresPanelComponent, PanelChangedEvent>(OnActivatableUIPanelChanged);
}
-
private void SetOrCreateWireLayout(EntityUid uid, WiresComponent? wires = null)
{
if (!Resolve(uid, ref wires))
if (!TryComp<ToolComponent>(args.Used, out var tool) || !TryComp<WiresPanelComponent>(uid, out var panel))
return;
- if (panel.Open && panel.WiresAccessible &&
+ if (panel.Open &&
+ _protoMan.TryIndex<WiresPanelSecurityLevelPrototype>(panel.CurrentSecurityLevelID, out var securityLevelPrototype) &&
+ securityLevelPrototype.WiresAccessible &&
(_toolSystem.HasQuality(args.Used, "Cutting", tool) ||
_toolSystem.HasQuality(args.Used, "Pulsing", tool)))
{
{
component.Visible = visible;
UpdateAppearance(uid, component);
- Dirty(component);
+ Dirty(uid, component);
}
public void TogglePanel(EntityUid uid, WiresPanelComponent component, bool open)
{
component.Open = open;
UpdateAppearance(uid, component);
- Dirty(component);
+ Dirty(uid, component);
var ev = new PanelChangedEvent(component.Open);
RaiseLocalEvent(uid, ref ev);
public void SetWiresPanelSecurityData(EntityUid uid, WiresPanelComponent component, string wiresPanelSecurityLevelID)
{
- var wiresPanelSecurityLevelPrototype = _protoMan.Index<WiresPanelSecurityLevelPrototype>(wiresPanelSecurityLevelID);
-
- if (wiresPanelSecurityLevelPrototype == null)
- return;
-
- component.WiresAccessible = wiresPanelSecurityLevelPrototype.WiresAccessible;
- component.WiresPanelSecurityExamination = wiresPanelSecurityLevelPrototype.Examine;
- Dirty(component);
+ component.CurrentSecurityLevelID = wiresPanelSecurityLevelID;
+ Dirty(uid, component);
- if (wiresPanelSecurityLevelPrototype?.WiresAccessible == false)
+ if (_protoMan.TryIndex<WiresPanelSecurityLevelPrototype>(component.CurrentSecurityLevelID, out var securityLevelPrototype) &&
+ securityLevelPrototype.WiresAccessible)
{
_uiSystem.TryCloseAll(uid, WiresUiKey.Key);
}
private void OnInteractUsing(EntityUid uid, WeldableComponent component, InteractUsingEvent args)
{
- // If any construction graph edges has its conditions meet and requires welding, then this construction takes priority
- /* TODO: Whatever this is is not the way to do what you think you want to do.
- if (Enumerable.Any<ConstructionGraphEdge>(_construction.GetCurrentNode(uid)?.Edges, x => _construction.CheckConditions(uid, x.Conditions)
- && Enumerable.Any<ConstructionGraphStep>(x.Steps, y => (y as ToolConstructionGraphStep)?.Tool == "Welding")) == true)
- {
- args.Handled = false;
- return;
- }
- */
-
if (args.Handled)
return;
using Content.Shared.Examine;
+using Content.Shared.Tools.Systems;
+using Robust.Shared.Prototypes;
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)
{
args.PushMarkup(Loc.GetString("wires-panel-component-on-examine-open"));
- if (component?.WiresPanelSecurityExamination != null)
+ if (_prototypeManager.TryIndex<WiresPanelSecurityLevelPrototype>(component.CurrentSecurityLevelID, out var securityLevelPrototype) &&
+ securityLevelPrototype.Examine != null)
{
- args.PushMarkup(Loc.GetString(component.WiresPanelSecurityExamination));
+ args.PushMarkup(Loc.GetString(securityLevelPrototype.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();
+ }
+ }
}
[DataField("screwdriverCloseSound")]
public SoundSpecifier ScrewdriverCloseSound = new SoundPathSpecifier("/Audio/Machines/screwdriverclose.ogg");
+ /// <summary>
+ /// This prototype describes the current security features of the wire panel
+ /// </summary>
+ [DataField("securityLevel")]
+ [ValidatePrototypeId<WiresPanelSecurityLevelPrototype>]
[AutoNetworkedField]
- public string? WiresPanelSecurityExamination = default!;
-
- [AutoNetworkedField]
- public bool WiresAccessible = true;
+ public string CurrentSecurityLevelID = "Level0";
}
/// <summary>
[IdDataField]
public string ID { get; private set; } = default!;
+ /// <summary>
+ /// A verbal description of the wire panel's current security level
+ /// </summary>
[DataField("examine")]
public string? Examine = default!;
+ /// <summary>
+ /// Determines whether the wiring is accessible to hackers or not
+ /// </summary>
[DataField("wiresAccessible")]
public bool WiresAccessible = true;
+
+ /// <summary>
+ /// Determines whether the device can be welded shut or not
+ /// </summary>
+ /// <remarks>
+ /// Should be set false when you need to weld/unweld something to/from the wire panel
+ /// </remarks>
+ [DataField("weldingAllowed")]
+ public bool WeldingAllowed = true;
}
components:
- type: Sprite
sprite: Structures/Doors/Airlocks/Standard/atmospherics.rsi
+ - type: WiresPanel
+ securityLevel: Level2
- type: Construction
node: airlockMedSecurity
components:
- type: Sprite
sprite: Structures/Doors/Airlocks/Standard/command.rsi
+ - type: WiresPanel
+ securityLevel: Level5
- type: Construction
node: airlockMaxSecurity
components:
- type: Sprite
sprite: Structures/Doors/Airlocks/Standard/security.rsi
+ - type: WiresPanel
+ securityLevel: Level2
- type: Construction
node: airlockMedSecurity
sprite: Structures/Doors/Airlocks/Glass/atmospherics.rsi
- type: PaintableAirlock
group: Glass
+ - type: WiresPanel
+ securityLevel: Level2
- type: Construction
node: glassAirlockMedSecurity
sprite: Structures/Doors/Airlocks/Glass/command.rsi
- type: PaintableAirlock
group: Glass
+ - type: WiresPanel
+ securityLevel: Level5
- type: Construction
node: glassAirlockMaxSecurity
sprite: Structures/Doors/Airlocks/Glass/security.rsi
- type: PaintableAirlock
group: Glass
+ - type: WiresPanel
+ securityLevel: Level2
- type: Construction
node: glassAirlockMedSecurity
id: Level1
examine: wires-panel-component-on-examine-security-level1
wiresAccessible: false
+ weldingAllowed: false
- type: WiresPanelSecurityLevel
id: Level2
examine: wires-panel-component-on-examine-security-level2
wiresAccessible: false
+ weldingAllowed: false
- type: WiresPanelSecurityLevel
id: Level3
examine: wires-panel-component-on-examine-security-level3
wiresAccessible: false
+ weldingAllowed: false
- type: WiresPanelSecurityLevel
id: Level4
examine: wires-panel-component-on-examine-security-level4
wiresAccessible: false
+ weldingAllowed: false
- type: WiresPanelSecurityLevel
id: Level5
id: Level6
examine: wires-panel-component-on-examine-security-level6
wiresAccessible: false
+ weldingAllowed: false
- type: WiresPanelSecurityLevel
id: Level7
examine: wires-panel-component-on-examine-security-level7
wiresAccessible: false
+ weldingAllowed: false
\ No newline at end of file