2021-06-21 02:13:54 +02:00
|
|
|
using System.Threading.Tasks;
|
2020-10-08 17:41:23 +02:00
|
|
|
using Content.Server.GameObjects.Components;
|
2021-07-04 18:11:52 +02:00
|
|
|
using Content.Server.WireHacking;
|
2020-10-08 17:41:23 +02:00
|
|
|
using Content.Shared.Construction;
|
|
|
|
|
using JetBrains.Annotations;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2020-10-08 17:41:23 +02:00
|
|
|
using Robust.Shared.Localization;
|
2021-03-05 01:08:38 +01:00
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2020-10-08 17:41:23 +02:00
|
|
|
using Robust.Shared.Utility;
|
|
|
|
|
|
|
|
|
|
namespace Content.Server.Construction.Conditions
|
|
|
|
|
{
|
|
|
|
|
[UsedImplicitly]
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataDefinition]
|
2021-03-25 18:59:16 +01:00
|
|
|
public class WirePanel : IGraphCondition
|
2020-10-08 17:41:23 +02:00
|
|
|
{
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("open")] public bool Open { get; private set; } = true;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
|
|
|
|
public async Task<bool> Condition(IEntity entity)
|
|
|
|
|
{
|
2021-03-16 15:50:20 +01:00
|
|
|
if (!entity.TryGetComponent(out WiresComponent? wires)) return false;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
|
|
|
|
return wires.IsPanelOpen == Open;
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-03 22:49:00 +01:00
|
|
|
public bool DoExamine(IEntity entity, FormattedMessage message, bool inDetailsRange)
|
2020-10-08 17:41:23 +02:00
|
|
|
{
|
2021-03-16 15:50:20 +01:00
|
|
|
if (!entity.TryGetComponent(out WiresComponent? wires)) return false;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
2020-12-03 22:49:00 +01:00
|
|
|
switch (Open)
|
|
|
|
|
{
|
|
|
|
|
case true when !wires.IsPanelOpen:
|
2021-06-21 02:13:54 +02:00
|
|
|
message.AddMarkup(Loc.GetString("construction-condition-wire-panel-open") + "\n");
|
2020-12-03 22:49:00 +01:00
|
|
|
return true;
|
|
|
|
|
case false when wires.IsPanelOpen:
|
2021-06-21 02:13:54 +02:00
|
|
|
message.AddMarkup(Loc.GetString("construction-condition-wire-panel-close") + "\n");
|
2020-12-03 22:49:00 +01:00
|
|
|
return true;
|
|
|
|
|
}
|
2020-10-08 17:41:23 +02:00
|
|
|
|
2020-12-03 22:49:00 +01:00
|
|
|
return false;
|
2020-10-08 17:41:23 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|