require( "levels_scripts/tasksconstants.lua" );
require( "scripts/objects/schoolagedwaiting.lua" );

schoolaged1sit = schoolagedwaiting:new{
	object_name="schoolaged1sit",

	
	texture="anim/objects/volarosschoolaged1_sit/volarosschoolaged1_sit",
	glow_texture="anim/objects/volarosschoolaged1_sit/volarosschoolaged1_sit_glow",
	glow_animation_script="anim/objects/default_glow_animation_script.lua",
}

function schoolaged1sit:cleaning_update()
	if (GetCurrentTime() - self.new_state_start_time) > self.cleaning_state_time then
		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;		
		
		LoadCharacterTask(self.current_action_character, gotoobjectanddo, "escrivaninha", "escrivaninha");
		
		ShowCharacter(self.current_action_character);
		HideCharacterStuff(self.current_action_character);
		FinishCharacterTask(self.current_action_character);
		
		PlayCharacterAnimation(self.parent_chosen, self.character_clean_animation);
		SetCharacterState(self.parent_chosen, self.parent_state_action);
		FinishCharacterTask(self.parent_chosen);
		
		PlayObjectAnimation(self.object_name, self.object_clean_animation);
		ChangeObjectState(self.object_name, self.clean_state_name);
		
		if self.finish_teamwork then
			FinishTeamWorkTask(self.parent_chosen, self.teamworktask_name, 1);
		end
		
		if self.check_teamwork then
			ShowTeamWorkIcon(self.object_name, 2);
			--ShowTeamWorkIcon(self.object_name, "mom", false);		
		end
		
		self.new_state_start_time = GetCurrentTime();
	end
end

function schoolaged1sit:clean_mess_action()
	if GetObjectState("escrivaninha") == "clean" and
	GetObjectState("estante1") == "clean" and
	GetObjectState("estante2") == "clean" and
	GetObjectState("schoolaged2sit") == "clean" and
	GetObjectState("materialestudo") == "clean" then
		PlayCharacterAnimation(self.current_action_character, self.character_messing_animation);
		FlipAnimation(self.current_action_character, self.flipped_animation);
		PlayObjectAnimation(self.object_name, self.object_messing_animation);
		ChangeObjectState(self.object_name, self.messing_state_name);
		self.new_state_start_time = GetCurrentTime();
		if self.sound_of_messing ~= "" then
			PlaySound(self.sound_of_messing, true);
		end	
		self.previous_state = "messing";
	else
		FinishCharacterTask(self.current_action_character);
	end
end