37 lines
1.0 KiB
C#
37 lines
1.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Security;
|
|
using BITFALL.Cosmetic;
|
|
using BITKit;
|
|
using BITKit.Entities;
|
|
using BITKit.Steamwork;
|
|
using UnityEngine;
|
|
using YooAsset;
|
|
using Object = UnityEngine.Object;
|
|
|
|
namespace BITFALL.Entities.Cosmetic
|
|
{
|
|
[CustomType(typeof(ICosmeticService))]
|
|
public class EntityCosmeticService : EntityBehavior,ICosmeticService
|
|
{
|
|
[SerializeReference, SubclassSelector] private ISteamService steamService;
|
|
|
|
public ICosmetic[] Cosmetics { get; private set; }
|
|
public event Action OnCosmeticsChanged;
|
|
public override async void OnStart()
|
|
{
|
|
base.OnStart();var items =await steamService.GetInventoryItemDefsAsync(destroyCancellationToken);
|
|
List<ICosmetic> cosmetics=new List<ICosmetic>();
|
|
foreach (var x in items.Select(x=>YooAssets.LoadAssetAsync<Object>(x.AddressablePath) ))
|
|
{
|
|
x.WaitForAsyncComplete();
|
|
cosmetics.Add(x.AssetObject as ICosmetic);
|
|
}
|
|
Cosmetics = cosmetics.ToArray();
|
|
OnCosmeticsChanged?.Invoke();
|
|
}
|
|
}
|
|
}
|