修复内容:
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:
@@ -18,6 +18,11 @@ namespace BaseGames.World
|
||||
[SerializeField] private SceneFeedback _crumbleFeedback; // 预警震动 + 碎裂粒子 + 音效
|
||||
[SerializeField] private BoxCollider2D _passengerSensor; // IsTrigger,检测玩家踩踏
|
||||
|
||||
[Header("持久化(_isOneShot = true 时生效)")]
|
||||
[Tooltip("平台唯一 ID。_isOneShot=true 时碎裂状态写入 WorldStateRegistry,重载场景后不复原。留空则不持久化。")]
|
||||
[SerializeField] private string _platformId;
|
||||
[SerializeField] private WorldStateRegistry _worldState;
|
||||
|
||||
private BoxCollider2D _col;
|
||||
private SpriteRenderer _sr;
|
||||
private bool _isCrumbling;
|
||||
@@ -28,6 +33,18 @@ namespace BaseGames.World
|
||||
_sr = GetComponent<SpriteRenderer>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// 读档恢复:_isOneShot 平台已碎裂则直接禁用,无需等待触发
|
||||
if (!_isOneShot || string.IsNullOrEmpty(_platformId) || _worldState == null) return;
|
||||
if (!_worldState.HasFlag("crumble_" + _platformId)) return;
|
||||
|
||||
_isCrumbling = true;
|
||||
_col.enabled = false;
|
||||
_sr.enabled = false;
|
||||
if (_passengerSensor != null) _passengerSensor.enabled = false;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D other)
|
||||
{
|
||||
if (_isCrumbling) return;
|
||||
@@ -53,7 +70,12 @@ namespace BaseGames.World
|
||||
_passengerSensor.enabled = false;
|
||||
|
||||
if (_isOneShot || _respawnDelay <= 0f)
|
||||
yield break; // 永久消失
|
||||
{
|
||||
// 持久化一次性碎裂状态,场景重载后不复原
|
||||
if (_isOneShot && !string.IsNullOrEmpty(_platformId))
|
||||
_worldState?.SetFlag("crumble_" + _platformId);
|
||||
yield break;
|
||||
}
|
||||
|
||||
// 4. Respawn
|
||||
yield return new WaitForSeconds(_respawnDelay);
|
||||
|
||||
Reference in New Issue
Block a user