mirror of
https://github.com/Cardidi/ca2d-unity-toolkit.git
synced 2025-12-20 09:16:03 +08:00
feat: Complete Guard.IgnoreException families.
feat: Add XML documentation to some methods and classes. remove: Cleanup BootUnit for rewriting.
This commit is contained in:
parent
cffb31c1df
commit
91c24b27e8
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 682379589b9245c194f6d38b178c8a7b
|
||||
timeCreated: 1712972381
|
||||
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1fdfef18a5d440bb8214c941d439e605
|
||||
timeCreated: 1712972698
|
||||
@ -1,11 +0,0 @@
|
||||
namespace Ca2d.Toolkit.Bootable
|
||||
{
|
||||
public struct BootDescription
|
||||
{
|
||||
public readonly string Id;
|
||||
|
||||
public readonly IBootCondition Condition;
|
||||
|
||||
public readonly IBootExecutor[] Executors;
|
||||
}
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ce9da660f08484f8ccebff2aaf3a825
|
||||
timeCreated: 1713192001
|
||||
@ -1,17 +0,0 @@
|
||||
namespace Ca2d.Toolkit.Bootable
|
||||
{
|
||||
public enum BootState
|
||||
{
|
||||
Created = 0,
|
||||
|
||||
Pending = 1,
|
||||
|
||||
Prepare = 2,
|
||||
|
||||
Running = 3,
|
||||
|
||||
Exit = 4,
|
||||
|
||||
Fatal = 5
|
||||
}
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ddd6ed54d6c24afa90dbe41a9cedbe22
|
||||
timeCreated: 1713193446
|
||||
@ -1,7 +0,0 @@
|
||||
namespace Ca2d.Toolkit.Bootable
|
||||
{
|
||||
public class IBootCondition
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d711f6a53d984d4ab120859e20193edc
|
||||
timeCreated: 1713192171
|
||||
@ -1,14 +0,0 @@
|
||||
using System;
|
||||
using Cysharp.Threading.Tasks;
|
||||
|
||||
namespace Ca2d.Toolkit.Bootable
|
||||
{
|
||||
public interface IBootExecutor
|
||||
{
|
||||
public bool FatalAsExit { get; }
|
||||
|
||||
public BootState RegisteredStage { get; }
|
||||
|
||||
public Func<UniTask<bool>> Runner { get; }
|
||||
}
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5221434446d45f9904f24ab2f9f4f3d
|
||||
timeCreated: 1713193262
|
||||
75
Assets/Main/Scripts/Boxing.cs
Normal file
75
Assets/Main/Scripts/Boxing.cs
Normal file
@ -0,0 +1,75 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
|
||||
namespace Ca2d.Toolkit
|
||||
{
|
||||
/// <summary>
|
||||
/// An utility which gives a type safe boxing.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The value type which will being boxing.</typeparam>
|
||||
[Serializable]
|
||||
public class Boxing<T> where T : struct
|
||||
{
|
||||
[SerializeField] private T m_value;
|
||||
|
||||
/// <summary>
|
||||
/// Create a copy of given boxing source.
|
||||
/// </summary>
|
||||
public Boxing(Boxing<T> source)
|
||||
{
|
||||
m_value = source.Unbox;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a copy of given value.
|
||||
/// </summary>
|
||||
public Boxing(T value)
|
||||
{
|
||||
m_value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create a empty boxing.
|
||||
/// </summary>
|
||||
public Boxing()
|
||||
{}
|
||||
|
||||
/// <summary>
|
||||
/// Get a copy of boxing value.
|
||||
/// </summary>
|
||||
public T Unbox
|
||||
{
|
||||
get => m_value;
|
||||
set => m_value = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Access to the boxing value directly.
|
||||
/// </summary>
|
||||
public ref T Direct => ref m_value;
|
||||
|
||||
/// <summary>
|
||||
/// Clean this boxing container to the default value of boxing target.
|
||||
/// </summary>
|
||||
public void Empty()
|
||||
{
|
||||
m_value = default;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return m_value.ToString();
|
||||
}
|
||||
|
||||
public static implicit operator T(Boxing<T> wrapper)
|
||||
{
|
||||
return wrapper.Unbox;
|
||||
}
|
||||
|
||||
public static implicit operator Boxing<T>(T value)
|
||||
{
|
||||
return new Boxing<T>(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f6e1e1705424ac39408a10837b49e52
|
||||
timeCreated: 1713285459
|
||||
File diff suppressed because it is too large
Load Diff
@ -378,6 +378,9 @@ namespace Ca2d.Toolkit
|
||||
|
||||
public void Error(string text)
|
||||
{}
|
||||
|
||||
public void Error(Exception err)
|
||||
{}
|
||||
}
|
||||
|
||||
public static class QLog
|
||||
|
||||
25
Assets/Main/Scripts/LoseRequirementException.cs
Normal file
25
Assets/Main/Scripts/LoseRequirementException.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System;
|
||||
|
||||
namespace Ca2d.Toolkit
|
||||
{
|
||||
public class LoseRequirementException : Exception
|
||||
{
|
||||
public Type RequiredType { get; }
|
||||
|
||||
public LoseRequirementException(Type type) : base($"Required type {type?.FullName} was lost when resolving.")
|
||||
{
|
||||
RequiredType = type;
|
||||
}
|
||||
|
||||
public LoseRequirementException(Object obj) : base($"Required type {obj?.GetType().FullName} was lost when resolving.")
|
||||
{
|
||||
RequiredType = obj?.GetType();
|
||||
}
|
||||
|
||||
|
||||
public LoseRequirementException(ValueType obj) : base($"Required type {obj.GetType().FullName} was lost when resolving.")
|
||||
{
|
||||
RequiredType = obj.GetType();
|
||||
}
|
||||
}
|
||||
}
|
||||
3
Assets/Main/Scripts/LoseRequirementException.cs.meta
Normal file
3
Assets/Main/Scripts/LoseRequirementException.cs.meta
Normal file
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e6b670f1e074609bca59e1042256991
|
||||
timeCreated: 1715182584
|
||||
@ -3,6 +3,11 @@ using UnityEngine.Assertions;
|
||||
|
||||
namespace Ca2d.Toolkit
|
||||
{
|
||||
/// <summary>
|
||||
/// An utility structure which helps you to create an optional field in Unity Editor or a <see cref="Nullable"/>
|
||||
/// alternative.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type which will be optional.</typeparam>
|
||||
[Serializable]
|
||||
public struct Option<T>
|
||||
{
|
||||
|
||||
@ -1,33 +0,0 @@
|
||||
namespace Ca2d.Toolkit
|
||||
{
|
||||
public class Ref<T> where T : struct
|
||||
{
|
||||
private T m_value;
|
||||
|
||||
public Ref(T mValue)
|
||||
{
|
||||
m_value = mValue;
|
||||
}
|
||||
|
||||
public T Value
|
||||
{
|
||||
get => m_value;
|
||||
set => m_value = value;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return m_value.ToString();
|
||||
}
|
||||
|
||||
public static implicit operator T(Ref<T> wrapper)
|
||||
{
|
||||
return wrapper.Value;
|
||||
}
|
||||
|
||||
public static implicit operator Ref<T>(T value)
|
||||
{
|
||||
return new Ref<T>(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 069b06808ea54580b3e8b8862e6b9587
|
||||
timeCreated: 1712972593
|
||||
@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 16a7b38b52044b7983d66b421c2fab7c
|
||||
timeCreated: 1712972588
|
||||
@ -1,16 +1,25 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Object = UnityEngine.Object;
|
||||
|
||||
namespace Ca2d.Toolkit
|
||||
{
|
||||
/// <summary>
|
||||
/// An utility which allows you to reference an <see cref="UnityEngine.Object"/> via it's interface.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of class which you are willing to reference as.</typeparam>
|
||||
[Serializable]
|
||||
public struct UnityObjectWarp<T> where T : class
|
||||
{
|
||||
[SerializeField] private Object m_referencedObject;
|
||||
[SerializeField] private UnityEngine.Object m_referencedObject;
|
||||
|
||||
/// <summary>
|
||||
/// Is this warp reference to a valid target?
|
||||
/// </summary>
|
||||
public bool Valid => m_referencedObject is T;
|
||||
|
||||
/// <summary>
|
||||
/// Trying to get the actual object of this reference.
|
||||
/// </summary>
|
||||
public T Object => m_referencedObject as T;
|
||||
|
||||
public static implicit operator T(UnityObjectWarp<T> wrapper)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user