Beispiel #1
0
    public void PrepareNodelessEvents()
    {
        EventBase nodelessEvent = null;

        if ((stageComponent != null) && (eventsWithoutNode != null))
        {
            for (int i = 0; i < eventsWithoutNode.Length; i++)
            {
                nodelessEvent = eventsWithoutNode[i];
                if (!nodelessEvent.IsConcluded())
                {
                    nodelessEvent.ExtractInterests(stageComponent);
                    nodelessEvent.Trigger(eventComponents, GraphNode.NODE_ID_INVALID);
                }

                /*
                 * if( nodelessEvent.IsTriggered() )
                 * {
                 *      Debug.Log("Debug : EventManager : EVENT "+nodelessEvent.eventID+" IS TRIGGERED, NODE ID "+currentNodeID+".");
                 * }
                 * if( nodelessEvent.IsConcluded() )
                 * {
                 *      Debug.Log("Debug : EventManager : EVENT "+nodelessEvent.eventID+" WAS ALREADY CONCLUDED.");
                 * }
                 */
            }
        }
    }
Beispiel #2
0
    public void PrepareNodeEvents(int loadedNodeID)
    {
        EventBase nodeEvent = null;

        currentNodeID     = GraphNode.NODE_ID_INVALID;
        currentNodeEvents = null;
        if ((stageComponent != null) && (eventsPerNode != null))
        {
            /*halmeida - if eventsPerNode is not null, it means eventNodeIDs is also not null and
             * both have the same length.*/
            currentNodeID = loadedNodeID;
            for (int i = 0; i < eventNodeIDs.Length; i++)
            {
                if (eventNodeIDs[i] == currentNodeID)
                {
                    currentNodeEvents = eventsPerNode[i];
                    if (currentNodeEvents != null)
                    {
                        for (int j = 0; j < currentNodeEvents.Length; j++)
                        {
                            nodeEvent = currentNodeEvents[j];
                            if (!nodeEvent.IsConcluded())
                            {
                                nodeEvent.ExtractInterests(stageComponent);
                                nodeEvent.Trigger(eventComponents, currentNodeID);
                            }

                            /*
                             * if( nodeEvent.IsTriggered() )
                             * {
                             *      Debug.Log("Debug : EventManager : EVENT "+nodeEvent.eventID+" IS TRIGGERED, NODE ID "+currentNodeID+".");
                             * }
                             * if( nodeEvent.IsConcluded() )
                             * {
                             *      Debug.Log("Debug : EventManager : EVENT "+nodeEvent.eventID+" WAS ALREADY CONCLUDED.");
                             * }
                             */
                        }
                    }
                    break;
                }
            }
        }
    }
Beispiel #3
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);
        }
    }