临时提交

This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2024-10-19 03:51:59 +08:00
parent 425f2eabea
commit 1315802fa2
162 changed files with 16452 additions and 11111 deletions

View File

@@ -76,52 +76,44 @@ namespace JNGame.Sync.Frame
int deltaTime = TickTime;
dtTotal += deltaTime;
dtInputTotal += deltaTime;
try
int nSyncTime = this.DyTime();
if (nSyncTime > 0)
{
int nSyncTime = this.DyTime();
if (nSyncTime > 0)
this._isLoop = false;
if (dtTotal > nSyncTime && _nFrameQueue.Count > 0)
{
this._isLoop = false;
if (dtTotal > nSyncTime && _nFrameQueue.Count > 0)
{
this.OnRunSimulate();
dtTotal -= nSyncTime;
}
if (_nFrameQueue.Count <= 0)
{
dtTotal = 0;
}
this.OnRunSimulate();
dtTotal -= nSyncTime;
}
else
if (_nFrameQueue.Count <= 0)
{
this._isLoop = true;
//追帧运行 保持前端 15 帧 刷新
long endTime = (new DateTimeOffset(DateTime.UtcNow)).ToUnixTimeMilliseconds() + 100;
while (this.DyTime() == 0 && ((new DateTimeOffset(DateTime.UtcNow)).ToUnixTimeMilliseconds()) < endTime)
{
this.OnRunSimulate();
}
dtTotal = 0;
}
//更新输入
if (dtInputTotal > (_nSyncTime / _nDivideFrame))
{
dtInputTotal = 0;
OnRunInput();
}
}
catch (Exception e)
else
{
Debug.LogError(e.Message);
this._isLoop = true;
//追帧运行 保持前端 15 帧 刷新
long endTime = (new DateTimeOffset(DateTime.UtcNow)).ToUnixTimeMilliseconds() + 100;
while (this.DyTime() == 0 && ((new DateTimeOffset(DateTime.UtcNow)).ToUnixTimeMilliseconds()) < endTime)
{
this.OnRunSimulate();
}
dtTotal = 0;
}
//更新输入
if (dtInputTotal > (_nSyncTime / _nDivideFrame))
{
dtInputTotal = 0;
OnRunInput();
}

View File

@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using JNGame.Sync.Entity;
using System.Collections.Generic;
using JNGame.Sync.Frame.Entity;
using JNGame.Sync.Frame.Entity.Components;
using UnityEngine;
namespace JNGame.Sync.State.Tile.Entity

View File

@@ -1,6 +1,5 @@
using JNGame.Sync.Entity;
using JNGame.Sync.Frame.Entity;
using JNGame.Sync.Frame.Entity.Components;
using JNGame.Sync.State.Tile.Entity.Component;
using JNGame.Sync.System.Data;
using NotImplementedException = System.NotImplementedException;

View File

@@ -1,7 +1,5 @@
using Entitas;
using JNGame.Math;
using JNGame.Math;
using JNGame.Sync.Entity.Component;
using JNGame.Sync.Frame.Entity.Components;
namespace JNGame.Sync.Frame.Entity.Component.Components
{

View File

@@ -4,7 +4,7 @@ using System;
using Entitas;
using JNGame.Runtime.Util.Types;
namespace JNGame.Sync.Frame.Entity.Components
namespace JNGame.Sync.Entity.Component
{
public class JNEntityLookup : JNLookup
{

View File

@@ -3,8 +3,8 @@ using System.Collections.Generic;
using Entitas;
using JNGame.Runtime.Sync;
using JNGame.Sync.Entity;
using JNGame.Sync.Entity.Component;
using JNGame.Sync.Frame.Entity.Component.Components;
using JNGame.Sync.Frame.Entity.Components;
using JNGame.Sync.System;
namespace JNGame.Sync.Frame.Entity

View File

@@ -3,7 +3,6 @@ using JNGame.Math;
using JNGame.Sync.Entity.Component;
using JNGame.Sync.Frame.Entity;
using JNGame.Sync.Frame.Entity.Component.Components;
using JNGame.Sync.Frame.Entity.Components;
using JNGame.Sync.Frame.Service;
using JNGame.Sync.System;

View File

@@ -18,11 +18,19 @@ namespace JNGame.Runtime.Sync
public JNContexts Contexts;
/// <summary>
/// 是否开始游戏
/// </summary>
public abstract bool IsStartGame { get; }
/// <summary>
/// 子线程
/// </summary>
private Thread thread;
//执行时间
/// <summary>
/// 执行时间
/// </summary>
protected int TickTime;
@@ -114,7 +122,7 @@ namespace JNGame.Runtime.Sync
/// <param name="ms"></param>
public void MExecute(int ms = -1)
{
if (ms <= -1) ms = (int)Time.deltaTime * 1000;
if (ms <= -1) ms = (int)(Time.deltaTime * 1000);
TickTime = ms;
Execute();
}
@@ -129,11 +137,11 @@ namespace JNGame.Runtime.Sync
thread = new Thread(() =>
{
while (thread.ThreadState != ThreadState.Aborted)
while (thread is not null && thread.ThreadState != ThreadState.Aborted)
{
Thread.Sleep(ms);
TickTime = ms;
Execute();
if(thread is not null) Execute();
}
});
thread.Start();
@@ -147,7 +155,7 @@ namespace JNGame.Runtime.Sync
/// <summary>
/// 推逻辑帧
/// </summary>
public void Simulate()
protected virtual void Simulate()
{
#if (!ENTITAS_DISABLE_VISUAL_DEBUGGING && UNITY_EDITOR)

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 5ac3500978fa4ddea0bc31deeeb97fc8
timeCreated: 1729277104

View File

@@ -0,0 +1,46 @@
using System;
using JNGame.Math;
using UnityEngine;
namespace JNGame.Sync.System.Data.Type
{
[Serializable]
public class DValuePosition
{
public long x;
public long y;
public long z;
public Vector3 ToVector3()
{
return new Vector3()
{
x = new LFloat(true,x).ToFloat(),
y = new LFloat(true,y).ToFloat(),
z = new LFloat(true,z).ToFloat(),
};
}
public override bool Equals(object obj)
{
if (obj is not DValuePosition old) return false;
return old.x == x && old.y == y && old.z == z;
}
public LVector3 ToLVector3()
{
return new LVector3(new LFloat(true,x), new LFloat(true,y), new LFloat(true,z));
}
public static DValuePosition Build(LVector3 vec3)
{
return new DValuePosition()
{
x = vec3.x.rawValue,
y = vec3.y.rawValue,
z = vec3.z.rawValue,
};
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 61dc0f629c2e4039b3d0a3a09a6dd9e4
timeCreated: 1729277108

View File

@@ -0,0 +1,24 @@
using GAS.Runtime;
using JNGame.Sync.System;
namespace JNGame.Runtime.Sync.System.Logic
{
/// <summary>
/// GAS 系统
/// </summary>
public class JNGASSystem : SLogicSystem
{
/// <summary>
/// GAS 管理器
/// </summary>
private JexGasManager _gas = new JexGasManager();
public JexGasManager GAS => _gas;
public override void OnSyncStart()
{
base.OnSyncStart();
}
}
}

View File

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: a2ad6a2528004e829e468bd37c84b181
timeCreated: 1729280850

View File

@@ -132,7 +132,7 @@ namespace JNGame.Sync.System.View
/// </summary>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public T Input<T>() where T : JNInputBase,new()
public T UIInput<T>() where T : JNInputBase,new()
{
lock (UIInputs)
{
@@ -145,10 +145,10 @@ namespace JNGame.Sync.System.View
}
/// <summary>
/// 移出输入
/// 移出 UI 输入
/// </summary>
/// <returns></returns>
public JNFrameInputs Dequeue()
public JNFrameInputs UIInputDequeue()
{
lock (UIInputs)
{
@@ -169,7 +169,7 @@ namespace JNGame.Sync.System.View
/// <summary>
/// 移入输入
/// </summary>
public void UpdateSInputs()
private void UpdateSInputs()
{
SInputs.Clear();

View File

@@ -49,13 +49,6 @@ namespace JNGame.Sync.System
//数据集
public ConcurrentDictionary<ulong, T> Data = new();
public virtual T[] Datas {
get
{
return Data.Values.ToArray();
}
}
public override void OnSyncStart()
{
//设置数据唯一Id

View File

@@ -3,7 +3,7 @@
namespace JNGame.Sync.System
{
/// <summary>
/// 帧同步 - 视图系统
/// 视图系统
/// </summary>
public class SViewSystem : SBaseSystem,IJNSyncCycle,IExecuteSystem
{

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Collections.Generic;
using JNGame.Sync.System;
using UnityEngine;
@@ -29,9 +30,9 @@ namespace JNGame.Sync.View
{
Update++;
var dataList = GetData();
bool isRest = dataList.Length != views.Count;
var dataList = GetData().Values;
bool isRest = dataList.Count != views.Count;
foreach (var data in dataList){
@@ -68,7 +69,7 @@ namespace JNGame.Sync.View
}
public abstract void ViewUpdate(T data,GameObject view);
public abstract GameObject NewView(T data);
public abstract T[] GetData();
public abstract ConcurrentDictionary<ulong, T> GetData();
public abstract void ViewRemove(GameObject view);