Example #1
0
        private void MarkPassedObjects()
        {
            // Call OnObjectLeft on all passed objects
            // Also handle addition/removal of active objects
            for (int i = 0; i < objectsInView.Count;)
            {
                double startingPosition = GetObjectGroupStartingPosition(objectsInView[i]);
                double endingPosition   = GetObjectGroupEndingPosition(objectsInView[i]);
                if (endingPosition < position)
                {
                    if (ActiveObjects.Contains(objectsInView[i]))
                    {
                        objectsToDeactivate.Add(objectsInView[i]);
                    }
                    else
                    {
                        // This should be single hit object
                        objectsToActivate.Add(objectsInView[i]);
                        objectsToDeactivate.Add(objectsInView[i]);
                    }

                    OnObjectLeft(objectsInView[i]);
                    objectsInView.RemoveAt(i);
                }
                else
                {
                    // Use actual starting postion
                    startingPosition = objectsInView[i].AbsolutePosition;

                    // Handle new active objects
                    if (startingPosition < position)
                    {
                        if (!activeObjects.Contains(objectsInView[i]))
                        {
                            objectsToActivate.Add(objectsInView[i]);
                        }
                    }

                    i++;
                }
            }

            // Call OnMeasureLeft on all passed measures
            for (int i = 0; i < measuresInView.Count;)
            {
                var measureEnd = measuresInView[i].AbsolutePosition + measuresInView[i].TimingPoint.MeasureDuration;
                if (measureEnd < position ||
                    measuresInView[i].AbsolutePosition > endPosition)
                {
                    OnMeasureLeft(measuresInView[i]);
                    measuresInView.RemoveAt(i);
                }
                else
                {
                    i++;
                }
            }
        }