mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-10 10:51:14 +03:00
* surprisingly easy * touchup * comment * refactor: cleanup ContainerFillSystem.OnTableMapInit, more xml-doc for EmptyContainerCondition * tested --------- Co-authored-by: iaada <iaada@users.noreply.github.com> Co-authored-by: Fildrance <fildrance@gmail.com>
30 lines
912 B
C#
30 lines
912 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 const string ContainerContextKey = "Container";
|
|
|
|
/// <inheritdoc/>>
|
|
protected override bool EvaluateImplementation(
|
|
EntityTableSelector root,
|
|
IEntityManager entMan,
|
|
IPrototypeManager proto,
|
|
EntityTableContext ctx
|
|
)
|
|
{
|
|
if (!ctx.TryGetData<BaseContainer>(ContainerContextKey, out var container))
|
|
return false;
|
|
|
|
return container.Count == 0;
|
|
}
|
|
}
|