class IconsModule extends HUDModule
{

	protected override function Process( out task : HUDJob, mode : ActiveMode )
	{
		var instruction : IconsInstance;
		instruction = task.instruction.iconsInstruction;
		if( !( task.actor.IsGrouppedClue() ) && ( ( ( mode == ActiveMode.FOCUS || m_hud.IsPulseActive() ) || task.actor.IsRevealed() ) || task.actor.IsTagged() ) )
		{
			instruction.SetState( InstanceState.ON, DuplicateLastInstance( task.actor ) );
			instruction.SetContext( IsActorLookedAt( task.actor ), task.actor.IsRevealed(), task.actor.IsIconForcedVisibileThroughWalls() );
			return;
		}
		else if( ShouldDisplayBodyDisposal( task.actor ) )
		{
			instruction.SetState( InstanceState.ON, DuplicateLastInstance( task.actor ) );
			instruction.SetContext( IsActorLookedAt( task.actor ), task.actor.IsRevealed(), task.actor.IsIconForcedVisibileThroughWalls() );
			return;
		}
		else if( mode == ActiveMode.SEMI && task.actor.IsInIconForcedVisibilityRange() )
		{
			instruction.SetState( InstanceState.ON, DuplicateLastInstance( task.actor ) );
			instruction.SetContext( IsActorLookedAt( task.actor ), task.actor.IsRevealed(), task.actor.IsIconForcedVisibileThroughWalls() );
			return;
		}
		else if( IsActorLookedAt( task.actor ) && ( ( task.actor.GetType() != HUDActorType.DEVICE && task.actor.GetType() != HUDActorType.BODY_DISPOSAL_DEVICE ) || task.actor.IsClue() ) )
		{
			instruction.SetState( InstanceState.ON, DuplicateLastInstance( task.actor ) );
			instruction.SetContext( IsActorLookedAt( task.actor ), task.actor.IsRevealed(), task.actor.IsIconForcedVisibileThroughWalls() );
			return;
		}
		else
		{
			instruction.SetState( InstanceState.DISABLED, DuplicateLastInstance( task.actor ) );
			instruction.SetContext( IsActorLookedAt( task.actor ), task.actor.IsRevealed(), task.actor.IsIconForcedVisibileThroughWalls() );
			return;
		}
	}

	protected function ShouldDisplayBodyDisposal( actor : HUDActor ) : Bool
	{
		if( actor.GetType() == HUDActorType.BODY_DISPOSAL_DEVICE )
		{
			if( IsPlayerCarrying() || IsEnemyGrappled() )
			{
				return true;
			}
		}
		return false;
	}

	private const function IsPlayerCarrying() : Bool
	{
		return m_hud.GetPlayerSMBlackboard().GetBool( GetAllBlackboardDefs().PlayerStateMachine.Carrying );
	}

	private const function IsEnemyGrappled() : Bool
	{
		return m_hud.GetPlayerSMBlackboard().GetInt( GetAllBlackboardDefs().PlayerStateMachine.Takedown ) == ( ( Int32 )( gamePSMTakedown.Grapple ) );
	}

	protected override function Process( out jobs : array< HUDJob >, mode : ActiveMode )
	{
		var i : Int32;
		for( i = 0; i < jobs.Size(); i += 1 )
		{
			Process( jobs[ i ], mode );
		}
	}

	public override function Suppress( jobs : ref< array< HUDJob > > )
	{
		var instruction : IconsInstance;
		var i : Int32;
		for( i = 0; i < jobs.Size(); i += 1 )
		{
			instruction = jobs[ i ].instruction.iconsInstruction;
			instruction.SetState( InstanceState.DISABLED, DuplicateLastInstance( jobs[ i ].actor ) );
			instruction.SetContext( false, false, false );
		}
	}

	protected override function DuplicateLastInstance( actor : HUDActor ) : IconsInstance
	{
		return ( ( IconsInstance )( super.DuplicateLastInstance( actor ) ) );
	}

}

class IconsInstance extends ModuleInstance
{
	var isForcedVisibleThroughWalls : Bool;

	public function SetContext( _isLookedAt : Bool, _isRevealed : Bool, _isForcedVisibleThroughWalls : Bool )
	{
		isForcedVisibleThroughWalls = _isForcedVisibleThroughWalls;
		isRevealed = _isRevealed;
		isLookedAt = _isLookedAt;
	}

}

