using System; using System.Collections.Generic; using System.Linq; using UnityEngine; public class HatManager : DestroyableSingleton { public HatBehaviour NoneHat; public List AllPets = new List(); public List AllHats = new List(); public List AllSkins = new List(); internal PetBehaviour GetPetById(uint petId) { if ((ulong)petId >= (ulong)((long)this.AllPets.Count)) { return this.AllPets[0]; } return this.AllPets[(int)petId]; } public uint GetIdFromPet(PetBehaviour pet) { return (uint)this.AllPets.FindIndex((PetBehaviour p) => p.idleClip == pet.idleClip); } public PetBehaviour[] GetUnlockedPets() { return (from h in this.AllPets where h.Free || SaveManager.GetPurchase(h.ProductId) select h).ToArray(); } public HatBehaviour GetHatById(uint hatId) { if ((ulong)hatId >= (ulong)((long)this.AllHats.Count)) { return this.NoneHat; } return this.AllHats[(int)hatId]; } public HatBehaviour[] GetUnlockedHats() { return (from h in this.AllHats where h.LimitedMonth == 0 || SaveManager.GetPurchase(h.ProductId) select h into o orderby o.Order descending, o.name select o).ToArray(); } public uint GetIdFromHat(HatBehaviour hat) { return (uint)this.AllHats.IndexOf(hat); } public SkinData[] GetUnlockedSkins() { return (from o in this.AllSkins orderby o.Order descending, o.name select o).ToArray(); } public uint GetIdFromSkin(SkinData skin) { return (uint)this.AllSkins.IndexOf(skin); } internal SkinData GetSkinById(uint skinId) { if ((ulong)skinId >= (ulong)((long)this.AllSkins.Count)) { return this.AllSkins[0]; } return this.AllSkins[(int)skinId]; } internal void SetSkin(SpriteRenderer skinRend, uint skinId) { SkinData skinById = this.GetSkinById(skinId); if (skinById) { skinRend.sprite = skinById.IdleFrame; } } }