迁移数据表到 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,9 +1,7 @@
using System;
using System;
using System.Collections.Generic;
using SepCore.Definition;
using SepCore.Entity;
using UnityGameFramework.Runtime;
using SepCore.DataTable;
using SepCore.CustomUtility;
namespace SepCore.Entity
@@ -11,15 +9,14 @@ namespace SepCore.Entity
public static class EntityExtension
{
private static int s_SerialId = -10;
private static int _serialId = 0;
private const string EntityNamespace = "SepCore.Entity.";
private static readonly Dictionary<string, Type> _typeDict;
private static readonly Dictionary<int, string> _assetNameDict;
static EntityExtension()
{
_typeDict = new Dictionary<string, Type>();
_assetNameDict = new Dictionary<int, string>();
}
public static EntityBase GetGameEntity(this EntityComponent entityComponent, int entityId)
@@ -44,6 +41,26 @@ namespace SepCore.Entity
entityComponent.AttachEntity(entityBase.Entity, ownerId, parentTransformPath, userData);
}
public static void ShowEntity<T>(this EntityComponent entityComponent, EntityDataBase data, string group,
int priority) where T : EntityBase
{
if (data == null)
{
Log.Warning("Data is invalid.");
return;
}
EntityConfig entityConfig = GameEntry.Luban.Get<EntityConfig>(data.AssetName);
if (entityConfig == null)
{
Log.Warning("Can not load entity assetName '{0}' from data table.", data.AssetName);
return;
}
entityComponent.ShowEntity(data.Id, typeof(T), AssetUtility.GetEntityAsset(entityConfig.PrefabPath), group,
priority, data);
}
public static void ShowPlayer(this EntityComponent entityComponent, PlayerData data)
{
entityComponent.ShowEntity(typeof(Player), "Player", Constant.AssetPriority.PlayerAsset, data);
@@ -58,15 +75,7 @@ namespace SepCore.Entity
}
var enemyType = TryGetType(data.EnemyType.ToString());
var assetName = TryGetAssetName(data.EntityTypeId);
entityComponent.ShowEntity(
entityId: data.Id,
entityLogicType: enemyType,
entityAssetName: AssetUtility.GetEntityAsset(assetName),
entityGroupName: "Enemy",
priority: Constant.AssetPriority.BulletAsset,
userData: data);
entityComponent.ShowEntity(enemyType, "Enemy", Constant.AssetPriority.EnemyAsset, data);
}
public static void ShowWeapon(this EntityComponent entityComponent, WeaponData data)
@@ -78,37 +87,9 @@ namespace SepCore.Entity
}
var weaponType = TryGetType("Weapon." + data.WeaponType);
var assetName = TryGetAssetName(data.EntityTypeId);
entityComponent.ShowEntity(
entityId: data.Id,
entityLogicType: weaponType,
entityAssetName: AssetUtility.GetEntityAsset(assetName),
entityGroupName: "Weapon",
priority: Constant.AssetPriority.BulletAsset,
userData: data);
entityComponent.ShowEntity(weaponType, "Weapon", Constant.AssetPriority.WeaponAsset, data);
}
// public static void ShowBullet(this EntityComponent entityComponent, BulletData data)
// {
// if (data == null)
// {
// Log.Warning("Bullet data is invalid.");
// return;
// }
//
// var bulletType = TryGetType(data.BulletType.ToString());
// string assetName = TryGetAssetName(data.EntityTypeId);
//
// entityComponent.ShowEntity(
// entityId: data.Id,
// entityLogicType: bulletType,
// entityAssetName: AssetUtility.GetEntityAsset(assetName),
// entityGroupName: "Bullet",
// priority: Constant.AssetPriority.BulletAsset,
// userData: data);
// }
public static void ShowEffect(this EntityComponent entityComponent, EffectData data)
{
entityComponent.ShowEntity(typeof(Effect), "Effect", Constant.AssetPriority.EffectAsset, data);
@@ -133,14 +114,14 @@ namespace SepCore.Entity
return;
}
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;
}
entityComponent.ShowEntity(data.Id, logicType, AssetUtility.GetEntityAsset(drEntity.AssetName), entityGroup,
entityComponent.ShowEntity(data.Id, logicType, AssetUtility.GetEntityAsset(entityConfig.PrefabPath), entityGroup,
priority, data);
}
@@ -162,27 +143,14 @@ namespace SepCore.Entity
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 bullet entity id '{0}' from data table.", entityId.ToString());
return null;
}
assetName = drEntity.AssetName;
_assetNameDict.Add(entityId, assetName);
}
return assetName;
}
public static int NextId(this EntityComponent entityComponent)
{
return --s_SerialId;
}
public static int SerialId(this EntityComponent entityComponent)
{
return ++_serialId;
}
}
}