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

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

// TODO: just like S1, there's something funky going on with this object's value0
// maybe it's an editor value, maybe it's a leftover from that game, idk

// Player Aliases
private alias object.type  : player.type
private alias object.state : player.state


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

event ObjectUpdate
	if player[0].state != Player_State_Drown
		// If the Player isn't drowning, then act as a box
		// I do wonder why it's only drowning that's checked against though, and not any other death states...
		BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, 0, C_BOX, C_BOX, C_BOX, C_BOX)
		
		if player[1].type != TypeName[Blank Object] // Shields are legally players, I guess
			// If Tails is with Sonic (the only mission this would apply to is Bodyguard), check against them too
			// No check if they're drowning or anything, just assume they're alive
			BoxCollisionTest(C_SOLID, object.entityPos, -16, -16, 16, 16, 1, C_BOX, C_BOX, C_BOX, C_BOX)
		end if
	end if
end event


event ObjectDraw
	DrawSprite(0)
end event


event ObjectStartup
	LoadSpriteSheet("Mission/Objects.gif")
	
	// Mission Block Frame
	SpriteFrame(-16, -16, 32, 32, 1, 18)
end event


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

event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("Mission/Objects.gif")
	SpriteFrame(-16, -16, 32, 32, 1, 18)
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
