Get Sprites from linked controllers also

This commit is contained in:
Tim Young 2017-09-10 17:00:59 -05:00
parent 1dc3b5e9f1
commit ed0529deae

View File

@ -964,9 +964,34 @@ namespace SpriteLibrary
if (OneSprite.SpriteName == Name)
{ return OneSprite; }
}
//If we have not found one on this controller, get it from another controller
foreach(SpriteController SC in LinkedControllers)
{
Sprite Found = SC.SpriteFromNameInternal(Name);
if (Found != null)
{
//If we get here, we do not have it in our list. Add it to this controller and then return it
AddSprite(Found);
return Found;
}
}
return null;
}
/// <summary>
/// The internal SpriteFromName does not check the linked controllers. Keeps us from entering into an endless loop
/// </summary>
/// <param name="Name"></param>
/// <returns></returns>
internal Sprite SpriteFromNameInternal(string Name)
{
foreach (Sprite OneSprite in Sprites)
{
if (OneSprite.SpriteName == Name)
{ return OneSprite; }
}
return null;
}
/// <summary>
/// Add the specified sprite to the list of sprites we know about. You usually do not need to do this.
/// Sprites add themselves to the controller when you create a new sprite.