多轮审查和修复

This commit is contained in:
2026-05-12 15:34:08 +08:00
parent f55d2a57c3
commit ebbbb7332e
805 changed files with 838724 additions and 1905 deletions

View File

@@ -0,0 +1,58 @@
using UnityEngine;
using BaseGames.Parry;
namespace BaseGames.Combat
{
/// <summary>
/// 可被玩家弹反的抛射物。
/// 触发时优先检测弹反窗口;若成功弹反则反向飞行并可切换伤害源;
/// 否则走正常伤害流水线。
/// </summary>
public class ParryableProjectile : LinearProjectile
{
[SerializeField] private DamageSourceSO _reflectSource;
private bool _reflected;
protected override void OnInitialized()
{
// 禁用子 HitBox 的自动检测,改由本组件的 OnTriggerEnter2D 手动处理,
// 以便在命中前插入弹反判断。
_hitBox.Deactivate();
_rb.velocity = Direction * _config.Speed;
}
private void OnTriggerEnter2D(Collider2D other)
{
// ── 弹反判断 ────────────────────────────────────────────────
if (!_reflected)
{
var parrySystem = other.GetComponentInParent<ParrySystem>();
if (parrySystem != null && parrySystem.IsParrying && parrySystem.ConsumeParry())
{
_reflected = true;
Direction = -Direction;
_rb.velocity = Direction * _config.Speed * _config.ParrySpeedMultiplier;
if (_reflectSource != null)
DamageInfo = DamageInfo.From(_reflectSource);
return;
}
}
// ── 正常命中 ─────────────────────────────────────────────────
var hurtBox = other.GetComponent<HurtBox>();
if (hurtBox != null)
{
hurtBox.ReceiveDamage(DamageInfo);
ReturnToPool();
}
}
protected override void OnDisable()
{
base.OnDisable();
_reflected = false;
}
}
}