mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 03:14:47 +00:00
提交无缝数据回滚
This commit is contained in:
parent
8932528f5e
commit
77db4d7d71
@ -23,11 +23,11 @@ namespace JNGame.Map.DotRecast
|
|||||||
|
|
||||||
//智能体避障
|
//智能体避障
|
||||||
public DtCrowd Crowd { private set; get; }
|
public DtCrowd Crowd { private set; get; }
|
||||||
private Dictionary<long, DtCrowdAgent> agents;
|
private Dictionary<ulong, DtCrowdAgent> agents;
|
||||||
|
|
||||||
public DotRecastRoot(MeshData data)
|
public DotRecastRoot(MeshData data)
|
||||||
{
|
{
|
||||||
agents = new Dictionary<long, DtCrowdAgent>();
|
agents = new Dictionary<ulong, DtCrowdAgent>();
|
||||||
//初始化导航数据
|
//初始化导航数据
|
||||||
InitNavMesh(data);
|
InitNavMesh(data);
|
||||||
//初始化避障数据
|
//初始化避障数据
|
||||||
@ -103,17 +103,19 @@ namespace JNGame.Map.DotRecast
|
|||||||
}
|
}
|
||||||
|
|
||||||
//添加避障
|
//添加避障
|
||||||
public void AddAgent(long id,RcVec3f start)
|
public void AddAgent(ulong id,RcVec3f start)
|
||||||
{
|
{
|
||||||
|
DelAgent(id);
|
||||||
agents.Add(id,Crowd.AddAgent(start, GetAgentParams()));
|
agents.Add(id,Crowd.AddAgent(start, GetAgentParams()));
|
||||||
}
|
}
|
||||||
public void AddAgent(long id,RcVec3f start,DtCrowdAgentParams agentParams)
|
public void AddAgent(ulong id,RcVec3f start,DtCrowdAgentParams agentParams)
|
||||||
{
|
{
|
||||||
|
DelAgent(id);
|
||||||
agents.Add(id,Crowd.AddAgent(start, agentParams));
|
agents.Add(id,Crowd.AddAgent(start, agentParams));
|
||||||
}
|
}
|
||||||
|
|
||||||
//添加避障
|
//添加避障
|
||||||
public void DelAgent(long id)
|
public void DelAgent(ulong id)
|
||||||
{
|
{
|
||||||
if (agents.ContainsKey(id))
|
if (agents.ContainsKey(id))
|
||||||
{
|
{
|
||||||
@ -123,7 +125,7 @@ namespace JNGame.Map.DotRecast
|
|||||||
}
|
}
|
||||||
|
|
||||||
//移动避障
|
//移动避障
|
||||||
public void MoveAgent(long id,RcVec3f move)
|
public void MoveAgent(ulong id,RcVec3f move)
|
||||||
{
|
{
|
||||||
|
|
||||||
DtCrowdAgent agent = agents[id];
|
DtCrowdAgent agent = agents[id];
|
||||||
@ -133,14 +135,14 @@ namespace JNGame.Map.DotRecast
|
|||||||
}
|
}
|
||||||
|
|
||||||
//向量移动避障
|
//向量移动避障
|
||||||
public void VectorMoveAgent(long id,RcVec3f vector)
|
public void VectorMoveAgent(ulong id,RcVec3f vector)
|
||||||
{
|
{
|
||||||
DtCrowdAgent agent = agents[id];
|
DtCrowdAgent agent = agents[id];
|
||||||
Crowd.RequestMoveVelocity(agent,vector);
|
Crowd.RequestMoveVelocity(agent,vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取避障
|
//获取避障
|
||||||
public DtCrowdAgent GetAgent(long id)
|
public DtCrowdAgent GetAgent(ulong id)
|
||||||
{
|
{
|
||||||
return agents[id];
|
return agents[id];
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ public static partial class JNSyncMessageReflection {
|
|||||||
"SACIAQFCCgoIX21lc3NhZ2UiKQoLSk5TdGF0ZURhdGESEQoEZGF0YRgCIAEo",
|
"SACIAQFCCgoIX21lc3NhZ2UiKQoLSk5TdGF0ZURhdGESEQoEZGF0YRgCIAEo",
|
||||||
"DEgAiAEBQgcKBV9kYXRhIpEBCg9KTlN0YXRlSXRlbURhdGESDQoFTmV0SUQY",
|
"DEgAiAEBQgcKBV9kYXRhIpEBCg9KTlN0YXRlSXRlbURhdGESDQoFTmV0SUQY",
|
||||||
"ASABKAUSMAoIbWVzc2FnZXMYAiADKAsyHi5KTlN0YXRlSXRlbURhdGEuTWVz",
|
"ASABKAUSMAoIbWVzc2FnZXMYAiADKAsyHi5KTlN0YXRlSXRlbURhdGEuTWVz",
|
||||||
"c2FnZXNFbnRyeRo9Cg1NZXNzYWdlc0VudHJ5EgsKA2tleRgBIAEoAxIbCgV2",
|
"c2FnZXNFbnRyeRo9Cg1NZXNzYWdlc0VudHJ5EgsKA2tleRgBIAEoBBIbCgV2",
|
||||||
"YWx1ZRgCIAEoCzIMLkpOU3RhdGVEYXRhOgI4ASIwCg5KTlN0YXRlQWxsRGF0",
|
"YWx1ZRgCIAEoCzIMLkpOU3RhdGVEYXRhOgI4ASIwCg5KTlN0YXRlQWxsRGF0",
|
||||||
"YRIeCgRkYXRhGAIgAygLMhAuSk5TdGF0ZUl0ZW1EYXRhIkEKEUpOU3RhdGVU",
|
"YRIeCgRkYXRhGAIgAygLMhAuSk5TdGF0ZUl0ZW1EYXRhIkEKEUpOU3RhdGVU",
|
||||||
"aWxlSW5wdXRzEgsKA3RJZBgBIAEoBRIfCgdtZXNzYWdlGAIgASgLMg4uSk5G",
|
"aWxlSW5wdXRzEgsKA3RJZBgBIAEoBRIfCgdtZXNzYWdlGAIgASgLMg4uSk5G",
|
||||||
@ -1813,15 +1813,15 @@ public sealed partial class JNStateItemData : pb::IMessage<JNStateItemData>
|
|||||||
|
|
||||||
/// <summary>Field number for the "messages" field.</summary>
|
/// <summary>Field number for the "messages" field.</summary>
|
||||||
public const int MessagesFieldNumber = 2;
|
public const int MessagesFieldNumber = 2;
|
||||||
private static readonly pbc::MapField<long, global::JNStateData>.Codec _map_messages_codec
|
private static readonly pbc::MapField<ulong, global::JNStateData>.Codec _map_messages_codec
|
||||||
= new pbc::MapField<long, global::JNStateData>.Codec(pb::FieldCodec.ForInt64(8, 0L), pb::FieldCodec.ForMessage(18, global::JNStateData.Parser), 18);
|
= new pbc::MapField<ulong, global::JNStateData>.Codec(pb::FieldCodec.ForUInt64(8, 0UL), pb::FieldCodec.ForMessage(18, global::JNStateData.Parser), 18);
|
||||||
private readonly pbc::MapField<long, global::JNStateData> messages_ = new pbc::MapField<long, global::JNStateData>();
|
private readonly pbc::MapField<ulong, global::JNStateData> messages_ = new pbc::MapField<ulong, global::JNStateData>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///状态bytes
|
///状态bytes
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||||
public pbc::MapField<long, global::JNStateData> Messages {
|
public pbc::MapField<ulong, global::JNStateData> Messages {
|
||||||
get { return messages_; }
|
get { return messages_; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ message JNStateData{
|
|||||||
// 更新状态
|
// 更新状态
|
||||||
message JNStateItemData{
|
message JNStateItemData{
|
||||||
int32 NetID = 1; //同步Id
|
int32 NetID = 1; //同步Id
|
||||||
map<int64 ,JNStateData> messages = 2; //状态bytes
|
map<uint64 ,JNStateData> messages = 2; //状态bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
// 全量状态
|
// 全量状态
|
||||||
|
@ -43,7 +43,7 @@ namespace JNGame.Sync.State.Tile.Entity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public T TileSyncCreate(long id)
|
public T TileSyncCreate(ulong id)
|
||||||
{
|
{
|
||||||
|
|
||||||
//判断是否有这个Id实体
|
//判断是否有这个Id实体
|
||||||
|
@ -32,6 +32,11 @@ namespace JNGame.Sync.State.Tile
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public int TID { get; private set; }
|
public int TID { get; private set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 随机数大小(100000000000UL * RandomSize)
|
||||||
|
/// </summary>
|
||||||
|
public int RandomSize { get; protected set; } = 1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 区块最大最小位置
|
/// 区块最大最小位置
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -70,7 +75,7 @@ namespace JNGame.Sync.State.Tile
|
|||||||
{
|
{
|
||||||
//根据区块设置Id 起始值
|
//根据区块设置Id 起始值
|
||||||
var random = base.CreateRandom();
|
var random = base.CreateRandom();
|
||||||
random.SetIdValue(100000000000L * TID,(100000000000L * (TID + 1) - 1));
|
random.SetIdValue(100000000000UL * (ulong)RandomSize,(100000000000UL * ((ulong)RandomSize + 1) - 1));
|
||||||
return random;
|
return random;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,8 +33,8 @@ namespace JNGame.Sync.Entity
|
|||||||
public abstract class JNEntity : Entitas.Entity,IJNEntity,IComparable
|
public abstract class JNEntity : Entitas.Entity,IJNEntity,IComparable
|
||||||
{
|
{
|
||||||
|
|
||||||
private long _id;
|
private ulong _id;
|
||||||
public long Id => _id;
|
public ulong Id => _id;
|
||||||
|
|
||||||
public IJNContext Context { get; private set; }
|
public IJNContext Context { get; private set; }
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ namespace JNGame.Sync.Entity
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public LVector3 Position => Transform.Position;
|
public LVector3 Position => Transform.Position;
|
||||||
|
|
||||||
public void OnInit(IJNContext context,long id = 0)
|
public void OnInit(IJNContext context,ulong id = 0)
|
||||||
{
|
{
|
||||||
Context = context;
|
Context = context;
|
||||||
_id = id;
|
_id = id;
|
||||||
@ -58,10 +58,6 @@ namespace JNGame.Sync.Entity
|
|||||||
{
|
{
|
||||||
_id = GetSystem<JNRandomSystem>().NextId();
|
_id = GetSystem<JNRandomSystem>().NextId();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
GetSystem<JNRandomSystem>().AdaptId(id);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract JNEntityLookup NewCLookup();
|
public abstract JNEntityLookup NewCLookup();
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
public interface IJNSyncId
|
public interface IJNSyncId
|
||||||
{
|
{
|
||||||
|
|
||||||
public long Id { get; }
|
public ulong Id { get; }
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -45,12 +45,12 @@ namespace JNGame.Sync.System.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 插入字节
|
/// 插入字节
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public void OnInsertUBytes(Dictionary<long, byte[]> bytes);
|
public void OnInsertUBytes(Dictionary<ulong, byte[]> bytes);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取全部字节
|
/// 获取全部字节
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<long, byte[]> GetDataBytes();
|
public Dictionary<ulong, byte[]> GetDataBytes();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ namespace JNGame.Sync.System.Data
|
|||||||
public abstract int NetID { get; }
|
public abstract int NetID { get; }
|
||||||
|
|
||||||
//网络通讯的更新字节数据
|
//网络通讯的更新字节数据
|
||||||
protected Dictionary<long, byte[]> UBytes = new();
|
protected Dictionary<ulong, byte[]> UBytes = new();
|
||||||
|
|
||||||
public SStateDataEnum Type;
|
public SStateDataEnum Type;
|
||||||
|
|
||||||
@ -117,13 +117,13 @@ namespace JNGame.Sync.System.Data
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="bytes"></param>
|
/// <param name="bytes"></param>
|
||||||
/// <returns>是否清空UBytes</returns>
|
/// <returns>是否清空UBytes</returns>
|
||||||
public abstract void OnSendUBytes(Dictionary<long, byte[]> bytes);
|
public abstract void OnSendUBytes(Dictionary<ulong, byte[]> bytes);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 插入字节
|
/// 插入字节
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public void OnInsertUBytes(Dictionary<long, byte[]> bytes)
|
public void OnInsertUBytes(Dictionary<ulong, byte[]> bytes)
|
||||||
{
|
{
|
||||||
//提交数据更新
|
//提交数据更新
|
||||||
OnUByteUpdate(bytes);
|
OnUByteUpdate(bytes);
|
||||||
@ -132,9 +132,9 @@ namespace JNGame.Sync.System.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取全部字节
|
/// 获取全部字节
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<long, byte[]> GetDataBytes()
|
public Dictionary<ulong, byte[]> GetDataBytes()
|
||||||
{
|
{
|
||||||
var data = new Dictionary<long, byte[]>();
|
var data = new Dictionary<ulong, byte[]>();
|
||||||
|
|
||||||
lock (Data)
|
lock (Data)
|
||||||
{
|
{
|
||||||
@ -153,7 +153,7 @@ namespace JNGame.Sync.System.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 将UByte提交更新
|
/// 将UByte提交更新
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void OnUByteUpdate(Dictionary<long, byte[]> bytes)
|
public virtual void OnUByteUpdate(Dictionary<ulong, byte[]> bytes)
|
||||||
{
|
{
|
||||||
lock (Data)
|
lock (Data)
|
||||||
{
|
{
|
||||||
@ -187,7 +187,7 @@ namespace JNGame.Sync.System.Data
|
|||||||
/// <param name="id"></param>
|
/// <param name="id"></param>
|
||||||
/// <param name="bytes"></param>
|
/// <param name="bytes"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public T NewObject(long id,byte[] bytes)
|
public T NewObject(ulong id,byte[] bytes)
|
||||||
{
|
{
|
||||||
var data = new T();
|
var data = new T();
|
||||||
data.Id = id;
|
data.Id = id;
|
||||||
@ -225,7 +225,7 @@ namespace JNGame.Sync.System.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 删除数据
|
/// 删除数据
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void Delete(long id)
|
public virtual void Delete(ulong id)
|
||||||
{
|
{
|
||||||
UBytes[id] = SDByteOperate.DELETE;
|
UBytes[id] = SDByteOperate.DELETE;
|
||||||
}
|
}
|
||||||
|
@ -21,13 +21,13 @@ namespace JNGame.Sync.System.Data
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取有权限的全部字节
|
/// 获取有权限的全部字节
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<long, byte[]> GetHostDataBytes();
|
public Dictionary<ulong, byte[]> GetHostDataBytes();
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 获取指定区块的全部字节
|
/// 获取指定区块的全部字节
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Dictionary<long, byte[]> GetTileDataBytes(int index);
|
public Dictionary<ulong, byte[]> GetTileDataBytes(int index);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ namespace JNGame.Sync.System.Data
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnUByteUpdate(Dictionary<long, byte[]> bytes)
|
public override void OnUByteUpdate(Dictionary<ulong, byte[]> bytes)
|
||||||
{
|
{
|
||||||
base.OnUByteUpdate(bytes);
|
base.OnUByteUpdate(bytes);
|
||||||
if (isServer)
|
if (isServer)
|
||||||
@ -83,11 +83,11 @@ namespace JNGame.Sync.System.Data
|
|||||||
protected virtual void OnDataSyncContext()
|
protected virtual void OnDataSyncContext()
|
||||||
{
|
{
|
||||||
|
|
||||||
Dictionary<long, T> lIsTileData;
|
Dictionary<ulong, T> lIsTileData;
|
||||||
|
|
||||||
lock (Data)
|
lock (Data)
|
||||||
{
|
{
|
||||||
lIsTileData = new Dictionary<long, T>(Data);
|
lIsTileData = new Dictionary<ulong, T>(Data);
|
||||||
}
|
}
|
||||||
|
|
||||||
NodeContext.GetEntities().ForEach(child =>
|
NodeContext.GetEntities().ForEach(child =>
|
||||||
@ -155,7 +155,7 @@ namespace JNGame.Sync.System.Data
|
|||||||
{
|
{
|
||||||
|
|
||||||
//需要删除的数据Id
|
//需要删除的数据Id
|
||||||
var ids = new List<long>();
|
var ids = new List<ulong>();
|
||||||
|
|
||||||
Data.ForEach(child =>
|
Data.ForEach(child =>
|
||||||
{
|
{
|
||||||
@ -175,10 +175,10 @@ namespace JNGame.Sync.System.Data
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<long, byte[]> GetHostDataBytes()
|
public Dictionary<ulong, byte[]> GetHostDataBytes()
|
||||||
{
|
{
|
||||||
|
|
||||||
var data = new Dictionary<long, byte[]>();
|
var data = new Dictionary<ulong, byte[]>();
|
||||||
|
|
||||||
lock (Data)
|
lock (Data)
|
||||||
{
|
{
|
||||||
@ -195,10 +195,10 @@ namespace JNGame.Sync.System.Data
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dictionary<long, byte[]> GetTileDataBytes(int index)
|
public Dictionary<ulong, byte[]> GetTileDataBytes(int index)
|
||||||
{
|
{
|
||||||
|
|
||||||
var data = new Dictionary<long, byte[]>();
|
var data = new Dictionary<ulong, byte[]>();
|
||||||
|
|
||||||
lock (Data)
|
lock (Data)
|
||||||
{
|
{
|
||||||
|
@ -16,9 +16,9 @@ namespace JNGame.Sync.Frame.Service
|
|||||||
private Func<int,int,int> nRandomInt;
|
private Func<int,int,int> nRandomInt;
|
||||||
|
|
||||||
//Id
|
//Id
|
||||||
private long _id = 0;
|
private ulong _id = 0;
|
||||||
private long _idMin = long.MinValue;
|
private ulong _idMin = ulong.MinValue;
|
||||||
private long _idMax = long.MaxValue;
|
private ulong _idMax = ulong.MaxValue;
|
||||||
|
|
||||||
public JNRandomSystem(int seed)
|
public JNRandomSystem(int seed)
|
||||||
{
|
{
|
||||||
@ -41,12 +41,12 @@ namespace JNGame.Sync.Frame.Service
|
|||||||
return nRandomInt(max,min);
|
return nRandomInt(max,min);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long NextId()
|
public ulong NextId()
|
||||||
{
|
{
|
||||||
return ++_id;
|
return ++_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetIdValue(long min,long max)
|
public void SetIdValue(ulong min,ulong max)
|
||||||
{
|
{
|
||||||
if (_id < min)
|
if (_id < min)
|
||||||
{
|
{
|
||||||
@ -55,21 +55,5 @@ namespace JNGame.Sync.Frame.Service
|
|||||||
_idMin = min;
|
_idMin = min;
|
||||||
_idMax = max;
|
_idMax = max;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 适配Id 用于 历史Id和新Id重复问题
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="id"></param>
|
|
||||||
/// <exception cref="NotImplementedException"></exception>
|
|
||||||
public void AdaptId(long id)
|
|
||||||
{
|
|
||||||
if (_idMin <= id && id >= _idMax)
|
|
||||||
{
|
|
||||||
if (id > _id)
|
|
||||||
{
|
|
||||||
_id = id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -26,7 +26,7 @@ namespace JNGame.Sync.System
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 数据唯一Id
|
/// 数据唯一Id
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public long Id { get; set; }
|
public ulong Id { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 判断是否一样
|
/// 判断是否一样
|
||||||
@ -54,12 +54,12 @@ namespace JNGame.Sync.System
|
|||||||
{
|
{
|
||||||
|
|
||||||
//数据Id
|
//数据Id
|
||||||
public long Id { get; private set; }
|
public ulong Id { get; private set; }
|
||||||
|
|
||||||
public JNRandomSystem Random => GetSystem<JNRandomSystem>();
|
public JNRandomSystem Random => GetSystem<JNRandomSystem>();
|
||||||
|
|
||||||
//数据集
|
//数据集
|
||||||
public Dictionary<long, T> Data = new();
|
public Dictionary<ulong, T> Data = new();
|
||||||
|
|
||||||
public virtual T[] Datas {
|
public virtual T[] Datas {
|
||||||
get
|
get
|
||||||
@ -80,7 +80,7 @@ namespace JNGame.Sync.System
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 返回最新数据 (收集最新的ISData数据 正常来讲只有服务端会运行)
|
/// 返回最新数据 (收集最新的ISData数据 正常来讲只有服务端会运行)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual Dictionary<long, T> GetLatest()
|
public virtual Dictionary<ulong, T> GetLatest()
|
||||||
{
|
{
|
||||||
return new ();
|
return new ();
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@ namespace JNGame.Sync.System
|
|||||||
public class SLogicSystem : SBaseSystem,IJNSyncCycle,IJNSyncId
|
public class SLogicSystem : SBaseSystem,IJNSyncCycle,IJNSyncId
|
||||||
{
|
{
|
||||||
|
|
||||||
private long _id;
|
private ulong _id;
|
||||||
public long Id => _id;
|
public ulong Id => _id;
|
||||||
|
|
||||||
public virtual void OnSyncStart()
|
public virtual void OnSyncStart()
|
||||||
{
|
{
|
||||||
|
@ -17,7 +17,7 @@ namespace JNGame.Sync.View
|
|||||||
public abstract class ViewData<T> : IViewData where T : ISData
|
public abstract class ViewData<T> : IViewData where T : ISData
|
||||||
{
|
{
|
||||||
|
|
||||||
private Dictionary<long, ViewGameObject> views = new();
|
private Dictionary<ulong, ViewGameObject> views = new();
|
||||||
private SViewSystem root;
|
private SViewSystem root;
|
||||||
public SViewSystem Root => root;
|
public SViewSystem Root => root;
|
||||||
|
|
||||||
@ -53,7 +53,7 @@ namespace JNGame.Sync.View
|
|||||||
|
|
||||||
if (isRest)
|
if (isRest)
|
||||||
{
|
{
|
||||||
List<long> deletes = new List<long>();
|
List<ulong> deletes = new List<ulong>();
|
||||||
foreach (var child in views)
|
foreach (var child in views)
|
||||||
{
|
{
|
||||||
if (child.Value.Update != Update)
|
if (child.Value.Update != Update)
|
||||||
|
@ -20,6 +20,7 @@ namespace AppGame
|
|||||||
|
|
||||||
//获取ID
|
//获取ID
|
||||||
public UniTask<NewsContext<int>> NSyncTileId = App.API.GetNews<int>($"/sync/tile/id");
|
public UniTask<NewsContext<int>> NSyncTileId = App.API.GetNews<int>($"/sync/tile/id");
|
||||||
|
public UniTask<NewsContext<int>> NSyncTileRandomId = App.API.GetNews<int>($"/sync/tile/random/id");
|
||||||
//获取端口
|
//获取端口
|
||||||
public UniTask<NewsContext<int>> NSyncTilePort = App.API.GetNews<int>($"/sync/tile/port");
|
public UniTask<NewsContext<int>> NSyncTilePort = App.API.GetNews<int>($"/sync/tile/port");
|
||||||
//获取默认连接
|
//获取默认连接
|
||||||
|
@ -49,6 +49,8 @@ namespace AppGame.Sync
|
|||||||
protected override async Task OnInit()
|
protected override async Task OnInit()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
RandomSize = (await App.GAPI.NSyncTileRandomId).data;
|
||||||
|
|
||||||
await base.OnInit();
|
await base.OnInit();
|
||||||
|
|
||||||
if (isRecover)
|
if (isRecover)
|
||||||
@ -67,7 +69,7 @@ namespace AppGame.Sync
|
|||||||
{
|
{
|
||||||
Debug.Log("[JNGTileServerSystem] 获取到恢复数据成功 正在恢复数据");
|
Debug.Log("[JNGTileServerSystem] 获取到恢复数据成功 正在恢复数据");
|
||||||
|
|
||||||
var message = new Dictionary<long, byte[]>();
|
var message = new Dictionary<ulong, byte[]>();
|
||||||
tileInfo.Data.Data.ForEach(frame =>
|
tileInfo.Data.Data.ForEach(frame =>
|
||||||
{
|
{
|
||||||
message.Clear();
|
message.Clear();
|
||||||
|
@ -115,7 +115,7 @@ namespace AppGame.Systems
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void AddState(JNStateItemData frame)
|
public void AddState(JNStateItemData frame)
|
||||||
{
|
{
|
||||||
var message = new Dictionary<long, byte[]>();
|
var message = new Dictionary<ulong, byte[]>();
|
||||||
foreach (var data in frame.Messages)
|
foreach (var data in frame.Messages)
|
||||||
{
|
{
|
||||||
message.Add(data.Key,data.Value.Data.ToByteArray());
|
message.Add(data.Key,data.Value.Data.ToByteArray());
|
||||||
|
@ -45,9 +45,9 @@ namespace Game.JNGState.Logic.Data
|
|||||||
|
|
||||||
public override int NetID => (int)NetDataEnum.EDNodeData;
|
public override int NetID => (int)NetDataEnum.EDNodeData;
|
||||||
|
|
||||||
public override Dictionary<long, EDNodeData> GetLatest()
|
public override Dictionary<ulong, EDNodeData> GetLatest()
|
||||||
{
|
{
|
||||||
var nodes = new Dictionary<long, EDNodeData>();
|
var nodes = new Dictionary<ulong, EDNodeData>();
|
||||||
NodeContext.GetEntities().ForEach(child =>
|
NodeContext.GetEntities().ForEach(child =>
|
||||||
{
|
{
|
||||||
if (nodes.ContainsKey(child.Id))
|
if (nodes.ContainsKey(child.Id))
|
||||||
|
@ -70,9 +70,9 @@ namespace Game.JNGState.Logic.Data
|
|||||||
public override JNTileContext<EDPlayer> NodeContext => Contexts.GetContext<EDPlayerContext>();
|
public override JNTileContext<EDPlayer> NodeContext => Contexts.GetContext<EDPlayerContext>();
|
||||||
|
|
||||||
|
|
||||||
public override Dictionary<long, EDPlayerData> GetLatest()
|
public override Dictionary<ulong, EDPlayerData> GetLatest()
|
||||||
{
|
{
|
||||||
var nodes = new Dictionary<long, EDPlayerData>();
|
var nodes = new Dictionary<ulong, EDPlayerData>();
|
||||||
NodeContext.GetEntities().ForEach(child =>
|
NodeContext.GetEntities().ForEach(child =>
|
||||||
{
|
{
|
||||||
nodes.Add(child.Id,new EDPlayerData(child));
|
nodes.Add(child.Id,new EDPlayerData(child));
|
||||||
|
@ -110,7 +110,7 @@ namespace Game.JNGState.Logic.Data
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnSendUBytes(Dictionary<long, byte[]> bytes)
|
public override void OnSendUBytes(Dictionary<ulong, byte[]> bytes)
|
||||||
{
|
{
|
||||||
|
|
||||||
JNStateItemData data = new JNStateItemData();
|
JNStateItemData data = new JNStateItemData();
|
||||||
|
@ -70,35 +70,35 @@ namespace Game.JNGFrame.Logic.System
|
|||||||
}
|
}
|
||||||
|
|
||||||
//添加避障
|
//添加避障
|
||||||
public void AddAgent(long id,LVector3 start)
|
public void AddAgent(ulong id,LVector3 start)
|
||||||
{
|
{
|
||||||
Root.AddAgent(id,new RcVec3f(start.x,start.y,start.z));
|
Root.AddAgent(id,new RcVec3f(start.x,start.y,start.z));
|
||||||
}
|
}
|
||||||
public void AddAgent(long id,LVector3 start,DtCrowdAgentParams agentParams)
|
public void AddAgent(ulong id,LVector3 start,DtCrowdAgentParams agentParams)
|
||||||
{
|
{
|
||||||
Root.AddAgent(id,new RcVec3f(start.x,start.y,start.z),agentParams);
|
Root.AddAgent(id,new RcVec3f(start.x,start.y,start.z),agentParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
//删除避障
|
//删除避障
|
||||||
public void DelAgent(long id)
|
public void DelAgent(ulong id)
|
||||||
{
|
{
|
||||||
Root.DelAgent(id);
|
Root.DelAgent(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
//移动避障
|
//移动避障
|
||||||
public void MoveAgent(long id,LVector3 move)
|
public void MoveAgent(ulong id,LVector3 move)
|
||||||
{
|
{
|
||||||
Root.MoveAgent(id,new RcVec3f(move.x,move.y,move.z));
|
Root.MoveAgent(id,new RcVec3f(move.x,move.y,move.z));
|
||||||
}
|
}
|
||||||
|
|
||||||
//向量移动避障
|
//向量移动避障
|
||||||
public void VectorMoveAgent(long id,LVector2 vector)
|
public void VectorMoveAgent(ulong id,LVector2 vector)
|
||||||
{
|
{
|
||||||
Root.VectorMoveAgent(id,new RcVec3f(vector.x,0,vector.y));
|
Root.VectorMoveAgent(id,new RcVec3f(vector.x,0,vector.y));
|
||||||
}
|
}
|
||||||
|
|
||||||
//获取避障
|
//获取避障
|
||||||
public DtCrowdAgent GetAgent(long id)
|
public DtCrowdAgent GetAgent(ulong id)
|
||||||
{
|
{
|
||||||
return Root.GetAgent(id);
|
return Root.GetAgent(id);
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
Base path: 'D:/Unity/2021.3.35f1/Editor/Data', plugins path 'D:/Unity/2021.3.35f1/Editor/Data/PlaybackEngines'
|
Base path: 'D:/Unity/2021.3.35f1/Editor/Data', plugins path 'D:/Unity/2021.3.35f1/Editor/Data/PlaybackEngines'
|
||||||
Cmd: initializeCompiler
|
Cmd: initializeCompiler
|
||||||
|
|
||||||
|
Cmd: shutdown
|
||||||
|
@ -19,7 +19,7 @@ MonoBehaviour:
|
|||||||
width: 1920
|
width: 1920
|
||||||
height: 989
|
height: 989
|
||||||
m_ShowMode: 4
|
m_ShowMode: 4
|
||||||
m_Title: Game
|
m_Title: Inspector
|
||||||
m_RootView: {fileID: 2}
|
m_RootView: {fileID: 2}
|
||||||
m_MinSize: {x: 875, y: 300}
|
m_MinSize: {x: 875, y: 300}
|
||||||
m_MaxSize: {x: 10000, y: 10000}
|
m_MaxSize: {x: 10000, y: 10000}
|
||||||
@ -119,7 +119,7 @@ MonoBehaviour:
|
|||||||
m_MinSize: {x: 400, y: 200}
|
m_MinSize: {x: 400, y: 200}
|
||||||
m_MaxSize: {x: 32384, y: 16192}
|
m_MaxSize: {x: 32384, y: 16192}
|
||||||
vertical: 0
|
vertical: 0
|
||||||
controlID: 90
|
controlID: 82
|
||||||
--- !u!114 &6
|
--- !u!114 &6
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 52
|
m_ObjectHideFlags: 52
|
||||||
@ -144,7 +144,7 @@ MonoBehaviour:
|
|||||||
m_MinSize: {x: 300, y: 200}
|
m_MinSize: {x: 300, y: 200}
|
||||||
m_MaxSize: {x: 24288, y: 16192}
|
m_MaxSize: {x: 24288, y: 16192}
|
||||||
vertical: 1
|
vertical: 1
|
||||||
controlID: 91
|
controlID: 83
|
||||||
--- !u!114 &7
|
--- !u!114 &7
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 52
|
m_ObjectHideFlags: 52
|
||||||
@ -170,7 +170,7 @@ MonoBehaviour:
|
|||||||
m_MinSize: {x: 300, y: 100}
|
m_MinSize: {x: 300, y: 100}
|
||||||
m_MaxSize: {x: 24288, y: 8096}
|
m_MaxSize: {x: 24288, y: 8096}
|
||||||
vertical: 0
|
vertical: 0
|
||||||
controlID: 92
|
controlID: 84
|
||||||
--- !u!114 &8
|
--- !u!114 &8
|
||||||
MonoBehaviour:
|
MonoBehaviour:
|
||||||
m_ObjectHideFlags: 52
|
m_ObjectHideFlags: 52
|
||||||
@ -296,8 +296,8 @@ MonoBehaviour:
|
|||||||
y: 0
|
y: 0
|
||||||
width: 452
|
width: 452
|
||||||
height: 939
|
height: 939
|
||||||
m_MinSize: {x: 275, y: 50}
|
m_MinSize: {x: 276, y: 71}
|
||||||
m_MaxSize: {x: 4000, y: 4000}
|
m_MaxSize: {x: 4001, y: 4021}
|
||||||
m_ActualView: {fileID: 20}
|
m_ActualView: {fileID: 20}
|
||||||
m_Panes:
|
m_Panes:
|
||||||
- {fileID: 20}
|
- {fileID: 20}
|
||||||
@ -368,7 +368,7 @@ MonoBehaviour:
|
|||||||
m_HSlider: 0
|
m_HSlider: 0
|
||||||
m_VSlider: 0
|
m_VSlider: 0
|
||||||
m_IgnoreScrollWheelUntilClicked: 0
|
m_IgnoreScrollWheelUntilClicked: 0
|
||||||
m_EnableMouseInput: 0
|
m_EnableMouseInput: 1
|
||||||
m_EnableSliderZoomHorizontal: 0
|
m_EnableSliderZoomHorizontal: 0
|
||||||
m_EnableSliderZoomVertical: 0
|
m_EnableSliderZoomVertical: 0
|
||||||
m_UniformScale: 1
|
m_UniformScale: 1
|
||||||
@ -489,9 +489,9 @@ MonoBehaviour:
|
|||||||
m_SceneHierarchy:
|
m_SceneHierarchy:
|
||||||
m_TreeViewState:
|
m_TreeViewState:
|
||||||
scrollPos: {x: 0, y: 0}
|
scrollPos: {x: 0, y: 0}
|
||||||
m_SelectedIDs: aca20000
|
m_SelectedIDs: 788c0000
|
||||||
m_LastClickedID: 0
|
m_LastClickedID: 35960
|
||||||
m_ExpandedIDs: ba75ffff427affffb27effff087fffffc481ffffc881ffffc88dffff1e8effffda90ffffde90ffff54caffff60ccffffb6ccffff72cfffff76cfffff68d9ffff9cdbfffff2dbffffaedeffffb2deffff88e1ffffd0e3ffff26e4ffffe2e6ffffe6e6ffff0ce9ffff38ebffff8eebffff4aeeffff4eeeffff7cf6ffffd2f6ffff8ef9ffff92f9ffff18fbffff3a9000002c93000016960000049900009ca20000
|
m_ExpandedIDs: 20f1ffff1ef3ffff28f5ffff7ef5ffff3af8ffff3ef8fffff2faffff4a8b0000688c0000
|
||||||
m_RenameOverlay:
|
m_RenameOverlay:
|
||||||
m_UserAcceptedRename: 0
|
m_UserAcceptedRename: 0
|
||||||
m_Name:
|
m_Name:
|
||||||
@ -994,7 +994,7 @@ MonoBehaviour:
|
|||||||
scrollPos: {x: 0, y: 199}
|
scrollPos: {x: 0, y: 199}
|
||||||
m_SelectedIDs: d28c0000
|
m_SelectedIDs: d28c0000
|
||||||
m_LastClickedID: 36050
|
m_LastClickedID: 36050
|
||||||
m_ExpandedIDs: 00000000a8730000aa730000ac730000ae730000b0730000b2730000b4730000b6730000b8730000ba730000bc730000
|
m_ExpandedIDs: 000000007a7300007c7300007e73000080730000827300008473000086730000887300008a7300008c7300008e730000
|
||||||
m_RenameOverlay:
|
m_RenameOverlay:
|
||||||
m_UserAcceptedRename: 0
|
m_UserAcceptedRename: 0
|
||||||
m_Name:
|
m_Name:
|
||||||
@ -1022,7 +1022,7 @@ MonoBehaviour:
|
|||||||
scrollPos: {x: 0, y: 0}
|
scrollPos: {x: 0, y: 0}
|
||||||
m_SelectedIDs:
|
m_SelectedIDs:
|
||||||
m_LastClickedID: 0
|
m_LastClickedID: 0
|
||||||
m_ExpandedIDs: 00000000a8730000aa730000ac730000ae730000b0730000b2730000b4730000b6730000b8730000ba730000bc730000
|
m_ExpandedIDs: 000000007a7300007c7300007e73000080730000827300008473000086730000887300008a7300008c7300008e730000
|
||||||
m_RenameOverlay:
|
m_RenameOverlay:
|
||||||
m_UserAcceptedRename: 0
|
m_UserAcceptedRename: 0
|
||||||
m_Name:
|
m_Name:
|
||||||
|
@ -32,6 +32,9 @@ public class DemoController {
|
|||||||
//Id 分配
|
//Id 分配
|
||||||
private Integer nClientId = 1;
|
private Integer nClientId = 1;
|
||||||
|
|
||||||
|
//随机Id 分配
|
||||||
|
private Integer nRandomId = 1;
|
||||||
|
|
||||||
|
|
||||||
@ApiOperation(value = "获取玩家Id")
|
@ApiOperation(value = "获取玩家Id")
|
||||||
@GetMapping("/sync/tile/client/id")
|
@GetMapping("/sync/tile/client/id")
|
||||||
@ -39,6 +42,12 @@ public class DemoController {
|
|||||||
return NewsContext.onSuccess("查询成功",nClientId++);
|
return NewsContext.onSuccess("查询成功",nClientId++);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ApiOperation(value = "获取随机Id")
|
||||||
|
@GetMapping("/sync/tile/random/id")
|
||||||
|
public NewsContext<Integer> getTileRandomId(){
|
||||||
|
return NewsContext.onSuccess("查询成功",nRandomId++);
|
||||||
|
}
|
||||||
|
|
||||||
@ApiOperation(value = "获取Tile端口")
|
@ApiOperation(value = "获取Tile端口")
|
||||||
@GetMapping("/sync/tile/port")
|
@GetMapping("/sync/tile/port")
|
||||||
public NewsContext<Integer> getTilePort(){
|
public NewsContext<Integer> getTilePort(){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user