// ----------------------------------
// RSDK Project: Sonic 2
// Script Description: Coconut 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 += 0x2000

	temp0 = screen.xcenter
	temp0 += 32
	temp1 = screen.ycenter
	temp1 += 32
	CheckCameraProximity(object.ixpos, object.iypos, temp0, temp1)
	if checkResult == false
		object.type = TypeName[Blank Object]
	end if

	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		BoxCollisionTest(C_TOUCH, object.entityPos, -8, -8, 8, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
		if checkResult == true
			CallFunction(Player_ProjectileHit)
		end if
	next
end event


event ObjectDraw
	DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
end event


event ObjectStartup
	CheckCurrentStageFolder("Zone01")
	if checkResult == true
		LoadSpriteSheet("EHZ/Objects.gif")
		SpriteFrame(-6, -7, 12, 13, 82, 95)
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-6, -7, 12, 13, 258, 297)
	end if
end event


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

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	CheckCurrentStageFolder("Zone01")
	if checkResult == true
		LoadSpriteSheet("EHZ/Objects.gif")
		SpriteFrame(-6, -7, 12, 13, 82, 95)
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-6, -7, 12, 13, 258, 297)
	end if
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
