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

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

reserve function CluckerBase_DebugDraw
reserve function CluckerBase_DebugSpawn


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

private function CluckerBase_DebugDraw
	DrawSprite(0)
end function


private function CluckerBase_DebugSpawn
	CreateTempObject(TypeName[Clucker Base], 0, object.xpos, object.ypos)
end function


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

event ObjectUpdate
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		BoxCollisionTest(C_SOLID, object.entityPos, -16, -8, 16, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
	next
end event


event ObjectDraw
	DrawSprite(0)
end event


event ObjectStartup
	CheckCurrentStageFolder("Zone11")
	if checkResult == true
		LoadSpriteSheet("SCZ/Objects.gif")
		SpriteFrame(-24, -8, 48, 16, 1, 206)
		
		// Hm?
		// Why is this part in the zone folder check if it's the same between both?
		SetTableValue(TypeName[Clucker Base], DebugMode_ObjCount, DebugMode_TypesTable)
		SetTableValue(CluckerBase_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
		SetTableValue(CluckerBase_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
		DebugMode_ObjCount++
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-24, -8, 48, 16, 576, 289)
		
		// The same as the SCZ addition type above, not quite sure why it's separate here...
		SetTableValue(TypeName[Clucker Base], DebugMode_ObjCount, DebugMode_TypesTable)
		SetTableValue(CluckerBase_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
		SetTableValue(CluckerBase_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
		DebugMode_ObjCount++
	end if
end event


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

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	CheckCurrentStageFolder("Zone11")
	if checkResult == true
		LoadSpriteSheet("SCZ/Objects.gif")
		SpriteFrame(-24, -8, 48, 16, 1, 206)
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-24, -8, 48, 16, 576, 289)
	end if
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
