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

//-------Aliases-------//
private alias 59 : TYPE_SPIKESACTIVATOR


// Static Values

// Tables

event ObjectMain
	arrayPos0 = object.value1
	while arrayPos0 < object.value0
		object[arrayPos0].priority = PRIORITY_ACTIVE
		arrayPos0++
	loop
end event


event ObjectDraw
	arrayPos0 = object.value1
	while arrayPos0 < object.value0
		if stage.state == STAGE_RUNNING
			object[arrayPos0].priority = PRIORITY_INACTIVE
		else
			object[arrayPos0].priority = PRIORITY_ACTIVE
		end if
		arrayPos0++
	loop
end event


event ObjectStartup
	foreach (TypeName[Spikes Activator], arrayPos0, ALL_ENTITIES)
		arrayPos1 = arrayPos0
		object[arrayPos0].value0 = object[arrayPos0].propertyValue
		temp0 = 0
		while temp0 == 0
			if object[arrayPos1].type == TypeName[Moving Spikes]
				object[arrayPos0].value1 = arrayPos1
				temp0 = 1
			else
				arrayPos1++
				if arrayPos1 >= 0x420
					temp0 = 1
				end if
			end if
		loop
		object[arrayPos0].value0 += object[arrayPos0].value1
	next
end event

event RSDKDraw
	DrawSprite(0)
end event

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