Exemplo n.º 1
0
 private static void CollectGroups(IEnumerable <ScriptBehaviourManager> activeManagers, out Dictionary <Type, ScriptBehaviourGroup> allGroups, out Dictionary <Type, DependantBehavior> dependencies)
 {
     allGroups    = new Dictionary <Type, ScriptBehaviourGroup>();
     dependencies = new Dictionary <Type, DependantBehavior>();
     foreach (ScriptBehaviourManager manager in activeManagers)
     {
         object[] objArray2 = manager.GetType().GetCustomAttributes(typeof(UpdateInGroupAttribute), true);
         int      index     = 0;
         while (true)
         {
             ScriptBehaviourGroup group;
             if (index >= objArray2.Length)
             {
                 DependantBehavior behavior = new DependantBehavior(manager);
                 dependencies.Add(manager.GetType(), behavior);
                 break;
             }
             object obj2 = objArray2[index];
             UpdateInGroupAttribute attribute = obj2 as UpdateInGroupAttribute;
             if (!allGroups.TryGetValue(attribute.GroupType, out group))
             {
                 group = new ScriptBehaviourGroup(attribute.GroupType, allGroups, null);
             }
             group.Managers.Add(manager.GetType());
             index++;
         }
     }
 }
Exemplo n.º 2
0
 public ScriptBehaviourGroup(Type grpType, IDictionary <Type, ScriptBehaviourUpdateOrder.ScriptBehaviourGroup> allGroups, HashSet <Type> circularCheck = null)
 {
     this.m_GroupType = grpType;
     foreach (object obj2 in grpType.GetCustomAttributes(typeof(UpdateAfterAttribute), true))
     {
         UpdateAfterAttribute attribute = obj2 as UpdateAfterAttribute;
         this.UpdateAfter.Add(attribute.SystemType);
     }
     foreach (object obj3 in grpType.GetCustomAttributes(typeof(UpdateBeforeAttribute), true))
     {
         UpdateBeforeAttribute attribute2 = obj3 as UpdateBeforeAttribute;
         this.UpdateBefore.Add(attribute2.SystemType);
     }
     allGroups.Add(this.m_GroupType, this);
     foreach (object obj4 in this.m_GroupType.GetCustomAttributes(typeof(UpdateInGroupAttribute), true))
     {
         ScriptBehaviourUpdateOrder.ScriptBehaviourGroup group;
         if (circularCheck == null)
         {
             HashSet <Type> set1 = new HashSet <Type>();
             set1.Add(this.m_GroupType);
             circularCheck = set1;
         }
         UpdateInGroupAttribute attribute3 = obj4 as UpdateInGroupAttribute;
         if (!circularCheck.Add(attribute3.GroupType))
         {
             string message = "Found circular chain in update groups involving: ";
             bool   flag3   = true;
             foreach (Type type in circularCheck)
             {
                 message = message + (flag3 ? "" : ", ") + type;
                 flag3   = false;
             }
             Debug.LogError(message);
         }
         if (!allGroups.TryGetValue(attribute3.GroupType, out group))
         {
             group = new ScriptBehaviourUpdateOrder.ScriptBehaviourGroup(attribute3.GroupType, allGroups, circularCheck);
         }
         circularCheck.Remove(attribute3.GroupType);
         group.m_Groups.Add(this);
         this.m_Parents.Add(group);
         foreach (Type type2 in group.UpdateBefore)
         {
             this.UpdateBefore.Add(type2);
         }
         foreach (Type type3 in group.UpdateAfter)
         {
             this.UpdateAfter.Add(type3);
         }
     }
 }
Exemplo n.º 3
0
        private static void AddDependencies(DependantBehavior targetSystem, IReadOnlyDictionary <Type, DependantBehavior> dependencies, IReadOnlyDictionary <Type, ScriptBehaviourGroup> allGroups, PlayerLoopSystem defaultPlayerLoop)
        {
            Type item = targetSystem.Manager.GetType();

            foreach (object obj2 in item.GetCustomAttributes(typeof(UpdateAfterAttribute), true))
            {
                DependantBehavior    behavior;
                UpdateAfterAttribute attribute = obj2 as UpdateAfterAttribute;
                if (dependencies.TryGetValue(attribute.SystemType, out behavior))
                {
                    targetSystem.UpdateAfter.Add(attribute.SystemType);
                    behavior.UpdateBefore.Add(item);
                }
                else
                {
                    ScriptBehaviourGroup group;
                    if (allGroups.TryGetValue(attribute.SystemType, out group))
                    {
                        group.AddUpdateBeforeToAllChildBehaviours(targetSystem, dependencies);
                    }
                    else
                    {
                        UpdateInsertionPos(targetSystem, attribute.SystemType, defaultPlayerLoop, true);
                    }
                }
            }
            foreach (object obj3 in item.GetCustomAttributes(typeof(UpdateBeforeAttribute), true))
            {
                DependantBehavior     behavior2;
                UpdateBeforeAttribute attribute2 = obj3 as UpdateBeforeAttribute;
                if (dependencies.TryGetValue(attribute2.SystemType, out behavior2))
                {
                    targetSystem.UpdateBefore.Add(attribute2.SystemType);
                    behavior2.UpdateAfter.Add(item);
                }
                else
                {
                    ScriptBehaviourGroup group2;
                    if (allGroups.TryGetValue(attribute2.SystemType, out group2))
                    {
                        group2.AddUpdateAfterToAllChildBehaviours(targetSystem, dependencies);
                    }
                    else
                    {
                        UpdateInsertionPos(targetSystem, attribute2.SystemType, defaultPlayerLoop, false);
                    }
                }
            }
            foreach (object obj4 in item.GetCustomAttributes(typeof(UpdateInGroupAttribute), true))
            {
                ScriptBehaviourGroup   group3;
                UpdateInGroupAttribute attribute3 = obj4 as UpdateInGroupAttribute;
                if (allGroups.TryGetValue(attribute3.GroupType, out group3))
                {
                    DependantBehavior    behavior3;
                    ScriptBehaviourGroup group4;
                    foreach (Type type2 in group3.UpdateAfter)
                    {
                        if (dependencies.TryGetValue(type2, out behavior3))
                        {
                            targetSystem.UpdateAfter.Add(type2);
                            behavior3.UpdateBefore.Add(item);
                            continue;
                        }
                        if (allGroups.TryGetValue(type2, out group4))
                        {
                            group4.AddUpdateBeforeToAllChildBehaviours(targetSystem, dependencies);
                            continue;
                        }
                        UpdateInsertionPos(targetSystem, type2, defaultPlayerLoop, true);
                    }
                    foreach (Type type3 in group3.UpdateBefore)
                    {
                        if (dependencies.TryGetValue(type3, out behavior3))
                        {
                            targetSystem.UpdateBefore.Add(type3);
                            behavior3.UpdateAfter.Add(item);
                            continue;
                        }
                        if (allGroups.TryGetValue(type3, out group4))
                        {
                            group4.AddUpdateAfterToAllChildBehaviours(targetSystem, dependencies);
                            continue;
                        }
                        UpdateInsertionPos(targetSystem, type3, defaultPlayerLoop, false);
                    }
                }
            }
        }