优化属性更新逻辑

This commit is contained in:
DESKTOP-5RP3AKU\Jisol
2024-09-22 03:27:16 +08:00
parent c59ebd6280
commit 81fee86ba7
54 changed files with 271 additions and 97 deletions

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Collections.Generic;
using DotRecast.Core.Collections;
using UnityEngine;
using NotImplementedException = System.NotImplementedException;
@@ -6,6 +7,16 @@ using NotImplementedException = System.NotImplementedException;
namespace JNGame.Sync.System.Data
{
public static class SDByteOperate
{
public static readonly byte[] Delete = { 0 }; //删除
public static bool IsDelete(byte[] value)
{
return value.Length == 1 && value[0] == Delete[0];
}
}
public enum SStateDataEnum
{
Server,
@@ -57,7 +68,7 @@ namespace JNGame.Sync.System.Data
/// <summary>
/// 状态同步的数据系统 (支持网络数据)
/// 注意:帧同步也可以使用不过不建议 因为会有额外开销 除非你的游戏 经常在帧同步或者状态同步之间切换
/// 注意:帧同步也可以使用不过不建议 因为会有额外开销 除非你的游戏 经常在帧同步或者状态同步之间切换 如果你要在帧同步系统中使用 则使用 ServerClient类型
/// </summary>
public abstract class SStateDataSystem<T> : SDataSystem<T>,ISStateDataSystem where T : ISStateData,new()
{
@@ -79,10 +90,10 @@ namespace JNGame.Sync.System.Data
{
Type = type;
}
public override void OnSyncUpdate(int dt)
{
while (WaitUBytes.Count > 0)
{
OnUByteUpdate(WaitUBytes.Dequeue());
@@ -241,7 +252,7 @@ namespace JNGame.Sync.System.Data
/// </summary>
public virtual void Delete(ulong id)
{
UBytes[id] = SDByteOperate.DELETE;
UBytes[id] = SDByteOperate.Delete;
}
}

View File

@@ -76,7 +76,6 @@ namespace JNGame.Sync.System.Data
public JNSSTileServerService TileSync => Sync as JNSSTileServerService;
public bool IsMaster => TileSync is not null && TileSync.IsMaster;
public bool IsSlave => TileSync is not null && TileSync.IsSlave;
protected STileDataSystem(SStateDataEnum type) : base(type)
{
@@ -113,6 +112,14 @@ namespace JNGame.Sync.System.Data
public override void OnSyncUpdate(int dt)
{
//如果不是Tile系统直接调用base
if (Sync is not JNSSTileServerService)
{
base.OnSyncUpdate(dt);
return;
}
while (WaitUBytes.Count > 0)
{
OnUByteUpdate(WaitUBytes.Dequeue());