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

local	indicator_pos_x = 65;
local	indicator_pos_y = -15;

local ObjectTable = GetObjectTable("bookshelftakestudymaterials");

bookshelf1 = get_something_object:new{
	object_name="bookshelf1",
	
	anchor_x=14,
	anchor_y=62,
	offset_x=-9,
	offset_y=-3,
	
	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_cleaning_animation = "doing_stuff_up";
	--object_cleaning_animation = "opened";
	
	next_object_selected = "escrivaninha";
	next_object_state = "dirty";
	
	stuff_name = "books";
	stuff_x = "0";
	stuff_y = "-70";
	stuff_layer = "1";
	
	parent_final_state = "holding_books";
	
	texture="anim/objects/bookshelf/bookshelf",
	animation_script="anim/objects/bookshelf/bookshelf1_animation_script.lua",
	glow_texture="anim/objects/bookshelf/glow1/bookshelf_glow",
	glow_animation_script="anim/objects/default_glow_animation_script.lua",
	flipped_texture = true,
	
	cleaning_state_time = 500,
	
	complex_object = true;
	next_task_x = 25,
	next_task_y = -100,
	
	stress_inc_enabled = false;

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

	is_a_mess = false;
}

function bookshelf1:cleaning_update()
	if (GetCurrentTime() - self.new_state_start_time) > self.cleaning_state_time then
		if self.parent_chosen == "dad" then
			StopSound("working_father");
			PlaySound("task_complete_father", false);
			ShowDadNextTaskIcon(self.next_object_selected);			
		else
			StopSound("working_mother");
			PlaySound("task_complete_mother", false);
			ShowMomNextTaskIcon(self.next_object_selected);
		end
		
		if self.stress_inc_enabled and not self.no_stress_power then
			AddCharacterStress(self.parent_chosen, self.stress_inc);
		end
		if self.no_stress_power then
			HideNoStressIcon(self.object_name);
		end
		self.no_stress_power = false;
		
		PlayCharacterAnimation(self.parent_chosen, self.character_clean_animation);	
		SetCharacterState(self.parent_chosen, self.parent_final_state);
		ShowCharacterStuff(self.parent_chosen, self.stuff_name, self.stuff_x, self.stuff_y, self.stuff_layer);
		--AddCharacterStress(self.parent_chosen, self.stress_inc);
		FinishCharacterTask(self.parent_chosen);
		
		PlayObjectAnimation(self.object_name, "without_books");
		ChangeObjectState(self.object_name, "without_books");
		self.click_enable = false;
		
		PlayGlowAnimation(self.object_name, "clean");
		
		PlayObjectAnimation("estante2", "dirty");
		
		HideNextTaskIcon(self.object_name);
		
		PlayObjectAnimation(self.next_object_selected, self.next_object_state);
		ChangeObjectState(self.next_object_selected, self.next_object_state);
	end
end