添加线程逻辑执行

This commit is contained in:
PC-20230316NUNE\Administrator
2024-09-12 18:06:22 +08:00
parent 77b305be7a
commit bf7b5b1160
13 changed files with 4818 additions and 49 deletions

View File

@@ -33,11 +33,6 @@ public class DApplication : MonoBehaviour
}
private void Update()
{
App.Game.Update();
}
public void OnClickPlayerCreate()
{
var input = App.Game.GetInput<IDWorld>();

View File

@@ -26,6 +26,13 @@ namespace AppGame.Systems
}
public override void OnClose()
{
base.OnClose();
client?.Dispose();
server?.Dispose();
}
/// <summary>
/// 运行同步类
/// </summary>
@@ -33,24 +40,17 @@ namespace AppGame.Systems
{
client = new T();
client.Initialize();
client.TStartExecute();
return client as T;
}
public T StartServer<T>() where T : JNSStateServerService,new()
{
server = new T();
server.Initialize();
server.TStartExecute();
return server as T;
}
/// <summary>
/// 更新周期
/// </summary>
public void Update()
{
client?.Execute();
server?.Execute();
}
/// <summary>
/// 获取第一个客户端的输入类
/// </summary>

View File

@@ -1,6 +1,7 @@
using Game.JNGFrame.View.Entity;
using JNGame.Sync.System;
using JNGame.Sync.View;
using JNGame.Util;
namespace Game.JNGFrame.View
{
@@ -23,7 +24,8 @@ namespace Game.JNGFrame.View
base.OnSyncUpdate(dt);
foreach (var view in views)
{
view.Execute();
//视图逻辑交给主线程运行
UnityMainThreadDispatcher.Instance.Enqueue(view.Execute);
}
}
// public override void Execute()