<scene name="Room26" numVictoryConditions="1">
	<inventory>
		<object name="Valve" memberName="HUD_valve" acquired="0" visible="1"/>
	</inventory>
	
	<finalStates>
		<finalState objName="Ambients" state="play_background_noises"/>
		<finalState objName="Valve" state="acquired"/>
		<finalState objName="VentilationControl" state="disabled"/>
		<finalState objName="Light1" state="on"/>
		<finalState objName="Light2" state="on"/>
		<finalState objName="Light3" state="on"/>
		<finalState objName="Fan" state="off"/>
		<finalState objName="Gas" state="no_gas"/>
		<finalState objName="GasDetector" state="disabled"/>
		<finalState objName="InPlaceValve" state="with_valve"/>
		<finalState objName="Door" state="unlocked"/>
	</finalStates>
	
	<animations>
		<animation name="FanAnim" type="loop">
			<frames>
				<frame memberName="fan1_anim" frameDelay="6"/>
				<frame memberName="fan2_anim" frameDelay="8"/>
			</frames>
		</animation>
	</animations>	
	
	<zoomWindows>
		<zoomWindow name="VentilationControlWindow" file="ZoomWindows\Room26_VentilationControlWindow.dir" x="150" y="290" visible="0"/>
	</zoomWindows>
	
	<objects>
		<object name="Ambients">
			<states>
				<state name="play_background_noises">
					<onStateEnter>
						<action target="Scene" name="PlaySound" param="indoor_small"/>
					</onStateEnter>
				</state>
			</states>
		</object>
		
		<object name="Valve">
			<clickStrategy type="alpha" layer="Valve"/>
			<states>
				<state name="too_dark">					
					<onStateEnter>
						<action target="Scene" name="HideLayer" param="Valve"/>
					</onStateEnter>
					
					<onEvent name="light_on">
						<action target="Valve" name="SetState" param="clickable"/>
					</onEvent>
				</state>
				
				<state name="clickable">
					<onStateEnter><action target="Scene" name="HideLayer" param="Valve"/></onStateEnter>
					
					<onMouseOver>
						<action target="Scene" name="SetCursor" param="interactive"/>
					</onMouseOver>
					
					<onClick>
						<action target="Scene" name="AddToInventory" param="Valve"/>
						<action target="Valve" name="SetState" param="acquired"/>
						<action target="Scene" name="PlaySound" param="Item_Pickup_Metal_small"/>
					</onClick>
					
					<onEvent name="light_off">
						<action target="Valve" name="SetState" param="too_dark"/>
					</onEvent>
				</state>
				
				<state name="acquired">
					<onStateEnter><action target="Scene" name="ShowLayer" param="Valve"/></onStateEnter>
					
					<onEvent name="light_off">
						<action target="Scene" name="HideLayer" param="Valve"/>
					</onEvent>
					
					<onEvent name="light_on">
						<action target="Scene" name="HideLayer" param="Valve"/>
					</onEvent>
				</state>
			</states>
		</object>
		
		<object name="VentilationControl">
			<clickStrategy type="alpha" layer="VentilationControl"/>
			<states>
				<state name="closed">
					<onStateEnter><action target="Scene" name="HideLayer" param="VentilationControl"/></onStateEnter>
					
					<onMouseOver>
						<action target="Scene" name="SetCursor" param="zoom"/>
					</onMouseOver>
					
					<onClick>
						<action target="Scene" name="OpenWindow" param="VentilationControlWindow"/>
						<action target="VentilationControl" name="SetState" param="open"/>
						<action target="Scene" name="ShowDialog" param="panel_click"/>
					</onClick>
				</state>
				
				<state name="open">
					<onStateEnter><action target="Scene" name="ShowLayer" param="VentilationControl"/></onStateEnter>
					
					<onMouseOver>
						<action target="Scene" name="SetCursor" param="zoom"/>
					</onMouseOver>
					
					<onClick>
						<action target="Scene" name="OpenWindow" param="VentilationControlWindow"/>
					</onClick>
					
					<onEvent name="switch1_on">
						<action target="Light1" name="SendEvent" param="turn_on"/>
						<action target="Scene" name="PlaySound" param="light_switch1"/>
					</onEvent>
					
					<onEvent name="switch1_off">
						<action target="Light1" name="SendEvent" param="turn_off"/>
						<action target="Scene" name="PlaySound" param="light_switch1"/>
					</onEvent>
					
					<onEvent name="switch2_on">
						<action target="Light2" name="SendEvent" param="turn_on"/>
						<action target="Scene" name="PlaySound" param="light_switch2"/>
					</onEvent>
					
					<onEvent name="switch2_off">
						<action target="Light2" name="SendEvent" param="turn_off"/>
						<action target="Scene" name="PlaySound" param="light_switch2"/>
					</onEvent>
					
					<onEvent name="switch3_on">
						<action target="Light3" name="SendEvent" param="turn_on"/>
						<action target="Fan" name="SendEvent" param="turn_off"/>
						<action target="Scene" name="PlaySound" param="ventilation_switch"/>
						<action target="Scene" name="ShowDialog" param="switch3_click"/>
					</onEvent>
					
					<onEvent name="switch3_off">
						<action target="Light3" name="SendEvent" param="turn_off"/>
						<action target="Fan" name="SendEvent" param="turn_on"/>
						<action target="Scene" name="PlaySound" param="ventilation_switch"/>
					</onEvent>		
				</state>
				
				<state name="disabled">
					<onStateEnter>
						<action target="Scene" name="ShowLayer" param="VentilationControl"/>
						<action target="Scene" name="CloseWindow" param="VentilationControlWindow"/>
					</onStateEnter>
				</state>
			</states>
		</object>
		
		<object name="Light1">
			<states>
				<state name="off">
					<onStateEnter>
						<action target="Scene" name="HideLayer" param="Light1"/>
					</onStateEnter>
					
					<onEvent name="turn_on">
						<action target="Light1" name="SetState" param="on"/>
					</onEvent>
				</state>
				
				<state name="on">
					<onStateEnter>
						<action target="Scene" name="ShowLayer" param="Light1"/>
					</onStateEnter>
					
					<onEvent name="turn_off">
						<action target="Light1" name="SetState" param="off"/>
					</onEvent>
				</state>
			</states>
		</object>
		
		<object name="Light2">
			<states>
				<state name="off">
					<onStateEnter>
						<action target="Scene" name="HideLayer" param="Light2"/>
					</onStateEnter>
					
					<onEvent name="turn_on">
						<action target="Light2" name="SetState" param="on"/>
					</onEvent>
				</state>
				
				<state name="on">
					<onStateEnter>
						<action target="Scene" name="ShowLayer" param="Light2"/>
					</onStateEnter>
					
					<onEvent name="turn_off">
						<action target="Light2" name="SetState" param="off"/>
					</onEvent>
				</state>
			</states>
		</object>
		
		<object name="Light3">
			<states>
				<state name="off">
					<onStateEnter>
						<action target="Scene" name="HideLayer" param="Light3"/>
					</onStateEnter>
					
					<onEvent name="turn_on">
						<action target="Light3" name="SetState" param="on"/>
						<action target="Valve" name="SendEvent" param="light_on"/>
					</onEvent>
				</state>
				
				<state name="on">
					<onStateEnter>
						<action target="Scene" name="ShowLayer" param="Light3"/>
					</onStateEnter>
					
					<onEvent name="turn_off">
						<action target="Light3" name="SetState" param="off"/>
						<action target="Valve" name="SendEvent" param="light_off"/>
					</onEvent>
				</state>
			</states>
		</object>
		
		<object name="Fan">
			<states>				
				<state name="on">
					<onStateEnter>
						<action target="Scene" name="StartAnimation" param="FanAnim"/>
						<action target="Scene" name="PlaySound" param="ventilator_loop_sound"/>
					</onStateEnter>
					
					<onEvent name="turn_off">
						<action target="Fan" name="SetState" param="off"/>
						<action target="Gas" name="SendEvent" param="fan_off"/>
					</onEvent>
				</state>
				
				<state name="off">
					<onStateEnter>
						<action target="Scene" name="StopAnimation" param="FanAnim"/>
						<action target="Scene" name="StopSound" param="ventilator_loop_sound"/>
						<action target="Scene" name="PlaySound" param="ventilator_stop_sound"/>
					</onStateEnter>
					
					<onEvent name="turn_on">
						<action target="Fan" name="SetState" param="on"/>
						<action target="Gas" name="SendEvent" param="fan_on"/>
					</onEvent>
				</state>
			</states>
		</object>
		
		<object name="Gas">
			<states>
				<state name="no_gas">
					<!--
					<onStateEnter>
						<action target="Scene" name="HideLayer" param="Gas"/>
					</onStateEnter>
					-->
					<onEvent name="fan_off">
						<action target="Gas" name="SetState" param="gassed_up" delay="180"/>
					</onEvent>
				</state>
				
				<state name="gassed_up">
					<onStateEnter>
						<!--<action target="Scene" name="ShowLayer" param="Gas"/>-->
						<action target="GasDetector" name="SendEvent" param="gassed_up"/>
						<action target="Scene" name="PlaySound" param="steam_loop_sound"/>
					</onStateEnter>
					
					<onEvent name="fan_on">
						<action target="Gas" name="SetState" param="no_gas"/>
						<action target="Scene" name="StopSound" param="steam_loop_sound"/>
						<action target="Scene" name="PlaySound" param="steam_stop_sound"/>
					</onEvent>
				</state>
			</states>
		</object>
		
		<object name="GasDetector">
			<states>
				<state name="off">
					<onStateEnter>
						<action target="Scene" name="ShowLayer" param="GasDetectorOff"/>
					</onStateEnter>
					
					<onEvent name="gassed_up">
						<action target="Scene" name="HideLayer" param="GasDetectorOff"/>
						<action target="GasDetector" name="SendEvent" param="turn_on" delay="120"/>
					</onEvent>
					
					<onEvent name="turn_on">
						<action target="GasDetector" name="SetState" param="on"/>
					</onEvent>
					
					<onEvent name="disable">
						<action target="GasDetector" name="SetState" param="disabled"/>
					</onEvent>
				</state>
				
				<state name="on">
					<onStateEnter>
						<action target="Scene" name="HideLayer" param="GasDetectorOff"/>
						<action target="Fan" name="SendEvent" param="turn_on"/>
						<action target="Light1" name="SendEvent" param="turn_off"/>
						<action target="Light2" name="SendEvent" param="turn_off"/>
						<action target="Light3" name="SendEvent" param="turn_off"/>
						<action target="GasDetector" name="SetState" param="off" delay="60"/>
						<action target="Scene" name="ShowDialog" param="detector_maxed"/>
					</onStateEnter>
					
					<onEvent name="disable">
						<action target="GasDetector" name="SetState" param="disabled"/>
					</onEvent>
				</state>
				
				<state name="disabled">
					<onStateEnter>
						<action target="Scene" name="ShowLayer" param="GasDetectorOff"/>
					</onStateEnter>
				</state>
			</states>			
		</object>
		
		<object name="InPlaceValve">
			<clickStrategy type="alpha" layer="ValveInPlace"/>
			<states>
				<state name="no_valve">
					<onStateEnter>
						<action target="Scene" name="HideLayer" param="ValveInPlace"/>
						<action target="Scene" name="StartGas" param=""/>
					</onStateEnter>
					
					<onMouseOver>
						<action target="Scene" name="SetCursor" param="interactive"/>
					</onMouseOver>
					
					<onClick>
						<action target="Scene" name="ShowDialog" param="gas_click"/>
					</onClick>
					
					<onUseObject name="Valve">
						<action target="Scene" name="RemoveFromInventory" param="Valve"/>
						<action target="Light1" name="SendEvent" param="turn_on"/>
						<action target="Light2" name="SendEvent" param="turn_on"/>
						<action target="Light3" name="SendEvent" param="turn_on"/>
						<action target="Door" name="SendEvent" param="unlock"/>
						<action target="GasDetector" name="SendEvent" param="disable"/>
						<action target="Fan" name="SetState" param="off"/>
						<action target="VentilationControl" name="SetState" param="disabled"/>						
						<action target="InPlaceValve" name="SetState" param="with_valve"/>
						<action target="Scene" name="PlaySound" param="attach_valve_to_pipe"/>						
					</onUseObject>
				</state>
				
				<state name="with_valve">
					<onStateEnter>
						<action target="Scene" name="ShowLayer" param="ValveInPlace"/>
						<action target="Scene" name="StopGas" param=""/>
					</onStateEnter>
				</state>
			</states>
		</object>
		
		<object name="Door">
			<clickStrategy type="alpha" layer="OpenDoor"/>
			<states>
				<state name="locked">						
					<onStateEnter>
						<action target="Scene" name="HideLayer" param="OpenDoor"/>
						<action target="Scene" name="HideLayer" param="OpenDoorLED"/>
					</onStateEnter>
					
					<onMouseOver>
						<action target="Scene" name="SetCursor" param="noExit"/>
					</onMouseOver>
					
					<onClick>
						<action target="Scene" name="ShowDialog" param="door_click"/>
					</onClick>
					
					<onEvent name="unlock">
						<action target="Door" name="SetState" param="unlocked"/>
					</onEvent>
				</state>
				
				<state name="unlocked">
					<onStateEnter>
						<action target="Scene" name="ShowLayer" param="OpenDoor"/>
						<action target="Scene" name="ShowLayer" param="OpenDoorLED"/>
					</onStateEnter>
					
					<onMouseOver>
						<action target="Scene" name="SetCursor" param="exit"/>
					</onMouseOver>
					
					<onClick>
						<action target="Scene" name="RegisterVictoryCondition" param=""/>
					</onClick>
				</state>
			</states>
		</object>
	
	</objects>
</scene>

