迁移 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,55 @@
using System;
using System.Collections.Generic;
using SepCore.DataTable;
using SepCore.Definition;
using UnityEngine;
namespace Entity.EntityData
{
[Serializable]
public class EnemyData : TargetableObjectData
{
private DREnemy _drEnemy;
public EnemyData(int entityId, DREnemy drEnemy, int level) : base(
entityId, drEnemy.Id, CampType.Enemy)
{
_drEnemy = drEnemy;
int effectiveLevel = Mathf.Max(1, level);
MaxHealthBase = _drEnemy.MaxHealth + _drEnemy.HpAddPerLevel * (effectiveLevel - 1);
}
public EnemyType EnemyType => (EnemyType)_drEnemy.Id;
public int EntityTypeId => _drEnemy.EntityTypeId;
public override int MaxHealthBase { get; }
public int AttackDamage => _drEnemy.AttackDamage;
public float AttackCooldown => _drEnemy.AttackCooldown;
public float AttackRange => _drEnemy.AttackRange;
public float SpeedBase => _drEnemy.Speed;
public int DropCoin => _drEnemy.DropCoin;
public int DropExp => _drEnemy.DropExp;
public float DropPercent => _drEnemy.DropPercent;
public IReadOnlyDictionary<string, string> Params => _drEnemy.Params;
public bool TryGetParam(string key, out string value)
{
value = null;
if (string.IsNullOrEmpty(key) || _drEnemy?.Params == null)
{
return false;
}
return _drEnemy.Params.TryGetValue(key, out value);
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 1b802c30cc274e04929b8659ec631e84
timeCreated: 1768890974
@@ -0,0 +1,29 @@
using System;
using SepCore.Definition;
using UnityEngine;
namespace Entity.EntityData
{
[Serializable]
public class EnemyProjectileData : EntityDataBase
{
public EnemyProjectileData(int entityId, int ownerEntityId, CampType ownerCamp, int attackDamage,
float speed, float lifeTime, Vector3 direction)
: base(entityId, 0)
{
OwnerEntityId = ownerEntityId;
OwnerCamp = ownerCamp;
AttackDamage = attackDamage;
Speed = speed;
LifeTime = lifeTime;
Direction = direction;
}
public int OwnerEntityId { get; }
public CampType OwnerCamp { get; }
public int AttackDamage { get; }
public float Speed { get; }
public float LifeTime { get; }
public Vector3 Direction { get; }
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 52b38f83ab6c4029803d40c189db47c7
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: