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

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

private alias object.propertyValue 		: object.targetPlayer

// Player Aliases
private alias object.xpos 				: player.xpos
private alias object.ypos 				: player.ypos
private alias object.direction 			: player.direction
private alias object.animation 			: player.animation
private alias object.collisionBottom 	: player.collisionBottom


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

event ObjectUpdate
	object.xpos += object.xvel
	object.ypos += object.yvel

	switch object.frame
	case 0
	case 1
	case 2
		object.animationTimer++
		if object.animationTimer > 3
			object.frame++
			object.animationTimer = 0
		end if
		break

	case 3
		object.animationTimer++
		if object.animationTimer > 3
			object.type = TypeName[Blank Object]
		end if
		break

	case 4
	case 5
	case 6
	case 7
	case 8
	case 9
		object.animationTimer++
		if object.animationTimer > 1
			object.frame++
			object.animationTimer = 0
		end if
		break

	case 10
		object.animationTimer++
		if object.animationTimer > 1
			object.frame = 4
			object.animationTimer = 0
		end if
		break
		
	end switch
end event


event ObjectDraw
	if object.frame > 3
		currentPlayer = object.targetPlayer
		object.direction = player[currentPlayer].direction
		object.xpos = player[currentPlayer].xpos
		object.iypos = player[currentPlayer].collisionBottom
		object.ypos += player[currentPlayer].ypos
		if player[currentPlayer].animation != ANI_SPINDASH
			object.type = TypeName[Blank Object]
		else
			DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
		end if

	else
		DrawSpriteFX(object.frame, FX_FLIP, object.xpos, object.ypos)
	end if
end event


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

	// Dust frames
	SpriteFrame(-7, -11, 13, 14, 51, 183)
	SpriteFrame(-7, -11, 13, 14, 65, 183)
	SpriteFrame(-6, -11, 13, 14, 79, 183)
	SpriteFrame(-7, -11, 13, 14, 93, 183)
	SpriteFrame(-32, -10, 32, 10, 58, 245)
	SpriteFrame(-32, -12, 32, 12, 91, 243)
	SpriteFrame(-32, -16, 32, 16, 124, 239)
	SpriteFrame(-32, -18, 32, 18, 157, 237)
	SpriteFrame(-32, -20, 32, 20, 190, 235)
	SpriteFrame(-32, -21, 32, 21, 223, 206)
	SpriteFrame(-32, -23, 32, 23, 223, 228)
end event


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

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("Global/Items.gif")
	SpriteFrame(-7, -11, 13, 14, 51, 183)
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
