コード例 #1
0
 // Token: 0x0600017A RID: 378 RVA: 0x0000CFAC File Offset: 0x0000B1AC
 private static void CheckTaskForErrors(Task task, bool projectLevelBehavior, ref List <ErrorDetails> errorDetails)
 {
     if (task.Disabled)
     {
         return;
     }
     if (task is UnknownTask || task is UnknownParentTask)
     {
         ErrorCheck.AddError(ref errorDetails, ErrorDetails.ErrorType.UnknownTask, task, -1, null);
     }
     if (task.GetType().GetCustomAttributes(typeof(SkipErrorCheckAttribute), false).Length == 0)
     {
         FieldInfo[] allFields = TaskUtility.GetAllFields(task.GetType());
         for (int i = 0; i < allFields.Length; i++)
         {
             ErrorCheck.CheckField(task, projectLevelBehavior, ref errorDetails, allFields[i], i, allFields[i].GetValue(task));
         }
     }
     if (task is ParentTask && task.NodeData.NodeDesigner != null && !(task.NodeData.NodeDesigner as NodeDesigner).IsEntryDisplay)
     {
         ParentTask parentTask = task as ParentTask;
         if (parentTask.Children == null || parentTask.Children.Count == 0)
         {
             ErrorCheck.AddError(ref errorDetails, ErrorDetails.ErrorType.MissingChildren, task, -1, null);
         }
         else
         {
             for (int j = 0; j < parentTask.Children.Count; j++)
             {
                 ErrorCheck.CheckTaskForErrors(parentTask.Children[j], projectLevelBehavior, ref errorDetails);
             }
         }
     }
 }
コード例 #2
0
        // Token: 0x06000179 RID: 377 RVA: 0x0000CEA8 File Offset: 0x0000B0A8
        public static List <ErrorDetails> CheckForErrors(BehaviorSource behaviorSource)
        {
            if (behaviorSource == null || behaviorSource.EntryTask == null)
            {
                return(null);
            }
            List <ErrorDetails> result = null;
            bool flag = AssetDatabase.GetAssetPath(behaviorSource.Owner.GetObject()).Length > 0;

            ErrorCheck.CheckTaskForErrors(behaviorSource.EntryTask, flag, ref result);
            if (behaviorSource.RootTask == null)
            {
                ErrorCheck.AddError(ref result, ErrorDetails.ErrorType.MissingChildren, behaviorSource.EntryTask, -1, null);
            }
            if (behaviorSource.RootTask != null)
            {
                ErrorCheck.CheckTaskForErrors(behaviorSource.RootTask, flag, ref result);
            }
            if (!EditorApplication.isPlaying && flag && behaviorSource.Variables != null)
            {
                for (int i = 0; i < behaviorSource.Variables.Count; i++)
                {
                    object value = behaviorSource.Variables[i].GetValue();
                    if (value is Object && AssetDatabase.GetAssetPath(value as Object).Length == 0)
                    {
                        ErrorCheck.AddError(ref result, ErrorDetails.ErrorType.InvalidVariableReference, null, i, behaviorSource.Variables[i].Name);
                    }
                }
            }
            return(result);
        }
コード例 #3
0
 private static void CheckTaskForErrors(Task task, ref List <ErrorDetails> errorDetails)
 {
     if (task.NodeData.Disabled)
     {
         return;
     }
     if (task is UnknownTask || task is UnknownParentTask)
     {
         ErrorCheck.AddError(ref errorDetails, ErrorDetails.ErrorType.UnknownTask, task, null);
     }
     if (task.GetType().GetCustomAttributes(typeof(SkipErrorCheckAttribute), false).Length == 0)
     {
         FieldInfo[] allFields = TaskUtility.GetAllFields(task.GetType());
         for (int i = 0; i < allFields.Length; i++)
         {
             FieldInfo fieldInfo = allFields[i];
             object    value     = fieldInfo.GetValue(task);
             if (TaskUtility.HasAttribute(fieldInfo, typeof(RequiredFieldAttribute)) && !ErrorCheck.IsRequiredFieldValid(fieldInfo.FieldType, value))
             {
                 ErrorCheck.AddError(ref errorDetails, ErrorDetails.ErrorType.RequiredField, task, fieldInfo.Name);
             }
             if (fieldInfo.FieldType.Equals(typeof(SharedVariable)) || fieldInfo.FieldType.IsSubclassOf(typeof(SharedVariable)))
             {
                 SharedVariable sharedVariable = value as SharedVariable;
                 if (sharedVariable != null && sharedVariable.IsShared && string.IsNullOrEmpty(sharedVariable.Name) && !TaskUtility.HasAttribute(fieldInfo, typeof(SharedRequiredAttribute)))
                 {
                     ErrorCheck.AddError(ref errorDetails, ErrorDetails.ErrorType.SharedVariable, task, fieldInfo.Name);
                 }
             }
         }
     }
     if (task is ParentTask && task.NodeData.NodeDesigner != null && !(task.NodeData.NodeDesigner as NodeDesigner).IsEntryDisplay)
     {
         ParentTask parentTask = task as ParentTask;
         if (parentTask.Children == null || parentTask.Children.Count == 0)
         {
             ErrorCheck.AddError(ref errorDetails, ErrorDetails.ErrorType.MissingChildren, task, null);
         }
         else
         {
             for (int j = 0; j < parentTask.Children.Count; j++)
             {
                 ErrorCheck.CheckTaskForErrors(parentTask.Children[j], ref errorDetails);
             }
         }
     }
 }
コード例 #4
0
        public static List <ErrorDetails> CheckForErrors(BehaviorSource behaviorSource)
        {
            if (behaviorSource == null || behaviorSource.EntryTask == null)
            {
                return(null);
            }
            List <ErrorDetails> result = null;

            ErrorCheck.CheckTaskForErrors(behaviorSource.EntryTask, ref result);
            if (behaviorSource.RootTask == null)
            {
                ErrorCheck.AddError(ref result, ErrorDetails.ErrorType.MissingChildren, behaviorSource.EntryTask, null);
            }
            if (behaviorSource.RootTask != null)
            {
                ErrorCheck.CheckTaskForErrors(behaviorSource.RootTask, ref result);
            }
            return(result);
        }
コード例 #5
0
 // Token: 0x0600017B RID: 379 RVA: 0x0000D0CC File Offset: 0x0000B2CC
 private static void CheckField(Task task, bool projectLevelBehavior, ref List <ErrorDetails> errorDetails, FieldInfo field, int index, object value)
 {
     if (value == null)
     {
         return;
     }
     if (TaskUtility.HasAttribute(field, typeof(RequiredFieldAttribute)) && !ErrorCheck.IsRequiredFieldValid(field.FieldType, value))
     {
         ErrorCheck.AddError(ref errorDetails, ErrorDetails.ErrorType.RequiredField, task, index, field.Name);
     }
     if (typeof(SharedVariable).IsAssignableFrom(field.FieldType))
     {
         SharedVariable sharedVariable = value as SharedVariable;
         if (sharedVariable != null)
         {
             if (sharedVariable.IsShared && string.IsNullOrEmpty(sharedVariable.Name) && !TaskUtility.HasAttribute(field, typeof(SharedRequiredAttribute)))
             {
                 ErrorCheck.AddError(ref errorDetails, ErrorDetails.ErrorType.SharedVariable, task, index, field.Name);
             }
             object value2 = sharedVariable.GetValue();
             if (!EditorApplication.isPlaying && projectLevelBehavior && !sharedVariable.IsShared && value2 is Object && AssetDatabase.GetAssetPath(value2 as Object).Length <= 0)
             {
                 ErrorCheck.AddError(ref errorDetails, ErrorDetails.ErrorType.InvalidTaskReference, task, index, field.Name);
             }
         }
     }
     else if (value is Object)
     {
         bool flag = AssetDatabase.GetAssetPath(value as Object).Length > 0;
         if (!EditorApplication.isPlaying && !flag)
         {
             ErrorCheck.AddError(ref errorDetails, ErrorDetails.ErrorType.InvalidTaskReference, task, index, field.Name);
         }
     }
     else if (!typeof(Delegate).IsAssignableFrom(field.FieldType) && (field.FieldType.IsClass || (field.FieldType.IsValueType && !field.FieldType.IsPrimitive)))
     {
         FieldInfo[] allFields = TaskUtility.GetAllFields(field.FieldType);
         for (int i = 0; i < allFields.Length; i++)
         {
             ErrorCheck.CheckField(task, projectLevelBehavior, ref errorDetails, allFields[i], index, allFields[i].GetValue(value));
         }
     }
 }