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

// This Object is used in Mission "Ring Challenge 50" - M014 - Mission_Zone04

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

private alias object.value0 : object.timeCheckpoint

// Ring/Ring Sparkle Aliases
private alias object.value2 : object.missionTypeEX

private alias 10 : MISSIONNO_RINGCHALLENGE50


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

event ObjectUpdate
	// Make sure the Object is out of the Player's sight before doing anything
	if object.outOfBounds == true
		// First, get the total time
		temp0 = stage.minutes
		temp0 *= 60
		temp0 += stage.seconds
		
		// Then compare it to when this Ring was collected
		if temp0 >= object.timeCheckpoint
			// If enough time has lapsed, then turn this Object back into a Ring
			object.type = TypeName[Ring]
			
			// Reset the Object's values
			object.priority = PRIORITY_BOUNDS
			object.timeCheckpoint = 0
		end if
	end if
end event


event ObjectStartup
	// This Object should only be used in Act 1, Act 2 is "The One Ring" Mission where we, of course, don't want respawning rings
	if stage.actNum == 1
		game.missionFunctionNo = MISSIONNO_RINGCHALLENGE50
		
		// Set the RingReset Type ID in all the Ring Objects across the level
		temp0 = TypeName[RingReset]
		foreach (TypeName[Ring], arrayPos0, ALL_ENTITIES)
			object[arrayPos0].missionTypeEX = temp0
		next
	end if
end event


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

event RSDKDraw
	DrawSprite(0)
end event


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