Scriptname _tckObjectContainerTriggerScript extends ObjectReference  

import debug
import utility

ObjectReference Property ShelfContainer auto hidden

Bool Property AlreadyLoaded = FALSE Auto Hidden


EVENT OnCellLoad()
	if AlreadyLoaded == FALSE
		ShelfContainer = GetLinkedRef()
		AlreadyLoaded = TRUE
	endif
endEVENT


auto STATE WaitForObjects

	EVENT OnBeginState()
	
	endEVENT

	EVENT OnTriggerEnter(ObjectReference TriggerRef)
	
	endEvent

	EVENT OnTriggerLeave(ObjectReference TriggerRef)
		; Reference has left this trigger
		if GetParentCell().IsAttached()
			if (TriggerRef == Game.GetPlayerGrabbedRef())
				; Check to see if the player is holding it
			else
				; Player isnt' grabbing this reference, check to see if it's in the container.
				if Shelfcontainer.GetItemCount(TriggerRef.GetBaseObject()) >= 1
					Shelfcontainer.RemoveItem(TriggerRef.GetBaseObject(), 1)
				else
				; There is no object based on this form in the container
				endif
			endif
		endif
	endEvent


endSTATE


STATE IgnoreObjects
	Event OnBeginState()

	endEVENT
endSTATE

int Property testint  Auto  
