mirror of
https://github.com/Alex-Rachel/TEngine.git
synced 2025-08-07 16:45:10 +00:00
GameScripts
GameScripts
This commit is contained in:
120
Assets/GameScripts/HotFix/GameLogic/GameApp.cs
Normal file
120
Assets/GameScripts/HotFix/GameLogic/GameApp.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
using GameBase;
|
||||
using TEngine;
|
||||
|
||||
public partial class GameApp:Singleton<GameApp>
|
||||
{
|
||||
/// <summary>
|
||||
/// 热更域App主入口。
|
||||
/// </summary>
|
||||
/// <param name="objects"></param>
|
||||
public static void Entrance(object[] objects)
|
||||
{
|
||||
Log.Warning("======= 看到此条日志代表你成功运行了热更新代码 =======");
|
||||
Log.Warning("======= Entrance GameApp =======");
|
||||
Instance.Init();
|
||||
Instance.Start();
|
||||
Utility.Unity.AddUpdateListener(Instance.Update);
|
||||
Utility.Unity.AddFixedUpdateListener(Instance.FixedUpdate);
|
||||
Utility.Unity.AddLateUpdateListener(Instance.LateUpdate);
|
||||
Utility.Unity.AddDestroyListener(Instance.OnDestroy);
|
||||
Utility.Unity.AddOnDrawGizmosListener(Instance.OnDrawGizmos);
|
||||
Utility.Unity.AddOnApplicationPauseListener(Instance.OnApplicationPause);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GameTime.StartFrame();
|
||||
var listLogic = m_listLogicMgr;
|
||||
var logicCnt = listLogic.Count;
|
||||
for (int i = 0; i < logicCnt; i++)
|
||||
{
|
||||
var logic = listLogic[i];
|
||||
logic.OnStart();
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
GameTime.StartFrame();
|
||||
TProfiler.BeginFirstSample("Update");
|
||||
var listLogic = m_listLogicMgr;
|
||||
var logicCnt = listLogic.Count;
|
||||
for (int i = 0; i < logicCnt; i++)
|
||||
{
|
||||
var logic = listLogic[i];
|
||||
TProfiler.BeginSample(logic.GetType().FullName);
|
||||
logic.OnUpdate();
|
||||
TProfiler.EndSample();
|
||||
}
|
||||
TProfiler.EndFirstSample();
|
||||
}
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
GameTime.StartFrame();
|
||||
TProfiler.BeginFirstSample("FixedUpdate");
|
||||
var listLogic = m_listLogicMgr;
|
||||
var logicCnt = listLogic.Count;
|
||||
for (int i = 0; i < logicCnt; i++)
|
||||
{
|
||||
var logic = listLogic[i];
|
||||
TProfiler.BeginSample(logic.GetType().FullName);
|
||||
logic.OnFixedUpdate();
|
||||
TProfiler.EndSample();
|
||||
}
|
||||
TProfiler.EndFirstSample();
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
GameTime.StartFrame();
|
||||
TProfiler.BeginFirstSample("LateUpdate");
|
||||
var listLogic = m_listLogicMgr;
|
||||
var logicCnt = listLogic.Count;
|
||||
for (int i = 0; i < logicCnt; i++)
|
||||
{
|
||||
var logic = listLogic[i];
|
||||
TProfiler.BeginSample(logic.GetType().FullName);
|
||||
logic.OnLateUpdate();
|
||||
TProfiler.EndSample();
|
||||
}
|
||||
TProfiler.EndFirstSample();
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
GameTime.StartFrame();
|
||||
var listLogic = m_listLogicMgr;
|
||||
var logicCnt = listLogic.Count;
|
||||
for (int i = 0; i < logicCnt; i++)
|
||||
{
|
||||
var logic = listLogic[i];
|
||||
logic.OnDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDrawGizmos()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
GameTime.StartFrame();
|
||||
var listLogic = m_listLogicMgr;
|
||||
var logicCnt = listLogic.Count;
|
||||
for (int i = 0; i < logicCnt; i++)
|
||||
{
|
||||
var logic = listLogic[i];
|
||||
logic.OnDrawGizmos();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
private void OnApplicationPause(bool isPause)
|
||||
{
|
||||
var listLogic = m_listLogicMgr;
|
||||
var logicCnt = listLogic.Count;
|
||||
for (int i = 0; i < logicCnt; i++)
|
||||
{
|
||||
var logic = listLogic[i];
|
||||
logic.OnApplicationPause(isPause);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/GameScripts/HotFix/GameLogic/GameApp.cs.meta
Normal file
11
Assets/GameScripts/HotFix/GameLogic/GameApp.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5fabb458720ae14bbdb4d781d4ef34e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,55 @@
|
||||
using System.Collections.Generic;
|
||||
using TEngine;
|
||||
|
||||
public partial class GameApp
|
||||
{
|
||||
private List<ILogicSys> m_listLogicMgr;
|
||||
|
||||
private void Init()
|
||||
{
|
||||
m_listLogicMgr = new List<ILogicSys>();
|
||||
RegisterAllSystem();
|
||||
InitSystemSetting();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置一些通用的系统属性。
|
||||
/// </summary>
|
||||
private void InitSystemSetting()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册所有逻辑系统
|
||||
/// </summary>
|
||||
private void RegisterAllSystem()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 注册逻辑系统。
|
||||
/// </summary>
|
||||
/// <param name="logicSys">ILogicSys</param>
|
||||
/// <returns></returns>
|
||||
protected bool AddLogicSys(ILogicSys logicSys)
|
||||
{
|
||||
|
||||
if (m_listLogicMgr.Contains(logicSys))
|
||||
{
|
||||
Log.Fatal("Repeat add logic system: {0}", logicSys.GetType().Name);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!logicSys.OnInit())
|
||||
{
|
||||
Log.Fatal("{0} Init failed", logicSys.GetType().Name);
|
||||
return false;
|
||||
}
|
||||
|
||||
m_listLogicMgr.Add(logicSys);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4703541a565f5ec4bb35edd81c28958c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
19
Assets/GameScripts/HotFix/GameLogic/GameLogic.asmdef
Normal file
19
Assets/GameScripts/HotFix/GameLogic/GameLogic.asmdef
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "GameLogic",
|
||||
"rootNamespace": "GameLogic",
|
||||
"references": [
|
||||
"GUID:b48be955427611241bcb6f2a07949c5b",
|
||||
"GUID:08c3762f54316454ca6b6fbcb22b40e5",
|
||||
"GUID:a90b2d3377c5e4a4db95cc44fb82045e",
|
||||
"GUID:aa06d4cc755c979489c256c1bcca1dfb"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acd6baa97ba40d3478c29cd9c76ff9e3
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user