mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
66 lines
1.4 KiB
C#
66 lines
1.4 KiB
C#
using System;
|
|
using Robust.Shared.Serialization;
|
|
|
|
namespace Robust.Shared.Map
|
|
{
|
|
[Serializable, NetSerializable]
|
|
public struct GridId : IEquatable<GridId>
|
|
{
|
|
/// <summary>
|
|
/// An invalid grid ID.
|
|
/// </summary>
|
|
public static readonly GridId Invalid = new GridId(0);
|
|
|
|
internal readonly int Value;
|
|
|
|
public GridId(int value)
|
|
{
|
|
Value = value;
|
|
}
|
|
|
|
public bool IsValid()
|
|
{
|
|
return Value > 0;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public bool Equals(GridId other)
|
|
{
|
|
return Value == other.Value;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override bool Equals(object obj)
|
|
{
|
|
if (ReferenceEquals(null, obj)) return false;
|
|
return obj is GridId id && Equals(id);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public override int GetHashCode()
|
|
{
|
|
return Value;
|
|
}
|
|
|
|
public static bool operator ==(GridId a, GridId b)
|
|
{
|
|
return a.Value == b.Value;
|
|
}
|
|
|
|
public static bool operator !=(GridId a, GridId b)
|
|
{
|
|
return !(a == b);
|
|
}
|
|
|
|
public static explicit operator int(GridId self)
|
|
{
|
|
return self.Value;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
return Value.ToString();
|
|
}
|
|
}
|
|
}
|