// Power Core Handler.
// Worthless Bums 2012.


function createPowerCore (%xIndex, %yIndex)
{//echo("createPowerCore()");
	%powerCore = new Sprite("Power Core")
	{
		SceneLayer = 11;		// Below monsters/squad members.
		graph = 11;				// Below monsters/squad members.
		position = %position;
		scenegraph = levelSceneGraph;
		imagemap = "PowerCorePickupImageMap";
		visible = true;
		size = "4 4";
		depleted = false;
	};
	addObjectToScene(%powerCore);
	$powerCoreList.add(%oxygenTank);
}
function spawnDisruptor ()
{//echo("spawnDisruptor()");echo("$DisruptorList.getCount() =" SPC $DisruptorList.getCount());
	if ($difficultyLevel >= 3	&&
		$DisruptorList.getCount() <= 0)
	{
		for (%i = 0; %i < 200; %i++)
		{
			%xIndex = getRandom(0, $mazeDimension - 1);
			%yIndex = getRandom(0, $mazeDimension - 1);
			
			if (tileIsClear(%xIndex, %yIndex)	&&
				!isSpaceTile(%xIndex, %yIndex))
			{//echo("spawning disruptor!");
				$ElevatorDisruptorXIndex = -1;
				$ElevatorDisruptorYIndex = -1;
				createDisruptorAnimation(%xIndex, %yIndex);
				return;
			}
		}
	}
}
function smashDisruptor ()
{
	if (isObject($ElevatorDisruptor))
	{
		createDisruptorExplosionAnimation($ElevatorDisruptor.xIndex, $ElevatorDisruptor.yIndex);
		$ElevatorDisruptor.safeDelete();
		playRandomMetalWallCollapseSfx();
	}
	powerElevatorOn();
	$ElevatorDisruptor = null;
	$ElevatorDisruptorXIndex = -1;
	$ElevatorDisruptorYIndex = -1;
}