Update EntityManager and Archetype
This commit is contained in:
@@ -106,6 +106,29 @@ public readonly struct Identifier<T>
|
||||
{
|
||||
return !a.Equals(b);
|
||||
}
|
||||
|
||||
public static bool operator <(Identifier<T> a, Identifier<T> b)
|
||||
{
|
||||
return a.value < b.value;
|
||||
}
|
||||
|
||||
public static bool operator >(Identifier<T> a, Identifier<T> b)
|
||||
{
|
||||
return a.value > b.value;
|
||||
}
|
||||
|
||||
public static bool operator <=(Identifier<T> a, Identifier<T> b)
|
||||
{
|
||||
return a.value <= b.value;
|
||||
}
|
||||
|
||||
public static bool operator >=(Identifier<T> a, Identifier<T> b)
|
||||
{
|
||||
return a.value >= b.value;
|
||||
}
|
||||
|
||||
public static implicit operator int(Identifier<T> id) => id.value;
|
||||
public static implicit operator Identifier<T>(int value) => new Identifier<T>(value);
|
||||
}
|
||||
|
||||
public readonly struct Key<T>
|
||||
|
||||
@@ -152,6 +152,14 @@ public readonly ref struct RefResult<T, S>
|
||||
|
||||
public static class ResultExtensions
|
||||
{
|
||||
public static void ThrowIfFailed(this ResultStatus result)
|
||||
{
|
||||
if (result != ResultStatus.Success)
|
||||
{
|
||||
throw new InvalidOperationException($"Operation failed: {result}");
|
||||
}
|
||||
}
|
||||
|
||||
public static void ThrowIfFailed(this Result result)
|
||||
{
|
||||
if (!result.IsSuccess)
|
||||
@@ -170,11 +178,6 @@ public static class ResultExtensions
|
||||
return result.Value;
|
||||
}
|
||||
|
||||
public static T? GetValueOrDefault<T>(this Result<T> result, T? defaultValue = default)
|
||||
{
|
||||
return result.IsSuccess ? result.Value : defaultValue;
|
||||
}
|
||||
|
||||
public static T GetValueOrThrow<T, S>(this Result<T, S> result, S expect)
|
||||
where S : Enum
|
||||
{
|
||||
@@ -186,12 +189,29 @@ public static class ResultExtensions
|
||||
return result.Value;
|
||||
}
|
||||
|
||||
public static T? GetValueOrDefault<T>(this Result<T> result, T? defaultValue = default)
|
||||
{
|
||||
return result.IsSuccess ? result.Value : defaultValue;
|
||||
}
|
||||
|
||||
public static T? GetValueOrDefault<T, S>(this Result<T, S> result, S expect, T? defaultValue = default)
|
||||
where S : Enum
|
||||
{
|
||||
return (result.Status?.Equals(expect) ?? false) ? defaultValue : result.Value;
|
||||
}
|
||||
|
||||
public static bool TryGetValue<T>(this Result<T> result, out T value)
|
||||
{
|
||||
if (result.IsSuccess)
|
||||
{
|
||||
value = result.Value;
|
||||
return true;
|
||||
}
|
||||
|
||||
value = default!;
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Result OnSuccess(this Result result, Action action)
|
||||
{
|
||||
if (result.IsSuccess)
|
||||
|
||||
Reference in New Issue
Block a user