Scriptname eXo:Goodneighbor:VendorScript extends ObjectReference Const

ObjectReference Property EnableMarker Auto Const
ObjectReference Property RadioRef Auto Const

Event OnActivate(ObjectReference akActionRef)
    OpenShop()
EndEvent

Event OnExitFurniture(ObjectReference akActionRef)
    CloseShop()
EndEvent

Event OnLoad()
    SyncState()
EndEvent

Event OnCellAttach()
    SyncState()
EndEvent

Function SyncState()
    if IsFurnitureInUse()
        OpenShop()
    else
        CloseShop()
    endif
EndFunction

Function OpenShop()
    if EnableMarker
        EnableMarker.Enable(true)
    endif
    if RadioRef
        RadioRef.SetRadioOn(true)
    endif
EndFunction

Function CloseShop()
    if EnableMarker
        EnableMarker.Disable()
    endif
    if RadioRef
        RadioRef.SetRadioOn(false)
    endif
EndFunction