// CryoTube Handler.
// Worthless Bums 2013.


function spawnCryoTubes ()
{//echo("spawnCryoTubes()");
	%maxTubes = 1;
	for (%i = 0; %i < %maxTubes; %i++)
	{
		spawnCryoTube();
	}
}
function tileHasCryoTube (%xIndex, %yIndex)
{
	for (%i = 0; %i < $CryoTubeList.getCount(); %i++)
	{
		%cryoTube = $CryoTubeList.getObject(%i);
		if (%cryoTube.xIndex == %xIndex	&&
			%cryoTube.yIndex == %yIndex)
		{
			return true;
		}
	}
	return false;
}
function spawnCryoTube ()
{
	for (%i = 0; %i < 200; %i++)
	{
		%xIndex = getRandom(0, $mazeDimension - 1);
		%yIndex = getRandom(0, $mazeDimension - 1);
		if (tileIsClear(%xIndex, %yIndex)	&&
			!isSpaceTile(%xIndex, %yIndex))
		{
			createCryoTubeAnimation(%xIndex, %yIndex);
			return;
		}
	}
}
function smashCryoTube (%cryoTubeIndex)
{
	%cryoTube = $CryoTubeList.getObject(%cryoTubeIndex);
	createDisruptorExplosionAnimation(%cryoTube.xIndex, %cryoTube.yIndex);
	%cryoTube.safeDelete();
	playRandomMetalWallCollapseSfx();
}