154 lines
4.1 KiB
C#
154 lines
4.1 KiB
C#
using Axibug;
|
|
using Axibug.Event;
|
|
using Axibug.Runtime;
|
|
using Codice.Client.Common.TreeGrouper;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Data.Odbc;
|
|
using System.Xml.Serialization;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using static Game.NoMonoComponent;
|
|
|
|
namespace Game
|
|
{
|
|
public class NoMonoComponent : GameComponent
|
|
{
|
|
public List<NoMonoInfo> NoMonoInfos = new List<NoMonoInfo>();
|
|
|
|
public event Action ApplicationPauseEvent;
|
|
public event Action ApplicationQuitEvent;
|
|
public event Action UpdateEvent;
|
|
public event Action FixedUpdateEvent;
|
|
public event Action<Scene, LoadSceneMode> SceneChangedEvent;
|
|
|
|
[Serializable]
|
|
public class NoMonoInfo
|
|
{
|
|
public string Name;
|
|
public GameObject Obj;
|
|
public NoMono noMono;
|
|
}
|
|
|
|
protected override void Awake()
|
|
{
|
|
base.Awake();
|
|
}
|
|
|
|
#region ÌṩÉúÃüÖÜÆÚ
|
|
|
|
void Update()
|
|
{
|
|
//for (int i = 0; i < Nodes.Count; i++)
|
|
// Nodes[i].Update();
|
|
|
|
UpdateEvent?.Invoke();
|
|
}
|
|
void FixedUpdate()
|
|
{
|
|
//for (int i = 0; i < Nodes.Count; i++)
|
|
// Nodes[i].FixedUpdate();
|
|
|
|
FixedUpdateEvent?.Invoke();
|
|
}
|
|
|
|
private void OnApplicationPause(bool pauseStatus)
|
|
{
|
|
if (pauseStatus)
|
|
{
|
|
ApplicationPauseEvent?.Invoke();
|
|
}
|
|
}
|
|
private void OnApplicationQuit()
|
|
{
|
|
ApplicationQuitEvent?.Invoke();
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
public static class NoMonoSys
|
|
{
|
|
static private NoMonoComponent _monoController => GamePlayEntry.NoMono;
|
|
|
|
static public void RegisterNoMono(string Name, NoMono node)
|
|
{
|
|
_monoController.NoMonoInfos.Add(new NoMonoInfo() { Name = Name, Obj = node.gameObject, noMono = node });
|
|
}
|
|
|
|
static public Coroutine StartCoroutine(IEnumerator routine)
|
|
{
|
|
return _monoController.StartCoroutine(routine);
|
|
}
|
|
|
|
static public void StopCoroutine(IEnumerator routine)
|
|
{
|
|
if (_monoController != null)
|
|
{
|
|
_monoController.StopCoroutine(routine);
|
|
}
|
|
}
|
|
|
|
static public void AddApplicationQuitEvent(Action action)
|
|
{
|
|
_monoController.ApplicationQuitEvent += action;
|
|
}
|
|
|
|
static public void RemoveApplicationQuitEvent(Action action)
|
|
{
|
|
_monoController.ApplicationQuitEvent -= action;
|
|
}
|
|
|
|
static public void AddApplicationPauseEvent(Action action)
|
|
{
|
|
_monoController.ApplicationPauseEvent += action;
|
|
}
|
|
|
|
static public void RemoveApplicationPauseEvent(Action action)
|
|
{
|
|
_monoController.ApplicationPauseEvent -= action;
|
|
}
|
|
|
|
static public void AddUpdateEvent(Action action)
|
|
{
|
|
_monoController.UpdateEvent += action;
|
|
}
|
|
|
|
static public void RemoveUpdateEvent(Action action)
|
|
{
|
|
_monoController.UpdateEvent -= action;
|
|
}
|
|
static public void AddSceneChangedEvent(Action<Scene, LoadSceneMode> action)
|
|
{
|
|
_monoController.SceneChangedEvent += action;
|
|
}
|
|
static public void RemoveSceneChangedEvent(Action<Scene, LoadSceneMode> action)
|
|
{
|
|
_monoController.SceneChangedEvent -= action;
|
|
}
|
|
|
|
static public IEnumerator DelayCall(float delayTime, Action action, bool isRealTime = false)
|
|
{
|
|
var coroutine = DelayCallCoroutine();
|
|
StartCoroutine(coroutine);
|
|
return coroutine;
|
|
|
|
IEnumerator DelayCallCoroutine()
|
|
{
|
|
if (isRealTime)
|
|
{
|
|
yield return new WaitForSecondsRealtime(delayTime);
|
|
}
|
|
else
|
|
{
|
|
yield return new WaitForSeconds(delayTime);
|
|
}
|
|
action?.Invoke();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|