BITFALL/Assets/Artists/Scripts/Entities/Cosmetic/EntityCosmeticService.cs

37 lines
1.0 KiB
C#
Raw Normal View History

2023-11-02 20:58:55 +08:00
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;
2023-11-30 00:23:23 +08:00
using YooAsset;
using Object = UnityEngine.Object;
2023-11-02 20:58:55 +08:00
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);
2023-11-30 00:23:23 +08:00
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();
2023-11-02 20:58:55 +08:00
}
}
}