Data-oriented Construction System (#2152)
- Powerful - Data-oriented - Approved by PJB - Powered by node graphs and AI pathfinding - Coded by the same nerd who brought you atmos Co-authored-by: Exp <theexp111@gmail.com>
This commit is contained in:
committed by
GitHub
parent
a6647e8de1
commit
745401a41e
41
Content.Server/Construction/Conditions/ContainerEmpty.cs
Normal file
41
Content.Server/Construction/Conditions/ContainerEmpty.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
#nullable enable
|
||||
using System.Threading.Tasks;
|
||||
using Content.Shared.Construction;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Server.GameObjects.Components.Container;
|
||||
using Robust.Shared.Interfaces.GameObjects;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Server.Construction.Conditions
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class ContainerEmpty : IEdgeCondition
|
||||
{
|
||||
public string Container { get; private set; } = string.Empty;
|
||||
public string Text { get; private set; } = string.Empty;
|
||||
|
||||
public void ExposeData(ObjectSerializer serializer)
|
||||
{
|
||||
serializer.DataField(this, x => x.Container, "container", string.Empty);
|
||||
serializer.DataField(this, x => x.Text, "text", string.Empty);
|
||||
}
|
||||
|
||||
public async Task<bool> Condition(IEntity entity)
|
||||
{
|
||||
if (!entity.TryGetComponent(out ContainerManagerComponent? containerManager) ||
|
||||
!containerManager.TryGetContainer(Container, out var container)) return true;
|
||||
|
||||
return container.ContainedEntities.Count == 0;
|
||||
}
|
||||
|
||||
public void DoExamine(IEntity entity, FormattedMessage message, bool inDetailsRange)
|
||||
{
|
||||
if (!entity.TryGetComponent(out ContainerManagerComponent? containerManager) ||
|
||||
!containerManager.TryGetContainer(Container, out var container)) return;
|
||||
|
||||
if (container.ContainedEntities.Count != 0)
|
||||
message.AddMarkup(Text);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user