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

//-------Aliases-------//
private alias 73 : TYPE_TILTPLATFORMV

// Function declarations
reserve function TiltPlatformV_DebugDraw
reserve function TiltPlatformV_DebugSpawn

// Static Values

// Tables

function TiltPlatformV_DebugDraw
	DrawSprite(0)
end function


function TiltPlatformV_DebugSpawn
	CreateTempObject(TypeName[Tilt Platform V], 0, object.xpos, object.ypos)
	object[tempObjectPos].direction = object.direction
end function


event ObjectMain
	switch object.state
	case 0
		temp0 = oscillation
		temp0 &= 240
		if temp0 == object.propertyValue
			object.priority = PRIORITY_ACTIVE
			object.animationTimer = 0
			object.frame = 1
			object.state = 1
		end if
		break
	case 1
		object.animationTimer++
		if object.animationTimer == 4
			object.frame = 2
			object.value0 = 74
			object.state = 2
		end if
		break
	case 2
		object.value0--
		if object.value0 == 0
			object.animationTimer = 0
			object.frame = 1
			object.state = 3
		end if
		break
	case 3
		object.animationTimer++
		if object.animationTimer == 4
			object.frame = 0
			object.state = 0
		end if
		break
	end switch
	if object.frame == 0
		foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
			BoxCollisionTest(C_BOX, object.entityPos, -4, -24, 4, 24, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
		next
	end if
	if object.outOfBounds == 1
		object.frame = 0
		object.state = 0
		object.priority = PRIORITY_ACTIVE_BOUNDS
	end if
end event


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


event ObjectStartup
	LoadSpriteSheet("SCZ/Objects.gif")
	SpriteFrame(-4, -24, 8, 48, 311, 99)
	SpriteFrame(-16, -16, 32, 32, 320, 108)
	SpriteFrame(-24, -4, 48, 8, 320, 99)
	SpriteFrame(-16, -16, 32, 32, 353, 108)
	SetTableValue(TypeName[Tilt Platform V], DebugMode_ObjCount, DebugMode_TypesTable)
	SetTableValue(TiltPlatformV_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
	SetTableValue(TiltPlatformV_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
	DebugMode_ObjCount++
end event

event RSDKDraw
	DrawSprite(0)
end event

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