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

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

reserve function Cannon_DebugDraw
reserve function Cannon_DebugSpawn


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

private function Cannon_DebugDraw
	DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
end function


private function Cannon_DebugSpawn
	CreateTempObject(TypeName[Cannon], 0, object.xpos, object.ypos)

	object[tempObjectPos].direction = object.direction
	object[tempObjectPos].drawOrder = 4
end function


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

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


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

	// Cannon frame
	SpriteFrame(-8, -16, 16, 32, 67, 59)

	foreach (TypeName[Cannon], arrayPos0, ALL_ENTITIES)
		object[arrayPos0].drawOrder = 4
	next

	// Add Cannons to the debug object list
	SetTableValue(TypeName[Cannon], DebugMode_ObjCount, DebugMode_TypesTable)
	SetTableValue(Cannon_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
	SetTableValue(Cannon_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
	DebugMode_ObjCount++
end event


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

event RSDKDraw
	// direction is set from editor
	DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
end event


event RSDKLoad
	LoadSpriteSheet("SLZ/Objects.gif")
	SpriteFrame(-8, -16, 16, 32, 67, 59)
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
