DESKTOP-5RP3AKU\Jisol c85f350e0a 临时提交
2024-10-17 01:59:25 +08:00

52 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using Game.JNGState.Logic.Data;
using JNGame.Sync.System;
using JNGame.Sync.View;
using UnityEngine;
namespace Game.JNGFrame.View
{
public abstract class VDEntityBasis<T> : ViewData<T> where T : IGDataBase
{
private readonly Dictionary<int, Action<(GameObject View, T Data)>> Event = new();
protected VDEntityBasis(SViewSystem root) : base(root)
{
}
public override void Execute()
{
base.Execute();
//调用改动
var dataList = GetData();
foreach (var data in dataList){
if (views.TryGetValue(data.Id,out var view))
{
data.WriteCodes.ForEach(code =>
{
Event[code]?.Invoke((view.Data,data));
});
}
}
}
public override void ViewUpdate(T data, GameObject view)
{
}
public void Register(int code,Action<(GameObject View, T Data)> action)
{
Event[code] = action;
}
}
}