// Environment Object Handler.
// Worthless Bums 2013.


// Creates a wall pipes static sprite.
function createWallPipes (%xIndex, %yIndex)
{//echo("createWallPipes()");
	%position = getTileShiftedPositionFromIndices(%xIndex, %yIndex);
	%wallPipes = new Sprite("WallPipes")
	{
		SceneLayer = $WallPipeObjectsLayer;
		graph = $WallPipeObjectsGroup;
		position = %position;
		scenegraph = levelSceneGraph;
		imagemap = "WallPipesImageMap";
		visible = true;
		size = "4 4";
	};
	addObjectToScene(%wallPipes);
	$mazeRoom[%xIndex, %yIndex].wallPipeObject = %wallPipes;
}

// Creates a right side wall pipes static sprite.
function createRightSideWallPipes (%xIndex, %yIndex)
{//echo("createRightSideWallPipes()");
	%position = getTileShiftedPositionFromIndices(%xIndex, %yIndex);
	%sideWallPipes = new Sprite("RightSideWallPipes")
	{
		SceneLayer = $WallPipeObjectsLayer;
		graph = $WallPipeObjectsGroup;
		position = %position;
		scenegraph = levelSceneGraph;
		imagemap = "RightSideWallPipeImageMap";
		visible = true;
		size = "4 4";
	};
	addObjectToScene(%sideWallPipes);
	$mazeRoom[%xIndex, %yIndex].sideWallPipe = 1;	// 1 is right side.
}
// Creates a left side wall pipes static sprite.
function createLeftSideWallPipes (%xIndex, %yIndex)
{//echo("createLeftSideWallPipes()");
	%position = getTileShiftedPositionFromIndices(%xIndex, %yIndex);
	%sideWallPipes = new Sprite("LeftSideWallPipes")
	{
		SceneLayer = $WallPipeObjectsLayer;
		graph = $WallPipeObjectsGroup;
		position = %position;
		scenegraph = levelSceneGraph;
		imagemap = "LeftSideWallPipeImageMap";
		visible = true;
		size = "4 4";
	};
	addObjectToScene(%sideWallPipes);
	$mazeRoom[%xIndex, %yIndex].sideWallPipe = 2;	// 2 is left side.
}

// Creates a porthole.
function createPorthole (%x, %y)
{//echo("createPorthole()");
	if ($overworldLocation $= "Alien Deck")
	{
		return;
	}
	%porthole = new Sprite("Porthole")
	{
		SceneLayer = $PortholeLayer;
		position = getTileShiftedPositionFromIndices(%x, %y);
		scenegraph = levelSceneGraph;
		image = "Sprites:Porthole";
		visible = true;
		size = "4 4";
	};
	addObjectToScene(%porthole);
	$mazeRoom[%x, %y].porthole = %porthole;
}