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


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

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

	temp0 = object.xpos
	temp0 >>= 16
	temp0 -= camera[0].xpos
	Abs(temp0)
	temp0 -= 32

	temp1 = object.ypos
	temp1 >>= 16
	temp1 -= camera[0].ypos
	Abs(temp1)
	temp1 -= 32

	if temp0 >= screen.xcenter
		object.type = TypeName[Blank Object]
	end if

	if temp1 >= screen.ycenter
		object.type = TypeName[Blank Object]
	end if
end event


event ObjectDraw
	DrawSprite(object.propertyValue)
end event


event ObjectStartup
	CheckCurrentStageFolder("Zone03")
	if checkResult == true
		LoadSpriteSheet("ARZ/Objects.gif")
		SpriteFrame(-16, -8, 32, 16, 18, 128)
		SpriteFrame(-7, -7, 15, 15, 207, 42)
		SpriteFrame(-4, -4, 7, 8, 207, 58)
		SpriteFrame(-3, -1, 4, 4, 216, 58)
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-16, -8, 32, 16, 436, 306)
		SpriteFrame(-7, -7, 15, 15, 111, 351)
		SpriteFrame(-4, -4, 7, 8, 111, 367)
		SpriteFrame(-3, -1, 4, 4, 120, 371)
	end if
end event


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

event RSDKDraw
	DrawSprite(object.propertyValue) // (even if we're not gonna label it as customisable, may as well draw it like this anyways, y'know?)
end event


event RSDKLoad
	CheckCurrentStageFolder("Zone03")
	if checkResult == true
		LoadSpriteSheet("ARZ/Objects.gif")
		SpriteFrame(-16, -8, 32, 16, 18, 128)
		SpriteFrame(-7, -7, 15, 15, 207, 42)
		SpriteFrame(-4, -4, 7, 8, 207, 58)
		SpriteFrame(-3, -1, 4, 4, 216, 58)
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-16, -8, 32, 16, 436, 306)
		SpriteFrame(-7, -7, 15, 15, 111, 351)
		SpriteFrame(-4, -4, 7, 8, 111, 367)
		SpriteFrame(-3, -1, 4, 4, 120, 371)
	end if

	// Used by the object, this object shouldn't be placed into a scene at all
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
