// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Secret Door Object
// Script Author: Christan Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 147 : TYPE_SECRETDOOR


// Static Values

// Tables

event ObjectMain
	if object.state == 0
		if object.value0 > 0
			object.value0 -= 0x80000
		end if
	else
		if object.value0 < 0x400000
			object.value0 += 0x80000
		else
			object.priority = PRIORITY_ACTIVE_BOUNDS
		end if
	end if
	object.ypos -= object.value0
	if object.value0 == 0
		foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
			BoxCollisionTest(C_BOX, object.entityPos, -8, -32, 8, 32, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
		next
	else
		foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
			BoxCollisionTest(C_BOX, object.entityPos, -8, -32, 8, 8, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
		next
	end if
	object.ypos += object.value0
end event


event ObjectDraw
	temp0 = object.value0
	FlipSign(temp0)
	temp0 += object.ypos
	DrawSpriteFX(0, FX_FLIP, object.xpos, temp0)
end event


event ObjectStartup
	LoadSpriteSheet("MBZ/Objects.gif")
	SpriteFrame(-8, -32, 16, 64, 93, 312)
	foreach (TypeName[Secret Door], arrayPos0, ALL_ENTITIES)
		object[arrayPos0].drawOrder = 4
	next
end event

event RSDKDraw
	DrawSprite(0)
end event

event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 143)
end event
