Exemplo n.º 1
0
 public static void Init()
 {
     ActionTargets.lookup.Clear();
     using (List <Type> .Enumerator enumerator = Actions.List.GetEnumerator())
     {
         while (enumerator.MoveNext())
         {
             Type current = enumerator.get_Current();
             IEnumerable <Attribute> attributes = CustomAttributeHelpers.GetAttributes(current, typeof(ActionTarget));
             using (IEnumerator <Attribute> enumerator2 = attributes.GetEnumerator())
             {
                 while (enumerator2.MoveNext())
                 {
                     Attribute current2 = enumerator2.get_Current();
                     ActionTargets.AddActionTarget(current, (ActionTarget)current2);
                 }
             }
         }
     }
     using (List <Type> .Enumerator enumerator3 = Actions.List.GetEnumerator())
     {
         while (enumerator3.MoveNext())
         {
             Type current3 = enumerator3.get_Current();
             if (!ActionTargets.HasNoActionTargetsAttribute(current3) && !ActionTargets.HasActionTargets(current3))
             {
                 ActionTargets.GenerateActionTargets(current3);
             }
         }
     }
 }
Exemplo n.º 2
0
 private static void FindGameObjectParameters(Type actionType, FieldInfo field)
 {
     if ((field.get_FieldType() == typeof(SkillOwnerDefault) || field.get_FieldType() == typeof(SkillGameObject) || field.get_FieldType() == typeof(GameObject)) && !CustomAttributeHelpers.HasAttribute <CheckForComponentAttribute>(field))
     {
         ActionTargets.AddActionTarget(actionType, new ActionTarget(typeof(GameObject), field.get_Name(), false));
     }
 }
Exemplo n.º 3
0
 public static void BuildList()
 {
     Actions.actionsList.Clear();
     Assembly[] assemblies = AppDomain.get_CurrentDomain().GetAssemblies();
     for (int i = 0; i < assemblies.Length; i++)
     {
         Assembly assembly = assemblies[i];
         try
         {
             Type[] exportedTypes = assembly.GetExportedTypes();
             Type[] array         = exportedTypes;
             for (int j = 0; j < array.Length; j++)
             {
                 Type type = array[j];
                 if (typeof(ISkillStateAction).IsAssignableFrom(type) && type.get_IsClass() && !type.get_IsAbstract() && (!FsmEditorSettings.HideObsoleteActions || (FsmEditorSettings.HideObsoleteActions && !CustomAttributeHelpers.IsObsolete(type))))
                 {
                     Actions.actionsList.Add(type);
                 }
             }
         }
         catch (Exception ex)
         {
             NotSupportedException arg_90_0 = ex as NotSupportedException;
         }
     }
     Actions.BuildCategoryList();
     Actions.InitCategories();
     Actions.UpdateUsage();
     ActionScripts.Init();
     ActionTargets.Init();
 }
Exemplo n.º 4
0
        private static void AddPrefabMenuItems(ref GenericMenu menu, ActionUtility.ActionCreationParams actionParams)
        {
            Type        type = actionParams.parameter.GetType();
            List <Type> actionsSortedByCategory = ActionTargets.GetActionsSortedByCategory();

            using (List <Type> .Enumerator enumerator = actionsSortedByCategory.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Type current = enumerator.get_Current();
                    ActionUtility.ActionCreationParams actionCreationParams = new ActionUtility.ActionCreationParams(actionParams);
                    List <ActionTarget> actionTargets = ActionTargets.GetActionTargets(current);
                    using (List <ActionTarget> .Enumerator enumerator2 = actionTargets.GetEnumerator())
                    {
                        while (enumerator2.MoveNext())
                        {
                            ActionTarget current2 = enumerator2.get_Current();
                            if (current2.get_AllowPrefabs() && current2.get_ObjectType().IsAssignableFrom(type))
                            {
                                actionCreationParams.actionType   = current;
                                actionCreationParams.actionTarget = current2;
                                menu.AddItem(new GUIContent(Labels.GetActionLabel(current)), false, new GenericMenu.MenuFunction2(ActionUtility.AddAction), actionCreationParams);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        private static void AddObjectMenuItems(ref GenericMenu menu, ActionUtility.ActionCreationParams actionParams, bool isSubMenu = false)
        {
            Type        type = actionParams.parameter.GetType();
            string      text = isSubMenu ? (Labels.StripNamespace(type.get_FullName()) + '/') : "";
            List <Type> actionsSortedByCategory = ActionTargets.GetActionsSortedByCategory();

            using (List <Type> .Enumerator enumerator = actionsSortedByCategory.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    Type current = enumerator.get_Current();
                    ActionUtility.ActionCreationParams actionCreationParams = new ActionUtility.ActionCreationParams(actionParams);
                    List <ActionTarget> actionTargets = ActionTargets.GetActionTargets(current);
                    using (List <ActionTarget> .Enumerator enumerator2 = actionTargets.GetEnumerator())
                    {
                        while (enumerator2.MoveNext())
                        {
                            ActionTarget current2 = enumerator2.get_Current();
                            if (ActionUtility.PinToTopOfMenu(current) && current2.get_ObjectType().IsAssignableFrom(type))
                            {
                                actionCreationParams.actionType   = current;
                                actionCreationParams.actionTarget = current2;
                                menu.AddItem(new GUIContent(text + Labels.GetActionLabel(current)), false, new GenericMenu.MenuFunction2(ActionUtility.AddAction), actionCreationParams);
                            }
                        }
                    }
                }
            }
            if (menu.GetItemCount() > 2)
            {
                menu.AddSeparator(text);
            }
            using (List <Type> .Enumerator enumerator3 = actionsSortedByCategory.GetEnumerator())
            {
                while (enumerator3.MoveNext())
                {
                    Type current3 = enumerator3.get_Current();
                    ActionUtility.ActionCreationParams actionCreationParams2 = new ActionUtility.ActionCreationParams(actionParams);
                    List <ActionTarget> actionTargets2 = ActionTargets.GetActionTargets(current3);
                    using (List <ActionTarget> .Enumerator enumerator4 = actionTargets2.GetEnumerator())
                    {
                        while (enumerator4.MoveNext())
                        {
                            ActionTarget current4 = enumerator4.get_Current();
                            if (!ActionUtility.PinToTopOfMenu(current3) && current4.get_ObjectType().IsAssignableFrom(type))
                            {
                                actionCreationParams2.actionType   = current3;
                                actionCreationParams2.actionTarget = current4;
                                string actionLabel = Labels.GetActionLabel(current3);
                                string text2       = Actions.GetActionCategory(current3) + '/';
                                menu.AddItem(new GUIContent(text + text2 + actionLabel), false, new GenericMenu.MenuFunction2(ActionUtility.AddAction), actionCreationParams2);
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
        private static void FindObjectTypeAttribute(Type actionType, FieldInfo field)
        {
            ObjectTypeAttribute attribute = CustomAttributeHelpers.GetAttribute <ObjectTypeAttribute>(field);

            if (attribute == null || attribute.get_ObjectType() == null)
            {
                return;
            }
            ActionTargets.AddActionTarget(actionType, new ActionTarget(attribute.get_ObjectType(), field.get_Name(), false));
        }
Exemplo n.º 7
0
 private static void FindMaterialParameters(Type actionType, FieldInfo field)
 {
     if (field.get_FieldType() == typeof(SkillMaterial) || field.get_FieldType() == typeof(Material))
     {
         ActionTargets.AddActionTarget(actionType, new ActionTarget(typeof(Material), field.get_Name(), false));
         return;
     }
     if (field.get_FieldType() == typeof(SkillTexture) || field.get_FieldType() == typeof(Texture))
     {
         ActionTargets.AddActionTarget(actionType, new ActionTarget(typeof(Texture), field.get_Name(), false));
     }
 }
Exemplo n.º 8
0
        private static void FindUIHintParameters(Type actionType, FieldInfo field)
        {
            IEnumerable <UIHintAttribute> attributes = CustomAttributeHelpers.GetAttributes <UIHintAttribute>(field);

            using (IEnumerator <UIHintAttribute> enumerator = attributes.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    UIHintAttribute current = enumerator.get_Current();
                    UIHint          hint    = current.get_Hint();
                    UIHint          uIHint  = hint;
                    if (uIHint == 6)
                    {
                        ActionTargets.AddActionTarget(actionType, new ActionTarget(typeof(AnimationClip), field.get_Name(), false));
                    }
                }
            }
        }
Exemplo n.º 9
0
        private static void FindColliderParameters(Type actionType, FieldInfo field)
        {
            Type fieldType = field.get_FieldType();

            if (fieldType == typeof(CollisionType) || fieldType == typeof(TriggerType))
            {
                ActionTargets.AddActionTarget(actionType, new ActionTarget(typeof(Collider), "", false));
                ActionTargets.AddActionTarget(actionType, new ActionTarget(typeof(Rigidbody), "", false));
                ActionTargets.AddActionTarget(actionType, new ActionTarget(typeof(GameObject), "", false));
                return;
            }
            if (fieldType == typeof(Collision2DType) || fieldType == typeof(Trigger2DType))
            {
                ActionTargets.AddActionTarget(actionType, new ActionTarget(typeof(Collider2D), "", false));
                ActionTargets.AddActionTarget(actionType, new ActionTarget(typeof(Rigidbody2D), "", false));
                ActionTargets.AddActionTarget(actionType, new ActionTarget(typeof(GameObject), "", false));
            }
        }
Exemplo n.º 10
0
 private static void GenerateActionTargets(Type actionType)
 {
     FieldInfo[] fields = actionType.GetFields(20);
     FieldInfo[] array  = fields;
     for (int i = 0; i < array.Length; i++)
     {
         FieldInfo field = array[i];
         if (!CustomAttributeHelpers.HasUIHint(field, 10))
         {
             ActionTargets.FindCheckForComponentAttribute(actionType, field);
             ActionTargets.FindObjectTypeAttribute(actionType, field);
             ActionTargets.FindMaterialParameters(actionType, field);
             ActionTargets.FindGameObjectParameters(actionType, field);
             ActionTargets.FindColliderParameters(actionType, field);
             ActionTargets.FindUIHintParameters(actionType, field);
         }
     }
 }
Exemplo n.º 11
0
        private static void AddActionTarget(Type actionType, ActionTarget actionTarget)
        {
            List <ActionTarget> list;

            if (ActionTargets.lookup.TryGetValue(actionType, ref list))
            {
                if (!ActionTargets.HasActionTargetForType(actionType, actionTarget.get_ObjectType()))
                {
                    list.Add(actionTarget);
                    return;
                }
            }
            else
            {
                List <ActionTarget> list2 = new List <ActionTarget>();
                list2.Add(actionTarget);
                list = list2;
                ActionTargets.lookup.Add(actionType, list);
            }
        }
Exemplo n.º 12
0
        private static void FindCheckForComponentAttribute(Type actionType, FieldInfo field)
        {
            CheckForComponentAttribute attribute = CustomAttributeHelpers.GetAttribute <CheckForComponentAttribute>(field);

            if (attribute != null)
            {
                if (attribute.get_Type0() != null)
                {
                    ActionTargets.AddActionTarget(actionType, new ActionTarget(attribute.get_Type0(), field.get_Name(), false));
                }
                if (attribute.get_Type1() != null)
                {
                    ActionTargets.AddActionTarget(actionType, new ActionTarget(attribute.get_Type1(), field.get_Name(), false));
                }
                if (attribute.get_Type2() != null)
                {
                    ActionTargets.AddActionTarget(actionType, new ActionTarget(attribute.get_Type2(), field.get_Name(), false));
                }
            }
        }