// Handles Weapon State Based on Current Motor State private void HandleWeaponState() { // Facing Direction and Reload Usage on Walls and Corners if (motor.motorState == PlatformerMotor2D.MotorState.WallSticking || motor.motorState == PlatformerMotor2D.MotorState.WallSliding) { if (motor.collidingAgainst == PlatformerMotor2D.CollidedSurface.LeftWall) { bLastWallCollisionDirLeft = true; } else if (motor.collidingAgainst == PlatformerMotor2D.CollidedSurface.RightWall) { bLastWallCollisionDirLeft = false; } motor.facingLeft = !bLastWallCollisionDirLeft; bOnWall = true; bOnCorner = false; bLockedDirection = true; bReloadDisabled = true; if (CurrentWeapon.Reloading) { CurrentWeapon.CancelReload(); } } else if (motor.motorState == PlatformerMotor2D.MotorState.OnCorner || motor.motorState == PlatformerMotor2D.MotorState.ClimbingCorner) { if (motor.collidingAgainst == PlatformerMotor2D.CollidedSurface.LeftWall) { bLastWallCollisionDirLeft = true; } else if (motor.collidingAgainst == PlatformerMotor2D.CollidedSurface.RightWall) { bLastWallCollisionDirLeft = false; } motor.facingLeft = bLastWallCollisionDirLeft; if (motor.motorState == PlatformerMotor2D.MotorState.OnCorner) { if (bAimState || animator.ArmBusy || bWallJumpReady) { motor.facingLeft = !motor.facingLeft; } } else { if (CurrentWeapon.Bolting) { CurrentWeapon.CancelBolt(); } } bFacingLeft = motor.facingLeft; bOnWall = false; bOnCorner = true; bLockedDirection = true; bReloadDisabled = true; if (CurrentWeapon.Reloading) { CurrentWeapon.CancelReload(); } } else { bOnWall = false; bOnCorner = false; bLockedDirection = false; bReloadDisabled = false; } // Weapon Usage while Dashing or Climbing Corners if (motor.motorState == PlatformerMotor2D.MotorState.Dashing) { bWeaponDisabled = true; bAimState = false; if (motor.velocity.x > 0.1f) { bFacingLeft = false; } else if (motor.velocity.x < -0.1f) { bFacingLeft = true; } bHolsteringWeapon = false; bUnholsteringWeapon = false; bReloadDisabled = true; if (CurrentWeapon.Reloading) { CurrentWeapon.CancelReload(); } if (CurrentWeapon.Bolting) { CurrentWeapon.CancelBolt(); } motor.facingLeft = bFacingLeft; } else if (motor.motorState == PlatformerMotor2D.MotorState.ClimbingCorner) { bAimState = false; bWeaponDisabled = true; bHolsteringWeapon = false; bUnholsteringWeapon = false; } else { // If not switching weapon and not holding weapon if (!bHolsteringWeapon && !bUnholsteringWeapon) { if (bHoldingWeapon) { CurrentWeapon.bActive = true; } else { bUnholsteringWeapon = true; } } bWeaponDisabled = false; } // If not holding weapon, disable weapon if (!bHoldingWeapon) { bWeaponDisabled = true; } // If on wall or corner, set increased recoil multiplier of non secondary weapons if (CurrentWeapon.HoldType != eWeaponHoldType.Secondary) { if (bOnWall || bOnCorner) { CurrentWeapon.SetRecoilMultiplier(fOnWallWeaponRecoil); } else { CurrentWeapon.SetRecoilMultiplier(1); } } else { CurrentWeapon.SetRecoilMultiplier(1); } if (!bAimState) { bAimingDownSights = false; } CurrentWeapon.SetReloadDisabled(bReloadDisabled); }