struct WeaponVendingMachineSetup
{
	[ customEditor = "TweakDBGroupInheritance;Vendors.WeaponVendingMachine" ]
	instanceeditable var m_vendorTweakID : TweakDBID;
	[ customEditor = "TweakDBGroupInheritance;Items.BaseDestroyedJunk" ]
	instanceeditable var m_junkItemID : TweakDBID;
	instanceeditable var m_timeToCompletePurchase : Float;
	default m_timeToCompletePurchase = 3.f;
}

struct WeaponVendingMachineSFX extends VendingMachineSFX
{
	[ customEditor = "AudioEvent" ]
	instanceeditable var m_processing : CName;
	default m_processing = 'dev_vending_machine_processing';
	[ customEditor = "AudioEvent" ]
	instanceeditable var m_gunFalls : CName;
}

class WeaponVendingMachineController extends ScriptableDeviceComponent
{

	public const override function GetPS() : WeaponVendingMachineControllerPS
	{
		return ( ( WeaponVendingMachineControllerPS )( GetBasePS() ) );
	}

}

class WeaponVendingMachineControllerPS extends VendingMachineControllerPS
{
	default m_deviceName = "LocKey#17883";
	default m_tweakDBRecord = T"Devices.WeaponVendingMachine";
	default m_tweakDBDescriptionRecord = T"device_descriptions.WeaponVendingMachine";
	private instanceeditable persistent var m_weaponVendingMachineSetup : WeaponVendingMachineSetup;
	private instanceeditable var m_weaponVendingMachineSFX : WeaponVendingMachineSFX;

	protected override function GetQuickHackActions( out actions : array< DeviceAction >, const context : ref< GetActionsContext > )
	{
		super.GetQuickHackActions( actions, context );
	}

	public function GetVendorTweakID() : TweakDBID
	{
		return m_weaponVendingMachineSetup.m_vendorTweakID;
	}

	public function GetJunkItemID() : TweakDBID
	{
		return m_weaponVendingMachineSetup.m_junkItemID;
	}

	public override function GetTimeToCompletePurchase() : Float
	{
		return m_weaponVendingMachineSetup.m_timeToCompletePurchase;
	}

	public function GetGunFallSFX() : CName
	{
		return m_weaponVendingMachineSFX.m_gunFalls;
	}

	public function GetProcessingSFX() : CName
	{
		return m_weaponVendingMachineSFX.m_processing;
	}

	public override function GetGlitchStartSFX() : CName
	{
		return m_weaponVendingMachineSFX.m_glitchingStart;
	}

	public override function GetGlitchStopSFX() : CName
	{
		return m_weaponVendingMachineSFX.m_glitchingStop;
	}

	public override function GetHackedItemCount() : Int32
	{
		return 5;
	}

	protected override function PushShopStockActions( actions : ref< array< DeviceAction > >, const context : ref< GetActionsContext > )
	{
		var shopStock : array< SItemStack >;
		var price : Int32;
		if( DispenceItemFromVendor.IsDefaultConditionMet( this, context ) && m_isReady )
		{
			shopStock = GetShopStock();
			if( shopStock.Size() > 0 )
			{
				price = MarketSystem.GetBuyPrice( ( ( GameObject )( GetOwnerEntityWeak() ) ), shopStock[ 0 ].itemID );
				actions.PushBack( ActionDispenceItemFromVendor( shopStock[ 0 ].itemID, price ) );
			}
		}
	}

}

