This repository has been archived on 2023-09-13. You can view files and clone it, but cannot push or open issues or pull requests.
station_obscurum_unity/Assets/FishNet/Runtime/Serializing/Helping/Comparers.cs

67 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
namespace FishNet.Serializing.Helping
{
public class GeneratedComparer<T>
{
/// <summary>
/// Compare if T is default.
/// </summary>
public static Func<T, bool> IsDefault { internal get; set; }
/// <summary>
/// Compare if T is the same as T2.
/// </summary>
public static Func<T, T, bool> Compare { internal get; set; }
}
public class Comparers
{
/// <summary>
/// Returns if A equals B using EqualityCompare.
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
public static bool EqualityCompare<T>(T a, T b)
{
return EqualityComparer<T>.Default.Equals(a, b);
}
public static bool IsDefault<T>(T t)
{
return t.Equals(default(T));
}
public static bool IsEqualityCompareDefault<T>(T a)
{
return EqualityComparer<T>.Default.Equals(a, default(T));
}
}
internal class SceneComparer : IEqualityComparer<Scene>
{
public bool Equals(Scene a, Scene b)
{
if (!a.IsValid() || !b.IsValid())
return false;
if (a.handle != 0 || b.handle != 0)
return (a.handle == b.handle);
return (a.name == b.name);
}
public int GetHashCode(Scene obj)
{
return obj.GetHashCode();
}
}
}