Exemplo n.º 1
0
        /// <summary>
        /// Sets the beatmap to use for source data
        /// </summary>
        protected void SetBeatmap(Beatmap beatmap)
        {
            // Reset state when beatmap is changed
            if (this.beatmap != beatmap)
            {
                this.beatmap = beatmap;
                foreach (var obj in objectsInView)
                {
                    OnObjectLeft(obj);
                }
                foreach (var obj in activeObjects)
                {
                    OnObjectDeactivated(obj);
                }

                objectsInView.Clear();
                allMeasures.Clear();
                currentMeasure = null;
                HasEnded       = true;
                LastObject     = null;
                FirstObject    = null;

                // Stop here when beatmap is cleared
                if (this.beatmap == null)
                {
                    return;
                }

                beatmap.UpdateMap();
            }

            UpdateView();

            allMeasures.Clear();
            foreach (var timingPoint in this.beatmap.TimingPoints)
            {
                allMeasures.AddRange(timingPoint.Measures);
            }

            // Find first object
            FirstObject = null;
            foreach (var measure in allMeasures)
            {
                foreach (var obj in measure.Objects)
                {
                    // TODO: Ignore events
                    FirstObject = new ObjectReference(obj, measure);
                    break;
                }

                if (FirstObject != null)
                {
                    break;
                }
            }

            // Find last object
            LastObject = null;
            for (int m = allMeasures.Count - 1; m >= 0; m--)
            {
                var measure = allMeasures[m];
                for (int o = measure.Objects.Count - 1; o >= 0; o--)
                {
                    var obj = measure.Objects[o];

                    // TODO: Ignore events
                    LastObject = new ObjectReference(obj, measure);
                    break;
                }

                if (LastObject != null)
                {
                    break;
                }
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Call this to notify that the current beamap's contents were changed
 /// </summary>
 public void OnBeatmapModified()
 {
     beatmap        = null;
     currentMeasure = null; // Invalidate cached measure
     SetBeatmap(beatmap);
 }