Пример #1
0
        public void Init(EcsWorlds worlds)
        {
            // pre init.
            foreach (var system in _allSystems)
            {
                if (system is IEcsPreInitSystem preInitSystem)
                {
                    preInitSystem.PreInit(worlds);
#if DEBUG
                    var leaked = worlds.CheckLeaks();
                    if (leaked != null)
                    {
                        throw new System.Exception($"\"{leaked}\" in {preInitSystem.GetType ().Name}.PreInit().");
                    }
#endif
                }
            }
            // init.
            foreach (var system in _allSystems)
            {
                if (system is IEcsInitSystem initSystem)
                {
                    initSystem.Init(worlds);
#if DEBUG
                    var leaked = worlds.CheckLeaks();
                    if (leaked != null)
                    {
                        throw new System.Exception($"\"{leaked}\" in {initSystem.GetType ().Name}.Init().");
                    }
#endif
                }
            }
        }
Пример #2
0
        public void Destroy(EcsWorlds worlds)
        {
            // destroy.
            foreach (var system in _allSystems)
            {
                if (system is IEcsDestroySystem destroySystem)
                {
                    destroySystem.Destroy(worlds);
#if DEBUG
                    var leaked = worlds.CheckLeaks();
                    if (leaked != null)
                    {
                        throw new System.Exception($"\"{leaked}\" in {destroySystem.GetType ().Name}.Destroy().");
                    }
#endif
                }
            }
            // post destroy.
            foreach (var system in _allSystems)
            {
                if (system is IEcsPostDestroySystem postDestroySystem)
                {
                    postDestroySystem.AfterDestroy(worlds);
#if DEBUG
                    var leaked = worlds.CheckLeaks();
                    if (leaked != null)
                    {
                        throw new System.Exception($"\"{leaked}\" in {postDestroySystem.GetType ().Name}.PreInit().");
                    }
#endif
                }
            }
        }
Пример #3
0
        public void Run(EcsWorlds worlds)
        {
            foreach (var runSystem in _runSystems)
            {
                runSystem.Run(worlds);
#if DEBUG
                var leaked = worlds.CheckLeaks();
                if (leaked != null)
                {
                    throw new System.Exception($"\"{leaked}\" in {runSystem.GetType ().Name}.Run().");
                }
#endif
            }
        }