优化属性更新逻辑

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

@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: cecc61f462364f198db69cf70c6c557d
timeCreated: 1726941153

View File

@@ -10,6 +10,10 @@ using JNGame.Sync.System.Data;
namespace Game.JNGState.Logic.Data
{
public enum EDPlayerValueCode : int
{
Auth = 201
}
[Serializable]
public class EDPlayerValue : GDataValue
@@ -46,7 +50,11 @@ namespace Game.JNGState.Logic.Data
public override void UData(EDPlayerValue data)
{
base.UData(data);
if (data.Auth is not null) Value.Auth = data.Auth;
if (data.Auth is not null)
{
Value.Auth = data.Auth;
WriteUpdate((int)EDPlayerValueCode.Auth);
}
}
}

View File

@@ -9,17 +9,41 @@ using JNGame.Sync.System;
using JNGame.Sync.System.Data;
using Plugins.JNGame.Network.Action;
using Plugins.JNGame.Util;
using TouchSocket.Core;
namespace Game.JNGState.Logic.Data
{
public enum GDataValueCode : int
{
Position = 101
}
[Serializable]
public class GDataValue
{
public DValuePosition Position = null;
}
public abstract class IGDataBase : ISTileData
{
//计入修改
public readonly ConcurrentList<int> WriteCodes = new();
/// <summary>
/// 计入修改
/// </summary>
/// <param name="code"></param>
public void WriteUpdate(int code)
{
if (WriteCodes.Contains(code)) return;
WriteCodes.Add(code);
}
}
public class GDataBase<Self,T,N> : ISTileData where Self : GDataBase<Self,T,N> where T : GDataValue,new() where N : JNTileEntity
public class GDataBase<Self,T,N> : IGDataBase where Self : GDataBase<Self,T,N> where T : GDataValue,new() where N : JNTileEntity
{
public readonly T Value = new ();
@@ -93,7 +117,11 @@ namespace Game.JNGState.Logic.Data
/// </summary>
public virtual void UData(T data)
{
if (data.Position is not null) Value.Position = data.Position;
if (data.Position is not null)
{
Value.Position = data.Position;
WriteUpdate((int)GDataValueCode.Position);
}
}
public override LVector3 GetDataPosition()