CatStation/Content.Shared/EntityTable/Conditions/EmptyContainerCondition.cs
Fildrance ec01361c4e
Bind type of EntityTableContext keys to expected values (#46214)
* refactor: EntityTableContext methods now use strongly typed keys, which are bound to type of value you want to extract from context.

* refactor: remove unused attributes

* refactor: extracted EntityTableContext into separate file, fixed xml-doc
2026-09-30 03:04:19 +00:00

30 lines
942 B
C#

using Content.Shared.EntityTable.EntitySelectors;
using Robust.Shared.Containers;
using Robust.Shared.Prototypes;
namespace Content.Shared.EntityTable.Conditions;
/// <summary>
/// Condition that passes when a container has nothing in it.
/// </summary>
public sealed partial class EmptyContainerCondition : EntityTableCondition
{
/// <summary>
/// Key for <see cref="EntityTableContext"/> to store container that should be checked by this condition.
/// </summary>
public static readonly EntityTableContextKey<BaseContainer> ContainerContextKey = new("Container");
/// <inheritdoc/>>
protected override bool EvaluateImplementation(
EntityTableSelector root,
IEntityManager entMan,
IPrototypeManager proto,
EntityTableContext ctx
)
{
if (!ctx.TryGetData(ContainerContextKey, out var container))
return false;
return container.Count == 0;
}
}