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));
            }
        }
Ejemplo n.º 2
0
 private void GenerateActionWikiHtml()
 {
     if (!Files.CreateFilePath(this.htmlSavePath))
     {
         return;
     }
     this.GenerateActionCategoriesWikiHtml();
     if (this.selectedCategory > 0)
     {
         this.selectedCategoryName = Actions.Categories.get_Item(this.selectedCategory - 1);
     }
     this.actionIndex = 0;
     while (this.actionIndex < Actions.List.get_Count())
     {
         EditorUtility.DisplayProgressBar("Saving Action Wiki Html...", "Press Escape to cancel", (float)this.actionIndex / (float)Actions.List.get_Count());
         if (Event.get_current().get_keyCode() == 27)
         {
             return;
         }
         if (this.selectedCategory > 0 && Actions.CategoryLookup.get_Item(this.actionIndex) != this.selectedCategoryName)
         {
             this.actionIndex++;
         }
         else
         {
             Type         type         = Actions.List.get_Item(this.actionIndex);
             string       text         = Labels.StripNamespace(type.ToString());
             string       text2        = Path.Combine(this.htmlSavePath, text);
             string       fullPath     = Path.GetFullPath(Application.get_dataPath() + "/../" + text2 + ".txt");
             StreamWriter streamWriter = File.CreateText(fullPath);
             streamWriter.WriteLine("<div id=\"actionImg\"><p><img src=\"" + this.imagesUrl + text + ".png\" title=\"\" /></p></div>");
             string text3 = Actions.GetTooltip(type);
             if (string.IsNullOrEmpty(text3))
             {
                 text3 = "TODO";
             }
             streamWriter.WriteLine("<div id=\"actionDesc\">\n<p>");
             streamWriter.WriteLine(text3 + "</p>\n</div>");
             FieldInfo[] fields = ActionData.GetFields(type);
             FieldInfo[] array  = fields;
             for (int i = 0; i < array.Length; i++)
             {
                 FieldInfo fieldInfo = array[i];
                 string    text4     = Actions.GetTooltip(fieldInfo);
                 if (string.IsNullOrEmpty(text4))
                 {
                     text4 = "TODO";
                 }
                 streamWriter.WriteLine("<div id=\"paramRow\">");
                 streamWriter.WriteLine("\t<div id=\"paramName\">");
                 streamWriter.WriteLine(ObjectNames.NicifyVariableName(fieldInfo.get_Name()) + "</div>");
                 streamWriter.WriteLine("\t<div id=\"paramDesc\">");
                 streamWriter.WriteLine(text4 + "</div>");
                 streamWriter.WriteLine("</div>");
                 streamWriter.WriteLine("");
             }
             streamWriter.Close();
             this.actionIndex++;
         }
     }
     EditorUtility.ClearProgressBar();
 }