<?xml version="1.0" ?>

<Scene name="UpstairsHall" type="FlashlightScene">

	<Audio source="Chapter4"/>

	<!-- Hidden objects -->
	<if t="$first_time_in_upstairs_room == 2">
		<Object type="HiddenObject" name="up_fuse_01_visible" item="up_fuse" image="ho_up_fuse_01" x="608" y="544"/>
		<Object type="HiddenObject" name="up_fuse_02_visible" item="up_fuse" image="ho_up_fuse_02" x="698" y="484"/>
		<Object type="HiddenObject" name="up_fuse_03_visible" item="up_fuse" image="ho_up_fuse_03" x="738" y="447"/>
		<Object type="HiddenObject" name="up_fuse_04_visible" item="up_fuse" image="ho_up_fuse_04" x="837" y="594"/>
		<Object type="HiddenObject" name="up_fuse_05_visible" item="up_fuse" image="ho_up_fuse_05" x="907" y="620"/>
		<Object type="HiddenObject" name="up_fuse_06_visible" item="up_fuse" image="ho_up_fuse_06" x="634" y="446"/>
		<Object type="HiddenObject" name="up_fuse_07_visible" item="up_fuse" image="ho_up_fuse_07" x="456" y="500"/>
		<Object type="HiddenObject" name="up_fuse_08_visible" item="up_fuse" image="ho_up_fuse_08" x="9" y="554"/>
		<Object type="HiddenObject" name="up_fuse_09_visible" item="up_fuse" image="ho_up_fuse_09" x="378" y="407"/>
	<else>
		<if t="$first_time_in_upstairs_room {= 1">
			<Object type="ImageBox" image="ho_up_fuse_01" x="608" y="544"/>
			<Object type="ImageBox" image="ho_up_fuse_02" x="698" y="484"/>
			<Object type="ImageBox" image="ho_up_fuse_03" x="738" y="447"/>
			<Object type="ImageBox" image="ho_up_fuse_04" x="837" y="594"/>
			<Object type="ImageBox" image="ho_up_fuse_05" x="907" y="620"/>
			<Object type="ImageBox" image="ho_up_fuse_06" x="634" y="446"/>
			<Object type="ImageBox" image="ho_up_fuse_07" x="456" y="500"/>
			<Object type="ImageBox" image="ho_up_fuse_08" x="9" y="554"/>
			<Object type="ImageBox" image="ho_up_fuse_09" x="378" y="407"/>
		</if>
	</else>
	</if>

	<!-- Scene layers & anims -->
    <if t="$upstairs_fusebox_opened"> <Object type="ImageBox" image="scene_fusebox_open" x="318" y="169"/> </if>
    <if t="$upstairs_picture_moved == 1">
		<Object type="ImageBox" image="scene_painting_moved" x="304" y="313"/>
	<else>
		<if t="$upstairs_picture_moved == -1">
			<Object type="ImageBox" image="scene_painting_moved" alpha="0" x="304" y="313">
				<Animator type="AlphaChanger" amplitude="255" speed="3"/>
			</Object>
			<Action type="PlaySound" sound="item_inplace"/>
			<Action type="SetVar" var="upstairs_picture_moved" value="1" reset="0"/>
		</if>
	</else>
	</if>

	<!-- Actions -->
	<Action color="FFFF00" type="Composite" cursor="walk">
		<Action type="PlaySound" sound="step"/>
		<Action type="SwitchScene" scene="cemetery.BuildingInside"/>
	</Action>

	<if t="not $upstairs_electricity_on">
		<if t="not $upstairs_picture_moved and not $ho_up_fuse_09_visible">
			<Action color="00FFFF" type="SetVar" var="upstairs_picture_moved" value="-1" reset="1" cursor="use"/>
			<Action color="0000FF" type="SetVar" var="upstairs_picture_moved" value="-1" reset="1" cursor="use"/>
		<else>
			<if t="$upstairs_picture_moved">
				<Action color="0000FF" type="Composite" cursor="use">
					<Action condition="not $upstairs_fusebox_repaired" type="Say" key="UPSTAIRS_LIGHT_SWITCH_FAIL"/>
					<Action condition="$upstairs_fusebox_repaired" type="Composite">
						<Action type="PlaySound" sound="ui.click"/>
						<Action type="SetVar" var="upstairs_electricity_on" value="1" reset="0"/>
						<Action type="RemoveItem" item="lit_cocktail" reset="0"/>
						<Action type="SwitchScene" scene="cemetery.UpstairsHallLight" fade_time="0.25"/>
					</Action>
				</Action>
			</if>
		</else>
		</if>
	</if>


	<if t="$first_time_in_upstairs_room == 2 and $cocktail_made"> <!-- after "mini intro" -->

		<Action condition="not $upstairs_fusebox_repaired" color="FF0000" type="ItemAction" cursor="look">
			<Action condition="not $upstairs_fusebox_opened" itemaction="noitem" type="Say" key="CANT_OPEN_UPSTAIRS_FUSEBOX"/>
			<Action condition="$upstairs_fusebox_opened" itemaction="noitem" type="Say" key="FUSEBOX_EMPTY"/>
			<Action condition="not $upstairs_fusebox_opened" itemaction="screwdriver" type="Composite">
				<Action type="PlaySound" sound="sfx_open-cabinet"/>
				<Action type="RemoveItem" item="screwdriver" reset="0"/>
				<Action type="SetVar" var="upstairs_fusebox_opened" value="1" reset="1"/>
			</Action>
			<Action condition="$upstairs_fusebox_opened and (not $ho_up_fuse_01_visible and not $ho_up_fuse_02_visible and not $ho_up_fuse_03_visible and not $ho_up_fuse_04_visible and not $ho_up_fuse_05_visible and not $ho_up_fuse_06_visible and not $ho_up_fuse_07_visible and not $ho_up_fuse_08_visible and not $ho_up_fuse_09_visible)" itemaction="up_fuse" type="Composite">
				<Action type="SwitchScene" scene="UpstairsHallFusebox"/>
			</Action>
			<Action condition="$upstairs_fusebox_opened and not (not $ho_up_fuse_01_visible and not $ho_up_fuse_02_visible and not $ho_up_fuse_03_visible and not $ho_up_fuse_04_visible and not $ho_up_fuse_05_visible and not $ho_up_fuse_06_visible and not $ho_up_fuse_07_visible and not $ho_up_fuse_08_visible and not $ho_up_fuse_09_visible)" itemaction="up_fuse" type="Composite">
				<Action type="Say" key="PUT_SOME_FUSES_UPSTAIRS"/>
			</Action>
		</Action>

		<Action color="FF00FF" type="Composite" cursor="look">
			<Action condition="not $upstairs_fusebox_repaired" type="Say" key="KEYPAD_POWERED_OFF"/>
			<Action condition="$upstairs_fusebox_repaired" type="SwitchScene" scene="cemetery.Keypad"/>
		</Action>

		<if t="not $upstairs_electricity_on" cursor="look">
			<Action color="00FF00" type="Composite">
				<Action type="PlaySound" sound="drawer_locked"/>
				<Action type="Say" key="OFFICE_DOOR_LOCKED"/>
			</Action>
		<else>
			<Action color="00FF00" type="SwitchScene" scene="cemetery.UnderTheDoor" fade_time="2" cursor="walk"/>
		</else>
		</if>
	</if>


	<!-- Foreground & other -->

	<if t="$first_time_in_upstairs_room == 0">
		<Action type="LockScene"/>
		<Object type="ImageBox" image="0x000000" x="0" y="0" w="1024" h="768" alpha="0">
			<Animator type="AlphaChanger" offset="0" amplitude="255" speed="0.25" delay="1"/>
		</Object>

		<Animator type="DelayedAction" time="5">
			<Action type="SetVar" var="first_time_in_upstairs_room" value="1" reset="1"/>
		</Animator>

	<else>
		<if t="$first_time_in_upstairs_room == 1 and not $cocktail_made">
			<Object type="ImageBox" image="scene_fx_flashlight_mask" alpha="255" x="0" y="0" w="1024" h="768"/> <!-- black mask -->
			<Object type="ImageBox" image="scene_fx_flashlight_mask" alpha="255" x="-400" y="0" w="1024" h="768"/> <!-- black mask -->
			<Action condition="flashlight_went_dead" type="Say" key="UPSTAIRS_DARK"/>
			<if t="not $flashlight_went_dead">
				<Action type="RemoveItem" item="shed_flashlight" reset="0"/>
				<Action type="Say" key="FLASHLIGHT_WENT_DEAD_UPSTAIRS"/>
				<Action type="SetVar" var="task26_repair_light" value="1" reset="0"/>
				<Action type="UnlockScene"/>
				<Action type="SetVar" var="flashlight_went_dead" value="1" reset="0"/>
			</if>
			<!-- BEGIN DEBUG -->
			<if t="0"> <!-- always false so it won't execute in the game, we use this just as a 'hack' to make the following items appear in the debug menu -->
				<Action type="AddItem" item="cloth_in_scotch" reset="0"/>
				<Action type="AddItem" item="lighter" reset="0"/>
			</if>
			<!-- END DEBUG -->
		</if>
		<if t="$cocktail_made and not $commented_on_cocktail_light">
			<Action type="Say" key="COCKTAIL_LIT_COMMENT_IN_UPSTAIRS_HALL"/>
			<Action type="SetVar" var="commented_on_cocktail_light" value="1" reset="0"/>
		</if>
	</else>
	</if>

	<Object type="ImageBox" name="UpstairsHall_flashlight" image="null" x="0" y="0" w="2400" h="2400" click_through="1">
		<Object type="ImageBox" image="0x000000" x="0" y="0" w="1700" h="700"/>
		<Object type="ImageBox" image="0x000000" x="0" y="700" w="700" h="1700"/>
		<Object type="ImageBox" image="0x000000" x="700" y="1700" w="1700" h="700"/>
		<Object type="ImageBox" image="0x000000" x="1700" y="0" w="700" h="1700"/>
	</Object>
	<if t="not $flashlight_went_dead">
		<Object type="ImageBox" image="scene_flashlight_mask" x="515" y="600" w="1400" h="1200" parent="UpstairsHall_flashlight" click_through="1"/>
	<else>
		<if t="$cocktail_made">
			<Object type="ImageBox" image="hole_light" x="515" y="600" w="1400" h="1200" parent="UpstairsHall_flashlight" scale_x="1.5" scale_y="1.5" click_through="1">
				<Animator type="ScalerX" periods="-1" function="sine" amplitude="0.1" speed="0.5"/>
				<Animator type="ScalerY" periods="-1" function="sine" amplitude="0.1" speed="1"/>
			</Object>
		</if>
	</else>
	</if>

</Scene>