class ScavengeComponent extends ScriptableComponent
{
	var m_scavengeTargets : array< weak< GameObject > >;

	public export function OnGameAttach() {}

	protected event OnSenseVisibilityEvent( evt : SenseVisibilityEvent )
	{
		var disassembleTargetRequest : DisassembleTargetRequest;
		if( evt.description == 'Disassemblable' && !( m_scavengeTargets.Contains( evt.target ) ) )
		{
			disassembleTargetRequest = new DisassembleTargetRequest;
			disassembleTargetRequest.requester = GetOwner();
			evt.target.QueueEvent( disassembleTargetRequest );
		}
	}

	protected event OnScavengeTargetReceived( evt : ScavengeTargetConfirmEvent )
	{
		m_scavengeTargets.PushBack( evt.target );
	}

	protected event OnTargetScavenged( evt : TargetScavengedEvent )
	{
		if( m_scavengeTargets.Contains( evt.target ) )
		{
			m_scavengeTargets.Remove( evt.target );
		}
	}

	public const function GetScavengeTargets() : array< weak< GameObject > >
	{
		return m_scavengeTargets;
	}

}

class ScavengeTargetConfirmEvent extends Event
{
	var target : weak< GameObject >;
}

class TargetScavengedEvent extends Event
{
	var target : weak< GameObject >;
}

