class_name RestProvider extends WorkProvider
## Phase 3 smoke-test WorkProvider: sends every pawn to a shared rest tile.
##
## If the pawn is already at rest_tile, returns a walk-less idle-forever job.
## Otherwise prepends a walk_to toil before the idle toil.
##
## No internal state beyond rest_tile — Decision's log line carries all
## the info needed for debugging (pawn name + provider category + job label).


## The tile pawns walk toward. Set by the world scene on instantiation.
@export var rest_tile: Vector2i = Vector2i(40, 40)


func _init() -> void:
	category = &"rest"
	priority = 0  # Only provider in Phase 3; no relative ordering needed yet.


## Returns a Job for `pawn`. Never returns null — Rest always has something
## to offer (walk there, or idle in place).
## `pawn` is duck-typed: must expose .tile (Vector2i).
func find_best_for(pawn) -> Job:
	var j := Job.new()
	j.label = "Rest at %s" % rest_tile

	if pawn.tile != rest_tile:
		j.toils.append(Toil.walk_to(rest_tile))

	j.toils.append(Toil.idle())
	return j
