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