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

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

private alias object.value0 : object.timer
private alias object.state  : object.emitting

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

// ========================
// Tables
// ========================

event ObjectUpdate
	if object.emitting == true
		object.animationTimer++
		object.animationTimer &= 7
		object.frame = object.animationTimer
		object.frame >>= 1
		object.frame++
		object.timer--
		if object.timer <= 0
			object.emitting = false
			object.frame = 0
			object.animationTimer = 0
		end if

		temp0 = oscillation
		temp0 &= 15
		if temp0 == 0
			PlaySfx(SfxName[Electric Arc], false)
		end if
	end if
	
	foreach (GROUP_PLAYERS, currentPlayer, ACTIVE_ENTITIES)
		BoxCollisionTest(C_SOLID, object.entityPos, -8, -24, 8, 8, currentPlayer, C_BOX, C_BOX, C_BOX, C_BOX)
	next
end event


event ObjectDraw
	DrawSprite(object.frame)
end event


event ObjectStartup
	LoadSpriteSheet("SBZ/Objects.gif")
	SpriteFrame(-8, -8, 16, 16, 162, 397)
	SpriteFrame(-8, -8, 16, 16, 179, 397)
	SpriteFrame(-8, -8, 16, 16, 196, 397)
	SpriteFrame(-8, -8, 16, 16, 179, 397)
	SpriteFrame(-8, -8, 16, 16, 213, 397)
	foreach (TypeName[Plasma Emitter], arrayPos0, ALL_ENTITIES)
		object[arrayPos0].drawOrder = 4
	next
end event


event RSDKDraw
	DrawSprite(0)
end event


event RSDKLoad
	LoadSpriteSheet("SBZ/Objects.gif")
	SpriteFrame(-8, -8, 16, 16, 162, 397)
	
	SetVariableAlias(ALIAS_VAR_PROPVAL, "unused")
end event
