This repository has been archived on 2023-02-02. You can view files and clone it, but cannot push or open issues or pull requests.
mfgames-nitride-cil/src/Nitride.Temporal/FilterOutFutureInstant.cs
2022-07-09 01:56:23 -05:00

34 lines
761 B
C#

using System.Collections.Generic;
using Gallium;
using NodaTime;
namespace Nitride.Temporal;
/// <summary>
/// Filters out all entities that have an instant before the current
/// NitrideClock time.
/// </summary>
[WithProperties]
public partial class FilterOutFutureInstant : OperationBase
{
public FilterOutFutureInstant(Timekeeper timekeeper)
{
this.Timekeeper = timekeeper;
}
public Timekeeper Timekeeper { get; set; }
/// <inheritdoc />
public override IEnumerable<Entity> Run(IEnumerable<Entity> input)
{
Instant now = this.Timekeeper.Clock.GetCurrentInstant();
return input.WhereEntity<Instant>(
(
_,
instant) => instant.CompareTo(now) <= 0);
}
}