迁移数据表到 Luban,移除 JsonNet、EnumUtility

This commit is contained in:
2026-09-13 14:08:14 +08:00
parent 4003b3aaba
commit de53890de6
607 changed files with 18515 additions and 3257 deletions
@@ -1,64 +0,0 @@
using System;
using Cysharp.Threading.Tasks;
using GameFramework;
using GameFramework.DataTable;
using SepCore.DataTable;
using UnityGameFramework.Runtime;
namespace SepCore.AsyncTask
{
/// <summary>
/// DataTable 异步扩展方法
/// </summary>
public static class DataTableAsyncExtension
{
/// <summary>
/// 异步加载数据表
/// </summary>
/// <param name="dataTableComponent">数据表组件</param>
/// <param name="dataTableAssetName">数据表资源名称</param>
/// <param name="userData">用户自定义数据</param>
/// <param name="timeout">超时时间(秒),0表示不超时</param>
/// <returns>加载成功事件</returns>
public static UniTask<LoadDataTableSuccessEventArgs> LoadDataTableAsync(this DataTableComponent dataTableComponent,
string dataTableAssetName,
object userData = null,
float timeout = 30f)
{
UniTask<LoadDataTableSuccessEventArgs> waitTask = AsyncTaskHelper.WaitSuccessOrFailureAsync<LoadDataTableSuccessEventArgs, LoadDataTableFailureEventArgs>(
LoadDataTableSuccessEventArgs.EventId,
LoadDataTableFailureEventArgs.EventId,
successArgs => successArgs.DataTableAssetName == dataTableAssetName && ReferenceEquals(successArgs.UserData, userData),
failureArgs => failureArgs.DataTableAssetName == dataTableAssetName && ReferenceEquals(failureArgs.UserData, userData),
timeout
);
string dataTableName = System.IO.Path.GetFileNameWithoutExtension(dataTableAssetName);
dataTableComponent.LoadDataTable(dataTableName, dataTableAssetName, userData);
return waitTask;
}
/// <summary>
/// 异步加载数据表(泛型版本)
/// </summary>
/// <typeparam name="T">数据行类型</typeparam>
/// <param name="dataTableComponent">数据表组件</param>
/// <param name="dataTableAssetName">数据表资源名称</param>
/// <param name="userData">用户自定义数据</param>
/// <param name="timeout">超时时间(秒),0表示不超时</param>
/// <returns>加载的数据表</returns>
public static UniTask<IDataTable<T>> LoadDataTableAsync<T>(this DataTableComponent dataTableComponent,
string dataTableAssetName,
object userData = null,
float timeout = 30f) where T : IDataRow
{
return LoadDataTableAsync(dataTableComponent, dataTableAssetName, userData, timeout)
.ContinueWith(successArgs =>
{
// 获取数据表名称(去掉路径和扩展名)
string dataTableName = System.IO.Path.GetFileNameWithoutExtension(dataTableAssetName);
return dataTableComponent.GetDataTable<T>(dataTableName);
});
}
}
}
@@ -1,11 +0,0 @@
fileFormatVersion: 2
guid: fd425f3318ddacb44a9c9468dcd434bf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
@@ -3,7 +3,6 @@ using System.Collections.Generic;
using System.Threading;
using Cysharp.Threading.Tasks;
using SepCore.CustomUtility;
using SepCore.DataTable;
using SepCore.Definition;
using SepCore.Entity;
using SepCore.Entity.Weapon;
@@ -22,7 +21,6 @@ namespace SepCore.AsyncTask
private const string EntityNamespace = "SepCore.Entity.";
private static readonly Dictionary<string, Type> _typeDict = new();
private static readonly Dictionary<int, string> _assetNameDict = new();
/// <summary>
/// 异步显示实体
@@ -171,15 +169,16 @@ namespace SepCore.AsyncTask
}
Type enemyType = TryGetType(data.EnemyType.ToString());
string assetName = TryGetAssetName(data.EntityTypeId);
if (enemyType == null || string.IsNullOrEmpty(assetName))
EntityConfig entityConfig = GameEntry.Luban.Get<EntityConfig>(data.AssetName);
if (enemyType == null || entityConfig == null)
{
Log.Warning("Can not load enemy logic type or entity config for assetName '{0}'.", data.AssetName);
return UniTask.FromResult<EnemyBase>(null);
}
return entityComponent
.ShowEntityAsync(data.Id, enemyType, AssetUtility.GetEntityAsset(assetName), "Enemy",
Constant.AssetPriority.BulletAsset, data, timeout, cancellationToken)
.ShowEntityAsync(data.Id, enemyType, AssetUtility.GetEntityAsset(entityConfig.PrefabPath), "Enemy",
Constant.AssetPriority.EnemyAsset, data, timeout, cancellationToken)
.ContinueWith(entity => entity?.Logic as EnemyBase);
}
@@ -198,15 +197,16 @@ namespace SepCore.AsyncTask
}
Type weaponType = TryGetType("Weapon." + data.WeaponType);
string assetName = TryGetAssetName(data.EntityTypeId);
if (weaponType == null || string.IsNullOrEmpty(assetName))
EntityConfig entityConfig = GameEntry.Luban.Get<EntityConfig>(data.AssetName);
if (weaponType == null || entityConfig == null)
{
Log.Warning("Can not load weapon logic type or entity config for assetName '{0}'.", data.AssetName);
return UniTask.FromResult<WeaponBase>(null);
}
return entityComponent
.ShowEntityAsync(data.Id, weaponType, AssetUtility.GetEntityAsset(assetName), "Weapon",
Constant.AssetPriority.BulletAsset, data, timeout, cancellationToken)
.ShowEntityAsync(data.Id, weaponType, AssetUtility.GetEntityAsset(entityConfig.PrefabPath), "Weapon",
Constant.AssetPriority.WeaponAsset, data, timeout, cancellationToken)
.ContinueWith(entity => entity?.Logic as WeaponBase);
}
@@ -304,14 +304,14 @@ namespace SepCore.AsyncTask
return UniTask.FromResult<T>(null);
}
DREntity drEntity = GameEntry.DataTable.GetDataTableRow<DREntity>(data.TypeId);
if (drEntity == null)
EntityConfig entityConfig = GameEntry.Luban.Get<EntityConfig>(data.AssetName);
if (entityConfig == null)
{
Log.Warning("Can not load entity id '{0}' from data table.", data.TypeId.ToString());
Log.Warning("Can not load entity assetName '{0}' from data table.", data.AssetName);
return UniTask.FromResult<T>(null);
}
return entityComponent.ShowEntityAsync<T>(data.Id, AssetUtility.GetEntityAsset(drEntity.AssetName),
return entityComponent.ShowEntityAsync<T>(data.Id, AssetUtility.GetEntityAsset(entityConfig.PrefabPath),
entityGroupName, priority, data, timeout, cancellationToken);
}
@@ -332,23 +332,5 @@ namespace SepCore.AsyncTask
return type;
}
private static string TryGetAssetName(int entityId)
{
if (!_assetNameDict.TryGetValue(entityId, out string assetName))
{
DREntity drEntity = GameEntry.DataTable.GetDataTableRow<DREntity>(entityId);
if (drEntity == null)
{
Log.Warning("Can not load entity id '{0}' from data table.", entityId.ToString());
return null;
}
assetName = drEntity.AssetName;
_assetNameDict.Add(entityId, assetName);
}
return assetName;
}
}
}