51 lines
1.3 KiB
GDScript3
Raw Permalink Normal View History

extends Node3D
# The player's ship, a safe zone where they can deposit grunk, save their game, and relax.
2025-03-20 08:59:37 -06:00
# TODO figure out whatever this is lol
2025-03-21 19:13:17 -06:00
const MAX_GRUNK := 6400000.0
2025-04-22 14:20:46 -06:00
const MIN_LIQUID_PCT := 0.001
2025-03-20 08:59:37 -06:00
const LIQUID_FACTOR := 2.8
const TANK_FILL_TIME := 1.0
@onready var tank_interactor: Interactive = %TankInteractor
2025-03-20 08:59:37 -06:00
@onready var grunk_liquid: MeshInstance3D = %GrunkLiquid
2025-04-02 12:19:06 -06:00
@onready var grunk_pump_sfx: AudioStreamPlayer3D = %GrunkPumpSFX
func _ready() -> void:
World.instance.manager.grunk_collected.connect(_enable_tank)
2025-04-22 14:20:46 -06:00
_deferred_init.call_deferred()
func _deferred_init() -> void:
set_liquid_level(vault_fill_pct())
func _enable_tank(_delta: float) -> void:
tank_interactor.enabled = true
## Called when the player interacts with the grunk tank.
func deposit_grunk() -> void:
# Tank is disabled until the player collects more grunk.
tank_interactor.enabled = false
World.instance.manager.deposit_tank()
2025-04-22 14:20:46 -06:00
set_liquid_level(vault_fill_pct())
2025-03-20 08:59:37 -06:00
2025-04-02 12:19:06 -06:00
grunk_pump_sfx.play()
2025-03-20 08:59:37 -06:00
2025-04-22 14:20:46 -06:00
func vault_fill_pct() -> float:
return clampf(World.instance.manager.grunk_vault / MAX_GRUNK, 0.0, 1.0)
2025-03-20 08:59:37 -06:00
func set_liquid_level(proportion: float) -> void:
2025-04-22 14:20:46 -06:00
if proportion > MIN_LIQUID_PCT:
(
create_tween()
. tween_property(grunk_liquid, "position:y", proportion * LIQUID_FACTOR, TANK_FILL_TIME)
. set_trans(Tween.TRANS_EXPO)
)