class CPOVotingDevice extends CPOMissionDevice
{
	default m_blockAfterOperation = false;
	default m_factToUnblock = 'defaults to compatibleDeviceName_enabled';
	protected instanceeditable var m_deviceName : CName;

	private const function GetVoteFactName() : CName
	{
		var factName : String;
		factName = ( ( NameToString( m_compatibleDeviceName ) + "_" ) + NameToString( m_deviceName ) ) + "_voted";
		return StringToName( factName );
	}

	private const function GetVoteTimerFactName() : CName
	{
		var factName : String;
		factName = NameToString( m_compatibleDeviceName ) + "_started";
		return StringToName( factName );
	}

	protected event OnGameAttached()
	{
		var factName : String;
		factName = NameToString( m_compatibleDeviceName ) + "_enabled";
		m_factToUnblock = StringToName( factName );
		super.OnGameAttached();
		SetFact( GetVoteFactName(), 0, EMathOperationType.Set );
	}

	protected event OnInteraction( choiceEvent : InteractionChoiceEvent )
	{
		var playerVoted : CPOMissionPlayerVotedEvent;
		if( choiceEvent.choice.choiceMetaData.tweakDBName == "CPOVote" )
		{
			if( m_blockAfterOperation )
			{
				m_isBlocked = true;
			}
			SetFact( GetVoteFactName(), 1, EMathOperationType.Add );
			SetFact( GetVoteTimerFactName(), 1, EMathOperationType.Add );
			playerVoted = new CPOMissionPlayerVotedEvent;
			playerVoted.compatibleDeviceName = m_compatibleDeviceName;
			choiceEvent.activator.QueueEvent( playerVoted );
		}
	}

}

