Add WeaponFeedback component and AddressableManagerWindow meta file

- Implemented WeaponFeedback class for handling weapon-related feedbacks such as hit effects and attack sounds.
- Added meta file for AddressableManagerWindow to manage addressable assets.
- Included a new jump.data file for profiler data.
This commit is contained in:
2026-05-22 22:03:32 +08:00
parent 3e1f234ddc
commit b7baf7ad6a
44 changed files with 1783 additions and 1927 deletions

View File

@@ -4,6 +4,7 @@ using System.Collections.Generic;
using BaseGames.Player;
using BaseGames.Input;
using BaseGames.Combat;
using BaseGames.Feedback;
namespace BaseGames.Skills
{
@@ -41,13 +42,23 @@ namespace BaseGames.Skills
private FormSkillSO _soulSkill;
private FormSkillSO _spirit1;
private FormSkillSO _spirit2;
private IFeedbackPlayer _feedback;
// 冷却字典FormSkillSO → 剩余冷却秒数UpdateSkillSet 时重建
private readonly Dictionary<FormSkillSO, float> _cooldowns = new(3);
// 无分配 Update 遍历用的快照数组
private FormSkillSO[] _activeSkills = System.Array.Empty<FormSkillSO>();
// 技能 HitBox 对象池prefab → 已创建的实例列表,通过 activeSelf 判断是否可复用
private readonly Dictionary<GameObject, List<SkillHitBoxInstance>> _hitBoxPools = new();
// ── 生命周期 ──────────────────────────────────────────────────────────
private void Awake()
{
_feedback = GetComponentInChildren<IFeedbackPlayer>()
?? GetComponentInParent<IFeedbackPlayer>()
?? NullFeedbackPlayer.Instance;
}
private void OnEnable()
{
if (_input != null)
@@ -147,6 +158,9 @@ namespace BaseGames.Skills
_cooldowns[skill] = p.effectiveCooldown;
// 施放反馈
_feedback.TriggerPreset("skill_cast");
// 播放动画(优先修改器动画,回退技能默认动画)
var clip = p.effectiveAnimation.Clip != null
? p.effectiveAnimation
@@ -158,14 +172,40 @@ namespace BaseGames.Skills
if (skill.SkillHitBoxPrefab != null)
{
var socket = _skillSocket != null ? _skillSocket : transform;
var go = Object.Instantiate(skill.SkillHitBoxPrefab, socket.position,
socket.rotation, socket);
var inst = go.GetComponent<SkillHitBoxInstance>();
var inst = GetOrCreateHitBox(skill.SkillHitBoxPrefab, socket);
inst?.Activate(skill.damageSource, transform);
inst?.AutoDestroyAfter(skill.castLockDuration > 0f ? skill.castLockDuration : 0.5f);
inst?.AutoReturnAfter(skill.castLockDuration > 0f ? skill.castLockDuration : 0.5f);
}
}
/// <summary>
/// 从对象池获取或新建 SkillHitBoxInstance。
/// 扫描该 prefab 已创建的实例列表,找到首个未激活的复用;
/// 无可用实例时 Instantiate并追加到列表供下次复用。
/// </summary>
private SkillHitBoxInstance GetOrCreateHitBox(GameObject prefab, Transform socket)
{
if (!_hitBoxPools.TryGetValue(prefab, out var list))
_hitBoxPools[prefab] = list = new List<SkillHitBoxInstance>(2);
for (int i = 0; i < list.Count; i++)
{
var pooled = list[i];
if (pooled != null && !pooled.gameObject.activeSelf)
{
pooled.transform.SetParent(socket);
pooled.transform.SetPositionAndRotation(socket.position, socket.rotation);
pooled.gameObject.SetActive(true);
return pooled;
}
}
var go = Object.Instantiate(prefab, socket.position, socket.rotation, socket);
var inst = go.GetComponent<SkillHitBoxInstance>();
if (inst != null) list.Add(inst);
return inst;
}
// ── 属性查询 ─────────────────────────────────────────────────────────
public FormSkillSO SoulSkill => _soulSkill;
public FormSkillSO Spirit1 => _spirit1;