mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:37:28 +08:00
Attempt to reduce skin lookup overhead where file access is not required
This commit is contained in:
parent
3ad7688eaf
commit
4bf22db4ff
@ -36,6 +36,11 @@ namespace osu.Game.Database
|
||||
/// </summary>
|
||||
public IQueryable<T> ConsumableItems => AddIncludesForConsumption(ContextFactory.Get().Set<T>());
|
||||
|
||||
/// <summary>
|
||||
/// Access barebones items with no includes.
|
||||
/// </summary>
|
||||
public IQueryable<T> Items => ContextFactory.Get().Set<T>();
|
||||
|
||||
/// <summary>
|
||||
/// Add a <typeparamref name="T"/> to the database.
|
||||
/// </summary>
|
||||
|
@ -105,12 +105,12 @@ namespace osu.Game.Skinning
|
||||
/// Returns a list of all usable <see cref="SkinInfo"/>s that have been loaded by the user.
|
||||
/// </summary>
|
||||
/// <returns>A newly allocated list of available <see cref="SkinInfo"/>.</returns>
|
||||
public List<SkinInfo> GetAllUserSkins() => ModelStore.ConsumableItems.Where(s => !s.DeletePending).ToList();
|
||||
public List<SkinInfo> GetAllUserSkins() => ModelStore.Items.Where(s => !s.DeletePending).ToList();
|
||||
|
||||
public void SelectRandomSkin()
|
||||
{
|
||||
// choose from only user skins, removing the current selection to ensure a new one is chosen.
|
||||
var randomChoices = GetAllUsableSkins().Where(s => s.ID != CurrentSkinInfo.Value.ID).ToArray();
|
||||
var randomChoices = ModelStore.Items.Where(s => !s.DeletePending && s.ID != CurrentSkinInfo.Value.ID).ToArray();
|
||||
|
||||
if (randomChoices.Length == 0)
|
||||
{
|
||||
@ -118,7 +118,8 @@ namespace osu.Game.Skinning
|
||||
return;
|
||||
}
|
||||
|
||||
CurrentSkinInfo.Value = randomChoices.ElementAt(RNG.Next(0, randomChoices.Length));
|
||||
var chosen = randomChoices.ElementAt(RNG.Next(0, randomChoices.Length));
|
||||
CurrentSkinInfo.Value = ModelStore.ConsumableItems.Single(i => i.ID == chosen.ID);
|
||||
}
|
||||
|
||||
protected override SkinInfo CreateModel(ArchiveReader archive) => new SkinInfo { Name = archive.Name };
|
||||
|
Loading…
Reference in New Issue
Block a user