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

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

reserve function LargeLaser_DebugDraw
reserve function LargeLaser_DebugSpawn


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

private function LargeLaser_DebugDraw
	DrawSprite(0)
end function


private function LargeLaser_DebugSpawn
	CreateTempObject(TypeName[Large Laser], 0, object.xpos, object.ypos)
	object[tempObjectPos].inkEffect = INK_ALPHA
	object[tempObjectPos].alpha 	= 0xC0
end function


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

event ObjectUpdate
	object.animationTimer++
	if object.animationTimer == 1
		PlaySfx(SfxName[Thruster], false)
	end if

	if object.animationTimer >= 64
		object.type = TypeName[Blank Object]
	end if

	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		BoxCollisionTest(C_TOUCH, object.entityPos, -24, -112, 24, 112, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
		if checkResult == true
			CallFunction(Player_Hit)
		end if
	next
end event


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


event ObjectStartup
	LoadSpriteSheet("SCZ/Objects.gif")
	SpriteFrame(-24, -112, 48, 256, 464, 0)

	foreach (TypeName[Large Laser], arrayPos0, ALL_ENTITIES)
		object[arrayPos0].inkEffect = INK_ALPHA
		object[arrayPos0].alpha 	= 0xC0
	next

	SetTableValue(TypeName[Large Laser], DebugMode_ObjCount, DebugMode_TypesTable)
	SetTableValue(LargeLaser_DebugDraw, DebugMode_ObjCount, DebugMode_DrawTable)
	SetTableValue(LargeLaser_DebugSpawn, DebugMode_ObjCount, DebugMode_SpawnTable)
	DebugMode_ObjCount++
end event


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

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("SCZ/Objects.gif")
	SpriteFrame(-24, -112, 48, 256, 464, 0)
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
