Telecom server panel check (#14523)
This commit is contained in:
39
Content.Shared/Wires/SharedWiresSystem.cs
Normal file
39
Content.Shared/Wires/SharedWiresSystem.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using Content.Shared.Examine;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Wires;
|
||||
|
||||
public abstract class SharedWiresSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<WiresPanelComponent, ExaminedEvent>(OnExamine);
|
||||
SubscribeLocalEvent<WiresPanelComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<WiresPanelComponent, ComponentHandleState>(OnHandleState);
|
||||
}
|
||||
|
||||
private void OnExamine(EntityUid uid, WiresPanelComponent component, ExaminedEvent args)
|
||||
{
|
||||
args.PushMarkup(Loc.GetString(component.Open
|
||||
? "wires-panel-component-on-examine-open"
|
||||
: "wires-panel-component-on-examine-closed"));
|
||||
}
|
||||
|
||||
private void OnGetState(EntityUid uid, WiresPanelComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new WiresPanelComponentState
|
||||
{
|
||||
Open = component.Open,
|
||||
Visible = component.Visible
|
||||
};
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, WiresPanelComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not WiresPanelComponentState state)
|
||||
return;
|
||||
component.Open = state.Open;
|
||||
component.Visible = state.Visible;
|
||||
}
|
||||
}
|
||||
41
Content.Shared/Wires/WiresPanelComponent.cs
Normal file
41
Content.Shared/Wires/WiresPanelComponent.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Wires;
|
||||
|
||||
[NetworkedComponent, RegisterComponent]
|
||||
[Access(typeof(SharedWiresSystem))]
|
||||
public sealed class WiresPanelComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// Is the panel open for this entity's wires?
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public bool Open;
|
||||
|
||||
/// <summary>
|
||||
/// Should this entity's wires panel be visible at all?
|
||||
/// </summary>
|
||||
[ViewVariables]
|
||||
public bool Visible = true;
|
||||
|
||||
/// <summary>
|
||||
/// Marks if maintenance panel being open/closed by someone with a screwdriver.
|
||||
/// Prevents do after spam.
|
||||
/// </summary>
|
||||
public bool IsScrewing;
|
||||
|
||||
[DataField("screwdriverOpenSound")]
|
||||
public SoundSpecifier ScrewdriverOpenSound = new SoundPathSpecifier("/Audio/Machines/screwdriveropen.ogg");
|
||||
|
||||
[DataField("screwdriverCloseSound")]
|
||||
public SoundSpecifier ScrewdriverCloseSound = new SoundPathSpecifier("/Audio/Machines/screwdriverclose.ogg");
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class WiresPanelComponentState : ComponentState
|
||||
{
|
||||
public bool Open;
|
||||
public bool Visible;
|
||||
}
|
||||
Reference in New Issue
Block a user