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

//-------Aliases-------//
private alias 45 : TYPE_VPROPELLER

// Function declarations
reserve function VPropeller_DebugDraw
reserve function VPropeller_DebugSpawn

// Static Values

// Tables

function VPropeller_DebugDraw
	DrawSprite(0)
end function


function VPropeller_DebugSpawn
	CreateTempObject(TypeName[V Propeller], 0, object.xpos, object.ypos)
end function


event ObjectMain
	temp0 = object.xpos
	temp0 >>= 16
	temp0 -= screen.cameraX
	Abs(temp0)
	temp0 -= 96
	if temp0 < screen.xcenter
		temp0 = object.ypos
		temp0 >>= 16
		temp0 -= screen.cameraY
		Abs(temp0)
		if temp0 < 160
			temp0 = oscillation
			temp0 &= 31
			if temp0 == 0
				PlaySfx(SfxName[Helicopter], 0)
			end if
		end if
	end if
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		BoxCollisionTest(C_TOUCH, object.entityPos, -4, -64, 4, 64, currentPlayer, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO, HITBOX_AUTO)
		if checkResult == 1
			CallFunction(PlayerObject_Hit)
		end if
	next
end event


event ObjectDraw
	DrawSprite(WFZSetup_value37)
end event


event ObjectStartup
	LoadSpriteSheet("SCZ/Objects.gif")
	SpriteFrame(-4, -64, 8, 64, 121, 106)
	SpriteFrame(-4, -32, 8, 64, 121, 106)
	SpriteFrame(-4, 0, 8, 64, 121, 106)
	SetTableValue(TypeName[V Propeller], DebugMode_ObjCount, DebugMode_TypesTable)
	SetTableValue(VPropeller_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
	SetTableValue(VPropeller_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
