v13 全量评审(终章):修复 TD-19/TD-20 + 编写 v13 评审文档

This commit is contained in:
2026-05-12 16:54:08 +08:00
parent 984a738478
commit 301691d1a0
3 changed files with 342 additions and 14 deletions

View File

@@ -1,6 +1,6 @@
using System.Collections;
using UnityEngine;
using MoreMountains.Tools;
using MoreMountains.Feedbacks;
using BaseGames.Player;
namespace BaseGames.World
@@ -17,7 +17,7 @@ namespace BaseGames.World
[SerializeField] private bool _destroyAfterUnlock = true;
[Header("演出配置")]
[SerializeField] private Component _unlockFeedback; // Assign MMF_Player or compatible component
[SerializeField] private MMF_Player _unlockFeedback;
[SerializeField] private float _cutsceneDuration = 1.5f;
[Header("Event Channel")]
@@ -37,7 +37,7 @@ namespace BaseGames.World
{
_used = true;
PlayFeedback(_unlockFeedback);
_unlockFeedback?.PlayFeedbacks();
yield return new WaitForSeconds(_cutsceneDuration);
stats.UnlockAbility(_abilityToUnlock);
@@ -46,12 +46,5 @@ namespace BaseGames.World
if (_destroyAfterUnlock)
Destroy(gameObject);
}
private static void PlayFeedback(Component feedback)
{
if (feedback == null) return;
var method = feedback.GetType().GetMethod("PlayFeedbacks", System.Type.EmptyTypes);
method?.Invoke(feedback, null);
}
}
}

View File

@@ -19,13 +19,17 @@ namespace BaseGames.World
private IInteractable _nearest;
private IInteractable _previousNearest;
// 预分配检测缓冲区,避免 OverlapCircleAll 每帧 GC 分配
private readonly Collider2D[] _overlapBuffer = new Collider2D[16];
private void OnEnable() => _inputReader.InteractEvent += TryInteract;
private void OnDisable() => _inputReader.InteractEvent -= TryInteract;
private void Update()
{
var hits = Physics2D.OverlapCircleAll(transform.position, _detectRadius, _interactableLayer);
_nearest = FindNearest(hits);
int count = Physics2D.OverlapCircleNonAlloc(
transform.position, _detectRadius, _overlapBuffer, _interactableLayer);
_nearest = FindNearest(_overlapBuffer, count);
if (_nearest != _previousNearest)
{
@@ -51,13 +55,14 @@ namespace BaseGames.World
_nearest.Interact(transform);
}
private IInteractable FindNearest(Collider2D[] hits)
private IInteractable FindNearest(Collider2D[] hits, int count)
{
IInteractable best = null;
float bestDist = float.MaxValue;
foreach (var col in hits)
for (int i = 0; i < count; i++)
{
var col = hits[i];
var interactable = col.GetComponentInParent<IInteractable>();
if (interactable == null || !interactable.CanInteract) continue;