Fix bug in weapon switching
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -61,12 +61,19 @@ class Player {
|
||||
|
||||
void updateWeaponSwitch() {
|
||||
if (switchState == WeaponSwitchState.lowering) {
|
||||
// If the map doesn't contain the pending weapon, stop immediately
|
||||
if (weapons[pendingWeaponType] == null) {
|
||||
switchState = WeaponSwitchState.idle;
|
||||
return;
|
||||
}
|
||||
|
||||
weaponAnimOffset += switchSpeed;
|
||||
if (weaponAnimOffset >= 500.0) {
|
||||
weaponAnimOffset = 500.0;
|
||||
|
||||
// Grab the pending weapon from inventory, default to pistol if something goes wrong
|
||||
currentWeapon = weapons[pendingWeaponType ?? WeaponType.pistol]!;
|
||||
// We already know it's not null now, but we can keep the
|
||||
// fallback to pistol just to be extra safe.
|
||||
currentWeapon = weapons[pendingWeaponType]!;
|
||||
|
||||
switchState = WeaponSwitchState.raising;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user