internal EntityQueryBuilder(ComponentSystem system)
 {
     m_System = system;
     m_Any    = new ResizableArray64Byte <int>();
     m_None   = new ResizableArray64Byte <int>();
     m_All    = new ResizableArray64Byte <int>();
     m_Query  = null;
 }
Example #2
0
 internal EntityQueryBuilder(ComponentSystem system)
 {
     m_System = system;
     m_Any    = new ResizableArray64Byte <int>();
     m_None   = new ResizableArray64Byte <int>();
     m_All    = new ResizableArray64Byte <int>();
     m_AnyWritableBitField = m_AllWritableBitField = 0;
     m_Options             = EntityQueryOptions.Default;
     m_Query = null;
 }
 internal EntityQueryBuilder(ComponentSystem system)
 {
     m_System = system;
     m_Any    = new FixedListInt64();
     m_None   = new FixedListInt64();
     m_All    = new FixedListInt64();
     m_AnyWritableBitField = m_AllWritableBitField = 0;
     m_Options             = EntityQueryOptions.Default;
     m_Query = null;
 }
Example #4
0
        public static void InitializeSystems(World world)
        {
            var allSystemTypes = TypeManager.GetSystems();
            var allSystemNames = TypeManager.SystemNames;

            if (allSystemTypes.Length == 0)
            {
                throw new InvalidOperationException("DefaultTinyWorldInitialization: No Systems found.");
            }

            // Create top level presentation system and simulation systems.
            InitializationSystemGroup initializationSystemGroup = new InitializationSystemGroup();

            world.AddManager(initializationSystemGroup);

            SimulationSystemGroup simulationSystemGroup = new SimulationSystemGroup();

            world.AddManager(simulationSystemGroup);

            PresentationSystemGroup presentationSystemGroup = new PresentationSystemGroup();

            world.AddManager(presentationSystemGroup);

            // Create the working set of systems.
            int nSystems = 0;

            Type[]            systemTypes = new Type[allSystemTypes.Length];
            ComponentSystem[] systems     = new ComponentSystem[allSystemTypes.Length];

#if WRITE_LOG
            Console.WriteLine("--- Adding systems:");
#endif

            for (int i = 0; i < allSystemTypes.Length; i++)
            {
                if (TypeManager.GetSystemAttributes(allSystemTypes[i], typeof(DisableAutoCreationAttribute)).Length > 0)
                {
                    continue;
                }
                if (allSystemTypes[i] == initializationSystemGroup.GetType() ||
                    allSystemTypes[i] == simulationSystemGroup.GetType() ||
                    allSystemTypes[i] == presentationSystemGroup.GetType())
                {
                    continue;
                }

                if (world.GetExistingManager(allSystemTypes[i]) != null)
                {
                    continue;
                }
#if WRITE_LOG
                Console.WriteLine(allSystemNames[i]);
#endif
                systemTypes[nSystems] = allSystemTypes[i];
                systems[nSystems]     = TypeManager.ConstructSystem(allSystemTypes[i]);
                world.AddManager(systems[nSystems]);
                nSystems++;
            }
#if WRITE_LOG
            Console.WriteLine("--- Adding systems Done.");
#endif

            for (int i = 0; i < nSystems; ++i)
            {
                var sysType = systemTypes[i];
                var system  = systems[i];

                var groups = TypeManager.GetSystemAttributes(sysType, typeof(UpdateInGroupAttribute));
                if (groups.Length == 0)
                {
                    simulationSystemGroup.AddSystemToUpdateList(system);
                }

                for (int g = 0; g < groups.Length; ++g)
                {
                    var groupType   = groups[g] as UpdateInGroupAttribute;
                    var groupSystem = world.GetExistingManager(groupType.GroupType) as ComponentSystemGroup;
                    if (groupSystem == null)
                    {
                        throw new Exception("DefaultTinyWorldInitialization failed to find existing SystemGroup.");
                    }

                    groupSystem.AddSystemToUpdateList(system);
                }
            }
        }
Example #5
0
        private static void MarkSchedulingAndWaitingJobs(Dictionary <Type, DependantBehavior> dependencyGraph)
        {
            HashSet <DependantBehavior> set = new HashSet <DependantBehavior>();

            foreach (KeyValuePair <Type, DependantBehavior> pair in dependencyGraph)
            {
                DependantBehavior item = pair.Value;
                if (item.Manager is JobComponentSystem)
                {
                    item.spawnsJobs = true;
                    set.Add(item);
                }
            }
            foreach (KeyValuePair <Type, DependantBehavior> pair2 in dependencyGraph)
            {
                ComponentGroup[]  componentGroups;
                DependantBehavior behavior2 = pair2.Value;
                ComponentSystem   manager   = behavior2.Manager as ComponentSystem;
                if (manager != null)
                {
                    componentGroups = manager.ComponentGroups;
                }
                else
                {
                    object obj1 = manager;
                    componentGroups = null;
                }
                if (componentGroups != null)
                {
                    HashSet <int>    set2            = new HashSet <int>();
                    ComponentGroup[] componentGroups = ((ComponentSystem)behavior2.Manager).ComponentGroups;
                    int index = 0;
                    while (true)
                    {
                        if (index >= componentGroups.Length)
                        {
                            using (HashSet <DependantBehavior> .Enumerator enumerator3 = set.GetEnumerator())
                            {
                                while (true)
                                {
                                    if (enumerator3.MoveNext())
                                    {
                                        DependantBehavior current = enumerator3.Current;
                                        if (!(current.Manager is ComponentSystem))
                                        {
                                            continue;
                                        }
                                        HashSet <int>    set3        = new HashSet <int>();
                                        ComponentGroup[] groupArray2 = ((ComponentSystem)current.Manager).ComponentGroups;
                                        int num3 = 0;
                                        while (true)
                                        {
                                            if (num3 < groupArray2.Length)
                                            {
                                                ComponentGroup  group2     = groupArray2[num3];
                                                ComponentType[] typeArray2 = group2.Types;
                                                int             num4       = 0;
                                                while (true)
                                                {
                                                    if (num4 >= typeArray2.Length)
                                                    {
                                                        num3++;
                                                        break;
                                                    }
                                                    ComponentType type2 = typeArray2[num4];
                                                    if (type2.RequiresJobDependency)
                                                    {
                                                        set3.Add(type2.TypeIndex);
                                                    }
                                                    num4++;
                                                }
                                                continue;
                                            }
                                            bool flag4 = false;
                                            foreach (int num5 in set2)
                                            {
                                                if (set3.Contains(num5))
                                                {
                                                    flag4 = true;
                                                    break;
                                                }
                                            }
                                            if (flag4)
                                            {
                                                behavior2.WaitsForJobs = true;
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                            break;
                                        }
                                    }
                                    break;
                                }
                            }
                            break;
                        }
                        ComponentGroup  group = componentGroups[index];
                        ComponentType[] types = group.Types;
                        int             num2  = 0;
                        while (true)
                        {
                            if (num2 >= types.Length)
                            {
                                index++;
                                break;
                            }
                            ComponentType type = types[num2];
                            if (type.RequiresJobDependency)
                            {
                                set2.Add(type.TypeIndex);
                            }
                            num2++;
                        }
                    }
                }
            }
        }