enum EGravityType
{
	LowGravity = 0,
	Regular = 1,
}

class GravityChangeTrigger extends GameObject
{
	instanceeditable var m_gravityType : EGravityType;
	instanceeditable var m_regularStateMachineName : CName;
	default m_regularStateMachineName = 'Locomotion';
	instanceeditable var m_lowGravityStateMachineName : CName;
	default m_lowGravityStateMachineName = 'LocomotionLowGravity';

	protected event OnRequestComponents( ri : EntityRequestComponentsInterface )
	{
		EntityRequestComponentsInterface.RequestComponent( ri, 'trigger', 'gameStaticTriggerComponent', false );
	}

	protected event OnAreaEnter( trigger : AreaEnteredEvent )
	{
		SwitchGravity( m_gravityType );
	}

	protected event OnAreaExit( trigger : AreaExitedEvent )
	{
		if( m_gravityType == EGravityType.LowGravity )
		{
			SwitchGravity( EGravityType.Regular );
		}
		else
		{
			SwitchGravity( EGravityType.LowGravity );
		}
	}

	private function SwitchGravity( gravityType : EGravityType )
	{
		var player : PlayerPuppet;
		var swapEvent : PSMAddOnDemandStateMachine;
		swapEvent = new PSMAddOnDemandStateMachine;
		player = GetPlayer( GetGame() );
		if( gravityType == EGravityType.LowGravity )
		{
			swapEvent.stateMachineName = 'LocomotionLowGravity';
		}
		else
		{
			swapEvent.stateMachineName = 'Locomotion';
		}
		player.QueueEvent( swapEvent );
	}

}

