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

// Object Name is a bit general, while yes this does indeed activate objects,
// it's used pretty much only for triplets of Nebulas since they should all by synced together

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

private alias object.propertyValue : object.activateCount

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

event ObjectUpdate
	// Activate some following objects

	arrayPos0 = object.entityPos
	arrayPos0++

	temp0 = 0

	while temp0 < object.activateCount
		object[arrayPos0].priority = PRIORITY_ACTIVE
		arrayPos0++
		temp0++
	loop

	// Clear this object, it's no longer needed
	object.type = TypeName[Blank Object]
end event


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

event RSDKDraw	
	DrawSprite(0)

	if editor.showGizmos == true
		// draw a line to the objects that'll be activated

		temp0 = 0
		arrayPos1 = object.entityPos
		while temp0 < object.activateCount
			arrayPos1++
			DrawLine(object.xpos, object.ypos, object[arrayPos1].xpos, object[arrayPos1].ypos, 0xFF, 0xFF, 0x00)
			temp0++
		loop
	end if
end event


event RSDKLoad
	LoadSpriteSheet("Global/Display.gif")
	SpriteFrame(-8, -8, 16, 16, 168, 18) // "Trigger" - #0
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "activateCount")
end event
