// Shadow Handler.
// Worthless Bums 2012.


// Adds a shadow to the specified unit.
function createUnitShadow (%unit)
{//echo("createUnitShadow()");echo("%unit.name =" SPC %unit.name);
return;	// Disabled for now!
	// CharacterShadowImageMap// Create sentry turret static sprite.
	%shadowSprite = new Sprite("Unit Shadow")
	{
		SceneLayer = $ShadowLayer;		// Below monsters/squad members.
		graph = $ShadowGroup;		// Below monsters/squad members.
		position = "4000 4000";
		scenegraph = levelSceneGraph;
		image = "Sprites:CharacterShadow";
		visible = true;
		size = "8 8";
	};
	addObjectToScene(%shadowSprite);
	
	// Track unit shadow.
	%unit.shadow = %shadowSprite;	// This seems to "mount" the shadow sprite directly above (north/up) the parent sprite!
//echo("%shadowSprite.position =" SPC %shadowSprite.position);
	
	// Adjust unit shadow by unit size (dispatched by name for now!)
	/*if (%unit.name $= "Hulk"	||
		%unit.name $= "Revenant")
	{
		%xOffset = 0;
		%yOffset = -0.6;
	}
	else if (%unit.name $= "Revenant")
	{
		%xOffset = 0;
		%yOffset = -0.5;
	}
	else if (%unit.name $= "Gunship")
	{
		%shadowSprite.size = "8 8";
		%xOffset = 0;
		%yOffset = -0.5;
	}
	else
	{
		%xOffset = 0;
		%yOffset = -1;
	}
	// Mount unit shadow.
	%shadowSprite.mount(%unit, %xOffset, %yOffset, 50.0, true, true, true, true);*/
}
// Attaches all unit shadows.
function attachAllUnitShadows ()
{//echo("attachAllUnitShadows()");
//return;	// Disable for now!
	// Attach shadows to squad members.
	if ($leaderPersist)
	{
		createUnitShadow($playerSquad[0]);
	}
	if ($scoutPersist)
	{
		createUnitShadow($playerSquad[1]);
	}
	if ($grenadierPersist)
	{
		createUnitShadow($playerSquad[2]);
	}
	if ($supportPersist)
	{
		createUnitShadow($playerSquad[3]);
	}
	
	// Attach shadows to monsters.
	for (%i = 0; %i < $monsterList.getCount(); %i++)
	{
		createUnitShadow($monsterList.getObject(%i));
	}
	
	// Attach shadows to treasure chests.
	for (%i = 0; %i < $treasureChestList.getCount(); %i++)
	{
		createUnitShadow($treasureChestList.getObject(%i));
	}
}