Esempio n. 1
0
 protected override void ExpandInternal(MyStateMachineCursor cursor, MyConcurrentHashSet <MyStringId> enquedActions, int passThrough)
 {
     foreach (var activeCursor in cursor.StateMachine.ActiveCursors)
     {
         cursor.StateMachine.DeleteCursor(activeCursor.Id);
     }
 }
        // Cache cursor data, remove cursor, let go when all incoming branch cursors reach the barrier node
        protected override void ExpandInternal(MyStateMachineCursor cursor, MyConcurrentHashSet <MyStringId> enquedActions, int passThrough)
        {
            var stateMachine      = cursor.StateMachine;
            var inTransitionIndex = 0;

            for (; inTransitionIndex < InTransitions.Count; inTransitionIndex++)
            {
                if (InTransitions[inTransitionIndex].Id == cursor.LastTransitionTakenId)
                {
                    break;
                }
            }

            Debug.Assert(inTransitionIndex < InTransitions.Count, "Transition not found.");
            Debug.Assert(!m_cursorsFromInEdgesReceived[inTransitionIndex], "More than one cursor from branch received.");

            m_cursorsFromInEdgesReceived[inTransitionIndex] = true;
            stateMachine.DeleteCursor(cursor.Id);

            // Check if all cursors arrived
            foreach (var value in m_cursorsFromInEdgesReceived)
            {
                if (!value)
                {
                    return;
                }
            }

            if (OutTransitions.Count > 0)
            {
                stateMachine.CreateCursor(OutTransitions[0].TargetNode.Name);
            }
        }
        protected override void ExpandInternal(MyStateMachineCursor cursor, MyConcurrentHashSet <MyStringId> enquedActions, int passThrough)
        {
            if (OutTransitions.Count == 0)
            {
                return;
            }

            var stateMachine = cursor.StateMachine;

            // Remove the current Cursor
            stateMachine.DeleteCursor(cursor.Id);

            // Spawn new cursors for the rest
            for (var i = 0; i < OutTransitions.Count; i++)
            {
                stateMachine.CreateCursor(OutTransitions[i].TargetNode.Name);
            }
        }