require( "scripts/common/simple_object.lua" );

local	indicator_pos_x = 0;
local	indicator_pos_y = -50;

--[[
local	diaper_x = "0";
local	diaper_y = "-70";
local	diaper_layer = "1";
--]]



get_something_object = simple_object:new{
	object_dirty_animation = "DoAnim",
	current_action_character="toddler",
	character_cleaning_animation="doing_stuff_up",
	character_clean_animation="standing_with_stuff",
	anchor_x=-22,
	anchor_y=129,
	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,
	cleaning_state_time = 0,
	
	next_object_selected = "";
	next_object_state = "dirty";
	
	stuff_name = "";
	stuff_x = "";
	stuff_y = "";
	stuff_layer = "";
	
	parent_final_state = "";
	show_cleaning_particle = false;
	
	stress_inc_enabled = false;
	
	complex_object = true;

	is_a_mess = false;
}

function get_something_object:new(o)
	o = o or {}   -- create object if user does not provide one
	setmetatable(o, self)
	self.__index = self
	return o
end

function get_something_object:messing_update()
	if not (IsObjectAnimationPlaying(self.object_name)) then
		PlayObjectAnimation(self.object_name, self.object_dirty_animation);
		ChangeObjectState(self.object_name, self.dirty_state_name);
	end
end

function get_something_object:cleaning_update()
	if (GetCurrentTime() - self.new_state_start_time) > self.cleaning_state_time then
		if self.sound_of_cleaning ~= "" then
			StopSound(self.sound_of_cleaning);
		end
		PlayObjectAnimation(self.next_object_selected, self.next_object_state);
		ChangeObjectState(self.next_object_selected, self.next_object_state);
		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
		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 self.no_stress_power then
			HideNoStressIcon(self.object_name);
		end
		self.no_stress_power = false;
		
		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
		
		if self.is_a_mess then
			FinishTeamWorkTask(self.parent_chosen, "messes", 1);
		end
	end
end