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

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

private alias 0 : BOSSBLOCK_SOLID
private alias 1 : BOSSBLOCK_NONSOLID

private alias 0 : BOSSBLOCK_BLOCK
private alias 1 : BOSSBLOCK_DEBRIS


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

event ObjectUpdate
	if object.propertyValue == BOSSBLOCK_BLOCK
		if object.state == BOSSBLOCK_SOLID
			foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
				BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
			next
		end if
	else
		object.yvel += 0x1800
		object.xpos += object.xvel
		object.ypos += object.yvel

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


event ObjectDraw
	DrawSprite(object.propertyValue)
end event


event ObjectStartup
	LoadSpriteSheet("SYZ/Objects.gif")
	SpriteFrame(-16, -16, 32, 32, 110, 152)
	SpriteFrame(-8, -8, 16, 16, 110, 152)
	SpriteFrame(-8, -8, 16, 16, 126, 152)
	SpriteFrame(-8, -8, 16, 16, 110, 168)
	SpriteFrame(-8, -8, 16, 16, 126, 168)
end event


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

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("SYZ/Objects.gif")
	SpriteFrame(-16, -16, 32, 32, 110, 152)
	
	// Although used by the object, it shouldn't be set by the editor
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
