private static void CheckTransitionsForErrors(SkillState state)
        {
            List <string> list = new List <string>();

            SkillTransition[] transitions = state.get_Transitions();
            for (int i = 0; i < transitions.Length; i++)
            {
                SkillTransition fsmTransition = transitions[i];
                if (FsmEditorSettings.CheckForTransitionMissingEvent && string.IsNullOrEmpty(fsmTransition.get_EventName()))
                {
                    FsmErrorChecker.AddError(state, fsmTransition, Strings.get_FsmErrorChecker_TransitionMissingEventError());
                }
                if (FsmEditorSettings.CheckForDuplicateTransitionEvent && list.Contains(fsmTransition.get_EventName()))
                {
                    FsmErrorChecker.AddError(state, fsmTransition, Strings.get_FsmErrorChecker_DuplicateTransitionEventError());
                }
                if (!string.IsNullOrEmpty(fsmTransition.get_EventName()))
                {
                    list.Add(fsmTransition.get_EventName());
                }
                if (FsmEditorSettings.CheckForTransitionMissingTarget && string.IsNullOrEmpty(fsmTransition.get_ToState()))
                {
                    FsmErrorChecker.AddError(state, fsmTransition, Strings.get_FsmErrorChecker_TransitionMissingTargetError());
                }
                if (state.get_Fsm() != null)
                {
                    SkillEvent fsmEvent = fsmTransition.get_FsmEvent();
                    if (fsmEvent != null && fsmEvent.get_IsSystemEvent())
                    {
                        FsmErrorChecker.CheckSystemEventsForErrors(state, fsmTransition, fsmEvent);
                    }
                }
            }
        }
Пример #2
0
 public static bool FsmRespondsToEvent(Skill fsm, string fsmEventName)
 {
     if (fsm == null || string.IsNullOrEmpty(fsmEventName))
     {
         return(false);
     }
     SkillTransition[] globalTransitions = fsm.get_GlobalTransitions();
     for (int i = 0; i < globalTransitions.Length; i++)
     {
         SkillTransition fsmTransition = globalTransitions[i];
         if (fsmTransition.get_EventName() == fsmEventName)
         {
             bool result = true;
             return(result);
         }
     }
     SkillState[] states = fsm.get_States();
     for (int j = 0; j < states.Length; j++)
     {
         SkillState        fsmState    = states[j];
         SkillTransition[] transitions = fsmState.get_Transitions();
         for (int k = 0; k < transitions.Length; k++)
         {
             SkillTransition fsmTransition2 = transitions[k];
             if (fsmTransition2.get_EventName() == fsmEventName)
             {
                 bool result = true;
                 return(result);
             }
         }
     }
     return(false);
 }
Пример #3
0
 public static bool FsmStateRespondsToEvent(SkillState state, SkillEvent fsmEvent)
 {
     if (SkillEvent.IsNullOrEmpty(fsmEvent))
     {
         return(false);
     }
     SkillTransition[] globalTransitions = state.get_Fsm().get_GlobalTransitions();
     for (int i = 0; i < globalTransitions.Length; i++)
     {
         SkillTransition fsmTransition = globalTransitions[i];
         if (fsmTransition.get_EventName() == fsmEvent.get_Name())
         {
             bool result = true;
             return(result);
         }
     }
     SkillTransition[] transitions = state.get_Transitions();
     for (int j = 0; j < transitions.Length; j++)
     {
         SkillTransition fsmTransition2 = transitions[j];
         if (fsmTransition2.get_EventName() == fsmEvent.get_Name())
         {
             bool result = true;
             return(result);
         }
     }
     return(false);
 }
Пример #4
0
 private void FindEventUsage(SkillState state)
 {
     SkillTransition[] transitions = state.get_Transitions();
     for (int i = 0; i < transitions.Length; i++)
     {
         SkillTransition fsmTransition = transitions[i];
         if (fsmTransition.get_EventName() != string.Empty)
         {
             this.GetEventUsageList(fsmTransition.get_EventName()).Add(new SkillInfo
             {
                 fsm        = this.fsm,
                 state      = state,
                 transition = fsmTransition
             });
         }
     }
 }
Пример #5
0
 private void FindEventsInGlobalTransitions()
 {
     if (this.fsm == null)
     {
         return;
     }
     SkillTransition[] globalTransitions = this.fsm.get_GlobalTransitions();
     for (int i = 0; i < globalTransitions.Length; i++)
     {
         SkillTransition fsmTransition = globalTransitions[i];
         if (fsmTransition.get_EventName() != string.Empty)
         {
             this.GetEventUsageList(fsmTransition.get_EventName()).Add(new SkillInfo
             {
                 fsm        = this.fsm,
                 state      = this.fsm.GetState(fsmTransition.get_ToState()),
                 transition = fsmTransition
             });
         }
     }
 }
Пример #6
0
        public static List <SkillInfo> FindTransitionsUsingEvent(Skill fsm, string eventName)
        {
            List <SkillInfo> list = new List <SkillInfo>();

            SkillState[] states = fsm.get_States();
            for (int i = 0; i < states.Length; i++)
            {
                SkillState        fsmState    = states[i];
                SkillTransition[] transitions = fsmState.get_Transitions();
                for (int j = 0; j < transitions.Length; j++)
                {
                    SkillTransition fsmTransition = transitions[j];
                    if (fsmTransition.get_EventName() == eventName)
                    {
                        list.Add(new SkillInfo
                        {
                            fsm        = fsm,
                            state      = fsmState,
                            transition = fsmTransition
                        });
                    }
                }
            }
            SkillTransition[] globalTransitions = fsm.get_GlobalTransitions();
            for (int k = 0; k < globalTransitions.Length; k++)
            {
                SkillTransition fsmTransition2 = globalTransitions[k];
                if (fsmTransition2.get_EventName() == eventName)
                {
                    list.Add(new SkillInfo
                    {
                        fsm        = fsm,
                        state      = fsm.GetState(fsmTransition2.get_ToState()),
                        transition = fsmTransition2
                    });
                }
            }
            return(list);
        }