迁移 EntityData 到 Base 中

- 新增 EntityDataFactory 工厂类,提供创建 EntityData 的统一入口
- 移出 EntityData 及派生类对 GameEntry 的依赖并移入 SepCore.Base 程序集中
This commit is contained in:
SepComet
2026-06-03 15:12:55 +08:00
parent 91f70dd783
commit 5de3fdc795
52 changed files with 284 additions and 315 deletions
@@ -0,0 +1,44 @@
using System;
using SepCore.DataTable;
using Entity.EntityData;
using SepCore.Definition;
namespace SepCore.Utility
{
public static class EntityDataFactory
{
public static EnemyData Create(int entityId, EnemyType enemyType, int level)
{
var dr = GameEntry.DataTable.GetDataTableRow<DREnemy>((int)enemyType);
return new EnemyData(entityId, dr, level);
}
public static WeaponData Create(int entityId, WeaponType weaponType, int ownerId, CampType ownerCamp)
{
var dr = GameEntry.DataTable.GetDataTableRow<DRWeapon>((int)weaponType);
return weaponType switch
{
WeaponType.WeaponHandgun => new WeaponHandgunData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponKnife => new WeaponKnifeData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponSlash => new WeaponSlashData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponLightning => new WeaponLightningData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponLance => new WeaponLanceData(entityId, dr, ownerId, ownerCamp),
_ => throw new NotImplementedException()
};
}
public static WeaponData Create(int entityId, DRWeapon dr, int ownerId, CampType ownerCamp)
{
WeaponType type = (WeaponType)dr.Id;
return type switch
{
WeaponType.WeaponHandgun => new WeaponHandgunData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponKnife => new WeaponKnifeData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponSlash => new WeaponSlashData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponLightning => new WeaponLightningData(entityId, dr, ownerId, ownerCamp),
WeaponType.WeaponLance => new WeaponLanceData(entityId, dr, ownerId, ownerCamp),
_ => throw new NotImplementedException()
};
}
}
}