2025-03-01 16:40:40 +03:00
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace mROA.Implementation
|
|
|
|
|
{
|
|
|
|
|
#pragma warning disable CS8618, CS9264
|
|
|
|
|
public struct UniversalObjectIdentifier : IEquatable<UniversalObjectIdentifier>
|
|
|
|
|
{
|
|
|
|
|
public int ContextId;
|
|
|
|
|
public int OwnerId;
|
|
|
|
|
|
|
|
|
|
public static UniversalObjectIdentifier Null = new UniversalObjectIdentifier { ContextId = -2, OwnerId = -1 };
|
2025-03-01 19:06:18 +03:00
|
|
|
public static UniversalObjectIdentifier FromFlat(ulong flat) => new() { Flat = flat };
|
|
|
|
|
|
2025-03-01 16:40:40 +03:00
|
|
|
public override string ToString()
|
|
|
|
|
{
|
|
|
|
|
return $"{{ {nameof(ContextId)}: {ContextId}, {nameof(OwnerId)}: {OwnerId} }}";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool IsStatic => ContextId == -1;
|
2025-03-01 19:06:18 +03:00
|
|
|
|
2025-03-01 16:40:40 +03:00
|
|
|
public ulong Flat
|
|
|
|
|
{
|
2025-03-03 07:53:14 +03:00
|
|
|
get => (ulong)OwnerId << 32 | (uint)ContextId;
|
2025-03-01 16:40:40 +03:00
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
OwnerId = (int)(value >> 32);
|
|
|
|
|
ContextId = (int)(value & 0xFFFFFFFF);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Equals(UniversalObjectIdentifier other)
|
|
|
|
|
{
|
|
|
|
|
return ContextId == other.ContextId && OwnerId == other.OwnerId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override bool Equals(object? obj)
|
|
|
|
|
{
|
|
|
|
|
return obj is UniversalObjectIdentifier other && Equals(other);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int GetHashCode()
|
|
|
|
|
{
|
|
|
|
|
return HashCode.Combine(ContextId, OwnerId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|