1
This commit is contained in:
@@ -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
|
||||
{
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@@ -12,4 +12,5 @@
|
||||
T Get();
|
||||
void Set(T t);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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();
|
||||
|
@@ -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))
|
||||
|
Reference in New Issue
Block a user