refactor(enemy): BossResource 去掉自动放招,触发权交回 AI 图

满值时由 BossResource 直接调 UseBossSkill 是绕过决策层执行,
违反「AI 只决策、能力负责实现」。现在只维护数值并暴露 IsFull,
AI 图挂 When(x => x.Boss.ResourceFull) 边进专属招态。
顺带解除对即将删除的 BossSkillSO 的依赖。

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-07-30 16:13:51 +08:00
co-authored by Claude Opus 5
parent 02c3a764a5
commit 635ab69bb6
2 changed files with 7 additions and 35 deletions
@@ -9,7 +9,7 @@ namespace BaseGames.Boss
/// - 每帧以 <see cref="BossResourceConfigSO.passiveRate"/> 自动积累或消耗。
/// - 受击时增加 <see cref="BossResourceConfigSO.onTakeDamageGain"/>。
/// - 技能使用时增加 <see cref="BossResourceConfigSO.onSkillUseGain"/>。
/// - 满值时 <see cref="BossResourceConfigSO.autoTriggerOnFull"/>,自动让 BossBase 执行配置的技能
/// - 满值时 <see cref="IsFull"/> 为真,由 AI 图的条件边决定放什么招(决策不在本组件)
/// </summary>
public sealed class BossResource : MonoBehaviour
{
@@ -17,7 +17,6 @@ namespace BaseGames.Boss
[SerializeField] private BossBase _boss;
private float _currentValue;
private bool _fullTriggered;
/// <summary>当前资源值(0 ~ config.maxValue)。</summary>
public float CurrentValue => _currentValue;
@@ -59,14 +58,14 @@ namespace BaseGames.Boss
AddValue(_config.onTakeDamageGain);
}
/// <summary>Boss 使用技能时调用。由 BossBase.UseBossSkill 触发。</summary>
/// <summary>Boss 使用技能时调用。由使用了资源的能力触发(Boss 的招在自己的 EnemyAbilityBase 里调用)。</summary>
public void OnBossUseSkill()
{
if (_config == null) return;
AddValue(_config.onSkillUseGain);
}
/// <summary>直接设置资源值(外部强制赋值,跳过满值触发)。</summary>
/// <summary>直接设置资源值(外部强制赋值)。</summary>
public void SetValue(float value)
{
_currentValue = Mathf.Clamp(value, 0f, _config != null ? _config.maxValue : float.MaxValue);
@@ -76,33 +75,7 @@ namespace BaseGames.Boss
private void AddValue(float delta)
{
float prev = _currentValue;
_currentValue = Mathf.Clamp(_currentValue + delta, 0f, _config.maxValue);
// 满值触发(从未满→满时只触发一次)
if (_config.autoTriggerOnFull &&
_currentValue >= _config.maxValue &&
prev < _config.maxValue &&
!_fullTriggered)
{
_fullTriggered = true;
OnReachFull();
}
if (_currentValue < _config.maxValue)
_fullTriggered = false;
}
private void OnReachFull()
{
if (_config.fullTriggerSkill == null || _boss == null) return;
_boss.UseBossSkill(_config.fullTriggerSkill.skillId);
if (_config.resetValueAfterTrigger > 0f)
_currentValue = _config.resetValueAfterTrigger;
else
_currentValue = 0f;
}
}
}