class WardrobeControllerPS extends ScriptableDeviceComponentPS
{
	default m_deviceName = "LocKey#2120";
	default m_tweakDBRecord = T"Devices.Wardrobe";
	default m_shouldScannerShowNetwork = false;
	default m_shouldScannerShowStatus = false;
	default m_shouldScannerShowAttitude = false;
	default m_shouldScannerShowHealth = false;
	protected persistent var m_clothingSets : array< ClothingSet >;
	protected instanceeditable var m_hasInteraction : Bool;
	default m_hasInteraction = false;

	protected override function GameAttached() {}

	protected override function LogicReady()
	{
		super.LogicReady();
	}

	public override function GetActions( out actions : array< DeviceAction >, context : GetActionsContext ) : Bool
	{
		var baseTestsPassed : Bool;
		baseTestsPassed = super.GetActions( actions, context );
		FirstInit();
		if( !( baseTestsPassed ) || context.requestType != gamedeviceRequestType.Direct )
		{
			return false;
		}
		if( m_hasInteraction )
		{
			actions.PushBack( ActionOpenWardrobeUI( context.processInitiatorObject ) );
		}
		SetActionIllegality( actions, m_illegalActions.regularActions );
		return true;
	}

	public const function HasInteraction() : Bool
	{
		return m_hasInteraction;
	}

	protected function ActionOpenWardrobeUI( executor : GameObject ) : OpenWardrobeUI
	{
		var action : OpenWardrobeUI;
		action = new OpenWardrobeUI;
		action.clearanceLevel = DefaultActionsParametersHolder.GetInteractiveClearance();
		action.SetUp( this );
		action.SetProperties();
		action.SetExecutor( executor );
		action.AddDeviceName( m_deviceName );
		action.CreateInteraction();
		return action;
	}

	protected function OnOpenWardrobeUI( evt : OpenWardrobeUI ) : EntityNotificationType
	{
		var uiSystem : UISystem;
		var menuEvent : inkMenuInstance_SpawnEvent;
		var userData : WardrobeUserData;
		menuEvent = new inkMenuInstance_SpawnEvent;
		uiSystem = GameInstance.GetUISystem( GetGameInstance() );
		if( uiSystem )
		{
			userData = new WardrobeUserData;
			menuEvent.Init( 'OnOpenWardrobeMenu', userData );
			uiSystem.QueueEvent( menuEvent );
		}
		UseNotifier( evt );
		return EntityNotificationType.DoNotNotifyEntity;
	}

	protected function FirstInit()
	{
		var factVal : Int32;
		factVal = GetFact( GetGameInstance(), 'WardrobeInitFromStash' );
		if( ( factVal <= 0 ) && ( ( ( Int32 )( gameGameVersion.Current ) ) >= 1500 ) )
		{
			InitializeWardrobeFromStash();
			SetFactValue( GetGameInstance(), 'WardrobeInitFromStash', 1 );
		}
	}

	protected function InitializeWardrobeFromStash()
	{
		var i : Int32;
		var dataManager : VendorDataManager;
		var storageItems : array< gameItemData >;
		var wardrobeSystem : WardrobeSystem;
		wardrobeSystem = GameInstance.GetWardrobeSystem( GetGameInstance() );
		dataManager = new VendorDataManager;
		dataManager.Initialize( GetPlayer( GetGameInstance() ), PersistentID.ExtractEntityID( GetID() ) );
		storageItems = dataManager.GetStorageItems();
		for( i = 0; i < storageItems.Size(); i += 1 )
		{
			if( RPGManager.IsItemClothing( storageItems[ i ].GetID() ) )
			{
				wardrobeSystem.StoreUniqueItemIDAndMarkNew( GetGameInstance(), storageItems[ i ].GetID() );
			}
		}
	}

}

importonly class ClothingSet extends IScriptable
{
	import var setID : gameWardrobeClothingSetIndex;
	import var clothingList : array< SSlotVisualInfo >;
	import var iconID : TweakDBID;

	public import static function IsEmpty( set : ClothingSet ) : Bool;
}

class OpenWardrobeUI extends ActionBool
{

	public function SetProperties()
	{
		actionName = 'OpenWardrobeUI';
		prop = DeviceActionPropertyFunctions.SetUpProperty_Bool( actionName, true, 'LocKey#79193', 'LocKey#79193' );
	}

	public override function GetTweakDBChoiceRecord() : String
	{
		return "OpenWardrobeUI";
	}

}

class DisableVisualOverride extends Event
{
	editable var blockReequipping : Bool;
	default blockReequipping = true;

	public constexpr function GetFriendlyDescription() : String
	{
		return "Unequip Wardrobe Set";
	}

}

class RestoreVisualOverride extends Event
{

	public constexpr function GetFriendlyDescription() : String
	{
		return "Reequip Last Wardrobe Set";
	}

}

class EnableVisualOverride extends Event
{

	public constexpr function GetFriendlyDescription() : String
	{
		return "Enable Equipping Wardrobe Set";
	}

}

class HideVisualSlot extends Event
{
	editable var slot : TransmogSlots;

	public constexpr function GetFriendlyDescription() : String
	{
		return "Hide Item In Slot";
	}

}

class RestoreVisualSlot extends Event
{
	editable var slot : TransmogSlots;

	public constexpr function GetFriendlyDescription() : String
	{
		return "Restore Item In Slot";
	}

}

enum TransmogSlots
{
	Head = 0,
	Face = 1,
	InnerChest = 2,
	OuterChest = 3,
	Legs = 4,
	Feet = 5,
}

