迁移数据表到 Luban,移除 JsonNet、EnumUtility
This commit is contained in:
+14
-32
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user