using System;
namespace UnityEngine.Networking
{
///
/// This is used to identify networked objects across all participants of a network. It is assigned at runtime by the server when an object is spawned.
///
[Serializable]
[Obsolete("The high level API classes are deprecated and will be removed in the future.")]
public struct NetworkInstanceId : IEquatable
{
public NetworkInstanceId(uint value)
{
m_Value = value;
}
[SerializeField]
readonly uint m_Value;
///
/// Returns true if the value of the NetworkInstanceId is zero.
/// Object that have not been spawned will have a value of zero.
///
/// True if zero.
public bool IsEmpty()
{
return m_Value == 0;
}
public override int GetHashCode()
{
return (int)m_Value;
}
public override bool Equals(object obj)
{
return obj is NetworkInstanceId && Equals((NetworkInstanceId)obj);
}
public bool Equals(NetworkInstanceId other)
{
return this == other;
}
public static bool operator==(NetworkInstanceId c1, NetworkInstanceId c2)
{
return c1.m_Value == c2.m_Value;
}
public static bool operator!=(NetworkInstanceId c1, NetworkInstanceId c2)
{
return c1.m_Value != c2.m_Value;
}
///
/// Returns a string of "NetID:value".
///
/// String representation of this object.
public override string ToString()
{
return m_Value.ToString();
}
///
/// The internal value of this identifier.
///
public uint Value { get { return m_Value; } }
///
/// A static invalid NetworkInstanceId that can be used for comparisons.
/// The default value of NetworkInstanceId.Value is zero, and IsEmpty() can be used to check this. But NetworkInstanceId.Invalid is available for specifically setting and checking for invalid IDs.
///
public static NetworkInstanceId Invalid = new NetworkInstanceId(uint.MaxValue);
internal static NetworkInstanceId Zero = new NetworkInstanceId(0);
}
}