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

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

// States
private alias 0 : LASER_WAITING
private alias 1 : LASER_FIRED

// Player Aliases
private alias object.xpos : player.xpos


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

event ObjectUpdate
	if object.state == LASER_WAITING
		temp0 = object.xpos
		temp0 -= 0xE80000
		if player[0].xpos >= temp0
			if player[0].xpos < object.xpos
				PlaySfx(SfxName[Medium Laser], false)
			end if

			object.state++
		end if
	else
		if object.alpha < 0x100
			object.alpha += 0x10
		end if

		object.xpos -= 0x100000
		if object.outOfBounds == true
			object.type = TypeName[Blank Object]
		end if
	end if
end event


event ObjectDraw
	if object.state == LASER_FIRED
		DrawSpriteFX(0, FX_INK, object.xpos, object.ypos)
	end if
end event


event ObjectStartup
	LoadSpriteSheet("SCZ/Objects.gif")
	SpriteFrame(-72, -8, 144, 16, 81, 198)

	foreach (TypeName[Laser], arrayPos0, ALL_ENTITIES)
		object[arrayPos0].drawOrder = 5
		object[arrayPos0].inkEffect = INK_ALPHA
		object[arrayPos0].priority 	= PRIORITY_ACTIVE
	next
end event


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

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("SCZ/Objects.gif")
	SpriteFrame(-72, -8, 144, 16, 81, 198)
	
	// Normally set to 118 in the scene for some reason, that value's unused though
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
