class AmmoStateHitPrereqCondition extends BaseHitPrereqCondition
{
	var m_valueToListen : EMagazineAmmoState;
	var m_ratio : Float;
	var m_comparisonType : EComparisonType;

	public override function SetData( recordID : TweakDBID )
	{
		var str : String;
		str = TweakDBInterface.GetString( recordID + T".ammoState", "" );
		m_valueToListen = ( ( EMagazineAmmoState )( ( ( Int32 )( EnumValueFromString( "EMagazineAmmoState", str ) ) ) ) );
		m_ratio = TweakDBInterface.GetFloat( recordID + T".ratioToCompare", 0.0 );
		m_ratio = ClampF( m_ratio, 0.0, 1.0 );
		str = TweakDBInterface.GetString( recordID + T".comparisonType", "" );
		m_comparisonType = ( ( EComparisonType )( ( ( Int32 )( EnumValueFromString( "EComparisonType", str ) ) ) ) );
		super.SetData( recordID );
	}

	public override function Evaluate( hitEvent : gameHitEvent ) : Bool
	{
		var result : Bool;
		var maxAmmo : Uint32;
		var currentAmmo : Uint32;
		var weapon : weak< WeaponObject >;
		weapon = hitEvent.attackData.GetWeapon();
		if( weapon )
		{
			currentAmmo = WeaponObject.GetMagazineAmmoCount( weapon );
		}
		switch( m_valueToListen )
		{
			case EMagazineAmmoState.FirstBullet:
				maxAmmo = WeaponObject.GetMagazineCapacity( weapon );
			result = currentAmmo >= ( maxAmmo - 1 );
			break;
			case EMagazineAmmoState.LastBullet:
				result = currentAmmo <= ( ( Uint32 )( 0 ) );
			break;
			case EMagazineAmmoState.None:
				maxAmmo = WeaponObject.GetMagazineCapacity( weapon );
			result = ProcessCompare( m_comparisonType, ( ( Float )( currentAmmo ) ) / ( ( Float )( maxAmmo ) ), m_ratio );
			break;
			default:
				return false;
		}
		if( result )
		{
			result = CheckOnlyOncePerShot( hitEvent );
		}
		return ( ( m_invert ) ? ( !( result ) ) : ( result ) );
	}

}

