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

@@ -287,7 +287,9 @@ namespace BITKit
BIT4Log.Warning<BITApp>($"{nameof(BITApp)}初始化错误:");
BIT4Log.LogException(e);
}
#if NET5_0_OR_GREATER
ServiceProvider = ServiceCollection.BuildServiceProvider();
#endif
}
public static void Stop()
{

View File

@@ -17,6 +17,9 @@ namespace BITKit.Entities
IEntityComponent[] Components { get; }
bool RegisterComponent<T>(T component);
IServiceProvider ServiceProvider { get; }
#if NET5_0_OR_GREATER
IServiceCollection ServiceCollection { get; }
#endif
void Inject(object obj);
}
/// <summary>

View File

@@ -65,9 +65,9 @@ namespace BITKit
public bool TryGetEntried(out T value)
{
EnsureConfiguration();
if (index is not -1)
if (m_index is not -1)
{
value = list[index];
value = list[m_index];
return true;
}
value = default;
@@ -86,7 +86,6 @@ namespace BITKit
else
{
var currentIndex = m_index;
m_index = index;
if (currentIndex is not -1 && list.TryGetElementAt(currentIndex, out var currentElement))
{
currentElement.Exit();
@@ -100,7 +99,7 @@ namespace BITKit
currentElement.IsEntered = false;
OnExit?.Invoke(currentElement);
}
m_index = index;
if (index is not -1 && list.TryGetElementAt(index, out var nextElement))
{
nextElement.IsEntered = true;

View File

@@ -56,7 +56,7 @@
"id": "9db494c5-bec3-4b09-bd5f-66ba07a3a729",
"expectedControlType": "Button",
"processors": "",
"interactions": "Tap,Hold,Press",
"interactions": "Press,Tap,Hold",
"initialStateCheck": false
},
{

View File

@@ -4,7 +4,8 @@
"references": [
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
"GUID:75469ad4d38634e559750d17036d5f7c",
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0"
"GUID:709caf8d7fb6ef24bbba0ab9962a3ad0",
"GUID:7efac18f239530141802fb139776f333"
],
"includePlatforms": [],
"excludePlatforms": [],

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Security.Permissions;
using UnityEngine;
using BITKit.Entities;
using BITKit.Events;
@@ -23,7 +24,7 @@ namespace BITKit.Vehicles
public WheelType wheelType;
}
public sealed class Vehicle : MonoBehaviour
public sealed class Vehicle : EntityBehavior
{
[Header(Constant.Header.Settings)] public float maxMotorTorque = 64;
[SerializeField] private float maxSteeringAngle = 45;
@@ -36,6 +37,9 @@ namespace BITKit.Vehicles
[SerializeField]
private new Rigidbody rigidbody;
[SerializeField] private GameObject[] objects;
[SerializeField] private GameObject[] destroyedObjects;
[SerializeField] private Transform driveAnchor;
[Header(Constant.Header.Gameobjects)]
@@ -53,7 +57,29 @@ namespace BITKit.Vehicles
private bool isBraking;
private readonly ValidHandle highSpeedHandle = new();
private IUnityEntity _unityEntity;
private void Start()
[Inject]
private IHealth _health;
public override void OnAwake()
{
base.OnAwake();
_health.OnSetAlive += OnSetAlive;
}
private void OnSetAlive(bool obj)
{
foreach (var x in objects)
{
x.SetActive(obj);
}
foreach (var x in destroyedObjects)
{
x.SetActive(!obj);
}
}
public override void OnStart()
{
highSpeedHandle.AddListener(x =>
{
@@ -69,8 +95,7 @@ namespace BITKit.Vehicles
});
highSpeedHandle.Invoke();
}
private void Update()
public override void OnUpdate(float deltaTime)
{
var torque = maxMotorTorque *(optionalVertical.Allow ? optionalVertical.Value : vertical);
var steel =maxSteeringAngle * (optionalHorizontal.Allow ? optionalHorizontal.Value : horizontal);

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: