2020-10-08 17:41:23 +02:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Content.Shared.Construction;
|
|
|
|
|
|
using JetBrains.Annotations;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Shared.GameObjects;
|
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]
|
2020-10-08 17:41:23 +02:00
|
|
|
|
public class EntityAnchored : IEdgeCondition
|
|
|
|
|
|
{
|
2021-03-05 01:08:38 +01:00
|
|
|
|
[DataField("anchored")] public bool Anchored { get; private set; } = true;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
|
|
|
|
|
|
public async Task<bool> Condition(IEntity entity)
|
|
|
|
|
|
{
|
2021-02-28 18:49:48 +01:00
|
|
|
|
if (!entity.TryGetComponent(out IPhysicsComponent physics)) return false;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
|
2021-02-28 18:49:48 +01:00
|
|
|
|
return physics.Anchored == Anchored;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
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-02-28 18:49:48 +01:00
|
|
|
|
if (!entity.TryGetComponent(out IPhysicsComponent physics)) return false;
|
2020-10-08 17:41:23 +02:00
|
|
|
|
|
2020-12-03 22:49:00 +01:00
|
|
|
|
switch (Anchored)
|
|
|
|
|
|
{
|
2021-02-28 18:49:48 +01:00
|
|
|
|
case true when !physics.Anchored:
|
2020-12-03 22:49:00 +01:00
|
|
|
|
message.AddMarkup("First, anchor it.\n");
|
|
|
|
|
|
return true;
|
2021-02-28 18:49:48 +01:00
|
|
|
|
case false when physics.Anchored:
|
2020-12-03 22:49:00 +01:00
|
|
|
|
message.AddMarkup("First, unanchor it.\n");
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|