// Worthless Bums, 2014.


function createScene ()
{
    if (isObject(myScene))
	{
        destroyScene();
	}
    new Scene(myScene);
	// Set the layer sort modes. We want closer images render on top.
    myScene.setLayerSortMode( 0, "-z");
    myScene.setLayerSortMode( 1, "-z");
    myScene.setLayerSortMode( 2, "-z");
    myScene.setLayerSortMode( 3, "-z");
    myScene.setLayerSortMode( 4, "-y");	// Units on this layer!
    myScene.setLayerSortMode( 5, "-z");
    myScene.setLayerSortMode( 6, "-z");
    myScene.setLayerSortMode( 7, "-z");
    myScene.setLayerSortMode( 8, "-z");
    myScene.setLayerSortMode( 9, "-z");
    myScene.setLayerSortMode(10, "-z");
    myScene.setLayerSortMode(11, "-z");
    myScene.setLayerSortMode(12, "-z");
    myScene.setLayerSortMode(13, "-z");
    myScene.setLayerSortMode(14, "-z");
    myScene.setLayerSortMode(15, "-z");
    myScene.setLayerSortMode(16, "-z");
}
function destroyScene ()
{
    if (isObject(myScene))
	{
		clearScene();
		myScene.delete();
	}
}
function clearScene ()
{
	%sceneObjectList = myScene.getSceneObjectList();
	for (%i = 0; %i < myScene.getCount(); %i++)
	{
		myScene.getObject(%i).safeDelete();
	}
}