importonly class MappinControllerCustomData extends IScriptable
{
}

importonly class TrackedMappinControllerCustomData extends MappinControllerCustomData
{
}

import abstract class BaseMappinBaseController extends inkLogicController
{
	protected import editable var iconWidget : inkImageRef;
	protected import editable var playerTrackedWidget : inkWidgetRef;
	protected editable var m_animPlayerTrackedWidget : inkWidgetRef;
	protected editable var m_animPlayerAboveBelowWidget : inkWidgetRef;
	protected const editable var m_taggedWidgets : array< inkWidgetRef >;

	public import function GetMappin() : weak< IMappin >;
	public import function GetProfile() : MappinUIRuntimeProfile_Record;
	public import function GetDistanceToPlayer() : Float;
	public import function GetVerticalRelationToPlayer() : gamemappinsVerticalPositioning;
	public import function ShouldShowDistance() : Bool;
	public import function ShouldShowDisplayName() : Bool;
	public import function SetProjectToScreenSpace( projectToScreenSpace : Bool );
	protected import function IsClamped() : Bool;
	public import function ShouldClamp() : Bool;
	public import function OverrideClamp( shouldClamp : Bool );
	public import function OverrideClampX( shouldClamp : Bool );
	public import function OverrideClampY( shouldClamp : Bool );
	protected import function OverrideScaleByDistance( shouldScale : Bool );
	protected import function SetRootVisible( visible : Bool );
	protected import function SetIgnorePriority( ignore : Bool );
	protected import function RequestForcedUpdate();
	public import function IsCustomPositionTracked() : Bool;
	public import function IsPlayerTracked() : Bool;
	public import function IsTracked() : Bool;
	protected import function IsGPSPortal() : Bool;

	protected function UpdateRootState()
	{
		var state : CName;
		state = ComputeRootState();
		if( state == '' )
		{
			state = 'Default';
		}
		GetRootWidget().SetState( state );
	}

	protected virtual function UpdateTrackedState()
	{
		var isRootVisible, isTracked, isClamped : Bool;
		var visible : Bool;
		var i : Int32;
		var animPlayer : animationPlayer;
		visible = false;
		if( m_taggedWidgets.Size() == 0 )
		{
			return;
		}
		if( GetProfile().ShowTrackedIcon() )
		{
			isRootVisible = GetRootWidget().IsVisible();
			isTracked = IsTracked();
			isClamped = IsClamped();
			visible = ( isRootVisible && isTracked ) && !( isClamped );
		}
		for( i = 0; i < m_taggedWidgets.Size(); i += 1 )
		{
			inkWidgetRef.SetVisible( m_taggedWidgets[ i ], visible );
		}
		animPlayer = GetAnimPlayer_Tracked();
		if( animPlayer != NULL )
		{
			animPlayer.PlayOrPause( visible );
		}
	}

	protected virtual function ComputeRootState() : CName
	{
		return 'Default';
	}

	public virtual function GetWidgetForNameplateSlot() : weak< inkWidget >
	{
		return GetRootWidget();
	}

	public const virtual function GetVisualData() : GameplayRoleMappinData
	{
		return NULL;
	}

	public function GetAnimPlayer_Tracked() : weak< animationPlayer >
	{
		return ( ( animationPlayer )( ( ( inkWidgetRef.IsValid( m_animPlayerTrackedWidget ) ) ? ( inkWidgetRef.GetController( m_animPlayerTrackedWidget ) ) : ( NULL ) ) ) );
	}

	public function GetAnimPlayer_AboveBelow() : weak< animationPlayer >
	{
		return ( ( animationPlayer )( ( ( inkWidgetRef.IsValid( m_animPlayerAboveBelowWidget ) ) ? ( inkWidgetRef.GetController( m_animPlayerAboveBelowWidget ) ) : ( NULL ) ) ) );
	}

}

importonly class BaseInteractionMappinController extends BaseMappinBaseController
{
	protected import var isCurrentlyClamped : Bool;
	protected import var isUnderCrosshair : Bool;
}

importonly class BaseQuestMappinController extends BaseInteractionMappinController
{
	protected import editable var distanceText : inkTextRef;
	protected import editable var displayName : inkTextRef;
	protected import var nameplateVisible : Bool;

	protected import function UpdateDistanceText();
	protected import function UpdateDisplayName();
}

class MapPinUtility
{

	public static function OnClampUpdates( argRoot : weak< inkCompoundWidget >, isClamped : Bool, optional isQuest : Bool )
	{
		var canvasHolder : weak< inkCompoundWidget >;
		canvasHolder = ( ( inkCompoundWidget )( argRoot.GetWidget( 'Canvas' ) ) );
		if( canvasHolder != NULL )
		{
			canvasHolder.SetVisible( !( isClamped ) );
		}
	}

}

