update
This commit is contained in:
parent
3a61f6677b
commit
936a94c84b
|
@ -4,7 +4,7 @@
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>disable</Nullable>
|
<Nullable>disable</Nullable>
|
||||||
<PackageId>BITKit</PackageId>
|
<PackageId>BITKit</PackageId>
|
||||||
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -44,6 +44,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0-preview.4.23259.5" />
|
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="8.0.0-preview.4.23259.5" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
|
||||||
|
<PackageReference Include="MySql.EntityFrameworkCore" Version="6.0.13" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.3-beta1" />
|
<PackageReference Include="Newtonsoft.Json.Bson" Version="1.0.3-beta1" />
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
|
<PackageReference Include="System.Data.SqlClient" Version="4.8.5" />
|
||||||
|
|
|
@ -57,6 +57,8 @@ namespace BITKit.IO
|
||||||
}
|
}
|
||||||
|
|
||||||
zipFile.Dispose();
|
zipFile.Dispose();
|
||||||
|
|
||||||
|
BIT4Log.Log<BITAssets>($"已创建Assets:\n{path}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static T ReadAs<T>(string path)
|
public static T ReadAs<T>(string path)
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 5ae1e7f59a6a2c64db48d78763a6dfa3
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,38 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace BITKit
|
||||||
|
{
|
||||||
|
|
||||||
|
public interface IDoubleBuffer<T>
|
||||||
|
{
|
||||||
|
T Current { get; }
|
||||||
|
void Release(T newValue);
|
||||||
|
event Action<T> OnRelease;
|
||||||
|
bool TryGetRelease(out T result);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class DoubleBuffer<T> : IDoubleBuffer<T>
|
||||||
|
{
|
||||||
|
public T Current
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
// ReSharper disable once MemberCanBePrivate.Global
|
||||||
|
protected set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Release(T newValue)
|
||||||
|
{
|
||||||
|
Current = newValue;
|
||||||
|
OnRelease?.Invoke(newValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
public event Action<T> OnRelease;
|
||||||
|
private readonly Queue<T> _releases = new();
|
||||||
|
|
||||||
|
public bool TryGetRelease(out T result)
|
||||||
|
{
|
||||||
|
return _releases.TryDequeue(out result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: aa92f9c5ddad64741a2a86086b4fc977
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 088acda9508faea49be2d9f04eb1308e
|
||||||
|
folderAsset: yes
|
||||||
|
DefaultImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -0,0 +1,8 @@
|
||||||
|
namespace BITKit
|
||||||
|
{
|
||||||
|
|
||||||
|
public interface ITextValidation
|
||||||
|
{
|
||||||
|
bool IsTextValid(string text, out string errorReason);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,11 @@
|
||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 7b3c05c0c7e840340a827ea12e285666
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
|
@ -56,6 +56,7 @@ namespace BITKit
|
||||||
public const string Internal = "Internal";
|
public const string Internal = "Internal";
|
||||||
}
|
}
|
||||||
public const string Value = "Value";
|
public const string Value = "Value";
|
||||||
|
public const string EmetyString = "";
|
||||||
public static Func<bool> True => () => true;
|
public static Func<bool> True => () => true;
|
||||||
public static Func<bool> False => () => false;
|
public static Func<bool> False => () => false;
|
||||||
public class EmetyClass { }
|
public class EmetyClass { }
|
||||||
|
|
|
@ -48,6 +48,11 @@ namespace BITKit.Animations
|
||||||
layerInfos.Add(new());
|
layerInfos.Add(new());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (index > layerInfos.Count - 1)
|
||||||
|
{
|
||||||
|
throw new Exception("Index out of range");
|
||||||
|
}
|
||||||
return layerInfos[index];
|
return layerInfos[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -107,10 +112,9 @@ namespace BITKit.Animations
|
||||||
|
|
||||||
private void Update()
|
private void Update()
|
||||||
{
|
{
|
||||||
int index = 0;
|
for (var i = 0; i < animator.layerCount; i++)
|
||||||
foreach (var x in layerInfos)
|
|
||||||
{
|
{
|
||||||
x.currentState = animator.GetCurrentAnimatorStateInfo(index++);
|
this[i].currentState = animator.GetCurrentAnimatorStateInfo(i);
|
||||||
}
|
}
|
||||||
isMatchingTarget = animator.isMatchingTarget;
|
isMatchingTarget = animator.isMatchingTarget;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,12 +4,15 @@ using UnityEngine;
|
||||||
using BITKit;
|
using BITKit;
|
||||||
namespace BITKit.Entities
|
namespace BITKit.Entities
|
||||||
{
|
{
|
||||||
public class EntityHitbox : EntityComponent
|
public class EntityHitbox : EntityComponent,IDamagable
|
||||||
{
|
{
|
||||||
public IEntity Entity => entity;
|
public IEntity Entity => entity;
|
||||||
|
|
||||||
public Rigidbody Rigidbody => m_rigidbody;
|
public Rigidbody Rigidbody => m_rigidbody;
|
||||||
|
public void GiveDamage(DamageMessage message)
|
||||||
|
{
|
||||||
|
entity.Invoke(message);
|
||||||
|
}
|
||||||
public Rigidbody m_rigidbody;
|
public Rigidbody m_rigidbody;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
"references": [
|
"references": [
|
||||||
"GUID:a209c53514018594f9f482516f2a6781",
|
"GUID:a209c53514018594f9f482516f2a6781",
|
||||||
"GUID:274d4ecae4648e94c8b2cee7218378a0",
|
"GUID:274d4ecae4648e94c8b2cee7218378a0",
|
||||||
"GUID:66d2ae14764cc7d49aad4b16930747c0",
|
|
||||||
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
"GUID:14fe60d984bf9f84eac55c6ea033a8f4",
|
||||||
"GUID:9400d40641bab5b4a9702f65bf5c6eb5"
|
"GUID:9400d40641bab5b4a9702f65bf5c6eb5",
|
||||||
|
"GUID:d525ad6bd40672747bde77962f1c401e"
|
||||||
],
|
],
|
||||||
"includePlatforms": [],
|
"includePlatforms": [],
|
||||||
"excludePlatforms": [],
|
"excludePlatforms": [],
|
||||||
|
@ -14,9 +14,7 @@
|
||||||
"overrideReferences": false,
|
"overrideReferences": false,
|
||||||
"precompiledReferences": [],
|
"precompiledReferences": [],
|
||||||
"autoReferenced": true,
|
"autoReferenced": true,
|
||||||
"defineConstraints": [
|
"defineConstraints": [],
|
||||||
"ODIN_INSPECTOR"
|
|
||||||
],
|
|
||||||
"versionDefines": [],
|
"versionDefines": [],
|
||||||
"noEngineReferences": false
|
"noEngineReferences": false
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using AYellowpaper.SerializedCollections;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using RotaryHeart.Lib.SerializableDictionary;
|
|
||||||
namespace BITKit.ObjectMaterial
|
namespace BITKit.ObjectMaterial
|
||||||
{
|
{
|
||||||
[System.Serializable]
|
[System.Serializable]
|
||||||
|
@ -16,29 +16,13 @@ namespace BITKit.ObjectMaterial
|
||||||
{
|
{
|
||||||
ObjectMaterialInfo GetObjectMaterial(string action = "None", Vector3 pos = default);
|
ObjectMaterialInfo GetObjectMaterial(string action = "None", Vector3 pos = default);
|
||||||
}
|
}
|
||||||
public class ObjectMaterialScriptableObject : BITKitSO
|
public class ObjectMaterialScriptableObject : ScriptableObject
|
||||||
{
|
{
|
||||||
|
|
||||||
[Header(Constant.Header.Settings)]
|
[Header(Constant.Header.Settings)]
|
||||||
public new string name;
|
public new string name;
|
||||||
[Header(Constant.Header.Prefabs)]
|
[Header(Constant.Header.Prefabs)]
|
||||||
public SerializableDictionaryBase<string, ObjectMaterialInfo> dictionary = new();
|
public SerializedDictionary<string, ObjectMaterialInfo> dictionary = new();
|
||||||
|
public ObjectMaterialInfo Get(string _name)=>dictionary[_name];
|
||||||
public override void RegisterAssets()
|
|
||||||
{
|
|
||||||
Data.Set<ObjectMaterialScriptableObject>(name, this);
|
|
||||||
dictionary.Values.ForEach(x =>
|
|
||||||
{
|
|
||||||
x.clips.ForEach(x =>
|
|
||||||
{
|
|
||||||
Data.Set<AudioSO>(x.name, x);
|
|
||||||
});
|
|
||||||
x.prefabs.ForEach(x=>
|
|
||||||
{
|
|
||||||
Data.Set<Transform>(x.name,x);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}
|
|
||||||
public ObjectMaterialInfo Get(string name)=>dictionary[name];
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,11 +6,11 @@ namespace BITKit
|
||||||
{
|
{
|
||||||
public static class PhysicsHelper
|
public static class PhysicsHelper
|
||||||
{
|
{
|
||||||
public static async void AddForceAtPositionAsync(this Rigidbody rigidbody, Vector3 force, Vector3 position)
|
public static async void AddForceAtPositionAsync(this Rigidbody rigidbody, Vector3 force, Vector3 position,ForceMode forceMode=ForceMode.Force)
|
||||||
{
|
{
|
||||||
await UniTask.DelayFrame(8);
|
await UniTask.DelayFrame(8);
|
||||||
if (rigidbody is not null)
|
if (rigidbody is not null)
|
||||||
rigidbody.AddForceAtPosition(force, position);
|
rigidbody.AddForceAtPosition(force, position,forceMode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -7,12 +7,16 @@ namespace BITKit
|
||||||
{
|
{
|
||||||
Rigidbody GetRigidbody();
|
Rigidbody GetRigidbody();
|
||||||
Collider GetCollider();
|
Collider GetCollider();
|
||||||
|
float AddForceMultiple { get; }
|
||||||
}
|
}
|
||||||
public class PhysicsInfo : MonoBehaviour, IPhysicsInfo
|
public class PhysicsInfo : MonoBehaviour, IPhysicsInfo
|
||||||
{
|
{
|
||||||
[SerializeField] Rigidbody mRigidbody;
|
[SerializeField] private Rigidbody mRigidbody;
|
||||||
[SerializeField] Collider mCollider;
|
[SerializeField] private Collider mCollider;
|
||||||
|
[SerializeField] private float addForcemultiple;
|
||||||
|
|
||||||
public Rigidbody GetRigidbody() => mRigidbody;
|
public Rigidbody GetRigidbody() => mRigidbody;
|
||||||
public Collider GetCollider() => mCollider;
|
public Collider GetCollider() => mCollider;
|
||||||
|
public float AddForceMultiple => addForcemultiple;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,3 +1,4 @@
|
||||||
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
@ -13,6 +14,7 @@ namespace BITKit.Sensors
|
||||||
public float radius;
|
public float radius;
|
||||||
public int fov;
|
public int fov;
|
||||||
public bool requireSight;
|
public bool requireSight;
|
||||||
|
public bool autoUpdate;
|
||||||
[Header(Constant.Header.Settings)]
|
[Header(Constant.Header.Settings)]
|
||||||
public LayerMask blockLayer;
|
public LayerMask blockLayer;
|
||||||
[Header(Constant.Header.InternalVariables)]
|
[Header(Constant.Header.InternalVariables)]
|
||||||
|
@ -25,6 +27,14 @@ namespace BITKit.Sensors
|
||||||
Vector3 dir;
|
Vector3 dir;
|
||||||
float maxDistance;
|
float maxDistance;
|
||||||
public override IEnumerable<Transform> Get() => detecteds;
|
public override IEnumerable<Transform> Get() => detecteds;
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
if (autoUpdate)
|
||||||
|
{
|
||||||
|
Execute().Forget();
|
||||||
|
}
|
||||||
|
}
|
||||||
public override UniTask Execute()
|
public override UniTask Execute()
|
||||||
{
|
{
|
||||||
if (frameUpdater)
|
if (frameUpdater)
|
||||||
|
@ -120,4 +130,7 @@ namespace BITKit.Sensors
|
||||||
return Vector3.Distance(collider.transform.position, transform.position) <= radius;
|
return Vector3.Distance(collider.transform.position, transform.position) <= radius;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if UNITY_EDITOR
|
||||||
|
|
||||||
|
#endif
|
||||||
}
|
}
|
|
@ -28,25 +28,16 @@ namespace BITKit.Sensors
|
||||||
// ReSharper disable once FieldCanBeMadeReadOnly.Local
|
// ReSharper disable once FieldCanBeMadeReadOnly.Local
|
||||||
private List<Collider> detected = new();
|
private List<Collider> detected = new();
|
||||||
|
|
||||||
private Queue<Collider> triggerEnterQueue=new();
|
private readonly Queue<Collider> triggerEnterQueue=new();
|
||||||
private Queue<Collider> triggerExitQueue=new();
|
private readonly Queue<Collider> triggerExitQueue=new();
|
||||||
|
|
||||||
|
|
||||||
private void OnTriggerEnter(Collider _collider)
|
private void OnTriggerEnter(Collider _collider)
|
||||||
{
|
{
|
||||||
triggerEnterQueue.Enqueue(_collider);
|
triggerEnterQueue.Enqueue(_collider);
|
||||||
|
|
||||||
// if (IsValid(_collider) is false) return;
|
|
||||||
// if (detected.Contains(_collider)) return;
|
|
||||||
// detected.Add(_collider);
|
|
||||||
// onDetected.Invoke(_collider);
|
|
||||||
}
|
}
|
||||||
private void OnTriggerExit(Collider _collider)
|
private void OnTriggerExit(Collider _collider)
|
||||||
{
|
{
|
||||||
triggerExitQueue.Enqueue(_collider);
|
triggerExitQueue.Enqueue(_collider);
|
||||||
// if (IsValid(_collider) is false) return;
|
|
||||||
// if (!detected.Remove(_collider)) return;
|
|
||||||
// onLost.Invoke(_collider);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnCollisionEnter(Collision collision)
|
private void OnCollisionEnter(Collision collision)
|
||||||
|
@ -102,7 +93,36 @@ namespace BITKit.Sensors
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if UNITY_EDITOR
|
#if UNITY_EDITOR
|
||||||
[CustomEditor(typeof(TriggerSensor))]
|
[CustomEditor(typeof(Sensor),true)]
|
||||||
|
public class SensorInspector:BITInspector<Sensor>
|
||||||
|
{
|
||||||
|
private VisualElement detectedContainer;
|
||||||
|
public override VisualElement CreateInspectorGUI()
|
||||||
|
{
|
||||||
|
FillDefaultInspector();
|
||||||
|
|
||||||
|
detectedContainer = root.Create<VisualElement>();
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
protected override void OnUpdate()
|
||||||
|
{
|
||||||
|
if (detectedContainer is null) return;
|
||||||
|
detectedContainer.Clear();
|
||||||
|
foreach (var x in agent.Get())
|
||||||
|
{
|
||||||
|
|
||||||
|
ObjectField objectField = new()
|
||||||
|
{
|
||||||
|
objectType = x.GetType(),
|
||||||
|
value = x,
|
||||||
|
};
|
||||||
|
objectField.SetEnabled(false);
|
||||||
|
detectedContainer.Add(objectField);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[CustomEditor(typeof(TriggerSensor),true)]
|
||||||
public class TriggerSensorInspector:BITInspector<TriggerSensor>
|
public class TriggerSensorInspector:BITInspector<TriggerSensor>
|
||||||
{
|
{
|
||||||
private VisualElement detectedContainer;
|
private VisualElement detectedContainer;
|
||||||
|
|
Loading…
Reference in New Issue