예제 #1
0
        internal static void RemoveComponent(IComponent component)
        {
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }

            foreach (var system in systems)
            {
                if (system is IWorldCallbackReceiver callbackReceiver)
                {
                    callbackReceiver.OnDestroyingComponent(component);
                }
            }

            if (enableRegistries)
            {
                Registries.Remove(component);
            }

            components.Remove(component);
        }
예제 #2
0
        internal static void AddComponent(IComponent component)
        {
            if (component == null)
            {
                throw new ArgumentNullException(nameof(component));
            }

            components.Add(component);

            if (enableRegistries)
            {
                Registries.Add(component);
            }

            foreach (var system in systems)
            {
                if (system is IWorldCallbackReceiver callbackReceiver)
                {
                    callbackReceiver.OnCreatedComponent(component);
                }
            }
        }