Removed Many Things
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public struct AnimatorParameter
|
||||
{
|
||||
public AnimatorControllerParameterType type;
|
||||
public string name;
|
||||
public object value;
|
||||
public T Get<T>()
|
||||
{
|
||||
if (value is T t)
|
||||
{
|
||||
return t;
|
||||
}
|
||||
return default;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e52e54c62a56b4438b5b0bee86b296d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,7 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 91584f6fe323a064fa5759e4ef15e279
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -10,10 +10,6 @@ using UnityEditor;
|
||||
#endif
|
||||
namespace BITKit
|
||||
{
|
||||
public abstract class VisualBehaviour:MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
public abstract class MonoBehaviourSingleton<T> : MonoBehaviour
|
||||
{
|
||||
public static T Singleton { get; private set; }
|
||||
@@ -22,40 +18,4 @@ namespace BITKit
|
||||
if (this is T t) Singleton = t;
|
||||
}
|
||||
}
|
||||
public abstract class BITBehavior : MonoBehaviour
|
||||
{
|
||||
public VisualTreeAsset customTreeAsset;
|
||||
public virtual void OnAwake() { }
|
||||
public virtual void OnStart() { }
|
||||
public virtual void OnStop() { }
|
||||
public virtual void OnUpdate(float deltaTime) { }
|
||||
public virtual void OnFixedUpdate(float deltaTime) { }
|
||||
public virtual void OnLateUpdate(float deltaTime) { }
|
||||
public virtual void OnDestroyComponent() { }
|
||||
public virtual void SetActive(bool active) { }
|
||||
public virtual Transform GetTransform() => transform;
|
||||
public void Toggle()
|
||||
{
|
||||
enabled = !enabled;
|
||||
}
|
||||
public virtual string GetName()
|
||||
{
|
||||
return gameObject.name;
|
||||
}
|
||||
public virtual object GetDiagnostics()
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
public VisualElement GetVisualElement()
|
||||
{
|
||||
return customTreeAsset ? customTreeAsset.CloneTree() : null;
|
||||
}
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
[CustomEditor(typeof(VisualBehaviour),true)]
|
||||
public class VisualBehaviourInspector:BITInspector<VisualBehaviour>
|
||||
{
|
||||
|
||||
}
|
||||
#endif
|
||||
}
|
@@ -1,27 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public class DeltaTimer
|
||||
{
|
||||
public static implicit operator int(DeltaTimer timer)
|
||||
{
|
||||
return ((int)(1f / timer.deltaTime));
|
||||
}
|
||||
public static implicit operator string(DeltaTimer timer)
|
||||
{
|
||||
return ((int)timer).ToString();
|
||||
}
|
||||
float deltaTime = 0.0f;
|
||||
// Update is called once per frame
|
||||
public void Update(float unscaleDeltaTime = -1)
|
||||
{
|
||||
if (unscaleDeltaTime is -1)
|
||||
{
|
||||
unscaleDeltaTime = Time.unscaledDeltaTime;
|
||||
}
|
||||
deltaTime += (unscaleDeltaTime - deltaTime) * 0.1f;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c55a657ad15e7ee4cafd2ff052e66af1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -290,14 +290,6 @@ namespace BITKit
|
||||
}
|
||||
public static float Random(this float self) => UnityEngine.Random.Range(-self, self);
|
||||
public static int Random(this int self) => UnityEngine.Random.Range(-self, self);
|
||||
public static Location GetLocation(this Component self)
|
||||
{
|
||||
return new Location(self);
|
||||
}
|
||||
public static Location GetLocation(this GameObject self)
|
||||
{
|
||||
return new Location(self.transform);
|
||||
}
|
||||
public static T Random<T>(this IEnumerable<T> e)
|
||||
{
|
||||
return e.ElementAt(UnityEngine.Random.Range(0, e.Count()));
|
||||
|
@@ -1,66 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
namespace BITKit
|
||||
{
|
||||
public static partial class Utility
|
||||
{
|
||||
public static class Path
|
||||
{
|
||||
[RuntimeInitializeOnLoadMethod]
|
||||
static void Init()
|
||||
{
|
||||
dataPath = Application.dataPath;
|
||||
persistentDataPath = Application.persistentDataPath;
|
||||
currentDirectory = System.Environment.CurrentDirectory;
|
||||
}
|
||||
public static string dataPath { get; private set; }
|
||||
public static string persistentDataPath { get; private set; }
|
||||
public static string currentDirectory { get; private set; }
|
||||
public static string Get(params string[] nextPaths)
|
||||
{
|
||||
currentDirectory = System.Environment.CurrentDirectory;
|
||||
var path = currentDirectory;
|
||||
var filePath = System.IO.Path.Combine(currentDirectory, "Assembly-CSharp.csproj");
|
||||
if (File.Exists(filePath))
|
||||
{
|
||||
path = System.IO.Path.Combine(path, "Assets");
|
||||
}
|
||||
foreach (var nextPath in nextPaths)
|
||||
{
|
||||
path = System.IO.Path.Combine(path, nextPath);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
public static string CombinePath(params string[] nextPaths)
|
||||
{
|
||||
string path = nextPaths[0];
|
||||
for (int i = 1; i < nextPaths.Length - 1; i++)
|
||||
{
|
||||
path += "/" + nextPaths[i];
|
||||
}
|
||||
path += "/" + nextPaths.Last();
|
||||
return path;
|
||||
}
|
||||
public static IEnumerable<string> ReadAllFile(string folderPath, string filter = null)
|
||||
{
|
||||
if (Directory.Exists(folderPath))
|
||||
{
|
||||
DirectoryInfo directoryInfo = new DirectoryInfo(folderPath);
|
||||
|
||||
var files = directoryInfo.GetFiles()
|
||||
.OrderBy(x => x.LastWriteTime)
|
||||
.Select(x => x);
|
||||
if (filter.IsValid())
|
||||
{
|
||||
files = files.Where(x => x.Name.Contains(filter));
|
||||
}
|
||||
return files.Select(x => x.ToString());
|
||||
}
|
||||
return new List<string>();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a7fc93c24d63e07419cae4c9512233d7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,50 +0,0 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System;
|
||||
namespace BITKit
|
||||
{
|
||||
class PerformanceTimer
|
||||
{
|
||||
[DllImport("Kernel32.dll")]
|
||||
private static extern bool QueryPerformanceCounter(
|
||||
out long lpPerformanceCount);
|
||||
|
||||
[DllImport("Kernel32.dll")]
|
||||
private static extern bool QueryPerformanceFrequency(
|
||||
out long lpFrequency);
|
||||
|
||||
private long startTime, stopTime;
|
||||
private long freq;
|
||||
|
||||
public PerformanceTimer()
|
||||
{
|
||||
startTime = 0;
|
||||
stopTime = 0;
|
||||
|
||||
if (QueryPerformanceFrequency(out freq) == false)
|
||||
{
|
||||
throw new Exception("Timer not supported.");
|
||||
}
|
||||
}
|
||||
|
||||
public void Start()
|
||||
{
|
||||
Thread.Sleep(0);
|
||||
QueryPerformanceCounter(out startTime);
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
QueryPerformanceCounter(out stopTime);
|
||||
}
|
||||
|
||||
public double Duration
|
||||
{
|
||||
get
|
||||
{
|
||||
return (double)(stopTime - startTime) / (double)freq;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca2eb15b2f23fbe4584e20969264cf20
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,106 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Pool;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
[System.Serializable]
|
||||
public class UnityPool<T> where T : Component
|
||||
{
|
||||
[Header(Constant.Header.Settings)]
|
||||
[SerializeField] private int defaultCapacity = 16;
|
||||
[Header(Constant.Header.Prefabs)]
|
||||
[SerializeField] private T prefab;
|
||||
|
||||
[Header(Constant.Header.Gameobjects)]
|
||||
[SerializeField] private Transform root;
|
||||
public Action<T> OnGet { get; set; } = x=>x.gameObject.SetActive(true);
|
||||
public Action<T> OnReturn { get; set; } = x=>x.gameObject.SetActive(false);
|
||||
public Action<T> OnDestroy { get; set; } = x=>Object.Destroy(x.gameObject);
|
||||
public Action<T> OnSpawn { get; set; }
|
||||
private ObjectPool<T> pool=> _pool ??=
|
||||
new ObjectPool<T>
|
||||
(Spawn, OnGet, OnReturn, OnDestroy,defaultCapacity:DefaultCapacity, maxSize:DefaultCapacity);
|
||||
private ObjectPool<T> _pool;
|
||||
private readonly List<T> _list=new();
|
||||
|
||||
public T Prefab
|
||||
{
|
||||
get => prefab;
|
||||
set => prefab = value;
|
||||
}
|
||||
public Transform Root
|
||||
{
|
||||
get => root;
|
||||
set => root = value;
|
||||
}
|
||||
|
||||
public int DefaultCapacity
|
||||
{
|
||||
get => defaultCapacity;
|
||||
set => defaultCapacity = value;
|
||||
}
|
||||
public int InstanceCount => _list.Count;
|
||||
public T Get(T element = null, Transform _root = null)
|
||||
{
|
||||
if (_list.Count == defaultCapacity)
|
||||
{
|
||||
var next = _list[0];
|
||||
next.gameObject.SetActive(false);
|
||||
_list.RemoveAt(0);
|
||||
_list.Add(next);
|
||||
next.gameObject.SetActive(true);
|
||||
return next;
|
||||
}
|
||||
|
||||
if (element is not null)
|
||||
prefab = element;
|
||||
if (_root is not null)
|
||||
root = _root;
|
||||
|
||||
var instance = pool.Get();
|
||||
|
||||
_list.Add(instance);
|
||||
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void Return(T element)
|
||||
{
|
||||
try
|
||||
{
|
||||
pool.Release(element);
|
||||
}
|
||||
catch (InvalidOperationException){}
|
||||
|
||||
_list.TryRemove(element);
|
||||
}
|
||||
private T Spawn()
|
||||
{
|
||||
var newObject = Object.Instantiate(prefab, root);
|
||||
OnSpawn?.Invoke(newObject);
|
||||
return newObject;
|
||||
}
|
||||
|
||||
#region 拓展
|
||||
|
||||
private readonly ConcurrentDictionary<string, T> _dictionary=new();
|
||||
|
||||
public T GetByKey(string key)
|
||||
{
|
||||
var instance = _dictionary.GetOrAdd(key, s => Get());
|
||||
return instance;
|
||||
}
|
||||
public void RemoveByKey(string key)
|
||||
{
|
||||
_dictionary.TryRemove(key);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 60f4121fe6b03c94d844fc68b8a06288
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,45 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
/// <summary>加工系统.处理系统,加工一个数据后返回,处理一个数据后返回</summary>
|
||||
public interface IProcessor
|
||||
{
|
||||
T GetContext<T>(string key, T value);
|
||||
void AddProcessor<T>(string key, Func<T, T> func);
|
||||
void RemoveProcessor<T>(string key, Func<T, T> func);
|
||||
T GetContext<T>(T value = default);
|
||||
void AddProcessor<T>(Func<T, T> func);
|
||||
void RemoveProcessor<T>(Func<T, T> func);
|
||||
}
|
||||
public class Processor : IProcessor
|
||||
{
|
||||
public Dictionary<string, List<object>> dictionary = new();
|
||||
public T GetContext<T>(T value = default) => GetContext<T>(key, value);
|
||||
public void AddProcessor<T>(Func<T, T> func) => AddProcessor<T>(key, func);
|
||||
public void RemoveProcessor<T>(Func<T, T> func) => RemoveProcessor<T>(key, func);
|
||||
string key => nameof(Processor);
|
||||
public T GetContext<T>(string key, T value)
|
||||
{
|
||||
key = string.Empty.GetType<T>();
|
||||
dictionary.Get(key).ForEach(x =>
|
||||
{
|
||||
var func = x as Func<T, T>;
|
||||
value = func.Invoke(value);
|
||||
});
|
||||
return value;
|
||||
}
|
||||
public void AddProcessor<T>(string key, Func<T, T> func)
|
||||
{
|
||||
key = string.Empty.GetType<T>();
|
||||
dictionary.Get(key).Add(func);
|
||||
}
|
||||
public void RemoveProcessor<T>(string key, Func<T, T> func)
|
||||
{
|
||||
key = string.Empty.GetType<T>();
|
||||
dictionary.Get(key).Remove(func);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aac15ca7a68ed6d4a934496d37d34252
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,27 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
namespace BITKit
|
||||
{
|
||||
public static class ScriptableObjectHelper
|
||||
{
|
||||
public static T Get<T>() where T : ScriptableObject
|
||||
{
|
||||
string name = typeof(T).Name;
|
||||
T so = Resources.Load<T>(name);
|
||||
#if UNITY_EDITOR
|
||||
if (so is null)
|
||||
{
|
||||
so = ScriptableObject.CreateInstance<T>();
|
||||
|
||||
AssetDatabase.CreateAsset(so, $"Assets/Resources/{name}.asset");
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
#endif
|
||||
return so;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 123c3d7f70c9b7d45956e3c27492f483
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,68 +0,0 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
namespace BITKit
|
||||
{
|
||||
public static class TimeUtils
|
||||
{
|
||||
///<summary>
|
||||
///2023-02-45 15:02:45:628
|
||||
///</summary>
|
||||
public const string dateTimeFormat = "yyyy-MM-dd HH:mm:ss:fff";
|
||||
/// <summary>
|
||||
/// 带毫秒的字符转换成时间(DateTime)格式
|
||||
/// 可处理格式:[2014-10-10 10:10:10,666 或 2014-10-10 10:10:10 666 或 2014-10-10 10:10:10.666]
|
||||
/// </summary>
|
||||
/// 2022-12-30 15:39:48:795
|
||||
/// 20080501T08:30:52Z"
|
||||
/// yyyyMMddTHH:mm:ssZ
|
||||
public static DateTime GetDateTime(string dateTime)
|
||||
{
|
||||
try
|
||||
{
|
||||
return DateTime.ParseExact(dateTime, dateTimeFormat, null);
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
try
|
||||
{
|
||||
return GetDateTime_SCADA(dateTime);
|
||||
}
|
||||
catch (System.Exception)
|
||||
{
|
||||
Debug.LogWarning($"{dateTime}\n{dateTimeFormat}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public static float GetNow(DateTime now = default)
|
||||
{
|
||||
now = now == default ? DateTime.Now : now;
|
||||
float time = 0;
|
||||
time += now.Hour * 60 * 60;
|
||||
time += now.Minute * 60;
|
||||
time += now.Second;
|
||||
time += now.Millisecond * 0.001f;
|
||||
return time;
|
||||
}
|
||||
public static string GetNowString(DateTime now = default)
|
||||
{
|
||||
now = now == default ? DateTime.Now : now;
|
||||
return now.ToString(dateTimeFormat);
|
||||
}
|
||||
static DateTime GetDateTime_SCADA(this string dateTime)
|
||||
{
|
||||
string[] strArr = dateTime.Split(new char[] { '-', ' ', ':', ',', '.' });
|
||||
DateTime dt = new DateTime(int.Parse(strArr[0]),
|
||||
int.Parse(strArr[1]),
|
||||
int.Parse(strArr[2]),
|
||||
int.Parse(strArr[3]),
|
||||
int.Parse(strArr[4]),
|
||||
int.Parse(strArr[5]),
|
||||
int.Parse(strArr[6]));
|
||||
return dt;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 051a061e947b9cc4ead1f980a178e516
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -1,229 +0,0 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BITKit
|
||||
{
|
||||
[Serializable]
|
||||
public class IProviderMonoProxy : IProvider
|
||||
{
|
||||
[SerializeField] private MonoBehaviour monoBehaviour;
|
||||
private IProvider _provider=>monoBehaviour as IProvider;
|
||||
public T Get<T>() => _provider.Get<T>();
|
||||
public void Set<T>(T t) => _provider.Set<T>(t);
|
||||
}
|
||||
public abstract class Provider : MonoBehaviour, IProvider
|
||||
{
|
||||
public virtual T Get<T>()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
public abstract void Set<T>(T obj);
|
||||
}
|
||||
public abstract class Provider<T> : Provider, IProvider<T>
|
||||
{
|
||||
public abstract T Get();
|
||||
public abstract void Set(T t);
|
||||
public override void Set<Unknow>(Unknow obj)
|
||||
{
|
||||
if (obj is T t)
|
||||
{
|
||||
Set(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
public abstract class BITAction : MonoBehaviour, IAction
|
||||
{
|
||||
public abstract void Execute();
|
||||
}
|
||||
[Serializable]
|
||||
public struct FrameUpdate
|
||||
{
|
||||
public bool Allow => this;
|
||||
private float prevframe;
|
||||
private bool updatedThisFrame;
|
||||
public static implicit operator bool(FrameUpdate self)
|
||||
{
|
||||
var updatedThisFrame = BITApp.Time.DeltaTime <= self.prevframe;
|
||||
if (updatedThisFrame)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
self.prevframe = BITApp.Time.DeltaTime;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
[Serializable]
|
||||
public class CompletionRate
|
||||
{
|
||||
public IntervalUpdate resetInterval = new(1);
|
||||
public float rate;
|
||||
public int resetWhen = 64;
|
||||
private int requestCount;
|
||||
private int successCount;
|
||||
public static implicit operator float(CompletionRate cr)
|
||||
{
|
||||
return cr.rate;
|
||||
}
|
||||
public void Get()
|
||||
{
|
||||
requestCount++;
|
||||
}
|
||||
public void Release()
|
||||
{
|
||||
successCount++;
|
||||
rate = (float)successCount / (float)requestCount;
|
||||
if (requestCount > resetWhen)
|
||||
{
|
||||
requestCount = successCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
[System.Serializable]
|
||||
public class Counter
|
||||
{
|
||||
public int count;
|
||||
int currentCount;
|
||||
public IntervalUpdate updater = new(1);
|
||||
public static implicit operator int(Counter self) => self.Get();
|
||||
public int Excute()
|
||||
{
|
||||
if (updater.AllowUpdate)
|
||||
{
|
||||
count = currentCount;
|
||||
currentCount = 0;
|
||||
}
|
||||
currentCount++;
|
||||
return count;
|
||||
}
|
||||
public int Get() => currentCount;
|
||||
}
|
||||
|
||||
public struct Location
|
||||
{
|
||||
|
||||
public Location(Transform transform, bool local = false)
|
||||
{
|
||||
if (local)
|
||||
{
|
||||
position = transform.localPosition;
|
||||
rotation = transform.localRotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
position = transform.position;
|
||||
rotation = transform.rotation;
|
||||
}
|
||||
|
||||
forward = transform.forward;
|
||||
}
|
||||
public Location(Component component)
|
||||
{
|
||||
var transform = component.transform;
|
||||
position = transform.position;
|
||||
rotation = transform.rotation;
|
||||
forward = transform.forward;
|
||||
}
|
||||
public Vector3 position;
|
||||
public Vector3 forward;
|
||||
public Quaternion rotation;
|
||||
|
||||
public Location(Vector3 position, Quaternion rotation)
|
||||
{
|
||||
this.position = position;
|
||||
this.rotation = rotation;
|
||||
this.forward = rotation * Vector3.forward;
|
||||
}
|
||||
|
||||
public Location Set(Vector3 value)
|
||||
{
|
||||
position = value;
|
||||
return this;
|
||||
}
|
||||
public Location Set(Quaternion value)
|
||||
{
|
||||
rotation = value;
|
||||
return this;
|
||||
}
|
||||
public Location Set(Transform value, bool isLocal)
|
||||
{
|
||||
if (isLocal)
|
||||
{
|
||||
position = value.localPosition; rotation = value.localRotation;
|
||||
}
|
||||
else
|
||||
{
|
||||
Set(value);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
public Location Set(Transform value)
|
||||
{
|
||||
position = value.position; rotation = value.rotation;
|
||||
return this;
|
||||
}
|
||||
public static Location Lerp(Location a, Location b, float t)
|
||||
{
|
||||
if (Quaternion.Dot(a, a) < Quaternion.kEpsilon)
|
||||
a.rotation = Quaternion.identity;
|
||||
if (Quaternion.Dot(b, b) < Quaternion.kEpsilon)
|
||||
b.rotation = Quaternion.identity;
|
||||
return new()
|
||||
{
|
||||
position = Vector3.Lerp(a.position, b.position, t),
|
||||
rotation = Quaternion.Lerp(a.rotation, b.rotation, t)
|
||||
};
|
||||
}
|
||||
public static implicit operator Vector3(Location self)
|
||||
{
|
||||
return self.position;
|
||||
}
|
||||
public static implicit operator Quaternion(Location self)
|
||||
{
|
||||
return self.rotation;
|
||||
}
|
||||
public static Location operator +(Location self, Location b)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
position = self.position + b.position,
|
||||
rotation = Quaternion.Euler(self.rotation.eulerAngles + b.rotation.eulerAngles),
|
||||
};
|
||||
}
|
||||
public static Location operator -(Location self, Location b)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
position = self.position - b.position,
|
||||
rotation = Quaternion.Euler(self.rotation.eulerAngles - b.rotation.eulerAngles),
|
||||
};
|
||||
}
|
||||
public static Location operator *(Location self, float weight)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
position = self.position * weight,
|
||||
rotation = Quaternion.Euler(self.rotation.eulerAngles * weight),
|
||||
};
|
||||
}
|
||||
public static Location operator /(Location self, float weight)
|
||||
{
|
||||
return new()
|
||||
{
|
||||
position = self.position / weight,
|
||||
rotation = Quaternion.Euler(self.rotation.eulerAngles / weight),
|
||||
};
|
||||
}
|
||||
public bool isNull
|
||||
{
|
||||
get
|
||||
{
|
||||
return position == Vector3.zero && rotation == Quaternion.identity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0ff33afa68f3cf245b857fff4b6b42cd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user