备份,准备做双端
This commit is contained in:
@@ -71,6 +71,10 @@ public class effectEventController : MonoBehaviour
|
||||
|
||||
// 门控:漂移关闭且已归位后,跳过每帧的 Perlin/缓存查找;开关切换时才归位一次。
|
||||
private bool _driftResetDone;
|
||||
// Last PlayerSkillService.SelectionVersion this controller applied its camera offset for.
|
||||
// While it matches the current version (and the pivot is already resolved), the offset
|
||||
// cannot change, so we skip the per-frame IsSkillEnabled traversal + localPosition write.
|
||||
private int _appliedSkillSelectionVersion = -1;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
@@ -86,7 +90,13 @@ public class effectEventController : MonoBehaviour
|
||||
_driftResetDone = true;
|
||||
}
|
||||
|
||||
UpdatePlayerSkillCameraOffset();
|
||||
// The camera offset only depends on the selected skill. Re-evaluate it once per
|
||||
// selection change; while the version is unchanged and the pivot is resolved, the
|
||||
// result is identical, so we can skip the work entirely.
|
||||
if (cachedCameraSkillPivot == null || _appliedSkillSelectionVersion != PlayerSkillService.SelectionVersion)
|
||||
{
|
||||
UpdatePlayerSkillCameraOffset();
|
||||
}
|
||||
}
|
||||
|
||||
private void CacheShakeTarget()
|
||||
@@ -378,6 +388,10 @@ public class effectEventController : MonoBehaviour
|
||||
if (cachedCameraSkillPivot == null)
|
||||
return;
|
||||
|
||||
// Pivot is resolved; mark this selection version as applied so Update can skip
|
||||
// subsequent frames until the selection changes again.
|
||||
_appliedSkillSelectionVersion = PlayerSkillService.SelectionVersion;
|
||||
|
||||
Vector3 targetLocalPosition = cameraSkillBaseLocalPosition;
|
||||
if (PlayerSkillService.IsSkillEnabled(10))
|
||||
{
|
||||
@@ -472,8 +486,12 @@ public class effectEventController : MonoBehaviour
|
||||
if (shake.timeSettings.fadeOutCurve == null || shake.timeSettings.fadeOutCurve.length == 0)
|
||||
shake.timeSettings.fadeOutCurve = AnimationCurve.Linear(0f, 1f, 1f, 0f);
|
||||
|
||||
shake.shakers = new[] { shake.positionShake, shake.rotationShake };
|
||||
shake.sum = new Vector3[2];
|
||||
// 复用已同步的内部数组(通常 PrewarmShakeComponent 已建好),仅在缺失/尺寸不符时重建,
|
||||
// 避免每次多押命中都分配两个数组。
|
||||
if (shake.shakers == null || shake.shakers.Length != 2)
|
||||
shake.shakers = new[] { shake.positionShake, shake.rotationShake };
|
||||
if (shake.sum == null || shake.sum.Length != 2)
|
||||
shake.sum = new Vector3[2];
|
||||
shake.StartShake();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user