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

#if ODIN_INSPECTOR
using Sirenix.OdinInspector;
#endif
using System;
using UnityEngine;

namespace Aster.Game
{
    /// <summary>
    /// 游戏运行器
    /// </summary>
    public class GameRuner : MonoBehaviour
    {

#if ODIN_INSPECTOR
        [LabelText("当前子系统")]
#endif
        public GameSystemCollection SystemCollection;

#if ODIN_INSPECTOR
        [LabelText("初始化完成")]
        [NonSerialized, ShowInInspector, DisplayAsString]
        [HideInEditorMode]
#endif
        public bool IsInited = false;


        private void Start()
        {
            if (SystemCollection == null)
                return;
            SystemCollection.Start();
            IsInited = true;
        }

        private void FixedUpdate()
        {
            if (!IsInited)
                return;

            SystemCollection.FixedUpdate();
        }

        private void Update()
        {
            if (!IsInited)
                return;

            SystemCollection.Update();
        }

        private void LateUpdate()
        {
            if (!IsInited)
                return;

            SystemCollection.LateUpdate();
        }

        private void OnDestroy()
        {
            if (!IsInited)
                return;

            SystemCollection.Destroy();
        }

    }
}