layoutShed.shownCatScare = false
layoutShed.shownFakeScare = false
-- ----------------------------------------------------------------------------
layoutShed.mExits =
{
	[objectShedPorchdoor] = 
	{
		target = layoutPorch,
		arrowX = 744,
		arrowY = 637,
		arrowAngle = 1.04 * math.pi,
		labelX = 777,
		labelY = 590,
		labelAnchorpoint = ANCHOR_CENTER_LEFT,
	},
}
layoutShed.mPOIs = 
{
	[objectShedCabinet] = 
	{
		target = layoutShedCabinet,
		sparkleX = 577,
    	sparkleY = 192,
	},
	[objectShedLawnmowerHitarea] = 
	{
		target = layoutShedLawnmower,
		sparkleX = 306,
    	sparkleY = 509,	
	},
	[objectShedShuttermanualOpen] = 
	{
		target = layoutShedShutterManual,
	},
	[objectShedToolboxLocked] = 
	{
		target = layoutShedToolbox,
		mirrors = {objectShedToolboxOpen},
		sparkleX = 779,
    	sparkleY = 441,	
	},
}
layoutShed.mHOs = 
{
	[objectShedElectricaltape] = 
	{
		siblings = {objectShedElectricaltapeDark, objectShedElectricaltapePocket},
	},
	[objectShedRag] = 
	{
		siblings = {objectShedRagDark, objectShedRagPocket, objectShedRagShadow},
	},
	[objectShedSmallwheel1] = 
	{
		siblings = {objectShedSmallwheel1Dark, objectShedSmallwheel1DarkPocket},
	},
	[objectShedSmallwheel2] = 
	{
		siblings = {objectShedSmallwheel2Dark, objectShedSmallwheel2Pocket},
	},
	[objectShedWirehanger] = 
	{
		siblings = {objectShedWirehangerDark},
	},
}
layoutShed.mIOs =
{
}
layoutShed.mMoonlightDustEffects = 
{
	["left"]  = {},
	["right"] = {},
}
layoutShed.mMoonlightDustSettings = {
	["left"] = 
	{
		startX = 140,
		startY = 430,
		endX = 490,
		endY = 430,
		durationMin = 900,
		durationMax = 1300,
	}
	,
	["right"] =
	{
		startX = 1300,
		startY = 100,
		endX = 1500,
		endY = 100,
		durationMin = 1000,
		durationMax = 1600,
	}	
}
-- ----------------------------------------------------------------------------
function layoutShed:onConstruct()
	
	Layout.onConstruct(self)
	
	objectShedCattrigger:ss(kDone)
	
	objectShedCat:ss(kInactive)
	objectShedCatface:ss(kInactive)
	objectShedCatface2:ss(kInactive)
	objectShedCatfaceMove1:ss(kInactive)
	objectShedCatfaceMove2:ss(kInactive)
	
	objectShedToolboxOpen:ss(kInactive)
	objectShedPorchdoor:ss(kActive)
	
	objectShedLawnmowerNowheelDark:ss(kInactive)
	objectShedLawnmowerNowheel1Dark:ss(kInactive)
	-- objectShedLawnmowerWheelDark:ss(kInactive) -- Image is obsolete
	objectShedLawnmowerWheelDark:ss(kDone)
	objectShedLawnmowerWheelDarkMoved:ss(kInactive)
	
	self.mMoonlightDustEffects["left"]  = self:newChildParticle( { name = "PARTICLE_SHED_MOONLIGHT_DUST_LEFT", x=0, y=0, library="PARTICLE_MOONLIGHT_DUST_LIVINGROOM", section="particles", play=true, removeWhenFinished=false } )
    self.mMoonlightDustEffects["right"] = self:newChildParticle( { name = "PARTICLE_SHED_MOONLIGHT_DUST_RIGHT", x=0, y=0, library="PARTICLE_MOONLIGHT_DUST_SHED", section="particles", play=true, removeWhenFinished=false } )
    
    self:animMoonlightDust("left")
	self:animMoonlightDust("right")
    	
	p = self:newChildParticle( { name = "PARTICLE_SHED_OPENROOF_MIST", x=1300, y=0, library="PARTICLE_SHED_OPENROOF_MIST", section="particles", play=true, removeWhenFinished=false } )
	p:addInitialTime(10000)
	
end
-- ----------------------------------------------------------------------------
function layoutShed:onShow()

	Layout.onShow(self)
	
end

-- ----------------------------------------------------------------------------
function layoutShed:onStartAudio()
	
	playAmbientAudio(kInsideHutAmbientGroup)
	
	if (layoutBedroom ~= nil) then
		layoutBedroom:checkRadioStatic("mute")
	end
	
end

-- ----------------------------------------------------------------------------
-- HELP REMOVE Scrolling
function layoutShed:onScrollStart()

	removeHelpDialog()
	
	Layout.onScrollStart(self)

end
-- ----------------------------------------------------------------------------
function layoutShed:onScrollFinish()

	if (self.shownCatScare == false and goalFindFuses:isActive()) then
		self:showCatScare()
	end
	
	if (self.shownFakeScare == false and goalGatherRadioParts:isActive()) then
		playAudioTrack("SMALL_SCAREMOMENT")
		self.shownFakeScare = true
	end
	
	Layout.onScrollFinish(self)

end
-- ----------------------------------------------------------------------------
function layoutShed:showCatScare()

	self.shownCatScare = true

	objectShedCatfaceMove2:setAlpha(0)
	objectShedCatfaceMove2:ss(kIdle)

	objectShedCatfaceMove2:animate("catEnter2_blocking",
		{ command="playTrack track=CAT_HISS",		target=self	},
		{ alpha=1					},
		{ delay=50					}
	)

end
-- ----------------------------------------------------------------------------
function layoutShed:animMoonlightDust(part)
	
	local effect   = self.mMoonlightDustEffects[part]
	local settings = self.mMoonlightDustSettings[part]
	
	local sx = settings.startX
	local sy = settings.startY
	local ex = settings.endX
	local ey = settings.endY
	local duration = math.random(settings.durationMin, settings.durationMax)
	
	animParticleEmitterLocationLine(effect, { sx=sx, sy=sy, ex=ex, ey=ey, duration=duration } )
	
	local animID = "animShedMoonlightDust_" .. part
    
    -- ugly hack code below
    self:animate(animID,
    	{ delay=duration		}
    )
end
-- ----------------------------------------------------------------------------
function layoutShed:showToolboxHighlight()
	--objectShedToolboxLocked
	if (objectShedToolboxShine:isIdle()) then
		objectShedToolboxShine:animate("shedToolboxShine",
			{ delay = math.random(2000, 3000) },
			{ startframe=0, frametime=75 }
		)
	end
end
-- ----------------------------------------------------------------------------
function layoutShed:showCabinetHighlight()
	--objectShedCabinet
	if (objectShedCabinetInsect:isIdle()) then
		objectShedCabinetInsect:animate("shedCabinetInsect",
			{ delay = math.random(2000, 3000) },
			{ startframe=0, frametime=75 }
		)
	end
end
-- ----------------------------------------------------------------------------
function layoutShed:showLawnmowerHighlight()
	--objectShedLawnmowerHitarea
	if (objectShedLawnmowerShine:isIdle()) then
		objectShedLawnmowerShine:animate("shedLawnmowerShine",
			{ delay = math.random(2000, 3000) },
			{ startframe=0, frametime=75 }
		)
	end
end
-- ----------------------------------------------------------------------------
function layoutShed:showDrawerHighlight()
	--objectShedShuttermanualOpen
	if (objectShedDrawerInsect:isIdle()) then
		objectShedDrawerInsect:animate("shedDrawerInsect",
			{ delay = math.random(2000, 3000) },
			{ startframe=0, frametime=75 }
		)
	end
end		
-- ----------------------------------------------------------------------------
function layoutShed:onAnimationFinish(animationName)

	Layout.onAnimationFinish(self, animationName)

	if (animationName == "catEnter1_blocking") then
		objectShedCatfaceMove1:ss(kInactive)
		
		objectShedCatfaceMove2:ss(kIdle)
	
		objectShedCatfaceMove2:animate("catEnter2_blocking",
			{ delay=100				}
		)
	
	elseif (animationName == "catEnter2_blocking") then
		local blinkDelay = 105
		
		objectShedCatfaceMove2:ss(kInactive)
		
		objectShedCatface:ss(kIdle)
		
		objectShedCatface2:setAlpha(0)
		objectShedCatface2:ss(kIdle)
	
		objectShedCatface2:animate("catFace2_blocking",
			{ alpha=0				},
			{ delay=blinkDelay		},
			{ alpha=1				},
			{ delay=blinkDelay		},
			{ alpha=0				},
			{ delay=blinkDelay		},
			{ alpha=1				},
			{ delay=blinkDelay		},
			{ alpha=0				},
			{ delay=blinkDelay		},
			{ alpha=1				},
			{ delay=blinkDelay		},
			{ alpha=0				},
			{ delay=blinkDelay		},
			{ alpha=1				},
			{ delay=blinkDelay		},
			{ alpha=0				} 
		)
	
	elseif (animationName == "catFace2_blocking") then
		objectShedCatface:ss(kDone)
		objectShedCatface2:ss(kDone)
		
		objectShedCatfaceMove2:ss(kIdle)
	
		objectShedCatfaceMove2:animate("catLeave2_blocking",
			{ delay=100				}
		)
		
	elseif (animationName == "catLeave2_blocking") then
		objectShedCatfaceMove2:ss(kDone)
		
		objectShedCatfaceMove1:ss(kIdle)
	
		objectShedCatfaceMove1:animate("catLeave1_blocking",
			{ delay=100				}
		)
		
	elseif (animationName == "catLeave1_blocking") then
		objectShedCatfaceMove1:ss(kDone)
		
		objectShedCat:ss(kIdle)
	
		objectShedCat:animate("catRunAway_blocking",
			{ startframe=0, 		frametime=65			},
			{ alpha=0										}
		)
		
	elseif (animationName == "catRunAway_blocking") then
		objectShedCat:ss(kDone)
	
	elseif (string.find(animationName, "animShedMoonlightDust_") ~= nil) then
		-- restart reverse moonlight dust animation
		local part = string.sub(animationName, string.len("animShedMoonlightDust_") + 1)
		
		self:animMoonlightDust(part)
		
	
	elseif (animationName == "shedToolboxShine") then
	
		self:showToolboxHighlight()				
	
	elseif (animationName == "shedCabinetInsect") then
	
		self:showCabinetHighlight()				
	
	elseif (animationName == "shedLawnmowerShine") then
	
		self:showLawnmowerHighlight()
						
	elseif (animationName == "shedDrawerInsect") then
	
		self:showDrawerHighlight()
		
	end	

end