public static void Burst_Unity__Entities__SystemBaseRegistry_CallForwardingFunction(IntPtr p)
        {
            SystemState *v0 = (SystemState *)((byte *)p + 0);
            var          v1 = default(int);

            SystemBaseRegistry.CallForwardingFunction(v0, v1);
        }
        void UpdateAllSystems()
        {
            if (m_systemSortDirty)
            {
                SortSystems();
            }

            // Update all unmanaged and managed systems together, in the correct sort order.
            // The master update list contains indices for both managed and unmanaged systems.
            // Negative values indicate an index in the unmanaged system list.
            // Positive values indicate an index in the managed system list.
            for (int i = 0; i < m_MasterUpdateList.Length; ++i)
            {
                try
                {
                    var index = m_MasterUpdateList[i];

                    if (!index.IsManaged)
                    {
                        // Update unmanaged (burstable) code.
                        SystemState *sys = World.ResolveSystemState(m_UnmanagedSystemsToUpdate[index.Index]);
                        if (sys != null)
                        {
                            if (SystemBase.UnmanagedUpdate(sys, out var details))
                            {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
                                var metaIndex       = sys->m_UnmanagedMetaIndex;
                                var systemDebugName = SystemBaseRegistry.GetDebugName(metaIndex);
                                var errorString     = details.FormatToString(systemDebugName);
                                Debug.LogError(errorString);
#endif
                            }
                        }
                    }
                    else
                    {
                        // Update managed code.
                        var sys = m_systemsToUpdate[index.Index];
                        sys.Update();
                    }
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
#if UNITY_DOTSPLAYER
                    // When in a DOTS Runtime build, throw this upstream -- continuing after silently eating an exception
                    // is not what you'll want, except maybe once we have LiveLink.  If you're looking at this code
                    // because your LiveLink dots runtime build is exiting when you don't want it to, feel free
                    // to remove this block, or guard it with something to indicate the player is not for live link.
                    throw;
#endif
                }

                if (World.QuitUpdate)
                {
                    break;
                }
            }
        }
        private void FreeSlot(ushort handle, SystemState *statePtr)
        {
            var systemPtr = statePtr->m_SystemPtr;

            // If the system ptr is not null, this is an unmanaged system and we need to actually destroy it.
            if (systemPtr != null)
            {
                try
                {
                    SystemBaseRegistry.CallOnStopRunning(statePtr);
                    SystemBaseRegistry.CallOnDestroy(statePtr);
                }
                catch (Exception ex)
                {
                    Debug.LogException(ex);
                }
            }
            statePtr->Dispose();
            _stateMemory.Free(handle);
        }
        public static void Burst_Unity__Entities__SystemBaseRegistry_CallOnUpdate(IntPtr p)
        {
            SystemState *v0 = (SystemState *)((byte *)p + 0);

            SystemBaseRegistry.CallOnUpdate(v0);
        }
Example #5
0
        void UpdateAllSystems()
        {
            if (m_systemSortDirty)
            {
                SortSystems();
            }

            // Update all unmanaged and managed systems together, in the correct sort order.
            // The master update list contains indices for both managed and unmanaged systems.
            // Negative values indicate an index in the unmanaged system list.
            // Positive values indicate an index in the managed system list.
            var world = World.Unmanaged;
            var previouslyExecutingSystem = world.ExecutingSystem;
            // Cache the update list length before updating; any new systems added mid-loop will change the length and
            // should not be processed until the subsequent group update, to give SortSystems() a chance to run.
            int updateListLength = m_MasterUpdateList.Length;

            for (int i = 0; i < updateListLength; ++i)
            {
                try
                {
                    var index = m_MasterUpdateList[i];

                    if (!index.IsManaged)
                    {
                        // Update unmanaged (burstable) code.
                        var handle = m_UnmanagedSystemsToUpdate[index.Index];
                        world.ExecutingSystem = handle;
                        SystemState *sys = world.ResolveSystemState(m_UnmanagedSystemsToUpdate[index.Index]);
                        if (sys != null)
                        {
                            bool updateError = false;
                            updateError = s_UnmanagedUpdateFn((IntPtr)sys, out var details);

                            if (updateError)
                            {
#if ENABLE_UNITY_COLLECTIONS_CHECKS
                                var errorString = details.FormatToString(sys->DebugName);
                                Debug.LogError(errorString);
#endif
                            }
                        }
                    }
                    else
                    {
                        // Update managed code.
                        var sys = m_systemsToUpdate[index.Index];
                        sys.Update();
                    }
                }
                catch (Exception e)
                {
                    Debug.LogException(e);
#if UNITY_DOTSRUNTIME
                    // When in a DOTS Runtime build, throw this upstream -- continuing after silently eating an exception
                    // is not what you'll want, except maybe once we have LiveLink.  If you're looking at this code
                    // because your LiveLink dots runtime build is exiting when you don't want it to, feel free
                    // to remove this block, or guard it with something to indicate the player is not for live link.
                    throw;
#endif
                }
                finally
                {
                    world.ExecutingSystem = previouslyExecutingSystem;
                }

                if (World.QuitUpdate)
                {
                    break;
                }
            }

            World.Unmanaged.DestroyPendingSystems();
        }