Example #1
0
 private static void CheckTask(Task t)
 {
     if (t.childNodes.Length > 0)
     {
         t.childNodes = new Node[0];
         _isChanged   = true;
     }
     if (t is Wait)
     {
         CheckWaitTask(t as Wait);
     }
     else
     {
         if (t.targetScript != null && !string.IsNullOrEmpty(t.targetMethod))
         {
             MethodInfo[] methods       = t.targetScript.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
             bool         isThereMethod = false;
             for (int i = 0; i < methods.Length; i++)
             {
                 MethodInfo method = methods[i];
                 if (method.Name == "Initialize")
                 {
                     continue;
                 }
                 if (method.Name.Contains("get_"))
                 {
                     continue;
                 }
                 if (method.ReturnType != typeof(IEnumerator) && method.ReturnType != typeof(System.IDisposable))
                 {
                     continue;
                 }
                 if (method.Name == t.targetMethod)
                 {
                     isThereMethod = true;
                     break;
                 }
             }
             if (!isThereMethod)
             {
                 t.Name         = "Task";
                 t.targetMethod = "";
                 BehaviorTreeEditorUtility.UpdateComment <Task>(t);
                 for (int i = 0; i < methods.Length; i++)
                 {
                     MethodInfo method = methods[i];
                     if (method.Name == "Initialize")
                     {
                         continue;
                     }
                     if (method.Name.Contains("get_"))
                     {
                         continue;
                     }
                     if (method.ReturnType != typeof(IEnumerator) && method.ReturnType != typeof(System.IDisposable))
                     {
                         continue;
                     }
                     t.Name         = method.Name;
                     t.targetMethod = method.Name;
                     BehaviorTreeEditorUtility.UpdateComment <Task>(t);
                     break;
                 }
                 _isChanged = true;
             }
         }
         else if (!string.IsNullOrEmpty(t.targetMethod))
         {
             t.Name         = "Task";
             t.targetMethod = "";
             BehaviorTreeEditorUtility.UpdateComment <Task>(t);
             _isChanged = true;
         }
     }
 }
Example #2
0
 private static void CheckDecorator(Decorator dc)
 {
     if (dc.observerAbortsType == 1 && dc.tick <= 0)
     {
         dc.tick = 1;
         BehaviorTreeEditorUtility.UpdateComment <Decorator>(dc);
         _isChanged = true;
     }
     else if (dc.observerAbortsType != 1 && dc.tick > 0)
     {
         dc.tick = 0;
         BehaviorTreeEditorUtility.UpdateComment <Decorator>(dc);
         _isChanged = true;
     }
     if (dc.targetScript != null && !string.IsNullOrEmpty(dc.targetMethod))
     {
         MethodInfo[] methods       = dc.targetScript.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
         bool         isThereMethod = false;
         for (int i = 0; i < methods.Length; i++)
         {
             MethodInfo method = methods[i];
             if (method.Name == "Initialize")
             {
                 continue;
             }
             if (method.Name.Contains("get_"))
             {
                 continue;
             }
             if (method.ReturnType != typeof(bool))
             {
                 continue;
             }
             if (method.Name == dc.targetMethod)
             {
                 isThereMethod = true;
                 break;
             }
         }
         if (!isThereMethod)
         {
             dc.Name         = "Decorator";
             dc.targetMethod = "";
             BehaviorTreeEditorUtility.UpdateComment <Decorator>(dc);
             for (int i = 0; i < methods.Length; i++)
             {
                 MethodInfo method = methods[i];
                 if (method.Name == "Initialize")
                 {
                     continue;
                 }
                 if (method.Name.Contains("get_"))
                 {
                     continue;
                 }
                 if (method.ReturnType != typeof(bool))
                 {
                     continue;
                 }
                 dc.Name         = method.Name;
                 dc.targetMethod = method.Name;
                 BehaviorTreeEditorUtility.UpdateComment <Decorator>(dc);
                 break;
             }
             _isChanged = true;
         }
     }
     else if (!string.IsNullOrEmpty(dc.targetMethod))
     {
         dc.Name         = "Decorator";
         dc.targetMethod = "";
         BehaviorTreeEditorUtility.UpdateComment <Decorator>(dc);
         _isChanged = true;
     }
 }
Example #3
0
 private static void CheckService(Service s)
 {
     if (s.tick <= 0)
     {
         s.tick = 0.1f;
         BehaviorTreeEditorUtility.UpdateComment <Service>(s);
         _isChanged = true;
     }
     if (s.targetScript != null && !string.IsNullOrEmpty(s.targetMethod))
     {
         MethodInfo[] methods       = s.targetScript.GetType().GetMethods(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly);
         bool         isThereMethod = false;
         for (int i = 0; i < methods.Length; i++)
         {
             MethodInfo method = methods[i];
             if (method.Name == "Initialize")
             {
                 continue;
             }
             if (method.Name.Contains("get_"))
             {
                 continue;
             }
             if (method.ReturnType != typeof(void))
             {
                 continue;
             }
             if (method.Name == s.targetMethod)
             {
                 isThereMethod = true;
                 break;
             }
         }
         if (!isThereMethod)
         {
             s.Name         = "Service";
             s.targetMethod = "";
             BehaviorTreeEditorUtility.UpdateComment <Service>(s);
             for (int i = 0; i < methods.Length; i++)
             {
                 MethodInfo method = methods[i];
                 if (method.Name == "Initialize")
                 {
                     continue;
                 }
                 if (method.Name.Contains("get_"))
                 {
                     continue;
                 }
                 if (method.ReturnType != typeof(void))
                 {
                     continue;
                 }
                 s.Name         = method.Name;
                 s.targetMethod = method.Name;
                 BehaviorTreeEditorUtility.UpdateComment <Service>(s);
                 break;
             }
             _isChanged = true;
             Debug.Log("Changed at method");
         }
     }
     else if (!string.IsNullOrEmpty(s.targetMethod))
     {
         s.Name         = "Service";
         s.targetMethod = "";
         BehaviorTreeEditorUtility.UpdateComment <Service>(s);
         _isChanged = true;
     }
 }