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:
@@ -27,6 +27,9 @@ namespace BaseGames.Player
|
||||
// 护符注入的武器覆盖:Key = FormSO.formId,Value = 替换武器(架构 05 §7)
|
||||
private readonly Dictionary<string, WeaponSO> _overrides = new();
|
||||
|
||||
// 对象池:避免每次切换形态时 Instantiate/Destroy(Key = WeaponSO,Value = 已创建实例)
|
||||
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)──────
|
||||
|
||||
Reference in New Issue
Block a user