class sampleVisWireMaster extends GameObject
{
	private const instanceeditable var m_dependableEntities : array< NodeRef >;
	private var m_inFocus : Bool;
	private var m_found : Bool;
	private var m_lookedAt : Bool;

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

	protected event OnTakeControl( ri : EntityResolveComponentsInterface )
	{
		m_visionComponent = ( ( VisionModeComponent )( EntityResolveComponentsInterface.GetComponent( ri, 'vision' ) ) );
	}

	protected event OnGameAttached()
	{
		m_visionComponent.SetHiddenInVisionMode( true, gameVisionModeType.Default );
		m_inFocus = false;
		m_found = false;
		m_lookedAt = false;
	}

	protected event OnInteractionChoice( choice : InteractionChoiceEvent )
	{
		var i : Int32;
		for( i = 0; i < m_dependableEntities.Size(); i += 1 )
		{
			GameInstance.GetVisionModeSystem( GetGame() ).SetChildEntityVisionMode( GetEntityID(), m_dependableEntities[ i ], true );
		}
	}

	protected event OnHUDInstruction( evt : HUDInstruction )
	{
		super.OnHUDInstruction( evt );
		if( evt.highlightInstructions.GetState() == InstanceState.ON )
		{
			m_inFocus = true;
			if( ( !( m_found ) && m_lookedAt ) && IsModeOn() )
			{
				OnFound();
			}
		}
		else if( evt.highlightInstructions.WasProcessed() )
		{
			m_inFocus = false;
		}
	}

	private function IsModeOn() : Bool
	{
		return m_inFocus;
	}

	private function OnFound()
	{
		var i : Int32;
		m_found = true;
		m_visionComponent.SetHiddenInVisionMode( false, gameVisionModeType.Default );
		for( i = 0; i < m_dependableEntities.Size(); i += 1 )
		{
			GameInstance.GetVisionModeSystem( GetGame() ).SetChildEntityVisionMode( GetEntityID(), m_dependableEntities[ i ], true );
		}
	}

}

class sampleVisWireSlave extends GameObject
{

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

	protected event OnTakeControl( ri : EntityResolveComponentsInterface )
	{
		m_visionComponent = ( ( VisionModeComponent )( EntityResolveComponentsInterface.GetComponent( ri, 'vision' ) ) );
	}

	protected event OnGameAttached()
	{
		m_visionComponent.SetHiddenInVisionMode( true, gameVisionModeType.Focus );
	}

	protected event OnInteractionChoice( choice : InteractionChoiceEvent ) {}

	private function IsModeOn() : Bool
	{
		var isFocusOn : Int32;
		isFocusOn = GameInstance.GetQuestsSystem( GetGame() ).GetFact( 'isFocusOn' );
		if( isFocusOn == 1 )
		{
			return true;
		}
		else if( isFocusOn == 0 )
		{
			return false;
		}
		else
		{
			return false;
		}
	}

}

class sampleVisWireMasterTwo extends GameObject
{
	private const instanceeditable var m_dependableEntities : array< NodeRef >;

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

	protected event OnTakeControl( ri : EntityResolveComponentsInterface )
	{
		m_visionComponent = ( ( VisionModeComponent )( EntityResolveComponentsInterface.GetComponent( ri, 'vision' ) ) );
	}

	protected event OnGameAttached()
	{
		m_visionComponent.SetHiddenInVisionMode( true, gameVisionModeType.Default );
	}

	private function IsModeOn() : Bool
	{
		var isFocusOn : Int32;
		isFocusOn = GameInstance.GetQuestsSystem( GetGame() ).GetFact( 'isFocusOn' );
		if( isFocusOn == 1 )
		{
			return true;
		}
		else if( isFocusOn == 0 )
		{
			return false;
		}
		else
		{
			return false;
		}
	}

}

class sampleVisWireSlaveTwo extends GameObject
{

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

	protected event OnTakeControl( ri : EntityResolveComponentsInterface )
	{
		m_visionComponent = ( ( VisionModeComponent )( EntityResolveComponentsInterface.GetComponent( ri, 'vision' ) ) );
	}

	protected event OnGameAttached()
	{
		m_visionComponent.SetHiddenInVisionMode( true, gameVisionModeType.Focus );
		GameInstance.GetVisionModeSystem( GetGame() ).SetEntityVisionMode( GetEntityID(), false );
	}

	protected event OnInteractionChoice( choice : InteractionChoiceEvent ) {}

	private function IsModeOn() : Bool
	{
		var isFocusOn : Int32;
		isFocusOn = GameInstance.GetQuestsSystem( GetGame() ).GetFact( 'isFocusOn' );
		if( isFocusOn == 1 )
		{
			return true;
		}
		else if( isFocusOn == 0 )
		{
			return false;
		}
		else
		{
			return false;
		}
	}

}

