1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 13:33:52 +08:00

Reduce duplicate texture retrieval code

This commit is contained in:
Craftplacer 2020-04-27 23:18:26 +02:00
parent 9b3c1e4126
commit 834eeb6d98

View File

@ -5,7 +5,6 @@ using System;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Animations;
using osu.Framework.Graphics.Textures;
using osu.Game.Skinning;
namespace osu.Game.Rulesets.Taiko.UI
@ -40,30 +39,33 @@ namespace osu.Game.Rulesets.Taiko.UI
{
foreach (var textureIndex in clear_animation_sequence)
{
var textureName = getStateTextureName(textureIndex);
Texture texture = skin.GetTexture(textureName);
if (texture == null)
if (!addFrame(skin, textureIndex))
break;
AddFrame(texture);
}
}
else
{
for (int i = 0; true; i++)
{
var textureName = getStateTextureName(i);
Texture texture = skin.GetTexture(textureName);
if (texture == null)
if (!addFrame(skin, i))
break;
AddFrame(texture);
}
}
}
private bool addFrame(ISkinSource skin, int textureIndex)
{
var textureName = getStateTextureName(textureIndex);
var texture = skin.GetTexture(textureName);
if (texture == null)
return false;
AddFrame(texture);
return true;
}
/// <summary>
/// Advances the current frame by one.
/// </summary>