mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-26 18:26:23 +00:00
提交bug 艰难先这样
This commit is contained in:
@@ -26,9 +26,12 @@
|
||||
|
||||
NSyncStateDataUpdate = 121, //状态同步更新
|
||||
NSyncStateAllUpdate = 122, //状态全量更新
|
||||
NSyncStateAllBack = 123, //状态同步全量回调
|
||||
NSyncStateAllUpdateBack = 123, //状态同步全量回调
|
||||
|
||||
NSyncTileInput = 131, //状态Tile同步输入
|
||||
NSyncTileInput = 131, //区块Tile同步输入
|
||||
NSyncTileAllUpdate = 132, //区块全量更新
|
||||
NSyncTileAllUpdateBack = 133, //区块同步全量回调
|
||||
NSyncTileGetTileInfo = 134, //获取指定区块的全量信息
|
||||
|
||||
NAddTileServer = 141, //添加区块服务器
|
||||
|
||||
|
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.Threading.Tasks;
|
||||
using AppGame;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using DotRecast.Core.Collections;
|
||||
using Google.Protobuf;
|
||||
using Plugins.JNGame.Network.Entity;
|
||||
@@ -26,6 +27,9 @@ namespace Plugins.JNGame.Network
|
||||
|
||||
//计入字节大小
|
||||
protected Dictionary<int, int> _byteSize = new();
|
||||
|
||||
//回调消息
|
||||
protected Dictionary<int, UniTaskCompletionSource<byte[]>> _callback = new ();
|
||||
|
||||
public void SetEvent(EventDispatcher dispatcher)
|
||||
{
|
||||
@@ -46,8 +50,21 @@ namespace Plugins.JNGame.Network
|
||||
public virtual void Dispatch(JNetParam data)
|
||||
{
|
||||
_byteSize[data.HId] = data.Bytes.Length;
|
||||
//发送消息
|
||||
_event.Dispatch($"{data.HId}",data.Bytes);
|
||||
|
||||
//判断是否是回调消息
|
||||
if (data.HId <= 0)
|
||||
{
|
||||
//回调消息
|
||||
_callback.TryGetValue(data.ID,out var task);
|
||||
if (task is null) return;
|
||||
task.TrySetResult(data.Bytes);
|
||||
}
|
||||
else
|
||||
{
|
||||
//通知消息
|
||||
_event.Dispatch($"{data.HId}",data.Bytes);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//向服务器发送消息
|
||||
@@ -57,6 +74,17 @@ namespace Plugins.JNGame.Network
|
||||
_byteSize[hId] = bytes.Length;
|
||||
SendBytes(bytes);
|
||||
}
|
||||
|
||||
//向服务器发送消息(有回调的消息)
|
||||
public virtual async Task<byte[]> SendCallback(int hId,IMessage data = null,int timeout = 1000)
|
||||
{
|
||||
var id = this._id++;
|
||||
_callback[id] = new UniTaskCompletionSource<byte[]>();
|
||||
var bytes = NDataUtil.Encrypt(JNetParam.Build(id, hId).SetData(data));
|
||||
SendBytes(bytes);
|
||||
var message = await UniTask.WhenAny(_callback[id].Task, UniTask.Delay(timeout));
|
||||
return message.result;
|
||||
}
|
||||
|
||||
public virtual void SendBytes(byte[] data){ }
|
||||
|
||||
|
@@ -17,6 +17,8 @@ namespace Plugins.JNGame.Network
|
||||
|
||||
public string Client;
|
||||
|
||||
public int MessageID;
|
||||
|
||||
public byte[] Message;
|
||||
|
||||
}
|
||||
|
@@ -9,6 +9,9 @@ using Google.Protobuf;
|
||||
using Plugins.JNGame.Network.Entity;
|
||||
using Plugins.JNGame.Network.Util;
|
||||
using Plugins.JNGame.Util;
|
||||
using TouchSocket.Core;
|
||||
using TouchSocket.Http.WebSockets;
|
||||
using TouchSocket.Sockets;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Plugins.JNGame.Network
|
||||
@@ -16,10 +19,7 @@ namespace Plugins.JNGame.Network
|
||||
public abstract class JNSocket : JNClientBase
|
||||
{
|
||||
|
||||
private WebSocket _socket;
|
||||
|
||||
private UniTaskCompletionSource _onOpen;
|
||||
|
||||
private WebSocketClient client;
|
||||
|
||||
public override async Task OnInit()
|
||||
{
|
||||
@@ -29,61 +29,40 @@ namespace Plugins.JNGame.Network
|
||||
public async Task StartConnect()
|
||||
{
|
||||
|
||||
client = new WebSocketClient();
|
||||
|
||||
await client.SetupAsync(new TouchSocketConfig()
|
||||
.SetRemoteIPHost(await this.GetUrl())
|
||||
.ConfigurePlugins(a =>
|
||||
{
|
||||
a.UseReconnection(-1, true, 1000); //如需永远尝试连接,tryCount设置为-1即可。
|
||||
})
|
||||
.ConfigureContainer(a =>
|
||||
{
|
||||
a.AddConsoleLogger();
|
||||
}));
|
||||
client.Received += OnReceived;
|
||||
|
||||
|
||||
var url = $"{await this.GetUrl()}";
|
||||
this._socket = new WebSocket(new Uri(url));
|
||||
|
||||
this._socket.OnOpen += OnOpen;
|
||||
this._socket.OnMessage += OnMessageReceived;
|
||||
this._socket.OnError += OnError;
|
||||
this._socket.OnClosed += OnClosed;
|
||||
this._socket.OnBinary += Onbinary;
|
||||
|
||||
Debug.Log($"[JNSocket]初始化WebSocket成功,URL:{url}");
|
||||
this._socket.Open();
|
||||
|
||||
//等待连接成功
|
||||
await (this._onOpen = new UniTaskCompletionSource()).Task;
|
||||
client.Connect();
|
||||
Debug.Log($"[JNSocket]连接WebSocket成功");
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void OnOpen(WebSocket websocket)
|
||||
private Task OnReceived(WebSocketClient webSocketClient, WSDataFrameEventArgs e)
|
||||
{
|
||||
Debug.Log($"[JNSocket] OnOpen");
|
||||
this._onOpen.TrySetResult();
|
||||
if (e.DataFrame.Opcode == WSDataType.Binary && e.DataFrame.FIN)
|
||||
{
|
||||
Dispatch(NDataUtil.Parse(e.DataFrame.PayloadData));
|
||||
}
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
private void OnMessageReceived(WebSocket websocket, string message)
|
||||
{
|
||||
Debug.Log($"[JNSocket] OnMessageReceived");
|
||||
}
|
||||
|
||||
private void OnError(WebSocket websocket, string reason)
|
||||
{
|
||||
Debug.Log($"[JNSocket] OnError");
|
||||
}
|
||||
|
||||
private void OnClosed(WebSocket websocket, ushort code, string message)
|
||||
{
|
||||
Debug.Log($"[JNSocket] OnClosed");
|
||||
}
|
||||
|
||||
private void Onbinary(WebSocket websocket, byte[] data)
|
||||
{
|
||||
|
||||
// NSystem.Log($"[JNSocket] Onbinary");
|
||||
Dispatch(NDataUtil.Parse(data));
|
||||
|
||||
}
|
||||
|
||||
protected abstract UniTask<string> GetUrl();
|
||||
|
||||
public override void SendBytes(byte[] data)
|
||||
{
|
||||
_socket.Send(data);
|
||||
client.SendAsync(data);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -36,7 +36,7 @@ namespace JNGame.Network
|
||||
tcpClient.Disconnected = OnDisconnected;//从服务器断开连接,当连接不成功时不会触发。
|
||||
tcpClient.Received = OnReceived;
|
||||
|
||||
tcpClient.Connect(await GetEndPoint());
|
||||
await tcpClient.ConnectAsync(await GetEndPoint());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -108,8 +108,10 @@ namespace JNGame.Network
|
||||
|
||||
public override void OnClose()
|
||||
{
|
||||
base.OnClose();
|
||||
tcpClient.Close();
|
||||
tcpClient.Dispose();
|
||||
Debug.Log($"[JNTCPClient] 关闭对象");
|
||||
base.OnClose();
|
||||
}
|
||||
|
||||
protected virtual async UniTask<string> GetEndPoint()
|
||||
|
@@ -103,6 +103,7 @@ namespace JNGame.Network
|
||||
Dispatch(param.HId,new JNServerParam()
|
||||
{
|
||||
Client = client.Id,
|
||||
MessageID = param.ID,
|
||||
Message = param.Bytes,
|
||||
});
|
||||
await UniTask.NextFrame();
|
||||
@@ -123,10 +124,19 @@ namespace JNGame.Network
|
||||
|
||||
|
||||
public void Send(SocketClient client,int hId,IMessage data = null)
|
||||
{
|
||||
Send(client.Id,hId,data);
|
||||
}
|
||||
public void Send(string client,int hId,IMessage data = null)
|
||||
{
|
||||
var bytes = NDataUtil.Encrypt(JNetParam.Build(this._id++, hId).SetData(data));
|
||||
_byteSize[hId] = bytes.Length;
|
||||
service.SendAsync(client.Id, bytes);
|
||||
service.SendAsync(client, bytes);
|
||||
}
|
||||
public void SendCallback(string client,int id,IMessage data = null)
|
||||
{
|
||||
var bytes = NDataUtil.Encrypt(JNetParam.Build(id, 0).SetData(data));
|
||||
service.SendAsync(client, bytes);
|
||||
}
|
||||
|
||||
public void AllSend(int hId,IMessage data = null)
|
||||
|
@@ -31,20 +31,17 @@ public static partial class JNSyncMessageReflection {
|
||||
"CzINLkpORnJhbWVJbnB1dCIsCgxKTkZyYW1lSW5mb3MSHAoGZnJhbWVzGAEg",
|
||||
"AygLMgwuSk5GcmFtZUluZm8iKwoHSk5JbnB1dBIUCgdtZXNzYWdlGAEgASgJ",
|
||||
"SACIAQFCCgoIX21lc3NhZ2UiKQoLSk5TdGF0ZURhdGESEQoEZGF0YRgCIAEo",
|
||||
"DEgAiAEBQgcKBV9kYXRhIo8BCg5KTlN0YXRlQWxsRGF0YRINCgVOZXRJRBgB",
|
||||
"IAEoBRIvCghtZXNzYWdlcxgCIAMoCzIdLkpOU3RhdGVBbGxEYXRhLk1lc3Nh",
|
||||
"Z2VzRW50cnkaPQoNTWVzc2FnZXNFbnRyeRILCgNrZXkYASABKAMSGwoFdmFs",
|
||||
"dWUYAiABKAsyDC5KTlN0YXRlRGF0YToCOAEikQEKD0pOU3RhdGVJdGVtRGF0",
|
||||
"YRINCgVOZXRJRBgBIAEoBRIwCghtZXNzYWdlcxgCIAMoCzIeLkpOU3RhdGVJ",
|
||||
"dGVtRGF0YS5NZXNzYWdlc0VudHJ5Gj0KDU1lc3NhZ2VzRW50cnkSCwoDa2V5",
|
||||
"GAEgASgDEhsKBXZhbHVlGAIgASgLMgwuSk5TdGF0ZURhdGE6AjgBIkEKEUpO",
|
||||
"U3RhdGVUaWxlSW5wdXRzEgsKA3RJZBgBIAEoBRIfCgdtZXNzYWdlGAIgASgL",
|
||||
"Mg4uSk5GcmFtZUlucHV0cyJCChNKTlN0YXRlVGlsZUl0ZW1EYXRhEgsKA3RJ",
|
||||
"ZBgBIAEoBRIeCgRkYXRhGAIgASgLMhAuSk5TdGF0ZUl0ZW1EYXRhIkAKEkpO",
|
||||
"U3RhdGVUaWxlQWxsRGF0YRILCgN0SWQYASABKAUSHQoEZGF0YRgCIAEoCzIP",
|
||||
"LkpOU3RhdGVBbGxEYXRhIjkKD0pOQWRkVGlsZVNlcnZlchIMCgR0aWxlGAEg",
|
||||
"ASgFEgoKAmlwGAIgASgJEgwKBHBvcnQYAyABKAVCFgoUY24uamlzb2wubmdh",
|
||||
"bWUucHJvdG9iBnByb3RvMw=="));
|
||||
"DEgAiAEBQgcKBV9kYXRhIpEBCg9KTlN0YXRlSXRlbURhdGESDQoFTmV0SUQY",
|
||||
"ASABKAUSMAoIbWVzc2FnZXMYAiADKAsyHi5KTlN0YXRlSXRlbURhdGEuTWVz",
|
||||
"c2FnZXNFbnRyeRo9Cg1NZXNzYWdlc0VudHJ5EgsKA2tleRgBIAEoAxIbCgV2",
|
||||
"YWx1ZRgCIAEoCzIMLkpOU3RhdGVEYXRhOgI4ASIwCg5KTlN0YXRlQWxsRGF0",
|
||||
"YRIeCgRkYXRhGAIgAygLMhAuSk5TdGF0ZUl0ZW1EYXRhIkEKEUpOU3RhdGVU",
|
||||
"aWxlSW5wdXRzEgsKA3RJZBgBIAEoBRIfCgdtZXNzYWdlGAIgASgLMg4uSk5G",
|
||||
"cmFtZUlucHV0cyJAChJKTlN0YXRlVGlsZUFsbERhdGESCwoDdElkGAEgASgF",
|
||||
"Eh0KBGRhdGEYAiABKAsyDy5KTlN0YXRlQWxsRGF0YSIqChtOU3luY1RpbGVH",
|
||||
"ZXRUaWxlSW5mb1JlcXVlc3QSCwoDdElkGAEgASgFIjkKD0pOQWRkVGlsZVNl",
|
||||
"cnZlchIMCgR0aWxlGAEgASgFEgoKAmlwGAIgASgJEgwKBHBvcnQYAyABKAVC",
|
||||
"FgoUY24uamlzb2wubmdhbWUucHJvdG9iBnByb3RvMw=="));
|
||||
descriptor = pbr::FileDescriptor.FromGeneratedCode(descriptorData,
|
||||
new pbr::FileDescriptor[] { },
|
||||
new pbr::GeneratedClrTypeInfo(null, null, new pbr::GeneratedClrTypeInfo[] {
|
||||
@@ -56,11 +53,11 @@ public static partial class JNSyncMessageReflection {
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::JNFrameInfos), global::JNFrameInfos.Parser, new[]{ "Frames" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::JNInput), global::JNInput.Parser, new[]{ "Message" }, new[]{ "Message" }, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::JNStateData), global::JNStateData.Parser, new[]{ "Data" }, new[]{ "Data" }, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::JNStateAllData), global::JNStateAllData.Parser, new[]{ "NetID", "Messages" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { null, }),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::JNStateItemData), global::JNStateItemData.Parser, new[]{ "NetID", "Messages" }, null, null, null, new pbr::GeneratedClrTypeInfo[] { null, }),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::JNStateAllData), global::JNStateAllData.Parser, new[]{ "Data" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::JNStateTileInputs), global::JNStateTileInputs.Parser, new[]{ "TId", "Message" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::JNStateTileItemData), global::JNStateTileItemData.Parser, new[]{ "TId", "Data" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::JNStateTileAllData), global::JNStateTileAllData.Parser, new[]{ "TId", "Data" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::NSyncTileGetTileInfoRequest), global::NSyncTileGetTileInfoRequest.Parser, new[]{ "TId" }, null, null, null, null),
|
||||
new pbr::GeneratedClrTypeInfo(typeof(global::JNAddTileServer), global::JNAddTileServer.Parser, new[]{ "Tile", "Ip", "Port" }, null, null, null, null)
|
||||
}));
|
||||
}
|
||||
@@ -1751,230 +1748,6 @@ public sealed partial class JNStateData : pb::IMessage<JNStateData>
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 全量状态
|
||||
/// </summary>
|
||||
public sealed partial class JNStateAllData : pb::IMessage<JNStateAllData>
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
, pb::IBufferMessage
|
||||
#endif
|
||||
{
|
||||
private static readonly pb::MessageParser<JNStateAllData> _parser = new pb::MessageParser<JNStateAllData>(() => new JNStateAllData());
|
||||
private pb::UnknownFieldSet _unknownFields;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public static pb::MessageParser<JNStateAllData> Parser { get { return _parser; } }
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public static pbr::MessageDescriptor Descriptor {
|
||||
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[8]; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
pbr::MessageDescriptor pb::IMessage.Descriptor {
|
||||
get { return Descriptor; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public JNStateAllData() {
|
||||
OnConstruction();
|
||||
}
|
||||
|
||||
partial void OnConstruction();
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public JNStateAllData(JNStateAllData other) : this() {
|
||||
netID_ = other.netID_;
|
||||
messages_ = other.messages_.Clone();
|
||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public JNStateAllData Clone() {
|
||||
return new JNStateAllData(this);
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "NetID" field.</summary>
|
||||
public const int NetIDFieldNumber = 1;
|
||||
private int netID_;
|
||||
/// <summary>
|
||||
///同步Id
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public int NetID {
|
||||
get { return netID_; }
|
||||
set {
|
||||
netID_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "messages" field.</summary>
|
||||
public const int MessagesFieldNumber = 2;
|
||||
private static readonly pbc::MapField<long, 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);
|
||||
private readonly pbc::MapField<long, global::JNStateData> messages_ = new pbc::MapField<long, global::JNStateData>();
|
||||
/// <summary>
|
||||
///状态bytes
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public pbc::MapField<long, global::JNStateData> Messages {
|
||||
get { return messages_; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override bool Equals(object other) {
|
||||
return Equals(other as JNStateAllData);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public bool Equals(JNStateAllData other) {
|
||||
if (ReferenceEquals(other, null)) {
|
||||
return false;
|
||||
}
|
||||
if (ReferenceEquals(other, this)) {
|
||||
return true;
|
||||
}
|
||||
if (NetID != other.NetID) return false;
|
||||
if (!Messages.Equals(other.Messages)) return false;
|
||||
return Equals(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override int GetHashCode() {
|
||||
int hash = 1;
|
||||
if (NetID != 0) hash ^= NetID.GetHashCode();
|
||||
hash ^= Messages.GetHashCode();
|
||||
if (_unknownFields != null) {
|
||||
hash ^= _unknownFields.GetHashCode();
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override string ToString() {
|
||||
return pb::JsonFormatter.ToDiagnosticString(this);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void WriteTo(pb::CodedOutputStream output) {
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
output.WriteRawMessage(this);
|
||||
#else
|
||||
if (NetID != 0) {
|
||||
output.WriteRawTag(8);
|
||||
output.WriteInt32(NetID);
|
||||
}
|
||||
messages_.WriteTo(output, _map_messages_codec);
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(output);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
|
||||
if (NetID != 0) {
|
||||
output.WriteRawTag(8);
|
||||
output.WriteInt32(NetID);
|
||||
}
|
||||
messages_.WriteTo(ref output, _map_messages_codec);
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(ref output);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public int CalculateSize() {
|
||||
int size = 0;
|
||||
if (NetID != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(NetID);
|
||||
}
|
||||
size += messages_.CalculateSize(_map_messages_codec);
|
||||
if (_unknownFields != null) {
|
||||
size += _unknownFields.CalculateSize();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void MergeFrom(JNStateAllData other) {
|
||||
if (other == null) {
|
||||
return;
|
||||
}
|
||||
if (other.NetID != 0) {
|
||||
NetID = other.NetID;
|
||||
}
|
||||
messages_.Add(other.messages_);
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void MergeFrom(pb::CodedInputStream input) {
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
input.ReadRawMessage(this);
|
||||
#else
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
switch(tag) {
|
||||
default:
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
|
||||
break;
|
||||
case 8: {
|
||||
NetID = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 18: {
|
||||
messages_.AddEntriesFrom(input, _map_messages_codec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
switch(tag) {
|
||||
default:
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
|
||||
break;
|
||||
case 8: {
|
||||
NetID = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 18: {
|
||||
messages_.AddEntriesFrom(ref input, _map_messages_codec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新状态
|
||||
/// </summary>
|
||||
@@ -1992,7 +1765,7 @@ public sealed partial class JNStateItemData : pb::IMessage<JNStateItemData>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public static pbr::MessageDescriptor Descriptor {
|
||||
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[9]; }
|
||||
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[8]; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
@@ -2199,6 +1972,190 @@ public sealed partial class JNStateItemData : pb::IMessage<JNStateItemData>
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 全量状态
|
||||
/// </summary>
|
||||
public sealed partial class JNStateAllData : pb::IMessage<JNStateAllData>
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
, pb::IBufferMessage
|
||||
#endif
|
||||
{
|
||||
private static readonly pb::MessageParser<JNStateAllData> _parser = new pb::MessageParser<JNStateAllData>(() => new JNStateAllData());
|
||||
private pb::UnknownFieldSet _unknownFields;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public static pb::MessageParser<JNStateAllData> Parser { get { return _parser; } }
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public static pbr::MessageDescriptor Descriptor {
|
||||
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[9]; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
pbr::MessageDescriptor pb::IMessage.Descriptor {
|
||||
get { return Descriptor; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public JNStateAllData() {
|
||||
OnConstruction();
|
||||
}
|
||||
|
||||
partial void OnConstruction();
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public JNStateAllData(JNStateAllData other) : this() {
|
||||
data_ = other.data_.Clone();
|
||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public JNStateAllData Clone() {
|
||||
return new JNStateAllData(this);
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "data" field.</summary>
|
||||
public const int DataFieldNumber = 2;
|
||||
private static readonly pb::FieldCodec<global::JNStateItemData> _repeated_data_codec
|
||||
= pb::FieldCodec.ForMessage(18, global::JNStateItemData.Parser);
|
||||
private readonly pbc::RepeatedField<global::JNStateItemData> data_ = new pbc::RepeatedField<global::JNStateItemData>();
|
||||
/// <summary>
|
||||
///数据
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public pbc::RepeatedField<global::JNStateItemData> Data {
|
||||
get { return data_; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override bool Equals(object other) {
|
||||
return Equals(other as JNStateAllData);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public bool Equals(JNStateAllData other) {
|
||||
if (ReferenceEquals(other, null)) {
|
||||
return false;
|
||||
}
|
||||
if (ReferenceEquals(other, this)) {
|
||||
return true;
|
||||
}
|
||||
if(!data_.Equals(other.data_)) return false;
|
||||
return Equals(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override int GetHashCode() {
|
||||
int hash = 1;
|
||||
hash ^= data_.GetHashCode();
|
||||
if (_unknownFields != null) {
|
||||
hash ^= _unknownFields.GetHashCode();
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override string ToString() {
|
||||
return pb::JsonFormatter.ToDiagnosticString(this);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void WriteTo(pb::CodedOutputStream output) {
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
output.WriteRawMessage(this);
|
||||
#else
|
||||
data_.WriteTo(output, _repeated_data_codec);
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(output);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
|
||||
data_.WriteTo(ref output, _repeated_data_codec);
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(ref output);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public int CalculateSize() {
|
||||
int size = 0;
|
||||
size += data_.CalculateSize(_repeated_data_codec);
|
||||
if (_unknownFields != null) {
|
||||
size += _unknownFields.CalculateSize();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void MergeFrom(JNStateAllData other) {
|
||||
if (other == null) {
|
||||
return;
|
||||
}
|
||||
data_.Add(other.data_);
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void MergeFrom(pb::CodedInputStream input) {
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
input.ReadRawMessage(this);
|
||||
#else
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
switch(tag) {
|
||||
default:
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
|
||||
break;
|
||||
case 18: {
|
||||
data_.AddEntriesFrom(input, _repeated_data_codec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
switch(tag) {
|
||||
default:
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
|
||||
break;
|
||||
case 18: {
|
||||
data_.AddEntriesFrom(ref input, _repeated_data_codec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// --------------------- 状态Tile同步 -----------------------
|
||||
/// 状态Tile输入
|
||||
@@ -2444,247 +2401,6 @@ public sealed partial class JNStateTileInputs : pb::IMessage<JNStateTileInputs>
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tile更新状态
|
||||
/// </summary>
|
||||
public sealed partial class JNStateTileItemData : pb::IMessage<JNStateTileItemData>
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
, pb::IBufferMessage
|
||||
#endif
|
||||
{
|
||||
private static readonly pb::MessageParser<JNStateTileItemData> _parser = new pb::MessageParser<JNStateTileItemData>(() => new JNStateTileItemData());
|
||||
private pb::UnknownFieldSet _unknownFields;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public static pb::MessageParser<JNStateTileItemData> Parser { get { return _parser; } }
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public static pbr::MessageDescriptor Descriptor {
|
||||
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[11]; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
pbr::MessageDescriptor pb::IMessage.Descriptor {
|
||||
get { return Descriptor; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public JNStateTileItemData() {
|
||||
OnConstruction();
|
||||
}
|
||||
|
||||
partial void OnConstruction();
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public JNStateTileItemData(JNStateTileItemData other) : this() {
|
||||
tId_ = other.tId_;
|
||||
data_ = other.data_ != null ? other.data_.Clone() : null;
|
||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public JNStateTileItemData Clone() {
|
||||
return new JNStateTileItemData(this);
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "tId" field.</summary>
|
||||
public const int TIdFieldNumber = 1;
|
||||
private int tId_;
|
||||
/// <summary>
|
||||
///区块Id
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public int TId {
|
||||
get { return tId_; }
|
||||
set {
|
||||
tId_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "data" field.</summary>
|
||||
public const int DataFieldNumber = 2;
|
||||
private global::JNStateItemData data_;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public global::JNStateItemData Data {
|
||||
get { return data_; }
|
||||
set {
|
||||
data_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override bool Equals(object other) {
|
||||
return Equals(other as JNStateTileItemData);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public bool Equals(JNStateTileItemData other) {
|
||||
if (ReferenceEquals(other, null)) {
|
||||
return false;
|
||||
}
|
||||
if (ReferenceEquals(other, this)) {
|
||||
return true;
|
||||
}
|
||||
if (TId != other.TId) return false;
|
||||
if (!object.Equals(Data, other.Data)) return false;
|
||||
return Equals(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override int GetHashCode() {
|
||||
int hash = 1;
|
||||
if (TId != 0) hash ^= TId.GetHashCode();
|
||||
if (data_ != null) hash ^= Data.GetHashCode();
|
||||
if (_unknownFields != null) {
|
||||
hash ^= _unknownFields.GetHashCode();
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override string ToString() {
|
||||
return pb::JsonFormatter.ToDiagnosticString(this);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void WriteTo(pb::CodedOutputStream output) {
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
output.WriteRawMessage(this);
|
||||
#else
|
||||
if (TId != 0) {
|
||||
output.WriteRawTag(8);
|
||||
output.WriteInt32(TId);
|
||||
}
|
||||
if (data_ != null) {
|
||||
output.WriteRawTag(18);
|
||||
output.WriteMessage(Data);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(output);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
|
||||
if (TId != 0) {
|
||||
output.WriteRawTag(8);
|
||||
output.WriteInt32(TId);
|
||||
}
|
||||
if (data_ != null) {
|
||||
output.WriteRawTag(18);
|
||||
output.WriteMessage(Data);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(ref output);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public int CalculateSize() {
|
||||
int size = 0;
|
||||
if (TId != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(TId);
|
||||
}
|
||||
if (data_ != null) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeMessageSize(Data);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
size += _unknownFields.CalculateSize();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void MergeFrom(JNStateTileItemData other) {
|
||||
if (other == null) {
|
||||
return;
|
||||
}
|
||||
if (other.TId != 0) {
|
||||
TId = other.TId;
|
||||
}
|
||||
if (other.data_ != null) {
|
||||
if (data_ == null) {
|
||||
Data = new global::JNStateItemData();
|
||||
}
|
||||
Data.MergeFrom(other.Data);
|
||||
}
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void MergeFrom(pb::CodedInputStream input) {
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
input.ReadRawMessage(this);
|
||||
#else
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
switch(tag) {
|
||||
default:
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
|
||||
break;
|
||||
case 8: {
|
||||
TId = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 18: {
|
||||
if (data_ == null) {
|
||||
Data = new global::JNStateItemData();
|
||||
}
|
||||
input.ReadMessage(Data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
switch(tag) {
|
||||
default:
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
|
||||
break;
|
||||
case 8: {
|
||||
TId = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
case 18: {
|
||||
if (data_ == null) {
|
||||
Data = new global::JNStateItemData();
|
||||
}
|
||||
input.ReadMessage(Data);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tile更新全量状态
|
||||
/// </summary>
|
||||
@@ -2702,7 +2418,7 @@ public sealed partial class JNStateTileAllData : pb::IMessage<JNStateTileAllData
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public static pbr::MessageDescriptor Descriptor {
|
||||
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[12]; }
|
||||
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[11]; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
@@ -2926,6 +2642,201 @@ public sealed partial class JNStateTileAllData : pb::IMessage<JNStateTileAllData
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定区块的全量数据
|
||||
/// </summary>
|
||||
public sealed partial class NSyncTileGetTileInfoRequest : pb::IMessage<NSyncTileGetTileInfoRequest>
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
, pb::IBufferMessage
|
||||
#endif
|
||||
{
|
||||
private static readonly pb::MessageParser<NSyncTileGetTileInfoRequest> _parser = new pb::MessageParser<NSyncTileGetTileInfoRequest>(() => new NSyncTileGetTileInfoRequest());
|
||||
private pb::UnknownFieldSet _unknownFields;
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public static pb::MessageParser<NSyncTileGetTileInfoRequest> Parser { get { return _parser; } }
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public static pbr::MessageDescriptor Descriptor {
|
||||
get { return global::JNSyncMessageReflection.Descriptor.MessageTypes[12]; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
pbr::MessageDescriptor pb::IMessage.Descriptor {
|
||||
get { return Descriptor; }
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public NSyncTileGetTileInfoRequest() {
|
||||
OnConstruction();
|
||||
}
|
||||
|
||||
partial void OnConstruction();
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public NSyncTileGetTileInfoRequest(NSyncTileGetTileInfoRequest other) : this() {
|
||||
tId_ = other.tId_;
|
||||
_unknownFields = pb::UnknownFieldSet.Clone(other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public NSyncTileGetTileInfoRequest Clone() {
|
||||
return new NSyncTileGetTileInfoRequest(this);
|
||||
}
|
||||
|
||||
/// <summary>Field number for the "tId" field.</summary>
|
||||
public const int TIdFieldNumber = 1;
|
||||
private int tId_;
|
||||
/// <summary>
|
||||
///区块Id
|
||||
/// </summary>
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public int TId {
|
||||
get { return tId_; }
|
||||
set {
|
||||
tId_ = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override bool Equals(object other) {
|
||||
return Equals(other as NSyncTileGetTileInfoRequest);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public bool Equals(NSyncTileGetTileInfoRequest other) {
|
||||
if (ReferenceEquals(other, null)) {
|
||||
return false;
|
||||
}
|
||||
if (ReferenceEquals(other, this)) {
|
||||
return true;
|
||||
}
|
||||
if (TId != other.TId) return false;
|
||||
return Equals(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override int GetHashCode() {
|
||||
int hash = 1;
|
||||
if (TId != 0) hash ^= TId.GetHashCode();
|
||||
if (_unknownFields != null) {
|
||||
hash ^= _unknownFields.GetHashCode();
|
||||
}
|
||||
return hash;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public override string ToString() {
|
||||
return pb::JsonFormatter.ToDiagnosticString(this);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void WriteTo(pb::CodedOutputStream output) {
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
output.WriteRawMessage(this);
|
||||
#else
|
||||
if (TId != 0) {
|
||||
output.WriteRawTag(8);
|
||||
output.WriteInt32(TId);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(output);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
void pb::IBufferMessage.InternalWriteTo(ref pb::WriteContext output) {
|
||||
if (TId != 0) {
|
||||
output.WriteRawTag(8);
|
||||
output.WriteInt32(TId);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
_unknownFields.WriteTo(ref output);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public int CalculateSize() {
|
||||
int size = 0;
|
||||
if (TId != 0) {
|
||||
size += 1 + pb::CodedOutputStream.ComputeInt32Size(TId);
|
||||
}
|
||||
if (_unknownFields != null) {
|
||||
size += _unknownFields.CalculateSize();
|
||||
}
|
||||
return size;
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void MergeFrom(NSyncTileGetTileInfoRequest other) {
|
||||
if (other == null) {
|
||||
return;
|
||||
}
|
||||
if (other.TId != 0) {
|
||||
TId = other.TId;
|
||||
}
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFrom(_unknownFields, other._unknownFields);
|
||||
}
|
||||
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
public void MergeFrom(pb::CodedInputStream input) {
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
input.ReadRawMessage(this);
|
||||
#else
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
switch(tag) {
|
||||
default:
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, input);
|
||||
break;
|
||||
case 8: {
|
||||
TId = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !GOOGLE_PROTOBUF_REFSTRUCT_COMPATIBILITY_MODE
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute]
|
||||
[global::System.CodeDom.Compiler.GeneratedCode("protoc", null)]
|
||||
void pb::IBufferMessage.InternalMergeFrom(ref pb::ParseContext input) {
|
||||
uint tag;
|
||||
while ((tag = input.ReadTag()) != 0) {
|
||||
switch(tag) {
|
||||
default:
|
||||
_unknownFields = pb::UnknownFieldSet.MergeFieldFrom(_unknownFields, ref input);
|
||||
break;
|
||||
case 8: {
|
||||
TId = input.ReadInt32();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///Tile服务器区块信息
|
||||
/// </summary>
|
||||
|
@@ -46,18 +46,17 @@ message JNStateData{
|
||||
optional bytes data = 2; //数据
|
||||
}
|
||||
|
||||
// 全量状态
|
||||
message JNStateAllData{
|
||||
int32 NetID = 1; //同步Id
|
||||
map<int64 ,JNStateData> messages = 2; //状态bytes
|
||||
}
|
||||
|
||||
// 更新状态
|
||||
message JNStateItemData{
|
||||
int32 NetID = 1; //同步Id
|
||||
map<int64 ,JNStateData> messages = 2; //状态bytes
|
||||
}
|
||||
|
||||
// 全量状态
|
||||
message JNStateAllData{
|
||||
repeated JNStateItemData data = 2; //数据
|
||||
}
|
||||
|
||||
// --------------------- 状态Tile同步 -----------------------
|
||||
// 状态Tile输入
|
||||
message JNStateTileInputs{
|
||||
@@ -65,18 +64,17 @@ message JNStateTileInputs{
|
||||
JNFrameInputs message = 2; //inputs
|
||||
}
|
||||
|
||||
// Tile更新状态
|
||||
message JNStateTileItemData{
|
||||
int32 tId = 1; //区块Id
|
||||
JNStateItemData data = 2;
|
||||
}
|
||||
|
||||
// Tile更新全量状态
|
||||
message JNStateTileAllData{
|
||||
int32 tId = 1; //区块Id
|
||||
JNStateAllData data = 2;
|
||||
}
|
||||
|
||||
// 获取指定区块的全量数据
|
||||
message NSyncTileGetTileInfoRequest{
|
||||
int32 tId = 1; //区块Id
|
||||
}
|
||||
|
||||
//Tile服务器区块信息
|
||||
message JNAddTileServer{
|
||||
int32 tile = 1; //TileId
|
||||
|
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using JNGame.Sync.Entity;
|
||||
using JNGame.Sync.Frame.Entity;
|
||||
using JNGame.Sync.Frame.Entity.Components;
|
||||
using UnityEngine;
|
||||
|
||||
namespace JNGame.Sync.State.Tile.Entity
|
||||
{
|
||||
@@ -44,6 +45,17 @@ namespace JNGame.Sync.State.Tile.Entity
|
||||
|
||||
public T TileSyncCreate(long id)
|
||||
{
|
||||
|
||||
//判断是否有这个Id实体
|
||||
foreach (var data in GetEntities())
|
||||
{
|
||||
if (data.Id == id)
|
||||
{
|
||||
Debug.Log("重复Id实体创建");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
var entity = NewEntity();
|
||||
entity.OnInit(this,id);
|
||||
entity.IsHost = false;
|
||||
|
@@ -26,55 +26,10 @@ namespace JNGame.Sync.State.Tile
|
||||
/// 区块大小
|
||||
/// </summary>
|
||||
protected abstract int TileSize { get; }
|
||||
|
||||
public bool IsTileIndex((int X, int Y) xTuple)
|
||||
{
|
||||
if (xTuple.X >= 0 && xTuple.Y >= 0)
|
||||
{
|
||||
return xTuple.Y < Tiles.Length && xTuple.X < Tiles[0].Length;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int GetTileIndex(LVector3 pos)
|
||||
{
|
||||
(int x, int y) = GetXYIndex(pos);
|
||||
return Tiles[y][x];
|
||||
}
|
||||
|
||||
public (int X, int Y) GetXYIndex(LVector3 pos)
|
||||
{
|
||||
// 遍历数组
|
||||
for (int y = 0; y < Tiles.Length; y++)
|
||||
{
|
||||
for (int x = 0; x < Tiles[y].Length; x++)
|
||||
{
|
||||
// 检查当前元素是否非零
|
||||
if (Tiles[y][x] != 0)
|
||||
{
|
||||
|
||||
//判断是否所在区块
|
||||
var min = new LVector2(x.ToLFloat() * TileSize,y.ToLFloat() * TileSize);
|
||||
var max = new LVector2((x + 1).ToLFloat() * TileSize,(y + 1).ToLFloat() * TileSize);
|
||||
|
||||
// 假设LVector2是一个包含X和Y属性的结构体或类
|
||||
// 检查X坐标是否在范围内
|
||||
if (pos.x < min.x || pos.x >= max.x)
|
||||
{
|
||||
continue; // X坐标不在范围内
|
||||
}
|
||||
// 检查Y坐标是否在范围内
|
||||
if (pos.z < min.y || pos.z >= max.y)
|
||||
{
|
||||
continue; // Y坐标不在范围内
|
||||
}
|
||||
|
||||
return (x,y);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (0,0);
|
||||
return JNSSTileTool.GetTileIndex(Tiles, TileSize, pos);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -83,23 +38,7 @@ namespace JNGame.Sync.State.Tile
|
||||
/// <returns></returns>
|
||||
public List<int> GetTileGridIndex(LVector3 pos)
|
||||
{
|
||||
|
||||
(int x, int y) = GetXYIndex(pos);
|
||||
List<int> grid = new List<int>();
|
||||
|
||||
// 填充九宫格
|
||||
for (int i = -1; i <= 1; i++)
|
||||
{
|
||||
for (int j = -1; j <= 1; j++)
|
||||
{
|
||||
int tempX = x + i;
|
||||
int tempY = y + j; // 注意这里j+1+1是因为数组第二维存储的是y坐标
|
||||
if (IsTileIndex((tempX,tempY))) grid.Add(Tiles[tempY][tempX]);
|
||||
}
|
||||
}
|
||||
|
||||
return grid;
|
||||
|
||||
return JNSSTileTool.GetTileGridIndex(Tiles, TileSize,pos);
|
||||
}
|
||||
|
||||
public void AddTileShow(int index)
|
||||
|
@@ -70,7 +70,7 @@ namespace JNGame.Sync.State.Tile
|
||||
{
|
||||
//根据区块设置Id 起始值
|
||||
var random = base.CreateRandom();
|
||||
random.SetIdValue(100000000000L * TID);
|
||||
random.SetIdValue(100000000000L * TID,(100000000000L * (TID + 1) - 1));
|
||||
return random;
|
||||
}
|
||||
|
||||
@@ -78,15 +78,6 @@ namespace JNGame.Sync.State.Tile
|
||||
{
|
||||
return new JNTileContexts();
|
||||
}
|
||||
|
||||
public bool IsTileIndex((int X, int Y) xTuple)
|
||||
{
|
||||
if (xTuple.X >= 0 && xTuple.Y >= 0)
|
||||
{
|
||||
return xTuple.Y < Tiles.Length && xTuple.X < Tiles[0].Length;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新区块范围
|
||||
@@ -110,6 +101,11 @@ namespace JNGame.Sync.State.Tile
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public int GetTileIndex(LVector3 pos)
|
||||
{
|
||||
return JNSSTileTool.GetTileIndex(Tiles, TileSize, pos);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断位置是否在区块内
|
||||
@@ -117,16 +113,20 @@ namespace JNGame.Sync.State.Tile
|
||||
/// <param name="pos"></param>
|
||||
/// <returns></returns>
|
||||
public bool IsContains(LVector3 position)
|
||||
{
|
||||
return IsContains(position,MaxContains,MinContains);
|
||||
}
|
||||
public bool IsContains(LVector3 position,LVector3 Max,LVector3 Min)
|
||||
{
|
||||
// 假设LVector2是一个包含X和Y属性的结构体或类
|
||||
// 检查X坐标是否在范围内
|
||||
if (position.x < MinContains.x || position.x >= MaxContains.x)
|
||||
if (position.x < Min.x || position.x >= Max.x)
|
||||
{
|
||||
return false; // X坐标不在范围内
|
||||
}
|
||||
|
||||
// 检查Y坐标是否在范围内
|
||||
if (position.z < MinContains.y || position.z >= MaxContains.y)
|
||||
if (position.z < Min.y || position.z >= Max.y)
|
||||
{
|
||||
return false; // Y坐标不在范围内
|
||||
}
|
||||
@@ -141,35 +141,7 @@ namespace JNGame.Sync.State.Tile
|
||||
/// <returns></returns>
|
||||
public (LVector2 Max,LVector2 Min) GetTileContains(int index)
|
||||
{
|
||||
(int X, int Y) = GetTileIDXY(index);
|
||||
var min = new LVector2(X.ToLFloat() * TileSize,Y.ToLFloat() * TileSize);
|
||||
var max = new LVector2((X + 1).ToLFloat() * TileSize,(Y + 1).ToLFloat() * TileSize);
|
||||
return (max,min);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取TileID X Y
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public (int X, int Y) GetTileIDXY(int index)
|
||||
{
|
||||
|
||||
// 遍历数组
|
||||
for (int y = 0; y < Tiles.Length; y++)
|
||||
{
|
||||
for (int x = 0; x < Tiles[y].Length; x++)
|
||||
{
|
||||
// 检查当前元素是否非零
|
||||
if (Tiles[y][x] != 0 && Tiles[y][x] == index)
|
||||
{
|
||||
// 返回找到的坐标
|
||||
return (x,y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception();
|
||||
|
||||
return JNSSTileTool.GetTileContains(Tiles,TileSize,index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -178,22 +150,7 @@ namespace JNGame.Sync.State.Tile
|
||||
/// <returns></returns>
|
||||
public List<int> GetTileGridIndex(int index)
|
||||
{
|
||||
|
||||
List<int> grid = new List<int>();
|
||||
(int X, int Y) = GetTileIDXY(index);
|
||||
// 填充九宫格
|
||||
for (int i = -1; i <= 1; i++)
|
||||
{
|
||||
for (int j = -1; j <= 1; j++)
|
||||
{
|
||||
int tempX = X + i;
|
||||
int tempY = Y + j; // 注意这里j+1+1是因为数组第二维存储的是y坐标
|
||||
if (IsTileIndex((tempX,tempY))) grid.Add(Tiles[tempY][tempX]);
|
||||
}
|
||||
}
|
||||
|
||||
return grid;
|
||||
|
||||
return JNSSTileTool.GetTileGridIndex(Tiles,TileSize,index);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
142
JNFrame2/Assets/JNGame/Sync/App/Tile/JNSSTileTool.cs
Normal file
142
JNFrame2/Assets/JNGame/Sync/App/Tile/JNSSTileTool.cs
Normal file
@@ -0,0 +1,142 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using JNGame.Math;
|
||||
|
||||
namespace JNGame.Sync.State.Tile
|
||||
{
|
||||
public class JNSSTileTool
|
||||
{
|
||||
|
||||
public static bool IsTileIndex(int[][] Tiles,(int X, int Y) xTuple)
|
||||
{
|
||||
if (xTuple.X >= 0 && xTuple.Y >= 0)
|
||||
{
|
||||
return xTuple.Y < Tiles.Length && xTuple.X < Tiles[0].Length;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取TileID X Y
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static (int X, int Y) GetTileIDXY(int[][] Tiles,int index)
|
||||
{
|
||||
|
||||
// 遍历数组
|
||||
for (int y = 0; y < Tiles.Length; y++)
|
||||
{
|
||||
for (int x = 0; x < Tiles[y].Length; x++)
|
||||
{
|
||||
// 检查当前元素是否非零
|
||||
if (Tiles[y][x] != 0 && Tiles[y][x] == index)
|
||||
{
|
||||
// 返回找到的坐标
|
||||
return (x,y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据TileId 获取最大最小范围
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static (LVector2 Max,LVector2 Min) GetTileContains(int[][] Tiles, int TileSize,int index)
|
||||
{
|
||||
(int X, int Y) = GetTileIDXY(Tiles,index);
|
||||
var min = new LVector2(X.ToLFloat() * TileSize,Y.ToLFloat() * TileSize);
|
||||
var max = new LVector2((X + 1).ToLFloat() * TileSize,(Y + 1).ToLFloat() * TileSize);
|
||||
return (max,min);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取九宫格Index
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static List<int> GetTileGridIndex(int[][] Tiles, int TileSize, (int X, int Y) xTuple)
|
||||
{
|
||||
List<int> grid = new List<int>();
|
||||
// 填充九宫格
|
||||
for (int i = -1; i <= 1; i++)
|
||||
{
|
||||
for (int j = -1; j <= 1; j++)
|
||||
{
|
||||
int tempX = xTuple.X + i;
|
||||
int tempY = xTuple.Y + j; // 注意这里j+1+1是因为数组第二维存储的是y坐标
|
||||
if (IsTileIndex(Tiles,(tempX,tempY))) grid.Add(Tiles[tempY][tempX]);
|
||||
}
|
||||
}
|
||||
return grid;
|
||||
}
|
||||
public static List<int> GetTileGridIndex(int[][] Tiles, int TileSize, int index)
|
||||
{
|
||||
return GetTileGridIndex(Tiles,TileSize,GetTileIDXY(Tiles,index));
|
||||
}
|
||||
public static List<int> GetTileGridIndex(int[][] Tiles,int TileSize,LVector3 pos)
|
||||
{
|
||||
return GetTileGridIndex(Tiles,TileSize,GetXYIndex(Tiles,TileSize,pos));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取Index
|
||||
/// </summary>
|
||||
/// <param name="Tiles"></param>
|
||||
/// <param name="TileSize"></param>
|
||||
/// <param name="pos"></param>
|
||||
/// <returns></returns>
|
||||
public static int GetTileIndex(int[][] Tiles,int TileSize,LVector3 pos)
|
||||
{
|
||||
(int x, int y) = JNSSTileTool.GetXYIndex(Tiles,TileSize,pos);
|
||||
return Tiles[y][x];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取XY
|
||||
/// </summary>
|
||||
/// <param name="Tiles"></param>
|
||||
/// <param name="TileSize"></param>
|
||||
/// <param name="pos"></param>
|
||||
/// <returns></returns>
|
||||
public static (int X, int Y) GetXYIndex(int[][] Tiles,int TileSize,LVector3 pos)
|
||||
{
|
||||
// 遍历数组
|
||||
for (int y = 0; y < Tiles.Length; y++)
|
||||
{
|
||||
for (int x = 0; x < Tiles[y].Length; x++)
|
||||
{
|
||||
// 检查当前元素是否非零
|
||||
if (Tiles[y][x] != 0)
|
||||
{
|
||||
|
||||
//判断是否所在区块
|
||||
var min = new LVector2(x.ToLFloat() * TileSize,y.ToLFloat() * TileSize);
|
||||
var max = new LVector2((x + 1).ToLFloat() * TileSize,(y + 1).ToLFloat() * TileSize);
|
||||
|
||||
// 假设LVector2是一个包含X和Y属性的结构体或类
|
||||
// 检查X坐标是否在范围内
|
||||
if (pos.x < min.x || pos.x >= max.x)
|
||||
{
|
||||
continue; // X坐标不在范围内
|
||||
}
|
||||
// 检查Y坐标是否在范围内
|
||||
if (pos.z < min.y || pos.z >= max.y)
|
||||
{
|
||||
continue; // Y坐标不在范围内
|
||||
}
|
||||
|
||||
return (x,y);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (0,0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44baac66240645d887c8996de748dd0c
|
||||
timeCreated: 1724315108
|
@@ -58,6 +58,10 @@ namespace JNGame.Sync.Entity
|
||||
{
|
||||
_id = GetSystem<JNRandomSystem>().NextId();
|
||||
}
|
||||
else
|
||||
{
|
||||
GetSystem<JNRandomSystem>().AdaptId(id);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract JNEntityLookup NewCLookup();
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using DotRecast.Core.Collections;
|
||||
using NotImplementedException = System.NotImplementedException;
|
||||
|
||||
namespace JNGame.Sync.System.Data
|
||||
{
|
||||
@@ -41,7 +42,16 @@ namespace JNGame.Sync.System.Data
|
||||
//网络Id (用于确定网络通讯时找到这个数据系统)
|
||||
public int NetID { get; }
|
||||
|
||||
/// <summary>
|
||||
/// 插入字节
|
||||
/// </summary>
|
||||
public void OnInsertUBytes(Dictionary<long, byte[]> bytes);
|
||||
|
||||
/// <summary>
|
||||
/// 获取全部字节
|
||||
/// </summary>
|
||||
public Dictionary<long, byte[]> GetDataBytes();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -118,34 +128,57 @@ namespace JNGame.Sync.System.Data
|
||||
//提交数据更新
|
||||
OnUByteUpdate(bytes);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取全部字节
|
||||
/// </summary>
|
||||
public Dictionary<long, byte[]> GetDataBytes()
|
||||
{
|
||||
var data = new Dictionary<long, byte[]>();
|
||||
|
||||
lock (Data)
|
||||
{
|
||||
|
||||
Data.ForEach(child =>
|
||||
{
|
||||
data[child.Key] = child.Value.GetByte();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将UByte提交更新
|
||||
/// </summary>
|
||||
public virtual void OnUByteUpdate(Dictionary<long, byte[]> bytes)
|
||||
{
|
||||
foreach (var info in bytes)
|
||||
lock (Data)
|
||||
{
|
||||
if (SDByteOperate.IsDelete(info.Value))
|
||||
foreach (var info in bytes)
|
||||
{
|
||||
Data.Remove(info.Key);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (Data.TryGetValue(info.Key, out var value))
|
||||
if (SDByteOperate.IsDelete(info.Value))
|
||||
{
|
||||
value.UByte(info.Value);
|
||||
Data.Remove(info.Key);
|
||||
}
|
||||
else
|
||||
{
|
||||
Data[info.Key] = NewObject(info.Key,info.Value);
|
||||
}
|
||||
|
||||
if (Data.TryGetValue(info.Key, out var value))
|
||||
{
|
||||
value.UByte(info.Value);
|
||||
}
|
||||
else
|
||||
{
|
||||
Data[info.Key] = NewObject(info.Key,info.Value);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -196,6 +229,6 @@ namespace JNGame.Sync.System.Data
|
||||
{
|
||||
UBytes[id] = SDByteOperate.DELETE;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -1,25 +1,68 @@
|
||||
using System.Collections.Generic;
|
||||
using DotRecast.Core.Collections;
|
||||
using JNGame.Math;
|
||||
using JNGame.Sync.Entity;
|
||||
using JNGame.Sync.Frame.Entity.Components;
|
||||
using JNGame.Sync.State.Tile;
|
||||
using JNGame.Sync.State.Tile.Entity;
|
||||
using NotImplementedException = System.NotImplementedException;
|
||||
|
||||
namespace JNGame.Sync.System.Data
|
||||
{
|
||||
|
||||
public interface ISTileDataSystem
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 清除指定区域数据
|
||||
/// </summary>
|
||||
public void ClearTileData(int index);
|
||||
|
||||
/// <summary>
|
||||
/// 获取有权限的全部字节
|
||||
/// </summary>
|
||||
public Dictionary<long, byte[]> GetHostDataBytes();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取指定区块的全部字节
|
||||
/// </summary>
|
||||
public Dictionary<long, byte[]> GetTileDataBytes(int index);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
public abstract class ISTileData : ISStateData
|
||||
{
|
||||
public abstract bool IsHost { get; }
|
||||
public JNTileEntity Entity;
|
||||
|
||||
/// <summary>
|
||||
/// 绑定实体到数据 (销毁数据时顺带销毁实体)
|
||||
/// </summary>
|
||||
/// <param name="entity"></param>
|
||||
public void BindEntity(JNTileEntity entity)
|
||||
{
|
||||
Entity = entity;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取数据位置(用于区块清除)
|
||||
/// </summary>
|
||||
public abstract LVector3 GetDataPosition();
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 支持区块的数据类
|
||||
/// </summary>
|
||||
public abstract class STileDataSystem<T,E> : SStateDataSystem<T> where T : ISTileData,new() where E : JNTileEntity, new()
|
||||
public abstract class STileDataSystem<T,E> : SStateDataSystem<T>,ISTileDataSystem where T : ISTileData,new() where E : JNTileEntity, new()
|
||||
{
|
||||
|
||||
public abstract JNTileContext<E> NodeContext { get; }
|
||||
|
||||
|
||||
|
||||
protected STileDataSystem(SStateDataEnum type) : base(type)
|
||||
{
|
||||
@@ -40,7 +83,12 @@ namespace JNGame.Sync.System.Data
|
||||
protected virtual void OnDataSyncContext()
|
||||
{
|
||||
|
||||
var lIsTileData = new Dictionary<long, T>(Data);
|
||||
Dictionary<long, T> lIsTileData;
|
||||
|
||||
lock (Data)
|
||||
{
|
||||
lIsTileData = new Dictionary<long, T>(Data);
|
||||
}
|
||||
|
||||
NodeContext.GetEntities().ForEach(child =>
|
||||
{
|
||||
@@ -60,7 +108,9 @@ namespace JNGame.Sync.System.Data
|
||||
foreach (var keyValue in lIsTileData)
|
||||
{
|
||||
var entity = NodeContext.TileSyncCreate(keyValue.Key);
|
||||
entity.TileSyncData(keyValue.Value);
|
||||
entity?.TileSyncData(keyValue.Value);
|
||||
//将实体绑定到数据中
|
||||
keyValue.Value.BindEntity(entity);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -76,6 +126,94 @@ namespace JNGame.Sync.System.Data
|
||||
if (!data.IsHost) return;
|
||||
base.Add(data);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 判断数据是否在区块内
|
||||
/// </summary>
|
||||
public bool IsTileInside(int tileId,T data)
|
||||
{
|
||||
|
||||
var index = -1;
|
||||
|
||||
if (Sync is JNSSTileClientService clientService)
|
||||
{
|
||||
index = clientService.GetTileIndex(data.GetDataPosition());
|
||||
}
|
||||
if (Sync is JNSSTileServerService serverService)
|
||||
{
|
||||
index = serverService.GetTileIndex(data.GetDataPosition());
|
||||
}
|
||||
|
||||
return index == tileId;
|
||||
|
||||
}
|
||||
|
||||
public void ClearTileData(int index)
|
||||
{
|
||||
|
||||
lock (Data)
|
||||
{
|
||||
|
||||
//需要删除的数据Id
|
||||
var ids = new List<long>();
|
||||
|
||||
Data.ForEach(child =>
|
||||
{
|
||||
if (IsTileInside(index,child.Value)) ids.Add(child.Key);
|
||||
});
|
||||
|
||||
//删除数据和实体
|
||||
ids.ForEach(child =>
|
||||
{
|
||||
//销毁实体
|
||||
Data[child].Entity?.Destroy();
|
||||
//销毁数据
|
||||
Data.Remove(child);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<long, byte[]> GetHostDataBytes()
|
||||
{
|
||||
|
||||
var data = new Dictionary<long, byte[]>();
|
||||
|
||||
lock (Data)
|
||||
{
|
||||
Data.ForEach(child =>
|
||||
{
|
||||
if (child.Value.IsHost)
|
||||
{
|
||||
data[child.Key] = child.Value.GetByte();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
|
||||
public Dictionary<long, byte[]> GetTileDataBytes(int index)
|
||||
{
|
||||
|
||||
var data = new Dictionary<long, byte[]>();
|
||||
|
||||
lock (Data)
|
||||
{
|
||||
Data.ForEach(child =>
|
||||
{
|
||||
if (IsTileInside(index,child.Value))
|
||||
{
|
||||
data[child.Key] = child.Value.GetByte();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return data;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -17,6 +17,8 @@ namespace JNGame.Sync.Frame.Service
|
||||
|
||||
//Id
|
||||
private long _id = 0;
|
||||
private long _idMin = long.MinValue;
|
||||
private long _idMax = long.MaxValue;
|
||||
|
||||
public JNRandomSystem(int seed)
|
||||
{
|
||||
@@ -44,13 +46,30 @@ namespace JNGame.Sync.Frame.Service
|
||||
return ++_id;
|
||||
}
|
||||
|
||||
public void SetIdValue(long id)
|
||||
public void SetIdValue(long min,long max)
|
||||
{
|
||||
if (_id < id)
|
||||
if (_id < min)
|
||||
{
|
||||
_id = id;
|
||||
_id = min;
|
||||
}
|
||||
_idMin = min;
|
||||
_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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user