This commit is contained in:
CortexCore 2023-07-05 10:20:36 +08:00
parent 6df4649c64
commit 3a61f6677b
3 changed files with 43 additions and 4 deletions

View File

@ -73,9 +73,11 @@ namespace BITKit
{
path = null;
}
public void Execute()
{
path = path.Replace(@"/", @"\");
//path = string.IsNullOrEmpty(path) ? Environment.CurrentDirectory : path.Replace(@"/", @"\");
path = string.IsNullOrEmpty(path) ? Environment.CurrentDirectory : System.IO.Path.Combine(Environment.CurrentDirectory, path);
BIT4Log.Log<OpenPath>($"正在打开文件夹:{path}");
try
{
@ -88,6 +90,7 @@ namespace BITKit
}
}
}
[System.Serializable]
public class OpenAPP : IAction, IDisposable
{
@ -214,6 +217,7 @@ namespace BITKit
CancellationTokenSource = default;
State = InitializationState.None;
BIT4Log.Log<BITApp>($"已停止{nameof(BITApp)}");
BIT4Log.Log<BITApp>("----------------------------------------");
}
public static void Run(string path, string WorkingDirectory = "")
{

View File

@ -60,6 +60,7 @@ namespace BITKit
return true;
}
public static IEnumerable<T[]> Combinations<T>(IEnumerable<T> source)
{
if (null == source) throw new ArgumentNullException(nameof(source));
@ -81,6 +82,7 @@ namespace BITKit
_list.Insert(index, item);
return _list;
}
return self;
}
@ -91,8 +93,10 @@ namespace BITKit
{
value = self.ElementAt(0);
}
return value is not null;
}
/// <summary>
/// 组合集合中的所有元素
/// </summary>
@ -113,6 +117,7 @@ namespace BITKit
}
}
}
/// <summary>
/// 获取集合中所有的组合,每个组合中的元素个数为输入集合的元素个数,每个元素只出现一次
/// </summary>
@ -132,5 +137,34 @@ namespace BITKit
}
}
}
/// <summary>
/// Linq Distinct扩展方法,可以传入自定义比较器
/// </summary>
/// <param name="source"></param>
/// <param name="comparer"></param>
/// <typeparam name="T"></typeparam>
/// <returns></returns>
public static IEnumerable<T> Distinct<T>(
this IEnumerable<T> source, Func<T, T, bool> comparer)
where T : class
=> source.Distinct(new DynamicEqualityComparer<T>(comparer));
/// <summary>
/// 动态自定义比较器
/// </summary>
/// <typeparam name="T"></typeparam>
private sealed class DynamicEqualityComparer<T> : IEqualityComparer<T>
where T : class
{
private readonly Func<T, T, bool> _func;
public DynamicEqualityComparer(Func<T, T, bool> func)
{
_func = func;
}
public bool Equals(T x, T y) => _func(x, y);
public int GetHashCode(T obj) => 0;
}
}
}

View File

@ -19,6 +19,7 @@ namespace BITKit.Sensors
[SerializeField] private Optional<LayerMask> detectedLayer;
[SerializeField] private bool allowStatic;
[SerializeField] private bool useRigidbody;
[Header(Constant.Header.Events)] public UnityEvent<Collider> onDetected = new();
public UnityEvent<Collider> onLost = new();