示例#1
0
    public void Progress(float timeStep)
    {
        EventBase nodeEvent      = null;
        EventBase nodelessEvent  = null;
        bool      eventConcluded = false;

        if (currentNodeEvents != null)
        {
            /*halmeida - since currentNodeEvents is just a subset of eventComponents, it
             * means all of its elements are not null, for they were already validated during
             * the Awake().*/
            for (int i = 0; i < currentNodeEvents.Length; i++)
            {
                nodeEvent = currentNodeEvents[i];
                if (!nodeEvent.IsConcluded())
                {
                    nodeEvent.Progress(timeStep);
                    if (nodeEvent.IsConcluded())
                    {
                        eventConcluded = true;
                    }
                }
            }
        }
        if (eventsWithoutNode != null)
        {
            /*halmeida - since eventsWithoutNode is just a subset of eventComponents, it
             * means all of its elements are not null, for they were already validated during
             * the Awake().*/
            for (int i = 0; i < eventsWithoutNode.Length; i++)
            {
                nodelessEvent = eventsWithoutNode[i];
                if (!nodelessEvent.IsConcluded())
                {
                    nodelessEvent.Progress(timeStep);
                    if (nodelessEvent.IsConcluded())
                    {
                        eventConcluded = true;
                    }
                }
            }
        }
        if (eventConcluded)

        /*halmeida - when an event is concluded, it may have made it possible for
         * other events to trigger themselves. Furthermore, an event that is triggered
         * might be immediately concluded if it, for example, takes no time. Since we
         * cannot tell how much of the time of this processing (how much of the timeStep
         * interval) was spent for the event to conclude, it would be very incorrect to
         * just repeat the Progress call with the same timeStep. So, to allow at least
         * the immediate events to trigger and conclude themselves, we repeat the Progress
         * call with zero timeStep.*/
        {
            if (currentNodeEvents != null)
            {
                for (int i = 0; i < currentNodeEvents.Length; i++)
                {
                    nodeEvent = currentNodeEvents[i];
                    if (!nodeEvent.IsConcluded())
                    {
                        nodeEvent.ExtractInterests(stageComponent);
                        nodeEvent.Trigger(eventComponents, currentNodeID);
                    }
                }
            }
            if (eventsWithoutNode != null)
            {
                for (int i = 0; i < eventsWithoutNode.Length; i++)
                {
                    nodelessEvent = eventsWithoutNode[i];
                    if (!nodelessEvent.IsConcluded())
                    {
                        nodelessEvent.ExtractInterests(stageComponent);
                        nodelessEvent.Trigger(eventComponents, currentNodeID);
                    }
                }
            }
            Progress(0f);
        }
    }