-- ************************************ Station ************************************ --
BathRobeStation = deriveLuaClass("BathRobeStation", "WorkStation")

function BathRobeStation:init(desc)
	self.workAnimationFrameTime = 100

	BathRobeStation.superInit(desc)
	self.maxOccupants = 0

	self.bathrobes = self:newChild({class="Sprite",	x=3, y=-43, image="ROOM1_BATHROBES:objects"})
	self:linkNodeUnderAtFront(self.bathrobes)
	self.bathrobes:setFrame(self.stock)
end

function BathRobeStation:hasWorkToDo()
	return true
end

function BathRobeStation:addToStationTask()
	if (BathRobeStation.super.addToStationTask(self)) then
		level:bm_onRestockBathrobes()
		return true
	end
	self:stopFaultySelectionBlink()
	return false
end

function BathRobeStation:onStockChange()
	level:getObject("changestation_1"):onStockChanged()
	level:getObject("changestation_2"):onStockChanged()
end

function BathRobeStation:onDisplayStockChange()
	assert(self.bathrobes)
	self.bathrobes:setFrame(self.stock)

	if (self.stock == 0) then
		hintManager:handle({id="empty_robes", sprite=self})
	end
end

function BathRobeStation:onWorkStart(task)
	local r = BathRobeStation.super.onWorkStart(self, task)
	if (self.stock == self.maxStock) then
		return false
	end
	hero:playAnimation(self.workAnimation, -1, "default", self.workAnimationFrameTime)
	task.duration = self.workDuration
	return r
end

function BathRobeStation:onWorkFinish(task)
	self:resetStock()
end
