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

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

reserve function Fireball_DebugDraw
reserve function Fireball_DebugSpawn


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

private function Fireball_DebugDraw
	DrawSprite(0)
end function


private function Fireball_DebugSpawn
	CreateTempObject(TypeName[Fireball], 0, object.xpos, object.ypos)
end function


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

event ObjectUpdate
	object.drawOrder = 5

	object.animationTimer++
	if object.animationTimer >= 12
		object.animationTimer = 0
	end if
	object.frame = object.animationTimer
	object.frame >>= 2
	GetBit(object.direction, object.animationTimer, 1)

	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_FireHit)
		end if
	next
end event


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


event ObjectStartup
	LoadSpriteSheet("CPZ/Objects.gif")
	SpriteFrame(-6, -23, 12, 28, 5, 161)
	SpriteFrame(-6, -26, 13, 31, 18, 158)
	SpriteFrame(-5, -27, 14, 32, 32, 157)

	SetTableValue(TypeName[Fireball], DebugMode_ObjCount, DebugMode_TypesTable)
	SetTableValue(Fireball_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
	SetTableValue(Fireball_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
	DebugMode_ObjCount++
end event


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

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("CPZ/Objects.gif")
	SpriteFrame(-6, -23, 12, 28, 5, 161)
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
