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

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

event ObjectUpdate
	if object.propertyValue == 5
		// Follow the water's surface
		temp0 = stage.waterLevel
		object.iypos = temp0
	end if
end event


event ObjectDraw
	DrawSprite(object.propertyValue)
end event


event ObjectStartup
	LoadSpriteSheet("HPZ/Objects.gif")

	// Waterfall frames
	SpriteFrame(-5, -16, 13, 32, 353, 222)
	SpriteFrame(-5, -16, 13, 12, 353, 222)
	SpriteFrame(-4, -4, 8, 12, 344, 222)
	SpriteFrame(-8, -16, 16, 32, 175, 140)
	SpriteFrame(-12, -22, 24, 24, 186, 231)
	SpriteFrame(-12, -22, 24, 24, 186, 231)

	foreach (TypeName[Waterfall Sprite], arrayPos0, ALL_ENTITIES)
		object[arrayPos0].drawOrder = 5
	next

end event


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

event RSDKEdit
	if editor.returnVariable == true
		switch editor.variableID
		case EDIT_VAR_PROPVAL // property value
			checkResult = object.propertyValue
			break
			
		case 0 // frameID
			checkResult = object.propertyValue
			break
			
		end switch
	else
		switch editor.variableID
		case EDIT_VAR_PROPVAL // property value
			object.propertyValue = editor.variableValue
			break
			
		case 0 // frameID
			object.propertyValue = editor.variableValue
			break
			
		end switch
	end if
end event


event RSDKDraw
	DrawSprite(object.propertyValue)
end event


event RSDKLoad
	LoadSpriteSheet("HPZ/Objects.gif")

	// Waterfall frames
	SpriteFrame(-5, -16, 13, 32, 353, 222)
	SpriteFrame(-5, -16, 13, 12, 353, 222)
	SpriteFrame(-4, -4, 8, 12, 344, 222)
	SpriteFrame(-8, -16, 16, 32, 175, 140)
	SpriteFrame(-12, -22, 24, 24, 186, 231)
	SpriteFrame(-12, -22, 24, 24, 186, 231)

	AddEditorVariable("frameID")
	SetActiveVariable("frameID")
	AddEnumVariable("frame 0", 0)
	AddEnumVariable("frame 1", 1)
	AddEnumVariable("frame 2", 2)
	AddEnumVariable("frame 3", 3)
	AddEnumVariable("frame 4", 4)
	AddEnumVariable("frame 5 (follows water surface)", 5)
end event
