mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 14:47:18 +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>
|
/// </summary>
|
||||||
public IQueryable<T> ConsumableItems => AddIncludesForConsumption(ContextFactory.Get().Set<T>());
|
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>
|
/// <summary>
|
||||||
/// Add a <typeparamref name="T"/> to the database.
|
/// Add a <typeparamref name="T"/> to the database.
|
||||||
/// </summary>
|
/// </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.
|
/// Returns a list of all usable <see cref="SkinInfo"/>s that have been loaded by the user.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <returns>A newly allocated list of available <see cref="SkinInfo"/>.</returns>
|
/// <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()
|
public void SelectRandomSkin()
|
||||||
{
|
{
|
||||||
// choose from only user skins, removing the current selection to ensure a new one is chosen.
|
// 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)
|
if (randomChoices.Length == 0)
|
||||||
{
|
{
|
||||||
@ -118,7 +118,8 @@ namespace osu.Game.Skinning
|
|||||||
return;
|
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 };
|
protected override SkinInfo CreateModel(ArchiveReader archive) => new SkinInfo { Name = archive.Name };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user