Exemplo n.º 1
0
        internal void RemoveUnmanagedSystemFromUpdateList(SystemHandleUntyped sys)
        {
            CheckCreated();

            if (m_UnmanagedSystemsToUpdate.Contains(sys) && !m_UnmanagedSystemsToRemove.Contains(sys))
            {
                m_systemSortDirty = true;
                m_UnmanagedSystemsToRemove.Add(sys);
            }
        }
Exemplo n.º 2
0
        private int UnmanagedSystemIndex(SystemHandleUntyped sysHandle)
        {
            int len = m_UnmanagedSystemsToUpdate.Length;
            var ptr = m_UnmanagedSystemsToUpdate.Ptr;

            for (int i = 0; i < len; ++i)
            {
                if (ptr[i] == sysHandle)
                {
                    return(i);
                }
            }
            return(-1);
        }
Exemplo n.º 3
0
        internal void RemoveUnmanagedSystemFromUpdateList(SystemHandleUntyped sys)
        {
            CheckCreated();
            if (!EnableSystemSorting)
            {
                throw new InvalidOperationException("Removing systems from a group is not supported if group.EnableSystemSorting is false.");
            }

            if (m_UnmanagedSystemsToUpdate.Contains(sys) && !m_UnmanagedSystemsToRemove.Contains(sys))
            {
                m_systemSortDirty = true;
                m_UnmanagedSystemsToRemove.Add(sys);
            }
        }
        internal WorldUnmanagedImpl(ulong sequenceNumber, WorldFlags flags)
        {
            CurrentTime = default;
#if ENABLE_UNITY_COLLECTIONS_CHECKS
            AllowGetSystem = true;
#endif
            SequenceNumber           = sequenceNumber;
            MaximumDeltaTime         = 1.0f / 3.0f;
            Flags                    = flags;
            _unmanagedSlotByTypeHash = new UnsafeMultiHashMap <long, ushort>(32, Allocator.Persistent);
            _pendingDestroys         = new UnsafeList <ushort>(32, Allocator.Persistent);
            _stateMemory             = default;
            _stateMemory.Init();
            Version         = 0;
            ExecutingSystem = default;
        }
Exemplo n.º 5
0
        internal void AddUnmanagedSystemToUpdateList(SystemHandleUntyped sysHandle)
        {
            CheckCreated();

            if (-1 != UnmanagedSystemIndex(sysHandle))
            {
                int index = m_UnmanagedSystemsToRemove.IndexOf(sysHandle);
                if (-1 != index)
                {
                    m_UnmanagedSystemsToRemove.RemoveAt(index);
                }
                return;
            }

            m_UnmanagedSystemsToUpdate.Add(sysHandle);
            m_systemSortDirty = true;
        }
        internal void AddUnmanagedSystemToUpdateList(SystemHandleUntyped sysHandle)
        {
            CheckCreated();

            if (-1 != UnmanagedSystemIndex(sysHandle))
            {
                int index = m_UnmanagedSystemsToRemove.IndexOf(sysHandle);
                if (-1 != index)
                {
                    m_UnmanagedSystemsToRemove.RemoveAt(index);
                }
                return;
            }

            if (UseLegacySortOrder)
            {
                throw new InvalidOperationException("ISystemBase systems are not compatible with legacy sort order. Set UseLegacySortOrder to false to use ISystemBase systems.");
            }

            m_UnmanagedSystemsToUpdate.Add(sysHandle);
            m_systemSortDirty = true;
        }
Exemplo n.º 7
0
 internal SystemHandle(ushort slot, ushort version, uint worldSeqNo)
 {
     MHandle = new SystemHandleUntyped(slot, version, worldSeqNo);
 }
        private static void AddSystemToRootLevelSystemGroupsInternal(World world, IEnumerable <Type> systemTypesOrig, int managedTypesCountOrig)
        {
            var initializationSystemGroup = world.GetOrCreateSystem <InitializationSystemGroup>();
            var simulationSystemGroup     = world.GetOrCreateSystem <SimulationSystemGroup>();
            var presentationSystemGroup   = world.GetOrCreateSystem <PresentationSystemGroup>();

            var managedTypes   = new List <Type>();
            var unmanagedTypes = new List <Type>();

            foreach (var stype in systemTypesOrig)
            {
                if (typeof(ComponentSystemBase).IsAssignableFrom(stype))
                {
                    managedTypes.Add(stype);
                }
                else if (typeof(ISystemBase).IsAssignableFrom(stype))
                {
                    unmanagedTypes.Add(stype);
                }
                else
                {
                    throw new InvalidOperationException("Bad type");
                }
            }

            var systems = world.GetOrCreateSystemsAndLogException(managedTypes, managedTypes.Count);

            // Add systems to their groups, based on the [UpdateInGroup] attribute.
            foreach (var system in systems)
            {
                if (system == null)
                {
                    continue;
                }

                // Skip the built-in root-level system groups
                var type = system.GetType();
                if (type == typeof(InitializationSystemGroup) ||
                    type == typeof(SimulationSystemGroup) ||
                    type == typeof(PresentationSystemGroup))
                {
                    continue;
                }

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

                foreach (var attr in updateInGroupAttributes)
                {
                    var group = FindGroup(world, type, attr);
                    if (group != null)
                    {
                        group.AddSystemToUpdateList(system);
                    }
                }
            }

#if !UNITY_DOTSRUNTIME
            // Add unmanaged systems
            foreach (var type in unmanagedTypes)
            {
                SystemHandleUntyped sysHandle = world.Unmanaged.CreateUnmanagedSystem(world, type);

                // Add systems to their groups, based on the [UpdateInGroup] attribute.

                var updateInGroupAttributes = TypeManager.GetSystemAttributes(type, typeof(UpdateInGroupAttribute));
                if (updateInGroupAttributes.Length == 0)
                {
                    simulationSystemGroup.AddUnmanagedSystemToUpdateList(sysHandle);
                }

                foreach (var attr in updateInGroupAttributes)
                {
                    ComponentSystemGroup groupSys = FindGroup(world, type, attr);

                    if (groupSys != null)
                    {
                        groupSys.AddUnmanagedSystemToUpdateList(sysHandle);
                    }
                }
            }
#endif


            // Update player loop
            initializationSystemGroup.SortSystems();
            simulationSystemGroup.SortSystems();
            presentationSystemGroup.SortSystems();
        }
Exemplo n.º 9
0
 internal static void RemoveSystemFromUpdateList(this ComponentSystemGroup self, SystemHandleUntyped sysHandle)
 {
     self.RemoveUnmanagedSystemFromUpdateList(sysHandle);
 }
Exemplo n.º 10
0
 internal static void AddSystemToUpdateList(this ComponentSystemGroup self, SystemHandleUntyped sysHandle)
 {
     self.AddUnmanagedSystemToUpdateList(sysHandle);
 }