1
This commit is contained in:
@@ -19,6 +19,9 @@ namespace BITKit.Steamwork
|
||||
[Header(Constant.Header.Settings)]
|
||||
[SerializeField] private TextAsset allowCharacters;
|
||||
|
||||
[Header(Constant.Header.Settings)]
|
||||
[SerializeField] private Optional<UnityInventoryItemDef[]> overrideInventoryItemDefs;
|
||||
|
||||
//接口实现
|
||||
public ulong SteamId => SteamClient.SteamId;
|
||||
public string Name =>SteamClient.IsValid ? SteamClient.Name.Where(x=>allowCharacters.text.Contains(x)).Aggregate("",(current, c) => current+c) : Environment.UserDomainName;
|
||||
@@ -30,6 +33,18 @@ namespace BITKit.Steamwork
|
||||
return avatar.Value.Covert();
|
||||
}
|
||||
|
||||
public async UniTask<ISteamInventoryItemDef[]> GetInventoryItemDefsAsync(CancellationToken token)
|
||||
{
|
||||
if(overrideInventoryItemDefs.Allow)return overrideInventoryItemDefs.Value;
|
||||
var items = await SteamInventory.GetAllItemsAsync();
|
||||
if(items.HasValue is false)return Array.Empty<ISteamInventoryItemDef>();
|
||||
return items.Value.GetItems().Select(x => new SteamInventoryItemDef()
|
||||
{
|
||||
Id = x.Id,
|
||||
DefId = x.DefId
|
||||
}).Cast<ISteamInventoryItemDef>().ToArray();
|
||||
}
|
||||
|
||||
public int Id => (int)SteamClient.SteamId.AccountId;
|
||||
|
||||
private bool initialized;
|
||||
@@ -50,10 +65,10 @@ namespace BITKit.Steamwork
|
||||
initialized = true;
|
||||
BIT4Log.Log<SteamService>("已初始化Steam");
|
||||
}
|
||||
catch (Exception)
|
||||
catch (Exception e)
|
||||
{
|
||||
BIT4Log.Warning<SteamService>("Steam初始化失败,请验证客户端是否运行");
|
||||
throw;
|
||||
Debug.Log(e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,5 +88,6 @@ namespace BITKit.Steamwork
|
||||
public string Name => _steamServiceImplementation.Name;
|
||||
public bool IsInitialized=>_steamServiceImplementation.IsInitialized;
|
||||
public UniTask<Texture2D> GetAvatarAsync(CancellationToken token)=>_steamServiceImplementation.GetAvatarAsync(token);
|
||||
public UniTask<ISteamInventoryItemDef[]> GetInventoryItemDefsAsync(CancellationToken token)=>_steamServiceImplementation.GetInventoryItemDefsAsync(token);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user