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

// ========================
// Aliases
// ========================

// Player Aliases
private alias object.value40 : player.hitboxLeft
private alias object.value38 : player.hitboxTop
private alias object.value41 : player.hitboxRight
private alias object.value39 : player.hitboxBottom


// ========================
// Function Declarations
// ========================

reserve function Antenna_DebugDraw
reserve function Antenna_DebugSpawn


// ========================
// Function Definitions
// ========================

private function Antenna_DebugDraw
	DrawSprite(0)
end function


private function Antenna_DebugSpawn
	CreateTempObject(TypeName[Antenna], 0, object.xpos, object.ypos)
end function


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

event ObjectUpdate
	object.animationTimer ^= 1
	if object.animationTimer == 0
		object.frame++
		if object.frame >= 3
			object.frame = 0
		end if
	end if

	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		BoxCollisionTest(C_TOUCH, object.entityPos, -4, -16, 4, 16, currentPlayer, player[currentPlayer].hitboxLeft, player[currentPlayer].hitboxTop, player[currentPlayer].hitboxRight, player[currentPlayer].hitboxBottom)
		if checkResult == true
			CallFunction(Player_BadnikBreak)
		end if
	next
end event


event ObjectDraw
	DrawSprite(object.frame)
end event


event ObjectStartup
	LoadSpriteSheet("SCZ/Objects.gif")
	SpriteFrame(-4, -16, 8, 30, 195, 159)
	SpriteFrame(-4, -16, 8, 30, 204, 159)
	SpriteFrame(-4, -16, 8, 30, 213, 159)

	SetTableValue(TypeName[Antenna], DebugMode_ObjCount, DebugMode_TypesTable)
	SetTableValue(Antenna_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
	SetTableValue(Antenna_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
	DebugMode_ObjCount++
end event


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

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("SCZ/Objects.gif")
	SpriteFrame(-4, -16, 8, 30, 195, 159)
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
