コード例 #1
0
        private static void CheckSystemEventsForErrors(SkillState state, SkillTransition transition, SkillEvent fsmEvent)
        {
            GameObject gameObject = state.get_Fsm().get_GameObject();

            if (gameObject == null)
            {
                return;
            }
            if (FsmEditorSettings.CheckForMouseEventErrors && fsmEvent.get_Name().Contains("MOUSE") && gameObject.GetComponent <Collider>() == null && gameObject.GetComponent <GUIElement>() == null)
            {
                FsmErrorChecker.AddError(state, transition, Strings.get_FsmErrorChecker_MouseEventsNeedCollider());
            }
            if ((FsmEditorSettings.CheckForCollisionEventErrors && fsmEvent.get_Name().Contains("COLLISION")) || fsmEvent.get_Name().Contains("TRIGGER"))
            {
                if (fsmEvent.get_Name().Contains("2D"))
                {
                    if (gameObject.GetComponent <Collider2D>() == null && gameObject.GetComponent <Rigidbody2D>() == null)
                    {
                        FsmErrorChecker.AddError(state, transition, Strings.get_FsmErrorChecker_CollisionEventsNeedCollider2D());
                    }
                }
                else
                {
                    if (gameObject.GetComponent <Collider>() == null && gameObject.GetComponent <Rigidbody>() == null)
                    {
                        FsmErrorChecker.AddError(state, transition, Strings.get_FsmErrorChecker_CollisionEventsNeedCollider());
                    }
                }
            }
            if (FsmEditorSettings.CheckForCollisionEventErrors && fsmEvent.get_Name().Contains("CONTROLLER COLLIDER") && gameObject.GetComponent <CharacterController>() == null)
            {
                FsmErrorChecker.AddError(state, transition, Strings.get_FsmErrorChecker_ControllerCollisionEventsNeedController());
            }
        }
コード例 #2
0
        private static FsmError AddRequiredFieldError()
        {
            FsmError fsmError = FsmErrorChecker.AddError(FsmErrorChecker.checkingState, FsmErrorChecker.checkingAction, FsmErrorChecker.checkingParameter, Strings.get_FsmErrorChecker_RequiredFieldError());

            fsmError.Type = FsmError.ErrorType.requiredField;
            return(fsmError);
        }
コード例 #3
0
        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);
                    }
                }
            }
        }
コード例 #4
0
        public static FsmError AddRuntimeError(string error)
        {
            FsmError error2 = new FsmError
            {
                Fsm          = SkillExecutionStack.get_ExecutingFsm(),
                State        = SkillExecutionStack.get_ExecutingState(),
                Action       = SkillExecutionStack.get_ExecutingAction(),
                ErrorString  = error,
                RuntimeError = true
            };

            return(FsmErrorChecker.AddError(error2));
        }
コード例 #5
0
 private static void CheckActionReportForErrors()
 {
     using (List <ActionReport> .Enumerator enumerator = ActionReport.ActionReportList.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             ActionReport current = enumerator.get_Current();
             if (current.isError && current.actionIndex < current.state.get_Actions().Length)
             {
                 FsmErrorChecker.AddError(current.state, current.state.get_Actions()[current.actionIndex], current.parameter, current.logText);
             }
         }
     }
 }
コード例 #6
0
 private static FsmError AddParameterError(string error)
 {
     return(FsmErrorChecker.AddError(FsmErrorChecker.checkingState, FsmErrorChecker.checkingAction, FsmErrorChecker.checkingParameter, error));
 }
コード例 #7
0
 private static FsmError AddError(SkillState state, SkillTransition transition, string error)
 {
     return(FsmErrorChecker.AddError(new FsmError(state, transition, error)));
 }
コード例 #8
0
 private static FsmError AddError(SkillState state, SkillStateAction action, string parameter, string error)
 {
     return(FsmErrorChecker.AddError(new FsmError(state, action, parameter, error)));
 }
コード例 #9
0
        private static void CheckActionForErrors(SkillState state, SkillStateAction action)
        {
            if (action == null)
            {
                FsmErrorChecker.AddError(new FsmError(state, null, Strings.get_FsmErrorChecker_MissingActionError()));
                return;
            }
            action.Init(state);
            FsmErrorChecker.fsmEventTargetContext = null;
            string actionLabel = Labels.GetActionLabel(action);

            if (FsmEditorSettings.CheckForMissingActions && action is MissingAction)
            {
                FsmErrorChecker.AddError(new FsmError(state, action, Strings.get_FsmErrorChecker_StateHasMissingActionError()));
                return;
            }
            if (FsmEditorSettings.CheckForObsoleteActions)
            {
                string obsoleteMessage = CustomAttributeHelpers.GetObsoleteMessage(action.GetType());
                if (!string.IsNullOrEmpty(obsoleteMessage))
                {
                    FsmErrorChecker.AddError(new FsmError(state, action, obsoleteMessage));
                }
            }
            Type type = action.GetType();

            FieldInfo[] fields = ActionData.GetFields(type);
            FieldInfo[] array  = fields;
            for (int i = 0; i < array.Length; i++)
            {
                FieldInfo fieldInfo = array[i];
                Type      fieldType = fieldInfo.get_FieldType();
                object    value     = fieldInfo.GetValue(action);
                if (fieldType == typeof(SkillEventTarget))
                {
                    SkillEventTarget fsmEventTarget = (SkillEventTarget)value;
                    if (actionLabel == "Set Event Target")
                    {
                        FsmErrorChecker.fsmEventTargetContextGlobal = fsmEventTarget;
                    }
                    else
                    {
                        FsmErrorChecker.fsmEventTargetContext = fsmEventTarget;
                    }
                }
                FsmErrorChecker.CheckActionParameter(state, action, fieldInfo);
            }
            string text = "";

            try
            {
                text = action.ErrorCheck();
            }
            catch (Exception ex)
            {
                Debug.Log(string.Concat(new object[]
                {
                    "Bad ErrorCheck: ",
                    type,
                    "\n",
                    ex
                }));
            }
            if (!string.IsNullOrEmpty(text))
            {
                FsmErrorChecker.AddError(new FsmError(state, action, text));
            }
        }