extends OnRoadObject

@export var mud_area: Area2D = null
@export var mud_time: float = 0.2


func _ready() -> void:
	super()
	var rand_rot: int = randi() % 4
	rotation = PI / 2 * rand_rot
	mud_area.area_entered.connect(_on_area_entered)
	mud_area.area_exited.connect(_on_area_exited)


func _on_area_entered(area: Area2D) -> void:
	if area.has_method(&"mud_effect"):
		area.mud_effect(mud_time)


func _on_area_exited(area: Area2D) -> void:
	if area.has_method(&"mud_exited"):
		area.mud_exited()
