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

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

private alias object.value0 : object.offset.x


// ========================
// Static Values
// ========================

private value EggmanLaser_sheetX = 0
private value EggmanLaser_sheetY = 0


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

event ObjectUpdate
	object.xpos += object.xvel

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

	if object.outOfBounds == true
		object.type = TypeName[Blank Object]
	end if
end event


event ObjectDraw
	temp0 = object.xpos
	temp0 &= 0xFFFF0000
	temp0 -= object.offset.x
	Abs(temp0)
	temp0 >>= 16
	temp0 += 4
	if temp0 > 64
		temp0 = 64
	end if

	EditFrame(0, -32, -6, temp0, 12, EggmanLaser_sheetX, EggmanLaser_sheetY)
	DrawSpriteFX(0, FX_FLIP, object.xpos, object.ypos)
end event


event ObjectStartup
	CheckCurrentStageFolder("Zone09")
	if checkResult == true
		LoadSpriteSheet("MPZ/Objects.gif")
		SpriteFrame(-32, -6, 64, 12, 220, 193)
		EggmanLaser_sheetX = 220
		EggmanLaser_sheetY = 193
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-32, -6, 64, 12, 247, 185)
		EggmanLaser_sheetX = 247
		EggmanLaser_sheetY = 185
	end if
end event


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

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	CheckCurrentStageFolder("Zone09")
	if checkResult == true
		LoadSpriteSheet("MPZ/Objects.gif")
		SpriteFrame(-32, -6, 64, 12, 220, 193)
	else
		LoadSpriteSheet("MBZ/Objects.gif")
		SpriteFrame(-32, -6, 64, 12, 247, 185)
	end if
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
