This commit is contained in:
CortexCore
2023-11-02 20:58:55 +08:00
parent f0f348c246
commit ee3ecec6cb
168 changed files with 58830 additions and 379 deletions

View File

@@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ab6c34283d61d534183f9a63e54f932c, type: 3}
m_Name: 6C
m_EditorClassIdentifier:
addressablePath: Cosmetics/6C
id: 4980
defId: 3071
type:

View File

@@ -3,7 +3,9 @@
"rootNamespace": "",
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:f51ebe6a0ceec4240a699833d6309b23"
"GUID:f51ebe6a0ceec4240a699833d6309b23",
"GUID:d525ad6bd40672747bde77962f1c401e",
"GUID:49b49c76ee64f6b41bf28ef951cb0e50"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BITKit.Steamwork
{
public interface ISteamInventoryItemDef:IAddressable
{
ulong Id { get; }
int DefId { get; }
string Type { get; }
}
}

View File

@@ -28,6 +28,8 @@ namespace BITKit.Steamwork
/// </summary>
bool IsInitialized { get; }
UniTask<Texture2D> GetAvatarAsync(CancellationToken token);
UniTask<ISteamInventoryItemDef[]> GetInventoryItemDefsAsync(CancellationToken token);
}
}

View File

@@ -0,0 +1,19 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace BITKit.Steamwork
{
public sealed class ScriptableInventoryItemDef: ScriptableObject,ISteamInventoryItemDef
{
[SerializeField] private string addressablePath;
[SerializeField] private ulong id;
[SerializeField] private int defId;
[SerializeField] private string type;
public string AddressablePath => addressablePath;
public ulong Id => id;
public int DefId => defId;
public string Type => type;
}
}

View File

@@ -0,0 +1,30 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Object = UnityEngine.Object;
namespace BITKit.Steamwork
{
public class SteamInventoryItemDef : ISteamInventoryItemDef
{
public string AddressablePath { get; internal set; }
public ulong Id { get; internal set;}
public int DefId { get; internal set;}
public string Type { get; internal set;}
}
[Serializable]
public sealed class UnityInventoryItemDef:ISteamInventoryItemDef
{
[SerializeField] private Object obj;
private ISteamInventoryItemDef _steamInventoryItemDefImplementation=>obj as ISteamInventoryItemDef;
public string AddressablePath => _steamInventoryItemDefImplementation.AddressablePath;
public ulong Id => _steamInventoryItemDefImplementation.Id;
public int DefId => _steamInventoryItemDefImplementation.DefId;
public string Type => _steamInventoryItemDefImplementation.Type;
}
}

View File

@@ -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);
}
}

View File

@@ -0,0 +1,18 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &11400000
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ab6c34283d61d534183f9a63e54f932c, type: 3}
m_Name: Steve
m_EditorClassIdentifier:
addressablePath: Cosmetics/Steve
id: 4980
defId: 3070
type: