mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
添加线程逻辑执行
This commit is contained in:
parent
77b305be7a
commit
bf7b5b1160
@ -90,6 +90,7 @@
|
||||
<Compile Include="Assets\JNGame\Map\DotRecast\Src\DotRecast.Detour.Dynamic\Io\DtVoxelFileReader.cs" />
|
||||
<Compile Include="Assets\JNGame\Plugins\Entitas\Entitas\src\Collector\CollectorContextExtension.cs" />
|
||||
<Compile Include="Assets\JNGame\Map\DotRecast\Src\DotRecast.Detour.TileCache\Io\DtTileCacheReader.cs" />
|
||||
<Compile Include="Assets\Scripts\Game\Logic\Entity\Nodes\Component\EDEntityComponent.cs" />
|
||||
<Compile Include="Assets\JNGame\Map\DotRecast\Src\DotRecast.Recast\RcAreas.cs" />
|
||||
<Compile Include="Assets\JNGame\Map\2DPathFinding\NavMesh\NavMesh\NavMeshData.cs" />
|
||||
<Compile Include="Assets\JNGame\Map\DotRecast\Src\DotRecast.Detour\BVItemYComparer.cs" />
|
||||
@ -477,6 +478,7 @@
|
||||
<Compile Include="Assets\Scripts\Game\Logic\Entity\Nodes\Contexts\EDBossContext.cs" />
|
||||
<Compile Include="Assets\JNGame\Map\DotRecast\Src\DotRecast.Detour.TileCache\DtTempContour.cs" />
|
||||
<Compile Include="Assets\JNGame\Map\2DPathFinding\BSP\ESplitType.cs" />
|
||||
<Compile Include="Assets\Scripts\Game\Logic\Entity\EDEntityBasis.cs" />
|
||||
<Compile Include="Assets\JNGame\Map\DotRecast\Src\DotRecast.Recast\RcHeightfieldLayer.cs" />
|
||||
<Compile Include="Assets\JNGame\Map\DotRecast\Src\DotRecast.Detour.TileCache\DtTileCacheLayer.cs" />
|
||||
<Compile Include="Assets\JNGame\Map\DotRecast\Src\DotRecast.Detour.Crowd\DtCrowdAgent.cs" />
|
||||
@ -701,8 +703,6 @@
|
||||
<Compile Include="Assets\JNGame\Map\DotRecast\Src\DotRecast.Core\IRcRand.cs" />
|
||||
<Compile Include="Assets\JNGame\Math\BaseType\LVector2.cs" />
|
||||
<Compile Include="Assets\JNGame\Plugins\Entitas\Entitas\src\Context\Context.cs" />
|
||||
<Compile Include="Assets\Scripts\Game\Logic\Entity\EDEntityBasis.cs" />
|
||||
<Compile Include="Assets\Scripts\Game\Logic\Entity\Nodes\Component\EDEntityComponent.cs" />
|
||||
<None Include="Assets\TextMesh Pro\Shaders\TMPro.cginc" />
|
||||
<None Include="Assets\TextMesh Pro\Shaders\TMP_SDF-Mobile Overlay.shader" />
|
||||
<None Include="Assets\Packages\Google.Protobuf.3.18.3\lib\netstandard2.0\Google.Protobuf.xml" />
|
||||
|
@ -72,7 +72,7 @@ namespace JNGame.Sync.Frame
|
||||
#endif
|
||||
if (!IsStart) return;
|
||||
base.Execute();
|
||||
int deltaTime = (int)(Time.deltaTime * 1000f);
|
||||
int deltaTime = TickTime;
|
||||
dtTotal += deltaTime;
|
||||
dtInputTotal += deltaTime;
|
||||
|
||||
|
@ -35,7 +35,7 @@ namespace JNGame.Sync.State
|
||||
#endif
|
||||
if (!IsStart) return;
|
||||
base.Execute();
|
||||
dtTime += (int)(Time.deltaTime * 1000);
|
||||
dtTime += TickTime;
|
||||
if (DeltaTime <= dtTime)
|
||||
{
|
||||
dtTime -= DeltaTime;
|
||||
|
@ -37,7 +37,7 @@ namespace JNGame.Sync.State
|
||||
#endif
|
||||
if (!IsStart) return;
|
||||
base.Execute();
|
||||
dtTime += (int)(Time.deltaTime * 1000);
|
||||
dtTime += TickTime;
|
||||
if (DeltaTime <= dtTime)
|
||||
{
|
||||
dtTime -= DeltaTime;
|
||||
|
@ -1,12 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Entitas;
|
||||
using JNGame.Sync.Entity;
|
||||
using JNGame.Sync.Frame.Entity;
|
||||
using JNGame.Sync.Frame.Service;
|
||||
using JNGame.Sync.System;
|
||||
using JNGame.Sync.System.View;
|
||||
using JNGame.Util;
|
||||
using UnityEngine;
|
||||
|
||||
namespace JNGame.Sync.Frame
|
||||
@ -21,6 +24,11 @@ namespace JNGame.Sync.Frame
|
||||
|
||||
public abstract bool IsStartGame { get; }
|
||||
|
||||
private Thread thread;
|
||||
|
||||
//执行时间
|
||||
protected int TickTime;
|
||||
|
||||
|
||||
public JNSyncDefaultService() : base()
|
||||
{
|
||||
@ -52,6 +60,13 @@ namespace JNGame.Sync.Frame
|
||||
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
base.Cleanup();
|
||||
thread?.Abort();
|
||||
thread = null;
|
||||
}
|
||||
|
||||
public override Systems Add(ISystem system)
|
||||
{
|
||||
(system as SLogicSystem)?.OnSyncStart();
|
||||
@ -85,7 +100,7 @@ namespace JNGame.Sync.Frame
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动更新视图帧
|
||||
/// 更新(不可在外部调用)
|
||||
/// </summary>
|
||||
public override void Execute()
|
||||
{
|
||||
@ -93,10 +108,45 @@ namespace JNGame.Sync.Frame
|
||||
#if (!ENTITAS_DISABLE_VISUAL_DEBUGGING && UNITY_EDITOR)
|
||||
if (paused) return;
|
||||
#endif
|
||||
base.Execute();
|
||||
UnityMainThreadDispatcher.Instance.Enqueue(base.Execute);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Unity主线程更新
|
||||
/// </summary>
|
||||
/// <param name="ms"></param>
|
||||
public void MExecute(int ms = -1)
|
||||
{
|
||||
if (ms <= -1) ms = (int)Time.deltaTime * 1000;
|
||||
TickTime = ms;
|
||||
Execute();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 线程更新
|
||||
/// </summary>
|
||||
public void TStartExecute(int ms = -1)
|
||||
{
|
||||
if (ms <= -1) ms = DeltaTime;
|
||||
|
||||
thread = new Thread(() =>
|
||||
{
|
||||
while (thread.ThreadState != ThreadState.Aborted)
|
||||
{
|
||||
Thread.Sleep(ms);
|
||||
TickTime = ms;
|
||||
Execute();
|
||||
}
|
||||
});
|
||||
thread.Start();
|
||||
}
|
||||
public void TStopExecute()
|
||||
{
|
||||
thread?.Abort();
|
||||
thread = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 推逻辑帧
|
||||
/// </summary>
|
||||
|
@ -27,7 +27,7 @@ namespace JNGame.Sync.System
|
||||
{
|
||||
}
|
||||
|
||||
public void OnSyncDestroy(){}
|
||||
public virtual void OnSyncDestroy(){}
|
||||
|
||||
}
|
||||
}
|
@ -33,11 +33,6 @@ public class DApplication : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
App.Game.Update();
|
||||
}
|
||||
|
||||
public void OnClickPlayerCreate()
|
||||
{
|
||||
var input = App.Game.GetInput<IDWorld>();
|
||||
|
@ -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>
|
||||
|
@ -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()
|
||||
|
2362
JNFrame2/Logs/AssetImportWorker0.log
Normal file
2362
JNFrame2/Logs/AssetImportWorker0.log
Normal file
File diff suppressed because it is too large
Load Diff
2354
JNFrame2/Logs/AssetImportWorker1.log
Normal file
2354
JNFrame2/Logs/AssetImportWorker1.log
Normal file
File diff suppressed because it is too large
Load Diff
6
JNFrame2/Logs/shadercompiler-AssetImportWorker0.log
Normal file
6
JNFrame2/Logs/shadercompiler-AssetImportWorker0.log
Normal file
@ -0,0 +1,6 @@
|
||||
Base path: 'D:/Unity/2021.3.35f1/Editor/Data', plugins path 'D:/Unity/2021.3.35f1/Editor/Data/PlaybackEngines'
|
||||
Cmd: initializeCompiler
|
||||
|
||||
Unhandled exception: Protocol error - failed to read magic number. Error code 0x80000004 (Not connected). (transferred 0/4)
|
||||
|
||||
Quitting shader compiler process
|
@ -119,7 +119,7 @@ MonoBehaviour:
|
||||
m_MinSize: {x: 400, y: 200}
|
||||
m_MaxSize: {x: 32384, y: 16192}
|
||||
vertical: 0
|
||||
controlID: 144
|
||||
controlID: 39
|
||||
--- !u!114 &6
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 52
|
||||
@ -144,7 +144,7 @@ MonoBehaviour:
|
||||
m_MinSize: {x: 300, y: 200}
|
||||
m_MaxSize: {x: 24288, y: 16192}
|
||||
vertical: 1
|
||||
controlID: 23
|
||||
controlID: 67
|
||||
--- !u!114 &7
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 52
|
||||
@ -170,7 +170,7 @@ MonoBehaviour:
|
||||
m_MinSize: {x: 300, y: 100}
|
||||
m_MaxSize: {x: 24288, y: 8096}
|
||||
vertical: 0
|
||||
controlID: 24
|
||||
controlID: 104
|
||||
--- !u!114 &8
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 52
|
||||
@ -394,9 +394,9 @@ MonoBehaviour:
|
||||
m_SceneHierarchy:
|
||||
m_TreeViewState:
|
||||
scrollPos: {x: 0, y: 0}
|
||||
m_SelectedIDs:
|
||||
m_SelectedIDs: c84a0000
|
||||
m_LastClickedID: 0
|
||||
m_ExpandedIDs: e6caffff3ccbfffffacdfffffecdffff30d2ffff86d2ffff48d5ffff50d5ffff7ad8ffff16fbffff5c730000
|
||||
m_ExpandedIDs: 16fbffff
|
||||
m_RenameOverlay:
|
||||
m_UserAcceptedRename: 0
|
||||
m_Name:
|
||||
@ -729,14 +729,14 @@ MonoBehaviour:
|
||||
m_OverrideSceneCullingMask: 6917529027641081856
|
||||
m_SceneIsLit: 1
|
||||
m_SceneLighting: 1
|
||||
m_2DMode: 1
|
||||
m_2DMode: 0
|
||||
m_isRotationLocked: 0
|
||||
m_PlayAudio: 0
|
||||
m_AudioPlay: 0
|
||||
m_Position:
|
||||
m_Target: {x: 364.1633, y: 146.86098, z: -12.584361}
|
||||
m_Target: {x: 40.998676, y: 35.7221, z: -22.265503}
|
||||
speed: 2
|
||||
m_Value: {x: 364.1633, y: 146.86098, z: -12.584361}
|
||||
m_Value: {x: 40.998676, y: 35.7221, z: -22.265503}
|
||||
m_RenderMode: 0
|
||||
m_CameraMode:
|
||||
drawMode: 0
|
||||
@ -765,17 +765,17 @@ MonoBehaviour:
|
||||
m_Size: {x: 0, y: 0}
|
||||
yGrid:
|
||||
m_Fade:
|
||||
m_Target: 0
|
||||
m_Target: 1
|
||||
speed: 2
|
||||
m_Value: 0
|
||||
m_Value: 1
|
||||
m_Color: {r: 0.5, g: 0.5, b: 0.5, a: 0.4}
|
||||
m_Pivot: {x: 0, y: 0, z: 0}
|
||||
m_Size: {x: 1, y: 1}
|
||||
zGrid:
|
||||
m_Fade:
|
||||
m_Target: 1
|
||||
m_Target: 0
|
||||
speed: 2
|
||||
m_Value: 1
|
||||
m_Value: 0
|
||||
m_Color: {r: 0.5, g: 0.5, b: 0.5, a: 0.4}
|
||||
m_Pivot: {x: 0, y: 0, z: 0}
|
||||
m_Size: {x: 1, y: 1}
|
||||
@ -783,17 +783,17 @@ MonoBehaviour:
|
||||
m_GridAxis: 1
|
||||
m_gridOpacity: 0.5
|
||||
m_Rotation:
|
||||
m_Target: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_Target: {x: -0.30956468, y: -0.05644073, z: 0.018410673, w: -0.9490255}
|
||||
speed: 2
|
||||
m_Value: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_Value: {x: -0.30956405, y: -0.056440614, z: 0.018410636, w: -0.9490236}
|
||||
m_Size:
|
||||
m_Target: 238.86409
|
||||
m_Target: 2.598076
|
||||
speed: 2
|
||||
m_Value: 238.86409
|
||||
m_Value: 2.598076
|
||||
m_Ortho:
|
||||
m_Target: 1
|
||||
m_Target: 0
|
||||
speed: 2
|
||||
m_Value: 1
|
||||
m_Value: 0
|
||||
m_CameraSettings:
|
||||
m_Speed: 1
|
||||
m_SpeedNormalized: 0.5
|
||||
@ -883,23 +883,23 @@ MonoBehaviour:
|
||||
m_SkipHidden: 0
|
||||
m_SearchArea: 1
|
||||
m_Folders:
|
||||
- Assets/Scenes
|
||||
- Assets/JNGame
|
||||
m_Globs: []
|
||||
m_OriginalText:
|
||||
m_FilterByTypeIntersection: 0
|
||||
m_ViewMode: 1
|
||||
m_StartGridSize: 96
|
||||
m_LastFolders:
|
||||
- Assets/Scenes
|
||||
- Assets/JNGame
|
||||
m_LastFoldersGridSize: 96
|
||||
m_LastProjectPath: D:\myproject\JisolGame\JNFrame2
|
||||
m_LockTracker:
|
||||
m_IsLocked: 0
|
||||
m_FolderTreeState:
|
||||
scrollPos: {x: 0, y: 0}
|
||||
m_SelectedIDs: 4e750000
|
||||
m_LastClickedID: 30030
|
||||
m_ExpandedIDs: 00000000d0740000d2740000d4740000d6740000d8740000da740000dc740000de740000e0740000e2740000e4740000e6740000e8740000ea740000ec74000000ca9a3bffffff7f
|
||||
m_SelectedIDs: 84740000
|
||||
m_LastClickedID: 29828
|
||||
m_ExpandedIDs: 000000000a7400000c7400000e74000010740000127400001474000016740000187400001a7400001c7400001e7400002074000022740000247400002674000000ca9a3bffffff7f
|
||||
m_RenameOverlay:
|
||||
m_UserAcceptedRename: 0
|
||||
m_Name:
|
||||
@ -927,7 +927,7 @@ MonoBehaviour:
|
||||
scrollPos: {x: 0, y: 0}
|
||||
m_SelectedIDs:
|
||||
m_LastClickedID: 0
|
||||
m_ExpandedIDs: 00000000d0740000d2740000d4740000d6740000d8740000da740000dc740000de740000e0740000e2740000e4740000e6740000e8740000ea740000ec740000
|
||||
m_ExpandedIDs: 000000000a7400000c7400000e74000010740000127400001474000016740000187400001a7400001c7400001e74000020740000227400002474000026740000
|
||||
m_RenameOverlay:
|
||||
m_UserAcceptedRename: 0
|
||||
m_Name:
|
||||
@ -952,8 +952,8 @@ MonoBehaviour:
|
||||
m_Icon: {fileID: 0}
|
||||
m_ResourceFile:
|
||||
m_ListAreaState:
|
||||
m_SelectedInstanceIDs: 7a750000
|
||||
m_LastClickedInstanceID: 30074
|
||||
m_SelectedInstanceIDs: c84a0000
|
||||
m_LastClickedInstanceID: 19144
|
||||
m_HadKeyboardFocusLastEvent: 1
|
||||
m_ExpandedInstanceIDs: c623000000000000
|
||||
m_RenameOverlay:
|
||||
|
Loading…
x
Reference in New Issue
Block a user