public InterpolatingStreamable(T start, T end, IStreamMoment startMoment, IStreamMoment endMoment)
 {
     m_Start       = start;
     m_End         = end;
     m_StartMoment = startMoment.PositionInStream;
     m_EndMoment   = endMoment.PositionInStream;
 }
Example #2
0
 public IVehicleSprite AtMoment(IStreamMoment moment)
 {
     return(new ConcreteVehicleSprite(
                CentrePoint.AtMoment(moment),
                Size,
                Heading.AtMoment(moment),
                Guid));
 }
        public T AtMoment(IStreamMoment moment)
        {
            var streamable = m_Streamables[moment.PositionInStream];

            if (streamable == null)
            {
                throw new ArgumentException("No streamable has been given for that stream moment");
            }
            return(streamable.AtMoment(moment));
        }
        public T AtMoment(IStreamMoment streamMoment)
        {
            var moment = streamMoment.PositionInStream;

            if (moment < m_StartMoment || m_EndMoment < moment)
            {
                throw new ArgumentOutOfRangeException(nameof(moment), moment, "Must be within start and end of range");
            }

            return(m_Start.Interpolate(m_End, (moment - m_StartMoment) / (m_EndMoment - m_StartMoment)));
        }
 public void AddSample(T item, IStreamMoment moment)
 {
     if (m_FirstSampleSeen)
     {
         if (moment.PositionInStream <= m_LastMoment.PositionInStream)
         {
             throw new ArgumentOutOfRangeException(nameof(moment), "Samples must be submitted in chronological order");
         }
         m_Streamable.Add(m_LastMoment, moment, new InterpolatingStreamable <T>(m_LastItem, item, m_LastMoment, moment));
     }
     m_LastItem        = item;
     m_LastMoment      = moment;
     m_FirstSampleSeen = true;
 }
Example #6
0
 public void RemoveAt(T item, IStreamMoment moment)
 {
     if (moment.PositionInStream < LatestLog)
     {
         throw new ArgumentOutOfRangeException(nameof(moment), "List must be accessed in chronological order");
     }
     m_Log.Add(new Log()
     {
         Time = moment.PositionInStream,
         Item = item,
         Type = Log.LogType.Remove
     });
     LatestLog = moment.PositionInStream;
 }
Example #7
0
        public IList <T> AtMoment(IStreamMoment moment)
        {
            var now     = moment.PositionInStream;
            var logs    = m_Log.TakeWhile(l => l.Time <= now).ToList();
            var added   = new List <Log>();
            var removed = new List <Log>();

            foreach (var log in logs)
            {
                if (log.Type == Log.LogType.Add)
                {
                    added.Add(log);
                }
                else
                {
                    removed.Add(log);
                }
            }
            var removedItems = removed.Select(l => l.Item).ToList();

            return(added.Select(l => l.Item).Except(removedItems).ToList());
        }
Example #8
0
 public void TakeSample(IStreamMoment moment)
 {
     CentrePoint.AddSample(m_Sprite.CentrePoint, moment);
     Heading.AddSample(m_Sprite.Heading, moment);
 }
 public T AtMoment(IStreamMoment moment)
 {
     return(m_Streamable.AtMoment(moment));
 }
 public void Add(IStreamMoment start, IStreamable <T> streamable)
 {
     m_Streamables.Add(start.PositionInStream, streamable);
 }
Example #11
0
 public T AtMoment(IStreamMoment moment)
 {
     return(m_Constant);
 }