using System.Collections; using System.Collections.Generic; using System.Reflection; using ExitGames.Client.Photon; using UnityEngine; public static class Extensions { public static Dictionary ParametersOfMethods = new Dictionary(); public static ParameterInfo[] GetCachedParemeters(this MethodInfo mo) { ParameterInfo[] value; if (!ParametersOfMethods.TryGetValue(mo, out value)) { value = mo.GetParameters(); ParametersOfMethods[mo] = value; } return value; } public static PhotonView[] GetPhotonViewsInChildren(this GameObject go) { return go.GetComponentsInChildren(true); } public static PhotonView GetPhotonView(this GameObject go) { return go.GetComponent(); } public static bool AlmostEquals(this Vector3 target, Vector3 second, float sqrMagnitudePrecision) { return (target - second).sqrMagnitude < sqrMagnitudePrecision; } public static bool AlmostEquals(this Vector2 target, Vector2 second, float sqrMagnitudePrecision) { return (target - second).sqrMagnitude < sqrMagnitudePrecision; } public static bool AlmostEquals(this Quaternion target, Quaternion second, float maxAngle) { return Quaternion.Angle(target, second) < maxAngle; } public static bool AlmostEquals(this float target, float second, float floatDiff) { return Mathf.Abs(target - second) < floatDiff; } public static void Merge(this IDictionary target, IDictionary addHash) { if (addHash == null || target.Equals(addHash)) { return; } foreach (object key in addHash.Keys) { target[key] = addHash[key]; } } public static void MergeStringKeys(this IDictionary target, IDictionary addHash) { if (addHash == null || target.Equals(addHash)) { return; } foreach (object key in addHash.Keys) { if (key is string) { target[key] = addHash[key]; } } } public static string ToStringFull(this IDictionary origin) { return SupportClass.DictionaryToString(origin, false); } public static string ToStringFull(this object[] data) { if (data == null) { return "null"; } string[] array = new string[data.Length]; for (int i = 0; i < data.Length; i++) { object obj = data[i]; array[i] = ((obj == null) ? "null" : obj.ToString()); } return string.Join(", ", array); } public static ExitGames.Client.Photon.Hashtable StripToStringKeys(this IDictionary original) { ExitGames.Client.Photon.Hashtable hashtable = new ExitGames.Client.Photon.Hashtable(); if (original != null) { foreach (object key in original.Keys) { if (key is string) { hashtable[key] = original[key]; } } } return hashtable; } public static void StripKeysWithNullValues(this IDictionary original) { object[] array = new object[original.Count]; int num = 0; foreach (object key2 in original.Keys) { array[num++] = key2; } foreach (object key in array) { if (original[key] == null) { original.Remove(key); } } } public static bool Contains(this int[] target, int nr) { if (target == null) { return false; } for (int i = 0; i < target.Length; i++) { if (target[i] == nr) { return true; } } return false; } }