generated from krampus/template-godot4
Ship grunk level is persisted
This commit is contained in:
parent
22a22a6409
commit
48c9953c53
@ -3,6 +3,7 @@ extends Node3D
|
|||||||
|
|
||||||
# TODO figure out whatever this is lol
|
# TODO figure out whatever this is lol
|
||||||
const MAX_GRUNK := 6400000.0
|
const MAX_GRUNK := 6400000.0
|
||||||
|
const MIN_LIQUID_PCT := 0.001
|
||||||
const LIQUID_FACTOR := 2.8
|
const LIQUID_FACTOR := 2.8
|
||||||
|
|
||||||
const TANK_FILL_TIME := 1.0
|
const TANK_FILL_TIME := 1.0
|
||||||
@ -14,6 +15,11 @@ const TANK_FILL_TIME := 1.0
|
|||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
World.instance.manager.grunk_collected.connect(_enable_tank)
|
World.instance.manager.grunk_collected.connect(_enable_tank)
|
||||||
|
_deferred_init.call_deferred()
|
||||||
|
|
||||||
|
|
||||||
|
func _deferred_init() -> void:
|
||||||
|
set_liquid_level(vault_fill_pct())
|
||||||
|
|
||||||
|
|
||||||
func _enable_tank(_delta: float) -> void:
|
func _enable_tank(_delta: float) -> void:
|
||||||
@ -26,14 +32,19 @@ func deposit_grunk() -> void:
|
|||||||
tank_interactor.enabled = false
|
tank_interactor.enabled = false
|
||||||
World.instance.manager.deposit_tank()
|
World.instance.manager.deposit_tank()
|
||||||
|
|
||||||
set_liquid_level(clampf(World.instance.manager.grunk_vault / MAX_GRUNK, 0.0, 1.0))
|
set_liquid_level(vault_fill_pct())
|
||||||
|
|
||||||
grunk_pump_sfx.play()
|
grunk_pump_sfx.play()
|
||||||
|
|
||||||
|
|
||||||
|
func vault_fill_pct() -> float:
|
||||||
|
return clampf(World.instance.manager.grunk_vault / MAX_GRUNK, 0.0, 1.0)
|
||||||
|
|
||||||
|
|
||||||
func set_liquid_level(proportion: float) -> void:
|
func set_liquid_level(proportion: float) -> void:
|
||||||
(
|
if proportion > MIN_LIQUID_PCT:
|
||||||
create_tween()
|
(
|
||||||
. tween_property(grunk_liquid, "position:y", proportion * LIQUID_FACTOR, TANK_FILL_TIME)
|
create_tween()
|
||||||
. set_trans(Tween.TRANS_EXPO)
|
. tween_property(grunk_liquid, "position:y", proportion * LIQUID_FACTOR, TANK_FILL_TIME)
|
||||||
)
|
. set_trans(Tween.TRANS_EXPO)
|
||||||
|
)
|
||||||
|
@ -344,10 +344,10 @@ anchor_left = 0.5
|
|||||||
anchor_top = 0.5
|
anchor_top = 0.5
|
||||||
anchor_right = 0.5
|
anchor_right = 0.5
|
||||||
anchor_bottom = 0.5
|
anchor_bottom = 0.5
|
||||||
offset_left = -402.339
|
offset_left = -399.906
|
||||||
offset_top = -299.253
|
offset_top = -299.03
|
||||||
offset_right = -402.339
|
offset_right = -399.906
|
||||||
offset_bottom = -299.253
|
offset_bottom = -299.03
|
||||||
grow_horizontal = 2
|
grow_horizontal = 2
|
||||||
grow_vertical = 2
|
grow_vertical = 2
|
||||||
script = ExtResource("4_ud8na")
|
script = ExtResource("4_ud8na")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user