extends TileMapLayer var movement_tween var last_level = 0 @export var level: int func _ready() -> void: Triggerer.listen("flood_level", _on_flood_level) func _on_flood_level(data): var value = int(data.value) var oldvalue = last_level if value < level and visible: if movement_tween: movement_tween.kill() movement_tween = create_tween() movement_tween.set_ease(Tween.EASE_OUT) movement_tween.set_trans(Tween.TRANS_BACK) movement_tween.tween_interval(((oldvalue - level)) * 0.1) movement_tween.tween_property(self, "position:y", 8, 0.1) movement_tween.tween_callback(func(): visible = false ) elif value >= level and not visible: if movement_tween: movement_tween.kill() movement_tween = create_tween() movement_tween.set_ease(Tween.EASE_OUT) movement_tween.set_trans(Tween.TRANS_BACK) movement_tween.tween_interval((level - oldvalue) * 0.1) movement_tween.tween_callback(func(): position.y = 8 visible = true ) movement_tween.tween_property(self, "position:y", 0, 0.1) last_level = value