require( "scripts/objects/get_something_object.lua" );

local	indicator_pos_x = -5;
local	indicator_pos_y = -20;

local ObjectTable = GetObjectTable("timetocleanoutsidetable");
outsidetable4 = get_something_object:new{	
	anchor_x=-40,
	anchor_y=98,
	
	--[[
	texture="anim/objects/singletonsdinnertable/dinnertable3/dinnertable3",
	animation_script="anim/objects/singletonsdinnertable/dinnertable3/dinnertable3_animation_script.lua",
	glow_texture="anim/objects/singletonsdinnertable/glow/dinnertable_glow",
	glow_animation_script="anim/objects/default_glow_animation_script.lua",
	--]]
	
	indicator_ui_x=indicator_pos_x,
	indicator_ui_y=indicator_pos_y,
	dad_ui_x=indicator_pos_x+35,
	dad_ui_y=indicator_pos_y,
	mom_ui_x=indicator_pos_x+35,
	mom_ui_y=indicator_pos_y,
	
	character_messing_animation = "doing_stuff_up",
	character_cleaning_animation = "doing_bow_down",
	
	next_object_selected = "pia";
	
	stuff_name = "dishes";
	stuff_x = "0";
	stuff_y = "-70";
	stuff_layer = "1";
	
	complex_object = true;
	next_task_x = indicator_pos_x,
	next_task_y = indicator_pos_y,
	
	parent_final_state = "holding_dishes";
	
	cleaning_state_time = 500,
	messing_state_time = 500,
	flipped_animation = false,
	
	check_teamwork = true;
	finish_teamwork = false;
	teamworktask_name = "dothedishes";
	
	stress_inc_enabled = false;

	messing_state_time = ObjectTable["messing_time"],
	cleaning_state_time = ObjectTable["cleaning_time"],
	stress_inc = ObjectTable["stress_inc"],
}

function outsidetable4:cleaning_update()
	if (GetCurrentTime() - self.new_state_start_time) > self.cleaning_state_time then
		if self.no_stress_power then
			HideNoStressIcon(self.object_name);
		end
		
		if self.parent_chosen == "dad" then
			ShowDadNextTaskIcon(self.next_object_selected);
		else
			ShowMomNextTaskIcon(self.next_object_selected);
		end
		
		self.no_stress_power = false;
		PlayCharacterAnimation(self.parent_chosen, self.character_clean_animation);
		ShowCharacterStuff(self.parent_chosen, self.stuff_name, self.stuff_x, self.stuff_y, self.stuff_layer);
		SetCharacterState(self.parent_chosen, self.parent_final_state);
		--AddCharacterStress(self.parent_chosen, self.stress_inc);
		FinishCharacterTask(self.parent_chosen);
		
		PlayObjectAnimation(self.object_name, self.object_clean_animation);
		ChangeObjectState(self.object_name, self.clean_state_name);
		
		if (GetObjectState("mesafora1") ~= "dirty") then
			PlayObjectAnimation("mesafora1", "clean");
			ChangeObjectState("mesafora1", "restarttable");
		end
		
		PlayObjectAnimation("mesafora2", "clean");
		ChangeObjectState("mesafora2", "clean");
		
		PlayObjectAnimation(self.next_object_selected, self.next_object_state);
		ChangeObjectState(self.next_object_selected, self.next_object_state);
		
		self.cleaning_state_time = self.previous_cleaning_state_time;
		
		if self.complex_object then
			HideNextTaskIcon(self.object_name);
			HideDadNextTaskIcon(self.object_name);
			HideMomNextTaskIcon(self.object_name);
		end
		
		FinishTeamWorkTask(self.parent_chosen, "messes", 1);
	end
end