using System.Collections;  
 | 
using System.Collections.Generic;  
 | 
using UnityEngine;  
 | 
  
 | 
  
 | 
namespace StartAot  
 | 
{  
 | 
    public class LogicEngine : SingletonMonobehaviour<LogicEngine>  
 | 
    {  
 | 
        List<LogicUpdate> logicUpdates = new List<LogicUpdate>();  
 | 
        public void Register(LogicUpdate logicUpdate)  
 | 
        {  
 | 
            if (!logicUpdates.Contains(logicUpdate))  
 | 
            {  
 | 
                logicUpdates.Add(logicUpdate);  
 | 
            }  
 | 
        }  
 | 
  
 | 
        public void UnRegister(LogicUpdate logicUpdate)  
 | 
        {  
 | 
            if (logicUpdates.Contains(logicUpdate))  
 | 
            {  
 | 
                logicUpdates.Remove(logicUpdate);  
 | 
            }  
 | 
        }  
 | 
  
 | 
        void Update()  
 | 
        {  
 | 
            for (var i = logicUpdates.Count - 1; i >= 0; i--)  
 | 
            {  
 | 
                var item = logicUpdates[i];  
 | 
                if (item.destroyDirty)  
 | 
                {  
 | 
                    logicUpdates.RemoveAt(i);  
 | 
                }  
 | 
                else  
 | 
                {  
 | 
                    try  
 | 
                    {  
 | 
                        item.Update();  
 | 
                    }  
 | 
                    catch (System.Exception ex)  
 | 
                    {  
 | 
                        DebugEx.LogError(ex);  
 | 
                    }  
 | 
                }  
 | 
            }  
 | 
  
 | 
        }  
 | 
  
 | 
    }  
 | 
  
 | 
} 
 |