Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Upgrade World v1.77.0
UpgradeWorld.dll
Decompiled a month ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Service; using SoftReferenceableAssets; using Splatform; using UnityEngine; using UpgradeWorld; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("UpgradeWorld")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a4fc1777c2821ea09437ee17e2d1c9a1b41d6f95")] [assembly: AssemblyProduct("UpgradeWorld")] [assembly: AssemblyTitle("UpgradeWorld")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace Service { public class ComponentInfo { private static Type[]? types; private static readonly Dictionary<string, HashSet<int>> PrefabComponents = new Dictionary<string, HashSet<int>>(); public static Type[] Types => types ?? (types = LoadTypes()); private static Type[] LoadTypes() { List<Assembly> list = new List<Assembly>(); list.Add(Assembly.GetAssembly(typeof(ZNetView))); list.AddRange(from p in Chainloader.PluginInfos.Values where (Object)(object)p.Instance != (Object)null select ((object)p.Instance).GetType().Assembly); List<Assembly> source = list; Assembly.GetAssembly(typeof(ZNetView)); Type baseType = typeof(MonoBehaviour); List<Type> list2 = new List<Type>(); list2.AddRange(source.SelectMany(delegate(Assembly s) { try { return s.GetTypes(); } catch (ReflectionTypeLoadException ex) { return ex.Types.Where((Type t) => t != null); } }).Where(delegate(Type t) { try { return baseType.IsAssignableFrom(t); } catch { return false; } })); return list2.ToArray(); } public static IEnumerable<KeyValuePair<int, GameObject>> HaveComponent(IEnumerable<KeyValuePair<int, GameObject>> objs, List<string[]> typeSets) { List<string[]> typeSets2 = typeSets; if (PrefabComponents.Count == 0) { foreach (KeyValuePair<int, GameObject> namedPrefab in ZNetScene.instance.m_namedPrefabs) { namedPrefab.Value.GetComponentsInChildren<MonoBehaviour>(ZNetView.m_tempComponents); foreach (MonoBehaviour tempComponent in ZNetView.m_tempComponents) { string key = ((object)tempComponent).GetType().Name.ToLowerInvariant(); if (!PrefabComponents.ContainsKey(key)) { PrefabComponents[key] = new HashSet<int>(); } PrefabComponents[key].Add(namedPrefab.Key); } } } HashSet<int> value; return objs.Where<KeyValuePair<int, GameObject>>((KeyValuePair<int, GameObject> obj) => typeSets2.Any((string[] types) => types.All((string type) => PrefabComponents.TryGetValue(type.ToLowerInvariant(), out value) && value.Contains(obj.Key)))); } } public class DataHelper { public static string GetData(ZDO zdo, string key, string type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = zdo.m_uid; int stableHashCode = StringExtensionMethods.GetStableHashCode(key); int stableHashCode2 = StringExtensionMethods.GetStableHashCode(key + "_u"); int stableHashCode3 = StringExtensionMethods.GetStableHashCode(key + "_i"); bool num = ZDOExtraData.s_vec3.ContainsKey(uid) && ZDOExtraData.s_vec3[uid].ContainsKey(stableHashCode); bool flag = ZDOExtraData.s_quats.ContainsKey(uid) && ZDOExtraData.s_quats[uid].ContainsKey(stableHashCode); bool flag2 = ZDOExtraData.s_longs.ContainsKey(uid) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode); bool flag3 = ZDOExtraData.s_strings.ContainsKey(uid) && ZDOExtraData.s_strings[uid].ContainsKey(stableHashCode); bool flag4 = ZDOExtraData.s_ints.ContainsKey(uid) && ZDOExtraData.s_ints[uid].ContainsKey(stableHashCode); bool flag5 = ZDOExtraData.s_floats.ContainsKey(uid) && ZDOExtraData.s_floats[uid].ContainsKey(stableHashCode); bool flag6 = ZDOExtraData.s_longs.ContainsKey(uid) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode2) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode3); if (num && (type == "" || type == "vector")) { return Helper.PrintVectorXZY(ZDOExtraData.s_vec3[uid][stableHashCode]) + " (vector)"; } if (flag && (type == "" || type == "quat")) { return Helper.PrintAngleYXZ(ZDOExtraData.s_quats[uid][stableHashCode]) + " (quat)"; } if (flag2 && (type == "" || type == "long")) { if (stableHashCode == ZDOVars.s_timeOfDeath) { return Helper.PrintDay(ZDOExtraData.s_longs[uid][stableHashCode]) + " (long)"; } return ZDOExtraData.s_longs[uid][stableHashCode] + " (long)"; } if (flag3 && (type == "" || type == "string")) { return ZDOExtraData.s_strings[uid][stableHashCode] + " (string)"; } if (flag4 && (type == "" || type == "int")) { return ZDOExtraData.s_ints[uid][stableHashCode] + " (int)"; } if (flag5 && (type == "" || type == "float")) { return ZDOExtraData.s_floats[uid][stableHashCode].ToString("F1") + " (float)"; } if (flag6 && (type == "" || type == "id")) { return ZDOExtraData.s_longs[uid][stableHashCode2] + "/" + ZDOExtraData.s_longs[uid][stableHashCode3] + " (id)"; } return "No data"; } public static bool SetData(ZDO zdo, string key, string data, string type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = zdo.m_uid; int stableHashCode = StringExtensionMethods.GetStableHashCode(key); int stableHashCode2 = StringExtensionMethods.GetStableHashCode(key + "_u"); bool flag = ZDOExtraData.s_vec3.ContainsKey(uid) && ZDOExtraData.s_vec3[uid].ContainsKey(stableHashCode); bool flag2 = ZDOExtraData.s_quats.ContainsKey(uid) && ZDOExtraData.s_quats[uid].ContainsKey(stableHashCode); bool flag3 = ZDOExtraData.s_longs.ContainsKey(uid) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode); bool flag4 = ZDOExtraData.s_strings.ContainsKey(uid) && ZDOExtraData.s_strings[uid].ContainsKey(stableHashCode); bool flag5 = ZDOExtraData.s_ints.ContainsKey(uid) && ZDOExtraData.s_ints[uid].ContainsKey(stableHashCode); bool flag6 = ZDOExtraData.s_floats.ContainsKey(uid) && ZDOExtraData.s_floats[uid].ContainsKey(stableHashCode); bool flag7 = ZDOExtraData.s_longs.ContainsKey(uid) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode2); if (type == "vector" || (type == "" && flag)) { zdo.Set(stableHashCode, Parse.VectorXZY(Parse.Split(data), Vector3.zero)); } else if (type == "quat" || (type == "" && flag2)) { zdo.Set(stableHashCode, Parse.AngleYXZ(data)); } else if (type == "long" || (type == "" && flag3)) { if (stableHashCode == ZDOVars.s_timeOfDeath) { zdo.Set(stableHashCode, Helper.ToTick(Parse.Long(data, 0L))); } else { zdo.Set(stableHashCode, Parse.Long(data, 0L)); } } else if (type == "string" || (type == "" && flag4)) { zdo.Set(stableHashCode, data); } else if (type == "int" || (type == "" && flag5)) { zdo.Set(stableHashCode, Parse.Int(data), false); } else if (type == "float" || (type == "" && flag6)) { zdo.Set(stableHashCode, Parse.Float(data)); } else { if (!(type == "id") && !(type == "" && flag7)) { return false; } string[] array = Parse.Split(data, '/'); int stableHashCode3 = StringExtensionMethods.GetStableHashCode(key + "_i"); zdo.Set(stableHashCode2, Parse.Long(array[0], 0L)); zdo.Set(stableHashCode3, Parse.Long(array, 1, 0L)); } return true; } public static bool HasData(ZDO zdo, string key, string data, bool includeEmpty) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = zdo.m_uid; int stableHashCode = StringExtensionMethods.GetStableHashCode(key); int stableHashCode2 = StringExtensionMethods.GetStableHashCode(key + "_u"); if (ZDOExtraData.s_vec3.ContainsKey(uid) && ZDOExtraData.s_vec3[uid].ContainsKey(stableHashCode)) { return Parse.VectorXZYRange(data, Vector3.zero).Includes(ZDOExtraData.s_vec3[uid][stableHashCode]); } if (ZDOExtraData.s_quats.ContainsKey(uid) && ZDOExtraData.s_quats[uid].ContainsKey(stableHashCode)) { return Parse.AngleYXZ(data) == ZDOExtraData.s_quats[uid][stableHashCode]; } if (ZDOExtraData.s_longs.ContainsKey(uid) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode)) { if (stableHashCode == ZDOVars.s_timeOfDeath) { return Parse.LongRange(data, 0L).Includes(Helper.ToDay(ZDOExtraData.s_longs[uid][stableHashCode])); } return Parse.LongRange(data, 0L).Includes(ZDOExtraData.s_longs[uid][stableHashCode]); } if (ZDOExtraData.s_strings.ContainsKey(uid) && ZDOExtraData.s_strings[uid].ContainsKey(stableHashCode)) { return data == ZDOExtraData.s_strings[uid][stableHashCode]; } if (ZDOExtraData.s_ints.ContainsKey(uid) && ZDOExtraData.s_ints[uid].ContainsKey(stableHashCode)) { return Parse.IntRange(data).Includes(ZDOExtraData.s_ints[uid][stableHashCode]); } if (ZDOExtraData.s_floats.ContainsKey(uid) && ZDOExtraData.s_floats[uid].ContainsKey(stableHashCode)) { return Parse.FloatRange(data).Includes(ZDOExtraData.s_floats[uid][stableHashCode]); } int stableHashCode3 = StringExtensionMethods.GetStableHashCode(key + "_i"); if (ZDOExtraData.s_longs.ContainsKey(uid) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode2) && ZDOExtraData.s_longs[uid].ContainsKey(stableHashCode3)) { return data == ZDOExtraData.s_longs[uid][stableHashCode2] + "/" + ZDOExtraData.s_longs[uid][stableHashCode3]; } return includeEmpty; } } public static class Hash { public static int Changed = StringExtensionMethods.GetStableHashCode("override_changed"); public static int OverrideItems = StringExtensionMethods.GetStableHashCode("override_items"); } public class Range<T> where T : IComparable { public T Min; public T Max; public Range(T value) { Min = value; Max = value; } public Range(T min, T max) { Min = min; Max = max; } public bool Includes(T value) { if (Min.CompareTo(value) <= 0) { return Max.CompareTo(value) >= 0; } return false; } } public class Vector3Range { public Vector3 Min; public Vector3 Max; public Vector3Range(Vector3 value) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Min = value; Max = value; } public Vector3Range(Vector3 min, Vector3 max) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Min = min; Max = max; } public bool Includes(Vector3 value) { if (((Vector3)(ref Min)).sqrMagnitude <= ((Vector3)(ref value)).sqrMagnitude) { return ((Vector3)(ref value)).sqrMagnitude <= ((Vector3)(ref Max)).sqrMagnitude; } return false; } } public static class Parse { private static readonly HashSet<string> Truthies = new HashSet<string> { "1", "true", "yes", "on" }; private static readonly HashSet<string> Falsies = new HashSet<string> { "0", "false", "no", "off" }; private static Range<string> Range(string arg) { List<string> list = arg.Split(new char[1] { '-' }).ToList(); if (list.Count > 1 && list[0] == "") { list[0] = "-" + list[1]; list.RemoveAt(1); } if (list.Count > 2 && list[1] == "") { list[1] = "-" + list[2]; list.RemoveAt(2); } if (list.Count == 1) { return new Range<string>(list[0]); } return new Range<string>(list[0], list[1]); } public static int Int(string arg, int defaultValue = 0) { if (!int.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return defaultValue; } return result; } public static int Int(string[] args, int index, int defaultValue = 0) { if (args.Length <= index) { return defaultValue; } return Int(args[index], defaultValue); } public static Range<int> IntRange(string arg, int defaultValue = 0) { Range<string> range = Range(arg); return new Range<int>(Int(range.Min, defaultValue), Int(range.Max, defaultValue)); } public static Range<int> IntRange(string[] args, int index, int defaultValue = 0) { if (args.Length <= index) { return new Range<int>(defaultValue); } return IntRange(args[index], defaultValue); } public static uint UInt(string arg, uint defaultValue = 0u) { if (!uint.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return defaultValue; } return result; } public static uint UInt(string[] args, int index, uint defaultValue = 0u) { if (args.Length <= index) { return defaultValue; } return UInt(args[index], defaultValue); } public static Range<uint> UIntRange(string arg, uint defaultValue = 0u) { Range<string> range = Range(arg); return new Range<uint>(UInt(range.Min, defaultValue), UInt(range.Max, defaultValue)); } public static Range<uint> UIntRange(string[] args, int index, uint defaultValue = 0u) { if (args.Length <= index) { return new Range<uint>(defaultValue); } return UIntRange(args[index], defaultValue); } public static long Long(string arg, long defaultValue = 0L) { if (!long.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return defaultValue; } return result; } public static long Long(string[] args, int index, long defaultValue = 0L) { if (args.Length <= index) { return defaultValue; } return Long(args[index], defaultValue); } public static Range<long> LongRange(string arg, long defaultValue = 0L) { Range<string> range = Range(arg); return new Range<long>(Long(range.Min, defaultValue), Long(range.Max, defaultValue)); } public static Range<long> LongRange(string[] args, int index, long defaultValue = 0L) { if (args.Length <= index) { return new Range<long>(defaultValue); } return LongRange(args[index], defaultValue); } public static bool TryFloat(string arg, out float value) { return float.TryParse(arg, NumberStyles.Float, CultureInfo.InvariantCulture, out value); } public static float Float(string arg, float defaultValue = 0f) { if (!TryFloat(arg, out var value)) { return defaultValue; } return value; } public static float Float(string[] args, int index, float defaultValue = 0f) { if (args.Length <= index) { return defaultValue; } return Float(args[index], defaultValue); } public static Range<float> FloatRange(string arg, float defaultValue = 0f) { Range<string> range = Range(arg); return new Range<float>(Float(range.Min, defaultValue), Float(range.Max, defaultValue)); } public static Range<float> FloatRange(string[] args, int index, float defaultValue = 0f) { if (args.Length <= index) { return new Range<float>(defaultValue); } return FloatRange(args[index], defaultValue); } public static string String(string[] args, int index, string defaultValue = "") { if (args.Length <= index) { return defaultValue; } return args[index]; } public static Quaternion AngleYXZ(string arg) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return AngleYXZ(arg, Quaternion.identity); } public static Quaternion AngleYXZ(string arg, Quaternion defaultValue) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) string[] args = Split(arg); Vector3 zero = Vector3.zero; zero.y = Float(args, 0, ((Quaternion)(ref defaultValue)).eulerAngles.y); zero.x = Float(args, 1, ((Quaternion)(ref defaultValue)).eulerAngles.x); zero.z = Float(args, 2, ((Quaternion)(ref defaultValue)).eulerAngles.z); return Quaternion.Euler(zero); } public static Vector3 VectorXZY(string[] args) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return VectorXZY(args, 0, Vector3.zero); } public static Vector3 VectorXZY(string[] args, Vector3 defaultValue) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return VectorXZY(args, 0, defaultValue); } public static Vector3 VectorXZY(string[] args, int index) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return VectorXZY(args, index, Vector3.zero); } public static Vector3 VectorXZY(string[] args, int index, Vector3 defaultValue) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; zero.x = Float(args, index, defaultValue.x); zero.y = Float(args, index + 2, defaultValue.y); zero.z = Float(args, index + 1, defaultValue.z); return zero; } public static Vector3Range VectorXZYRange(string arg, Vector3 defaultValue) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) string[] args = Split(arg); Range<float> x = FloatRange(args, 0, defaultValue.x); Range<float> y = FloatRange(args, 2, defaultValue.y); Range<float> z = FloatRange(args, 1, defaultValue.z); return ToVectorRange(x, y, z); } public static Vector3 VectorZXY(string[] args) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return VectorZXY(args, 0, Vector3.zero); } public static Vector3 VectorZXY(string[] args, Vector3 defaultValue) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return VectorZXY(args, 0, defaultValue); } public static Vector3 VectorZXY(string[] args, int index) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return VectorZXY(args, index, Vector3.zero); } public static Vector3 VectorZXY(string[] args, int index, Vector3 defaultValue) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; zero.x = Float(args, index + 1, defaultValue.x); zero.y = Float(args, index + 2, defaultValue.y); zero.z = Float(args, index, defaultValue.z); return zero; } public static Vector3Range VectorZXYRange(string arg, Vector3 defaultValue) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) string[] args = Split(arg); Range<float> x = FloatRange(args, 1, defaultValue.x); Range<float> y = FloatRange(args, 2, defaultValue.y); Range<float> z = FloatRange(args, 0, defaultValue.z); return ToVectorRange(x, y, z); } private static Vector3Range ToVectorRange(Range<float> x, Range<float> y, Range<float> z) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) Vector3 min = new Vector3(x.Min, y.Min, z.Min); Vector3 max = default(Vector3); ((Vector3)(ref max))..ctor(x.Max, y.Max, z.Max); return new Vector3Range(min, max); } public static Vector3 VectorYXZ(string[] args) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return VectorYXZ(args, 0, Vector3.zero); } public static Vector3 VectorYXZ(string[] args, Vector3 defaultValue) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) return VectorYXZ(args, 0, defaultValue); } public static Vector3 VectorYXZ(string[] args, int index) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return VectorYXZ(args, index, Vector3.zero); } public static Vector3 VectorYXZ(string[] args, int index, Vector3 defaultValue) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; zero.y = Float(args, index, defaultValue.y); zero.x = Float(args, index + 1, defaultValue.x); zero.z = Float(args, index + 2, defaultValue.z); return zero; } public static Vector3Range VectorYXZRange(string arg, Vector3 defaultValue) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) string[] args = Split(arg); Range<float> x = FloatRange(args, 1, defaultValue.x); Range<float> y = FloatRange(args, 0, defaultValue.y); Range<float> z = FloatRange(args, 2, defaultValue.z); return ToVectorRange(x, y, z); } public static Vector3 Scale(string[] args) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return Scale(args, 0); } public static Vector3 Scale(string[] args, int index) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) return SanityCheck(VectorXZY(args, index)); } private static Vector3 SanityCheck(Vector3 scale) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) if (scale.x == 0f) { scale.x = 1f; } if (scale.y == 0f) { scale.y = scale.x; } if (scale.z == 0f) { scale.z = scale.x; } return scale; } public static Vector3Range ScaleRange(string arg) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) string[] args = Split(arg); Range<float> x = FloatRange(args, 0); Range<float> y = FloatRange(args, 1); Range<float> z = FloatRange(args, 2); Vector3Range vector3Range = ToVectorRange(x, y, z); vector3Range.Min = SanityCheck(vector3Range.Min); vector3Range.Max = SanityCheck(vector3Range.Max); return vector3Range; } public static string[] Split(string arg, char separator = ',') { List<string> list = new List<string>(); list.AddRange(from s in arg.Split(new char[1] { separator }) select s.Trim() into s where s != "" select s); return list.ToArray(); } public static string[] Split(string[] args, int index, char separator) { if (args.Length > index) { return Split(args[index], separator); } return Array.Empty<string>(); } private static bool IsTruthy(string value) { return Truthies.Contains(value); } private static bool IsFalsy(string value) { return Falsies.Contains(value); } public static bool? Boolean(string arg) { if (IsTruthy(arg)) { return true; } if (IsFalsy(arg)) { return false; } return null; } public static IEnumerable<string> Flag(IEnumerable<string> parameters, string flag, out bool value) { string flag2 = flag; value = parameters.FirstOrDefault((string arg) => arg.ToLower() == flag2) != null; return parameters.Where((string arg) => arg.ToLower() != flag2); } public static bool Flag(List<string> parameters, string flag) { string flag2 = flag; string text = parameters.FirstOrDefault((string value) => value.ToLower() == flag2.ToLower()); if (text == null) { return false; } return parameters.Remove(text); } public static Vector2i Zone(string arg) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) string[] array = Split(arg).ToArray(); Vector2i result = default(Vector2i); if (array.Length != 0) { result.x = Int(array[0]); } if (array.Length > 1) { result.y = Int(array[1]); } return result; } public static Vector2 Pos(string arg) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) string[] array = Split(arg).ToArray(); Vector2 result = default(Vector2); if (array.Length != 0) { result.x = Float(array[0]); } if (array.Length > 1) { result.y = Float(array[1]); } return result; } public static HashSet<Biome> Biomes(string arg) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) HashSet<Biome> hashSet = new HashSet<Biome>(); foreach (Biome item in Split(arg).Select(Helper.GetBiome)) { hashSet.Add(item); } return hashSet; } } public class ZDOData { public ZDO Zdo; public int Prefab; public Dictionary<int, string> Strings = new Dictionary<int, string>(); public Dictionary<int, float> Floats = new Dictionary<int, float>(); public Dictionary<int, int> Ints = new Dictionary<int, int>(); public Dictionary<int, long> Longs = new Dictionary<int, long>(); public Dictionary<int, Vector3> Vecs = new Dictionary<int, Vector3>(); public Dictionary<int, Quaternion> Quats = new Dictionary<int, Quaternion>(); public Dictionary<int, byte[]> ByteArrays = new Dictionary<int, byte[]>(); public ConnectionType ConnectionType; public int ConnectionHash; public ZDOID OriginalId = ZDOID.None; public ZDOID TargetConnectionId = ZDOID.None; public ZDOData(ZDO zdo) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) Zdo = zdo; Load(zdo); } public ZDO Clone() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) ZDO val = ZDOMan.instance.CreateNewZDO(Zdo.m_position, 0); val.Persistent = Zdo.Persistent; val.Type = Zdo.Type; val.Distant = Zdo.Distant; val.m_prefab = Prefab; val.m_rotation = Zdo.m_rotation; val.SetOwnerInternal(Zdo.GetOwner()); Write(val); return val; } public ZDO Move(Vector3 pos, Quaternion rot) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) ZDO val = ZDOMan.instance.CreateNewZDO(pos, 0); val.Persistent = Zdo.Persistent; val.Type = Zdo.Type; val.Distant = Zdo.Distant; val.m_prefab = Prefab; val.m_rotation = ((Quaternion)(ref rot)).eulerAngles; val.SetOwnerInternal(Zdo.GetOwner()); Write(val); return val; } private void Write(ZDO zdo) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = zdo.m_uid; if (Floats.Count > 0) { ZDOHelper.Init<float>(ZDOExtraData.s_floats, uid); } if (Vecs.Count > 0) { ZDOHelper.Init<Vector3>(ZDOExtraData.s_vec3, uid); } if (Quats.Count > 0) { ZDOHelper.Init<Quaternion>(ZDOExtraData.s_quats, uid); } if (Ints.Count > 0) { ZDOHelper.Init<int>(ZDOExtraData.s_ints, uid); } if (Longs.Count > 0) { ZDOHelper.Init<long>(ZDOExtraData.s_longs, uid); } if (Strings.Count > 0) { ZDOHelper.Init<string>(ZDOExtraData.s_strings, uid); } if (ByteArrays.Count > 0) { ZDOHelper.Init<byte[]>(ZDOExtraData.s_byteArrays, uid); } foreach (KeyValuePair<int, float> @float in Floats) { ZDOExtraData.s_floats[uid].SetValue(@float.Key, @float.Value); } foreach (KeyValuePair<int, Vector3> vec in Vecs) { ZDOExtraData.s_vec3[uid].SetValue(vec.Key, vec.Value); } foreach (KeyValuePair<int, Quaternion> quat in Quats) { ZDOExtraData.s_quats[uid].SetValue(quat.Key, quat.Value); } foreach (KeyValuePair<int, int> @int in Ints) { ZDOExtraData.s_ints[uid].SetValue(@int.Key, @int.Value); } foreach (KeyValuePair<int, long> @long in Longs) { ZDOExtraData.s_longs[uid].SetValue(@long.Key, @long.Value); } foreach (KeyValuePair<int, string> @string in Strings) { ZDOExtraData.s_strings[uid].SetValue(@string.Key, @string.Value); } foreach (KeyValuePair<int, byte[]> byteArray in ByteArrays) { ZDOExtraData.s_byteArrays[uid].SetValue(byteArray.Key, byteArray.Value); } HandleConnection(zdo); HandleHashConnection(zdo); } private void HandleConnection(ZDO ownZdo) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Invalid comparison between Unknown and I4 //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (OriginalId == ZDOID.None) { return; } ZDOID uid = ownZdo.m_uid; if (TargetConnectionId != ZDOID.None) { ZDO zDO = ZDOMan.instance.GetZDO(TargetConnectionId); if (zDO != null) { ownZdo.SetConnection(ConnectionType, TargetConnectionId); if ((int)ConnectionType == 1) { zDO.SetConnection((ConnectionType)1, uid); } } return; } KeyValuePair<ZDOID, ZDOConnection> keyValuePair = ZDOExtraData.s_connections.FirstOrDefault((KeyValuePair<ZDOID, ZDOConnection> kvp) => kvp.Value.m_target == OriginalId); if (keyValuePair.Value != null) { ZDO zDO2 = ZDOMan.instance.GetZDO(keyValuePair.Key); if (zDO2 != null) { zDO2.SetConnection(keyValuePair.Value.m_type, uid); } } } private void HandleHashConnection(ZDO ownZdo) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Invalid comparison between Unknown and I4 //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Invalid comparison between Unknown and I4 //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Invalid comparison between Unknown and I4 //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) if (ConnectionHash == 0 || (int)ConnectionType == 0) { return; } ZDOID uid = ownZdo.m_uid; ZDOExtraData.SetConnectionData(uid, ConnectionType, ConnectionHash); ? val = ConnectionType ^ 0x10; bool flag = (ConnectionType & 0x10) == 0; ZDOID val2 = ((IEnumerable<ZDOID>)ZDOExtraData.GetAllConnectionZDOIDs((ConnectionType)val)).FirstOrDefault((Func<ZDOID, bool>)((ZDOID z) => ZDOExtraData.GetConnectionHashData(z, ConnectionType)?.m_hash == ConnectionHash)); if (val2 == ZDOID.None) { return; } ZDO zDO = ZDOMan.instance.GetZDO(val2); if (zDO != null) { if ((ConnectionType & 3) > 0) { ZDO val3 = (ZDO)(flag ? ((object)ownZdo) : ((object)zDO)); ZDOID val4 = (flag ? val2 : uid); val3.SetConnection((ConnectionType)3, val4); } if ((ConnectionType & 2) > 0) { ZDO val5 = (ZDO)(flag ? ((object)ownZdo) : ((object)zDO)); ZDOID val6 = (flag ? val2 : uid); val5.SetConnection((ConnectionType)2, val6); } if ((ConnectionType & 1) > 0) { zDO.SetConnection((ConnectionType)1, uid); ownZdo.SetConnection((ConnectionType)1, val2); } } } private void Load(ZDO zdo) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032e: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = zdo.m_uid; Prefab = zdo.m_prefab; Floats = (ZDOExtraData.s_floats.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, float>>)ZDOExtraData.s_floats[uid]).ToDictionary((KeyValuePair<int, float> kvp) => kvp.Key, (KeyValuePair<int, float> kvp) => kvp.Value) : new Dictionary<int, float>()); Ints = (ZDOExtraData.s_ints.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, int>>)ZDOExtraData.s_ints[uid]).ToDictionary((KeyValuePair<int, int> kvp) => kvp.Key, (KeyValuePair<int, int> kvp) => kvp.Value) : new Dictionary<int, int>()); Longs = (ZDOExtraData.s_longs.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, long>>)ZDOExtraData.s_longs[uid]).ToDictionary((KeyValuePair<int, long> kvp) => kvp.Key, (KeyValuePair<int, long> kvp) => kvp.Value) : new Dictionary<int, long>()); Strings = (ZDOExtraData.s_strings.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, string>>)ZDOExtraData.s_strings[uid]).ToDictionary((KeyValuePair<int, string> kvp) => kvp.Key, (KeyValuePair<int, string> kvp) => kvp.Value) : new Dictionary<int, string>()); Vecs = (ZDOExtraData.s_vec3.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, Vector3>>)ZDOExtraData.s_vec3[uid]).ToDictionary((KeyValuePair<int, Vector3> kvp) => kvp.Key, (KeyValuePair<int, Vector3> kvp) => kvp.Value) : new Dictionary<int, Vector3>()); Quats = (ZDOExtraData.s_quats.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, Quaternion>>)ZDOExtraData.s_quats[uid]).ToDictionary((KeyValuePair<int, Quaternion> kvp) => kvp.Key, (KeyValuePair<int, Quaternion> kvp) => kvp.Value) : new Dictionary<int, Quaternion>()); ByteArrays = (ZDOExtraData.s_byteArrays.ContainsKey(uid) ? ((IEnumerable<KeyValuePair<int, byte[]>>)ZDOExtraData.s_byteArrays[uid]).ToDictionary((KeyValuePair<int, byte[]> kvp) => kvp.Key, (KeyValuePair<int, byte[]> kvp) => kvp.Value) : new Dictionary<int, byte[]>()); if (ZDOExtraData.s_connectionsHashData.TryGetValue(uid, out var value)) { ConnectionType = value.m_type; ConnectionHash = value.m_hash; } OriginalId = uid; if (ZDOExtraData.s_connections.TryGetValue(uid, out var value2) && value2.m_target != ZDOID.None) { TargetConnectionId = value2.m_target; ConnectionType = value2.m_type; } } } } namespace UpgradeWorld { public abstract class BaseOperation { [CompilerGenerated] private bool <pin>P; protected int LocationProxyHash; protected int LocationHash; protected Terminal Context; public ZRpc? User; private readonly List<Vector3> Pins; protected BaseOperation(Terminal context, bool pin = false) { <pin>P = pin; LocationProxyHash = StringExtensionMethods.GetStableHashCode("LocationProxy"); LocationHash = StringExtensionMethods.GetStableHashCode("location"); Context = (Terminal)(((object)context) ?? ((object)Console.instance)); User = ServerExecution.User; Pins = new List<Vector3>(); base..ctor(); } public void Print(string value, bool addDot = true) { if (addDot && !value.EndsWith(".")) { value += "."; } Helper.Print(Context, User, value); } protected void Log(IEnumerable<string> values) { ZLog.Log((object)("\n" + string.Join("\n", values))); } protected void Print(IEnumerable<string> values, bool addDot = true) { foreach (string value in values) { Print(value, addDot); } } protected void PrintOnce(string value, bool addDot = true) { if (addDot && !value.EndsWith(".")) { value += "."; } Helper.PrintOnce(Context, User, value, 10f); } protected void AddPin(Vector3 pos) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (<pin>P) { Pins.Add(pos); } } protected void PrintPins() { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) if (!<pin>P) { return; } if (User != null) { User.Invoke(ServerExecution.RPC_Pins, new object[1] { string.Join("|", Pins.Select(Helper.PrintPin)) }); return; } List<PinData> findPins = ((Terminal)Console.instance).m_findPins; foreach (PinData item in findPins) { Minimap instance = Minimap.instance; if (instance != null) { instance.RemovePin(item); } } findPins.Clear(); foreach (Vector3 pin in Pins) { Minimap instance2 = Minimap.instance; PinData val = ((instance2 != null) ? instance2.AddPin(pin, (PinType)3, "", false, false, Player.m_localPlayer.GetPlayerID(), default(PlatformUserID)) : null); if (val != null) { findPins.Add(val); } } } } public abstract class EntityOperation : BaseOperation { private static readonly int PlayerHash = StringExtensionMethods.GetStableHashCode("Player"); private static Dictionary<int, string> HashToName = new Dictionary<int, string>(); protected EntityOperation(Terminal context, bool pin) : base(context, pin) { } protected static string S(int i) { if (i <= 1) { return ""; } return "s"; } public static string GetName(int prefab) { if (!HashToName.TryGetValue(prefab, out string value)) { return ""; } return value; } public static HashSet<int> GetPrefabs(IEnumerable<string> id, List<string[]> types) { List<string[]> types2 = types; if (id.Count() == 0) { return GetPrefabs("*", types2); } HashSet<int> hashSet = new HashSet<int>(); foreach (int item in id.SelectMany((string id) => GetPrefabs(id, types2))) { hashSet.Add(item); } return hashSet; } public static HashSet<int> GetPrefabs(string id, List<string[]> types) { string id2 = id; if (HashToName.Count == 0) { HashToName = ZNetScene.instance.m_namedPrefabs.ToDictionary((KeyValuePair<int, GameObject> kvp) => StringExtensionMethods.GetStableHashCode(((Object)kvp.Value).name), (KeyValuePair<int, GameObject> kvp) => ((Object)kvp.Value).name); } IEnumerable<KeyValuePair<int, GameObject>> source = ZNetScene.instance.m_namedPrefabs.Where((KeyValuePair<int, GameObject> kvp) => kvp.Key != PlayerHash); if (!(id2 == "*")) { source = ((!id2.Contains("*")) ? source.Where((KeyValuePair<int, GameObject> kvp) => string.Equals(((Object)kvp.Value).name, id2, StringComparison.OrdinalIgnoreCase)) : source.Where((KeyValuePair<int, GameObject> kvp) => Helper.IsIncluded(id2, ((Object)kvp.Value).name))); } if (types.Count > 0) { source = ComponentInfo.HaveComponent(source.ToArray(), types); } HashSet<int> hashSet = new HashSet<int>(); foreach (int item in source.Select((KeyValuePair<int, GameObject> kvp) => kvp.Key)) { hashSet.Add(item); } return hashSet; } public static ZDO[] GetZDOs(ZDO[] zdos, int hash) { List<ZDO> list = new List<ZDO>(); list.AddRange(zdos.Where((ZDO zdo) => hash == zdo.m_prefab)); return list.ToArray(); } public static ZDO[] GetZDOs(FiltererParameters args, HashSet<int> prefabs) { HashSet<int> prefabs2 = prefabs; IEnumerable<ZDO> zdos = ZDOMan.instance.m_objectsByID.Values.Where((ZDO zdo) => prefabs2.Contains(zdo.m_prefab)); List<ZDO> list = new List<ZDO>(); list.AddRange(FilterZdos(zdos, args)); return list.ToArray(); } public static ZDO[] GetZDOs(DataParameters args, HashSet<int> prefabs) { HashSet<int> prefabs2 = prefabs; IEnumerable<ZDO> zdos = ZDOMan.instance.m_objectsByID.Values.Where((ZDO zdo) => prefabs2.Contains(zdo.m_prefab)); List<ZDO> list = new List<ZDO>(); list.AddRange(FilterZdos(zdos, args)); return list.ToArray(); } public static ZDO[] GetZDOs(FiltererParameters args) { List<ZDO> list = new List<ZDO>(); list.AddRange(FilterZdos(ZDOMan.instance.m_objectsByID.Values, args)); return list.ToArray(); } public static ZDO[] GetZDOs(DataParameters args) { List<ZDO> list = new List<ZDO>(); list.AddRange(FilterZdos(ZDOMan.instance.m_objectsByID.Values, args)); return list.ToArray(); } public static ZDO[] GetZDOs(string id) { return GetZDOs(StringExtensionMethods.GetStableHashCode(id)); } public static ZDO[] GetZDOs(int hash) { List<ZDO> list = new List<ZDO>(); list.AddRange(ZDOMan.instance.m_objectsByID.Values.Where((ZDO zdo) => hash == zdo.m_prefab)); return list.ToArray(); } public static IEnumerable<ZDO> FilterZdos(IEnumerable<ZDO> zdos, DataParameters args) { return args.LimitZdos(args.FilterZdos(zdos, checkExcludedZones: false)); } public static IEnumerable<ZDO> FilterZdos(IEnumerable<ZDO> zdos, FiltererParameters args) { return args.LimitZdos(args.FilterZdos(zdos, checkExcludedZones: false)); } } public abstract class ExecutedEntityOperation : ExecutedOperation { protected readonly IEnumerable<string> Ids; protected readonly DataParameters Args; protected HashSet<int> Prefabs; protected ZDO[] ZdosToProcess; protected Dictionary<int, int> Counts; protected int ProcessedCount; protected int TotalCount; protected ExecutedEntityOperation(Terminal context, IEnumerable<string> ids, DataParameters args) { Ids = ids; Args = args; Prefabs = new HashSet<int>(); ZdosToProcess = Array.Empty<ZDO>(); Counts = new Dictionary<int, int>(); base..ctor(context, args.Pin); } protected override string OnInit() { Prefabs = GetPrefabsForOperation(); ZdosToProcess = EntityOperation.GetZDOs(Args, Prefabs); TotalCount = ZdosToProcess.Length; Counts = Prefabs.ToDictionary((int prefab) => prefab, (int prefab) => 0); if (TotalCount == 0) { Print(GetNoObjectsMessage()); return ""; } return GetInitMessage(); } protected override IEnumerator OnExecute(Stopwatch sw) { if (TotalCount == 0) { yield break; } int processed = 0; ZDO[] zdosToProcess = ZdosToProcess; foreach (ZDO val in zdosToProcess) { if (ProcessZDO(val)) { Counts[val.m_prefab]++; ProcessedCount++; AddPin(val.GetPosition()); } processed++; if (processed >= 10000) { processed = 0; yield return null; } } } protected override void OnEnd() { IEnumerable<string> collection = from kvp in Counts where kvp.Value > 0 select GetCountMessage(kvp.Value, kvp.Key) into msg where !string.IsNullOrEmpty(msg) select msg; List<string> list = new List<string>(); list.Add(GetProcessedMessage()); list.AddRange(collection); string[] values = list.ToArray(); if (Args.Log) { Log(values); } else { Print(values, addDot: false); } PrintPins(); } protected virtual HashSet<int> GetPrefabsForOperation() { return EntityOperation.GetPrefabs(Ids, Args.Types); } protected abstract bool ProcessZDO(ZDO zdo); protected abstract string GetNoObjectsMessage(); protected abstract string GetInitMessage(); protected abstract string GetProcessedMessage(); protected abstract string GetCountMessage(int count, int prefab); } public abstract class ExecutedOperation : BaseOperation { protected int Failed; protected ExecutedOperation(Terminal context, bool pin = false) : base(context, pin) { } public IEnumerator Execute(Stopwatch sw) { IEnumerator enumerator; try { OnStart(); enumerator = OnExecute(sw); } catch (InvalidOperationException ex) { Helper.Print(Context, User, ex.Message); OnEnd(); yield break; } yield return enumerator; PrintPins(); OnEnd(); } protected abstract IEnumerator OnExecute(Stopwatch sw); public bool Init(bool autoStart) { string text = OnInit(); if (text == "") { return false; } if (!autoStart) { text += Helper.GetStartMessage(); } Print(text); return true; } protected abstract string OnInit(); public string GetInfo() { string text = OnInit(); if (!(text != "")) { return GetType().Name; } return text; } protected virtual void OnStart() { } protected virtual void OnEnd() { } } public abstract class TimeOperation : BaseOperation { protected TimeOperation(Terminal context) : base(context) { } protected void Change(double time) { //IL_00e3: Unknown result type (might be due to invalid IL or missing references) if (time < 0.0) { Print("Error: New time would be negative."); return; } ZNet instance = ZNet.instance; long ticks = instance.GetTime().Ticks; instance.SetNetTime(time); _ = instance.GetTime().Ticks; int num = 0; int num2 = 0; Dictionary<int, int> dictionary = new Dictionary<int, int>(); IEnumerable<string> timeBasedDataNames = Settings.TimeBasedDataNames; HashSet<int> hashSet = timeBasedDataNames.Select((string par) => StringExtensionMethods.GetStableHashCode(par)).ToHashSet(); foreach (int item in hashSet) { dictionary.Add(item, 0); } foreach (ZDO value2 in ZDOMan.instance.m_objectsByID.Values) { if (!ZDOExtraData.s_longs.TryGetValue(value2.m_uid, out var value)) { continue; } bool flag = false; if (value2.m_prefab == Settings.ZoneControlHash) { num2++; foreach (int item2 in value.Keys.ToList()) { if (value[item2] != 0L) { flag = true; num++; value[item2] = (long)time; } } } foreach (int item3 in hashSet) { if (value.ContainsKey(item3) && value[item3] != 0L) { value[item3] = (long)time; dictionary[item3]++; flag = true; } } if (flag) { value2.IncreaseDataRevision(); } } if (Settings.Verbose) { Print("Updated " + num + " spawn zones in " + num2 + " of zones"); foreach (string item4 in timeBasedDataNames) { int stableHashCode = StringExtensionMethods.GetStableHashCode(item4); Print("Updated " + dictionary[stableHashCode] + " of " + item4); } } Print("Setting time to " + time.ToString("0") + "s , Day: " + EnvMan.instance.GetDay(time)); } } public abstract class ZoneOperation : ExecutedOperation { public string Operation = "BaseOperation"; protected Vector2i[] ZonesToUpgrade = Zones.GetZones(args); protected int ZoneIndex; protected int PreOperated; protected FiltererParameters Args; protected List<IZoneFilterer> Filterers; protected string InitString; private readonly Stopwatch LastSuccessTimer; protected ZoneOperation(Terminal context, FiltererParameters args) { Args = args; Filterers = new List<IZoneFilterer>(); InitString = ""; LastSuccessTimer = Stopwatch.StartNew(); base..ctor(context, args.Pin); } protected override string OnInit() { List<string> messages = new List<string>(); ZonesToUpgrade = Filterers.Aggregate(ZonesToUpgrade, (Vector2i[] zones, IZoneFilterer filterer) => filterer.FilterZones(zones, ref messages)); InitString += $" {ZonesToUpgrade.Length} zones"; if (messages.Count > 0) { InitString = InitString + ": " + Helper.JoinRows(messages); } InitString += "."; return InitString; } protected abstract bool ExecuteZone(Vector2i zone); protected override IEnumerator OnExecute(Stopwatch sw) { if (ZonesToUpgrade == null || ZonesToUpgrade.Length == 0) { yield break; } LastSuccessTimer.Restart(); while (ZoneIndex < ZonesToUpgrade.Length) { Vector2i zone = ZonesToUpgrade[ZoneIndex]; bool flag = ExecuteZone(zone); MoveToNextZone(flag); if (flag) { if (sw.ElapsedMilliseconds >= 100) { UpdateConsole(); yield return null; sw.Restart(); } } else { yield return null; sw.Restart(); } } UpdateConsole(); } private void MoveToNextZone(bool success) { if (success) { LastSuccessTimer.Restart(); ZoneIndex++; } else if (LastSuccessTimer.ElapsedMilliseconds >= 10000) { Failed++; LastSuccessTimer.Restart(); ZoneIndex++; } } private void UpdateConsole() { if (Settings.Verbose) { string text = (ZonesToUpgrade.Length + PreOperated).ToString(); string text2 = (ZoneIndex + PreOperated).ToString().PadLeft(text.Length, '0'); PrintOnce(Operation + ": " + text2 + "/" + text, addDot: false); } else { int num = Math.Min(100, (ZonesToUpgrade.Length == 0) ? 100 : ((int)Math.Floor(100.0 * (double)(ZoneIndex + PreOperated) / (double)(ZonesToUpgrade.Length + PreOperated)))); PrintOnce(Operation + ": " + num + "%", addDot: false); } } } public class ChangeTime : TimeOperation { public ChangeTime(Terminal context, double time) : base(context) { Change(ZNet.instance.GetTimeSeconds() + time); } } public class CountBiomes : BaseOperation { public CountBiomes(Terminal context, float frequency, FiltererParameters args) : base(context) { Count(frequency, args); } private void Count(float frequency, FiltererParameters args) { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) if (!args.Pos.HasValue) { return; } if (args.MaxDistance == 0f) { args.MaxDistance = Settings.WorldRadius; } Dictionary<Biome, int> dictionary = new Dictionary<Biome, int>(); float num = (0f - (float)Math.Ceiling(args.MaxDistance / frequency)) * frequency; for (float num2 = num; num2 <= args.MaxDistance; num2 += frequency) { for (float num3 = num; num3 <= args.MaxDistance; num3 += frequency) { Vector2 val = new Vector2(num2, num3); float magnitude = ((Vector2)(ref val)).magnitude; if (magnitude < args.MinDistance || magnitude > args.MaxDistance) { continue; } Biome biome = WorldGenerator.instance.GetBiome(args.Pos.Value.x + num2, args.Pos.Value.y + num3, 0.02f, false); if (args.IsBiomeValid(biome)) { if (!dictionary.ContainsKey(biome)) { dictionary[biome] = 0; } dictionary[biome]++; } } } float total = dictionary.Values.Sum(); IEnumerable<string> values = from kvp in dictionary orderby Enum.GetName(typeof(Biome), kvp.Key) select Enum.GetName(typeof(Biome), kvp.Key) + ": " + kvp.Value + "/" + total + " (" + ((float)kvp.Value / total).ToString("P2", CultureInfo.InvariantCulture) + ")"; Print(string.Join("\n", values)); } } public class Generate : ZoneOperation { private readonly bool Empty; public Generate(Terminal context, FiltererParameters args, bool empty) : base(context, args) { Operation = "Generate"; InitString = args.Print("Generate"); Filterers = FiltererFactory.Create(args); Empty = empty; } protected override bool ExecuteZone(Vector2i zone) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) ZoneSystem instance = ZoneSystem.instance; if (Empty) { instance.m_generatedZones.Add(zone); return true; } if (instance.IsZoneGenerated(zone)) { return true; } GameObject val = default(GameObject); return instance.SpawnZone(zone, (SpawnMode)2, ref val); } protected override void OnEnd() { int num = ZonesToUpgrade.Length - Failed; string text = Operation + " completed. " + num + " zones generated."; if (Failed > 0) { text = text + " " + Failed + " errors."; } Print(text); } } public class CountLocations : EntityOperation { public CountLocations(Terminal context, HashSet<string> ids, bool log, FiltererParameters args) : base(context, args.Pin) { CountPositions(ids, log, args); } private void CountPositions(HashSet<string> ids, bool log, FiltererParameters args) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) HashSet<string> ids2 = ids; ZoneSystem instance = ZoneSystem.instance; List<LocationInstance> list = (from l in args.FilterLocations(instance.m_locationInstances.Values) where ids2.Count() == 0 || ids2.Contains(l.m_location?.m_prefab.Name ?? "") select l).ToList(); int num = 0; Dictionary<string, int> dictionary = new Dictionary<string, int>(); foreach (LocationInstance item in list) { string name = item.m_location.m_prefab.Name; if (!dictionary.ContainsKey(name)) { dictionary[name] = 0; } dictionary[name]++; num++; AddPin(item.m_position); } IEnumerable<string> collection = from kvp in dictionary orderby kvp.Key select $"{kvp.Key}: {kvp.Value}"; List<string> list2 = new List<string>(); list2.Add($"Total: {num}"); list2.AddRange(collection); string[] values = list2.ToArray(); if (log) { Log(values); } else { Print(values, addDot: false); } PrintPins(); } } public class DistributeLocations : ExecutedOperation { private readonly string[] Ids = Array.Empty<string>(); public float Chance = 1f; public int Added; private int Total; public static HashSet<Vector2i> AllowedZones = new HashSet<Vector2i>(); private readonly Dictionary<string, int> Counts = new Dictionary<string, int>(); public DistributeLocations(Terminal context, HashSet<string> ids, FiltererParameters args) { //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) HashSet<string> ids2 = ids; FiltererParameters args2 = args; base..ctor(context, args2.Start); List<string> list = new List<string>(); list.AddRange(from loc in ZoneSystem.instance.m_locations.Where(Helper.IsValid) where ids2.Contains(loc.m_prefab.Name) where loc.m_enable && loc.m_quantity != 0 where (loc.m_biome & args2.BiomeMask) > 0 orderby loc.m_prioritized descending select loc.m_prefab.Name); Ids = list.ToArray(); if (Ids.Length == 0) { Print("Error: No valid location ids."); return; } Chance = args2.Chance; args2 = new FiltererParameters(args2) { TargetZones = TargetZones.All }; List<IZoneFilterer> source = FiltererFactory.Create(args2); List<string> messages = new List<string>(); HashSet<Vector2i> hashSet = new HashSet<Vector2i>(); foreach (Vector2i item in source.Aggregate(Zones.GetZones(args2), (Vector2i[] zones, IZoneFilterer filterer) => filterer.FilterZones(zones, ref messages)).Distinct()) { hashSet.Add(item); } AllowedZones = hashSet; } protected override IEnumerator OnExecute(Stopwatch sw) { if (Ids.Length == 0) { Print("No locations to generate."); yield break; } ClearNotSpawned(Ids); int counter = 0; string[] ids = Ids; foreach (string id in ids) { counter++; ZoneSystem zs = ZoneSystem.instance; ZoneLocation[] array = zs.m_locations.Where((ZoneLocation location) => Helper.IsValid(location) && location.m_prefab.Name == id).ToArray(); if (array.Length == 0) { continue; } Print("Generating locations " + id + ". This may take a while..."); int value; int before = (Counts.TryGetValue(id, out value) ? value : 0); ZoneLocation[] array2 = array; foreach (ZoneLocation location2 in array2) { yield return GenerateLocationsTimeSliced(location2, sw); } if (Chance < 1f) { zs.m_locationInstances = zs.m_locationInstances.Where((KeyValuePair<Vector2i, LocationInstance> kvp) => kvp.Value.m_placed || kvp.Value.m_location.m_prefab.Name != id || FiltererParameters.random.NextDouble() < (double)Chance).ToDictionary((KeyValuePair<Vector2i, LocationInstance> kvp) => kvp.Key, (KeyValuePair<Vector2i, LocationInstance> kvp) => kvp.Value); } foreach (KeyValuePair<Vector2i, LocationInstance> item in zs.m_locationInstances.Where((KeyValuePair<Vector2i, LocationInstance> kvp) => kvp.Value.m_location.m_prefab.Name == id && !kvp.Value.m_placed).ToList()) { AddPin(item.Value.m_position); } Total += Count(id); Added += Total - before; } if (Object.op_Implicit((Object)(object)Hud.instance)) { Hud.instance.m_loadingIndicator.SetShowProgress(false); } } private void ClearNotSpawned(string[] ids) { Counts.Clear(); foreach (string text in ids) { Counts[text] = Count(text); } ZoneSystem instance = ZoneSystem.instance; instance.m_locationInstances = instance.m_locationInstances.Where((KeyValuePair<Vector2i, LocationInstance> kvp) => kvp.Value.m_placed || !Counts.ContainsKey(kvp.Value.m_location.m_prefab.Name)).ToDictionary((KeyValuePair<Vector2i, LocationInstance> kvp) => kvp.Key, (KeyValuePair<Vector2i, LocationInstance> kvp) => kvp.Value); DummyClearNonPlacedLocations.Skip = true; instance.ClearNonPlacedLocations(); DummyClearNonPlacedLocations.Skip = false; } private int Count(string id) { string id2 = id; return ZoneSystem.instance.m_locationInstances.Count((KeyValuePair<Vector2i, LocationInstance> kvp) => kvp.Value.m_location.m_prefab.Name == id2); } protected override void OnEnd() { if (Added >= 0) { Print($"{Added} locations{LocationOperation.IdString(Ids)} added to the world (total amount in the world: {Total})."); } else { Print($"{Math.Abs(Added)} locations{LocationOperation.IdString(Ids)} removed from the world (total amount in the world: {Total})."); } } protected override string OnInit() { return "Generate locations" + LocationOperation.IdString(Ids) + "."; } private IEnumerator GenerateLocationsTimeSliced(ZoneLocation location, Stopwatch timeSliceStopwatch) { ZoneSystem zs = ZoneSystem.instance; int num = WorldGenerator.instance.GetSeed() + StringExtensionMethods.GetStableHashCode(location.m_prefab.Name); State state = Random.state; Random.InitState(num); int errorLocationInZone = 0; int errorCenterDistance = 0; int errorBiome = 0; int errorBiomeArea = 0; int errorAlt = 0; int errorForest = 0; int errorSimilar = 0; int errorNotSimilar = 0; int errorTerrainDelta = 0; int errorVegetation = 0; float maxRadius = Mathf.Max(location.m_exteriorRadius, location.m_interiorRadius); int attempts = (location.m_prioritized ? 200000 : 100000); int iterations = 0; int placed = zs.CountNrOfLocation(location); float maxRange = 10000f; if (location.m_centerFirst) { maxRange = location.m_minDistance; } if (!location.m_unique || placed <= 0) { zs.s_tempVeg.Clear(); int i = 0; Color val = default(Color); float num5 = default(float); Vector3 val2 = default(Vector3); Color val4 = default(Color); while (i < attempts && placed < location.m_quantity) { if (timeSliceStopwatch.Elapsed.TotalSeconds >= (double)zs.m_timeSlicedGenerationTimeBudget) { State insideState2 = Random.state; Random.state = state; yield return null; timeSliceStopwatch.Restart(); state = Random.state; Random.state = insideState2; } Vector2i zoneID = ZoneSystem.GetRandomZone(maxRange); if (location.m_centerFirst) { maxRange += 1f; } int num2; if (zs.m_locationInstances.ContainsKey(zoneID)) { num2 = errorLocationInZone + 1; errorLocationInZone = num2; } else if (AllowedZones.Contains(zoneID)) { Vector3 zonePos = ZoneSystem.GetZonePos(zoneID); BiomeArea biomeArea = WorldGenerator.instance.GetBiomeArea(zonePos); if ((location.m_biomeArea & biomeArea) == 0) { num2 = errorBiomeArea + 1; errorBiomeArea = num2; } else { for (int j = 0; j < 20; num2 = j + 1, j = num2) { if (timeSliceStopwatch.Elapsed.TotalSeconds >= (double)zs.m_timeSlicedGenerationTimeBudget) { State insideState2 = Random.state; Random.state = state; yield return null; timeSliceStopwatch.Restart(); state = Random.state; Random.state = insideState2; } num2 = iterations + 1; iterations = num2; Vector3 randomPointInZone = ZoneSystem.GetRandomPointInZone(zoneID, maxRadius); float magnitude = ((Vector3)(ref randomPointInZone)).magnitude; if (location.m_minDistance != 0f && magnitude < location.m_minDistance) { num2 = errorCenterDistance + 1; errorCenterDistance = num2; continue; } if (location.m_maxDistance != 0f && magnitude > location.m_maxDistance) { num2 = errorCenterDistance + 1; errorCenterDistance = num2; continue; } Biome biome = WorldGenerator.instance.GetBiome(randomPointInZone); if ((location.m_biome & biome) == 0) { num2 = errorBiome + 1; errorBiome = num2; continue; } randomPointInZone.y = WorldGenerator.instance.GetHeight(randomPointInZone.x, randomPointInZone.z, ref val); float num3 = (float)((double)randomPointInZone.y - 30.0); if (num3 < location.m_minAltitude || num3 > location.m_maxAltitude) { num2 = errorAlt + 1; errorAlt = num2; continue; } if (location.m_inForest) { float forestFactor = WorldGenerator.GetForestFactor(randomPointInZone); if (forestFactor < location.m_forestTresholdMin || forestFactor > location.m_forestTresholdMax) { num2 = errorForest + 1; errorForest = num2; continue; } } if (location.m_minDistanceFromCenter > 0f || location.m_maxDistanceFromCenter > 0f) { float num4 = Utils.LengthXZ(randomPointInZone); if ((location.m_minDistanceFromCenter > 0f && num4 < location.m_minDistanceFromCenter) || (location.m_maxDistanceFromCenter > 0f && num4 > location.m_maxDistanceFromCenter)) { continue; } } WorldGenerator.instance.GetTerrainDelta(randomPointInZone, location.m_exteriorRadius, ref num5, ref val2); if (num5 > location.m_maxTerrainDelta || num5 < location.m_minTerrainDelta) { num2 = errorTerrainDelta + 1; errorTerrainDelta = num2; continue; } if (location.m_minDistanceFromSimilar > 0f && zs.HaveLocationInRange(location.m_prefab.Name, location.m_group, randomPointInZone, location.m_minDistanceFromSimilar, false)) { num2 = errorSimilar + 1; errorSimilar = num2; continue; } if (location.m_maxDistanceFromSimilar > 0f && !zs.HaveLocationInRange(location.m_prefab.Name, location.m_groupMax, randomPointInZone, location.m_maxDistanceFromSimilar, true)) { num2 = errorNotSimilar + 1; errorNotSimilar = num2; continue; } float a = val.a; if (location.m_minimumVegetation > 0f && a <= location.m_minimumVegetation) { num2 = errorVegetation + 1; errorVegetation = num2; continue; } if (location.m_maximumVegetation >= 1f || a < location.m_maximumVegetation) { if (location.m_surroundCheckVegetation) { float num6 = 0f; for (int k = 0; k < location.m_surroundCheckLayers; k++) { float num7 = (float)(k + 1) / (float)location.m_surroundCheckLayers * location.m_surroundCheckDistance; for (int l = 0; l < 6; l++) { float num8 = (float)l / 6f * (float)Math.PI * 2f; Vector3 val3 = randomPointInZone + new Vector3(Mathf.Sin(num8) * num7, 0f, Mathf.Cos(num8) * num7); WorldGenerator.instance.GetHeight(val3.x, val3.z, ref val4); float num9 = (location.m_surroundCheckDistance - num7) / (location.m_surroundCheckDistance * 2f); num6 += val4.a * num9; } } zs.s_tempVeg.Add(num6); if (zs.s_tempVeg.Count < 10) { continue; } float num10 = zs.s_tempVeg.Max(); float num11 = zs.s_tempVeg.Average(); float num12 = num11 + (num10 - num11) * location.m_surroundBetterThanAverage; if (num6 < num12) { continue; } } zs.RegisterLocation(location, randomPointInZone, false); num2 = placed + 1; placed = num2; break; } num2 = errorVegetation + 1; errorVegetation = num2; } } } num2 = i + 1; i = num2; } if (placed < location.m_quantity) { Print($"Failed to place all {location.m_prefab.Name}, placed {placed} out of {location.m_quantity}."); if (Settings.VerboseLocations) { if (errorLocationInZone > 0) { Print("Failed " + errorLocationInZone + " times because the zone already had a location."); } if (errorCenterDistance > 0) { Print("Failed " + errorCenterDistance + " times because the location had wrong distance from the world center."); } if (errorBiome > 0) { Print("Failed " + errorBiome + " times because the biome was wrong."); } if (errorBiomeArea > 0) { Print("Failed " + errorBiomeArea + " times because the biome area was wrong."); } if (errorAlt > 0) { Print("Failed " + errorAlt + " times because the altitude was wrong."); } if (errorForest > 0) { Print("Failed " + errorForest + " times because the forest factor was wrong."); } if (errorSimilar > 0) { Print("Failed " + errorSimilar + " times because there was a similar location too close."); } if (errorNotSimilar > 0) { Print("Failed " + errorNotSimilar + " times because there was no similar location close enough."); } if (errorTerrainDelta > 0) { Print("Failed " + errorTerrainDelta + " times because the terrain delta was too high."); } if (errorVegetation > 0) { Print("Failed " + errorVegetation + " times because the vegetation factor was wrong."); } } } } Random.state = state; } } [HarmonyPatch(typeof(ZoneSystem), "ClearNonPlacedLocations")] public class DummyClearNonPlacedLocations { public static bool Skip; private static bool Prefix() { return !Skip; } } public class FixLocations : BaseOperation { private int Fixed; public FixLocations(Terminal context, FiltererParameters args) : base(context, args.Pin) { Execute(); } private void Execute() { //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) foreach (ZDO value in ZDOMan.instance.m_objectsByID.Values) { if (value.m_prefab != LocationProxyHash) { continue; } int @int = value.GetInt(ZDOVars.s_location, 0); ZoneLocation location = ZoneSystem.instance.GetLocation(@int); if (location == null || !Helper.IsValid(location)) { continue; } Vector2i zone = ZoneSystem.GetZone(value.m_position); if (!ZoneSystem.instance.m_locationInstances.ContainsKey(zone)) { ZoneSystem.instance.m_locationInstances[zone] = new LocationInstance { m_location = location, m_position = value.m_position, m_placed = true }; Fixed++; AddPin(value.m_position); if (Settings.Verbose) { Print($"Fixed location {location.m_prefabName} at {zone}"); } } } Print($"{Fixed} locations fixed."); PrintPins(); } } public class ListLocationPositions : EntityOperation { public ListLocationPositions(Terminal context, HashSet<string> ids, bool log, FiltererParameters args) : base(context, args.Pin) { ListPositions(ids, log, args); } private void ListPositions(HashSet<string> ids, bool log, FiltererParameters args) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) HashSet<string> ids2 = ids; ZoneSystem instance = ZoneSystem.instance; List<string> list = new List<string>(); foreach (LocationInstance item in (from l in args.FilterLocations(instance.m_locationInstances.Values) where ids2.Count() == 0 || ids2.Contains(l.m_location?.m_prefab.Name ?? "") select l).ToList()) { string name = item.m_location.m_prefab.Name; list.Add($"{name}: {Helper.PrintVectorXZY(item.m_position)} {WorldGenerator.instance.GetBiome(item.m_position)}"); AddPin(item.m_position); } if (log) { Log(list); } else { Print(list, addDot: false); } PrintPins(); } } public abstract class LocationOperation : ZoneOperation { protected int Operated; protected string Verb = ""; private static List<string>? ServerIds = null; private static int ServerIdsHash = 0; private static readonly Dictionary<string, Func<int, List<string>?>> Named = CreateNamed(); private static readonly List<string> Parameters; private static readonly Func<int, List<string>> AutoComplete; public LocationOperation(Terminal context, FiltererParameters args) : base(context, args) { args.TargetZones = TargetZones.Generated; Filterers = FiltererFactory.Create(args); } protected override bool ExecuteZone(Vector2i zone) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) ZoneSystem instance = ZoneSystem.instance; if (!instance.m_locationInstances.TryGetValue(zone, out var value)) { return true; } if (instance.IsZoneLoaded(zone)) { if (ExecuteLocation(zone, value)) { Operated++; } Zones.ReleaseZone(zone); return true; } Zones.PokeZone(zone); return false; } protected abstract bool ExecuteLocation(Vector2i zone, LocationInstance location); protected override void OnEnd() { string text = $"{Operation} completed. {Operated} locations {Verb}."; if (Failed > 0) { text = text + " " + Failed + " errors."; } Print(text); } protected void SpawnLocation(Vector2i zone, LocationInstance location, float clearRadius) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) ZoneSystem instance = ZoneSystem.instance; GameObject root = instance.m_zones[zone].m_root; Vector3 zonePos = ZoneSystem.GetZonePos(zone); Heightmap heightmap = Zones.GetHeightmap(root); Helper.ClearAreaForLocation(zone, location, clearRadius); float radius = ((Args.TerrainReset == 0f) ? location.m_location.m_exteriorRadius : Args.TerrainReset); ResetTerrain.Execute(location.m_position, radius); instance.m_tempSpawnedObjects.Clear(); instance.m_tempClearAreas.Clear(); instance.PlaceLocations(zone, zonePos, root.transform, heightmap, instance.m_tempClearAreas, (SpawnMode)2, instance.m_tempSpawnedObjects); foreach (GameObject tempSpawnedObject in instance.m_tempSpawnedObjects) { Object.Destroy((Object)(object)tempSpawnedObject); } instance.m_tempSpawnedObjects.Clear(); } public static HashSet<string> Ids(IEnumerable<string> ids, IEnumerable<string> ignore) { IEnumerable<string> ids2 = ids; IEnumerable<string> ignore2 = ignore; if (ids2.Count() == 0) { return new HashSet<string>(); } HashSet<string> hashSet = new HashSet<string>(); foreach (string item in from id in AllIds() where ids2.Any((string x) => Helper.IsIncluded(x, id)) && (ignore2.Count() == 0 || !ignore2.Contains(id)) select id) { hashSet.Add(item); } return hashSet; } public static List<string> AllIds() { if (ServerIds != null) { return ServerIds; } List<string> list = new List<string>(); list.AddRange((from location in ZoneSystem.instance.m_locations.Where(Helper.IsValid) select location.m_prefab.Name).Distinct()); return list; } public static void SetServerIds(string? data) { if (data == null) { ServerIds = null; ServerIdsHash = 0; return; } int stableHashCode = StringExtensionMethods.GetStableHashCode(data); if (ServerIdsHash != stableHashCode) { ServerIdsHash = stableHashCode; List<string> list = new List<string>(); list.AddRange(from s in data.Split(new char[1] { '|' }) where !string.IsNullOrEmpty(s) select s); ServerIds = list; } } public static int GetServerIdsHash() { return ServerIdsHash; } public static string IdString(IEnumerable<string> ids) { if (ids.Count() == AllIds().Count) { return ""; } if (ids.Count() == 0) { return ""; } return " " + Helper.JoinRows(ids); } public static void Register(string name) { CommandWrapper.Register(name, AutoComplete, Named); } private static Dictionary<string, Func<int, List<string>?>> CreateNamed() { Dictionary<string, Func<int, List<string>?>> autoComplete = FiltererParameters.GetAutoComplete(); autoComplete["id"] = (int index) => AllIds(); autoComplete["ignore"] = (int index) => AllIds(); return autoComplete; } static LocationOperation() { List<string> list = new List<string>(); list.AddRange(from x in FiltererParameters.Parameters.Concat(new <>z__ReadOnlyArray<string>(new string[2] { "id", "ignore" })) orderby x select x); Parameters = list; AutoComplete = (int index) => (index != 0) ? Parameters : AllIds(); } } public class RegisterLocation : BaseOperation { public RegisterLocation(Terminal context, string id, Vector3 position) : base(context) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) Register(id, position); } private void Register(string id, Vector3 position) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) int stableHashCode = StringExtensionMethods.GetStableHashCode(id); ZoneSystem instance = ZoneSystem.instance; if (!instance.m_locationsByHash.TryGetValue(stableHashCode, out var value)) { throw new InvalidOperationException("Location " + id + " not found."); } Vector2i zone = ZoneSystem.GetZone(position); int num = ZDOMan.instance.SectorToIndex(zone); List<ZDO> list = ZDOMan.instance.m_objectsBySector[num]; if (list != null) { foreach (ZDO item in list) { if (item.m_prefab == LocationProxyHash && item.GetInt(LocationHash, 0) == stableHashCode) { position = item.GetPosition(); Print("Using position " + Helper.PrintVectorXZY(position) + " of already existing location."); break; } } } instance.m_locationInstances.Remove(zone); instance.RegisterLocation(value, position, instance.IsZoneGenerated(zone)); AddPin(position); Print("Location " + id + " registered to " + Helper.PrintVectorXZY(position) + "."); Print("To actually spawn the registered locations, reset the zone or spawn them manually."); } } public class RemoveLocations : ExecutedOperation { private readonly HashSet<string> Ids; private readonly FiltererParameters Args; public RemoveLocations(Terminal context, HashSet<string> ids, FiltererParameters args) : base(context, args.Start) { Args = new FiltererParameters(args) { TargetZones = TargetZones.All }; Ids = ids; } protected override void OnStart() { if (Args.SafeZones != 0) { new PlayerBaseFilterer(Args.SafeZones).CalculateExcluded(); } } private int RemoveSpawned() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references)