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

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

private alias object.state : object.isSetup

private alias object.value0 : object.fadeColor.A
private alias object.value1 : object.fadeColor.R
private alias object.value2 : object.fadeColor.G
private alias object.value3 : object.fadeColor.B


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

event ObjectUpdate
	if object.isSetup == false
		object.fadeColor.R = fadeColor
		object.fadeColor.R >>= 16
		object.fadeColor.G = fadeColor
		object.fadeColor.G &= 0x00FF00
		object.fadeColor.G >>= 8
		object.fadeColor.B = fadeColor
		object.fadeColor.B &= 0x0000FF
		object.fadeColor.A = 0x100
		object.isSetup = true
		PlayMusic(0)
	else
		if object.fadeColor.A > 0
			object.fadeColor.A -= 8
		else
			object.type = TypeName[Blank Object]
			object.controlMode = CONTROLMODE_P1
		end if
	end if

	SetScreenFade(object.fadeColor.R, object.fadeColor.G, object.fadeColor.B, object.fadeColor.A)
end event


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

event RSDKDraw
	DrawSprite(0)
end event


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