feat: Implement DownDash ability and related systems

- Added DownDash ability with cooldown and speed configuration.
- Introduced DownDashState to handle down dashing mechanics, including gravity manipulation and animation playback.
- Updated PlayerMovement to support DownDash functionality.
- Enhanced PlayerStats to manage spring charge consumption and healing.
- Modified PlayerCombat and WeaponHitBoxInstance to support new hit confirmation events.
- Updated AbilityType to include new form types for character abilities.
- Improved Gizmos for better visualization of enemy detection and attack ranges.
- Added feedback systems for form switching in PlayerFeedback and IFeedbackPlayer.
- Refactored combat and movement states to accommodate new abilities and ensure smooth transitions.
This commit is contained in:
2026-05-22 00:09:50 +08:00
parent 534de11e5d
commit 47bdc67cdf
27 changed files with 443 additions and 129 deletions

View File

@@ -27,6 +27,9 @@ namespace BaseGames.Player
// 护符注入的武器覆盖Key = FormSO.formIdValue = 替换武器(架构 05 §7
private readonly Dictionary<string, WeaponSO> _overrides = new();
// 对象池:避免每次切换形态时 Instantiate/DestroyKey = WeaponSOValue = 已创建实例)
private readonly Dictionary<WeaponSO, WeaponHitBoxInstance> _hitBoxPool = new();
private void Awake()
{
if (_formController != null && _formController.CurrentForm != null)
@@ -70,22 +73,33 @@ namespace BaseGames.Player
private void SetDirectWeapon(WeaponSO weapon)
{
var oldInstance = ActiveHitBoxInstance;
// 归还旧实例到池SetActive(false) 会触发 HitBox.OnDisable → Deactivate自动关闭 Collider2D
ActiveHitBoxInstance?.gameObject.SetActive(false);
ActiveWeapon = weapon;
ActiveHitBoxInstance = null;
if (weapon?.hitBoxPrefab != null && _weaponSocket != null)
{
var go = Instantiate(weapon.hitBoxPrefab, _weaponSocket);
ActiveHitBoxInstance = go.GetComponent<WeaponHitBoxInstance>();
if (!_hitBoxPool.TryGetValue(weapon, out var pooled) || pooled == null)
{
var go = Instantiate(weapon.hitBoxPrefab, _weaponSocket);
pooled = go.GetComponent<WeaponHitBoxInstance>();
_hitBoxPool[weapon] = pooled;
}
pooled.gameObject.SetActive(true);
ActiveHitBoxInstance = pooled;
}
// 通知订阅者(使其有机会取消旧实例事件订阅),再销毁旧实例
// 通知订阅者(PlayerCombat 取消旧实例事件订阅,订阅新实例
OnWeaponChanged?.Invoke(weapon);
}
if (oldInstance != null)
Destroy(oldInstance.gameObject);
private void OnDestroy()
{
foreach (var inst in _hitBoxPool.Values)
if (inst != null) Destroy(inst.gameObject);
_hitBoxPool.Clear();
}
// ── 护符 Override API由 WeaponOverrideEffect 调用,架构 05 §7──────