修复内容:
PlayerMovement:新增 _facingLocked 字段 + LockFacing(bool) 方法;UpdateFacing() 锁定时直接返回 WallSlideState:OnStateEnter 调用 LockFacing(true) + FlipFacing(_wallDir);OnStateExit 调用 LockFacing(false) 解锁 WallJumpState:OnStateEnter 保险性再调一次 LockFacing(false);WallJumpAway/Toward 同步写入 _inputVelocityX,确保解锁后 UpdateFacing 朝向正确(背墙跳 = 离墙方向,对墙跳 = 朝墙方向)
This commit is contained in:
@@ -51,10 +51,15 @@ namespace BaseGames.World
|
||||
|
||||
// ── Physics Triggers ──────────────────────────────────────────────────
|
||||
|
||||
/// <summary>
|
||||
/// 判断碰撞体是否为有效触发来源。子类可覆写以扩展触发主体(如幻影身体)。
|
||||
/// </summary>
|
||||
protected virtual bool IsValidTriggerBody(Collider2D col) => col.CompareTag("Player");
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (_triggerCondition != TriggerCondition.PlayerBody) return;
|
||||
if (!other.CompareTag("Player")) return;
|
||||
if (!IsValidTriggerBody(other)) return;
|
||||
if (!CheckSide(other.transform.position)) return;
|
||||
TryActivate();
|
||||
}
|
||||
@@ -62,7 +67,7 @@ namespace BaseGames.World
|
||||
private void OnTriggerExit2D(Collider2D other)
|
||||
{
|
||||
if (_triggerCondition != TriggerCondition.PlayerBody) return;
|
||||
if (!other.CompareTag("Player") || _isOneShot) return;
|
||||
if (!IsValidTriggerBody(other) || _isOneShot) return;
|
||||
_activated = false;
|
||||
_deactivationChannel?.Raise();
|
||||
}
|
||||
@@ -106,13 +111,14 @@ namespace BaseGames.World
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 读档恢复:若机关已激活则静默还原
|
||||
// 读档恢复:仅标记 _activated = true,不广播激活事件。
|
||||
// 下游组件(PuzzleReceiver / 动画门等)已通过各自的 WorldStateRegistry 检查在 Start 中自行恢复,
|
||||
// 重复广播会导致它们再次播放开门动画等副作用。
|
||||
if (_isOneShot && !string.IsNullOrEmpty(_interactableId)
|
||||
&& _worldState != null
|
||||
&& _worldState.HasFlag("mechanism_" + _interactableId))
|
||||
{
|
||||
_activated = true;
|
||||
_activationChannel?.Raise();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user