Make jetpack versions easily swappable in the code.

layered_gunshot
tokc 2021-03-30 17:31:16 +02:00
parent 2aab6e1287
commit 104cdc76e0
1 changed files with 12 additions and 11 deletions

View File

@ -103,15 +103,18 @@ remote func jump():
$Sounds/Jump.play()
weapon_bob_anim.travel("Jump")
"""
# Charge when empty variant.
func jetpack(delta):
#debug.text = "Jetpack fuel: %s\nJetpack active: %s\nJetpack used: %s\nJetpack sound: %s" % [
# jetpack_fuel, jetpack_active, jetpack_used, !$Sounds/Jetpack.stream_paused
#]
# Swap these to try the different versions of the jetpack.
jetpack_grounded(delta)
#jetpack_empty(delta)
func jetpack_empty(delta):
debug.text = "JP fuel: %s\nJP active: %s\nJP used: %s\nJP sound: %s" % [
jetpack_fuel, jetpack_active, jetpack_used, !$Sounds/Jetpack.stream_paused
]
# Enable jetpack when it is fully charged.
if jetpack_fuel == JETPACK_FUEL_MAX:
if jetpack_fuel > (JETPACK_FUEL_MAX - 0.001):
jetpack_used = false
# Disable jetpack when it is empty.
elif jetpack_fuel <= 0 and not jetpack_active:
@ -131,16 +134,15 @@ func jetpack(delta):
0.0,
JETPACK_FUEL_MAX
)
"""
# Charge when grounded variant.
func jetpack(delta):
debug.text = "Jetpack fuel: %s\nJetpack active: %s\nJetpack sound: %s" % [
func jetpack_grounded(delta):
debug.text = "JP fuel: %s\nJP active: %s\nJP sound: %s" % [
jetpack_fuel, jetpack_active, !$Sounds/Jetpack.stream_paused
]
# Only charge when grounded.
if is_on_floor():
if is_on_floor:
jetpack_fuel = clamp(
jetpack_fuel + JETPACK_REFILL_RATE * delta,
0.0,
@ -157,7 +159,6 @@ func jetpack(delta):
$Sounds/Jetpack.stream_paused = false
else:
$Sounds/Jetpack.stream_paused = true
remote func mouselook_abs(x, y):
camera.rotation.x = x