mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-09-27 10:46:17 +00:00
提交
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using Newtonsoft.Json;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Plugins.JNGame.Sync.Frame.game
|
||||
@@ -10,7 +12,8 @@ namespace Plugins.JNGame.Sync.Frame.game
|
||||
|
||||
//标识
|
||||
private int _nId;
|
||||
|
||||
public int NID => _nId;
|
||||
|
||||
//当前输入
|
||||
private T _input;
|
||||
|
||||
@@ -42,8 +45,21 @@ namespace Plugins.JNGame.Sync.Frame.game
|
||||
//加载
|
||||
public abstract void OnSyncLoad();
|
||||
|
||||
|
||||
//解析
|
||||
public T Decoder(byte[] bytes)
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(Encoding.UTF8.GetString(bytes));
|
||||
}
|
||||
|
||||
//编码
|
||||
public byte[] Encoder(T input){
|
||||
return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(input));
|
||||
}
|
||||
|
||||
|
||||
//帧同步
|
||||
public abstract void OnSyncUpdate(int dt,JNFrameInfo frame,Input input = null);
|
||||
public abstract void OnSyncUpdate(int dt,JNFrameInfo frame,T input);
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user