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

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

private alias object.value3  : object.localPos.z
private alias object.value4  : object.worldPos.x
private alias object.value5  : object.worldPos.y
private alias object.value6  : object.worldPos.z

// Halfpipe Aliases
private alias object.value13 : halfpipe.playerPos.z

// Face Buffer Flag Aliases
private alias 7 : FACE_SPRITE_3D


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

event ObjectUpdate
	arrayPos0 = scene3D.vertexCount
	arrayPos1 = scene3D.faceCount
	faceBuffer[arrayPos1].flag = FACE_SPRITE_3D
	faceBuffer[arrayPos1].a = arrayPos0
	vertexBuffer[arrayPos0].x = object.worldPos.x
	vertexBuffer[arrayPos0].y = object.worldPos.y
	vertexBuffer[arrayPos0].z = object.worldPos.z
	vertexBuffer[arrayPos0].u = TypeName[Ring Sparkle]
	vertexBuffer[arrayPos0].v = FX_ROTATE
	arrayPos0++

	faceBuffer[arrayPos1].b = arrayPos0
	vertexBuffer[arrayPos0].x = object.worldPos.x
	vertexBuffer[arrayPos0].y = object.worldPos.y
	vertexBuffer[arrayPos0].z = object.worldPos.z
	vertexBuffer[arrayPos0].u = object.frame
	vertexBuffer[arrayPos0].v = 0
	arrayPos0++

	faceBuffer[arrayPos1].c = arrayPos0
	vertexBuffer[arrayPos0].x = object.worldPos.x
	vertexBuffer[arrayPos0].y = object.worldPos.y
	vertexBuffer[arrayPos0].z = object.worldPos.z
	vertexBuffer[arrayPos0].u = 0x200
	vertexBuffer[arrayPos0].v = 0
	arrayPos0++

	faceBuffer[arrayPos1].d = arrayPos0
	vertexBuffer[arrayPos0].x = object.worldPos.x
	vertexBuffer[arrayPos0].y = object.worldPos.y
	vertexBuffer[arrayPos0].z = object.worldPos.z
	scene3D.vertexCount += 4
	scene3D.faceCount++

	if object.localPos.z < halfpipe[0].playerPos.z
		object.type = TypeName[Blank Object]
	end if
	
	object.animationTimer++
	if object.animationTimer == 4
		object.animationTimer = 0
		object.frame++
		if object.frame == 3
			object.type = TypeName[Blank Object]
			object.frame = 0
		end if
	end if
end event


event ObjectStartup
	LoadSpriteSheet("Special/Objects.gif")
	
	SpriteFrame(-14, -16, 24, 27, 323, 108)
	SpriteFrame(-14, -12, 30, 22, 348, 122)
	SpriteFrame(-11, -11, 24, 27, 323, 126)
end event


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

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("Special/Objects.gif")
	SpriteFrame(-14, -12, 30, 22, 348, 122)
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
