class BaseHitPrereqCondition extends IScriptable
{
	var m_invert : Bool;
	var m_onlyOncePerShot : Bool;
	var m_lastAttackTime : Float;

	public virtual function SetData( recordID : TweakDBID )
	{
		m_invert = TweakDBInterface.GetBool( recordID + T".invert", false );
		m_onlyOncePerShot = TweakDBInterface.GetBool( recordID + T".onlyOncePerShot", false );
	}

	public virtual function Evaluate( hitEvent : gameHitEvent ) : Bool
	{
		return false;
	}

	public virtual function OnMissTriggered( missEvent : gameMissEvent ) {}

	protected function GetObjectToCheck( obj : CName, hitEvent : gameHitEvent ) : weak< GameObject >
	{
		switch( obj )
		{
			case 'Instigator':
				return hitEvent.attackData.GetInstigator();
			case 'Source':
				return hitEvent.attackData.GetSource();
			case 'Target':
				return hitEvent.target;
			case 'Weapon':
				return hitEvent.attackData.GetWeapon();
			default:
				return NULL;
		}
	}

	protected function CheckOnlyOncePerShot( hitEvent : gameHitEvent ) : Bool
	{
		var attackTime : Float;
		if( !( m_onlyOncePerShot ) )
		{
			return true;
		}
		attackTime = hitEvent.attackData.GetAttackTime();
		if( attackTime > m_lastAttackTime )
		{
			m_lastAttackTime = attackTime;
			return true;
		}
		return false;
	}

}

