mirror of
https://gitee.com/jisol/jisol-game/
synced 2025-06-26 19:34:47 +00:00
52 lines
1.2 KiB
C#
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;
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|
||
|
}
|