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


drawingsquare2 = discipline_kids_left_dirty_no_animation:new{
	object_name="drawingsquare2",
	
	anchor_y = -30,
	
	dad_ui_x=-21,
	dad_ui_y=-71,
	mom_ui_x=-21,
	mom_ui_y=-71,
	
	character_messing_animation = "doing_stuff_up",
	object_left_dirty = "desenhobanheiro";
	object_dad_disciplining = "daddiscipline6";
	object_mom_disciplining = "momdiscipline6";
	--object_child_being_disciplined = "schoolageddiscipline1";
	parent_node_discipline = "112";
	
	texture="anim/objects/fall_floor/fall_floor",
	animation_script="anim/objects/default_animation_script.lua",
	glow_texture="anim/objects/fall_floor/fall_floor_glow",
	glow_animation_script="anim/objects/default_glow_animation_script.lua",
	
	animated = true,
	
	mask = true;
	maskX = 0;
	maskY = -30;
	maskWidth = 92;
	maskHeight = 90;
	maskAlpha = 0.01;
	
	cleaning_state_time = 5000;
	messing_state_time = 10000;
	
	sound_of_messing = "drawing";
	
	flipped_animation = true;
	
	object_to_verify = "desenhobanheiro";	
	node_of_discipline = "58";
}

function drawingsquare2:clean_mess_action()
	if self.object_to_verify == "" or GetObjectState(self.object_to_verify) ~= "cleaning" then
		PlayCharacterAnimation(self.current_action_character, self.character_messing_animation);
		FlipAnimation(self.current_action_character, self.flipped_animation);
		ChangeObjectState(self.object_name, self.dirty_state_name);
		
		if self.sound_of_messing ~= "" then
			PlaySound(self.sound_of_messing, true);
		end
		LoadCharacterTask(self.current_action_character, gotonodeanddo, self.node_of_discipline, self.object_name);
	else
		LoadCharacterTask(self.current_action_character, gotonodeanddo, self.node_of_discipline, "idle");
		FinishCharacterTask(self.current_action_character);
	end
end

function drawingsquare2:child_give_up()
	FinishCharacterTask(self.current_action_character);
	ChangeObjectState(self.object_name, self.clean_state_name);
end

function drawingsquare2:parent_action()	
	self.parent_is_coming = false;
	DebugOut("discipline_kids:parent_action:"..self.object_name);
	
	if self.parent_chosen == "dad" then
		HideDadIcon(self.object_name);
	else
		HideMomIcon(self.object_name);
	end
	
	RemoveObjectFromClickedList(self.object_name);
	if GetCharacterState(self.parent_chosen) == self.parent_state_action and self.object_is_dirty then
		if self.sound_of_work_enable then
			if self.parent_chosen == "dad" then
				--PlaySound("working_father", true);
			else
				--PlaySound("working_mother", true);
			end
		end
		PlayObjectAnimation(self.object_name, self.object_cleaning_animation);
		
		--ChangeObjectState(self.object_left_dirty, "dirty");
		FinishCharacterTask(self.current_action_character);
		
		PlayObjectAnimation(self.object_name, self.object_clean_animation);
		PlayGlowAnimation(self.object_name, "clean");		
		
		ChangeObjectState(self.object_name, "waitingchild");
		SetCharacterState(self.parent_chosen, self.cleaning_state_name);
		
		if self.cleaning_timer_enabled then
			SetCleaningTimerVisible(self.object_name, true);
		end
		
		if self.sound_of_messing ~= "" then
			StopSound(self.sound_of_messing);
		end
		
		if self.sound_of_cleaning ~= "" then
			PlaySound(self.sound_of_cleaning, true);
		end
	else
		ShowMiss(self.object_name);
		if self.stress_inc_enabled and not self.no_stress_power then
			AddFutureCharacterStress(self.parent_chosen, -self.stress_inc);
		end
		if self.no_stress_power then
			HideNoStressIcon(self.object_name);
		end
		self.no_stress_power = false;
		FinishCharacterTask(self.parent_chosen);
		self.parent_chosen = "";
		self.click_enable = self.set_click_enable;
		if self.object_is_dirty then
			IncludeObjectMouseHandler(self.object_name);			
			self.click_enable = true;
			PlayObjectAnimation(self.object_name, self.object_dirty_animation);
		else
			if self.click_enable then
				IncludeObjectMouseHandler(self.object_name);
			end
		end
	end
end