示例#1
0
        /// <summary>
        /// Add a single preset event to the timeline.
        /// </summary>
        /// <param name="ev">
        /// A <see cref="TimedPresetEvent"/>.
        /// </param>
        /// <remarks>
        /// When adding multiple events, <see cref="TimedPresetBase.AddEvents"/>
        /// will be more efficient.
        /// </remarks>
        protected void AddEvent(TimedPresetEvent ev)
        {
            this.mTimeline.Add(ev);

            // TODO: Make this more efficient by inserting at the right place.
            this.mTimeline.Sort();
        }
示例#2
0
        private void SyncCurrent(IController controller)
        {
            if (this.mTimeline.Count <= this.mCurrentPosition)
            {
                // If the list isn't empty then something bad happened.
                if (this.mTimeline.Count != 0)
                {
                    throw new InvalidOperationException("Logic error -- this should not happen.");
                }

                return;
            }

            double position = controller.PlayerData.SongPosition;

            if (this.mCurrentPosition >= 0 && this.mTimeline[this.mCurrentPosition].Time > position)
            {
                this.mCurrentPosition = -1;
                this.mCurrentScene    = null;
            }

            while (this.mCurrentPosition + 1 < this.mTimeline.Count &&
                   this.mTimeline[this.mCurrentPosition + 1].Time <= position)
            {
                this.mCurrentPosition++;

                TimedPresetEvent ev = this.mTimeline[this.mCurrentPosition];

                switch (ev.Type)
                {
                case TimedPresetEventType.Scene:
                    this.mCurrentScene = ev.Callback;
                    break;

                case TimedPresetEventType.Event:
                    ev.Callback(controller);
                    break;
                }
            }
        }