添加 SepCore.Runtime 和 SepCore.Base 程序集

- 暂时将 Entity 全部归进 Runtime 程序集里
- 调整部分 UI 的 UseCase/RawData/Context 之间的关系,让 RawData 更接近业务原始数据,Context 更接近 UI 直接可读的数据
- 调整其他程序集的引用关系
This commit is contained in:
SepComet
2026-06-03 11:15:58 +08:00
parent d5893ac52b
commit 91f70dd783
176 changed files with 245 additions and 231 deletions
@@ -0,0 +1,81 @@
//------------------------------------------------------------
// Game Framework
// Copyright © 2013-2021 Jiang Yin. All rights reserved.
// Homepage: https://gameframework.cn/
// Feedback: mailto:ellan@gameframework.cn
//------------------------------------------------------------
using Components;
using SepCore.Definition;
using Entity.EntityData;
using CustomUtility;
using UnityEngine;
namespace Entity
{
/// <summary>
/// 可作为目标的实体类。
/// </summary>
public abstract class TargetableObject : EntityBase
{
protected abstract TargetableObjectData _targetableObjectData { get; }
public bool IsDead => _healthComponent.CurrentHealth <= 0;
protected HealthComponent _healthComponent;
public abstract ImpactData GetImpactData();
public void ApplyDamage(EntityBase attacker, int damageHP)
{
float fromHPRatio = _healthComponent.HealthRatio;
_healthComponent.TakeDamage(damageHP);
float toHPRatio = _healthComponent.HealthRatio;
if (fromHPRatio > toHPRatio)
{
GameEntry.HPBar.ShowHPBar(this, fromHPRatio, toHPRatio);
}
if (_healthComponent.CurrentHealth <= 0)
{
OnDead(attacker);
}
}
protected override void OnInit(object userData)
{
base.OnInit(userData);
_healthComponent = GetComponent<HealthComponent>();
}
protected override void OnShow(object userData)
{
base.OnShow(userData);
}
protected virtual void OnDead(EntityBase attacker)
{
GameEntry.Entity.HideEntity(this);
}
private void OnTriggerEnter(Collider other)
{
EntityBase entity = other.GetComponentInParent<EntityBase>();
if (entity == null || entity == this)
{
return;
}
if (entity is TargetableObject && entity.Id < Id)
{
// 碰撞事件由 Id 大的一方处理
// 在这里约定 Enemy 的 Id 为非负数(通常从 0 开始)
// 而其他的 Entity (Player, Weapon, Bullet) 的 Id 均小于 0
return;
}
AIUtility.PerformCollision(this, entity);
}
}
}