animated_discipline_object = {
	-- ANCHOR
	anchor_x=0,
	anchor_y=0,
	offset_x=0,
	offset_y=0,
	
	-- TEXTURE
	texture="",
	
	-- UI
	animated=true,
	
	-- INIT STATE
	init_state="clean",
	
	-- OBJECT
	object_name = "",
	
	-- STATES NAMES
	invisible_state_name = "clean",
	playing_state_name = "playing",
	
	-- ANIMATION NAMES
	invisible_state_animation = "invisible",
	good_playing_state_animation = "good",
	bad_playing_state_animation = "bad",
	flipped_texture = false,
	
	parent_disciplining = "",
	
	discipline_way = "",
}

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

function animated_discipline_object:clean_init()
	PlayObjectAnimation(self.object_name, self.invisible_state_animation);
end

function animated_discipline_object:good_init()
	self.discipline_way = "good";
	PlayObjectAnimation(self.object_name, self.good_playing_state_animation);
	if self.parent_disciplining ~= "" then
		IncludeObjectMouseHandler(self.object_name);
		setIdleType(self.parent_disciplining, 1);
	end
end

function animated_discipline_object:good_update()
	if not IsObjectAnimationPlaying(self.object_name) then
		PlayObjectAnimation(self.object_name, self.invisible_state_animation);
		ChangeObjectState(self.object_name, self.invisible_state_name);
	end
end

function animated_discipline_object:bad_init()
	self.discipline_way = "bad";
	PlayObjectAnimation(self.object_name, self.bad_playing_state_animation);
	if self.parent_disciplining ~= "" then
		IncludeObjectMouseHandler(self.object_name);
		setIdleType(self.parent_disciplining, 2);
	end
end

function animated_discipline_object:bad_update()
	if not IsObjectAnimationPlaying(self.object_name) then
		PlayObjectAnimation(self.object_name, self.invisible_state_animation);
		ChangeObjectState(self.object_name, self.invisible_state_name);
	end
end

function animated_discipline_object:transition_update()	
	if self.parent_disciplining ~= "" then
		if(self.discipline_way == "good" and isPraised(self.parent_disciplining)) then
			clearPraised(self.parent_disciplining);
		end
		if(self.discipline_way == "bad" and isCorrected(self.parent_disciplining)) then
			clearCorrected(self.parent_disciplining);
		end
		setIdleType(self.parent_disciplining, 0);
		RemoveObjectMouseHandler(self.object_name);
	end
	ChangeObjectState(self.object_name, self.invisible_state_name);
end

function animated_discipline_object:click()
	if self.parent_disciplining ~= "" then
		SetParentSelected(self.parent_disciplining);
	end
end