This commit is contained in:
CortexCore
2024-03-31 23:31:00 +08:00
parent e179d2eb53
commit b7b89ee71a
641 changed files with 31286 additions and 22134 deletions

View File

@@ -1,4 +1,6 @@
namespace BITKit
using System;
namespace BITKit
{
public interface IAwake { void OnAwake(); }
@@ -23,7 +25,11 @@
public interface IFixedUpdate { void OnFixedUpdate(float deltaTime); }
public interface ILateUpdate { void OnLateUpdate(float deltaTime); }
public interface IDestroy { void OnDestroyComponent(); }
[Serializable]
public struct EmptyAction : IAction
{
public void Execute() { }
}
public class BehaviorUpdater
{

View File

@@ -34,6 +34,15 @@ namespace BITKit
private readonly Dictionary<string, List<object>> events = new();
private readonly Dictionary<string, object> dictionary = new();
public const string defaultEventName = nameof(GenericEvent);
public void Clear()
{
_directDirection.Clear();
events.Clear();
dictionary.Clear();
}
public void AddListener<T>(Action<T> action) =>
AddListener<T>(defaultEventName, action);
public void Invoke<T>(T value) =>
@@ -182,5 +191,7 @@ namespace BITKit
{
return dictionary.TryGetValue(key, out value);
}
}
}

View File

@@ -12,4 +12,5 @@
T Get();
void Set(T t);
}
}

View File

@@ -1,5 +1,11 @@
namespace BITKit
using System;
using System.Collections.Generic;
using System.Linq;
namespace BITKit
{
public interface IReference
{
string Get();
@@ -7,6 +13,15 @@
string Replace(string value) => Get().Replace("{x}",value);
}
public static class IReferenceExtensions
{
public static string[] Cast(this IEnumerable<IReference> self)
{
return self.Select(Get).ToArray();
string Get(IReference x) => x.Value;
}
}
public interface IReference<T>
{
T Get();

View File

@@ -22,6 +22,11 @@ namespace BITKit
[CustomType(typeof(IValidHandle))]
public sealed class ValidHandle: IValidHandle
{
public override string ToString()
{
return $"Allow:{enableHandle}\nElements:{string.Join("\n",objs)}\nDisableElements:{string.Join("\n",disableObjs)}";
}
public ValidHandle() {}
public ValidHandle(Action<bool> boolDelegate)
{
@@ -36,11 +41,18 @@ namespace BITKit
public bool Allow => this;
private bool enableHandle;
private readonly List<object> objs = new List<object>();
private readonly List<object> disableObjs = new List<object>();
/// <summary>
/// ⚠Dont operate this field directly
/// </summary>
public readonly List<object> objs = new List<object>();
/// <summary>
/// ⚠Dont operate this field directly
/// </summary>
public readonly List<object> disableObjs = new List<object>();
private bool tempEnable;
private Action<bool> EventOnEnableChanged;
public void AddElement(object obj)
{
if (objs.Contains(obj))