/// <summary>
        /// Flush specified transformations, using the last available values (ignoring current clock time).
        /// </summary>
        /// <param name="propagateChildren">Whether we also flush down the child tree.</param>
        /// <param name="flushType">An optional type of transform to flush. Null for all types.</param>
        public virtual void Flush(bool propagateChildren = false, Type flushType = null)
        {
            var operateTransforms = flushType == null ? Transforms : Transforms.FindAll(t => t.GetType() == flushType);

            double maxTime = double.MinValue;

            foreach (ITransform t in operateTransforms)
            {
                if (t.EndTime > maxTime)
                {
                    maxTime = t.EndTime;
                }
            }

            FrameTimeInfo maxTimeInfo = new FrameTimeInfo {
                Current = maxTime
            };

            foreach (ITransform t in operateTransforms)
            {
                t.UpdateTime(maxTimeInfo);
                t.Apply(this);
            }

            if (flushType == null)
            {
                ClearTransformations();
            }
            else
            {
                Transforms.RemoveAll(t => t.GetType() == flushType);
            }
        }
Beispiel #2
0
            public override bool Update(FrameTimeInfo time)
            {
                bool anyAliveChanged = false;

                //check existing items to make sure they haven't died.
                foreach (var item in AliveItems.ToArray())
                {
                    item.UpdateTime(time);
                    if (!item.IsAlive)
                    {
                        //todo: make this more efficient
                        int i = IndexOf(item);
                        anyAliveChanged |= CheckItem(item, ref i);
                    }
                }

                //handle custom range
                for (int i = StartIndex; i < EndIndex; i++)
                {
                    var item = this[i];
                    item.UpdateTime(time);
                    anyAliveChanged |= CheckItem(item, ref i);
                }

                return(anyAliveChanged);
            }
Beispiel #3
0
        /// <summary>
        /// Updates the life status of this LifetimeList's children.
        /// </summary>
        /// <returns>Whether any alive states were changed.</returns>
        public virtual bool Update(FrameTimeInfo time)
        {
            bool anyAliveChanged = false;

            for (int i = 0; i < Count; i++)
            {
                var item = this[i];
                item.UpdateTime(time);
                anyAliveChanged |= CheckItem(item, ref i);
            }

            return(anyAliveChanged);
        }
Beispiel #4
0
        /// <summary>
        /// Updates the life status of this LifetimeList's children.
        /// </summary>
        /// <returns>Whether any alive states were changed.</returns>
        public bool Update(FrameTimeInfo time)
        {
            bool anyAliveChanged = false;

            for (int i = 0; i < Count; i++)
            {
                var item = this[i];

                item.UpdateTime(time);

                if (item.IsAlive)
                {
                    if (!current[i])
                    {
                        LoadRequested?.Invoke(item);
                        if (item.IsLoaded)
                        {
                            AliveItems.Add(item);
                            current[i]      = true;
                            anyAliveChanged = true;
                        }
                    }
                }
                else
                {
                    if (current[i])
                    {
                        AliveItems.Remove(item);
                        current[i]      = false;
                        anyAliveChanged = true;
                    }

                    if (item.RemoveWhenNotAlive)
                    {
                        RemoveAt(i--);
                        Removed?.Invoke(item);
                    }
                }
            }

            return(anyAliveChanged);
        }
Beispiel #5
0
 public void UpdateTime(FrameTimeInfo time)
 {
     this.time = time;
 }
Beispiel #6
0
 public void UpdateTime(FrameTimeInfo time)
 {
 }