dofile("scripts/entities/entityinclude.lua")

didInit = false
done = false
door = 0

function init(me)
	door = node_getNearestEntity(me, "EnergyDoor")
end

function doInit(me)
	debugLog("Setting door to opened")
	--entity_setState(door, STATE_OPENED, -1, true)
	entity_setState(door, STATE_OPENED)
end

function update(me, dt)
	if not didInit then
		doInit(me)
		didInit = true
	end
	
	if not done then
		if getFlag(FLAG_SUNKENCITY_PUZZLE) < SUNKENCITY_BOSSDONE then
			if node_isEntityIn(me, getNaija()) then
				debugLog("closing door")
				entity_setState(door, STATE_CLOSE, -1, true)
				--if entity_isState(door, STATE_CLOSE) then
					--done = true			
				--end
				done = true
			end
		end
	end
end


