Scriptname _00E_FS_Smelter_Workbench extends ObjectReference
{script that is attached to all smelter workbenches and manages the switching between dismantling and smelting}

Actor Property PlayerREF Auto
Message Property _00E_Theriantrophist_CantCraftMSG Auto
Message Property _00E_Smelting_DismantlingMSG Auto
Race Property _00E_Theriantrophist_PlayerWerewolfRace Auto
ObjectReference Property _00E_Dismantling_SmelterREF Auto

Event OnInit()
	BlockActivation()
Endevent

Event OnActivate(ObjectReference akActionRef)
	
	; block the player from activating the smelter when being transformed in werewolf due to animation bugs
	If akActionRef == PlayerREF && PlayerREF.GetRace() == _00E_Theriantrophist_PlayerWerewolfRace
		_00E_Theriantrophist_CantCraftMSG.Show()
	ElseIf akActionRef == PlayerREF && !(PlayerREF.GetRace() == _00E_Theriantrophist_PlayerWerewolfRace)
		int iButton = _00E_Smelting_DismantlingMSG.Show()
		
		If iButton == 0 ; if the player wants to process ore into ingots
			Self.Activate(akActionRef, true)
		ElseIf iButton == 1 ; if the player wants to dismantle items back into crafting components, disable player controls
			Game.DisablePlayerControls(true, true, true, true, true, true, true, true)
			_00E_Dismantling_SmelterREF.Activate(PlayerREF)
		Else
			return
		EndIf
	Else 
		Self.Activate(akActionRef, true) ; if it's not the player but an NPC
	EndIf

Endevent