Files
tbd-station-14/Content.Server/Construction/Conditions/StorageWelded.cs
deltanedas 58812c6ae7 fix weldable (#19878)
Co-authored-by: deltanedas <@deltanedas:kde.org>
2023-09-06 14:18:11 -04:00

54 lines
1.8 KiB
C#

using Content.Server.Storage.Components;
using Content.Shared.Construction;
using Content.Shared.Examine;
using Content.Shared.Tools.Systems;
using JetBrains.Annotations;
namespace Content.Server.Construction.Conditions
{
[UsedImplicitly]
[DataDefinition]
public sealed partial class StorageWelded : IGraphCondition
{
[DataField("welded")]
public bool Welded { get; private set; } = true;
public bool Condition(EntityUid uid, IEntityManager entityManager)
{
return entityManager.System<WeldableSystem>().IsWelded(uid) == Welded;
}
public bool DoExamine(ExaminedEvent args)
{
var entMan = IoCManager.Resolve<IEntityManager>();
var entity = args.Examined;
if (!entMan.HasComponent<EntityStorageComponent>(entity))
return false;
var metaData = entMan.GetComponent<MetaDataComponent>(entity);
if (entMan.System<WeldableSystem>().IsWelded(entity) != Welded)
{
if (Welded)
args.PushMarkup(Loc.GetString("construction-examine-condition-door-weld", ("entityName", metaData.EntityName)) + "\n");
else
args.PushMarkup(Loc.GetString("construction-examine-condition-door-unweld", ("entityName", metaData.EntityName)) + "\n");
return true;
}
return false;
}
public IEnumerable<ConstructionGuideEntry> GenerateGuideEntry()
{
yield return new ConstructionGuideEntry()
{
Localization = Welded
? "construction-guide-condition-door-weld"
: "construction-guide-condition-door-unweld",
};
}
}
}