コード例 #1
0
        private void RemoveComponentImmediate(Component component)
        {
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }

            if (component.Deleted)
            {
                return;
            }

            // these two components are required on all entities and cannot be removed.
            if (component is ITransformComponent || component is IMetaDataComponent)
            {
                DebugTools.Assert("Tried to remove a protected component.");
                return;
            }

            component.Running = false;
            component.OnRemove();
            ComponentRemoved?.Invoke(this, new ComponentEventArgs(component));

            DeleteComponent(component);
        }
コード例 #2
0
        private void RemoveComponentDeferred(Component component)
        {
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }

            if (component.Deleted)
            {
                return;
            }

            _deleteList.Add(component);

            if (component.Running)
            {
                component.Shutdown();
            }

            component.OnRemove();
            ComponentRemoved?.Invoke(this, new ComponentEventArgs(component));
        }
コード例 #3
0
        private void RemoveComponentImmediate(Component component)
        {
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }

            if (component.Deleted)
            {
                return;
            }

            if (component.Running)
            {
                component.Shutdown();
            }

            component.OnRemove();
            ComponentRemoved?.Invoke(this, new ComponentEventArgs(component));

            DeleteComponent(component);
        }
コード例 #4
0
        private void RemoveComponentDeferred(Component component, bool removeProtected)
        {
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }

            if (component.Deleted)
            {
                return;
            }

#if EXCEPTION_TOLERANCE
            try
            {
#endif
            // these two components are required on all entities and cannot be removed normally.
            if (!removeProtected && (component is ITransformComponent || component is IMetaDataComponent))
            {
                DebugTools.Assert("Tried to remove a protected component.");
                return;
            }

            _deleteList.Add(component);

            component.Running = false;
            component.OnRemove();
            ComponentRemoved?.Invoke(this, new ComponentEventArgs(component));
#if EXCEPTION_TOLERANCE
        }

        catch (Exception e)
        {
            _runtimeLog.LogException(e,
                                     $"RemoveComponentDeferred, owner={component.Owner}, type={component.GetType()}");
        }
#endif
        }