/*
 *Copyright(C) 2023 by Chief All rights reserved.
 *Unity版本：2023.2.5f1c1 
 *作者:Chief  
 *创建日期: 2024-01-29 
 *模块说明：游戏运行器
 *版本: 1.0
*/

using UnityEngine;
using System.Collections.Generic;

#if ODIN_INSPECTOR
using Sirenix.OdinInspector;
#endif

namespace Aster.Game
{
    /// <summary>
    /// 游戏子系统集合；
    /// </summary>
    public class GameSystemCollection :
#if ODIN_INSPECTOR
        SerializedScriptableObject
#else
        ScriptableObject
#endif
    {

#if ODIN_INSPECTOR
        [LabelText("所有子系统")]
#endif
        public List<GameSystem> ListSystems = new List<GameSystem>();


        public void Start()
        {
            int length = ListSystems.Count;
            for (int i = length - 1; i >= 0; i--)
            {
                var system = ListSystems[i];
                system?.Start();
            }
        }

        public void FixedUpdate()
        {
            int length = ListSystems.Count;
            for (int i = length - 1; i >= 0; i--)
            {
                var system = ListSystems[i];
                system?.FixedUpdate();
            }
        }

        public void Update()
        {
            int length = ListSystems.Count;
            for (int i = length - 1; i >= 0; i--)
            {
                var system = ListSystems[i];
                system?.Update();
            }
        }

        public void LateUpdate()
        {
            int length = ListSystems.Count;
            for (int i = length - 1; i >= 0; i--)
            {
                var system = ListSystems[i];
                system?.LateUpdate();
            }
        }

        public void Destroy()
        {
            int length = ListSystems.Count;
            for (int i = length - 1; i >= 0; i--)
            {
                var system = ListSystems[i];
                system?.Destroy();
            }
        }

    }
}