85 lines
2.1 KiB
C#
85 lines
2.1 KiB
C#
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public static class DlcContentAccess
|
|
{
|
|
public static bool IsSongAccessible(SongData song)
|
|
{
|
|
if (song == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
dlcData owningDlc = SongDlcContentResolver.GetOwningDlc(song);
|
|
return owningDlc == null || DlcOwnershipService.IsDlcOwned(owningDlc);
|
|
}
|
|
|
|
public static bool IsHeroAccessible(AllyHero_SO hero)
|
|
{
|
|
if (hero == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(hero.sourceDlcId))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return DlcOwnershipService.IsDlcOwned(hero.sourceDlcId);
|
|
}
|
|
|
|
public static bool IsSkinAccessible(HeroSkinResolvedData skin)
|
|
{
|
|
if (skin == null)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
if (skin.isBaseSkin || skin.unlockedByDefault)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
if (string.IsNullOrWhiteSpace(skin.sourceDlcId))
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return DlcOwnershipService.IsDlcOwned(skin.sourceDlcId);
|
|
}
|
|
|
|
public static HeroSkinResolvedData GetAccessibleSelectedSkin(AllyHero_SO hero, bool fallbackToBase = true)
|
|
{
|
|
if (hero == null)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
HeroSkinResolvedData selected = hero.GetResolvedSelectedSkin(fallbackToBase);
|
|
if (IsSkinAccessible(selected))
|
|
{
|
|
return selected;
|
|
}
|
|
|
|
return fallbackToBase ? HeroSkinResolver.BuildBaseSkin(hero) : null;
|
|
}
|
|
|
|
public static List<HeroSkinResolvedData> GetAccessibleSkinSet(AllyHero_SO hero, bool includeBaseSkin = true)
|
|
{
|
|
List<HeroSkinResolvedData> all = hero != null ? hero.GetResolvedSkinSet(includeBaseSkin) : new List<HeroSkinResolvedData>();
|
|
List<HeroSkinResolvedData> result = new List<HeroSkinResolvedData>(all.Count);
|
|
|
|
for (int i = 0; i < all.Count; i++)
|
|
{
|
|
HeroSkinResolvedData skin = all[i];
|
|
if (IsSkinAccessible(skin))
|
|
{
|
|
result.Add(skin);
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
}
|