// ----------------------------------
// RSDK Project: Sonic 1/Sonic 2
// Script Description: Bubble Shield Object
// Script Author: Christan Whitehead/Simon Thomley
// Unpacked by Rubberduckycooly's script unpacker
// ----------------------------------

//-------Aliases-------//
private alias 26 : TYPE_BUBBLESHIELD


// Static Values

// Tables
public table BubbleShield_table23
	2, 0, 2, 0, 2, 0, 3, 1, 3, 1, 3, 1, 4, 0, 4, 0
	4, 0, 5, 1, 5, 1, 5, 1, 6, 0, 6, 0, 6, 0, 5, 1
	5, 1, 5, 1, 4, 0, 4, 0, 4, 0, 3, 1, 3, 1, 3, 1
	2, 0, 2, 0, 2, 0
end table


event ObjectMain
	if object[-playerCount].state == PlayerObject_Death
		object.type = TypeName[Blank Object]
	end if
	if object[-playerCount].state == PlayerObject_Drown
		object.type = TypeName[Blank Object]
	end if
	object.drawOrder = -1
	switch object.state
	case 0
		object.animationTimer = 0
		object.value0 = 0
		GetTableValue(object.frame, object.value0, BubbleShield_table23)
		object.state++
	case 1
		object.animationTimer++
		if object.animationTimer >= 2
			object.animationTimer = 0
			object.value0++
			if object.value0 >= 54
				object.value0 = 0
			end if
			GetTableValue(object.frame, object.value0, BubbleShield_table23)
		end if
		break
	case 2
		object.animationTimer = 0
		object.value0 = 0
		object.frame = 0
		object.state++
	case 3
		if object.value0 == 0
			object.animationTimer++
			if object.animationTimer >= 5
				object.frame = 8
				object.animationTimer = 0
				object.value0++
			end if
		else
			object.animationTimer++
			if object.animationTimer >= 19
				object.state = 0
			end if
		end if
		break
	case 4
		object.animationTimer = 0
		object.value0 = 0
		object.frame = 7
		object.state++
	case 5
		if object.value0 == 0
			object.animationTimer++
			if object.animationTimer >= 13
				object.frame = 8
				object.animationTimer = 0
				object.value0++
			end if
		else
			object.animationTimer++
			if object.animationTimer >= 7
				object.state = 0
			end if
		end if
		break
	end switch
end event


event ObjectDraw
	if PlayerObject_SuperState != 1
		object.direction = FLIP_NONE
		if object.value0 >= 30
			if object.frame > 1
				object.direction = FLIP_Y
			end if
		end if
		DrawSpriteFX(object.frame, FX_FLIP, object[-playerCount].xpos, object[-playerCount].ypos)
	end if
end event


event ObjectStartup
	LoadSpriteSheet("Global/Items3.gif")
	SpriteFrame(-24, -24, 48, 48, 1, 1)
	SpriteFrame(-24, -24, 48, 48, 50, 1)
	SpriteFrame(-16, -23, 32, 7, 99, 1)
	SpriteFrame(-20, -22, 40, 12, 99, 9)
	SpriteFrame(-22, -22, 44, 20, 99, 22)
	SpriteFrame(-23, -20, 46, 19, 144, 1)
	SpriteFrame(-23, -15, 46, 30, 144, 21)
	SpriteFrame(-36, -16, 72, 32, 1, 50)
	SpriteFrame(-28, -20, 56, 40, 74, 50)
	SpriteFrame(0, 0, 1, 1, 1, 1)
end event

event RSDKDraw
	DrawSprite(0)
end event

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