2023-12-24 18:18:49 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Runtime.CompilerServices;
|
|
|
|
|
using System.Runtime.InteropServices;
|
|
|
|
|
|
|
|
|
|
namespace DCFApixels.DragonECS
|
|
|
|
|
{
|
|
|
|
|
[StructLayout(LayoutKind.Sequential, Pack = 4, Size = 8)]
|
|
|
|
|
[Serializable]
|
2024-01-29 17:40:38 +08:00
|
|
|
|
public readonly struct RelEntityInfo : IEquatable<RelEntityInfo>
|
2023-12-24 18:18:49 +08:00
|
|
|
|
{
|
2024-01-29 17:40:38 +08:00
|
|
|
|
public static readonly RelEntityInfo Empty = new RelEntityInfo();
|
2023-12-24 18:18:49 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>Start vertex entity ID.</summary>
|
|
|
|
|
public readonly int start;
|
|
|
|
|
/// <summary>End vertex entity ID.</summary>
|
|
|
|
|
public readonly int end;
|
|
|
|
|
|
|
|
|
|
#region Properties
|
|
|
|
|
public bool IsEmpty
|
|
|
|
|
{
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
get => start == 0 && end == 0;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-01-29 17:40:38 +08:00
|
|
|
|
internal RelEntityInfo(int startEntity, int endEntity)
|
2023-12-24 18:18:49 +08:00
|
|
|
|
{
|
|
|
|
|
start = startEntity;
|
|
|
|
|
end = endEntity;
|
|
|
|
|
}
|
2024-01-28 02:19:49 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
public void Deconstruct(out int start, out int end)
|
|
|
|
|
{
|
|
|
|
|
start = this.start;
|
|
|
|
|
end = this.end;
|
|
|
|
|
}
|
2023-12-24 18:18:49 +08:00
|
|
|
|
|
|
|
|
|
#region operators
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-01-29 17:40:38 +08:00
|
|
|
|
public static bool operator ==(RelEntityInfo a, RelEntityInfo b) => a.start == b.start && a.end == b.end;
|
2023-12-24 18:18:49 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-01-29 17:40:38 +08:00
|
|
|
|
public static bool operator !=(RelEntityInfo a, RelEntityInfo b) => a.start != b.start || a.end != b.end;
|
2023-12-24 18:18:49 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region Other
|
2024-01-29 17:40:38 +08:00
|
|
|
|
public override bool Equals(object obj) => obj is RelEntityInfo targets && targets == this;
|
2023-12-24 18:18:49 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2024-01-29 17:40:38 +08:00
|
|
|
|
public bool Equals(RelEntityInfo other) => this == other;
|
2023-12-24 18:18:49 +08:00
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
|
|
|
public override int GetHashCode() => ~start ^ end;
|
|
|
|
|
public override string ToString() => $"arc({start} -> {end})";
|
|
|
|
|
#endregion
|
|
|
|
|
}
|
|
|
|
|
}
|