// ----------------------------------
// RSDK Project: Sonic 1
// Script Description: Ring Sparkle Object
// Script Author: Christian Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

// ========================
// Aliases
// ========================

private alias object.value0 : object.timer

// Ring Reset (Mission Object) Aliases
private alias object.value0 : object.timeCheckpoint
private alias object.value2 : object.missionTypeEX

private alias 10 : MISSIONNO_RINGCHALLENGE50


// ========================
// Events
// ========================

event ObjectUpdate
	object.timer++
	if object.timer == 6
		object.timer = 0
		object.frame++

		if object.frame == 4
			object.type = TypeName[Blank Object]
			object.frame = 0
			
#platform: USE_ORIGINS
			if game.playMode == BOOT_PLAYMODE_MISSION
				if game.missionFunctionNo == MISSIONNO_RINGCHALLENGE50
					// Turn the Object into a Ring Reset Object
					// -> missionTypeEX is set by a foreach in Ring Reset's startup
					object.type = object.missionTypeEX
					
					// Now, set the time the Object was collected + 20 seconds
					object.timeCheckpoint = stage.minutes
					object.timeCheckpoint *= 60
					object.timeCheckpoint += stage.seconds
					object.timeCheckpoint += 20
					
					object.priority = PRIORITY_ACTIVE
				end if
			end if
#endplatform
		end if
	end if
end event


event ObjectDraw
	DrawSprite(object.frame)
end event


event ObjectStartup
	LoadSpriteSheet("Global/Items.gif")

	// Sparkle frames
	SpriteFrame(-8, -8, 16, 16, 1, 202)
	SpriteFrame(-8, -8, 16, 16, 18, 202)
	SpriteFrame(-8, -8, 16, 16, 1, 219)
	SpriteFrame(-8, -8, 16, 16, 18, 219)
end event


// ========================
// Editor Events
// ========================

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("Global/Items.gif")
	SpriteFrame(-8, -8, 16, 16, 1, 202) // * Sparkle *
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
