Files
OldThink/Content.Server/Construction/Conditions/DoorWelded.cs
ShadowCommander 51178b9ae7 Airlock construction (#3609)
* Add construction and deconstsruction of airlocks

* Change name to door electronics

* Rearrange things

* Fix errors

* Fix physics error from bumping

* Prevent editing the map for now

* Address reviews

* Change switch to if

* Fix newlines
2021-03-17 13:07:49 +01:00

45 lines
1.5 KiB
C#

#nullable enable
using System.Threading.Tasks;
using Content.Server.GameObjects.Components.Doors;
using Content.Shared.Construction;
using JetBrains.Annotations;
using Robust.Shared.GameObjects;
using Robust.Shared.Localization;
using Robust.Shared.Serialization.Manager.Attributes;
using Robust.Shared.Utility;
using static Content.Shared.GameObjects.Components.Doors.SharedDoorComponent;
namespace Content.Server.Construction.Conditions
{
[UsedImplicitly]
[DataDefinition]
public class DoorWelded : IEdgeCondition
{
[DataField("welded")]
public bool Welded { get; private set; } = true;
public async Task<bool> Condition(IEntity entity)
{
if (!entity.TryGetComponent(out ServerDoorComponent? doorComponent)) return false;
return doorComponent.IsWeldedShut == Welded;
}
public bool DoExamine(IEntity entity, FormattedMessage message, bool inDetailsRange)
{
if (!entity.TryGetComponent(out ServerDoorComponent? door)) return false;
if (door.IsWeldedShut != Welded)
{
if (Welded == true)
message.AddMarkup(Loc.GetString("construction-condition-door-weld", ("entityName", entity.Name)) + "\n");
else
message.AddMarkup(Loc.GetString("construction-condition-door-unweld", ("entityName", entity.Name)) + "\n");
return true;
}
return false;
}
}
}