Exemplo n.º 1
0
        private static void CalculateGroupID(Note note, CompiledNote compiledNote)
        {
            if (note.GroupID != EntityID.Invalid)
            {
                compiledNote.GroupID = note.GroupID;
            }
            else
            {
                int groupID;
                FlickGroupModificationResult result;
                Note groupStart;
                if (!note.TryGetFlickGroupID(out result, out groupID, out groupStart))
                {
                    // No need to set a group ID. E.g. the note is not a flick / slide note.
                    return;
                }
                switch (result)
                {
                case FlickGroupModificationResult.Reused:
                    note.GroupID = compiledNote.GroupID = groupID;
                    break;

                case FlickGroupModificationResult.CreationPending:
                    groupID            = FlickGroupIDGenerator.Next();
                    groupStart.GroupID = note.GroupID = compiledNote.GroupID = groupID;
                    break;
                }
            }
        }
Exemplo n.º 2
0
        public static void CompileTo(this Score score, CompiledScore compiledScore)
        {
            FlickGroupIDGenerator.Reset();
            var compiledNotes = compiledScore.Notes;

            compiledNotes.Clear();

            // Clear the GroupID caches.
            foreach (var bar in score.Bars)
            {
                foreach (var note in bar.Notes)
                {
                    note.GroupID = EntityID.Invalid;

                    var compiledNote = new CompiledNote();
                    SetCommonNoteProperties(note, compiledNote);
                    CalculateGroupID(note, compiledNote);
                    compiledNote.HitTiming = note.HitTiming;

                    compiledNotes.Add(compiledNote);
                }
            }

            // The normal gaming notes.
            var noteId = 3;

            foreach (var compiledNote in compiledNotes)
            {
                compiledNote.ID = noteId++;
            }

            // Special notes are added to their destined positions.
            var totalNoteCount = compiledNotes.Count;
            var scoreInfoNote  = new CompiledNote {
                ID        = 1,
                Type      = NoteType.NoteCount,
                FlickType = totalNoteCount
            };
            var songStartNote = new CompiledNote {
                ID   = 2,
                Type = NoteType.MusicStart
            };

            compiledNotes.Insert(0, scoreInfoNote);
            compiledNotes.Insert(1, songStartNote);

            double endTiming;

            if (score.Bars.Count > 0)
            {
                var lastBar = score.Bars.Last();
                endTiming = lastBar.StartTime + lastBar.TimeLength;
            }
            else
            {
                endTiming = 0;
            }
            var songEndNote = new CompiledNote {
                ID        = noteId,
                Type      = NoteType.MusicEnd,
                HitTiming = endTiming
            };

            compiledNotes.Add(songEndNote);
        }