using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Data; using ExpandWorld.Prefab; using HarmonyLib; using Microsoft.CodeAnalysis; using Service; using Splatform; using Steamworks; using UnityEngine; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; [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("ExpandWorldPrefabs")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+5cc015314cdd6ddb845ea86b7492fc2b2160673b")] [assembly: AssemblyProduct("ExpandWorldPrefabs")] [assembly: AssemblyTitle("ExpandWorldPrefabs")] [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 Data { public class Calculator { public static Vector3 EvaluateVector3(string expression) { //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_0061: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; string[] array = Parse.Split(expression); zero.x = EvaluateFloat(array[0]).GetValueOrDefault(); if (array.Length > 1) { zero.z = EvaluateFloat(array[1]).GetValueOrDefault(); } if (array.Length > 2) { zero.y = EvaluateFloat(array[2]).GetValueOrDefault(); } return zero; } public static Vector3 EvaluateVector3(string[] s, int index) { //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_0065: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; if (s.Length > index) { zero.x = EvaluateFloat(s[index]).GetValueOrDefault(); } if (s.Length > index + 1) { zero.z = EvaluateFloat(s[index + 1]).GetValueOrDefault(); } if (s.Length > index + 2) { zero.y = EvaluateFloat(s[index + 2]).GetValueOrDefault(); } return zero; } public static Quaternion EvaluateQuaternion(string expression) { //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_0061: 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) Vector3 zero = Vector3.zero; string[] array = Parse.Split(expression); zero.y = EvaluateFloat(array[0]).GetValueOrDefault(); if (array.Length > 1) { zero.x = EvaluateFloat(array[1]).GetValueOrDefault(); } if (array.Length > 2) { zero.z = EvaluateFloat(array[2]).GetValueOrDefault(); } return Quaternion.Euler(zero); } public static Quaternion EvaluateQuaternion(string[] s, int index) { //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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) Vector3 zero = Vector3.zero; if (s.Length > index) { zero.y = EvaluateFloat(s[index]).GetValueOrDefault(); } if (s.Length > index + 1) { zero.x = EvaluateFloat(s[index + 1]).GetValueOrDefault(); } if (s.Length > index + 2) { zero.z = EvaluateFloat(s[index + 2]).GetValueOrDefault(); } return Quaternion.Euler(zero); } public static int? EvaluateInt(string expression) { try { return (int?)EvaluateLong(expression); } catch { return null; } } public static float? EvaluateFloat(string expression) { try { return (float)EvaluateDouble(expression); } catch { return null; } } private static double EvaluateDouble(string expression) { string[] array = expression.Split(new char[1] { '+' }); if (array.Length > 1) { double num = 0.0; string[] array2 = array; foreach (string expression2 in array2) { num += EvaluateDouble(expression2); } return num; } string[] array3 = expression.Split(new char[1] { '-' }); if (array3.Where((string s) => s != "").Count() > 1) { double? num2 = null; for (int j = 0; j < array3.Length; j++) { if (!(array3[j] == "") || j + 1 >= array3.Length) { num2 = (num2.HasValue ? (num2 - EvaluateDouble(array3[j])) : new double?(EvaluateDouble(array3[j]))); } else { array3[j + 1] = "-" + array3[j + 1]; } } return num2.GetValueOrDefault(); } string[] array4 = expression.Split(new char[1] { '*' }); if (array4.Length > 1) { double num3 = 1.0; string[] array2 = array4; foreach (string expression3 in array2) { num3 *= EvaluateDouble(expression3); } return num3; } string[] array5 = expression.Split(new char[1] { '/' }); if (array5.Length > 1) { double num4 = EvaluateDouble(array5[0]); for (int k = 1; k < array5.Length; k++) { num4 /= EvaluateDouble(array5[k]); } return num4; } try { return double.Parse(expression.Trim(), NumberFormatInfo.InvariantInfo); } catch { throw new InvalidOperationException("Failed to parse expression: " + expression); } } public static long? EvaluateLong(string expression) { try { return EvalLong(expression); } catch { return null; } } private static long EvalLong(string expression) { string[] array = expression.Split(new char[1] { '+' }); if (array.Length > 1) { long num = 0L; string[] array2 = array; foreach (string expression2 in array2) { num += EvalLong(expression2); } return num; } string[] array3 = expression.Split(new char[1] { '-' }); if (array3.Where((string s) => s != "").Count() > 1) { long? num2 = null; for (int j = 0; j < array3.Length; j++) { if (!(array3[j] == "") || j + 1 >= array3.Length) { num2 = (num2.HasValue ? (num2 - EvalLong(array3[j])) : new long?(EvalLong(array3[j]))); } else { array3[j + 1] = "-" + array3[j + 1]; } } return num2.GetValueOrDefault(); } string[] array4 = expression.Split(new char[1] { '*' }); if (array4.Length > 1) { long num3 = 1L; string[] array2 = array4; foreach (string expression3 in array2) { num3 *= EvalLong(expression3); } return num3; } string[] array5 = expression.Split(new char[1] { '/' }); if (array5.Length > 1) { long num4 = EvalLong(array5[0]); for (int k = 1; k < array5.Length; k++) { num4 /= EvalLong(array5[k]); } return num4; } try { return long.Parse(expression.Trim()); } catch { throw new InvalidOperationException("Failed to parse expression: " + expression); } } } public class DataData { [DefaultValue(null)] public string? name; [DefaultValue(null)] public string? position; [DefaultValue(null)] public string? rotation; [DefaultValue(null)] public string? connection; [DefaultValue(null)] public string[]? bools; [DefaultValue(null)] public string[]? ints; [DefaultValue(null)] public string[]? hashes; [DefaultValue(null)] public string[]? floats; [DefaultValue(null)] public string[]? strings; [DefaultValue(null)] public string[]? longs; [DefaultValue(null)] public string[]? vecs; [DefaultValue(null)] public string[]? quats; [DefaultValue(null)] public string[]? bytes; [DefaultValue(null)] public ItemData[]? items; [DefaultValue(null)] public string? containerSize; [DefaultValue(null)] public string? itemAmount; [DefaultValue(null)] public string? valueGroup; [DefaultValue(null)] public string? value; [DefaultValue(null)] public string[]? values; [DefaultValue(null)] public string? persistent; [DefaultValue(null)] public string? distant; [DefaultValue(null)] public string? priority; } public class ItemData { public string pos = ""; [DefaultValue(1f)] public float chance = 1f; [DefaultValue("")] public string prefab = ""; public string? stack; public string? quality; public string? variant; public string? durability; public string? crafterID; public string? crafterName; public string? worldLevel; public string? equipped; public string? pickedUp; public Dictionary? customData; } public class DataEntry { public bool InjectDataByDefault; public Dictionary? Strings; public Dictionary? Floats; public Dictionary? Ints; public Dictionary? Components; public Dictionary? Bools; public Dictionary? Hashes; public Dictionary? Longs; public Dictionary? Vecs; public Dictionary? Quats; public Dictionary? ByteArrays; public List? Items; public Vector2i? ContainerSize; public IIntValue? ItemAmount; public ConnectionType? ConnectionType; public int ConnectionHash; public IZdoIdValue? OriginalId; public IZdoIdValue? TargetConnectionId; public IBoolValue? Persistent; public IBoolValue? Distant; public ObjectType? Priority; public IVector3Value? Position; public IQuaternionValue? Rotation; public static HashSet SupportedTypes = new HashSet { "float", "int", "bool", "hash", "long", "string", "vec", "vec3", "quat", "bytes" }; public DataEntry() { } public DataEntry(string[] tkv) { InjectDataByDefault = true; Load(tkv); } public DataEntry(DataData data) { Load(data); } public DataEntry(ZDO zdo) { Load(zdo); } public DataEntry(ZPackage pkg) { Load(pkg); } public 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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_0149: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: 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_0300: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0310: 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_032f: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = zdo.m_uid; Floats = (ZDOExtraData.s_floats.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_floats[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => DataValue.Simple(kvp.Value)) : null); Ints = (ZDOExtraData.s_ints.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_ints[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => DataValue.Simple(kvp.Value)) : null); Longs = (ZDOExtraData.s_longs.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_longs[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => DataValue.Simple(kvp.Value)) : null); Strings = (ZDOExtraData.s_strings.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_strings[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => DataValue.Simple(kvp.Value)) : null); Vecs = (ZDOExtraData.s_vec3.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_vec3[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => DataValue.Simple(kvp.Value)) : null); Quats = (ZDOExtraData.s_quats.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_quats[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => DataValue.Simple(kvp.Value)) : null); ByteArrays = (ZDOExtraData.s_byteArrays.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_byteArrays[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => DataValue.Simple(kvp.Value)) : null); if (ZDOExtraData.s_connectionsHashData.TryGetValue(uid, out var value)) { ConnectionType = value.m_type; ConnectionHash = value.m_hash; } OriginalId = new SimpleZdoIdValue(uid); if (ZDOExtraData.s_connections.TryGetValue(uid, out var value2) && value2.m_target != ZDOID.None) { TargetConnectionId = new SimpleZdoIdValue(value2.m_target); ConnectionType = value2.m_type; } Persistent = null; Distant = null; Priority = null; } public void Load(DataEntry data) { if (data.Floats != null) { if (Floats == null) { Floats = new Dictionary(); } foreach (KeyValuePair @float in data.Floats) { Floats[@float.Key] = @float.Value; } } if (data.Vecs != null) { if (Vecs == null) { Vecs = new Dictionary(); } foreach (KeyValuePair vec in data.Vecs) { Vecs[vec.Key] = vec.Value; } } if (data.Quats != null) { if (Quats == null) { Quats = new Dictionary(); } foreach (KeyValuePair quat in data.Quats) { Quats[quat.Key] = quat.Value; } } if (data.Ints != null) { if (Ints == null) { Ints = new Dictionary(); } foreach (KeyValuePair @int in data.Ints) { Ints[@int.Key] = @int.Value; } } if (data.Strings != null) { if (Strings == null) { Strings = new Dictionary(); } foreach (KeyValuePair @string in data.Strings) { Strings[@string.Key] = @string.Value; } } if (data.ByteArrays != null) { if (ByteArrays == null) { ByteArrays = new Dictionary(); } foreach (KeyValuePair byteArray in data.ByteArrays) { ByteArrays[byteArray.Key] = byteArray.Value; } } if (data.Longs != null) { if (Longs == null) { Longs = new Dictionary(); } foreach (KeyValuePair @long in data.Longs) { Longs[@long.Key] = @long.Value; } } if (data.Bools != null) { if (Bools == null) { Bools = new Dictionary(); } foreach (KeyValuePair @bool in data.Bools) { Bools[@bool.Key] = @bool.Value; } } if (data.Hashes != null) { if (Hashes == null) { Hashes = new Dictionary(); } foreach (KeyValuePair hash in data.Hashes) { Hashes[hash.Key] = hash.Value; } } if (data.Components != null) { if (Components == null) { Components = new Dictionary(); } foreach (KeyValuePair component in data.Components) { Components[component.Key] = component.Value; } } if (data.Items != null) { if (Items == null) { Items = new List(); } foreach (ItemValue item in data.Items) { Items.Add(item); } } if (data.ContainerSize.HasValue) { ContainerSize = data.ContainerSize; } if (data.ItemAmount != null) { ItemAmount = data.ItemAmount; } ConnectionType = data.ConnectionType; ConnectionHash = data.ConnectionHash; OriginalId = data.OriginalId; TargetConnectionId = data.TargetConnectionId; if (data.Persistent != null) { Persistent = data.Persistent; } if (data.Distant != null) { Distant = data.Distant; } if (data.Priority.HasValue) { Priority = data.Priority; } if (data.Position != null) { Position = data.Position; } if (data.Rotation != null) { Rotation = data.Rotation; } } public DataEntry Reset(DataData data) { Floats = null; Vecs = null; Quats = null; Ints = null; Strings = null; ByteArrays = null; Longs = null; Bools = null; Hashes = null; Items = null; Components = null; ContainerSize = null; ItemAmount = null; ConnectionType = null; ConnectionHash = 0; OriginalId = null; TargetConnectionId = null; Position = null; Rotation = null; Distant = null; Persistent = null; Priority = null; Load(data); return this; } public void Load(DataData data) { //IL_0a29: Unknown result type (might be due to invalid IL or missing references) //IL_0b6e: Unknown result type (might be due to invalid IL or missing references) //IL_0be5: Unknown result type (might be due to invalid IL or missing references) //IL_0bb3: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = new HashSet(); if (data.floats != null) { if (Floats == null) { Floats = new Dictionary(); } string[] floats = data.floats; foreach (string text in floats) { KeyValuePair keyValuePair = Parse.Kvp(text); if (keyValuePair.Key == "") { throw new InvalidOperationException("Failed to parse float " + text + "."); } if (keyValuePair.Key.Contains(".")) { hashSet.Add(keyValuePair.Key.Split(new char[1] { '.' })[0]); } int key = ZdoHelper.Hash(keyValuePair.Key); if (Floats.ContainsKey(key)) { Log.Warning("Data " + data.name + ": Duplicate float key " + keyValuePair.Key + "."); } Floats[key] = DataValue.Float(keyValuePair.Value); } } if (data.ints != null) { if (Ints == null) { Ints = new Dictionary(); } string[] floats = data.ints; foreach (string text2 in floats) { KeyValuePair keyValuePair2 = Parse.Kvp(text2); if (keyValuePair2.Key == "") { throw new InvalidOperationException("Failed to parse int " + text2 + "."); } if (keyValuePair2.Key.Contains(".")) { hashSet.Add(keyValuePair2.Key.Split(new char[1] { '.' })[0]); } int key2 = ZdoHelper.Hash(keyValuePair2.Key); if (Ints.ContainsKey(key2)) { Log.Warning("Data " + data.name + ": Duplicate int key " + keyValuePair2.Key + "."); } Ints[key2] = DataValue.Int(keyValuePair2.Value); } } if (data.bools != null) { if (Bools == null) { Bools = new Dictionary(); } string[] floats = data.bools; foreach (string text3 in floats) { KeyValuePair keyValuePair3 = Parse.Kvp(text3); if (keyValuePair3.Key == "") { throw new InvalidOperationException("Failed to parse bool " + text3 + "."); } if (keyValuePair3.Key.Contains(".")) { hashSet.Add(keyValuePair3.Key.Split(new char[1] { '.' })[0]); } int key3 = ZdoHelper.Hash(keyValuePair3.Key); if (Bools.ContainsKey(key3)) { Log.Warning("Data " + data.name + ": Duplicate bool key " + keyValuePair3.Key + "."); } Bools[key3] = DataValue.Bool(keyValuePair3.Value); } } if (data.hashes != null) { if (Hashes == null) { Hashes = new Dictionary(); } string[] floats = data.hashes; foreach (string text4 in floats) { KeyValuePair keyValuePair4 = Parse.Kvp(text4); if (keyValuePair4.Key == "") { throw new InvalidOperationException("Failed to parse hash " + text4 + "."); } if (keyValuePair4.Key.Contains(".")) { hashSet.Add(keyValuePair4.Key.Split(new char[1] { '.' })[0]); } int key4 = ZdoHelper.Hash(keyValuePair4.Key); if (Hashes.ContainsKey(key4)) { Log.Warning("Data " + data.name + ": Duplicate hash key " + keyValuePair4.Key + "."); } Hashes[key4] = DataValue.Hash(keyValuePair4.Value); } } if (data.longs != null) { if (Longs == null) { Longs = new Dictionary(); } string[] floats = data.longs; foreach (string text5 in floats) { KeyValuePair keyValuePair5 = Parse.Kvp(text5); if (keyValuePair5.Key == "") { throw new InvalidOperationException("Failed to parse long " + text5 + "."); } if (keyValuePair5.Key.Contains(".")) { hashSet.Add(keyValuePair5.Key.Split(new char[1] { '.' })[0]); } int key5 = ZdoHelper.Hash(keyValuePair5.Key); if (Longs.ContainsKey(key5)) { Log.Warning("Data " + data.name + ": Duplicate long key " + keyValuePair5.Key + "."); } Longs[key5] = DataValue.Long(keyValuePair5.Value); } } if (data.strings != null) { if (Strings == null) { Strings = new Dictionary(); } string[] floats = data.strings; foreach (string text6 in floats) { KeyValuePair keyValuePair6 = Parse.Kvp(text6); if (keyValuePair6.Key == "") { throw new InvalidOperationException("Failed to parse string " + text6 + "."); } if (keyValuePair6.Key.Contains(".")) { hashSet.Add(keyValuePair6.Key.Split(new char[1] { '.' })[0]); } int key6 = ZdoHelper.Hash(keyValuePair6.Key); if (Strings.ContainsKey(key6)) { Log.Warning("Data " + data.name + ": Duplicate string key " + keyValuePair6.Key + "."); } Strings[key6] = DataValue.String(keyValuePair6.Value); } } if (data.vecs != null) { if (Vecs == null) { Vecs = new Dictionary(); } string[] floats = data.vecs; foreach (string text7 in floats) { KeyValuePair keyValuePair7 = Parse.Kvp(text7); if (keyValuePair7.Key == "") { throw new InvalidOperationException("Failed to parse vector " + text7 + "."); } if (keyValuePair7.Key.Contains(".")) { hashSet.Add(keyValuePair7.Key.Split(new char[1] { '.' })[0]); } int key7 = ZdoHelper.Hash(keyValuePair7.Key); if (Vecs.ContainsKey(key7)) { Log.Warning("Data " + data.name + ": Duplicate vector key " + keyValuePair7.Key + "."); } Vecs[key7] = DataValue.Vector3(keyValuePair7.Value); } } if (data.quats != null) { if (Quats == null) { Quats = new Dictionary(); } string[] floats = data.quats; foreach (string text8 in floats) { KeyValuePair keyValuePair8 = Parse.Kvp(text8); if (keyValuePair8.Key == "") { throw new InvalidOperationException("Failed to parse quaternion " + text8 + "."); } if (keyValuePair8.Key.Contains(".")) { hashSet.Add(keyValuePair8.Key.Split(new char[1] { '.' })[0]); } int key8 = ZdoHelper.Hash(keyValuePair8.Key); if (Quats.ContainsKey(key8)) { Log.Warning("Data " + data.name + ": Duplicate quaternion key " + keyValuePair8.Key + "."); } Quats[key8] = DataValue.Quaternion(keyValuePair8.Value); } } if (data.bytes != null) { if (ByteArrays == null) { ByteArrays = new Dictionary(); } string[] floats = data.bytes; foreach (string text9 in floats) { KeyValuePair keyValuePair9 = Parse.Kvp(text9); if (keyValuePair9.Key == "") { throw new InvalidOperationException("Failed to parse byte array " + text9 + "."); } if (keyValuePair9.Key.Contains(".")) { hashSet.Add(keyValuePair9.Key.Split(new char[1] { '.' })[0]); } int key9 = ZdoHelper.Hash(keyValuePair9.Key); if (ByteArrays.ContainsKey(key9)) { Log.Warning("Data " + data.name + ": Duplicate byte array key " + keyValuePair9.Key + "."); } ByteArrays[key9] = DataValue.Bytes(keyValuePair9.Value); } } if (data.items != null) { List list = new List(); list.AddRange(data.items.Select((ItemData item) => new ItemValue(item))); Items = list; } if (!string.IsNullOrWhiteSpace(data.containerSize)) { ContainerSize = Parse.Vector2Int(data.containerSize); } if (!string.IsNullOrWhiteSpace(data.itemAmount)) { ItemAmount = DataValue.Int(data.itemAmount); } if (hashSet.Count > 0) { if (Components == null) { Components = new Dictionary(); } Components[ZdoHelper.Hash("HasFields")] = DataValue.Simple(1); foreach (string item in hashSet) { Components[ZdoHelper.Hash("HasFields" + item)] = DataValue.Simple(1); } } if (!string.IsNullOrWhiteSpace(data.position)) { Position = DataValue.Vector3(data.position); } if (!string.IsNullOrWhiteSpace(data.rotation)) { Rotation = DataValue.Quaternion(data.rotation); } if (data.persistent != null) { Persistent = DataValue.Bool(data.persistent); } if (data.distant != null) { Distant = DataValue.Bool(data.distant); } if (data.priority != null) { Priority = (Enum.TryParse(data.priority, ignoreCase: true, out ObjectType result) ? new ObjectType?(result) : null); } if (string.IsNullOrWhiteSpace(data.connection)) { return; } string[] array = Parse.SplitWithEmpty(data.connection); if (array.Length == 1) { string[] floats = array; List list2 = new List(floats.Length); list2.AddRange(floats); ConnectionType = ToByteEnum(list2); return; } List list3 = array.Take(array.Length - 1).ToList(); string text10 = array[^1]; ConnectionType = ToByteEnum(list3); if (text10.Contains(":") || text10.Contains("<")) { TargetConnectionId = DataValue.ZdoId(text10); OriginalId = TargetConnectionId; return; } ConnectionHash = Parse.Int(text10); if (ConnectionHash == 0) { ConnectionHash = StringExtensionMethods.GetStableHashCode(text10); } } public void Load(string[] tkv) { if (tkv.Length != 3) { throw new InvalidOperationException("Failed to parse type, field, value."); } string text = tkv[0].ToLowerInvariant(); string text2 = tkv[1]; string values = tkv[2]; if (text2.Contains(".")) { string text3 = text2.Split(new char[1] { '.' })[0]; if (Ints == null) { Ints = new Dictionary(); } Ints[ZdoHelper.Hash("HasFields")] = DataValue.Simple(1); Ints[ZdoHelper.Hash("HasFields" + text3)] = DataValue.Simple(1); } switch (text) { case "float": if (Floats == null) { Floats = new Dictionary(); } Floats[ZdoHelper.Hash(text2)] = DataValue.Float(values); break; case "int": if (Ints == null) { Ints = new Dictionary(); } Ints[ZdoHelper.Hash(text2)] = DataValue.Int(values); break; case "bool": if (Bools == null) { Bools = new Dictionary(); } Bools[ZdoHelper.Hash(text2)] = DataValue.Bool(values); break; case "hash": if (Hashes == null) { Hashes = new Dictionary(); } Hashes[ZdoHelper.Hash(text2)] = DataValue.Hash(values); break; case "long": if (Longs == null) { Longs = new Dictionary(); } Longs[ZdoHelper.Hash(text2)] = DataValue.Long(values); break; case "string": if (Strings == null) { Strings = new Dictionary(); } Strings[ZdoHelper.Hash(text2)] = DataValue.String(values); break; case "vec": case "vec3": if (Vecs == null) { Vecs = new Dictionary(); } Vecs[ZdoHelper.Hash(text2)] = DataValue.Vector3(values); break; case "quat": if (Quats == null) { Quats = new Dictionary(); } Quats[ZdoHelper.Hash(text2)] = DataValue.Quaternion(values); break; case "bytes": if (ByteArrays == null) { ByteArrays = new Dictionary(); } ByteArrays[ZdoHelper.Hash(text2)] = DataValue.Bytes(values); break; default: throw new InvalidOperationException("Unknown type " + text + "."); } } public void Load(ZPackage pkg) { //IL_0086: 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) pkg.SetPos(0); int num = pkg.ReadInt(); if (((uint)num & (true ? 1u : 0u)) != 0) { if (Floats == null) { Floats = new Dictionary(); } byte b = pkg.ReadByte(); for (int i = 0; i < b; i++) { Floats[pkg.ReadInt()] = new SimpleFloatValue(pkg.ReadSingle()); } } if (((uint)num & 2u) != 0) { if (Vecs == null) { Vecs = new Dictionary(); } byte b2 = pkg.ReadByte(); for (int j = 0; j < b2; j++) { Vecs[pkg.ReadInt()] = new SimpleVector3Value(pkg.ReadVector3()); } } if (((uint)num & 4u) != 0) { if (Quats == null) { Quats = new Dictionary(); } byte b3 = pkg.ReadByte(); for (int k = 0; k < b3; k++) { Quats[pkg.ReadInt()] = new SimpleQuaternionValue(pkg.ReadQuaternion()); } } if (((uint)num & 8u) != 0) { if (Ints == null) { Ints = new Dictionary(); } byte b4 = pkg.ReadByte(); for (int l = 0; l < b4; l++) { Ints[pkg.ReadInt()] = new SimpleIntValue(pkg.ReadInt()); } } if (((uint)num & 0x40u) != 0) { if (Longs == null) { Longs = new Dictionary(); } byte b5 = pkg.ReadByte(); for (int m = 0; m < b5; m++) { Longs[pkg.ReadInt()] = new SimpleLongValue(pkg.ReadLong()); } } if (((uint)num & 0x10u) != 0) { if (Strings == null) { Strings = new Dictionary(); } byte b6 = pkg.ReadByte(); for (int n = 0; n < b6; n++) { Strings[pkg.ReadInt()] = new SimpleStringValue(pkg.ReadString()); } } if (((uint)num & 0x80u) != 0) { if (ByteArrays == null) { ByteArrays = new Dictionary(); } byte b7 = pkg.ReadByte(); for (int num2 = 0; num2 < b7; num2++) { ByteArrays[pkg.ReadInt()] = new SimpleBytesValue(pkg.ReadByteArray()); } } if (((uint)num & 0x100u) != 0) { ConnectionType = (ConnectionType)pkg.ReadByte(); ConnectionHash = pkg.ReadInt(); } if (((uint)num & 0x200u) != 0) { Persistent = new SimpleBoolValue(pkg.ReadBool()); } if (((uint)num & 0x400u) != 0) { Distant = new SimpleBoolValue(pkg.ReadBool()); } if (((uint)num & 0x800u) != 0) { Priority = (ObjectType)pkg.ReadByte(); } } public bool Match(Parameters pars, ZDO zdo) { //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0253: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0272: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) Parameters pars2 = pars; ZDO zdo2 = zdo; if (Strings != null && Strings.Any>((KeyValuePair pair) => pair.Value.Match(pars2, GetString(zdo2, pair.Key)) == false)) { return false; } if (Floats != null && Floats.Any>((KeyValuePair pair) => pair.Value.Match(pars2, GetFloat(zdo2, pair.Key)) == false)) { return false; } if (Ints != null && Ints.Any>((KeyValuePair pair) => pair.Value.Match(pars2, GetInt(zdo2, pair.Key)) == false)) { return false; } if (Longs != null && Longs.Any>((KeyValuePair pair) => pair.Value.Match(pars2, GetLong(zdo2, pair.Key)) == false)) { return false; } if (Bools != null && Bools.Any>((KeyValuePair pair) => pair.Value.Match(pars2, GetBool(zdo2, pair.Key)) == false)) { return false; } if (Hashes != null && Hashes.Any>((KeyValuePair pair) => pair.Value.Match(pars2, GetInt(zdo2, pair.Key)) == false)) { return false; } if (Vecs != null && Vecs.Any>((KeyValuePair pair) => pair.Value.Match(pars2, GetVec(zdo2, pair.Key)) == false)) { return false; } if (Quats != null && Quats.Any>((KeyValuePair pair) => pair.Value.Match(pars2, GetQuaternion(zdo2, pair.Key)) == false)) { return false; } if (ByteArrays != null && ByteArrays.Any>((KeyValuePair pair) => pair.Value.Match(pars2, zdo2.GetByteArray(pair.Key, (byte[])null)) == false)) { return false; } if (Persistent != null && Persistent.Match(pars2, zdo2.Persistent) == false) { return false; } if (Distant != null && Distant.Match(pars2, zdo2.Distant) == false) { return false; } if (Priority.HasValue && Priority.Value != zdo2.Type) { return false; } if (Items != null) { return ItemValue.Match(pars2, Items, zdo2, ItemAmount); } if (ItemAmount != null) { return ItemValue.Match(pars2, zdo2, ItemAmount); } if (ConnectionType.HasValue) { if ((int)ConnectionType.Value == 0) { ZDOConnection connection = zdo2.GetConnection(); if (connection != null && connection.m_target != ZDOID.None) { return false; } } else { ZDOID connectionZDOID = zdo2.GetConnectionZDOID(ConnectionType.Value); if (TargetConnectionId == null) { if (connectionZDOID == ZDOID.None) { return false; } } else { ZDOID? val = TargetConnectionId.Get(pars2); if (val.HasValue) { ZDOID val2 = connectionZDOID; ZDOID? val3 = val; if (!val3.HasValue || val2 != val3.GetValueOrDefault()) { return false; } } } } } return true; } public bool Unmatch(Parameters pars, ZDO zdo) { //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: 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) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0288: 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_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) Parameters pars2 = pars; ZDO zdo2 = zdo; if (Strings != null && Strings.Any>((KeyValuePair pair) => pair.Value.Match(pars2, GetString(zdo2, pair.Key)).GetValueOrDefault())) { return false; } if (Floats != null && Floats.Any>((KeyValuePair pair) => pair.Value.Match(pars2, GetFloat(zdo2, pair.Key)).GetValueOrDefault())) { return false; } if (Ints != null && Ints.Any>((KeyValuePair pair) => pair.Value.Match(pars2, GetInt(zdo2, pair.Key)).GetValueOrDefault())) { return false; } if (Longs != null && Longs.Any>((KeyValuePair pair) => pair.Value.Match(pars2, GetLong(zdo2, pair.Key)).GetValueOrDefault())) { return false; } if (Bools != null && Bools.Any>((KeyValuePair pair) => pair.Value.Match(pars2, GetBool(zdo2, pair.Key)).GetValueOrDefault())) { return false; } if (Hashes != null && Hashes.Any>((KeyValuePair pair) => pair.Value.Match(pars2, GetInt(zdo2, pair.Key)).GetValueOrDefault())) { return false; } if (Vecs != null && Vecs.Any>((KeyValuePair pair) => pair.Value.Match(pars2, GetVec(zdo2, pair.Key)).GetValueOrDefault())) { return false; } if (Quats != null && Quats.Any>((KeyValuePair pair) => pair.Value.Match(pars2, GetQuaternion(zdo2, pair.Key)).GetValueOrDefault())) { return false; } if (ByteArrays != null && ByteArrays.Any>((KeyValuePair pair) => pair.Value.Match(pars2, zdo2.GetByteArray(pair.Key, (byte[])null)).GetValueOrDefault())) { return false; } if (Persistent != null && Persistent.Match(pars2, zdo2.Persistent).GetValueOrDefault()) { return false; } if (Distant != null && Distant.Match(pars2, zdo2.Distant).GetValueOrDefault()) { return false; } if (Priority.HasValue && Priority.Value == zdo2.Type) { return false; } if (Items != null) { return !ItemValue.Match(pars2, Items, zdo2, ItemAmount); } if (ItemAmount != null) { return !ItemValue.Match(pars2, zdo2, ItemAmount); } if (ConnectionType.HasValue) { if ((int)ConnectionType.Value == 0) { ZDOConnection connection = zdo2.GetConnection(); if (connection == null || connection.m_target == ZDOID.None) { return false; } } else { ZDOID connectionZDOID = zdo2.GetConnectionZDOID(ConnectionType.Value); if (TargetConnectionId == null) { if (connectionZDOID != ZDOID.None) { return false; } } else { ZDOID? val = TargetConnectionId.Get(pars2); if (val.HasValue) { ZDOID val2 = connectionZDOID; ZDOID? val3 = val; if (val3.HasValue && val2 == val3.GetValueOrDefault()) { return false; } } } } } return true; } private string GetString(ZDO zdo, int key) { return ZdoHelper.TryGetString(zdo, key) ?? ""; } private float GetFloat(ZDO zdo, int key) { return ZdoHelper.TryGetFloat(zdo, key).GetValueOrDefault(); } private int GetInt(ZDO zdo, int key) { return ZdoHelper.TryGetInt(zdo, key).GetValueOrDefault(); } private long GetLong(ZDO zdo, int key) { return ZdoHelper.TryGetLong(zdo, key).GetValueOrDefault(); } private bool GetBool(ZDO zdo, int key) { return ZdoHelper.TryGetBool(zdo, key).GetValueOrDefault(); } private Vector3 GetVec(ZDO zdo, int key) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) return (Vector3)(((??)ZdoHelper.TryGetVec(zdo, key)) ?? Vector3.zero); } private Quaternion GetQuaternion(ZDO zdo, int key) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) return (Quaternion)(((??)ZdoHelper.TryGetQuaternion(zdo, key)) ?? Quaternion.identity); } public static string PrintVectorXZY(Vector3 vector) { return vector.x.ToString("0.##", CultureInfo.InvariantCulture) + " " + vector.z.ToString("0.##", CultureInfo.InvariantCulture) + " " + vector.y.ToString("0.##", CultureInfo.InvariantCulture); } public static string PrintAngleYXZ(Quaternion quaternion) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return PrintVectorYXZ(((Quaternion)(ref quaternion)).eulerAngles); } private static string PrintVectorYXZ(Vector3 vector) { return vector.y.ToString("0.##", CultureInfo.InvariantCulture) + " " + vector.x.ToString("0.##", CultureInfo.InvariantCulture) + " " + vector.z.ToString("0.##", CultureInfo.InvariantCulture); } private static T ToByteEnum(List list) where T : struct, Enum { byte b = 0; foreach (string item in list) { string text = item.Trim(); if (Enum.TryParse(text, ignoreCase: true, out var result)) { b += (byte)(object)result; } else { Log.Warning("Failed to parse value " + text + " as T."); } } return (T)(object)b; } public void RollItems(Parameters pars, ZDO zdo) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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) List? items = Items; if (items != null && items.Count > 0) { Vector2i size = (Vector2i)(((??)ContainerSize) ?? ZdoHelper.GetInventorySize(this, pars, zdo)); string value = ItemValue.LoadItems(pars, Items, size, (ItemAmount?.Get(pars)).GetValueOrDefault()); if (Strings == null) { Strings = new Dictionary(); } Strings[ZDOVars.s_items] = DataValue.Simple(value); } } public void AddItems(Parameters parameters, ZDO zdo) { //IL_0032: 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) //IL_0037: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown if (Items == null || Items.Count == 0) { return; } Vector2i val = (Vector2i)(((??)ContainerSize) ?? ZdoHelper.GetInventorySize(this, parameters, zdo)); Inventory val2 = ItemValue.CreateInventory(zdo, val.x, val.y); foreach (ItemValue item in GenerateItems(parameters, val)) { item.AddTo(parameters, val2); } ZPackage val3 = new ZPackage(); val2.Save(val3); zdo.Set(ZDOVars.s_items, val3.GetBase64()); } public void RemoveItems(Parameters parameters, ZDO zdo) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown if (Items == null || Items.Count == 0) { return; } Inventory val = ItemValue.CreateInventory(zdo); if (val.m_inventory.Count == 0) { return; } foreach (ItemValue item in GenerateItems(parameters, new Vector2i(10000, 10000))) { item.RemoveFrom(parameters, val); } ZPackage val2 = new ZPackage(); val.Save(val2); zdo.Set(ZDOVars.s_items, val2.GetBase64()); } public List GenerateItems(Parameters pars, Vector2i size) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (Items == null) { throw new ArgumentNullException("Items"); } return ItemValue.Generate(pars, Items, size, (ItemAmount?.Get(pars)).GetValueOrDefault()); } } public class DataHelper { public static DataEntry? Merge(params DataEntry?[] datas) { DataEntry[] array = datas.Where((DataEntry d) => d != null).ToArray(); if (array.Length == 0) { return null; } if (array.Length == 1) { return array[0]; } DataEntry dataEntry = new DataEntry(); DataEntry[] array2 = array; foreach (DataEntry data in array2) { dataEntry.Load(data); } return dataEntry; } public static bool Exists(int hash) { return DataLoading.Data.ContainsKey(hash); } public static bool Match(int hash, ZDO zdo, Parameters pars) { if (DataLoading.Data.TryGetValue(hash, out DataEntry value)) { return value.Match(pars, zdo); } return false; } public static DataEntry? Get(string name) { if (!(name == "")) { return DataLoading.Get(name); } return null; } public static DataEntry? Get(IStringValue? name, Parameters parameters) { if (name == null) { return null; } string whole = name.GetWhole(parameters); if (whole == null) { return null; } int stableHashCode = StringExtensionMethods.GetStableHashCode(whole); if (DataLoading.TryGet(stableHashCode, out DataEntry entry)) { return entry; } if (!Enumerable.Contains(whole, ',')) { return Get(whole); } string[] array = (from s in whole.Split(new char[1] { ',' }, 3) select s.Trim()).ToArray(); if (array.Length > 2 && DataEntry.SupportedTypes.Contains(array[0])) { DataEntry dataEntry = new DataEntry(array); DataLoading.Add(stableHashCode, dataEntry); return dataEntry; } return Get(name.Get(parameters) ?? ""); } public static int GetHash(string name) { int stableHashCode = StringExtensionMethods.GetStableHashCode(name); if (Enumerable.Contains(name, ',')) { string[] array = (from s in name.Split(new char[1] { ',' }, 3) select s.Trim()).ToArray(); if (array.Length > 2 && DataEntry.SupportedTypes.Contains(array[0])) { DataEntry entry = new DataEntry(array); DataLoading.Add(stableHashCode, entry); return stableHashCode; } } Get(name); return stableHashCode; } public static List? GetValuesFromGroup(string group) { int stableHashCode = StringExtensionMethods.GetStableHashCode(group.ToLowerInvariant()); if (DataLoading.ValueGroups.TryGetValue(stableHashCode, out List value)) { return value; } return null; } public static string GetGlobalKey(string key) { string lower = key.ToLowerInvariant(); return ZoneSystem.instance.m_globalKeysValues.FirstOrDefault((KeyValuePair kvp) => kvp.Key.ToLowerInvariant() == lower).Value ?? "0"; } } public class DataLoading { private static readonly string GamePath = Path.GetFullPath(Path.Combine("BepInEx", "config", "data")); private static readonly string ProfilePath = Path.GetFullPath(Path.Combine(Paths.ConfigPath, "data")); public static Dictionary Data = new Dictionary(); public static readonly Dictionary> ValueGroups = new Dictionary>(); private static readonly Dictionary> DefaultValueGroups = new Dictionary>(); private static readonly int WearNTearHash = StringExtensionMethods.GetStableHashCode("wearntear"); private static readonly int HumanoidHash = StringExtensionMethods.GetStableHashCode("humanoid"); private static readonly int CreatureHash = StringExtensionMethods.GetStableHashCode("creature"); private static readonly int StructureHash = StringExtensionMethods.GetStableHashCode("structure"); public static string Pattern = "expand_data*.yaml"; public static void Add(int hash, DataEntry entry) { Data[hash] = entry; } public static DataEntry? Get(string name) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown DataEntry dataEntry = Get(StringExtensionMethods.GetStableHashCode(name)); if (dataEntry != null) { return dataEntry; } if (name.Length >= 12 && name.Length % 4 == 0) { try { DataEntry dataEntry2 = new DataEntry(new ZPackage(name)); Data[StringExtensionMethods.GetStableHashCode(name)] = dataEntry2; return dataEntry2; } catch { Log.Error("Failed to decode base64 data: " + name); } } Log.Warning("Data entry not found: " + name); return null; } public static DataEntry? Get(int hash) { if (!Data.ContainsKey(hash)) { return null; } return Data[hash]; } public static bool TryGet(int hash, out DataEntry? entry) { entry = (Data.ContainsKey(hash) ? Data[hash] : null); return entry != null; } public static void LoadEntries() { Dictionary data = Data; Data = new Dictionary(); ValueGroups.Clear(); List list = Yaml.Read(Directory.GetFiles(GamePath, "*.yaml").Concat(Directory.GetFiles(ProfilePath, "*.yaml")).Concat(Directory.GetFiles(Yaml.BaseDirectory, Pattern)) .Select(Path.GetFullPath) .Distinct() .ToList(), migrate: false); foreach (DataData item in list) { LoadValues(item); } if (ValueGroups.Count > 0) { Log.Info($"Loaded {ValueGroups.Count} value groups."); } LoadDefaultValueGroups(); foreach (KeyValuePair> valueGroup in ValueGroups) { ResolveValues(valueGroup.Value); } foreach (KeyValuePair> defaultValueGroup in DefaultValueGroups) { if (!ValueGroups.ContainsKey(defaultValueGroup.Key)) { ValueGroups[defaultValueGroup.Key] = defaultValueGroup.Value; } } foreach (DataData item2 in list) { LoadEntry(item2, data); } PrefabHelper.ClearCache(); Log.Info($"Loaded {Data.Count} data entries."); } private static void LoadValues(DataData data) { if (data.value != null) { KeyValuePair keyValuePair = Parse.Kvp(data.value); int stableHashCode = StringExtensionMethods.GetStableHashCode(keyValuePair.Key.ToLowerInvariant()); if (ValueGroups.ContainsKey(stableHashCode)) { Log.Warning("Duplicate value group entry: " + keyValuePair.Key); } if (!ValueGroups.ContainsKey(stableHashCode)) { ValueGroups[stableHashCode] = new List(); } ValueGroups[stableHashCode].Add(keyValuePair.Value); } if (data.valueGroup != null && data.values != null) { int stableHashCode2 = StringExtensionMethods.GetStableHashCode(data.valueGroup.ToLowerInvariant()); if (ValueGroups.ContainsKey(stableHashCode2)) { Log.Warning("Duplicate value group entry: " + data.valueGroup); } if (!ValueGroups.ContainsKey(stableHashCode2)) { ValueGroups[stableHashCode2] = new List(); } string[] values = data.values; foreach (string item in values) { ValueGroups[stableHashCode2].Add(item); } } } private static void LoadEntry(DataData data, Dictionary oldData) { if (data.name != null) { int stableHashCode = StringExtensionMethods.GetStableHashCode(data.name); if (Data.ContainsKey(stableHashCode)) { Log.Warning("Duplicate data entry: " + data.name); } Data[stableHashCode] = (oldData.TryGetValue(stableHashCode, out DataEntry value) ? value.Reset(data) : new DataEntry(data)); } } private static void LoadDefaultValueGroups() { //IL_0081: 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) if (DefaultValueGroups.Count == 0) { foreach (GameObject value in ZNetScene.instance.m_namedPrefabs.Values) { if (!Object.op_Implicit((Object)(object)value)) { continue; } value.GetComponentsInChildren(ZNetView.m_tempComponents); foreach (MonoBehaviour tempComponent in ZNetView.m_tempComponents) { AddDefaultValue(((object)tempComponent).GetType().Name, ((Object)value).name); WearNTear val = (WearNTear)(object)((tempComponent is WearNTear) ? tempComponent : null); if (val != null) { AddDefaultValue($"material_{val.m_materialType}", ((Object)value).name); } ItemDrop val2 = (ItemDrop)(object)((tempComponent is ItemDrop) ? tempComponent : null); if (val2 != null) { AddDefaultValue($"itemtype_{val2.m_itemData.m_shared.m_itemType}", ((Object)value).name); } } } } DefaultValueGroups[CreatureHash] = DefaultValueGroups[HumanoidHash]; DefaultValueGroups[StructureHash] = DefaultValueGroups[WearNTearHash]; } private static void AddDefaultValue(string name, string prefab) { int stableHashCode = StringExtensionMethods.GetStableHashCode(name.ToLowerInvariant().Replace(" ", "_")); if (!DefaultValueGroups.ContainsKey(stableHashCode)) { DefaultValueGroups[stableHashCode] = new List(); } DefaultValueGroups[stableHashCode].Add(prefab); } private static void ResolveValues(List values) { for (int i = 0; i < values.Count; i++) { string text = values[i]; if (text.StartsWith("<", StringComparison.OrdinalIgnoreCase) && text.EndsWith(">", StringComparison.OrdinalIgnoreCase)) { string text2 = text.Substring(1, text.Length - 2); List value2; if (ValueGroups.TryGetValue(StringExtensionMethods.GetStableHashCode(text2.ToLowerInvariant()), out List value)) { values.RemoveAt(i); values.InsertRange(i, value); i--; } else if (DefaultValueGroups.TryGetValue(StringExtensionMethods.GetStableHashCode(text2.ToLowerInvariant()), out value2)) { values.RemoveAt(i); values.InsertRange(i, value2); i += value2.Count - 1; } } } } public static void SetupWatcher() { if (!Directory.Exists(GamePath)) { Directory.CreateDirectory(GamePath); } if (!Directory.Exists(ProfilePath)) { Directory.CreateDirectory(ProfilePath); } if (!Directory.Exists(Yaml.BaseDirectory)) { Directory.CreateDirectory(Yaml.BaseDirectory); } Yaml.SetupWatcher(GamePath, "*", LoadEntries, overwriteBackup: true); if (GamePath != ProfilePath) { Yaml.SetupWatcher(ProfilePath, "*", LoadEntries, overwriteBackup: true); } Yaml.SetupWatcher(Pattern, LoadEntries, overwriteBackup: true); } } public class DataValue { public static IZdoIdValue ZdoId(string values) { //IL_000a: 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) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) string[] array = SplitWithValues(values); ZDOID val = Parse.ZdoId(array[0]); if (array.Length == 1 && val != ZDOID.None) { return new SimpleZdoIdValue(val); } return new ZdoIdValue(array); } public static IIntValue Simple(int value) { return new SimpleIntValue(value); } public static IStringValue Simple(string value) { return new SimpleStringValue(value); } public static IFloatValue Simple(float value) { return new SimpleFloatValue(value); } public static ILongValue Simple(long value) { return new SimpleLongValue(value); } public static IVector3Value Simple(Vector3 value) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return new SimpleVector3Value(value); } public static IQuaternionValue Simple(Quaternion value) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return new SimpleQuaternionValue(value); } public static IBytesValue Simple(byte[]? value) { return new SimpleBytesValue(value); } public static IIntValue Int(string values) { string[] array = SplitWithValues(values); if (array.Length == 1 && int.TryParse(array[0], out var result)) { return new SimpleIntValue(result); } return new IntValue(array); } public static IFloatValue Float(string values) { string[] array = SplitWithValues(values); if (array.Length == 1 && Parse.TryFloat(array[0], out var result)) { return new SimpleFloatValue(result); } return new FloatValue(array); } public static ILongValue Long(string values) { string[] array = SplitWithValues(values); if (array.Length == 1 && long.TryParse(array[0], out var result)) { return new SimpleLongValue(result); } return new LongValue(array); } public static IStringValue String(string values) { if (values.Length > 2 && values[0] == '"' && values[values.Length - 1] == '"') { return new SimpleStringValue(values.Substring(1, values.Length - 2)); } string[] array = SplitWithValues(values); if (array.Length == 1 && !HasParameters(array[0])) { return new SimpleStringValue(array[0]); } return new StringValue(array); } public static IBoolValue Bool(string values) { string[] array = SplitWithValues(values); if (array.Length == 1 && bool.TryParse(array[0], out var result)) { return new SimpleBoolValue(result); } return new BoolValue(array); } public static IBytesValue Bytes(string values) { string[] array = SplitWithValues(values); if (array.Length == 1 && !HasParameters(array[0])) { if (string.IsNullOrEmpty(array[0])) { return new SimpleBytesValue(null); } try { return new SimpleBytesValue(Convert.FromBase64String(array[0])); } catch (FormatException) { } } return new BytesValue(array); } public static IHashValue Hash(string values) { string[] array = SplitWithValues(values); if (array.Length == 1 && !HasParameters(array[0])) { return new SimpleHashValue(array[0]); } return new HashValue(array); } public static IPrefabValue Prefab(string values) { if (HasParameters(values)) { return new PrefabValue(SplitWithValues(values)); } List prefabs = PrefabHelper.GetPrefabs(values, ""); if (prefabs.Count == 0) { return new SimplePrefabValue(null); } if (prefabs.Count == 1) { return new SimplePrefabValue(prefabs[0]); } return new SimplePrefabsValue(prefabs); } public static IVector3Value Vector3(string values) { //IL_0095: 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) string[] array = SplitWithValues(values); if (HasParameters(values) || array.Length > 3) { List list = new List(); for (int i = 0; i < array.Length; i += 3) { string[] array2; if (i + 3 >= array.Length) { List list2 = new List(); list2.AddRange(array.Skip(i)); array2 = list2.ToArray(); } else { array2 = array.Skip(i).Take(3).ToArray(); } string[] value = array2; list.Add(string.Join(",", value)); } return new Vector3Value(list.ToArray()); } Vector3? val = Parse.VectorXZYNull(array); return new SimpleVector3Value(val.HasValue ? val.Value : Vector3.zero); } public static IQuaternionValue Quaternion(string values) { //IL_0095: 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) string[] array = SplitWithValues(values); if (HasParameters(values) || array.Length > 3) { List list = new List(); for (int i = 0; i < array.Length; i += 3) { string[] array2; if (i + 3 >= array.Length) { List list2 = new List(); list2.AddRange(array.Skip(i)); array2 = list2.ToArray(); } else { array2 = array.Skip(i).Take(3).ToArray(); } string[] value = array2; list.Add(string.Join(",", value)); } return new QuaternionValue(list.ToArray()); } Quaternion? val = Parse.AngleYXZNull(array); return new SimpleQuaternionValue(val.HasValue ? val.Value : Quaternion.identity); } private static bool HasParameters(string value) { if (value.Contains("<")) { return value.Contains(">"); } return false; } private static string[] SplitWithValues(string str) { List list = new List(); string[] array = Parse.SplitWithEmpty(str); foreach (string text in array) { if (!text.Contains("<") || !text.Contains(">")) { list.Add(text); continue; } string[] array2 = text.Split('<', '>'); List list2 = new List(); List list3 = new List(); for (int j = 1; j < array2.Length; j += 2) { int stableHashCode = StringExtensionMethods.GetStableHashCode(array2[j].ToLowerInvariant()); if (DataLoading.ValueGroups.ContainsKey(stableHashCode)) { list2.Add("<" + array2[j] + ">"); list3.Add(stableHashCode); } } if (list2.Count == 0) { list.Add(text); if (list.Count > 1000) { break; } } else { SubstitueValues(list, text, list2, list3, 0); } } if (list.Count > 1000) { Log.Warning("Too many values loaded for " + str); } if (list.Count <= 1000) { return list.ToArray(); } return new string[1] { str }; } private static void SubstitueValues(List result, string format, List parameters, List hashes, int index) { foreach (string item in DataLoading.ValueGroups[hashes[index]]) { string text = format.Replace(parameters[index], item); if (index == parameters.Count - 1) { result.Add(text); if (result.Count > 1000) { break; } } else { SubstitueValues(result, text, parameters, hashes, index + 1); } } } } public class AnyValue { protected readonly string[] Values; public AnyValue(string[] values) { Values = values; base..ctor(); } private string? RollValue() { if (Values.Length == 1) { return Values[0]; } return Values[Random.Range(0, Values.Length)]; } protected string? GetValue(Parameters pars) { string text = RollValue(); if (text == null || text == "") { return null; } return pars.Replace(text); } protected string? GetValue() { string text = RollValue(); if (text != null && !(text == "")) { return text; } return null; } protected List GetAllValues(Parameters pars) { List list = new List(); list.AddRange(from v in Values.Select(pars.Replace) where v != null && v != "" && v != "" select v); return list; } protected string GetWholeValue(Parameters pars) { return string.Join(",", Values.Select(pars.Replace)); } } public class ItemValue { public IPrefabValue Prefab = DataValue.Prefab(data.prefab); public float Chance = data.chance; public IIntValue? Stack = ((data.stack == null) ? null : DataValue.Int(data.stack)); public IFloatValue? Durability = ((data.durability == null) ? null : DataValue.Float(data.durability)); public string Position = data.pos; private Vector2i RolledPosition = Parse.Vector2Int(data.pos); public IBoolValue? Equipped = ((data.equipped == null) ? null : DataValue.Bool(data.equipped)); public IIntValue? Quality = ((data.quality == null) ? null : DataValue.Int(data.quality)); public IIntValue? Variant = ((data.variant == null) ? null : DataValue.Int(data.variant)); public ILongValue? CrafterID = ((data.crafterID == null) ? null : DataValue.Long(data.crafterID)); public IStringValue? CrafterName = ((data.crafterName == null) ? null : DataValue.String(data.crafterName)); public Dictionary? CustomData = data.customData?.ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => DataValue.String(kvp.Value)); public IIntValue? WorldLevel = ((data.worldLevel == null) ? null : DataValue.Int(data.worldLevel)); public IBoolValue? PickedUp = ((data.pickedUp == null) ? null : DataValue.Bool(data.pickedUp)); private int RolledPrefab; private int RolledStack; public ItemValue(ItemData data) { }//IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) public static bool Match(Parameters pars, List data, ZDO zdo, IIntValue? amount) { Parameters pars2 = pars; Inventory inv = CreateInventory(zdo); int num = data.Where((ItemValue item) => item.Match(pars2, inv)).Count(); if (amount == null) { if (num == data.Count) { return inv.m_inventory.Count == 0; } return false; } return amount.Match(pars2, num).GetValueOrDefault(); } public static bool Match(Parameters pars, ZDO zdo, IIntValue amount) { Inventory val = CreateInventory(zdo); return amount.Match(pars, val.m_inventory.Count).GetValueOrDefault(); } public static Inventory CreateInventory(ZDO zdo, int width = 100000, int height = 10000) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown Inventory val = new Inventory("", (Sprite)null, width, height); string @string = zdo.GetString(ZDOVars.s_items, ""); if (@string != "") { ZPackage val2 = new ZPackage(@string); val.Load(val2); } return val; } public static string LoadItems(Parameters pars, List items, Vector2i size, int amount) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0010: Unknown result type (might be due to invalid IL or missing references) ZPackage val = new ZPackage(); val.Write(106); items = Generate(pars, items, size, amount); val.Write(items.Count); foreach (ItemValue item in items) { item.Write(pars, val); } return val.GetBase64(); } public static List Generate(Parameters pars, List data, Vector2i size, int amount) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) List list = data.Where((ItemValue item) => item.Position != "").ToList(); List items = data.Where((ItemValue item) => item.Position == "").ToList(); Dictionary dictionary = new Dictionary(); foreach (ItemValue item in list) { if (item.Roll(pars)) { dictionary[item.RolledPosition] = item; } } if (amount == 0) { GenerateEach(pars, dictionary, size, items); } else { GenerateAmount(pars, dictionary, size, items, amount); } Dictionary.ValueCollection values = dictionary.Values; List list2 = new List(values.Count); list2.AddRange(values); return list2; } private static void GenerateEach(Parameters pars, Dictionary inventory, Vector2i size, List items) { //IL_001b: 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) //IL_0035: 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) foreach (ItemValue item in items) { if (item.Roll(pars)) { Vector2i? val = FindNextFreeSlot(inventory, size); if (!val.HasValue) { break; } item.RolledPosition = val.Value; inventory[val.Value] = item; } } } private static void GenerateAmount(Parameters pars, Dictionary inventory, Vector2i size, List items, int amount) { //IL_002b: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) float num = items.Sum((ItemValue item) => item.Chance); for (int i = 0; i < amount; i++) { if (items.Count <= 0) { break; } Vector2i? val = FindNextFreeSlot(inventory, size); if (val.HasValue) { ItemValue itemValue = RollItem(items, num); itemValue.RolledPosition = val.Value; if (itemValue.RollPrefab(pars)) { inventory[val.Value] = itemValue; } num -= itemValue.Chance; items.Remove(itemValue); continue; } break; } } private static ItemValue RollItem(List items, float maxWeight) { float num = Random.Range(0f, maxWeight); foreach (ItemValue item in items) { if (num < item.Chance) { return item; } num -= item.Chance; } return items.Last(); } private static Vector2i? FindNextFreeSlot(Dictionary inventory, Vector2i size) { //IL_0000: 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) //IL_0020: 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) int x = size.x; int y = size.y; Vector2i val = default(Vector2i); for (int i = 0; i < y; i++) { for (int j = 0; j < x; j++) { ((Vector2i)(ref val))..ctor(j, i); if (!inventory.ContainsKey(val)) { return val; } } } return null; } public bool RollPrefab(Parameters pars) { RolledPrefab = Prefab.Get(pars).GetValueOrDefault(); RolledStack = (Stack?.Get(pars)).GetValueOrDefault(1); if (RolledPrefab != 0) { return RolledStack != 0; } return false; } public bool RollChance() { if (!(Chance >= 1f)) { return Random.value <= Chance; } return true; } public bool Roll(Parameters pars) { if (RollChance()) { return RollPrefab(pars); } return false; } public void Write(Parameters pars, ZPackage pkg) { //IL_00c7: Unknown result type (might be due to invalid IL or missing references) GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(RolledPrefab); pkg.Write(((itemPrefab != null) ? ((Object)itemPrefab).name : null) ?? ""); int valueOrDefault = (Quality?.Get(pars)).GetValueOrDefault(1); float? num = Durability?.Get(pars); if (!num.HasValue) { ItemDrop val = default(ItemDrop); num = ((!((Object)(object)itemPrefab != (Object)null) || !itemPrefab.TryGetComponent(ref val)) ? new float?(100f) : new float?(val.m_itemData.GetMaxDurability(valueOrDefault))); } pkg.Write(RolledStack); pkg.Write(num.Value); pkg.Write(RolledPosition); pkg.Write((Equipped?.GetBool(pars)).GetValueOrDefault()); pkg.Write(valueOrDefault); pkg.Write((Variant?.Get(pars)).GetValueOrDefault()); pkg.Write((CrafterID?.Get(pars)).GetValueOrDefault()); pkg.Write(CrafterName?.Get(pars) ?? ""); pkg.Write(CustomData?.Count ?? 0); if (CustomData != null) { foreach (KeyValuePair customDatum in CustomData) { pkg.Write(customDatum.Key); pkg.Write(customDatum.Value.Get(pars)); } } pkg.Write((WorldLevel?.Get(pars)).GetValueOrDefault()); pkg.Write((PickedUp?.GetBool(pars)).GetValueOrDefault()); } public void Spawn(ZDO source, Parameters pars) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = ZNetScene.instance.GetPrefab(RolledPrefab); if ((Object)(object)prefab == (Object)null) { Log.Error($"Can't spawn missing drop: {RolledPrefab}"); return; } Vector3 position = source.m_position; if (Object.op_Implicit((Object)(object)prefab.GetComponent())) { ZDO val = ZdoEntry.Spawn(RolledPrefab, position, Vector3.zero, source.GetOwner()); if (val == null) { return; } val.Set(ZDOVars.s_durability, (Durability?.Get(pars)).GetValueOrDefault(100f)); val.Set(ZDOVars.s_stack, RolledStack, false); val.Set(ZDOVars.s_quality, (Quality?.Get(pars)).GetValueOrDefault(1), false); val.Set(ZDOVars.s_variant, (Variant?.Get(pars)).GetValueOrDefault(), false); val.Set(ZDOVars.s_crafterID, (CrafterID?.Get(pars)).GetValueOrDefault()); val.Set(ZDOVars.s_crafterName, CrafterName?.Get(pars) ?? ""); val.Set(ZDOVars.s_dataCount, CustomData?.Count ?? 0, false); int num = 0; if (CustomData != null) { foreach (KeyValuePair customDatum in CustomData) { val.Set($"data_{num}", customDatum.Key); val.Set($"data__{num}", customDatum.Value.Get(pars) ?? ""); num++; } } val.Set(ZDOVars.s_worldLevel, (WorldLevel?.Get(pars)).GetValueOrDefault(), false); val.Set(ZDOVars.s_pickedUp, (PickedUp?.GetBool(pars)).GetValueOrDefault()); return; } for (int i = 0; i < RolledStack; i++) { ZDO val2 = ZdoEntry.Spawn(RolledPrefab, position, Vector3.zero, source.GetOwner()); if (val2 == null) { break; } if (Object.op_Implicit((Object)(object)prefab.GetComponent())) { val2.Set(ZDOVars.s_level, (Quality?.Get(pars)).GetValueOrDefault(1), false); } if (CustomData == null) { continue; } foreach (KeyValuePair customDatum2 in CustomData) { LoadCustomData(val2, pars, customDatum2); } } } private void LoadCustomData(ZDO zdo, Parameters pars, KeyValuePair kvp) { if (kvp.Key == "data") { DataEntry dataEntry = DataHelper.Get(kvp.Value.Get(pars) ?? ""); if (dataEntry != null) { ZdoEntry zdoEntry = new ZdoEntry(zdo); zdoEntry.Load(dataEntry, pars); zdoEntry.Write(zdo); } } } public void AddTo(Parameters pars, Inventory inv) { int valueOrDefault = (Stack?.Get(pars)).GetValueOrDefault(1); valueOrDefault = StackTo(pars, valueOrDefault, inv); InsertTo(pars, valueOrDefault, inv); } private int StackTo(Parameters pars, int stack, Inventory inv) { foreach (ItemData item in inv.m_inventory) { if (MatchItem(pars, item)) { int num = Mathf.Min(item.m_shared.m_maxStackSize - item.m_stack, stack); item.m_stack += num; stack -= num; if (stack <= 0) { break; } } } return stack; } private int InsertTo(Parameters pars, int stack, Inventory inv) { //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) Parameters pars2 = pars; ItemDrop val = default(ItemDrop); while (stack > 0) { int valueOrDefault = Prefab.Get(pars2).GetValueOrDefault(); GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(valueOrDefault); if ((Object)(object)itemPrefab == (Object)null || !itemPrefab.TryGetComponent(ref val)) { return stack; } ItemData val2 = val.m_itemData.Clone(); val2.m_dropPrefab = itemPrefab; val2.m_quality = (Quality?.Get(pars2)).GetValueOrDefault(1); val2.m_variant = (Variant?.Get(pars2)).GetValueOrDefault(); val2.m_crafterID = (CrafterID?.Get(pars2)).GetValueOrDefault(); val2.m_crafterName = CrafterName?.Get(pars2) ?? ""; val2.m_worldLevel = (WorldLevel?.Get(pars2)).GetValueOrDefault(); val2.m_durability = Durability?.Get(pars2) ?? val2.GetMaxDurability(val2.m_quality); val2.m_equipped = (Equipped?.GetBool(pars2)).GetValueOrDefault(); val2.m_pickedUp = (PickedUp?.GetBool(pars2)).GetValueOrDefault(); if (CustomData != null) { val2.m_customData = CustomData.ToDictionary, string, string>((KeyValuePair x) => x.Key, (KeyValuePair x) => x.Value.Get(pars2) ?? ""); } int num = Mathf.Min(val2.m_shared.m_maxStackSize, stack); stack -= num; val2.m_stack = num; if (Position == "") { Vector2i val3 = inv.FindEmptySlot(true); if (val3.x < 0) { return stack; } val2.m_gridPos = val3; inv.m_inventory.Add(val2); } else { val2.m_gridPos = RolledPosition; inv.m_inventory.RemoveAll((ItemData x) => x.m_gridPos == RolledPosition); inv.m_inventory.Add(val2); } } return stack; } public void RemoveFrom(Parameters pars, Inventory inv) { int num = (Stack?.Get(pars)).GetValueOrDefault(1); for (int num2 = inv.m_inventory.Count - 1; num2 >= 0; num2--) { ItemData val = inv.m_inventory[num2]; if (MatchItem(pars, val)) { int num3 = Mathf.Min(val.m_stack, num); val.m_stack -= num3; num -= num3; if (num <= 0) { break; } } } inv.m_inventory.RemoveAll((ItemData x) => x.m_stack <= 0); } public bool Match(Parameters pars, Inventory inv) { ItemData val = FindMatch(pars, inv); if (val == null) { return false; } inv.RemoveItem(val); return true; } private ItemData? FindMatch(Parameters pars, Inventory inv) { if (Position != "") { ItemData itemAt = inv.GetItemAt(RolledPosition.x, RolledPosition.y); if (itemAt == null) { return null; } IIntValue? stack = Stack; if (stack != null && stack.Match(pars, itemAt.m_stack) == false) { return null; } if (MatchItem(pars, itemAt)) { return itemAt; } } foreach (ItemData item in inv.m_inventory) { IIntValue? stack2 = Stack; if ((stack2 == null || stack2.Match(pars, item.m_stack) != false) && MatchItem(pars, item)) { return item; } } return null; } private bool MatchItem(Parameters pars, ItemData item) { GameObject dropPrefab = item.m_dropPrefab; string text = ((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? item.m_shared.m_name; bool? flag = Prefab.Match(pars, StringExtensionMethods.GetStableHashCode(text)); bool flag2 = false; if (flag == flag2) { return false; } IFloatValue? durability = Durability; if (durability != null) { flag = durability.Match(pars, item.m_durability); flag2 = false; if (flag == flag2) { return false; } } IBoolValue? equipped = Equipped; if (equipped != null) { flag = equipped.Match(pars, item.m_equipped); flag2 = false; if (flag == flag2) { return false; } } IIntValue? quality = Quality; if (quality != null) { flag = quality.Match(pars, item.m_quality); flag2 = false; if (flag == flag2) { return false; } } IIntValue? variant = Variant; if (variant != null) { flag = variant.Match(pars, item.m_variant); flag2 = false; if (flag == flag2) { return false; } } ILongValue? crafterID = CrafterID; if (crafterID != null) { flag = crafterID.Match(pars, item.m_crafterID); flag2 = false; if (flag == flag2) { return false; } } IStringValue? crafterName = CrafterName; if (crafterName != null) { flag = crafterName.Match(pars, item.m_crafterName); flag2 = false; if (flag == flag2) { return false; } } IIntValue? worldLevel = WorldLevel; if (worldLevel != null) { flag = worldLevel.Match(pars, item.m_worldLevel); flag2 = false; if (flag == flag2) { return false; } } IBoolValue? pickedUp = PickedUp; if (pickedUp != null) { flag = pickedUp.Match(pars, item.m_pickedUp); flag2 = false; if (flag == flag2) { return false; } } if (CustomData == null) { return true; } foreach (KeyValuePair customDatum in CustomData) { if (!item.m_customData.TryGetValue(customDatum.Key, out var value)) { flag2 = false; } else { if (customDatum.Value.Match(pars, value) != false) { continue; } flag2 = false; } goto IL_025f; } return true; IL_025f: return flag2; } } public class ObjectParameters : Parameters { [CompilerGenerated] private ZDO P; private Inventory? inventory; public ObjectParameters(string prefab, string[] args, ZDO zdo) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) P = zdo; base..ctor(prefab, args, P.m_position); } protected override string? GetParameter(string key, string defaultValue) { string parameter = base.GetParameter(key, defaultValue); if (parameter != null) { return parameter; } parameter = GetGeneralParameter(key); if (parameter != null) { return parameter; } KeyValuePair keyValuePair = Parse.Kvp(key, '_'); if (keyValuePair.Value == "") { return null; } key = keyValuePair.Key; string value = keyValuePair.Value; parameter = Parameters.ExecuteCodeWithValue(key, value); if (parameter != null) { return parameter; } parameter = base.GetValueParameter(key, value, defaultValue); if (parameter != null) { return parameter; } return GetValueParameter(key, value, defaultValue); } private string? GetGeneralParameter(string key) { //IL_01f9: 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_0203: Unknown result type (might be due to invalid IL or missing references) //IL_021c: 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_0226: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: 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) switch (key) { case "zdo": return ((object)(ZDOID)(ref P.m_uid)).ToString(); case "pos": return Helper.FormatPos(P.m_position); case "i": return ZoneSystem.GetZone(P.m_position).x.ToString(); case "j": return ZoneSystem.GetZone(P.m_position).y.ToString(); case "a": return Helper.Format(P.m_rotation.y); case "rot": return Helper.FormatRot(P.m_rotation); case "pid": return PeerManager.GetPid(P); case "cid": return PeerManager.GetCid(P)?.ToString() ?? ""; case "platform": return PeerManager.GetPlatform(P); case "pname": return PeerManager.GetPName(P); case "pchar": return PeerManager.GetPChar(P); case "pvisible": return PeerManager.GetPVisible(P); case "owner": return P.GetOwner().ToString(); case "biome": { Biome biome = WorldGenerator.instance.GetBiome(P.m_position); return ((object)(Biome)(ref biome)).ToString(); } default: return null; } } protected override string? GetValueParameter(string key, string value, string defaultValue) { //IL_0306: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: 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) //IL_032a: Unknown result type (might be due to invalid IL or missing references) switch (key) { case "key": return DataHelper.GetGlobalKey(value); case "string": return GetString(value, defaultValue); case "float": return GetFloat(value, defaultValue).ToString(CultureInfo.InvariantCulture); case "int": return GetInt(value, defaultValue).ToString(CultureInfo.InvariantCulture); case "long": return GetLong(value, defaultValue).ToString(CultureInfo.InvariantCulture); case "bool": return GetBool(value, defaultValue) ? "true" : "false"; case "hash": return GetHash(value, defaultValue); case "vec": return DataEntry.PrintVectorXZY(GetVec(value, defaultValue)); case "quat": return DataEntry.PrintAngleYXZ(GetQuaternion(value, defaultValue)); case "byte": return GetBytes(value, defaultValue); case "zdo": { ZDOID zDOID = P.GetZDOID(value); return ((object)(ZDOID)(ref zDOID)).ToString(); } case "amount": return GetAmount(value, defaultValue); case "quality": return GetQuality(value, defaultValue); case "durability": return GetDurability(value, defaultValue); case "item": return GetItem(value, defaultValue); case "pos": return DataEntry.PrintVectorXZY(GetPos(value)); case "pdata": return PeerManager.GetPlayerData(P, value); default: return null; } } private string GetBytes(string value, string defaultValue) { byte[] byteArray = P.GetByteArray(value, (byte[])null); if (byteArray != null) { return Convert.ToBase64String(byteArray); } return defaultValue; } private string GetString(string value, string defaultValue) { return ZdoHelper.GetString(P, value, defaultValue); } private float GetFloat(string value, string defaultValue) { return ZdoHelper.GetFloat(P, value, defaultValue); } private int GetInt(string value, string defaultValue) { return ZdoHelper.GetInt(P, value, defaultValue); } private long GetLong(string value, string defaultValue) { return ZdoHelper.GetLong(P, value, defaultValue); } private bool GetBool(string value, string defaultValue) { return ZdoHelper.GetBool(P, value, defaultValue); } private string GetHash(string value, string defaultValue) { if (value == "") { return defaultValue; } int @int = P.GetInt(value, 0); GameObject prefab = ZNetScene.instance.GetPrefab(@int); return ((prefab != null) ? ((Object)prefab).name : null) ?? ZoneSystem.instance.GetLocation(@int)?.m_prefabName ?? defaultValue; } private Vector3 GetVec(string value, string defaultValue) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) return ZdoHelper.GetVec(P, value, defaultValue); } private Quaternion GetQuaternion(string value, string defaultValue) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) return ZdoHelper.GetQuaternion(P, value, defaultValue); } private string GetItem(string value, string defaultValue) { if (value == "") { return defaultValue; } KeyValuePair keyValuePair = Parse.Kvp(value, '_'); if (!Parse.TryInt(keyValuePair.Key, out var result) || !Parse.TryInt(keyValuePair.Value, out var result2)) { return GetAmountOfItems(value).ToString(); } return GetNameAt(result, result2) ?? defaultValue; } private string GetAmount(string value, string defaultValue) { if (value == "") { return defaultValue; } KeyValuePair keyValuePair = Parse.Kvp(value, '_'); if (!Parse.TryInt(keyValuePair.Key, out var result) || !Parse.TryInt(keyValuePair.Value, out var result2)) { return GetAmountOfItems(value).ToString(); } return GetAmountAt(result, result2) ?? defaultValue; } private string GetDurability(string value, string defaultValue) { if (value == "") { return defaultValue; } KeyValuePair keyValuePair = Parse.Kvp(value, '_'); if (!Parse.TryInt(keyValuePair.Key, out var result) || !Parse.TryInt(keyValuePair.Value, out var result2)) { return defaultValue; } return GetDurabilityAt(result, result2) ?? defaultValue; } private string GetQuality(string value, string defaultValue) { if (value == "") { return defaultValue; } KeyValuePair keyValuePair = Parse.Kvp(value, '_'); if (!Parse.TryInt(keyValuePair.Key, out var result) || !Parse.TryInt(keyValuePair.Value, out var result2)) { return defaultValue; } return GetQualityAt(result, result2) ?? defaultValue; } private int GetAmountOfItems(string prefab) { LoadInventory(); if (inventory == null) { return 0; } if (prefab == "") { return inventory.m_inventory.Sum((ItemData i) => i.m_stack); } if (prefab == "*") { return inventory.m_inventory.Sum((ItemData i) => i.m_stack); } int num = 0; if (prefab[0] == '*' && prefab[prefab.Length - 1] == '*') { prefab = prefab.Substring(1, prefab.Length - 2).ToLowerInvariant(); foreach (ItemData item in inventory.m_inventory) { if (GetName(item).ToLowerInvariant().Contains(prefab)) { num += item.m_stack; } } } else if (prefab[0] == '*') { prefab = prefab.Substring(1); foreach (ItemData item2 in inventory.m_inventory) { if (GetName(item2).EndsWith(prefab, StringComparison.OrdinalIgnoreCase)) { num += item2.m_stack; } } } else if (prefab[prefab.Length - 1] == '*') { prefab = prefab.Substring(0, prefab.Length - 1); foreach (ItemData item3 in inventory.m_inventory) { if (GetName(item3).StartsWith(prefab, StringComparison.OrdinalIgnoreCase)) { num += item3.m_stack; } } } else { int num2 = prefab.IndexOf('*'); if (num2 > 0 && num2 < prefab.Length - 1) { string value = prefab.Substring(0, num2); string value2 = prefab.Substring(num2 + 1); foreach (ItemData item4 in inventory.m_inventory) { string name = GetName(item4); if (name.StartsWith(value, StringComparison.OrdinalIgnoreCase) && name.EndsWith(value2, StringComparison.OrdinalIgnoreCase)) { num += item4.m_stack; } } } else { foreach (ItemData item5 in inventory.m_inventory) { if (GetName(item5) == prefab) { num += item5.m_stack; } } } } return num; } private string GetName(ItemData? item) { object obj; if (item == null) { obj = null; } else { GameObject dropPrefab = item.m_dropPrefab; obj = ((dropPrefab != null) ? ((Object)dropPrefab).name : null); } if (obj == null) { obj = item?.m_shared.m_name ?? ""; } return (string)obj; } private string? GetNameAt(int x, int y) { ItemData itemAt = GetItemAt(x, y); return GetName(itemAt); } private string? GetAmountAt(int x, int y) { return GetItemAt(x, y)?.m_stack.ToString(); } private string? GetDurabilityAt(int x, int y) { return GetItemAt(x, y)?.m_durability.ToString(); } private string? GetQualityAt(int x, int y) { return GetItemAt(x, y)?.m_quality.ToString(); } private ItemData? GetItemAt(int x, int y) { LoadInventory(); if (inventory == null) { return null; } if (x < 0 || x >= inventory.m_width || y < 0 || y >= inventory.m_height) { return null; } return inventory.GetItemAt(x, y); } private void LoadInventory() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown if (inventory == null) { string @string = P.GetString(ZDOVars.s_items, ""); if (!(@string == "")) { inventory = new Inventory("", (Sprite)null, 9999, 9999); inventory.Load(new ZPackage(@string)); } } } private Vector3 GetPos(string value) { //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_000d: 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_001d: 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_0023: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Parse.VectorXZY(value); return P.GetPosition() + P.GetRotation() * val; } } public class Parameters { [CompilerGenerated] private string P; [CompilerGenerated] private string[] P; [CompilerGenerated] private Vector3 P; protected const char Separator = '_'; public static Func ExecuteCode = (string key) => null; public static Func ExecuteCodeWithValue = (string key, string value) => null; private readonly double time; public int Amount; public Parameters(string prefab, string[] args, Vector3 pos) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) P = prefab; P = args; P = pos; time = ZNet.instance.GetTimeSeconds(); base..ctor(); } public string Replace(string str) { return Replace(str, preventInjections: false); } public string Replace(string str, bool preventInjections) { StringBuilder stringBuilder = new StringBuilder(); int num = 0; int num2 = 0; for (int i = 0; i < str.Length; i++) { if (str[i] == '<') { if (num == 0) { stringBuilder.Append(str.Substring(num2, i - num2)); num2 = i; } num++; } if (str[i] != '>') { continue; } if (num == 1) { string str2 = str.Substring(num2, i - num2 + 1); string text = ResolveParameters(str2); if (preventInjections && text.Contains(";")) { text = text.Replace(";", ","); } stringBuilder.Append(text); num2 = i + 1; } if (num > 0) { num--; } } if (num2 < str.Length) { stringBuilder.Append(str.Substring(num2)); } return stringBuilder.ToString(); } private string ResolveParameters(string str) { int num; for (num = 0; num < str.Length; num++) { int num2 = str.IndexOf(">", num); if (num2 == -1) { break; } num = num2; int num3 = str.LastIndexOf("<", num2); if (num3 != -1) { int num4 = num2 - num3 + 1; if (TryReplaceParameter(str.Substring(num3, num4), out string resolved)) { str = str.Remove(num3, num4); str = str.Insert(num3, resolved); num = num3 - 1; } else { num = num2; } } } return str; } private bool TryReplaceParameter(string rawKey, out string? resolved) { string text = rawKey.Substring(1, rawKey.Length - 2); KeyValuePair keyValuePair = Parse.Kvp(text, '='); string text2 = keyValuePair.Value; if (text2.All((char c) => c == '=')) { text2 = ""; } else { text = keyValuePair.Key; } resolved = GetParameter(text, text2); if (resolved == null) { resolved = ResolveValue(rawKey); } return resolved != rawKey; } protected virtual string? GetParameter(string key, string defaultValue) { string text = Api.ResolveParameter(key); if (text != null) { return text; } text = ExecuteCode(key); if (text != null) { return text; } text = GetGeneralParameter(key, defaultValue); if (text != null) { return text; } KeyValuePair keyValuePair = Parse.Kvp(key, '_'); if (keyValuePair.Value == "") { return null; } key = keyValuePair.Key; string value = keyValuePair.Value; text = Api.ResolveValueParameter(key, value); if (text != null) { return text; } text = ExecuteCodeWithValue(key, value); if (text != null) { return text; } return GetValueParameter(key, value, defaultValue); } private string? GetGeneralParameter(string key, string defaultValue) { return key switch { "prefab" => P, "safeprefab" => P.Replace('_', '-'), "par" => string.Join(" ", P), "par0" => GetArg(0, defaultValue), "par1" => GetArg(1, defaultValue), "par2" => GetArg(2, defaultValue), "par3" => GetArg(3, defaultValue), "par4" => GetArg(4, defaultValue), "par5" => GetArg(5, defaultValue), "par6" => GetArg(6, defaultValue), "par7" => GetArg(7, defaultValue), "par8" => GetArg(8, defaultValue), "par9" => GetArg(9, defaultValue), "day" => EnvMan.instance.GetDay(time).ToString(), "ticks" => ((long)(time * 10000000.0)).ToString(), "x" => Helper.Format(P.x), "y" => Helper.Format(P.y), "z" => Helper.Format(P.z), "snap" => Helper.Format(WorldGenerator.instance.GetHeight(P.x, P.z)), "amount" => (P.Length < 2) ? Amount.ToString() : null, "time" => Helper.Format(time), "realtime" => DateTimeOffset.UtcNow.ToUnixTimeSeconds().ToString(), _ => null, }; } protected virtual string? GetValueParameter(string key, string value, string defaultValue) { float result; float result2; float result3; float result4; float result5; float result6; float result7; float result8; float result9; float result10; KeyValuePair kvp; float result11; float result12; float result13; KeyValuePair kvp2; float result14; float result15; KeyValuePair kvp3; int result16; int result17; KeyValuePair kvp4; float result18; float result19; KeyValuePair kvp5; int result20; int result21; int result22; int result23; int result24; return key switch { "sqrt" => Parse.TryFloat(value, out result) ? Mathf.Sqrt(result).ToString(CultureInfo.InvariantCulture) : defaultValue, "round" => Parse.TryFloat(value, out result2) ? Mathf.Round(result2).ToString(CultureInfo.InvariantCulture) : defaultValue, "ceil" => Parse.TryFloat(value, out result3) ? Mathf.Ceil(result3).ToString(CultureInfo.InvariantCulture) : defaultValue, "floor" => Parse.TryFloat(value, out result4) ? Mathf.Floor(result4).ToString(CultureInfo.InvariantCulture) : defaultValue, "abs" => Parse.TryFloat(value, out result5) ? Mathf.Abs(result5).ToString(CultureInfo.InvariantCulture) : defaultValue, "sin" => Parse.TryFloat(value, out result6) ? Mathf.Sin(result6).ToString(CultureInfo.InvariantCulture) : defaultValue, "cos" => Parse.TryFloat(value, out result7) ? Mathf.Cos(result7).ToString(CultureInfo.InvariantCulture) : defaultValue, "tan" => Parse.TryFloat(value, out result8) ? Mathf.Tan(result8).ToString(CultureInfo.InvariantCulture) : defaultValue, "asin" => Parse.TryFloat(value, out result9) ? Mathf.Asin(result9).ToString(CultureInfo.InvariantCulture) : defaultValue, "acos" => Parse.TryFloat(value, out result10) ? Mathf.Acos(result10).ToString(CultureInfo.InvariantCulture) : defaultValue, "atan" => Atan(value, defaultValue), "pow" => (Parse.TryKvp(value, out kvp, '_') && Parse.TryFloat(kvp.Key, out result11) && Parse.TryFloat(kvp.Value, out result12)) ? Mathf.Pow(result11, result12).ToString(CultureInfo.InvariantCulture) : defaultValue, "log" => Loga(value, defaultValue), "exp" => Parse.TryFloat(value, out result13) ? Mathf.Exp(result13).ToString(CultureInfo.InvariantCulture) : defaultValue, "min" => HandleMin(value, defaultValue), "max" => HandleMax(value, defaultValue), "add" => HandleAdd(value, defaultValue), "sub" => HandleSub(value, defaultValue), "mul" => HandleMul(value, defaultValue), "div" => HandleDiv(value, defaultValue), "mod" => HandleMod(value, defaultValue), "addlong" => HandleAddLong(value, defaultValue), "sublong" => HandleSubLong(value, defaultValue), "mullong" => HandleMulLong(value, defaultValue), "divlong" => HandleDivLong(value, defaultValue), "modlong" => HandleModLong(value, defaultValue), "randf" => (Parse.TryKvp(value, out kvp2, '_') && Parse.TryFloat(kvp2.Key, out result14) && Parse.TryFloat(kvp2.Value, out result15)) ? Random.Range(result14, result15).ToString(CultureInfo.InvariantCulture) : defaultValue, "randi" => (Parse.TryKvp(value, out kvp3, '_') && Parse.TryInt(kvp3.Key, out result16) && Parse.TryInt(kvp3.Value, out result17)) ? Random.Range(result16, result17).ToString(CultureInfo.InvariantCulture) : defaultValue, "randomfloat" => (Parse.TryKvp(value, out kvp4, '_') && Parse.TryFloat(kvp4.Key, out result18) && Parse.TryFloat(kvp4.Value, out result19)) ? Random.Range(result18, result19).ToString(CultureInfo.InvariantCulture) : defaultValue, "randomint" => (Parse.TryKvp(value, out kvp5, '_') && Parse.TryInt(kvp5.Key, out result20) && Parse.TryInt(kvp5.Value, out result21)) ? Random.Range(result20, result21).ToString(CultureInfo.InvariantCulture) : defaultValue, "hashof" => ZdoHelper.Hash(value).ToString(), "textof" => Parse.TryInt(value, out result22) ? ZdoHelper.ReverseHash(result22) : defaultValue, "len" => value.Length.ToString(CultureInfo.InvariantCulture), "lower" => value.ToLowerInvariant(), "upper" => value.ToUpperInvariant(), "trim" => value.Trim(), "left" => HandleLeft(value, defaultValue), "right" => HandleRight(value, defaultValue), "mid" => HandleMid(value, defaultValue), "proper" => HandleProper(value, defaultValue), "search" => HandleSearch(value, defaultValue), "calcf" => Calculator.EvaluateFloat(value)?.ToString(CultureInfo.InvariantCulture) ?? defaultValue, "calci" => Calculator.EvaluateInt(value)?.ToString(CultureInfo.InvariantCulture) ?? defaultValue, "calcfloat" => Calculator.EvaluateFloat(value)?.ToString(CultureInfo.InvariantCulture) ?? defaultValue, "calcint" => Calculator.EvaluateInt(value)?.ToString(CultureInfo.InvariantCulture) ?? defaultValue, "calclong" => Calculator.EvaluateLong(value)?.ToString(CultureInfo.InvariantCulture) ?? defaultValue, "par" => Parse.TryInt(value, out result23) ? GetArg(result23, defaultValue) : defaultValue, "rest" => Parse.TryInt(value, out result24) ? GetRest(result24, defaultValue) : defaultValue, "load" => DataStorage.GetValue(value, defaultValue), "save" => SetValue(value), "save++" => DataStorage.IncrementValue(value, 1L), "save--" => DataStorage.IncrementValue(value, -1L), "clear" => RemoveValue(value), "rank" => HandleRank(value, defaultValue), "small" => HandleSmall(value, defaultValue), "large" => HandleLarge(value, defaultValue), "eq" => HandleEqual(value, defaultValue), "ne" => HandleNotEqual(value, defaultValue), "gt" => HandleGreater(value, defaultValue), "ge" => HandleGreaterOrEqual(value, defaultValue), "lt" => HandleLess(value, defaultValue), "le" => HandleLessOrEqual(value, defaultValue), "even" => HandleEven(value, defaultValue), "odd" => HandleOdd(value, defaultValue), "findupper" => HandleFindUpper(value, defaultValue), "findlower" => HandleFindLower(value, defaultValue), "time" => HandleTime(value), "realtime" => HandleRealtime(value), _ => null, }; } private string HandleMin(string value, string defaultValue) { string[] array = value.Split(new char[1] { '_' }); if (array.Length == 0) { return defaultValue; } return array.Select((string v) => Parse.Float(v, float.MaxValue)).Min().ToString(CultureInfo.InvariantCulture); } private string HandleMax(string value, string defaultValue) { string[] array = value.Split(new char[1] { '_' }); if (array.Length == 0) { return defaultValue; } return array.Select((string v) => Parse.Float(v, float.MinValue)).Max().ToString(CultureInfo.InvariantCulture); } private string SetValue(string value) { KeyValuePair keyValuePair = Parse.Kvp(value, '_'); if (keyValuePair.Value == "") { return ""; } DataStorage.SetValue(keyValuePair.Key, keyValuePair.Value); return keyValuePair.Value; } private string RemoveValue(string value) { DataStorage.SetValue(value, ""); return ""; } private string GetRest(int index, string defaultValue = "") { if (index < 0 || index >= P.Length) { return defaultValue; } return string.Join(" ", P, index, P.Length - index); } private string Atan(string value, string defaultValue) { KeyValuePair keyValuePair = Parse.Kvp(value, '_'); if (!Parse.TryFloat(keyValuePair.Key, out var result)) { return defaultValue; } if (keyValuePair.Value == "") { return Mathf.Atan(result).ToString(CultureInfo.InvariantCulture); } if (!Parse.TryFloat(keyValuePair.Value, out var result2)) { return defaultValue; } return Mathf.Atan2(result, result2).ToString(CultureInfo.InvariantCulture); } private string Loga(string value, string defaultValue) { KeyValuePair keyValuePair = Parse.Kvp(value, '_'); if (!Parse.TryFloat(keyValuePair.Key, out var result)) { return defaultValue; } if (keyValuePair.Value == "") { return Mathf.Log(result).ToString(CultureInfo.InvariantCulture); } if (!Parse.TryFloat(keyValuePair.Value, out var result2)) { return defaultValue; } return Mathf.Log(result, result2).ToString(CultureInfo.InvariantCulture); } private string HandleAdd(string value, string defaultValue) { string[] array = value.Split(new char[1] { '_' }); if (array.Length == 0) { return defaultValue; } float num = 0f; string[] array2 = array; foreach (string arg in array2) { num += Parse.Float(arg); } return num.ToString(CultureInfo.InvariantCulture); } private string HandleSub(string value, string defaultValue) { string[] array = value.Split(new char[1] { '_' }); if (array.Length == 0) { return defaultValue; } float num = Parse.Float(array[0]); for (int i = 1; i < array.Length; i++) { num -= Parse.Float(array[i]); } return num.ToString(CultureInfo.InvariantCulture); } private string HandleMul(string value, string defaultValue) { string[] array = value.Split(new char[1] { '_' }); if (array.Length == 0) { return defaultValue; } float num = 1f; string[] array2 = array; foreach (string arg in array2) { num *= Parse.Float(arg, 1f); } return num.ToString(CultureInfo.InvariantCulture); } private string HandleDiv(string value, string defaultValue) { string[] array = value.Split(new char[1] { '_' }); if (array.Length == 0) { return defaultValue; } float num = Parse.Float(array[0]); for (int i = 1; i < array.Length; i++) { float num2 = Parse.Float(array[i], 1f); if (num2 == 0f) { return defaultValue; } num /= num2; } return num.ToString(CultureInfo.InvariantCulture); } private string HandleMod(string value, string defaultValue) { string[] array = value.Split(new char[1] { '_' }); if (array.Length == 0) { return defaultValue; } float num = Parse.Float(array[0]); for (int i = 1; i < array.Length; i++) { float num2 = Parse.Float(array[i], 1f); if (num2 == 0f) { return defaultValue; } num %= num2; } return num.ToString(CultureInfo.InvariantCulture); } private string HandleAddLong(string value, string defaultValue) { string[] array = value.Split(new char[1] { '_' }); if (array.Length == 0) { return defaultValue; } long num = 0L; string[] array2 = array; foreach (string arg in array2) { num += Parse.Long(arg, 0L); } return num.ToString(CultureInfo.InvariantCulture); } private string HandleSubLong(string value, string defaultValue) { string[] array = value.Split(new char[1] { '_' }); if (array.Length == 0) { return defaultValue; } long num = Parse.Long(array[0], 0L); for (int i = 1; i < array.Length; i++) { num -= Parse.Long(array[i], 0L); } return num.ToString(CultureInfo.InvariantCulture); } private string HandleMulLong(string value, string defaultValue) { string[] array = value.Split(new char[1] { '_' }); if (array.Length == 0) { return defaultValue; } long num = 1L; string[] array2 = array; foreach (string arg in array2) { num *= Parse.Long(arg, 1L); } return num.ToString(CultureInfo.InvariantCulture); } private string HandleDivLong(string value, string defaultValue) { string[] array = value.Split(new char[1] { '_' }); if (array.Length == 0) { return defaultValue; } long num = Parse.Long(array[0], 0L); for (int i = 1; i < array.Length; i++) { long num2 = Parse.Long(array[i], 1L); if (num2 == 0L) { return defaultValue; } num /= num2; } return num.ToString(CultureInfo.InvariantCulture); } private string HandleModLong(string value, string defaultValue) { string[] array = value.Split(new char[1] { '_' }); if (array.Length == 0) { return defaultValue; } long num = Parse.Long(array[0], 0L); for (int i = 1; i < array.Length; i++) { long num2 = Parse.Long(array[i], 1L); if (num2 == 0L) { return defaultValue; } num %= num2; } return num.ToString(CultureInfo.InvariantCulture); } private string HandleLeft(string value, string defaultValue) { KeyValuePair keyValuePair = Parse.Kvp(value, '_'); string key = keyValuePair.Key; int num = Parse.Int(keyValuePair.Value, 1); if (key.Length == 0) { return defaultValue; } if (num <= 0) { return ""; } if (num >= key.Length) { return key; } return key.Substring(0, num); } private string HandleRight(string value, string defaultValue) { KeyValuePair keyValuePair = Parse.Kvp(value, '_'); string key = keyValuePair.Key; int num = Parse.Int(keyValuePair.Value, 1); if (key.Length == 0) { return defaultValue; } if (num <= 0) { return ""; } if (num >= key.Length) { return key; } return key.Substring(key.Length - num); } private string HandleMid(string value, string defaultValue) { string[] array = value.Split(new char[1] { '_' }); if (array.Length < 3) { return defaultValue; } string text = array[0]; if (!Parse.TryInt(array[1], out var result) || !Parse.TryInt(array[2], out var result2)) { return defaultValue; } if (text.Length == 0 || result >= text.Length || result2 <= 0) { return ""; } int num = Math.Min(result + result2, text.Length); return text.Substring(result, num - result); } private string HandleProper(string value, string defaultValue) { if (string.IsNullOrEmpty(value)) { return defaultValue; } string[] array = value.Split(new char[1] { ' ' }); for (int i = 0; i < array.Length; i++) { if (array[i].Length > 0) { array[i] = char.ToUpper(array[i][0]) + ((array[i].Length > 1) ? array[i].Substring(1).ToLower() : ""); } } return string.Join(" ", array); } private string HandleSearch(string value, string defaultValue) { string[] array = value.Split(new char[1] { '_' }); if (array.Length < 2) { return defaultValue; } string value2 = array[0]; string text = array[1]; int num = ((array.Length >= 3) ? Parse.Int(array[2]) : 0); if (num >= text.Length) { return defaultValue; } int num2 = text.IndexOf(value2, num, StringComparison.OrdinalIgnoreCase); if (num2 < 0) { return defaultValue; } return num2.ToString(); } private string GetArg(int index, string defaultValue = "") { if (P.Length > index && !(P[index] == "")) { return P[index]; } return defaultValue; } private string HandleRank(string value, string defaultValue) { string[] array = value.Split(new char[1] { '_' }); if (array.Length < 2) { return defaultValue; } if (!Parse.TryFloat(array[0], out var result)) { return defaultValue; } List list = (from v in array.Skip(1) select Parse.Float(v, float.MaxValue)).ToList(); int num = 0; foreach (float item in list) { if (item > result) { num++; } } return num.ToString(CultureInfo.InvariantCulture); } private string HandleSmall(string value, string defaultValue) { string[] array = value.Split(new char[1] { '_' }); if (array.Length < 2) { return defaultValue; } if (!Parse.TryInt(array[0], out var result) || result < 1) { return defaultValue; } result--; List list = (from v in array.Skip(1) select Parse.Float(v, float.MaxValue)).ToList(); list.Sort(); return list[result].ToString(CultureInfo.InvariantCulture); } private string HandleLarge(string value, string defaultValue) { string[] array = value.Split(new char[1] { '_' }); if (array.Length < 2) { return defaultValue; } if (!Parse.TryInt(array[0], out var result) || result < 1) { return defaultValue; } result = array.Length - result; List list = (from v in array.Skip(1) select Parse.Float(v, float.MinValue)).ToList(); list.Sort(); return list[result].ToString(CultureInfo.InvariantCulture); } private string HandleEqual(string value, string defaultValue) { KeyValuePair keyValuePair = Parse.Kvp(value, '_'); if (keyValuePair.Value == "") { return defaultValue; } if (Parse.TryFloat(keyValuePair.Key, out var result) && Parse.TryFloat(keyValuePair.Value, out var result2)) { if (!(Math.Abs(result - result2) < float.Epsilon)) { return "false"; } return "true"; } if (!string.Equals(keyValuePair.Key, keyValuePair.Value, StringComparison.OrdinalIgnoreCase)) { return "false"; } return "true"; } private string HandleNotEqual(string value, string defaultValue) { KeyValuePair keyValuePair = Parse.Kvp(value, '_'); if (keyValuePair.Value == "") { return defaultValue; } if (Parse.TryFloat(keyValuePair.Key, out var result) && Parse.TryFloat(keyValuePair.Value, out var result2)) { if (!(Math.Abs(result - result2) >= float.Epsilon)) { return "false"; } return "true"; } if (string.Equals(keyValuePair.Key, keyValuePair.Value, StringComparison.OrdinalIgnoreCase)) { return "false"; } return "true"; } private string HandleGreater(string value, string defaultValue) { KeyValuePair keyValuePair = Parse.Kvp(value, '_'); if (keyValuePair.Value == "" || !Parse.TryFloat(keyValuePair.Key, out var result) || !Parse.TryFloat(keyValuePair.Value, out var result2)) { return defaultValue; } if (!(result > result2)) { return "false"; } return "true"; } private string HandleGreaterOrEqual(string value, string defaultValue) { KeyValuePair keyValuePair = Parse.Kvp(value, '_'); if (keyValuePair.Value == "" || !Parse.TryFloat(keyValuePair.Key, out var result) || !Parse.TryFloat(keyValuePair.Value, out var result2)) { return defaultValue; } if (!(result >= result2)) { return "false"; } return "true"; } private string HandleLess(string value, string defaultValue) { KeyValuePair keyValuePair = Parse.Kvp(value, '_'); if (keyValuePair.Value == "" || !Parse.TryFloat(keyValuePair.Key, out var result) || !Parse.TryFloat(keyValuePair.Value, out var result2)) { return defaultValue; } if (!(result < result2)) { return "false"; } return "true"; } private string HandleLessOrEqual(string value, string defaultValue) { KeyValuePair keyValuePair = Parse.Kvp(value, '_'); if (keyValuePair.Value == "" || !Parse.TryFloat(keyValuePair.Key, out var result) || !Parse.TryFloat(keyValuePair.Value, out var result2)) { return defaultValue; } if (!(result <= result2)) { return "false"; } return "true"; } private string HandleEven(string value, string defaultValue) { if (!Parse.TryInt(value, out var result)) { return defaultValue; } if (result % 2 != 0) { return "false"; } return "true"; } private string HandleOdd(string value, string defaultValue) { if (!Parse.TryInt(value, out var result)) { return defaultValue; } if (result % 2 == 0) { return "false"; } return "true"; } private string HandleFindUpper(string value, string defaultValue) { if (string.IsNullOrEmpty(value)) { return defaultValue; } List list = new List(); list.AddRange(value.Where(char.IsUpper)); return new string(list.ToArray()); } private string HandleFindLower(string value, string defaultValue) { if (string.IsNullOrEmpty(value)) { return defaultValue; } List list = new List(); list.AddRange(value.Where(char.IsLower)); return new string(list.ToArray()); } private string HandleTime(string value) { long dayLengthSec = EnvMan.instance.m_dayLengthSec; double num = (double)dayLengthSec / 24.0; double num2 = num / 60.0; int num3 = (int)(time / (double)dayLengthSec); double num4 = time - (double)(num3 * dayLengthSec); int num5 = (int)(num4 / num); int num6 = (int)((num4 - (double)num5 * num) / num2); int num7 = (int)((num4 - (double)num5 * num - (double)num6 * num2) / (num2 / 60.0)); return new DateTimeOffset(2000, 1, 1, 0, 0, 0, TimeSpan.Zero).AddDays(num3).AddHours(num5).AddMinutes(num6) .AddSeconds(num7) .ToString(value, CultureInfo.InvariantCulture); } private string HandleRealtime(string value) { string[] array = value.Split(new char[1] { '_' }); string text = array[0]; float num = ((array.Length > 1) ? Parse.Float(array[1]) : ((float)TimeZoneInfo.Local.BaseUtcOffset.TotalHours)); return DateTimeOffset.UtcNow.AddHours(num).ToString(text, CultureInfo.InvariantCulture); } private static string ResolveValue(string value) { if (!value.StartsWith("<", StringComparison.OrdinalIgnoreCase)) { return value; } if (!value.EndsWith(">", StringComparison.OrdinalIgnoreCase)) { return value; } if (TryGetValueFromGroup(value.Substring(1, value.Length - 2), out string value2)) { return value2; } return value; } private static bool TryGetValueFromGroup(string group, out string value) { int stableHashCode = StringExtensionMethods.GetStableHashCode(group.ToLowerInvariant()); if (!DataLoading.ValueGroups.ContainsKey(stableHashCode)) { value = group; return false; } int index = Random.Range(0, DataLoading.ValueGroups[stableHashCode].Count); value = ResolveValue(DataLoading.ValueGroups[stableHashCode][index]); return true; } } public class PrefabHelper { private static readonly Dictionary> ResultCache = new Dictionary>(); private static Dictionary PrefabCache = new Dictionary(); public static void ClearCache() { ResultCache.Clear(); PrefabCache.Clear(); } public static List GetPrefabs(string include, string exclude) { string key = include + "|" + exclude; if (ResultCache.ContainsKey(key)) { return ResultCache[key]; } List includes = Parse.ToList(include); List excludes = ((exclude == "") ? null : Parse.ToList(exclude)); List prefabs = GetPrefabs(includes, excludes); if (prefabs == null) { return new List(); } ResultCache[key] = prefabs; return prefabs; } public static List? GetPrefabs(List includes, List? excludes) { if (includes.Count == 0) { return null; } HashSet excludedPrefabs = null; if (excludes != null && excludes.Count > 0) { excludedPrefabs = (from s in excludes.Select(ParsePrefabs) where s != null select s).SelectMany((List s) => s).ToHashSet(); } if (includes.Count == 1) { List list = ParsePrefabs(includes[0]); if (list == null) { return null; } if (excludedPrefabs != null) { List list2 = new List(); list2.AddRange(list.Where((int i) => !excludedPrefabs.Contains(i))); list = list2; } return list; } List> list3 = (from s in includes.Select(ParsePrefabs) where s != null select s).ToList(); HashSet hashSet = new HashSet(); foreach (List item in list3) { if (item == null) { continue; } foreach (int item2 in item) { if (excludedPrefabs == null || !excludedPrefabs.Contains(item2)) { hashSet.Add(item2); } } } if (hashSet.Count != 0) { HashSet hashSet2 = hashSet; List list4 = new List(hashSet2.Count); list4.AddRange(hashSet2); return list4; } return null; } private static List? ParsePrefabs(string prefab) { string p = prefab.ToLowerInvariant(); if (PrefabCache.Count == 0) { PrefabCache = ZNetScene.instance.m_namedPrefabs.ToDictionary((KeyValuePair pair) => ((Object)pair.Value).name, (KeyValuePair pair) => pair.Key); } if (p == "*") { Dictionary.ValueCollection values = PrefabCache.Values; List list = new List(values.Count); list.AddRange(values); return list; } if (p[0] == '*' && p[p.Length - 1] == '*') { p = p.Substring(1, p.Length - 2); List list2 = new List(); list2.AddRange(from pair in PrefabCache where Contains(pair, p) select pair.Value); return list2; } if (p[0] == '*') { p = p.Substring(1); List list3 = new List(); list3.AddRange(from pair in PrefabCache where EndsWith(pair, p) select pair.Value); return list3; } if (p[p.Length - 1] == '*') { p = p.Substring(0, p.Length - 1); List list4 = new List(); list4.AddRange(from pair in PrefabCache where StartsWith(pair, p) select pair.Value); return list4; } int num = p.IndexOf('*'); if (num > 0 && num < p.Length - 1) { string prefix = p.Substring(0, num); string suffix = p.Substring(num + 1); List list5 = new List(); list5.AddRange(from pair in PrefabCache where Contained(pair, prefix, suffix) select pair.Value); return list5; } if (PrefabCache.ContainsKey(prefab)) { return new List(1) { PrefabCache[prefab] }; } List valuesFromGroup = DataHelper.GetValuesFromGroup(prefab); if (valuesFromGroup != null) { List list6 = new List(); list6.AddRange(valuesFromGroup.Select((string s) => StringExtensionMethods.GetStableHashCode(s))); return list6; } Log.Warning("Failed to resolve prefab: " + prefab); return null; } private static bool Contains(KeyValuePair pair, string prefab) { return pair.Key.ToLowerInvariant().Contains(prefab.ToString()); } private static bool StartsWith(KeyValuePair pair, string prefab) { return pair.Key.StartsWith(prefab, StringComparison.OrdinalIgnoreCase); } private static bool EndsWith(KeyValuePair pair, string prefab) { return pair.Key.EndsWith(prefab, StringComparison.OrdinalIgnoreCase); } private static bool Contained(KeyValuePair pair, string start, string end) { if (pair.Key.StartsWith(start, StringComparison.OrdinalIgnoreCase)) { return pair.Key.EndsWith(end, StringComparison.OrdinalIgnoreCase); } return false; } } public class BoolValue : AnyValue, IBoolValue { public BoolValue(string[] values) : base(values) { } public int? GetInt(Parameters pars) { string value = GetValue(pars); if (value == null) { return null; } return (value == "true") ? 1 : 0; } public bool? GetBool(Parameters pars) { string value = GetValue(pars); if (value == null) { return null; } return value == "true"; } public bool? Match(Parameters pars, bool value) { bool flag = true; string[] values = Values; foreach (string str in values) { string text = pars.Replace(str); if (text != null) { flag = false; if (text == "true" == value) { return true; } } } if (!flag) { return false; } return null; } } public class SimpleBoolValue : IBoolValue { private readonly bool Value; public SimpleBoolValue(bool value) { Value = value; base..ctor(); } public int? GetInt(Parameters pars) { return Value ? 1 : 0; } public bool? GetBool(Parameters pars) { return Value; } public bool? Match(Parameters pars, bool value) { return Value == value; } } public interface IBoolValue { int? GetInt(Parameters pars); bool? GetBool(Parameters pars); bool? Match(Parameters pars, bool value); } public class BytesValue : AnyValue, IBytesValue { public BytesValue(string[] values) : base(values) { } public byte[]? Get(Parameters pars) { string value = GetValue(pars); if (value == null || value == "") { return null; } try { return Convert.FromBase64String(value); } catch (FormatException) { return null; } } public bool? Match(Parameters pars, byte[]? value) { bool flag = true; string[] values = Values; foreach (string str in values) { string text = pars.Replace(str); if (text == null) { continue; } flag = false; if (text == "" && value == null) { return true; } if (text == "" || value == null) { continue; } try { if (Convert.FromBase64String(text).SequenceEqual(value)) { return true; } } catch (FormatException) { } } if (!flag) { return false; } return null; } } public class SimpleBytesValue : IBytesValue { private readonly byte[]? Value; public SimpleBytesValue(byte[]? value) { Value = value; base..ctor(); } public byte[]? Get(Parameters pars) { return Value; } public bool? Match(Parameters pars, byte[]? value) { if (Value == null && value == null) { return true; } if (Value == null || value == null) { return false; } return Value.SequenceEqual(value); } } public interface IBytesValue { byte[]? Get(Parameters pars); bool? Match(Parameters pars, byte[]? value); } public class FloatValue : AnyValue, IFloatValue { public FloatValue(string[] values) : base(values) { } public float? Get(Parameters pars) { string value = GetValue(pars); if (value == null) { return null; } if (!value.Contains(";")) { return Calculator.EvaluateFloat(value); } string[] array = value.Split(new char[1] { ';' }); if (array.Length < 2) { throw new InvalidOperationException("Invalid range format: " + value); } float? num = Calculator.EvaluateFloat(array[0]); float? num2 = Calculator.EvaluateFloat(array[1]); if (!num.HasValue || !num2.HasValue) { return null; } float? num3; if (array.Length < 3 || array[2] == "") { num3 = Random.Range(num.Value, num2.Value); } else { float? num4 = Calculator.EvaluateFloat(array[2]); if (!num4.HasValue) { num3 = Random.Range(num.Value, num2.Value); } else { int num5 = (int)((num2.Value - num.Value) / num4.Value); int num6 = Random.Range(0, num5 + 1); num3 = num + (float)num6 * num4; } } if (array.Length < 4) { return num3; } return Calculator.EvaluateFloat(array[3].Replace("", num3?.ToString(CultureInfo.InvariantCulture))); } public bool TryGet(Parameters pars, out float value) { float? num = Get(pars); if (num.HasValue) { value = num.Value; } else { value = 0f; } return num.HasValue; } public bool? Match(Parameters pars, float value) { bool flag = true; string[] values = Values; foreach (string str in values) { string text = pars.Replace(str); if (!text.Contains(";")) { float? num = Calculator.EvaluateFloat(text); if (num.HasValue) { flag = false; if (Helper.Approx(num.Value, value)) { return true; } } continue; } string[] array = text.Split(new char[1] { ';' }); if (array.Length < 2) { throw new InvalidOperationException("Invalid range format: " + text); } float? num2 = Calculator.EvaluateFloat(array[0]); float? num3 = Calculator.EvaluateFloat(array[1]); if (!num2.HasValue || !num3.HasValue) { continue; } if (array.Length < 3) { flag = false; if (Helper.ApproxBetween(value, num2.Value, num3.Value)) { return true; } continue; } if (array.Length < 4) { float? num4 = Calculator.EvaluateFloat(array[2]); if (!num4.HasValue) { continue; } flag = false; int num5 = (int)((num3.Value - num2.Value) / num4.Value); for (int j = 0; j <= num5; j++) { if (Helper.Approx(num2.Value + (float)j * num4.Value, value)) { return true; } } continue; } if (array[2] == "") { float? num6 = Calculator.EvaluateFloat(array[3].Replace("", num2?.ToString(CultureInfo.InvariantCulture))); float? num7 = Calculator.EvaluateFloat(array[3].Replace("", num3?.ToString(CultureInfo.InvariantCulture))); if (num6.HasValue && num7.HasValue) { flag = false; if (Helper.ApproxBetween(value, num6.Value, num7.Value)) { return true; } } continue; } float? num8 = Calculator.EvaluateFloat(array[2]); if (!num8.HasValue) { continue; } flag = false; int num9 = (int)((num3.Value - num2.Value) / num8.Value); for (int k = 0; k <= num9; k++) { float? num10 = num2; float num11 = k; float? num12 = num8; float? num13 = Calculator.EvaluateFloat(array[3].Replace("", (num10 + num11 * num12)?.ToString(CultureInfo.InvariantCulture))); if (num13.HasValue && Helper.Approx(num13.Value, value)) { return true; } } } if (!flag) { return false; } return null; } } public class SimpleFloatValue : IFloatValue { private readonly float Value; public SimpleFloatValue(float value) { Value = value; base..ctor(); } public float? Get(Parameters pars) { return Value; } public bool TryGet(Parameters pars, out float value) { value = Value; return true; } public bool? Match(Parameters pars, float value) { return Value == value; } } public interface IFloatValue { float? Get(Parameters pars); bool TryGet(Parameters pars, out float value); bool? Match(Parameters pars, float value); } public class HashValue : AnyValue, IHashValue { public HashValue(string[] values) : base(values) { } public int? Get(Parameters pars) { string value = GetValue(pars); if (value == null || value == "") { return null; } return StringExtensionMethods.GetStableHashCode(value); } public bool? Match(Parameters pars, int value) { List allValues = GetAllValues(pars); if (allValues.Count == 0) { return null; } return allValues.Any((string v) => StringExtensionMethods.GetStableHashCode(v) == value); } } public class SimpleHashValue : IHashValue { private readonly int Value = StringExtensionMethods.GetStableHashCode(value); public SimpleHashValue(string value) { } public int? Get(Parameters pars) { return Value; } public bool? Match(Parameters pars, int value) { return Value == value; } } public interface IHashValue { int? Get(Parameters pars); bool? Match(Parameters pars, int value); } public class IntValue : AnyValue, IIntValue { public IntValue(string[] values) : base(values) { } public int? Get(Parameters pars) { string value = GetValue(pars); if (value == null) { return null; } if (!value.Contains(";")) { return Calculator.EvaluateInt(value); } string[] array = value.Split(new char[1] { ';' }); if (array.Length < 2) { throw new InvalidOperationException("Invalid range format: " + value); } int? num = Calculator.EvaluateInt(array[0]); int? num2 = Calculator.EvaluateInt(array[1]); if (!num.HasValue || !num2.HasValue) { return null; } int? result; if (array.Length < 3 || array[2] == "") { result = Random.Range(num.Value, num2.Value + 1); } else { int? num3 = Calculator.EvaluateInt(array[2]); if (!num3.HasValue) { result = Random.Range(num.Value, num2.Value + 1); } else { int num4 = Random.Range(0, ((num2 - num) / num3).Value + 1); result = num + num4 * num3; } } if (array.Length < 4) { return result; } return Calculator.EvaluateInt(array[3].Replace("", result.ToString())); } public bool? Match(Parameters pars, int value) { bool flag = true; string[] values = Values; foreach (string str in values) { string text = pars.Replace(str); if (!text.Contains(";")) { int? num = Calculator.EvaluateInt(text); if (num.HasValue) { flag = false; if (num.Value == value) { return true; } } continue; } string[] array = text.Split(new char[1] { ';' }); if (array.Length < 2) { throw new InvalidOperationException("Invalid range format: " + text); } int? num2 = Calculator.EvaluateInt(array[0]); int? num3 = Calculator.EvaluateInt(array[1]); if (!num2.HasValue || !num3.HasValue) { continue; } if (array.Length < 3) { flag = false; if (value >= num2.Value && value <= num3.Value) { return true; } continue; } if (array.Length < 4) { int? num4 = Calculator.EvaluateInt(array[2]); if (!num4.HasValue) { continue; } flag = false; int num5 = (num3.Value - num2.Value) / num4.Value; for (int j = 0; j <= num5; j++) { if (num2.Value + j * num4.Value == value) { return true; } } continue; } if (array[2] == "") { int? num6 = Calculator.EvaluateInt(array[3].Replace("", num2?.ToString(CultureInfo.InvariantCulture))); int? num7 = Calculator.EvaluateInt(array[3].Replace("", num3?.ToString(CultureInfo.InvariantCulture))); if (num6.HasValue && num7.HasValue) { flag = false; if (value >= num6.Value && value <= num7.Value) { return true; } } continue; } int? num8 = Calculator.EvaluateInt(array[2]); if (!num8.HasValue) { continue; } flag = false; int num9 = (num3.Value - num2.Value) / num8.Value; for (int k = 0; k <= num9; k++) { int? num10 = num2; int num11 = k; int? num12 = num8; int? num13 = Calculator.EvaluateInt(array[3].Replace("", (num10 + num11 * num12)?.ToString(CultureInfo.InvariantCulture))); if (num13.HasValue && num13.Value == value) { return true; } } } if (!flag) { return false; } return null; } } public class SimpleIntValue : IIntValue { private readonly int Value; public SimpleIntValue(int value) { Value = value; base..ctor(); } public int? Get(Parameters pars) { return Value; } public bool? Match(Parameters pars, int value) { return Value == value; } } public interface IIntValue { int? Get(Parameters pars); bool? Match(Parameters pars, int value); } public class LongValue : AnyValue, ILongValue { public LongValue(string[] values) : base(values) { } public long? Get(Parameters pars) { string value = GetValue(pars); if (value == null) { return null; } if (!value.Contains(";")) { return Calculator.EvaluateLong(value); } string[] array = value.Split(new char[1] { ';' }); if (array.Length < 2) { throw new InvalidOperationException("Invalid range format: " + value); } long? num = Calculator.EvaluateLong(array[0]); long? num2 = Calculator.EvaluateLong(array[1]); if (!num.HasValue || !num2.HasValue) { return null; } long? result; if (array.Length < 3 || array[2] == "") { result = (long)(Random.value * (float)(num2.Value - num.Value) + (float)num.Value); } else { long? num3 = Calculator.EvaluateLong(array[2]); if (!num3.HasValue) { result = (long)(Random.value * (float)(num2.Value - num.Value) + (float)num.Value); } else { float num4 = Random.Range(0f, (float)(((num2 - num) / num3).Value + 1)); result = (long?)((float?)num + num4 * (float?)num3); } } if (array.Length < 4) { return result; } return Calculator.EvaluateLong(array[3].Replace("", result.ToString())); } public bool? Match(Parameters pars, long value) { bool flag = true; string[] values = Values; foreach (string str in values) { string text = pars.Replace(str); if (!text.Contains(";")) { long? num = Calculator.EvaluateLong(text); if (num.HasValue) { flag = false; if (num.Value == value) { return true; } } continue; } string[] array = text.Split(new char[1] { ';' }); if (array.Length < 2) { throw new InvalidOperationException("Invalid range format: " + text); } long? num2 = Calculator.EvaluateLong(array[0]); long? num3 = Calculator.EvaluateLong(array[1]); if (!num2.HasValue || !num3.HasValue) { continue; } if (array.Length < 3) { flag = false; if (value >= num2.Value && value <= num3.Value) { return true; } continue; } if (array.Length < 4) { long? num4 = Calculator.EvaluateLong(array[2]); if (!num4.HasValue) { continue; } flag = false; long num5 = (num3.Value - num2.Value) / num4.Value; for (int j = 0; j <= num5; j++) { if (num2.Value + j * num4.Value == value) { return true; } } continue; } if (array[2] == "") { long? num6 = Calculator.EvaluateLong(array[3].Replace("", num2?.ToString(CultureInfo.InvariantCulture))); long? num7 = Calculator.EvaluateLong(array[3].Replace("", num3?.ToString(CultureInfo.InvariantCulture))); if (num6.HasValue && num7.HasValue) { flag = false; if (value >= num6.Value && value <= num7.Value) { return true; } } continue; } long? num8 = Calculator.EvaluateLong(array[2]); if (!num8.HasValue) { continue; } flag = false; long num9 = (num3.Value - num2.Value) / num8.Value; for (int k = 0; k <= num9; k++) { long? num10 = num2; long num11 = k; long? num12 = num8; long? num13 = Calculator.EvaluateLong(array[3].Replace("", (num10 + num11 * num12)?.ToString(CultureInfo.InvariantCulture))); if (num13.HasValue && num13.Value == value) { return true; } } } if (!flag) { return false; } return null; } } public class SimpleLongValue : ILongValue { private readonly long Value; public SimpleLongValue(long value) { Value = value; base..ctor(); } public long? Get(Parameters pars) { return Value; } public bool? Match(Parameters pars, long value) { return Value == value; } } public interface ILongValue { long? Get(Parameters pars); bool? Match(Parameters pars, long value); } public class PrefabValue : AnyValue, IPrefabValue { private List? Cache; private Parameters? LastParameters; public PrefabValue(string[] values) : base(values) { } public int? Get(Parameters pars) { if (pars != LastParameters) { List allValues = GetAllValues(pars); Cache = PrefabHelper.GetPrefabs(allValues, null); LastParameters = pars; } if (Cache == null || Cache.Count == 0) { return null; } if (Cache.Count == 1) { return Cache[0]; } return Cache[Random.Range(0, Cache.Count)]; } public bool? Match(Parameters pars, int value) { if (pars != LastParameters) { List allValues = GetAllValues(pars); Cache = PrefabHelper.GetPrefabs(allValues, null); LastParameters = pars; } if (Cache == null || Cache.Count == 0) { return null; } return Cache.Contains(value); } } public class SimplePrefabsValue : IPrefabValue { private readonly List Values; public SimplePrefabsValue(List value) { Values = value; base..ctor(); } public int? Get(Parameters pars) { return RollValue(); } public bool? Match(Parameters pars, int value) { return Values.Contains(value); } private int RollValue() { return Values[Random.Range(0, Values.Count)]; } } public class SimplePrefabValue : IPrefabValue { private readonly int? Value; public SimplePrefabValue(int? value) { Value = value; base..ctor(); } public int? Get(Parameters pars) { return Value; } public bool? Match(Parameters pars, int value) { return Value == value; } } public interface IPrefabValue { int? Get(Parameters pars); bool? Match(Parameters pars, int value); } public class QuaternionValue : AnyValue, IQuaternionValue { public QuaternionValue(string[] values) : base(values) { } public Quaternion? Get(Parameters pars) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) string value = GetValue(pars); if (value != null) { return Calculator.EvaluateQuaternion(value); } return null; } public bool? Match(Parameters pars, Quaternion 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) List allValues = GetAllValues(pars); if (allValues.Count == 0) { return null; } return allValues.Any(delegate(string v) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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) Quaternion? val = Parse.AngleYXZNull(v); Quaternion val2 = value; return val.HasValue && val.GetValueOrDefault() == val2; }); } } public class SimpleQuaternionValue : IQuaternionValue { private readonly Quaternion Value; public SimpleQuaternionValue(Quaternion value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) Value = value; base..ctor(); } public Quaternion? Get(Parameters pars) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return Value; } public bool? Match(Parameters pars, Quaternion value) { //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 Value == value; } } public interface IQuaternionValue { Quaternion? Get(Parameters pars); bool? Match(Parameters pars, Quaternion value); } public class StringValue : AnyValue, IStringValue { private readonly bool IsPattern = values.Any((string v) => v.Contains("*")); public StringValue(string[] values) : base(values) { } public string? Get(Parameters pars) { return GetValue(pars); } public string? GetWhole(Parameters pars) { return GetWholeValue(pars); } public bool? Match(Parameters pars, string value) { string value2 = value; List allValues = GetAllValues(pars); if (allValues.Count == 0) { return null; } return IsPattern ? allValues.Any((string v) => SimpleStringValue.PatternMatch(value2, v)) : allValues.Contains(value2); } } public class SimpleStringValue : IStringValue { private readonly string Value; private readonly bool IsPattern; public SimpleStringValue(string value) { Value = value; IsPattern = value.Contains("*"); base..ctor(); } public string? Get(Parameters pars) { return Value; } public string? GetWhole(Parameters pars) { return Value; } public bool? Match(Parameters pars, string value) { return IsPattern ? PatternMatch(value, Value) : (Value == value); } public static bool PatternMatch(string value, string pattern) { if (value == pattern) { return true; } if (pattern == "") { return false; } if (pattern[0] == '*' && pattern[pattern.Length - 1] == '*') { return value.Contains(pattern.Substring(1, pattern.Length - 2)); } if (pattern[0] == '*') { return value.EndsWith(pattern.Substring(1), StringComparison.Ordinal); } if (pattern[pattern.Length - 1] == '*') { return value.StartsWith(pattern.Substring(0, pattern.Length - 1), StringComparison.Ordinal); } int num = pattern.IndexOf('*'); if (num > 0 && num < pattern.Length - 1) { string value2 = pattern.Substring(0, num); string value3 = pattern.Substring(num + 1); if (value.StartsWith(value2, StringComparison.Ordinal)) { return value.EndsWith(value3, StringComparison.Ordinal); } return false; } return false; } } public interface IStringValue { string? Get(Parameters pars); string? GetWhole(Parameters pars); bool? Match(Parameters pars, string value); } public class Vector3Value : AnyValue, IVector3Value { public Vector3Value(string[] values) : base(values) { } public Vector3? Get(Parameters pars) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) string value = GetValue(pars); if (value != null) { return Calculator.EvaluateVector3(value); } return null; } public bool? Match(Parameters pars, 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) List allValues = GetAllValues(pars); if (allValues.Count == 0) { return null; } return allValues.Any(delegate(string v) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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) Vector3? val = Parse.VectorXZYNull(v); Vector3 val2 = value; return val.HasValue && val.GetValueOrDefault() == val2; }); } } public class SimpleVector3Value : IVector3Value { private readonly Vector3 Value; public SimpleVector3Value(Vector3 value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) Value = value; base..ctor(); } public Vector3? Get(Parameters pars) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return Value; } public bool? Match(Parameters pars, Vector3 value) { //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 Value == value; } } public interface IVector3Value { Vector3? Get(Parameters pars); bool? Match(Parameters pars, Vector3 value); } public class ZdoIdValue : AnyValue, IZdoIdValue { public ZdoIdValue(string[] values) : base(values) { } public ZDOID? Get(Parameters pars) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) string value = GetValue(pars); if (value == null) { return null; } return Parse.ZdoId(value); } public bool? Match(Parameters pars, ZDOID 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) List allValues = GetAllValues(pars); if (allValues.Count == 0) { return null; } return allValues.Any((string v) => Parse.ZdoId(v) == value); } } public class SimpleZdoIdValue : IZdoIdValue { private readonly ZDOID Value; public SimpleZdoIdValue(ZDOID value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) Value = value; base..ctor(); } public ZDOID? Get(Parameters pars) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return Value; } public bool? Match(Parameters pars, ZDOID value) { //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 Value == value; } } public interface IZdoIdValue { ZDOID? Get(Parameters pars); bool? Match(Parameters pars, ZDOID value); } public class ZdoEntry { [CompilerGenerated] private int P; [CompilerGenerated] private Vector3 P; [CompilerGenerated] private ZDO P; public Dictionary? Strings; public Dictionary? Floats; public Dictionary? Ints; public Dictionary? Longs; public Dictionary? Vecs; public Dictionary? Quats; public Dictionary? ByteArrays; public ConnectionType? ConnectionType; public int ConnectionHash; public ZDOID? OriginalId; public ZDOID? TargetConnectionId; public Vector3 Rotation; public long Owner; public bool? Persistent; public bool? Distant; public ObjectType? Type; public ZdoEntry(int Prefab, Vector3 Position, Vector3 rotation, ZDO zdo) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) P = Prefab; P = Position; P = zdo; Rotation = rotation; Owner = P.GetOwner(); base..ctor(); } public ZdoEntry(ZDO zdo) : this(zdo.m_prefab, zdo.m_position, zdo.m_rotation, zdo) { }//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) public ZDO? Create() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) ZDO val = Spawn(P, P, Rotation, Owner); if (val == null) { return null; } Write(val); return val; } public static ZDO? Spawn(int prefab, Vector3 position, Vector3 rotation, long owner) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_006b: Unknown result type (might be due to invalid IL or missing references) if (prefab == 0) { return null; } GameObject prefab2 = ZNetScene.instance.GetPrefab(prefab); if (!Object.op_Implicit((Object)(object)prefab2)) { Log.Error($"Can't spawn missing prefab: {prefab}"); return null; } ZDO obj = ZDOMan.instance.CreateNewZDO(position, prefab); ZNetView component = prefab2.GetComponent(); obj.m_prefab = prefab; obj.m_rotation = rotation; obj.Persistent = component.m_persistent; obj.Distant = component.m_distant; obj.Type = component.m_type; DelayedOwner.Check(obj, owner); return obj; } public void Load(DataEntry data, Parameters pars) { //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_062b: Unknown result type (might be due to invalid IL or missing references) //IL_0622: Unknown result type (might be due to invalid IL or missing references) //IL_0630: Unknown result type (might be due to invalid IL or missing references) //IL_066b: Unknown result type (might be due to invalid IL or missing references) //IL_0670: Unknown result type (might be due to invalid IL or missing references) //IL_0674: Unknown result type (might be due to invalid IL or missing references) //IL_0693: Unknown result type (might be due to invalid IL or missing references) //IL_068a: Unknown result type (might be due to invalid IL or missing references) //IL_0698: Unknown result type (might be due to invalid IL or missing references) data.RollItems(pars, P); Dictionary? floats = data.Floats; if (floats != null && floats.Count > 0) { if (Floats == null) { Floats = new Dictionary(); } foreach (KeyValuePair @float in data.Floats) { float? num = @float.Value.Get(pars); if (num.HasValue) { Floats[@float.Key] = num.Value; } } } Dictionary? ints = data.Ints; if (ints != null && ints.Count > 0) { if (Ints == null) { Ints = new Dictionary(); } foreach (KeyValuePair int2 in data.Ints) { int? num2 = int2.Value.Get(pars); if (num2.HasValue) { Ints[int2.Key] = num2.Value; } } } Dictionary? longs = data.Longs; if (longs != null && longs.Count > 0) { if (Longs == null) { Longs = new Dictionary(); } foreach (KeyValuePair @long in data.Longs) { long? num3 = @long.Value.Get(pars); if (num3.HasValue) { Longs[@long.Key] = num3.Value; } } } Dictionary? strings = data.Strings; if (strings != null && strings.Count > 0) { if (Strings == null) { Strings = new Dictionary(); } foreach (KeyValuePair @string in data.Strings) { string text = @string.Value.Get(pars); if (text != null) { Strings[@string.Key] = text; } } } Dictionary? vecs = data.Vecs; if (vecs != null && vecs.Count > 0) { if (Vecs == null) { Vecs = new Dictionary(); } foreach (KeyValuePair vec in data.Vecs) { Vector3? val = vec.Value.Get(pars); if (val.HasValue) { Vecs[vec.Key] = val.Value; } } } Dictionary? quats = data.Quats; if (quats != null && quats.Count > 0) { if (Quats == null) { Quats = new Dictionary(); } foreach (KeyValuePair quat in data.Quats) { Quaternion? val2 = quat.Value.Get(pars); if (val2.HasValue) { Quats[quat.Key] = val2.Value; } } } Dictionary? byteArrays = data.ByteArrays; if (byteArrays != null && byteArrays.Count > 0) { if (ByteArrays == null) { ByteArrays = new Dictionary(); } foreach (KeyValuePair byteArray in data.ByteArrays) { byte[] array = byteArray.Value.Get(pars); if (array != null) { ByteArrays[byteArray.Key] = array; } } } Dictionary? bools = data.Bools; if (bools != null && bools.Count > 0) { if (Ints == null) { Ints = new Dictionary(); } foreach (KeyValuePair @bool in data.Bools) { int? @int = @bool.Value.GetInt(pars); if (@int.HasValue) { Ints[@bool.Key] = @int.Value; } } } Dictionary? hashes = data.Hashes; if (hashes != null && hashes.Count > 0) { if (Ints == null) { Ints = new Dictionary(); } foreach (KeyValuePair hash in data.Hashes) { int? num4 = hash.Value.Get(pars); if (num4.HasValue) { Ints[hash.Key] = num4.Value; } } } if (data.Components != null) { if (Ints == null) { Ints = new Dictionary(); } foreach (KeyValuePair component in data.Components) { int? num5 = component.Value.Get(pars); if (num5.HasValue) { Ints[component.Key] = num5.Value; } } } ConnectionHash = data.ConnectionHash; ConnectionType = data.ConnectionType; if (data.OriginalId != null) { OriginalId = data.OriginalId.Get(pars); } if (data.TargetConnectionId != null) { TargetConnectionId = data.TargetConnectionId.Get(pars); } Distant = data.Distant?.GetBool(pars); Persistent = data.Persistent?.GetBool(pars); Type = data.Priority; P = (Vector3)(((??)data.Position?.Get(pars)) ?? P); IQuaternionValue? rotation = data.Rotation; Vector3? obj; if (rotation == null) { obj = null; } else { Quaternion? val3 = rotation.Get(pars); if (!val3.HasValue) { obj = null; } else { Quaternion valueOrDefault = val3.GetValueOrDefault(); obj = ((Quaternion)(ref valueOrDefault)).eulerAngles; } } Rotation = (Vector3)(((??)obj) ?? Rotation); } public 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_0014: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: 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_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = zdo.m_uid; if (Floats != null) { ZDOHelper.Init(ZDOExtraData.s_floats, uid); foreach (KeyValuePair @float in Floats) { zdo.Set(@float.Key, @float.Value); } } if (Ints != null) { ZDOHelper.Init(ZDOExtraData.s_ints, uid); foreach (KeyValuePair @int in Ints) { zdo.Set(@int.Key, @int.Value, false); } } if (Longs != null) { ZDOHelper.Init(ZDOExtraData.s_longs, uid); foreach (KeyValuePair @long in Longs) { zdo.Set(@long.Key, @long.Value); } } if (Strings != null) { ZDOHelper.Init(ZDOExtraData.s_strings, uid); foreach (KeyValuePair @string in Strings) { zdo.Set(@string.Key, @string.Value); } } if (Vecs != null) { ZDOHelper.Init(ZDOExtraData.s_vec3, uid); foreach (KeyValuePair vec in Vecs) { zdo.Set(vec.Key, vec.Value); } } if (Quats != null) { ZDOHelper.Init(ZDOExtraData.s_quats, uid); foreach (KeyValuePair quat in Quats) { zdo.Set(quat.Key, quat.Value); } } if (ByteArrays != null) { ZDOHelper.Init(ZDOExtraData.s_byteArrays, uid); foreach (KeyValuePair byteArray in ByteArrays) { zdo.Set(byteArray.Key, byteArray.Value); } } zdo.m_position = P; zdo.SetSector(ZoneSystem.GetZone(P)); zdo.m_rotation = Rotation; if (Persistent.HasValue) { zdo.Persistent = Persistent.Value; } if (Distant.HasValue) { zdo.Distant = Distant.Value; } if (Type.HasValue) { zdo.Type = Type.Value; } HandleConnection(zdo); HandleHashConnection(zdo); } private void HandleConnection(ZDO ownZdo) { //IL_001d: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_005c: 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_0071: 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_00cf: 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_0085: Unknown result type (might be due to invalid IL or missing references) if (!OriginalId.HasValue || !ConnectionType.HasValue) { return; } ZDOID uid = ownZdo.m_uid; if (TargetConnectionId.HasValue) { ZDO zDO = ZDOMan.instance.GetZDO(TargetConnectionId.Value); if (zDO != null) { ownZdo.SetConnection(ConnectionType.Value, TargetConnectionId.Value); if (ConnectionType == (ConnectionType?)1) { zDO.SetConnection((ConnectionType)1, uid); } } return; } KeyValuePair keyValuePair = ZDOExtraData.s_connections.FirstOrDefault(delegate(KeyValuePair kvp) { //IL_0007: 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_001f: 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) ZDOID target = kvp.Value.m_target; ZDOID? originalId = OriginalId; return originalId.HasValue && target == originalId.GetValueOrDefault(); }); 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Invalid comparison between Unknown and I4 //IL_0066: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0090: 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_0098: Invalid comparison between Unknown and I4 //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Invalid comparison between Unknown and I4 //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Invalid comparison between Unknown and I4 //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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_00aa: 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_00d6: 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) if (ConnectionHash == 0 || !ConnectionType.HasValue) { return; } ZDOID uid = ownZdo.m_uid; ZDOExtraData.SetConnectionData(uid, ConnectionType.Value, ConnectionHash); ? val = ConnectionType.Value ^ 0x10; bool flag = (ConnectionType.Value & 0x10) == 0; ZDOID val2 = ((IEnumerable)ZDOExtraData.GetAllConnectionZDOIDs((ConnectionType)val)).FirstOrDefault((Func)((ZDOID z) => ZDOExtraData.GetConnectionHashData(z, ConnectionType.Value)?.m_hash == ConnectionHash)); if (val2 == ZDOID.None) { return; } ZDO zDO = ZDOMan.instance.GetZDO(val2); if (zDO != null) { if ((ConnectionType.Value & 3) > 0) { ZDO val3 = (ZDO)(flag ? ((object)ownZdo) : ((object)zDO)); ZDOID val4 = (flag ? val2 : uid); val3.SetConnection((ConnectionType)3, val4); } if ((ConnectionType.Value & 2) > 0) { ZDO val5 = (ZDO)(flag ? ((object)ownZdo) : ((object)zDO)); ZDOID val6 = (flag ? val2 : uid); val5.SetConnection((ConnectionType)2, val6); } if ((ConnectionType.Value & 1) > 0) { zDO.SetConnection((ConnectionType)1, uid); ownZdo.SetConnection((ConnectionType)1, val2); } } } } public static class ZdoHelper { private static readonly Dictionary HashCache = new Dictionary(); private static readonly Dictionary ReverseHashCache = new Dictionary(); private static readonly int InventoryWidthHash = Hash("Container.m_width"); private static readonly int InventoryHeightHash = Hash("Container.m_height"); public static string GetString(ZDO zdo, string value, string defaultValue) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) string result = default(string); if (!ZDOExtraData.s_strings.TryGetValue(zdo.m_uid, out var value2) || !value2.TryGetValue(Hash(value), ref result)) { return GetStringField(zdo.m_prefab, value, defaultValue); } return result; } public static float GetFloat(ZDO zdo, string value, string defaultValue) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) float result = default(float); if (!ZDOExtraData.s_floats.TryGetValue(zdo.m_uid, out var value2) || !value2.TryGetValue(Hash(value), ref result)) { return GetFloatField(zdo.m_prefab, value, defaultValue); } return result; } public static int GetInt(ZDO zdo, string value, string defaultValue) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) int result = default(int); if (!ZDOExtraData.s_ints.TryGetValue(zdo.m_uid, out var value2) || !value2.TryGetValue(Hash(value), ref result)) { return GetIntField(zdo.m_prefab, value, defaultValue); } return result; } public static long GetLong(ZDO zdo, string value, string defaultValue) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) long result = default(long); if (!ZDOExtraData.s_longs.TryGetValue(zdo.m_uid, out var value2) || !value2.TryGetValue(Hash(value), ref result)) { return GetLongField(zdo.m_prefab, value, defaultValue); } return result; } public static bool GetBool(ZDO zdo, string value, string defaultValue) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) int num = default(int); if (!ZDOExtraData.s_ints.TryGetValue(zdo.m_uid, out var value2) || !value2.TryGetValue(Hash(value), ref num)) { return GetBoolField(zdo.m_prefab, value, defaultValue); } return num > 0; } public static Vector3 GetVec(ZDO zdo, string value, string defaultValue) { //IL_0006: 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_0032: Unknown result type (might be due to invalid IL or missing references) Vector3 result = default(Vector3); if (!ZDOExtraData.s_vec3.TryGetValue(zdo.m_uid, out var value2) || !value2.TryGetValue(Hash(value), ref result)) { return GetVecField(zdo.m_prefab, value, defaultValue); } return result; } public static Quaternion GetQuaternion(ZDO zdo, string value, string defaultValue) { //IL_0006: 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_0032: Unknown result type (might be due to invalid IL or missing references) Quaternion result = default(Quaternion); if (!ZDOExtraData.s_quats.TryGetValue(zdo.m_uid, out var value2) || !value2.TryGetValue(Hash(value), ref result)) { return GetQuatField(zdo.m_prefab, value, defaultValue); } return result; } public static string? TryGetString(ZDO zdo, int value) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) string result = default(string); if (!ZDOExtraData.s_strings.TryGetValue(zdo.m_uid, out var value2) || !value2.TryGetValue(value, ref result)) { return TryGetStringField(zdo.m_prefab, value); } return result; } public static float? TryGetFloat(ZDO zdo, int value) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) float value3 = default(float); if (!ZDOExtraData.s_floats.TryGetValue(zdo.m_uid, out var value2) || !value2.TryGetValue(value, ref value3)) { return TryGetFloatField(zdo.m_prefab, value); } return value3; } public static int? TryGetInt(ZDO zdo, int value) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) int value3 = default(int); if (!ZDOExtraData.s_ints.TryGetValue(zdo.m_uid, out var value2) || !value2.TryGetValue(value, ref value3)) { return TryGetIntField(zdo.m_prefab, value); } return value3; } public static long? TryGetLong(ZDO zdo, int value) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) long value3 = default(long); if (!ZDOExtraData.s_longs.TryGetValue(zdo.m_uid, out var value2) || !value2.TryGetValue(value, ref value3)) { return TryGetLongField(zdo.m_prefab, value); } return value3; } public static bool? TryGetBool(ZDO zdo, int value) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) int num = default(int); if (!ZDOExtraData.s_ints.TryGetValue(zdo.m_uid, out var value2) || !value2.TryGetValue(value, ref num)) { return TryGetBoolField(zdo.m_prefab, value); } return num > 0; } public static Vector3? TryGetVec(ZDO zdo, int value) { //IL_0006: 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) Vector3 value3 = default(Vector3); if (!ZDOExtraData.s_vec3.TryGetValue(zdo.m_uid, out var value2) || !value2.TryGetValue(value, ref value3)) { return TryGetVecField(zdo.m_prefab, value); } return value3; } public static Quaternion? TryGetQuaternion(ZDO zdo, int value) { //IL_0006: 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) Quaternion value3 = default(Quaternion); if (!ZDOExtraData.s_quats.TryGetValue(zdo.m_uid, out var value2) || !value2.TryGetValue(value, ref value3)) { return TryGetQuatField(zdo.m_prefab, value); } return value3; } private static string GetStringField(int prefabHash, string value, string defaultValue) { if (!(GetField(prefabHash, value) is string result)) { return defaultValue; } return result; } private static float GetFloatField(int prefabHash, string value, string defaultValue) { object field = GetField(prefabHash, value); if (field is float) { return (float)field; } return Parse.Float(defaultValue); } private static int GetIntField(int prefabHash, string value, string defaultValue) { object field = GetField(prefabHash, value); if (field is int) { return (int)field; } return Parse.Int(defaultValue); } private static bool GetBoolField(int prefabHash, string value, string defaultValue) { object field = GetField(prefabHash, value); if (field is bool) { return (bool)field; } return Parse.Boolean(defaultValue); } private static long GetLongField(int prefabHash, string value, string defaultValue) { object field = GetField(prefabHash, value); if (field is long) { return (long)field; } return Parse.Long(defaultValue, 0L); } private static Vector3 GetVecField(int prefabHash, string value, string defaultValue) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) object field = GetField(prefabHash, value); if (field is Vector3) { return (Vector3)field; } return Parse.VectorXZY(defaultValue); } private static Quaternion GetQuatField(int prefabHash, string value, string defaultValue) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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) object field = GetField(prefabHash, value); if (field is Quaternion) { return (Quaternion)field; } return Parse.AngleYXZ(defaultValue); } private static string? TryGetStringField(int prefabHash, int value) { if (!(GetField(prefabHash, ReverseHash(value)) is string result)) { return null; } return result; } private static float? TryGetFloatField(int prefabHash, int value) { object field = GetField(prefabHash, ReverseHash(value)); if (!(field is float)) { return null; } return (float)field; } private static int? TryGetIntField(int prefabHash, int value) { object field = GetField(prefabHash, ReverseHash(value)); if (!(field is int)) { return null; } return (int)field; } private static bool? TryGetBoolField(int prefabHash, int value) { object field = GetField(prefabHash, ReverseHash(value)); if (!(field is bool)) { return null; } return (bool)field; } private static long? TryGetLongField(int prefabHash, int value) { object field = GetField(prefabHash, ReverseHash(value)); if (!(field is long)) { return null; } return (long)field; } private static Vector3? TryGetVecField(int prefabHash, int value) { //IL_0016: 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_0028: Unknown result type (might be due to invalid IL or missing references) object field = GetField(prefabHash, ReverseHash(value)); if (!(field is Vector3)) { return null; } return (Vector3)field; } private static Quaternion? TryGetQuatField(int prefabHash, int value) { //IL_0016: 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_0028: Unknown result type (might be due to invalid IL or missing references) object field = GetField(prefabHash, ReverseHash(value)); if (!(field is Quaternion)) { return null; } return (Quaternion)field; } private static object? GetField(int prefabHash, string value) { KeyValuePair keyValuePair = Parse.Kvp(value, '.'); if (keyValuePair.Value == "") { return null; } GameObject prefab = ZNetScene.instance.GetPrefab(prefabHash); if ((Object)(object)prefab == (Object)null) { return null; } Component val = FindComponent(prefab, keyValuePair.Key); if ((Object)(object)val == (Object)null) { return null; } string[] array = keyValuePair.Value.Split(new char[1] { '.' }); object obj = val; string[] array2 = array; foreach (string name in array2) { FieldInfo field = obj.GetType().GetField(name); if (field == null) { return null; } obj = field.GetValue(obj); if (obj == null) { return null; } } GameObject val2 = (GameObject)((obj is GameObject) ? obj : null); if (val2 != null) { return ((Object)val2).name; } ItemDrop val3 = (ItemDrop)((obj is ItemDrop) ? obj : null); if (val3 != null) { return ((Object)((Component)val3).gameObject).name; } return obj; } private static Component? FindComponent(GameObject obj, string name) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) obj.GetComponentsInChildren(ZNetView.m_tempComponents); foreach (MonoBehaviour tempComponent in ZNetView.m_tempComponents) { if (((object)tempComponent).GetType().Name == name) { return (Component?)(object)tempComponent; } } foreach (Transform item in obj.transform) { Component val = FindComponent(((Component)item).gameObject, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } public static int Hash(string key) { if (HashCache.TryGetValue(key, out var value)) { return value; } value = HashKey(key); HashCache[key] = value; ReverseHashCache[value] = key; return value; } private static int HashKey(string key) { if (Parse.TryInt(key, out var result)) { return result; } if (key.StartsWith("$", StringComparison.InvariantCultureIgnoreCase)) { int hash = ZSyncAnimation.GetHash(key.Substring(1)); if (key == "$anim_speed") { return hash; } return 438569 + hash; } return StringExtensionMethods.GetStableHashCode(key); } public static string ReverseHash(int hash) { if (!ReverseHashCache.TryGetValue(hash, out string value)) { return hash.ToString(CultureInfo.InvariantCulture); } return value; } public static Vector2i GetInventorySize(DataEntry entry, Parameters parameters, ZDO zdo) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) int num = 0; int num2 = 0; Dictionary? ints = entry.Ints; if (ints != null && ints.TryGetValue(InventoryWidthHash, out IIntValue value)) { num = value.Get(parameters).GetValueOrDefault(); } Dictionary? ints2 = entry.Ints; if (ints2 != null && ints2.TryGetValue(InventoryHeightHash, out IIntValue value2)) { num2 = value2.Get(parameters).GetValueOrDefault(); } if (num > 0 && num2 > 0) { return new Vector2i(num, num2); } if (num <= 0) { num = zdo.GetInt(InventoryWidthHash, 0); } if (num2 <= 0) { num2 = zdo.GetInt(InventoryHeightHash, 0); } if (num > 0 && num2 > 0) { return new Vector2i(num, num2); } Container componentInChildren = ZNetScene.instance.GetPrefab(zdo.GetPrefab()).GetComponentInChildren(); if (Object.op_Implicit((Object)(object)componentInChildren)) { if (num <= 0) { num = componentInChildren.m_width; } if (num2 <= 0) { num2 = componentInChildren.m_height; } } if (num <= 0) { num = 4; } if (num2 <= 0) { num2 = 2; } return new Vector2i(num, num2); } } } namespace Service { public class DataStorage { private static Dictionary Database = new Dictionary(); private static readonly Stopwatch LastSaveStopwatch = Stopwatch.StartNew(); private static readonly string SavedDataFile = Path.Combine(Yaml.BaseDirectory, "ewp_data.yaml"); private static bool UnsavedChanges = false; public static Action? OnSet; public static void LoadSavedData() { if (!Directory.Exists(Yaml.BaseDirectory)) { Directory.CreateDirectory(Yaml.BaseDirectory); } if (!File.Exists(SavedDataFile)) { return; } foreach (KeyValuePair item in Yaml.DeserializeData(File.ReadAllText(SavedDataFile))) { Database[item.Key.ToLowerInvariant()] = item.Value; } Log.Info($"Reloaded saved data ({Database.Count} entries)."); } public static void SaveSavedData() { if (UnsavedChanges && !(LastSaveStopwatch.Elapsed.TotalSeconds < 10.0)) { UnsavedChanges = false; LastSaveStopwatch.Restart(); if (!Directory.Exists(Yaml.BaseDirectory)) { Directory.CreateDirectory(Yaml.BaseDirectory); } string contents = Yaml.SerializeData(Database); File.WriteAllText(SavedDataFile, contents); } } public static string GetValue(string key, string defaultValue = "") { if (!Database.TryGetValue(key.ToLowerInvariant(), out string value)) { return defaultValue; } return value; } public static bool TryGetValue(string key, out string value) { return Database.TryGetValue(key.ToLowerInvariant(), out value); } public static void SetValue(string key, string value) { if (!(key == "")) { key = key.ToLowerInvariant(); int num = key.IndexOf('*'); if (num < 0) { SetValueSub(key, value); } else { SetValues(MatchKeys(key, num), value); } } } public static string IncrementValue(string key, long amount) { if (key == "") { return "0"; } key = key.ToLowerInvariant(); int num = key.IndexOf('*'); if (num < 0) { long num2 = Parse.Long(GetValue(key, "0"), 0L) + amount; SetValueSub(key, num2.ToString()); return num2.ToString(); } foreach (string item in MatchKeys(key, num)) { if (Database.TryGetValue(item, out string value)) { SetValueSub(item, (Parse.Long(value, 0L) + amount).ToString()); } } return "0"; } private static List MatchKeys(string key, int wildIndex) { string key2 = key; if (key2 == "*") { Dictionary.KeyCollection keys = Database.Keys; List list = new List(keys.Count); list.AddRange(keys); return list; } if (key2[0] == '*' && key2[key2.Length - 1] == '*') { List list2 = new List(); list2.AddRange(Database.Keys.Where((string k) => k.Contains(key2.Substring(1, key2.Length - 2)))); return list2; } if (key2[0] == '*') { List list3 = new List(); list3.AddRange(Database.Keys.Where((string k) => k.EndsWith(key2.Substring(1), StringComparison.OrdinalIgnoreCase))); return list3; } if (key2[key2.Length - 1] == '*') { List list4 = new List(); list4.AddRange(Database.Keys.Where((string k) => k.StartsWith(key2.Substring(0, key2.Length - 1), StringComparison.OrdinalIgnoreCase))); return list4; } if (wildIndex > 0 && wildIndex < key2.Length - 1) { string prefix = key2.Substring(0, wildIndex); string suffix = key2.Substring(wildIndex + 1); List list5 = new List(); list5.AddRange(Database.Keys.Where((string k) => k.StartsWith(prefix, StringComparison.OrdinalIgnoreCase) && k.EndsWith(suffix, StringComparison.OrdinalIgnoreCase))); return list5; } return new List(); } public static void SetValues(List keys, string value) { foreach (string key in keys) { SetValueSub(key, value); } } private static void SetValueSub(string key, string value) { if ((!(value == "") || Database.ContainsKey(key)) && (!Database.TryGetValue(key, out string value2) || !(value2 == value))) { if (value == "") { Database.Remove(key); } else { Database[key] = value; } UnsavedChanges = true; OnSet?.Invoke(key, value); } } public static bool HasAnyKey(List keys, Parameters pars) { foreach (string key in keys) { KeyValuePair keyValuePair = Parse.Kvp(key.Contains("<") ? pars.Replace(key) : key, ' '); string text = keyValuePair.Key.ToLowerInvariant(); if (text == "") { continue; } IIntValue intValue = ((keyValuePair.Value == "") ? null : DataValue.Int(keyValuePair.Value)); int num = text.IndexOf('*'); string value2; if (num >= 0) { List list = MatchKeys(text, num); if (list.Count == 0) { return false; } foreach (string item in list) { if (Database.TryGetValue(item, out string value) && (intValue == null || value == keyValuePair.Value)) { return true; } } } else if (Database.TryGetValue(text, out value2) && (intValue == null || value2 == keyValuePair.Value)) { return true; } } return false; } public static bool HasEveryKey(List keys, Parameters pars) { foreach (string key in keys) { KeyValuePair keyValuePair = Parse.Kvp(key.Contains("<") ? pars.Replace(key) : key, ' '); int num = keyValuePair.Key.IndexOf('*'); string value2; if (num >= 0) { List list = MatchKeys(keyValuePair.Key, num); if (list.Count == 0) { return false; } foreach (string item in list) { if (!Database.TryGetValue(item, out string value) || (keyValuePair.Value != "" && value != keyValuePair.Value)) { return false; } } } else if (!Database.TryGetValue(keyValuePair.Key.ToLowerInvariant(), out value2) || (keyValuePair.Value != "" && value2 != keyValuePair.Value)) { return false; } } return true; } } public class Log { private static ManualLogSource Logger; public static void Init(ManualLogSource logger) { Logger = logger; } public static void Error(string message) { Logger.LogError((object)message); } public static void Warning(string message) { Logger.LogWarning((object)message); } public static void Info(string message) { Logger.LogInfo((object)message); } public static void Debug(string message) { Logger.LogDebug((object)message); } } public class Range { public T Min; public T Max; public bool Uniform = true; public Range(T value) { Min = value; Max = value; } public Range(T min, T max) { Min = min; Max = max; } } public static class Parse { private static Dictionary Paints = new Dictionary { { "grass", Color.black }, { "patches", new Color(0f, 0.75f, 0f) }, { "grass_dark", new Color(0.6f, 0.5f, 0f) }, { "dirt", Color.red }, { "cultivated", Color.green }, { "paved", Color.blue }, { "paved_moss", new Color(0f, 0f, 0.5f) }, { "paved_dirt", new Color(1f, 0f, 0.5f) }, { "paved_dark", new Color(0f, 1f, 0.5f) } }; public static List ToList(string str, bool removeEmpty = true) { string[] array = Split(str, removeEmpty); List list = new List(array.Length); list.AddRange(array); return list; } public static string[] ToArr(string str, bool removeEmpty = true) { string[] array = Split(str, removeEmpty); int num = 0; string[] array2 = new string[array.Length]; string[] array3 = array; foreach (string text in array3) { array2[num] = text; num++; } return array2; } public static Vector2i Vector2Int(string arg) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) string[] array = SplitWithEmpty(arg); return new Vector2i(Int(array[0]), (array.Length > 1) ? Int(array[1]) : 0); } public static int Int(string arg, int defaultValue = 0) { if (!TryInt(arg, out var result)) { return defaultValue; } return result; } public static uint UInt(string arg, uint defaultValue = 0u) { if (!TryUInt(arg, out var result)) { return defaultValue; } return result; } 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 bool TryLong(string arg, out long result) { return long.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out 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 bool TryUInt(string arg, out uint result) { return uint.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out result); } public static bool TryInt(string arg, out int result) { return int.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out result); } public static float Float(string arg, float defaultValue = 0f) { if (!TryFloat(arg, out var result)) { return defaultValue; } return result; } public static float Float(string[] args, int index, float defaultValue = 0f) { if (args.Length <= index) { return defaultValue; } return Float(args[index], defaultValue); } public static bool TryFloat(string arg, out float result) { return float.TryParse(arg, NumberStyles.Float, CultureInfo.InvariantCulture, out result); } public static bool TryBoolean(string arg, out bool result) { result = false; if (arg.ToLowerInvariant() == "true") { result = true; return true; } if (arg.ToLowerInvariant() == "false") { return true; } return false; } public static Quaternion AngleYXZ(string arg) { //IL_000a: 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) return AngleYXZ(Split(arg), 0, Vector3.zero); } public static Quaternion AngleYXZ(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 AngleYXZ(args, index, Vector3.zero); } public static Quaternion AngleYXZ(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) //IL_0047: 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 Quaternion.Euler(zero); } public static string[] Split(string arg, bool removeEmpty = true, char split = ',') { List list; if (!removeEmpty) { list = new List(); list.AddRange(from s in arg.Split(new char[1] { split }) select s.Trim()); return list.ToArray(); } list = new List(); list.AddRange(from s in arg.Split(new char[1] { split }) select s.Trim() into s where s != "" select s); return list.ToArray(); } public static KeyValuePair Kvp(string str, char separator = ',') { int num = str.IndexOf(separator); if (num < 0) { return new KeyValuePair(str, ""); } return new KeyValuePair(str.Substring(0, num), str.Substring(num + 1).Trim()); } public static bool TryKvp(string str, out KeyValuePair kvp, char separator = ',') { kvp = Kvp(str, separator); return kvp.Value != ""; } public static string[] SplitWithEmpty(string arg, char split = ',') { List list = new List(); list.AddRange(from s in arg.Split(new char[1] { split }) select s.Trim()); return list.ToArray(); } public static string[] SplitWithEscape(string arg, char separator = ',') { List list = new List(); string[] array = arg.Split(new char[1] { separator }); for (int i = 0; i < array.Length; i++) { string text = array[i].TrimStart(Array.Empty()); if (text.StartsWith("\"")) { array[i] = text.Substring(1); int j; for (j = i; j < array.Length; j++) { text = array[j].TrimEnd(Array.Empty()); if (text.EndsWith("\"")) { array[j] = text.Substring(0, text.Length - 1); break; } } list.Add(string.Join(separator.ToString(), array.Skip(i).Take(j - i + 1))); i = j; } else { list.Add(array[i].Trim()); } } return list.ToArray(); } public static string Name(string arg) { return arg.Split(new char[1] { ':' })[0]; } public static Vector3 VectorXZY(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 VectorXZY(arg, Vector3.zero); } public static Vector3 VectorXZY(string arg, Vector3 defaultValue) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) return VectorXZY(Split(arg), 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.z = Float(args, index + 1, defaultValue.z); zero.y = Float(args, index + 2, defaultValue.y); return zero; } public static Vector2 VectorXY(string arg) { //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_0036: Unknown result type (might be due to invalid IL or missing references) Vector2 zero = Vector2.zero; string[] args = Split(arg); zero.x = Float(args, 0); zero.y = Float(args, 1); return zero; } public static Vector3 Scale(string args) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) return Scale(Split(args), 0); } 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 Range StringRange(string arg) { string[] array = Split(arg, removeEmpty: true, ';'); if (array.Length > 1) { return new Range(array[0], array[1]); } return new Range(array[0], array[0]); } public static Range IntRange(string arg) { Range range = StringRange(arg); return new Range(Int(range.Min), Int(range.Max)); } public static Range FloatRange(string arg) { Range range = StringRange(arg); return new Range(Float(range.Min), Float(range.Max)); } public static Range LongRange(string arg) { Range range = StringRange(arg); return new Range(Long(range.Min, 0L), Long(range.Max, 0L)); } public static int? IntNull(string arg) { if (int.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return result; } return null; } public static int? IntNull(string[] args, int index) { if (args.Length <= index) { return null; } return IntNull(args[index]); } public static float? FloatNull(string arg) { if (float.TryParse(arg, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { return result; } return null; } public static float? FloatNull(string[] args, int index) { if (args.Length <= index) { return null; } return FloatNull(args[index]); } public static long? LongNull(string[] args, int index) { if (args.Length <= index) { return null; } return LongNull(args[index]); } public static long? LongNull(string arg) { if (long.TryParse(arg, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { return result; } return null; } public static Vector3? VectorXZYNull(string? arg) { if (arg != null) { return VectorXZYNull(Split(arg)); } return null; } public static Vector3? VectorXZYNull(string[] args) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) float? num = FloatNull(args, 0); float? num2 = FloatNull(args, 2); float? num3 = FloatNull(args, 1); if (!num.HasValue && !num2.HasValue && !num3.HasValue) { return null; } return new Vector3(num.GetValueOrDefault(), num2.GetValueOrDefault(), num3.GetValueOrDefault()); } public static Quaternion? AngleYXZNull(string? arg) { if (arg != null) { return AngleYXZNull(Split(arg)); } return null; } public static Quaternion? AngleYXZNull(string[] values) { //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) float? num = FloatNull(values, 0); float? num2 = FloatNull(values, 1); float? num3 = FloatNull(values, 2); if (!num.HasValue && !num2.HasValue && !num3.HasValue) { return null; } return Quaternion.Euler(new Vector3(num2.GetValueOrDefault(), num.GetValueOrDefault(), num3.GetValueOrDefault())); } public static string String(string[] args, int index) { if (args.Length <= index) { return ""; } return args[index]; } public static int Hash(string[] args, int index) { if (args.Length <= index) { return 0; } return StringExtensionMethods.GetStableHashCode(args[index]); } public static bool Boolean(string[] args, int index) { if (args.Length > index) { return Boolean(args[index]); } return false; } public static bool Boolean(string arg) { return arg.ToLowerInvariant() == "true"; } public static bool BooleanTrue(string arg) { return arg.ToLowerInvariant() == "false"; } public static ZDOID ZdoId(string arg) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) string[] array = Split(arg, removeEmpty: true, ':'); if (array.Length < 2) { return ZDOID.None; } return new ZDOID(Long(array[0], 0L), UInt(array[1])); } public static HitData Hit(ZDO? zdo, string arg) { //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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: 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_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_0393->IL0393: Incompatible stack types: O vs I4 //IL_0391->IL0393: Incompatible stack types: I4 vs O //IL_0391->IL0393: Incompatible stack types: O vs I4 //IL_0398->IL0398: Incompatible stack types: I4 vs O HitData val = new HitData { m_point = (zdo?.m_position ?? Vector3.zero) }; string[] array = Split(arg, removeEmpty: true, ' '); for (int i = 0; i < array.Length; i++) { KeyValuePair keyValuePair = Kvp(array[i], '='); object obj = keyValuePair.Key; string value = keyValuePair.Value; if ((string?)obj == "damage") { val.m_damage.m_damage = Float(value); } if ((string?)obj == "blunt") { val.m_damage.m_blunt = Float(value); } if ((string?)obj == "slash") { val.m_damage.m_slash = Float(value); } if ((string?)obj == "pierce") { val.m_damage.m_pierce = Float(value); } if ((string?)obj == "chop") { val.m_damage.m_chop = Float(value); } if ((string?)obj == "pickaxe") { val.m_damage.m_pickaxe = Float(value); } if ((string?)obj == "fire") { val.m_damage.m_fire = Float(value); } if ((string?)obj == "frost") { val.m_damage.m_frost = Float(value); } if ((string?)obj == "lightning") { val.m_damage.m_lightning = Float(value); } if ((string?)obj == "poison") { val.m_damage.m_poison = Float(value); } if ((string?)obj == "spirit") { val.m_damage.m_spirit = Float(value); } if ((string?)obj == "tier") { val.m_toolTier = (short)Int(value); } if ((string?)obj == "force") { val.m_pushForce = Float(value); } if ((string?)obj == "backstab") { val.m_backstabBonus = Float(value); } if ((string?)obj == "stagger") { val.m_staggerMultiplier = Float(value); } if ((string?)obj == "dodge") { val.m_dodgeable = Boolean(value); } if ((string?)obj == "block") { val.m_blockable = Boolean(value); } if ((string?)obj == "dir") { val.m_dir = VectorXZY(value); } if ((string?)obj == "ranged") { val.m_ranged = Boolean(value); } if ((string?)obj == "pvp") { val.m_ignorePVP = Boolean(value); } if ((string?)obj == "pos") { val.m_point = VectorXZY(value); } if ((string?)obj == "status") { val.m_statusEffectHash = StringExtensionMethods.GetStableHashCode(value); } if ((string?)obj == "attacker") { val.m_attacker = ZdoId(value); } if ((string?)obj == "skill") { val.m_skillLevel = Float(value); } if ((string?)obj == "level") { val.m_itemLevel = (short)Int(value); } if ((string?)obj == "world") { val.m_itemWorldLevel = (byte)Int(value); } if ((string?)obj == "type") { int num; if (Enum.TryParse(value, ignoreCase: true, out HitType result)) { obj = result; num = (int)obj; } else { num = 0; obj = num; num = (int)obj; } val.m_hitType = (HitType)obj; obj = num; } if ((string?)obj == "spot") { val.m_weakSpot = (short)Int(value); } } return val; } public static int EnumMessage(string arg) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected I4, but got Unknown if (!Enum.TryParse(arg, ignoreCase: true, out MessageType result)) { return Int(arg, 2); } return (int)result; } public static int EnumReason(string arg) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected I4, but got Unknown if (!Enum.TryParse(arg, ignoreCase: true, out AggravatedReason result)) { return Int(arg); } return (int)result; } public static int EnumTrap(string arg) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected I4, but got Unknown if (!Enum.TryParse(arg, ignoreCase: true, out TrapState result)) { return Int(arg); } return (int)result; } public static int EnumDamageText(string arg) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected I4, but got Unknown if (!Enum.TryParse(arg, ignoreCase: true, out TextType result)) { return Int(arg); } return (int)result; } public static int EnumTerrainPaint(string arg) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected I4, but got Unknown if (!Enum.TryParse(arg, ignoreCase: true, out PaintType result)) { return Int(arg); } return (int)result; } public static Color? Color(string arg, float defaultAlpha) { //IL_0016: 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) string key = arg.ToLowerInvariant(); if (Paints.TryGetValue(key, out var value)) { return value; } string[] array = Split(arg); if (array.Length < 3) { return null; } return new Color(Float(array[0]), Float(array[1]), Float(array[2]), (array.Length > 3) ? Float(array[3]) : defaultAlpha); } } public class ServerClient { private static PlayerInfo? client; public static PlayerInfo Client { get { //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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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) PlayerInfo valueOrDefault = client.GetValueOrDefault(); if (!client.HasValue) { valueOrDefault = CreatePlayerInfo(); client = valueOrDefault; return valueOrDefault; } return valueOrDefault; } } public static void Patch(Harmony harmony) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(ZNet), "TryGetPlayerByPlatformUserID", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(ServerClient), "RecognizeServerClient", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); methodInfo = AccessTools.Method(typeof(ZNet), "SendPlayerList", (Type[])null, (Type[])null); methodInfo2 = AccessTools.Method(typeof(ServerClient), "AddServerClient", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null); } private static bool RecognizeServerClient(bool result, PlatformUserID platformUserID, ref PlayerInfo playerInfo) { //IL_0005: 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) if (result) { return result; } if (platformUserID != Client.m_userInfo.m_id) { return result; } playerInfo = Client; return true; } private static IEnumerable AddServerClient(IEnumerable instructions) { //IL_0002: 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_0039: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).End().MatchStartBackwards((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(ZNet), "m_players"), (string)null) }).Advance(-1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldarg_0, (object)null) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldloc_0, (object)null) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(ServerClient), "AddServer", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } private static void AddServer(ZNet net, ZPackage pkg) { int pos = pkg.GetPos(); pkg.SetPos(0); if (IsExtraPlayerAdded(net, pkg.ReadInt())) { pkg.SetPos(pos); return; } pkg.SetPos(0); pkg.Write(net.m_players.Count + 1); Write(pkg); } private static bool IsExtraPlayerAdded(ZNet net, int count) { return count >= net.m_players.Count + 1; } private static PlayerInfo CreatePlayerInfo() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0046: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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) PlayerInfo result = default(PlayerInfo); result.m_name = "Server"; result.m_characterID = new ZDOID(ZDOMan.GetSessionID(), uint.MaxValue); result.m_userInfo = new CrossNetworkUserInfo { m_id = new PlatformUserID(ZNet.instance.m_steamPlatform, GetId()), m_displayName = "Server" }; result.m_serverAssignedDisplayName = "Server"; result.m_publicPosition = false; result.m_position = Vector3.zero; return result; } private static string GetId() { //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) try { CSteamID steamID = SteamGameServer.GetSteamID(); return ((object)(CSteamID)(ref steamID)).ToString(); } catch (InvalidOperationException) { return "0"; } } public static void Write(ZPackage pkg) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0044: 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_0059: Unknown result type (might be due to invalid IL or missing references) pkg.Write(Client.m_name); pkg.Write(Client.m_characterID); PlayerInfo val = Client; pkg.Write(((object)(PlatformUserID)(ref val.m_userInfo.m_id)).ToString()); pkg.Write(Client.m_userInfo.m_displayName); pkg.Write(Client.m_serverAssignedDisplayName); pkg.Write(false); } } public class Yaml { public static string BaseDirectory = Path.Combine(Paths.ConfigPath, "expand_world"); public static string BackupDirectory = Path.Combine(Paths.ConfigPath, "expand_world_backups"); public static List Read(string pattern, bool migrate) { if (!Directory.Exists(BaseDirectory)) { Directory.CreateDirectory(BaseDirectory); } return Read(Directory.GetFiles(BaseDirectory, pattern, SearchOption.AllDirectories).Reverse().ToList(), migrate); } public static List Read(List files, bool migrate) { List list = new List(); foreach (string file in files) { try { string raw = (migrate ? PreParse(File.ReadAllLines(file)) : File.ReadAllText(file)); list.AddRange(Deserialize(raw, file)); } catch (Exception ex) { Log.Error("Error reading " + Path.GetFileName(file) + ": " + ex.Message); } } return list; } private static string PreParse(string[] lines) { bool flag = false; List list = new List(); foreach (string text in lines) { if (flag) { if (text.StartsWith(" - ") && !text.Contains(":")) { HandleObjects(list, text); continue; } flag = false; } if (text.StartsWith(" spawn: ") && !text.Contains("#") && text.Trim().Length > 6) { list.Add(" spawns:"); list.Add(" - " + text.Substring(9)); } else if (text.StartsWith(" swap: ") && !text.Contains("#") && text.Trim().Length > 5) { list.Add(" swaps:"); list.Add(" - " + text.Substring(8)); } else if (text.StartsWith(" filter:")) { list.Add(" filters:"); if (!text.Contains("#") && text.Trim().Length > 7) { list.Add(" - " + text.Substring(10)); } } else if (text.StartsWith(" bannedFilter:")) { list.Add(" bannedFilters:"); if (!text.Contains("#") && text.Trim().Length > 13) { list.Add(" - " + text.Substring(16)); } } else if (text.StartsWith(" filter:")) { list.Add(" filters:"); if (!text.Contains("#") && text.Trim().Length > 7) { list.Add(" - " + text.Substring(12)); } } else if (text.StartsWith(" bannedFilter: ")) { list.Add(" bannedFilters:"); if (!text.Contains("#") && text.Trim().Length > 7) { list.Add(" - " + text.Substring(18)); } } else if (text.StartsWith(" objects:") || text.StartsWith(" bannedObjects:")) { flag = true; list.Add(text); } else { list.Add(text); } } return string.Join("\n", list); } private static void HandleObjects(List result, string line) { string[] array = line.Substring(4).Split(new char[1] { ',' }); result.Add(" - prefab: " + array[0]); if (array.Length > 1) { Range range = Parse.StringRange(array[1]); if (range.Min != range.Max) { result.Add(" minDistance: " + range.Min); } result.Add(" maxDistance: " + range.Max); } if (array.Length > 2) { result.Add(" data: " + array[2]); } if (array.Length > 3) { result.Add(" weight: " + array[3]); } if (array.Length > 4) { Range range2 = Parse.StringRange(array[4]); if (range2.Min != range2.Max) { result.Add(" minHeight: " + range2.Min); } result.Add(" maxHeight: " + range2.Max); } } public static Biome ToBiomes(string biomeStr, bool defaultAll) { //IL_0001: 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_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_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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) Biome val = (Biome)0; if (biomeStr == "") { if (defaultAll) { return (Biome)(-1); } return (Biome)0; } string[] array = Parse.Split(biomeStr); foreach (string text in array) { if (Enum.TryParse(text, ignoreCase: true, out Biome result)) { val |= result; continue; } if (int.TryParse(text, out var result2)) { val = (Biome)(val + result2); continue; } throw new InvalidOperationException("Invalid biome " + text + "."); } return val; } public static void SetupWatcher(ConfigFile config) { ConfigFile config2 = config; FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Path.GetDirectoryName(config2.ConfigFilePath), Path.GetFileName(config2.ConfigFilePath)); fileSystemWatcher.Changed += delegate(object s, FileSystemEventArgs e) { ReadConfigValues(e.FullPath, config2); }; fileSystemWatcher.Created += delegate(object s, FileSystemEventArgs e) { ReadConfigValues(e.FullPath, config2); }; fileSystemWatcher.Renamed += delegate(object s, RenamedEventArgs e) { ReadConfigValues(e.FullPath, config2); }; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private static void ReadConfigValues(string path, ConfigFile config) { if (!File.Exists(path)) { return; } BackupFile(path, overwrite: true); try { config.Reload(); } catch { Log.Error("There was an issue loading your " + config.ConfigFilePath); Log.Error("Please check your config entries for spelling and format!"); } } public static void SetupWatcher(string pattern, Action action) { SetupWatcherSub(Paths.ConfigPath, pattern, action); } public static void SetupWatcher(string folder, string pattern, Action action, bool overwriteBackup) { Action action2 = action; SetupWatcherSub(folder, pattern, delegate(string file) { BackupFile(file, overwriteBackup); action2(); }); } public static void SetupWatcher(string pattern, Action action, bool overwriteBackup) { Action action2 = action; SetupWatcherSub(BaseDirectory, pattern, delegate(string file) { BackupFile(file, overwriteBackup); action2(); }); } private static void SetupWatcherSub(string folder, string pattern, Action action) { Action action2 = action; FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(folder, pattern); fileSystemWatcher.Created += delegate(object s, FileSystemEventArgs e) { action2(e.FullPath); }; fileSystemWatcher.Changed += delegate(object s, FileSystemEventArgs e) { action2(e.FullPath); }; fileSystemWatcher.Renamed += delegate(object s, RenamedEventArgs e) { action2(e.FullPath); }; fileSystemWatcher.Deleted += delegate(object s, FileSystemEventArgs e) { action2(e.FullPath); }; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } private static void SetupWatcherSub(string folder, string pattern, Action action) { Action action2 = action; FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(folder, pattern); fileSystemWatcher.Created += delegate { action2(); }; fileSystemWatcher.Changed += delegate { action2(); }; fileSystemWatcher.Renamed += delegate { action2(); }; fileSystemWatcher.Deleted += delegate { action2(); }; fileSystemWatcher.IncludeSubdirectories = true; fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject; fileSystemWatcher.EnableRaisingEvents = true; } public static void BackupFile(string path, bool overwrite) { if (File.Exists(path)) { if (!Directory.Exists(BackupDirectory)) { Directory.CreateDirectory(BackupDirectory); } string text = DateTime.Now.ToString("yyyy-MM-dd"); string path2 = Path.GetFileNameWithoutExtension(path) + "_" + text + Path.GetExtension(path) + ".bak"; string text2 = Path.Combine(BackupDirectory, path2); if (overwrite) { File.Copy(path, text2, overwrite: true); } else if (!File.Exists(text2)) { File.Copy(path, text2); } } } public static void Init() { if (!Directory.Exists(BaseDirectory)) { Directory.CreateDirectory(BaseDirectory); } } private static IDeserializer Deserializer() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown return ((BuilderSkeleton)new DeserializerBuilder()).WithNamingConvention(CamelCaseNamingConvention.Instance).Build(); } private static IDeserializer DeserializerUnSafe() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown return ((BuilderSkeleton)new DeserializerBuilder()).WithNamingConvention(CamelCaseNamingConvention.Instance).IgnoreUnmatchedProperties().Build(); } private static List Deserialize(string raw, string file) { try { return Deserializer().Deserialize>(raw) ?? new List(); } catch (Exception ex) { Log.Error(Path.GetFileName(file) + ": " + ex.Message); try { return DeserializerUnSafe().Deserialize>(raw) ?? new List(); } catch (Exception) { return new List(); } } } public static Dictionary DeserializeData(string raw) { try { return Deserializer().Deserialize>(raw) ?? new Dictionary(); } catch { try { return DeserializerUnSafe().Deserialize>(raw) ?? new Dictionary(); } catch (Exception) { return new Dictionary(); } } } public static string SerializeData(Dictionary data) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown return ((BuilderSkeleton)new SerializerBuilder()).WithNamingConvention(CamelCaseNamingConvention.Instance).Build().Serialize((object)data); } } } namespace ExpandWorld.Prefab { public static class Api { private static readonly Dictionary> ParameterHandlers = new Dictionary>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary> ValueParameterHandlers = new Dictionary>(StringComparer.OrdinalIgnoreCase); private static readonly Dictionary> GroupHandlers = new Dictionary>(StringComparer.OrdinalIgnoreCase); public static void RegisterParameterHandler(string key, Func handler) { if (!(key == "") && handler != null) { ParameterHandlers[key] = handler; } } public static void RegisterParameterHandler(string key, Func handler) { if (!(key == "") && handler != null) { ValueParameterHandlers[key] = handler; } } public static bool UnregisterParameterHandler(string key) { if (key == "") { return false; } return false | ParameterHandlers.Remove(key) | ValueParameterHandlers.Remove(key); } public static void RegisterGroupHandler(string key, Func handler) { if (!(key == "") && handler != null) { GroupHandlers[key] = handler; } } public static bool UnregisterGroupHandler(string key) { if (key == "") { return false; } return GroupHandlers.Remove(key); } internal static string? ResolveParameter(string key) { if (ParameterHandlers.TryGetValue(key, out Func value)) { return value(); } return null; } internal static string? ResolveValueParameter(string key, string value) { if (ValueParameterHandlers.TryGetValue(key, out Func value2)) { return value2(value); } return null; } internal static bool IsInGroup(string playerId, long characterId, string group) { if (group == "") { return false; } foreach (Func value in GroupHandlers.Values) { if (value(playerId, characterId, group)) { return true; } } return false; } public static void TriggerCustom(params string[] args) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) TriggerCustom(Vector3.zero, args); } public static void TriggerCustom(Vector3 pos, params string[] args) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (args != null && args.Length != 0 && !(args[0] == "")) { Manager.HandleGlobal(ActionType.Custom, args, pos, remove: false); } } } public class Commands { public static void Run(Info info, Parameters pars) { Parameters pars2 = pars; if (info.Commands.Length != 0) { Run(info.Commands.Select((string c) => pars2.Replace(c, preventInjections: true)).ToArray()); } } private static void Run(IEnumerable commands) { string[] array = commands.Select(Parse).ToArray(); foreach (string text in array) { try { ((Terminal)Console.instance).TryRunCommand(text, false, false); } catch (Exception ex) { Log.Error("Failed to run command: " + text + "\n" + ex.Message); } } } private static string Parse(string command) { string[] array = (from s in command.Split(new char[1] { ' ' }) select s.Split(new char[1] { '=' }) into a select a[^1].Trim()).SelectMany((string s) => s.Split(new char[1] { ',' })).ToArray(); foreach (string text in array) { if (text.Length == 0) { continue; } string source = text.Substring(1); if (!Enumerable.Contains(source, '*') && !Enumerable.Contains(source, '/') && !Enumerable.Contains(source, '+') && !Enumerable.Contains(source, '-')) { continue; } float? num = Calculator.EvaluateFloat(text); if (num.HasValue) { int num2 = command.IndexOf(text); if (num2 >= 0) { command = command.Substring(0, num2) + num.Value.ToString("0.#####", NumberFormatInfo.InvariantInfo) + command.Substring(num2 + text.Length); } } } return command; } } public class DelayedOwner { private static readonly List Owners = new List(); private readonly ZDOID Zdo; public float Delay; private readonly long Owner; public DelayedOwner(float delay, ZDOID zdo, long owner) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) Zdo = zdo; Delay = delay; Owner = owner; base..ctor(); } public static void Check(ZDO zdo, long owner) { ZDO zdo2 = zdo; if (owner == 0L) { owner = ((IEnumerable)ZDOMan.instance.m_peers.OrderBy((ZDOPeer p) => Utils.DistanceXZ(p.m_peer.m_refPos, zdo2.m_position))).FirstOrDefault((Func)((ZDOPeer p) => p.m_peer.m_uid != zdo2.GetOwner()))?.m_peer.m_uid ?? 0; } GameObject prefab = ZNetScene.instance.GetPrefab(zdo2.m_prefab); if (Object.op_Implicit((Object)(object)prefab.GetComponent())) { zdo2.Set(ZDOVars.s_spawnTime, ZNet.instance.GetTime().Ticks); Add(0.1f, zdo2, owner); } else if (Object.op_Implicit((Object)(object)prefab.GetComponent())) { Add(0.1f, zdo2, owner); } else { zdo2.SetOwnerInternal(owner); } } public static void Add(float delay, ZDO zdo, long owner) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) zdo.SetOwner(0L); if (delay <= 0f) { zdo.SetOwner(owner); } else { Owners.Add(new DelayedOwner(delay, zdo.m_uid, owner)); } } public static void Execute(float dt) { for (int i = 0; i < Owners.Count; i++) { DelayedOwner delayedOwner = Owners[i]; delayedOwner.Delay -= dt; if (!((double)delayedOwner.Delay > -0.001)) { delayedOwner.Execute(); Owners.RemoveAt(i); i--; } } } public void Execute() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ZDO zDO = ZDOMan.instance.GetZDO(Zdo); if (zDO != null) { zDO.SetOwner(Owner); } } } public interface IPokeable { float Delay { get; set; } void Execute(); } public class DelayedSinglePoke : DelayedPoke, IPokeable { [CompilerGenerated] private float P; private readonly ZDOID Zdo; private readonly string[] Args; float IPokeable.Delay { get { return P; } set { P = value; } } public DelayedSinglePoke(float delay, ZDOID zdo, string[] args) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) P = delay; Zdo = zdo; Args = args; base..ctor(); } public void Execute() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) DelayedPoke.Poke(Zdo, Args); } } public class DelayedMultiPoke : DelayedPoke, IPokeable { [CompilerGenerated] private float P; private readonly ZDOID[] Zdos; private readonly string[] Args; float IPokeable.Delay { get { return P; } set { P = value; } } public DelayedMultiPoke(float delay, ZDOID[] zdos, string[] args) { P = delay; Zdos = zdos; Args = args; base..ctor(); } public void Execute() { DelayedPoke.Poke(Zdos, Args); } } public class DelayedPoke { private static readonly List Pokes = new List(); public static void Add(Poke poke, ZDOID zdo, Vector3 pos, Quaternion rot, Parameters pars) { //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012d: 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_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) float valueOrDefault = (poke.Chance?.Get(pars)).GetValueOrDefault(1f); if (valueOrDefault < 1f && Random.value > valueOrDefault) { return; } float valueOrDefault2 = (poke.Delay?.Get(pars)).GetValueOrDefault(); int valueOrDefault3 = (poke.Repeat?.Get(pars)).GetValueOrDefault(); float valueOrDefault4 = (poke.RepeatInterval?.Get(pars)).GetValueOrDefault(valueOrDefault2); float valueOrDefault5 = (poke.RepeatChance?.Get(pars)).GetValueOrDefault(1f); List list = Helper.GenerateDelays(valueOrDefault2, valueOrDefault3, valueOrDefault4, valueOrDefault5); if (list != null) { foreach (float item in list) { Add(poke, zdo, pos, rot, pars, item); } return; } Add(poke, zdo, pos, rot, pars, valueOrDefault2); } private static void Add(Poke poke, ZDOID zdo, Vector3 pos, Quaternion rot, Parameters pars, float delay) { //IL_00db: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) bool? flag = poke.Self?.GetBool(pars); ZDOID? val = poke.Target?.Get(pars); if (poke.HasPrefab) { ZDOID[] nearby = ObjectsFiltering.GetNearby((poke.Limit?.Get(pars)).GetValueOrDefault(), poke.Filter, pos, rot, pars, flag.GetValueOrDefault() ? null : new ZDOID?(zdo)); pars.Amount = nearby.Length; string[] args = poke.GetArgs(pars); Add(delay, nearby, args); } else if (flag.GetValueOrDefault() || val.HasValue) { string[] args2 = poke.GetArgs(pars); if (flag.GetValueOrDefault()) { Add(delay, zdo, args2); } if (val.HasValue && val.Value != zdo) { Add(delay, val.Value, args2); } } } public static void AddGlobal(Poke poke, Vector3 pos, Quaternion rot, Parameters pars) { //IL_0124: 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_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) float valueOrDefault = (poke.Chance?.Get(pars)).GetValueOrDefault(1f); if (valueOrDefault < 1f && Random.value > valueOrDefault) { return; } float valueOrDefault2 = (poke.Delay?.Get(pars)).GetValueOrDefault(); int valueOrDefault3 = (poke.Repeat?.Get(pars)).GetValueOrDefault(); float valueOrDefault4 = (poke.RepeatInterval?.Get(pars)).GetValueOrDefault(valueOrDefault2); float valueOrDefault5 = (poke.RepeatChance?.Get(pars)).GetValueOrDefault(1f); List list = Helper.GenerateDelays(valueOrDefault2, valueOrDefault3, valueOrDefault4, valueOrDefault5); if (list != null) { foreach (float item in list) { AddGlobal(poke, pos, rot, pars, item); } return; } AddGlobal(poke, pos, rot, pars, valueOrDefault2); } private static void AddGlobal(Poke poke, Vector3 pos, Quaternion rot, Parameters pars, float delay) { //IL_0031: 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) string[] args = poke.GetArgs(pars); ZDOID[] nearby = ObjectsFiltering.GetNearby((poke.Limit?.Get(pars)).GetValueOrDefault(), poke.Filter, pos, rot, pars, null); Add(delay, nearby, args); } public static void Add(float delay, ZDOID[] zdos, string[] args) { if (delay <= 0f) { Poke(zdos, args); } else { Pokes.Add(new DelayedMultiPoke(delay, zdos, args)); } } private static void Add(float delay, ZDOID zdo, string[] args) { //IL_0016: 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) if (delay <= 0f) { Poke(zdo, args); } else { Pokes.Add(new DelayedSinglePoke(delay, zdo, args)); } } public static void Execute(float dt) { for (int i = 0; i < Pokes.Count; i++) { IPokeable pokeable = Pokes[i]; pokeable.Delay -= dt; if (!((double)pokeable.Delay > -0.001)) { pokeable.Execute(); Pokes.RemoveAt(i); i--; } } } protected static void Poke(ZDOID[] zdos, string[] args) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) foreach (ZDOID id in zdos) { Manager.Handle(ActionType.Poke, args, id); } } protected static void Poke(ZDOID zdo, string[] args) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Manager.Handle(ActionType.Poke, args, zdo); } } public class DelayedRemove { private static readonly List Removes = new List(); private readonly ZDOID Zdo; public float Delay; private readonly bool TriggerRules; public DelayedRemove(float delay, ZDOID zdo, bool triggerRules) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) Zdo = zdo; Delay = delay; TriggerRules = triggerRules; base..ctor(); } public static void Add(float delay, ZDOID zdo, bool triggerRules) { //IL_0016: 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) if (delay <= 0f) { Manager.RemoveZDO(zdo, triggerRules); } else { Removes.Add(new DelayedRemove(delay, zdo, triggerRules)); } } public static void Execute(float dt) { for (int i = 0; i < Removes.Count; i++) { DelayedRemove delayedRemove = Removes[i]; delayedRemove.Delay -= dt; if (!((double)delayedRemove.Delay > -0.001)) { delayedRemove.Execute(); Removes.RemoveAt(i); i--; } } } public void Execute() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Manager.RemoveZDO(Zdo, TriggerRules); } } public class DelayedRpc { private static readonly List Rpcs = new List(); public float Delay; private readonly long Source; private readonly long Target; private readonly ZDOID Zdo; private readonly int Hash; private readonly object[] Parameters; public DelayedRpc(float delay, long source, long target, ZDOID zdo, int hash, object[] parameters) { //IL_0016: 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) Delay = delay; Source = source; Target = target; Zdo = zdo; Hash = hash; Parameters = parameters; base..ctor(); } public static void Add(float delay, long source, long target, ZDOID zdo, int hash, object[] parameters, bool overwrite) { //IL_0004: 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) //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (overwrite) { Remove(zdo, hash); } if (delay <= 0f) { Manager.Rpc(source, target, zdo, hash, parameters); } else { Rpcs.Add(new DelayedRpc(delay, source, target, zdo, hash, parameters)); } } public static void Remove(ZDOID zdo, int hash) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) for (int num = Rpcs.Count - 1; num >= 0; num--) { DelayedRpc delayedRpc = Rpcs[num]; if (delayedRpc.Zdo == zdo && delayedRpc.Hash == hash) { Rpcs.RemoveAt(num); } } } public static void Execute(float dt) { for (int i = 0; i < Rpcs.Count; i++) { DelayedRpc delayedRpc = Rpcs[i]; delayedRpc.Delay -= dt; if (!((double)delayedRpc.Delay > -0.001)) { delayedRpc.Execute(); Rpcs.RemoveAt(i); i--; } } } public void Execute() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) Manager.Rpc(Source, Target, Zdo, Hash, Parameters); } } public class DelayedSpawn { private static readonly List Spawns = new List(); public float Delay; private readonly ZdoEntry ZdoEntry; private readonly bool TriggerRules; public DelayedSpawn(float delay, ZdoEntry zdoEntry, bool triggerRules) { Delay = delay; ZdoEntry = zdoEntry; TriggerRules = triggerRules; base..ctor(); } public static ZDO? CreateObject(ZdoEntry entry, bool triggerRules) { HandleCreated.Skip = !triggerRules; ZDO? result = entry.Create(); HandleCreated.Skip = false; return result; } public static void Add(Spawn spawn, ZDO originalZdo, DataEntry? data, Parameters pars) { float valueOrDefault = (spawn.Chance?.Get(pars)).GetValueOrDefault(1f); if (valueOrDefault < 1f && Random.value > valueOrDefault) { return; } float valueOrDefault2 = (spawn.Delay?.Get(pars)).GetValueOrDefault(); int valueOrDefault3 = (spawn.Repeat?.Get(pars)).GetValueOrDefault(); float valueOrDefault4 = (spawn.RepeatInterval?.Get(pars)).GetValueOrDefault(valueOrDefault2); float valueOrDefault5 = (spawn.RepeatChance?.Get(pars)).GetValueOrDefault(1f); List list = Helper.GenerateDelays(valueOrDefault2, valueOrDefault3, valueOrDefault4, valueOrDefault5); if (list != null) { foreach (float item in list) { Add(spawn, originalZdo, data, pars, item); } return; } Add(spawn, originalZdo, data, pars, valueOrDefault2); } private static void Add(Spawn spawn, ZDO originalZdo, DataEntry? data, Parameters pars, float delay) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //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_0050: 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_0078: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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_00fc: 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) Vector3 position = originalZdo.m_position; Quaternion val = originalZdo.GetRotation(); position += val * (Vector3)(((??)spawn.Pos?.Get(pars)) ?? Vector3.zero); val *= (Quaternion)(((??)spawn.Rot?.Get(pars)) ?? Quaternion.identity); Vector3 eulerAngles = ((Quaternion)(ref val)).eulerAngles; IBoolValue? snap = spawn.Snap; if (snap != null && snap.GetBool(pars).GetValueOrDefault()) { position.y = WorldGenerator.instance.GetHeight(position.x, position.z); } data = DataHelper.Merge(data, DataHelper.Get(spawn.Data, pars)); int prefab = spawn.GetPrefab(pars); if (prefab != 0) { ZdoEntry zdoEntry = new ZdoEntry(prefab, position, eulerAngles, originalZdo); if (data != null) { zdoEntry.Load(data, pars); } long? num = spawn.Owner?.Get(pars); if (num.HasValue) { zdoEntry.Owner = num.Value; } Add(delay, zdoEntry, (spawn.TriggerRules?.GetBool(pars)).GetValueOrDefault()); } } private static void Add(float delay, ZdoEntry zdoEntry, bool triggerRules) { if (delay <= 0f) { CreateObject(zdoEntry, triggerRules); } else { Spawns.Add(new DelayedSpawn(delay, zdoEntry, triggerRules)); } } public static void Execute(float dt) { for (int i = 0; i < Spawns.Count; i++) { DelayedSpawn delayedSpawn = Spawns[i]; delayedSpawn.Delay -= dt; if (!((double)delayedSpawn.Delay > -0.001)) { delayedSpawn.Execute(); Spawns.RemoveAt(i); i--; } } } public void Execute() { CreateObject(ZdoEntry, TriggerRules); } } public class DelayedTerrain { [CompilerGenerated] private long P; [CompilerGenerated] private Vector3 P; [CompilerGenerated] private float P; [CompilerGenerated] private ZPackage P; [CompilerGenerated] private float P; private static readonly List Terrains = new List(); public float Delay; public DelayedTerrain(float delay, long source, Vector3 pos, float size, ZPackage pkg, float resetRadius) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) P = source; P = pos; P = size; P = pkg; P = resetRadius; Delay = delay; base..ctor(); } public static void Add(float delay, long source, Vector3 pos, float size, ZPackage pkg, float resetRadius) { //IL_0001: 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_0020: Unknown result type (might be due to invalid IL or missing references) if (Manager.GenerateTerrainCompilers(source, pos, size)) { delay = Mathf.Max(delay, 1f); } if (delay <= 0f) { Manager.ModifyTerrain(source, pos, size, pkg, resetRadius); } else { Terrains.Add(new DelayedTerrain(delay, source, pos, size, pkg, resetRadius)); } } public static void Execute(float dt) { for (int i = 0; i < Terrains.Count; i++) { DelayedTerrain delayedTerrain = Terrains[i]; delayedTerrain.Delay -= dt; if (!((double)delayedTerrain.Delay > -0.001)) { delayedTerrain.Execute(); Terrains.RemoveAt(i); i--; } } } public void Execute() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Manager.ModifyTerrain(P, P, P, P, P); } } [BepInPlugin("expand_world_prefabs", "Expand World Prefabs", "1.52")] public class EWP : BaseUnityPlugin { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__6_0; internal void b__6_0(ConsoleEventArgs args) { DataStorage.LoadSavedData(); } } public const string GUID = "expand_world_prefabs"; public const string NAME = "Expand World Prefabs"; public const string VERSION = "1.52"; public static Harmony Harmony; public static Assembly? ExpandEvents; public void Awake() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown Harmony = new Harmony("expand_world_prefabs"); Harmony.PatchAll(); Log.Init(((BaseUnityPlugin)this).Logger); Yaml.Init(); try { DataLoading.SetupWatcher(); Loading.SetupWatcher(); DataStorage.LoadSavedData(); } catch (Exception ex) { Log.Error(ex.StackTrace); } } public void Start() { //IL_005a: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown if (Chainloader.PluginInfos.TryGetValue("expand_world_events", out var value)) { ExpandEvents = ((object)value.Instance).GetType().Assembly; } object obj = <>c.<>9__6_0; if (obj == null) { ConsoleEvent val = delegate { DataStorage.LoadSavedData(); }; <>c.<>9__6_0 = val; obj = (object)val; } new ConsoleCommand("ewp_reload", "Manually reloads the ewp_data.yaml file.", (ConsoleEvent)obj, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } public void LateUpdate() { if (!((Object)(object)ZNet.instance == (Object)null)) { HandleCreated.Execute(); HandleChanged.Execute(); DelayedSpawn.Execute(Time.deltaTime); DelayedRemove.Execute(Time.deltaTime); DelayedPoke.Execute(Time.deltaTime); DelayedRpc.Execute(Time.deltaTime); DelayedTerrain.Execute(Time.deltaTime); DelayedOwner.Execute(Time.deltaTime); DataStorage.SaveSavedData(); } } public static RandomEvent GetCurrentEvent(Vector3 pos) { //IL_0052: 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) //IL_0064: Expected O, but got Unknown if (ExpandEvents == null) { return RandEventSystem.instance.GetCurrentRandomEvent(); } MethodInfo method = ExpandEvents.GetType("ExpandWorld.EWE").GetMethod("GetCurrentRandomEvent", BindingFlags.Static | BindingFlags.Public); if (method == null) { return RandEventSystem.instance.GetCurrentRandomEvent(); } return (RandomEvent)method.Invoke(null, new object[1] { pos }); } } public class HandleChanged { private static readonly List ChangedZDOs = new List(); private static int Index = 0; public static ZDOID IgnoreZdo = ZDOID.None; private static readonly Dictionary> TrackedHashes = new Dictionary>(); public static void Patch(Harmony harmony, PrefabInfo changeDatas) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_021b: Expected O, but got Unknown //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Expected O, but got Unknown //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(ZDOExtraData), "Set", new Type[3] { typeof(ZDOID), typeof(int), typeof(int) }, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(HandleChanged), "HandleInt", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); methodInfo = AccessTools.Method(typeof(ZDOExtraData), "Set", new Type[3] { typeof(ZDOID), typeof(int), typeof(float) }, (Type[])null); methodInfo2 = AccessTools.Method(typeof(HandleChanged), "HandleFloat", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); methodInfo = AccessTools.Method(typeof(ZDOExtraData), "Set", new Type[3] { typeof(ZDOID), typeof(int), typeof(string) }, (Type[])null); methodInfo2 = AccessTools.Method(typeof(HandleChanged), "HandleString", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); methodInfo = AccessTools.Method(typeof(ZDOExtraData), "Set", new Type[3] { typeof(ZDOID), typeof(int), typeof(long) }, (Type[])null); methodInfo2 = AccessTools.Method(typeof(HandleChanged), "HandleLong", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); methodInfo = AccessTools.Method(typeof(ZDOExtraData), "Set", new Type[3] { typeof(ZDOID), typeof(int), typeof(Vector3) }, (Type[])null); methodInfo2 = AccessTools.Method(typeof(HandleChanged), "HandleVec", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); methodInfo = AccessTools.Method(typeof(ZDOExtraData), "Set", new Type[3] { typeof(ZDOID), typeof(int), typeof(Quaternion) }, (Type[])null); methodInfo2 = AccessTools.Method(typeof(HandleChanged), "HandleQuaternion", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); methodInfo = AccessTools.Method(typeof(ZDOExtraData), "Set", new Type[3] { typeof(ZDOID), typeof(int), typeof(byte[]) }, (Type[])null); methodInfo2 = AccessTools.Method(typeof(HandleChanged), "HandleByteArray", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); TrackedHashes.Clear(); AddTracks(changeDatas.Weighted); AddTracks(changeDatas.Fallback); AddTracks(changeDatas.Separate); } private static void AddTracks(Dictionary> datas) { foreach (KeyValuePair> data in datas) { int key = data.Key; foreach (Info item in data.Value) { if (item.Args.Length != 0) { int key2 = ZdoHelper.Hash(item.Args[0]); if (!TrackedHashes.ContainsKey(key2)) { TrackedHashes[key2] = new HashSet(); } TrackedHashes[key2].Add(key); } } } } public static void Execute() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) if (ChangedZDOs.Count > 10000) { Log.Warning("Too many changes, possible infinite loop."); Index = 0; ChangedZDOs.Clear(); return; } int count = ChangedZDOs.Count; while (Index < count) { ChangedZdo changedZdo = ChangedZDOs[Index]; ZDO zDO = ZDOMan.instance.GetZDO(changedZdo.Zdo); if (zDO != null && zDO.Valid) { Manager.Handle(ActionType.Change, new string[3] { changedZdo.Key, changedZdo.Value, changedZdo.PreviousValue }, zDO); } Index++; } if (Index >= ChangedZDOs.Count) { Index = 0; ChangedZDOs.Clear(); } } private static void HandleInt(ZDOID zid, int hash, int value) { //IL_001a: 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) if (!TrackedHashes.TryGetValue(hash, out HashSet value2) || !ZDOMan.instance.m_objectsByID.TryGetValue(zid, out var value3) || !value2.Contains(value3.m_prefab) || IgnoreZdo == zid) { return; } int @int = value3.GetInt(hash, 0); if (@int != value) { ChangedZDOs.Add(new ChangedZdo(value3, ZdoHelper.ReverseHash(hash), value.ToString(), @int.ToString())); ChangedZDOs.Add(new ChangedZdo(value3, ZdoHelper.ReverseHash(hash), (value != 0) ? "true" : "false", (@int != 0) ? "true" : "false")); GameObject prefab = ZNetScene.instance.GetPrefab(value); GameObject prefab2 = ZNetScene.instance.GetPrefab(@int); if (Object.op_Implicit((Object)(object)prefab) || Object.op_Implicit((Object)(object)prefab2)) { ChangedZDOs.Add(new ChangedZdo(value3, ZdoHelper.ReverseHash(hash), ((prefab != null) ? ((Object)prefab).name : null) ?? "", ((prefab2 != null) ? ((Object)prefab2).name : null) ?? "")); } } } private static void HandleFloat(ZDOID zid, int hash, float value) { //IL_001a: 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) if (TrackedHashes.TryGetValue(hash, out HashSet value2) && ZDOMan.instance.m_objectsByID.TryGetValue(zid, out var value3) && value2.Contains(value3.m_prefab) && !(IgnoreZdo == zid)) { float @float = value3.GetFloat(hash, 0f); if (@float != value) { ChangedZDOs.Add(new ChangedZdo(value3, ZdoHelper.ReverseHash(hash), value.ToString(NumberFormatInfo.InvariantInfo), @float.ToString(NumberFormatInfo.InvariantInfo))); } } } private static void HandleString(ZDOID zid, int hash, string value) { //IL_001a: 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) if (TrackedHashes.TryGetValue(hash, out HashSet value2) && ZDOMan.instance.m_objectsByID.TryGetValue(zid, out var value3) && value2.Contains(value3.m_prefab) && !(IgnoreZdo == zid)) { string @string = value3.GetString(hash, ""); if (!(@string == value)) { ChangedZDOs.Add(new ChangedZdo(value3, ZdoHelper.ReverseHash(hash), (value == "") ? "" : value, (@string == "") ? "" : @string)); } } } private static void HandleLong(ZDOID zid, int hash, long value) { //IL_001a: 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) if (TrackedHashes.TryGetValue(hash, out HashSet value2) && ZDOMan.instance.m_objectsByID.TryGetValue(zid, out var value3) && value2.Contains(value3.m_prefab) && !(IgnoreZdo == zid)) { long @long = value3.GetLong(hash, 0L); if (@long != value) { ChangedZDOs.Add(new ChangedZdo(value3, ZdoHelper.ReverseHash(hash), value.ToString(), @long.ToString())); } } } private static void HandleVec(ZDOID zid, int hash, Vector3 value) { //IL_001a: 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_0044: 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) if (TrackedHashes.TryGetValue(hash, out HashSet value2) && ZDOMan.instance.m_objectsByID.TryGetValue(zid, out var value3) && value2.Contains(value3.m_prefab) && !(IgnoreZdo == zid)) { string text = Helper.FormatPos2(value3.GetVec3(hash, Vector3.zero)); string text2 = Helper.FormatPos2(value); if (!(text == text2)) { ChangedZDOs.Add(new ChangedZdo(value3, ZdoHelper.ReverseHash(hash), text2, text)); } } } private static void HandleQuaternion(ZDOID zid, int hash, Quaternion value) { //IL_001a: 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_0044: 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_0052: 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) if (TrackedHashes.TryGetValue(hash, out HashSet value2) && ZDOMan.instance.m_objectsByID.TryGetValue(zid, out var value3) && value2.Contains(value3.m_prefab) && !(IgnoreZdo == zid)) { Quaternion quaternion = value3.GetQuaternion(hash, Quaternion.identity); string text = Helper.FormatRot2(((Quaternion)(ref quaternion)).eulerAngles); string text2 = Helper.FormatRot2(((Quaternion)(ref value)).eulerAngles); if (!(text == text2)) { ChangedZDOs.Add(new ChangedZdo(value3, ZdoHelper.ReverseHash(hash), text2, text)); } } } private static void HandleByteArray(ZDOID zid, int hash, byte[] value) { //IL_001a: 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) if (TrackedHashes.TryGetValue(hash, out HashSet value2) && ZDOMan.instance.m_objectsByID.TryGetValue(zid, out var value3) && value2.Contains(value3.m_prefab) && !(IgnoreZdo == zid)) { byte[] byteArray = value3.GetByteArray(hash, (byte[])null); if (!(byteArray?.SequenceEqual(value) ?? (value == null))) { ChangedZDOs.Add(new ChangedZdo(value3, ZdoHelper.ReverseHash(hash), (value == null) ? "" : Convert.ToBase64String(value), (byteArray == null) ? "" : Convert.ToBase64String(byteArray))); } } } } public class ChangedZdo { public ZDOID Zdo = zdo.m_uid; public string Key; public string Value; public string PreviousValue; public ChangedZdo(ZDO zdo, string key, string value, string previous) { //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) Key = key; Value = value; PreviousValue = previous; base..ctor(); } } public class HandleCreated { private static readonly List CreatedZDOs = new List(); private static readonly List GhostZDOs = new List(); public static bool Skip = false; public static void Patch(Harmony harmony) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(ZDOMan), "CreateNewZDO", new Type[2] { typeof(Vector3), typeof(int) }, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(HandleCreated), "HandleOwnCreated", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); methodInfo = AccessTools.Method(typeof(ZDOMan), "RPC_ZDOData", (Type[])null, (Type[])null); methodInfo2 = AccessTools.Method(typeof(HandleCreated), "RPC_ZDOData", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null); } public static void Execute() { //IL_000a: 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) //IL_0015: 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_0058: 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) for (int i = 0; i < CreatedZDOs.Count; i++) { ZDOID val = CreatedZDOs[i]; ZDO zDO = ZDOMan.instance.GetZDO(val); if (zDO != null) { PeerManager.HandlePlayerCreatedState(zDO); Manager.Handle(ActionType.Create, Array.Empty(), zDO); } } ZNetView.m_ghostInit = true; for (int j = 0; j < GhostZDOs.Count; j++) { ZDOID val2 = GhostZDOs[j]; ZDO zDO2 = ZDOMan.instance.GetZDO(val2); if (zDO2 != null) { Manager.Handle(ActionType.Create, Array.Empty(), zDO2); } } ZNetView.m_ghostInit = false; CreatedZDOs.Clear(); GhostZDOs.Clear(); } private static void HandleOwnCreated(ZDO __result, int prefabHash) { //IL_002a: 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) if (!Skip && prefabHash != 0) { if (ZNetView.m_ghostInit) { GhostZDOs.Add(__result.m_uid); } else { CreatedZDOs.Add(__result.m_uid); } } } private static IEnumerable RPC_ZDOData(IEnumerable instructions) { //IL_0002: 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) //IL_0036: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).MatchEndForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(ZDO), "Deserialize", (Type[])null, (Type[])null), (string)null) }).Advance(1).InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldloc_S, (object)12) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldloc_S, (object)13) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, Transpilers.EmitDelegate>((Action)HandleClientCreated).operand) }) .InstructionEnumeration(); } private static void HandleClientCreated(ZDO zdo, bool flag) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (flag) { CreatedZDOs.Add(zdo.m_uid); } } } public class HandleDestroyed { public static void Patch(Harmony harmony) { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(ZDOMan), "HandleDestroyedZDO", new Type[1] { typeof(ZDOID) }, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(HandleDestroyed), "Handle", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void Handle(ZDOID uid) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) ZDO zDO = ZDOMan.instance.GetZDO(uid); if (zDO != null) { Manager.Handle(ActionType.Destroy, Array.Empty(), zDO); } } } public class HandleEvent { public static void Patch(Harmony harmony) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(RandEventSystem), "SetRandomEvent", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(HandleEvent), "SetRandomEvent", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void SetRandomEvent(RandEventSystem __instance, RandomEvent ev, Vector3 pos) { //IL_0023: 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) if (__instance.m_randomEvent != null) { Manager.HandleGlobal(ActionType.Event, new string[1] { __instance.m_randomEvent.m_name }, __instance.m_randomEvent.m_pos, remove: true); } if (ev != null) { Manager.HandleGlobal(ActionType.Event, new string[1] { ev.m_name }, pos, remove: false); } } } public class HandleGlobalKey { public static void Patch(Harmony harmony) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(ZoneSystem), "RPC_SetGlobalKey", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(HandleGlobalKey), "RPC_SetGlobalKey", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); methodInfo = AccessTools.Method(typeof(ZoneSystem), "RPC_RemoveGlobalKey", (Type[])null, (Type[])null); methodInfo2 = AccessTools.Method(typeof(HandleGlobalKey), "RPC_RemoveGlobalKey", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); methodInfo = AccessTools.Method(typeof(ZoneSystem), "ClearGlobalKeys", (Type[])null, (Type[])null); methodInfo2 = AccessTools.Method(typeof(HandleGlobalKey), "ClearGlobalKeys", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void RPC_SetGlobalKey(string name) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) string text = default(string); GlobalKeys val = default(GlobalKeys); string keyValue = ZoneSystem.GetKeyValue(name.ToLower(), ref text, ref val); Manager.HandleGlobal(ActionType.GlobalKey, new string[1] { keyValue }, Vector3.zero, remove: false); } private static void RPC_RemoveGlobalKey(string name) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) string text = default(string); GlobalKeys val = default(GlobalKeys); string keyValue = ZoneSystem.GetKeyValue(name.ToLower(), ref text, ref val); Manager.HandleGlobal(ActionType.GlobalKey, new string[1] { keyValue }, Vector3.zero, remove: true); } private static void ClearGlobalKeys(ZoneSystem __instance) { foreach (string globalKey in __instance.m_globalKeys) { RPC_RemoveGlobalKey(globalKey); } } } public class HandleRPC { private delegate bool RPCHandler(ZDO zdo, RoutedRPCData data); private static readonly Dictionary Handlers = new Dictionary(); private static readonly int RepairHash = StringExtensionMethods.GetStableHashCode("RPC_HealthChanged"); private static readonly ParameterInfo[] RepairPars = AccessTools.Method(typeof(WearNTear), "RPC_HealthChanged", (Type[])null, (Type[])null).GetParameters(); private static readonly int SetTriggerHash = StringExtensionMethods.GetStableHashCode("SetTrigger"); private static readonly ParameterInfo[] SetTriggerPars = AccessTools.Method(typeof(ZSyncAnimation), "RPC_SetTrigger", (Type[])null, (Type[])null).GetParameters(); private static readonly int SetTargetHash = StringExtensionMethods.GetStableHashCode("RPC_SetTarget"); private static readonly ParameterInfo[] SetTargetPars = AccessTools.Method(typeof(Turret), "RPC_SetTarget", (Type[])null, (Type[])null).GetParameters(); private static readonly int ShakeHash = StringExtensionMethods.GetStableHashCode("RPC_Shake"); private static readonly ParameterInfo[] ShakePars = AccessTools.Method(typeof(TreeBase), "RPC_Shake", (Type[])null, (Type[])null).GetParameters(); private static readonly int OnStateChangedHash = StringExtensionMethods.GetStableHashCode("RPC_OnStateChanged"); private static readonly ParameterInfo[] OnStateChangedPars = AccessTools.Method(typeof(Trap), "RPC_OnStateChanged", (Type[])null, (Type[])null).GetParameters(); private static readonly int SetSaddleHash = StringExtensionMethods.GetStableHashCode("SetSaddle"); private static readonly ParameterInfo[] SetSaddlePars = AccessTools.Method(typeof(Tameable), "RPC_SetSaddle", (Type[])null, (Type[])null).GetParameters(); private static readonly int SayHash = StringExtensionMethods.GetStableHashCode("Say"); private static readonly ParameterInfo[] SayPars = AccessTools.Method(typeof(Talker), "RPC_Say", (Type[])null, (Type[])null).GetParameters(); private static readonly int ChatMessageHash = StringExtensionMethods.GetStableHashCode("ChatMessage"); private static readonly ParameterInfo[] ChatMessgePars = AccessTools.Method(typeof(Chat), "RPC_ChatMessage", (Type[])null, (Type[])null).GetParameters(); private static readonly int FlashShieldHash = StringExtensionMethods.GetStableHashCode("FlashShield"); private static readonly ParameterInfo[] FlashShieldPars = AccessTools.Method(typeof(PrivateArea), "RPC_FlashShield", (Type[])null, (Type[])null).GetParameters(); private static readonly int SetPickedHash = StringExtensionMethods.GetStableHashCode("RPC_SetPicked"); private static readonly ParameterInfo[] SetPickedPars = AccessTools.Method(typeof(Pickable), "RPC_SetPicked", (Type[])null, (Type[])null).GetParameters(); private static readonly int PlayMusicHash = StringExtensionMethods.GetStableHashCode("RPC_PlayMusic"); private static readonly ParameterInfo[] PlayMusicPars = AccessTools.Method(typeof(MusicVolume), "RPC_PlayMusic", (Type[])null, (Type[])null).GetParameters(); private static readonly int WakeupHash = StringExtensionMethods.GetStableHashCode("RPC_Wakeup"); private static readonly ParameterInfo[] WakeupPars = AccessTools.Method(typeof(MonsterAI), "RPC_Wakeup", (Type[])null, (Type[])null).GetParameters(); private static readonly int SetAreaHealthHash = StringExtensionMethods.GetStableHashCode("RPC_SetAreaHealth"); private static readonly ParameterInfo[] SetAreaHealthPars = AccessTools.Method(typeof(MineRock5), "RPC_SetAreaHealth", (Type[])null, (Type[])null).GetParameters(); private static readonly int HideHash = StringExtensionMethods.GetStableHashCode("Hide"); private static readonly ParameterInfo[] HidePars = AccessTools.Method(typeof(MineRock), "RPC_Hide", (Type[])null, (Type[])null).GetParameters(); private static readonly int SetVisualItemHash = StringExtensionMethods.GetStableHashCode("SetVisualItem"); private static readonly ParameterInfo[] ItemStandPars = AccessTools.Method(typeof(ItemStand), "RPC_SetVisualItem", (Type[])null, (Type[])null).GetParameters(); private static readonly int SetArmorVisualItemHash = StringExtensionMethods.GetStableHashCode("RPC_SetVisualItem"); private static readonly ParameterInfo[] ArmorStandPars = AccessTools.Method(typeof(ArmorStand), "RPC_SetVisualItem", (Type[])null, (Type[])null).GetParameters(); private static readonly int AnimateLeverHash = StringExtensionMethods.GetStableHashCode("RPC_AnimateLever"); private static readonly ParameterInfo[] AnimateLeverPars = AccessTools.Method(typeof(Incinerator), "RPC_AnimateLever", (Type[])null, (Type[])null).GetParameters(); private static readonly int AnimateLeverReturnHash = StringExtensionMethods.GetStableHashCode("RPC_AnimateLeverReturn"); private static readonly ParameterInfo[] AnimateLeverReturnPars = AccessTools.Method(typeof(Incinerator), "RPC_AnimateLeverReturn", (Type[])null, (Type[])null).GetParameters(); private static readonly int SetSlotVisualHash = StringExtensionMethods.GetStableHashCode("RPC_SetSlotVisual"); private static readonly ParameterInfo[] SetSlotVisualPars = AccessTools.Method(typeof(CookingStation), "RPC_SetSlotVisual", (Type[])null, (Type[])null).GetParameters(); private static readonly int MakePieceHash = StringExtensionMethods.GetStableHashCode("RPC_MakePiece"); private static readonly ParameterInfo[] MakePieceHashPars = AccessTools.Method(typeof(ItemDrop), "RPC_MakePiece", (Type[])null, (Type[])null).GetParameters(); private static readonly int OnEatHash = StringExtensionMethods.GetStableHashCode("RPC_OnEat"); private static readonly ParameterInfo[] OnEatPars = AccessTools.Method(typeof(Feast), "RPC_OnEat", (Type[])null, (Type[])null).GetParameters(); private static readonly int OnDeathHash = StringExtensionMethods.GetStableHashCode("OnDeath"); private static readonly ParameterInfo[] OnDeathPars = AccessTools.Method(typeof(Player), "RPC_OnDeath", (Type[])null, (Type[])null).GetParameters(); private static readonly int OnSetPoseHash = StringExtensionMethods.GetStableHashCode("RPC_SetPose"); private static readonly ParameterInfo[] OnSetPosePars = AccessTools.Method(typeof(ArmorStand), "RPC_SetPose", (Type[])null, (Type[])null).GetParameters(); private static readonly int OnLegUseHash = StringExtensionMethods.GetStableHashCode("RPC_OnLegUse"); private static readonly ParameterInfo[] OnLegUsePars = AccessTools.Method(typeof(Catapult), "RPC_OnLegUse", (Type[])null, (Type[])null).GetParameters(); private static readonly int OnSetLoadedHash = StringExtensionMethods.GetStableHashCode("RPC_SetLoadedVisual"); private static readonly ParameterInfo[] OnSetLoadedPars = AccessTools.Method(typeof(Catapult), "RPC_SetLoadedVisual", (Type[])null, (Type[])null).GetParameters(); private static readonly int OnShootHash = StringExtensionMethods.GetStableHashCode("RPC_Shoot"); private static readonly ParameterInfo[] OnShootPars = AccessTools.Method(typeof(Catapult), "RPC_Shoot", (Type[])null, (Type[])null).GetParameters(); private static readonly int OnFreezeFrameHash = StringExtensionMethods.GetStableHashCode("RPC_FreezeFrame"); private static readonly ParameterInfo[] OnFreezeFramePars = AccessTools.Method(typeof(Character), "RPC_FreezeFrame", (Type[])null, (Type[])null).GetParameters(); private static readonly int OnResetClothHash = StringExtensionMethods.GetStableHashCode("RPC_ResetCloth"); private static readonly ParameterInfo[] OnResetClothPars = AccessTools.Method(typeof(Character), "RPC_ResetCloth", (Type[])null, (Type[])null).GetParameters(); private static readonly int OnFragmentsHash = StringExtensionMethods.GetStableHashCode("RPC_CreateFragments"); private static readonly ParameterInfo[] OnFragmentsPars = AccessTools.Method(typeof(Destructible), "RPC_CreateFragments", (Type[])null, (Type[])null).GetParameters(); private static readonly int OnStepHash = StringExtensionMethods.GetStableHashCode("Step"); private static readonly ParameterInfo[] OnStepPars = AccessTools.Method(typeof(FootStep), "RPC_Step", (Type[])null, (Type[])null).GetParameters(); private static readonly int OnMaterialHash = StringExtensionMethods.GetStableHashCode("RPC_UpdateMaterial"); private static readonly ParameterInfo[] OnMaterialPars = AccessTools.Method(typeof(MaterialVariation), "RPC_UpdateMaterial", (Type[])null, (Type[])null).GetParameters(); private static readonly int OnEffectsHash = StringExtensionMethods.GetStableHashCode("RPC_UpdateEffects"); private static readonly ParameterInfo[] OnEffectsPars = AccessTools.Method(typeof(SapCollector), "RPC_UpdateEffects", (Type[])null, (Type[])null).GetParameters(); private static readonly int OnHitHash = StringExtensionMethods.GetStableHashCode("RPC_HitNow"); private static readonly ParameterInfo[] OnHitPars = AccessTools.Method(typeof(ShieldGenerator), "RPC_HitNow", (Type[])null, (Type[])null).GetParameters(); private static readonly int OnUnsummonHash = StringExtensionMethods.GetStableHashCode("RPC_UnSummon"); private static readonly ParameterInfo[] OnUnsummonPars = AccessTools.Method(typeof(Tameable), "RPC_UnSummon", (Type[])null, (Type[])null).GetParameters(); private static readonly int OnGrowHash = StringExtensionMethods.GetStableHashCode("RPC_Grow"); private static readonly ParameterInfo[] OnGrowPars = AccessTools.Method(typeof(TreeBase), "RPC_Grow", (Type[])null, (Type[])null).GetParameters(); private static readonly (int Hash, RPCHandler Handler, string[] States)[] AllAvailableHandlers = new(int, RPCHandler, string[])[34] { (RepairHash, WNTHealthChanged, new string[2] { "damage", "repair" }), (SetTriggerHash, SetTrigger, new string[1] { "action" }), (SetTargetHash, SetTarget, new string[2] { "target", "targeting" }), (ShakeHash, Shake, new string[1] { "damage" }), (OnStateChangedHash, OnStateChanged, new string[1] { "trap" }), (SetSaddleHash, SetSaddle, new string[2] { "saddle", "unsaddle" }), (SayHash, Say, new string[1] { "say" }), (FlashShieldHash, FlashShield, new string[1] { "flash" }), (SetPickedHash, SetPicked, new string[2] { "picked", "unpicked" }), (PlayMusicHash, PlayMusic, new string[1] { "music" }), (WakeupHash, Wakeup, new string[1] { "wakeup" }), (SetAreaHealthHash, SetAreaHealth, new string[1] { "damage" }), (HideHash, Hide, new string[1] { "damage" }), (SetVisualItemHash, SetVisualItem, new string[1] { "item" }), (AnimateLeverHash, AnimateLever, new string[1] { "start" }), (AnimateLeverReturnHash, AnimateLeverReturn, new string[1] { "end" }), (SetArmorVisualItemHash, SetArmorVisualItem, new string[1] { "item" }), (SetSlotVisualHash, SetSlotVisual, new string[1] { "item" }), (MakePieceHash, MakePiece, new string[1] { "piece" }), (OnEatHash, OnEat, new string[1] { "eat" }), (OnDeathHash, OnDeath, new string[1] { "death" }), (OnSetPoseHash, OnSetPose, new string[1] { "pose" }), (OnLegUseHash, OnLegUse, new string[2] { "lock", "release" }), (OnSetLoadedHash, OnSetLoaded, new string[1] { "loaded" }), (OnShootHash, OnShoot, new string[1] { "shoot" }), (OnFreezeFrameHash, OnFreezeFrame, new string[1] { "freezeframe" }), (OnResetClothHash, OnResetCloth, new string[1] { "resetcloth" }), (OnFragmentsHash, OnFragments, new string[1] { "fragments" }), (OnStepHash, OnStep, new string[1] { "step" }), (OnMaterialHash, OnMaterial, new string[1] { "material" }), (OnEffectsHash, OnEffects, new string[1] { "effects" }), (OnHitHash, OnHit, new string[1] { "hit" }), (OnUnsummonHash, OnUnsummon, new string[1] { "unsummon" }), (OnGrowHash, OnGrow, new string[1] { "grow" }) }; private static readonly Dictionary RPCHandlers = new Dictionary { { RepairHash, WNTHealthChanged }, { SetTriggerHash, SetTrigger }, { SetTargetHash, SetTarget }, { ShakeHash, Shake }, { OnStateChangedHash, OnStateChanged }, { SetSaddleHash, SetSaddle }, { SayHash, Say }, { FlashShieldHash, FlashShield }, { SetPickedHash, SetPicked }, { PlayMusicHash, PlayMusic }, { WakeupHash, Wakeup }, { SetAreaHealthHash, SetAreaHealth }, { HideHash, Hide }, { SetVisualItemHash, SetVisualItem }, { AnimateLeverHash, AnimateLever }, { AnimateLeverReturnHash, AnimateLeverReturn }, { SetArmorVisualItemHash, SetArmorVisualItem }, { SetSlotVisualHash, SetSlotVisual }, { MakePieceHash, MakePiece }, { OnEatHash, OnEat }, { OnDeathHash, OnDeath }, { OnSetPoseHash, OnSetPose }, { OnLegUseHash, OnLegUse }, { OnSetLoadedHash, OnSetLoaded }, { OnShootHash, OnShoot }, { OnFreezeFrameHash, OnFreezeFrame }, { OnResetClothHash, OnResetCloth }, { OnFragmentsHash, OnFragments }, { OnStepHash, OnStep }, { OnMaterialHash, OnMaterial }, { OnEffectsHash, OnEffects }, { OnHitHash, OnHit }, { OnUnsummonHash, OnUnsummon }, { OnGrowHash, OnGrow } }; public static void Patch(Harmony harmony) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method(typeof(ZRoutedRpc), "HandleRoutedRPC", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(HandleRPC), "Handle", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); methodInfo = AccessTools.Method(typeof(ZRoutedRpc), "RouteRPC", (Type[])null, (Type[])null); methodInfo2 = AccessTools.Method(typeof(HandleRPC), "RouteRPC", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static void SetRequiredStates(HashSet requiredStates) { Handlers.Clear(); (int, RPCHandler, string[])[] allAvailableHandlers = AllAvailableHandlers; for (int i = 0; i < allAvailableHandlers.Length; i++) { (int, RPCHandler, string[]) tuple = allAvailableHandlers[i]; int item = tuple.Item1; RPCHandler item2 = tuple.Item2; string[] item3 = tuple.Item3; foreach (string item4 in item3) { if (requiredStates.Contains(item4)) { Handlers[item] = item2; } } } } private static bool RouteRPC(RoutedRPCData rpcData) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) bool flag = false; if (rpcData.m_methodHash == SayHash) { ZDO zDO = ZDOMan.instance.GetZDO(rpcData.m_targetZDO); if (zDO == null) { return true; } flag = CancelSay(zDO, rpcData); } return !flag; } private static bool Handle(RoutedRPCData data) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ZDO zDO = ZDOMan.instance.GetZDO(data.m_targetZDO); if (zDO == null) { return true; } bool flag = false; if (Handlers.TryGetValue(data.m_methodHash, out RPCHandler value)) { flag = value(zDO, data); } return !flag; } private static bool WNTHealthChanged(ZDO zdo, RoutedRPCData data) { GameObject prefab = ZNetScene.instance.GetPrefab(zdo.GetPrefab()); if (!Object.op_Implicit((Object)(object)prefab)) { return false; } WearNTear val = default(WearNTear); if (!prefab.TryGetComponent(ref val)) { return false; } object[] array = ZNetView.Deserialize(data.m_senderPeerID, RepairPars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 2) { return false; } float num = (float)array[1]; if ((double)num > 1E+20) { return false; } if (num == val.m_health) { return Manager.Handle(ActionType.State, new string[1] { "repair" }, zdo); } return Manager.Handle(ActionType.State, new string[1] { "damage" }, zdo); } private static bool SetTrigger(ZDO zdo, RoutedRPCData data) { object[] array = ZNetView.Deserialize(data.m_senderPeerID, SetTriggerPars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 2) { return false; } string text = (string)array[1]; return Manager.Handle(ActionType.State, new string[2] { "action", text }, zdo); } private static bool SetTarget(ZDO zdo, RoutedRPCData data) { //IL_002e: 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_0034: 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_0048: Unknown result type (might be due to invalid IL or missing references) object[] array = ZNetView.Deserialize(data.m_senderPeerID, SetTargetPars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 2) { return false; } ZDOID val = (ZDOID)array[1]; if (val == ZDOID.None) { return false; } ZDO zDO = ZDOMan.instance.GetZDO(val); if (zDO == null) { return false; } GameObject prefab = ZNetScene.instance.GetPrefab(zDO.GetPrefab()); if (!Object.op_Implicit((Object)(object)prefab)) { return false; } bool flag = Manager.Handle(ActionType.State, new string[2] { "targeting", ((Object)prefab).name }, zdo); bool flag2 = Manager.Handle(ActionType.State, new string[1] { "target" }, zDO); return flag || flag2; } private static bool Shake(ZDO zdo, RoutedRPCData data) { return Manager.Handle(ActionType.State, new string[1] { "damage" }, zdo); } private static bool OnStateChanged(ZDO zdo, RoutedRPCData data) { object[] array = ZNetView.Deserialize(data.m_senderPeerID, OnStateChangedPars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 2) { return false; } int num = (int)array[1]; if (num == 0) { return false; } return Manager.Handle(ActionType.State, new string[2] { "trap", num.ToString() }, zdo); } private static bool SetSaddle(ZDO zdo, RoutedRPCData data) { object[] array = ZNetView.Deserialize(data.m_senderPeerID, SetSaddlePars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 2) { return false; } bool flag = (bool)array[1]; return Manager.Handle(ActionType.State, new string[1] { flag ? "saddle" : "unsaddle" }, zdo); } private static bool Say(ZDO zdo, RoutedRPCData data) { object[] array = ZNetView.Deserialize(data.m_senderPeerID, SayPars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 4) { return false; } string text = (string)array[3]; return Manager.Handle(ActionType.Say, text.Split(new char[1] { ' ' }), zdo); } private static bool CancelSay(ZDO zdo, RoutedRPCData data) { object[] array = ZNetView.Deserialize(data.m_senderPeerID, SayPars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 4) { return false; } string text = (string)array[3]; return Manager.CheckCancel(ActionType.Say, text.Split(new char[1] { ' ' }), zdo); } private static bool HandleChat(ZDO zdo, RoutedRPCData data) { object[] array = ZNetView.Deserialize(data.m_senderPeerID, ChatMessgePars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 5) { return false; } string text = (string)array[4]; return Manager.Handle(ActionType.Say, text.Split(new char[1] { ' ' }), zdo); } private static bool CancelChat(ZDO zdo, RoutedRPCData data) { object[] array = ZNetView.Deserialize(data.m_senderPeerID, ChatMessgePars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 5) { return false; } string text = (string)array[4]; return Manager.CheckCancel(ActionType.Say, text.Split(new char[1] { ' ' }), zdo); } private static bool FlashShield(ZDO zdo, RoutedRPCData data) { return Manager.Handle(ActionType.State, new string[1] { "flash" }, zdo); } private static bool SetPicked(ZDO zdo, RoutedRPCData data) { object[] array = ZNetView.Deserialize(data.m_senderPeerID, SetPickedPars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 2) { return false; } bool flag = (bool)array[1]; return Manager.Handle(ActionType.State, new string[1] { flag ? "picked" : "unpicked" }, zdo); } private static bool PlayMusic(ZDO zdo, RoutedRPCData data) { return Manager.Handle(ActionType.State, new string[1] { "music" }, zdo); } private static bool Wakeup(ZDO zdo, RoutedRPCData data) { return Manager.Handle(ActionType.State, new string[1] { "wakeup" }, zdo); } private static bool SetAreaHealth(ZDO zdo, RoutedRPCData data) { object[] array = ZNetView.Deserialize(data.m_senderPeerID, SetAreaHealthPars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 3) { return false; } int num = (int)array[1]; float value = (float)array[2]; return Manager.Handle(ActionType.State, new string[3] { "damage", num.ToString(), Helper.Format2(value) }, zdo); } private static bool Hide(ZDO zdo, RoutedRPCData data) { object[] array = ZNetView.Deserialize(data.m_senderPeerID, HidePars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 2) { return false; } int num = (int)array[1]; return Manager.Handle(ActionType.State, new string[2] { "damage", num.ToString() }, zdo); } private static bool SetVisualItem(ZDO zdo, RoutedRPCData data) { if (!Object.op_Implicit((Object)(object)ZNetScene.instance.GetPrefab(zdo.GetPrefab()))) { return false; } object[] array = ZNetView.Deserialize(data.m_senderPeerID, ItemStandPars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 4) { return false; } string text = (string)array[1]; int num = (int)array[2]; int num2 = (int)array[3]; string text2 = ((text == "") ? "" : text); return Manager.Handle(ActionType.State, new string[4] { "item", text2, num.ToString(), num2.ToString() }, zdo); } private static bool SetArmorVisualItem(ZDO zdo, RoutedRPCData data) { if (!Object.op_Implicit((Object)(object)ZNetScene.instance.GetPrefab(zdo.GetPrefab()))) { return false; } object[] array = ZNetView.Deserialize(data.m_senderPeerID, ArmorStandPars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 4) { return false; } int num = (int)array[1]; string text = (string)array[2]; int num2 = (int)array[3]; string text2 = ((text == "") ? "" : text); return Manager.Handle(ActionType.State, new string[4] { "item", text2, num2.ToString(), num.ToString() }, zdo); } private static bool AnimateLever(ZDO zdo, RoutedRPCData data) { return Manager.Handle(ActionType.State, new string[1] { "start" }, zdo); } private static bool AnimateLeverReturn(ZDO zdo, RoutedRPCData data) { return Manager.Handle(ActionType.State, new string[1] { "end" }, zdo); } private static bool SetSlotVisual(ZDO zdo, RoutedRPCData data) { object[] array = ZNetView.Deserialize(data.m_senderPeerID, SetSlotVisualPars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 3) { return false; } int num = (int)array[1]; string text = (string)array[2]; string text2 = ((text == "") ? "" : text); return Manager.Handle(ActionType.State, new string[3] { "item", num.ToString(), text2 }, zdo); } private static bool MakePiece(ZDO zdo, RoutedRPCData data) { return Manager.Handle(ActionType.State, new string[1] { "piece" }, zdo); } private static bool OnEat(ZDO zdo, RoutedRPCData data) { return Manager.Handle(ActionType.State, new string[1] { "eat" }, zdo); } private static bool OnDeath(ZDO zdo, RoutedRPCData data) { return Manager.Handle(ActionType.State, new string[1] { "death" }, zdo); } private static bool OnSetPose(ZDO zdo, RoutedRPCData data) { object[] array = ZNetView.Deserialize(data.m_senderPeerID, OnSetPosePars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 2) { return false; } int num = (int)array[1]; return Manager.Handle(ActionType.State, new string[2] { "pose", num.ToString() }, zdo); } private static bool OnLegUse(ZDO zdo, RoutedRPCData data) { object[] array = ZNetView.Deserialize(data.m_senderPeerID, OnLegUsePars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 2) { return false; } bool flag = (bool)array[1]; return Manager.Handle(ActionType.State, new string[1] { flag ? "lock" : "release" }, zdo); } private static bool OnSetLoaded(ZDO zdo, RoutedRPCData data) { object[] array = ZNetView.Deserialize(data.m_senderPeerID, OnSetLoadedPars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 2) { return false; } string text = (string)array[1]; return Manager.Handle(ActionType.State, new string[2] { "loaded", text }, zdo); } private static bool OnShoot(ZDO zdo, RoutedRPCData data) { return Manager.Handle(ActionType.State, new string[1] { "shoot" }, zdo); } private static bool OnFreezeFrame(ZDO zdo, RoutedRPCData data) { object[] array = ZNetView.Deserialize(data.m_senderPeerID, OnFreezeFramePars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 2) { return false; } float value = (float)array[1]; return Manager.Handle(ActionType.State, new string[2] { "freezeframe", Helper.Format2(value) }, zdo); } private static bool OnResetCloth(ZDO zdo, RoutedRPCData data) { return Manager.Handle(ActionType.State, new string[1] { "resetcloth" }, zdo); } private static bool OnFragments(ZDO zdo, RoutedRPCData data) { return Manager.Handle(ActionType.State, new string[1] { "fragments" }, zdo); } private static bool OnStep(ZDO zdo, RoutedRPCData data) { //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_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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) object[] array = ZNetView.Deserialize(data.m_senderPeerID, OnStepPars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 3) { return false; } int num = (int)array[1]; Vector3 val = (Vector3)array[2]; return Manager.Handle(ActionType.State, new string[5] { "step", num.ToString(), Helper.Format(val.x), Helper.Format(val.z), Helper.Format(val.y) }, zdo); } private static bool OnMaterial(ZDO zdo, RoutedRPCData data) { object[] array = ZNetView.Deserialize(data.m_senderPeerID, OnMaterialPars, data.m_parameters); data.m_parameters.SetPos(0); if (array.Length < 2) { return false; } int num = (int)array[1]; return Manager.Handle(ActionType.State, new string[2] { "material", num.ToString() }, zdo); } private static bool OnEffects(ZDO zdo, RoutedRPCData data) { return Manager.Handle(ActionType.State, new string[1] { "effects" }, zdo); } private static bool OnHit(ZDO zdo, RoutedRPCData data) { return Manager.Handle(ActionType.State, new string[1] { "hit" }, zdo); } private static bool OnUnsummon(ZDO zdo, RoutedRPCData data) { return Manager.Handle(ActionType.State, new string[1] { "unsummon" }, zdo); } private static bool OnGrow(ZDO zdo, RoutedRPCData data) { return Manager.Handle(ActionType.State, new string[1] { "grow" }, zdo); } private static ZDO? GetSource(long id) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) ZDO result = null; if (id == ZDOMan.GetSessionID()) { Player localPlayer = Player.m_localPlayer; object obj; if (localPlayer == null) { obj = null; } else { ZNetView nview = ((Character)localPlayer).m_nview; obj = ((nview != null) ? nview.GetZDO() : null); } result = (ZDO)obj; } else { ZNetPeer peer = PeerManager.GetPeer(id); if (peer != null) { result = ZDOMan.instance.GetZDO(peer.m_characterID); } } return result; } } public class HandleTime { private static bool TrackTicks; private static bool TrackMinutes; private static bool TrackHours; private static bool TrackDays; private static double PreviousTime; private static int PreviousMinute; private static int PreviousHour; private static int PreviousDay; private static bool TrackRealSeconds; private static bool TrackRealMinutes; private static bool TrackRealHours; private static bool TrackRealDays; private static long PreviousRealSecond; private static int PreviousRealMinute; private static int PreviousRealHour; private static int PreviousRealDay; public static void Patch(Harmony harmony, bool trackTicks, bool trackMinutes, bool trackHours, bool trackDays) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown TrackTicks = trackTicks; TrackMinutes = trackMinutes; TrackHours = trackHours; TrackDays = trackDays; MethodInfo methodInfo = AccessTools.Method(typeof(ZNet), "UpdateNetTime", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(HandleTime), "UpdateNetTime", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } public static void PatchRealTime(Harmony harmony, bool trackSeconds, bool trackMinutes, bool trackHours, bool trackDays) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown TrackRealSeconds = trackSeconds; TrackRealMinutes = trackMinutes; TrackRealHours = trackHours; TrackRealDays = trackDays; MethodInfo methodInfo = AccessTools.Method(typeof(ZNet), "UpdateNetTime", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(typeof(HandleTime), "UpdateRealTime", (Type[])null, (Type[])null); harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(methodInfo2), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); } private static void UpdateNetTime(ZNet __instance) { //IL_00a2: 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_0116: 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) if (__instance.m_netTime == PreviousTime) { return; } long num = (long)(__instance.m_netTime * 10000000.0); long dayLengthSec = EnvMan.instance.m_dayLengthSec; double num2 = (double)dayLengthSec / 24.0; double num3 = num2 / 60.0; int num4 = (int)(__instance.m_netTime / (double)dayLengthSec); double num5 = __instance.m_netTime - (double)(num4 * dayLengthSec); int num6 = (int)(num5 / num2); int num7 = (int)((num5 - (double)num6 * num2) / num3); if (PreviousTime != 0.0) { if (TrackTicks) { Manager.HandleGlobal(ActionType.Time, new string[2] { "tick", num.ToString() }, Vector3.zero, remove: false); } if (TrackDays && PreviousDay != num4) { Manager.HandleGlobal(ActionType.Time, new string[2] { "day", num4.ToString() }, Vector3.zero, remove: false); } if (TrackHours && PreviousHour != num6) { Manager.HandleGlobal(ActionType.Time, new string[3] { "hour", num6.ToString(), num4.ToString() }, Vector3.zero, remove: false); } if (TrackMinutes && PreviousMinute != num7) { Manager.HandleGlobal(ActionType.Time, new string[4] { "minute", num7.ToString(), num6.ToString(), num4.ToString() }, Vector3.zero, remove: false); } } PreviousTime = __instance.m_netTime; PreviousDay = num4; PreviousHour = num6; PreviousMinute = num7; } private static void UpdateRealTime() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_011f: Unknown result type (might be due to invalid IL or missing references) DateTimeOffset utcNow = DateTimeOffset.UtcNow; DateTimeOffset dateTimeOffset = utcNow.ToLocalTime(); long num = utcNow.ToUnixTimeSeconds(); int minute = dateTimeOffset.Minute; int hour = dateTimeOffset.Hour; int dayOfYear = dateTimeOffset.DayOfYear; if (PreviousRealSecond != 0L) { if (TrackRealSeconds && PreviousRealSecond != num) { Manager.HandleGlobal(ActionType.RealTime, new string[2] { "second", num.ToString() }, Vector3.zero, remove: false); } if (TrackRealDays && PreviousRealDay != dayOfYear) { Manager.HandleGlobal(ActionType.RealTime, new string[2] { "day", dayOfYear.ToString() }, Vector3.zero, remove: false); } if (TrackRealHours && PreviousRealHour != hour) { Manager.HandleGlobal(ActionType.RealTime, new string[3] { "hour", hour.ToString(), dayOfYear.ToString() }, Vector3.zero, remove: false); } if (TrackRealMinutes && PreviousRealMinute != minute) { Manager.HandleGlobal(ActionType.RealTime, new string[4] { "minute", minute.ToString(), hour.ToString(), dayOfYear.ToString() }, Vector3.zero, remove: false); } } PreviousRealSecond = num; PreviousRealDay = dayOfYear; PreviousRealHour = hour; PreviousRealMinute = minute; } } public class Helper { public static bool CheckWild(string wild, string str) { if (wild == "*") { return true; } string[] array = Parse.Split(wild); if (array.Length > 1) { string[] array2 = array; for (int i = 0; i < array2.Length; i++) { if (CheckWild(array2[i], str)) { return true; } } } if (wild[0] == '*' && wild[wild.Length - 1] == '*') { return str.ToLowerInvariant().Contains(wild.Substring(1, wild.Length - 2).ToLowerInvariant()); } if (wild[0] == '*') { return str.EndsWith(wild.Substring(1), StringComparison.OrdinalIgnoreCase); } if (wild[wild.Length - 1] == '*') { return str.StartsWith(wild.Substring(0, wild.Length - 1), StringComparison.OrdinalIgnoreCase); } int num = wild.IndexOf('*'); if (num > 0 && num < wild.Length - 1) { string value = wild.Substring(0, num); string value2 = wild.Substring(num + 1); if (str.StartsWith(value, StringComparison.OrdinalIgnoreCase)) { return str.EndsWith(value2, StringComparison.OrdinalIgnoreCase); } return false; } if (Parse.TryFloat(str, out var result) && (Parse.TryFloat(wild, out var _) || wild.Contains(";"))) { Range range = Parse.FloatRange(wild); return ApproxBetween(result, range.Min, range.Max); } return str.Equals(wild, StringComparison.OrdinalIgnoreCase); } public static bool IsServer() { if (Object.op_Implicit((Object)(object)ZNet.instance)) { return ZNet.instance.IsServer(); } return false; } public static bool IsClient() { return !IsServer(); } public static bool IsZero(float a) { return Mathf.Abs(a) < 0.001f; } public static bool Approx(float a, float b) { return Mathf.Abs(a - b) < 0.001f; } public static bool ApproxBetween(float a, float min, float max) { if (min - 0.001f <= a) { return a <= max + 0.001f; } return false; } public static bool HasAnyGlobalKey(List keys, Parameters pars) { foreach (string key in keys) { if (key.Contains("<")) { if (ZoneSystem.instance.m_globalKeys.Contains(pars.Replace(key))) { return true; } } else if (ZoneSystem.instance.m_globalKeys.Contains(key)) { return true; } } return false; } public static bool HasEveryGlobalKey(List keys, Parameters pars) { foreach (string key in keys) { if (key.Contains("<")) { if (!ZoneSystem.instance.m_globalKeys.Contains(pars.Replace(key).ToLowerInvariant())) { return false; } } else if (!ZoneSystem.instance.m_globalKeys.Contains(key)) { return false; } } return true; } public static string Format(float value) { return value.ToString("0.#####", NumberFormatInfo.InvariantInfo); } public static string Format(double value) { return value.ToString("0.#####", NumberFormatInfo.InvariantInfo); } public static string FormatPos(Vector3 value) { //IL_0008: 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_0034: Unknown result type (might be due to invalid IL or missing references) return Format(value.x) + "," + Format(value.z) + "," + Format(value.y); } public static string FormatRot(Vector3 value) { //IL_0008: 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_0034: Unknown result type (might be due to invalid IL or missing references) return Format(value.y) + "," + Format(value.x) + "," + Format(value.z); } public static string FormatPos2(Vector3 value) { //IL_0008: 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_0034: Unknown result type (might be due to invalid IL or missing references) return Format2(value.x) + "," + Format2(value.z) + "," + Format2(value.y); } public static string FormatRot2(Vector3 value) { //IL_0008: 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_0034: Unknown result type (might be due to invalid IL or missing references) return Format2(value.y) + "," + Format2(value.x) + "," + Format2(value.z); } public static string Format2(float value) { return value.ToString("0.##", NumberFormatInfo.InvariantInfo); } public static List? GenerateDelays(float delay, int amount, float interval, float chance) { if (amount == 0) { return null; } List list = new List(); for (int i = 0; i < amount + 1; i++) { if (!(chance < 1f) || !(Random.value > chance)) { list.Add(delay + interval * (float)i); } } list.Reverse(); return list; } } public enum ActionType { Create, Destroy, State, Command, Say, Poke, GlobalKey, Event, Change, Key, Custom, Time, RealTime } public class InfoManager { public static readonly PrefabInfo CreateDatas = new PrefabInfo(); public static readonly PrefabInfo RemoveDatas = new PrefabInfo(); public static readonly PrefabInfo StateDatas = new PrefabInfo(); public static readonly PrefabInfo SayDatas = new PrefabInfo(); public static readonly PrefabInfo PokeDatas = new PrefabInfo(); public static readonly PrefabInfo ChangeDatas = new PrefabInfo(); public static readonly GlobalInfo GlobalKeyDatas = new GlobalInfo(); public static readonly GlobalInfo KeyDatas = new GlobalInfo(); public static readonly GlobalInfo CustomDatas = new GlobalInfo(); public static readonly GlobalInfo EventDatas = new GlobalInfo(); public static readonly GlobalInfo TimeDatas = new GlobalInfo(); public static readonly GlobalInfo RealTimeDatas = new GlobalInfo(); public static void Clear() { CreateDatas.Clear(); RemoveDatas.Clear(); StateDatas.Clear(); SayDatas.Clear(); PokeDatas.Clear(); GlobalKeyDatas.Clear(); KeyDatas.Clear(); CustomDatas.Clear(); EventDatas.Clear(); ChangeDatas.Clear(); TimeDatas.Clear(); RealTimeDatas.Clear(); } public static void Add(Info info) { if (info.Type == ActionType.GlobalKey) { GlobalKeyDatas.Add(info); return; } if (info.Type == ActionType.Key) { KeyDatas.Add(info); return; } if (info.Type == ActionType.Custom) { CustomDatas.Add(info); return; } if (info.Type == ActionType.Event) { EventDatas.Add(info); return; } if (info.Type == ActionType.Time) { TimeDatas.Add(info); return; } if (info.Type == ActionType.RealTime) { RealTimeDatas.Add(info); return; } if (info.Type == ActionType.Command) { info.Admin = new SimpleBoolValue(value: true); info.Type = ActionType.Say; } Select(info.Type).Add(info); } public static void Patch() { EWP.Harmony.UnpatchSelf(); if (Helper.IsClient()) { return; } EWP.Harmony.PatchAll(); HashSet requiredStates = GetRequiredStates(); if (CreateDatas.Exists || requiredStates.Contains("join") || requiredStates.Contains("respawn")) { HandleCreated.Patch(EWP.Harmony); } if (RemoveDatas.Exists) { HandleDestroyed.Patch(EWP.Harmony); } if (StateDatas.Exists || SayDatas.Exists) { HandleRPC.Patch(EWP.Harmony); HandleRPC.SetRequiredStates(requiredStates); } if (SayDatas.Exists) { ServerClient.Patch(EWP.Harmony); } if (GlobalKeyDatas.Exists) { HandleGlobalKey.Patch(EWP.Harmony); } if (EventDatas.Exists) { HandleEvent.Patch(EWP.Harmony); } if (ChangeDatas.Exists) { HandleChanged.Patch(EWP.Harmony, ChangeDatas); } if (TimeDatas.Exists) { bool trackTicks = TimeDatas.Separate.Any((Info v) => v.Args.Length != 0 && v.Args[0] == "tick"); bool trackMinutes = TimeDatas.Separate.Any((Info v) => v.Args.Length != 0 && v.Args[0] == "minute"); bool trackHours = TimeDatas.Separate.Any((Info v) => v.Args.Length != 0 && v.Args[0] == "hour"); bool trackDays = TimeDatas.Separate.Any((Info v) => v.Args.Length != 0 && v.Args[0] == "day"); HandleTime.Patch(EWP.Harmony, trackTicks, trackMinutes, trackHours, trackDays); } if (RealTimeDatas.Exists) { bool trackSeconds = RealTimeDatas.Separate.Any((Info v) => v.Args.Length != 0 && v.Args[0] == "second"); bool trackMinutes2 = RealTimeDatas.Separate.Any((Info v) => v.Args.Length != 0 && v.Args[0] == "minute"); bool trackHours2 = RealTimeDatas.Separate.Any((Info v) => v.Args.Length != 0 && v.Args[0] == "hour"); bool trackDays2 = RealTimeDatas.Separate.Any((Info v) => v.Args.Length != 0 && v.Args[0] == "day"); HandleTime.PatchRealTime(EWP.Harmony, trackSeconds, trackMinutes2, trackHours2, trackDays2); } DataStorage.OnSet = (KeyDatas.Exists ? new Action(OnKeySet) : null); } private static HashSet GetRequiredStates() { HashSet hashSet = new HashSet(); if (SayDatas.Exists) { hashSet.Add("say"); } foreach (List value in StateDatas.Weighted.Values) { foreach (Info item in value) { if (item.Args.Length != 0) { hashSet.Add(item.Args[0]); } } } foreach (List value2 in StateDatas.Fallback.Values) { foreach (Info item2 in value2) { if (item2.Args.Length != 0) { hashSet.Add(item2.Args[0]); } } } foreach (List value3 in StateDatas.Separate.Values) { foreach (Info item3 in value3) { if (item3.Args.Length != 0) { hashSet.Add(item3.Args[0]); } } } return hashSet; } private static void OnKeySet(string key, string value) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Manager.HandleGlobal(ActionType.Key, new string[2] { key, value }, Vector3.zero, value == ""); } public static PrefabInfo Select(ActionType type) { return type switch { ActionType.Destroy => RemoveDatas, ActionType.State => StateDatas, ActionType.Say => SayDatas, ActionType.Poke => PokeDatas, ActionType.Create => CreateDatas, ActionType.Change => ChangeDatas, _ => Error(type), }; } private static PrefabInfo Error(ActionType type) { Log.Error($"Unknown entry type {type}"); return new PrefabInfo(); } public static GlobalInfo SelectGlobal(ActionType type) { return type switch { ActionType.GlobalKey => GlobalKeyDatas, ActionType.Key => KeyDatas, ActionType.Custom => CustomDatas, ActionType.Event => EventDatas, ActionType.Time => TimeDatas, ActionType.RealTime => RealTimeDatas, _ => ErrorGlobal(type), }; } private static GlobalInfo ErrorGlobal(ActionType type) { Log.Error($"Unknown entry type {type}"); return new GlobalInfo(); } } public class PrefabInfo { public readonly Dictionary> Weighted = new Dictionary>(); public readonly Dictionary> Fallback = new Dictionary>(); public readonly Dictionary> Separate = new Dictionary>(); public bool Exists { get { if (Weighted.Count <= 0 && Fallback.Count <= 0) { return Separate.Count > 0; } return true; } } public void Clear() { Weighted.Clear(); Fallback.Clear(); Separate.Clear(); } public void Add(Info info) { foreach (int item in PrefabHelper.GetPrefabs(info.Prefabs, info.ExcludedPrefabs).ToList()) { if (info.Fallback) { if (!Fallback.TryGetValue(item, out List value)) { value = (Fallback[item] = new List()); } value.Add(info); } else if (info.Weight != null) { if (!Weighted.TryGetValue(item, out List value2)) { value2 = (Weighted[item] = new List()); } value2.Add(info); } else { if (!Separate.TryGetValue(item, out List value3)) { value3 = (Separate[item] = new List()); } value3.Add(info); } } } public bool TryGetWeightedValue(int prefab, out List list) { return Weighted.TryGetValue(prefab, out list); } public bool TryGetFallbackValue(int prefab, out List list) { return Fallback.TryGetValue(prefab, out list); } public bool TryGetSeparateValue(int prefab, out List list) { return Separate.TryGetValue(prefab, out list); } } public class GlobalInfo { public readonly List Weighted = new List(); public readonly List Fallback = new List(); public readonly List Separate = new List(); public bool Exists { get { if (Weighted.Count <= 0 && Fallback.Count <= 0) { return Separate.Count > 0; } return true; } } public void Clear() { Weighted.Clear(); Fallback.Clear(); Separate.Clear(); } public void Add(Info info) { if (info.Fallback) { Fallback.Add(info); } else if (info.Weight != null) { Weighted.Add(info); } else { Separate.Add(info); } } } public class InfoSelector { public static Info? SelectWeighted(ActionType type, ZDO zdo, string[] args, Parameters parameters) { if (!InfoManager.Select(type).TryGetWeightedValue(zdo.m_prefab, out List list)) { return null; } return SelectInfo(list, zdo, args, parameters); } public static Info? SelectFallback(ActionType type, ZDO zdo, string[] args, Parameters parameters) { if (!InfoManager.Select(type).TryGetFallbackValue(zdo.m_prefab, out List list)) { return null; } return SelectInfo(list, zdo, args, parameters); } public static Info[]? SelectSeparate(ActionType type, ZDO zdo, string[] args, Parameters parameters) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) if (!InfoManager.Select(type).TryGetSeparateValue(zdo.m_prefab, out List list)) { return null; } return SelectInfos(list, zdo.m_position, zdo, args, parameters); } private static Info? SelectInfo(List data, ZDO zdo, string[] args, Parameters parameters) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Info[] array = SelectInfos(data, zdo.m_position, zdo, args, parameters); if (array == null || array.Length == 0) { return null; } return Randomize(array, parameters); } private static Info[]? SelectInfos(List data, Vector3 pos, ZDO zdo, string[] args, Parameters parameters) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Unknown result type (might be due to invalid IL or missing references) //IL_0567: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_0680: Unknown result type (might be due to invalid IL or missing references) //IL_0686: Unknown result type (might be due to invalid IL or missing references) //IL_068b: Unknown result type (might be due to invalid IL or missing references) //IL_0690: Unknown result type (might be due to invalid IL or missing references) string[] args2 = args; Parameters parameters2 = parameters; ZDO zdo2 = zdo; if (data.Count == 0) { return null; } Biome biome = WorldGenerator.instance.GetBiome(pos); float distance = Utils.LengthXZ(pos); bool day = EnvMan.IsDay(); float waterY = pos.y - ZoneSystem.instance.m_waterLevel; IEnumerable collection = from d in (from d in data where CheckArgs(d, args2) where (Biome)(d.Biomes & biome) == biome where (d.BannedBiomes & biome) == 0 select d).Where(delegate(Info d) { IBoolValue? day2 = d.Day; return day2 == null || day2.GetBool(parameters2) != false || !day; }).Where(delegate(Info d) { IBoolValue? night = d.Night; return night == null || night.GetBool(parameters2) != false || day; }) where d.MinDistance == null || !d.MinDistance.TryGet(parameters2, out var value10) || value10 < distance where d.MaxDistance == null || !d.MaxDistance.TryGet(parameters2, out var value9) || value9 >= distance where d.MinY == null || !d.MinY.TryGet(parameters2, out var value8) || value8 < pos.y where d.MaxY == null || !d.MaxY.TryGet(parameters2, out var value7) || value7 >= pos.y where d.MinX == null || !d.MinX.TryGet(parameters2, out var value6) || value6 < pos.x where d.MaxX == null || !d.MaxX.TryGet(parameters2, out var value5) || value5 >= pos.x where d.MinZ == null || !d.MinZ.TryGet(parameters2, out var value4) || value4 < pos.z where d.MaxZ == null || !d.MaxZ.TryGet(parameters2, out var value3) || value3 >= pos.z where d.MinAltitude == null || !d.MinAltitude.TryGet(parameters2, out var value2) || value2 < waterY where d.MaxAltitude == null || !d.MaxAltitude.TryGet(parameters2, out var value) || value >= waterY where Helper.HasEveryGlobalKey(d.GlobalKeys, parameters2) where !Helper.HasAnyGlobalKey(d.BannedGlobalKeys, parameters2) where DataStorage.HasEveryKey(d.Keys, parameters2) where !DataStorage.HasAnyKey(d.BannedKeys, parameters2) select d; List list = new List(); list.AddRange(collection); collection = new <>z__ReadOnlyList(list); bool num = collection.Any((Info d) => d.Environments.Count > 0) || collection.Any((Info d) => d.BannedEnvironments.Count > 0); bool flag = collection.Any((Info d) => d.Events.Count > 0); bool flag2 = collection.Any((Info d) => d.Objects != null); bool flag3 = collection.Any((Info d) => d.BannedObjects != null); bool flag4 = collection.Any((Info d) => d.Locations != null || d.BannedLocations != null); bool flag5 = collection.Any((Info d) => d.PlayerEvents != null || d.BannedPlayerEvents != null); bool flag6 = collection.Any((Info d) => d.Groups != null || d.BannedGroups != null); bool flag7 = collection.Any((Info d) => d.Filters != null); bool flag8 = collection.Any((Info d) => d.MinPaint.HasValue || d.MaxPaint.HasValue); bool num2 = collection.Any((Info d) => d.MinTerrainHeight != null || d.MaxTerrainHeight != null); bool flag9 = collection.Any((Info d) => d.Admin != null); if (num2) { float height = WorldGenerator.instance.GetHeight(pos.x, pos.z); List list2 = new List(); list2.AddRange(collection.Where((Info d) => (d.MinTerrainHeight == null && d.MaxTerrainHeight == null) || Helper.ApproxBetween(height, (d.MinTerrainHeight?.Get(parameters2)).GetValueOrDefault(-1000000f), (d.MaxTerrainHeight?.Get(parameters2)).GetValueOrDefault(1000000f)))); collection = new <>z__ReadOnlyList(list2); } if (num) { string environment = GetEnvironment(biome); List list3 = new List(); list3.AddRange(from d in collection where d.Environments.Count == 0 || d.Environments.Contains(environment) where !d.BannedEnvironments.Contains(environment) select d); collection = new <>z__ReadOnlyList(list3); } if (flag) { RandomEvent ev2 = EWP.GetCurrentEvent(pos); List list4 = new List(); list4.AddRange(collection.Where((Info d) => d.EventDistance == 0f || (ev2 != null && (d.Events.Contains(ev2.m_name) || d.Events.Count == 0) && d.EventDistance >= Utils.DistanceXZ(pos, ev2.m_pos)))); collection = new <>z__ReadOnlyList(list4); } if (flag2) { List list5 = new List(); list5.AddRange(collection.Where((Info d) => d.Objects == null || ObjectsFiltering.HasNearby(d.ObjectsLimit, d.Objects, zdo2, parameters2))); collection = new <>z__ReadOnlyList(list5); } if (flag3) { List list6 = new List(); list6.AddRange(collection.Where((Info d) => d.BannedObjects == null || ObjectsFiltering.HasNotNearby(d.BannedObjectsLimit, d.BannedObjects, zdo2, parameters2))); collection = new <>z__ReadOnlyList(list6); } if (flag9) { bool admin = PeerManager.IsAdmin(zdo2); List list7 = new List(); list7.AddRange(collection.Where((Info d) => d.Admin == null || d.Admin.GetBool(parameters2) == admin)); collection = new <>z__ReadOnlyList(list7); } if (flag4) { Vector2i zone = ZoneSystem.GetZone(pos); List list8 = new List(); list8.AddRange(collection.Where((Info d) => CheckLocations(d, pos, zone))); collection = new <>z__ReadOnlyList(list8); } if (flag5) { string playerData = PeerManager.GetPlayerData(zdo2, "possibleEvents"); string[] events = playerData.Split(new char[1] { ',' }); List list9 = new List(); list9.AddRange(collection.Where(delegate(Info d) { if (d.BannedPlayerEvents != null && events.Any((string ev) => d.BannedPlayerEvents.Contains(ev))) { return false; } return d.PlayerEvents == null || events.Any((string ev) => d.PlayerEvents.Contains(ev)); })); collection = new <>z__ReadOnlyList(list9); } if (flag6) { string pid = PeerManager.GetPid(zdo2); long cid = PeerManager.GetCid(zdo2).GetValueOrDefault(); List list10 = new List(); list10.AddRange(collection.Where((Info d) => CheckGroups(d, pid, cid))); collection = new <>z__ReadOnlyList(list10); } if (flag7) { List list11 = new List(); list11.AddRange(collection.Where((Info d) => d.Filters == null || d.Filters.Match(parameters2, zdo2))); collection = new <>z__ReadOnlyList(list11); } if (flag8) { Color paint = Paint.GetPaint(pos, biome); List list12 = new List(); list12.AddRange(collection.Where((Info d) => (!d.MinPaint.HasValue || (d.MinPaint.Value.b <= paint.b && d.MinPaint.Value.g <= paint.g && d.MinPaint.Value.r <= paint.r && d.MinPaint.Value.a <= paint.a)) && (!d.MaxPaint.HasValue || (d.MaxPaint.Value.b >= paint.b && d.MaxPaint.Value.g >= paint.g && d.MaxPaint.Value.r >= paint.r && d.MaxPaint.Value.a >= paint.a)))); collection = new <>z__ReadOnlyList(list12); } List list13 = new List(); list13.AddRange(collection); Info[] array = list13.ToArray(); if (array.Length != 0) { return array; } return null; } private static bool CheckGroups(Info d, string pid, long cid) { string pid2 = pid; if (d.BannedGroups != null && d.BannedGroups.Any((string group) => Api.IsInGroup(pid2, cid, group))) { return false; } if (d.Groups == null) { return true; } return d.Groups.Any((string group) => Api.IsInGroup(pid2, cid, group)); } private static bool CheckLocations(Info d, Vector3 pos, Vector2i zone) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000b: 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) if (CheckBannedLocations(d, pos, zone)) { return CheckRequiredLocations(d, pos, zone); } return false; } private static bool CheckBannedLocations(Info d, Vector3 pos, Vector2i zone) { //IL_002a: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_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 (d.BannedLocations == null) { return true; } int num = (int)(d.BannedLocationDistance / 64f) + 1; int num2 = (int)(d.BannedLocationDistance / 64f) + 1; int num3 = zone.x - num; int num4 = zone.x + num; int num5 = zone.y - num2; int num6 = zone.y + num2; Vector2i key = default(Vector2i); for (int i = num3; i <= num4; i++) { for (int j = num5; j <= num6; j++) { ((Vector2i)(ref key))..ctor(i, j); if (ZoneSystem.instance.m_locationInstances.TryGetValue(key, out var value) && d.BannedLocations.Contains(value.m_location.m_prefabName)) { float num7 = ((d.LocationDistance == 0f) ? value.m_location.m_exteriorRadius : d.LocationDistance); if (Utils.DistanceXZ(value.m_position, pos) <= num7) { return false; } } } } return true; } private static bool CheckRequiredLocations(Info d, Vector3 pos, Vector2i zone) { //IL_002a: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_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 (d.Locations == null) { return true; } int num = (int)(d.LocationDistance / 64f) + 1; int num2 = (int)(d.LocationDistance / 64f) + 1; int num3 = zone.x - num; int num4 = zone.x + num; int num5 = zone.y - num2; int num6 = zone.y + num2; Vector2i key = default(Vector2i); for (int i = num3; i <= num4; i++) { for (int j = num5; j <= num6; j++) { ((Vector2i)(ref key))..ctor(i, j); if (ZoneSystem.instance.m_locationInstances.TryGetValue(key, out var value) && d.Locations.Contains(value.m_location.m_prefabName)) { float num7 = ((d.LocationDistance == 0f) ? value.m_location.m_exteriorRadius : d.LocationDistance); if (Utils.DistanceXZ(value.m_position, pos) <= num7) { return true; } } } } return false; } private static Info? Randomize(Info[] valid, Parameters parameters) { Parameters parameters2 = parameters; if (valid.Length == 0) { return null; } float[] array = valid.Select((Info d) => (d.Weight?.Get(parameters2)).GetValueOrDefault(1f)).ToArray(); if (valid.Length == 1 && array[0] >= 1f) { return valid[0]; } float num = Mathf.Max(1f, array.Sum()); float num2 = Random.Range(0f, num); for (int i = 0; i < valid.Length; i++) { num2 -= array[i]; if (num2 <= 0f) { return valid[i]; } } return null; } private static bool CheckArgs(Info info, string[] args) { if (info.Args.Length == 0) { return true; } if (info.Args.Length > args.Length) { return false; } for (int i = 0; i < info.Args.Length; i++) { if (!Helper.CheckWild(info.Args[i], args[i])) { return false; } } return true; } private static string GetEnvironment(Biome biome) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0044: Unknown result type (might be due to invalid IL or missing references) EnvMan instance = EnvMan.instance; List availableEnvironments = instance.GetAvailableEnvironments(biome); if (availableEnvironments == null || availableEnvironments.Count == 0) { return ""; } State state = Random.state; Random.InitState((int)((long)ZNet.instance.GetTimeSeconds() / instance.m_environmentDuration)); EnvSetup obj = instance.SelectWeightedEnvironment(availableEnvironments); Random.state = state; return obj.m_name.ToLower(); } public static Info? SelectGlobalWeighted(ActionType type, string[] args, Parameters parameters, Vector3 pos, bool remove) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) return SelectGlobalInfo(InfoManager.SelectGlobal(type).Weighted, args, parameters, pos, remove); } public static Info? SelectGlobalFallback(ActionType type, string[] args, Parameters parameters, Vector3 pos, bool remove) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) return SelectGlobalInfo(InfoManager.SelectGlobal(type).Fallback, args, parameters, pos, remove); } public static Info[]? SelectGlobalSeparate(ActionType type, string[] args, Parameters parameters, Vector3 pos, bool remove) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) return SelectGlobalInfos(InfoManager.SelectGlobal(type).Separate, args, parameters, pos, remove); } private static Info? SelectGlobalInfo(List data, string[] args, Parameters parameters, Vector3 pos, bool remove) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) Info[] array = SelectGlobalInfos(data, args, parameters, pos, remove); if (array == null || array.Length == 0) { return null; } return Randomize(array, parameters); } private static Info[]? SelectGlobalInfos(List data, string[] args, Parameters parameters, Vector3 pos, bool remove) { //IL_001d: 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_003a: Unknown result type (might be due to invalid IL or missing references) string[] args2 = args; Parameters parameters2 = parameters; if (data.Count == 0) { return null; } bool day = EnvMan.IsDay(); float distance = Utils.LengthXZ(pos); float waterY = pos.y - ZoneSystem.instance.m_waterLevel; float value4; float value3; float value2; float value; IEnumerable collection = from d in (from d in data where CheckArgs(d, args2) where remove == (d.Remove?.GetBool(parameters2).GetValueOrDefault() ?? false) select d).Where(delegate(Info d) { IBoolValue? day2 = d.Day; return day2 == null || day2.GetBool(parameters2) != false || !day; }).Where(delegate(Info d) { IBoolValue? night = d.Night; return night == null || night.GetBool(parameters2) != false || day; }) where d.MinDistance == null || distance >= d.MinDistance.Get(parameters2) where d.MaxDistance == null || distance < d.MaxDistance.Get(parameters2) where d.MinY == null || !d.MinY.TryGet(parameters2, out value4) || value4 < pos.y where d.MaxY == null || !d.MaxY.TryGet(parameters2, out value3) || value3 >= pos.y where d.MinAltitude == null || !d.MinAltitude.TryGet(parameters2, out value2) || value2 < waterY where d.MaxAltitude == null || !d.MaxAltitude.TryGet(parameters2, out value) || value >= waterY where Helper.HasEveryGlobalKey(d.GlobalKeys, parameters2) where !Helper.HasAnyGlobalKey(d.BannedGlobalKeys, parameters2) where DataStorage.HasEveryKey(d.Keys, parameters2) where !DataStorage.HasAnyKey(d.BannedKeys, parameters2) select d; List list = new List(); list.AddRange(collection); Info[] array = list.ToArray(); if (array.Length != 0) { return array; } return null; } } public class ObjectsFiltering { public static ZDOID[] GetNearby(int limit, Object[] objects, Vector3 pos, Quaternion rot, Parameters parameters, ZDOID? exclude) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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) if (objects.Length == 0) { return Array.Empty(); } for (int i = 0; i < objects.Length; i++) { objects[i].Roll(parameters, pos, rot); } if (objects.Max((Object o) => o.MaxDistance) > 10000f) { Dictionary.ValueCollection values = ZDOMan.instance.m_objectsByID.Values; return GetObjects(limit, values, objects, pos, parameters, exclude); } List> sectorIndices = GetSectorIndices(objects); return GetObjects(limit, sectorIndices, objects, pos, parameters, exclude); } public static ZDOID[] GetNearby(int limit, Object objects, Vector3 pos, Quaternion rot, Parameters parameters, ZDOID? exclude) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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_002a: Unknown result type (might be due to invalid IL or missing references) objects.Roll(parameters, pos, rot); if (objects.MaxDistance > 10000f) { Dictionary.ValueCollection values = ZDOMan.instance.m_objectsByID.Values; return GetObjects(limit, values, objects, pos, parameters, exclude); } List> sectorIndices = GetSectorIndices(objects); return GetObjects(limit, sectorIndices, objects, pos, parameters, exclude); } private static ZDOID[] GetObjects(int limit, List> zdoLists, Object objects, Vector3 pos, Parameters parameters, ZDOID? exclude) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Object objects2 = objects; Parameters parameters2 = parameters; _ = ZDOMan.instance; IEnumerable source = zdoLists.SelectMany((List z) => z).Where(delegate(ZDO z) { //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_001d: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = z.m_uid; ZDOID? val = exclude; return (!val.HasValue || uid != val.GetValueOrDefault()) && objects2.IsValid(z, parameters2); }); if (limit > 0) { source = source.OrderBy((ZDO z) => Utils.DistanceXZ(z.m_position, pos)).Take(limit); } List list = new List(); list.AddRange(source.Select((ZDO z) => z.m_uid)); return list.ToArray(); } private static ZDOID[] GetObjects(int limit, Dictionary.ValueCollection zdos, Object objects, Vector3 pos, Parameters parameters, ZDOID? exclude) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Object objects2 = objects; Parameters parameters2 = parameters; _ = ZDOMan.instance; IEnumerable source = zdos.Where(delegate(ZDO z) { //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_001d: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = z.m_uid; ZDOID? val = exclude; return (!val.HasValue || uid != val.GetValueOrDefault()) && objects2.IsValid(z, parameters2); }); if (limit > 0) { source = source.OrderBy((ZDO z) => Utils.DistanceXZ(z.m_position, pos)).Take(limit); } List list = new List(); list.AddRange(source.Select((ZDO z) => z.m_uid)); return list.ToArray(); } private static ZDOID[] GetObjects(int limit, List> zdoLists, Object[] objects, Vector3 pos, Parameters parameters, ZDOID? exclude) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Object[] objects2 = objects; Parameters parameters2 = parameters; _ = ZDOMan.instance; IEnumerable source = zdoLists.SelectMany((List z) => z).Where(delegate(ZDO z) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0036: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = z.m_uid; ZDOID? val = exclude; return (!val.HasValue || uid != val.GetValueOrDefault()) && objects2.Any((Object o) => o.IsValid(z, parameters2)); }); if (limit > 0) { source = source.OrderBy((ZDO z) => Utils.DistanceXZ(z.m_position, pos)).Take(limit); } List list = new List(); list.AddRange(source.Select((ZDO z) => z.m_uid)); return list.ToArray(); } private static ZDOID[] GetObjects(int limit, Dictionary.ValueCollection zdos, Object[] objects, Vector3 pos, Parameters parameters, ZDOID? exclude) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) Object[] objects2 = objects; Parameters parameters2 = parameters; _ = ZDOMan.instance; IEnumerable source = zdos.Where(delegate(ZDO z) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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_0036: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = z.m_uid; ZDOID? val = exclude; return (!val.HasValue || uid != val.GetValueOrDefault()) && objects2.Any((Object o) => o.IsValid(z, parameters2)); }); if (limit > 0) { source = source.OrderBy((ZDO z) => Utils.DistanceXZ(z.m_position, pos)).Take(limit); } List list = new List(); list.AddRange(source.Select((ZDO z) => z.m_uid)); return list.ToArray(); } public static bool HasNearby(Range? limit, Object[] objects, ZDO zdo, Parameters parameters) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (objects.Length == 0) { return true; } for (int i = 0; i < objects.Length; i++) { objects[i].Roll(parameters, zdo.m_position, zdo.GetRotation()); } if (objects.Max((Object o) => o.MaxDistance) > 10000f) { Dictionary.ValueCollection values = ZDOMan.instance.m_objectsByID.Values; if (limit == null) { return HasAllObjects(values, objects, zdo, parameters); } return HasLimitObjects(values, limit, objects, zdo, parameters); } List> sectorIndices = GetSectorIndices(objects); if (limit == null) { return HasAllObjects(sectorIndices, objects, zdo, parameters); } return HasLimitObjects(sectorIndices, limit, objects, zdo, parameters); } public static bool HasNotNearby(Range? limit, Object[] objects, ZDO zdo, Parameters parameters) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (objects.Length == 0) { return true; } for (int i = 0; i < objects.Length; i++) { objects[i].Roll(parameters, zdo.m_position, zdo.GetRotation()); } List> sectorIndices = GetSectorIndices(objects); if (limit == null) { return !HasAllObjects(sectorIndices, objects, zdo, parameters); } return !HasLimitObjects(sectorIndices, limit, objects, zdo, parameters); } private static bool HasAllObjects(List> zdoLists, Object[] objects, ZDO zdo, Parameters parameters) { List> zdoLists2 = zdoLists; Parameters parameters2 = parameters; ZDO zdo2 = zdo; return objects.All((Object o) => zdoLists2.Any((List zdos) => zdos.Any((ZDO z) => o.IsValid(z, parameters2) && z != zdo2))); } private static bool HasAllObjects(Dictionary.ValueCollection zdos, Object[] objects, ZDO zdo, Parameters parameters) { Dictionary.ValueCollection zdos2 = zdos; Parameters parameters2 = parameters; ZDO zdo2 = zdo; return objects.All((Object o) => zdos2.Any((ZDO z) => o.IsValid(z, parameters2) && z != zdo2)); } private static bool HasLimitObjects(List> zdoLists, Range limit, Object[] objects, ZDO zdo, Parameters parameters) { Parameters parameters2 = parameters; ZDO zdo2 = zdo; int num = 0; bool flag = limit.Max > 0; foreach (List zdoList in zdoLists) { foreach (ZDO z in zdoList) { Object @object = objects.FirstOrDefault((Object o) => o.IsValid(z, parameters2) && z != zdo2); if (@object != null) { num += @object.Weight; if (flag && limit.Max < num) { return false; } if (limit.Min <= num && !flag) { return true; } } } } if (limit.Min <= num) { return num <= limit.Max; } return false; } private static bool HasLimitObjects(Dictionary.ValueCollection zdos, Range limit, Object[] objects, ZDO zdo, Parameters parameters) { Parameters parameters2 = parameters; ZDO zdo2 = zdo; int num = 0; bool flag = limit.Max > 0; foreach (ZDO z in zdos) { Object @object = objects.FirstOrDefault((Object o) => o.IsValid(z, parameters2) && z != zdo2); if (@object != null) { num += @object.Weight; if (flag && limit.Max < num) { return false; } if (limit.Min <= num && !flag) { return true; } } } if (limit.Min <= num) { return num <= limit.Max; } return false; } private static List> GetSectorIndices(Object[] objects) { List> list = new List>(); HashSet handled = new HashSet(); for (int i = 0; i < objects.Length; i++) { GetSectorIndices(objects[i], list, handled); } return list; } private static List> GetSectorIndices(Object objects) { List> list = new List>(); HashSet handled = new HashSet(); GetSectorIndices(objects, list, handled); return list; } private static void GetSectorIndices(Object o, List> zdoLists, HashSet handled) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_0025: 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_0033: Unknown result type (might be due to invalid IL or missing references) //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_00ed: 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_00da: 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_0076: 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_009f: Unknown result type (might be due to invalid IL or missing references) float maxDistance = o.MaxDistance; Vector2i zone = ZoneSystem.GetZone(o.CachedPosition + new Vector3(0f - maxDistance, 0f, 0f - maxDistance)); Vector2i zone2 = ZoneSystem.GetZone(o.CachedPosition + new Vector3(maxDistance, 0f, maxDistance)); ZDOMan instance = ZDOMan.instance; Vector2i val = default(Vector2i); for (int i = zone.x; i <= zone2.x; i++) { for (int j = zone.y; j <= zone2.y; j++) { ((Vector2i)(ref val))..ctor(i, j); if (handled.Contains(val)) { continue; } handled.Add(val); int num = instance.SectorToIndex(val); if (num < 0 || num >= instance.m_objectsBySector.Length) { if (instance.m_objectsByOutsideSector.TryGetValue(val, out var value) && value != null) { zdoLists.Add(value); } } else if (instance.m_objectsBySector[num] != null) { zdoLists.Add(instance.m_objectsBySector[num]); } } } } } public static class Paint { private static readonly int TerrainCompilerHash = StringExtensionMethods.GetStableHashCode("_TerrainCompiler"); public static Color GetPaint(Vector3 pos, Biome biome) { //IL_0005: 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_000c: 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_0025: 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_003a: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0047: 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_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) Color result = default(Color); WorldGenerator.instance.GetBiomeHeight(biome, pos.x, pos.z, ref result, false); ZDO compiler = GetCompiler(pos); if (compiler == null) { return result; } byte[] byteArray = compiler.GetByteArray(ZDOVars.s_TCData, (byte[])null); if (byteArray == null) { return result; } Vector3 zonePos = ZoneSystem.GetZonePos(ZoneSystem.GetZone(pos)); Vector3 val = pos - zonePos; int num = Mathf.FloorToInt(val.x + 0.5f) + 32; int num2 = Mathf.FloorToInt(val.z + 0.5f) + 32; int num3 = num + num2 * 65; ZPackage val2 = new ZPackage(Utils.Decompress(byteArray)); val2.ReadInt(); val2.ReadInt(); val2.ReadVector3(); val2.ReadSingle(); int num4 = val2.ReadInt(); for (int i = 0; i < num4; i++) { if (val2.ReadBool()) { val2.ReadSingle(); val2.ReadSingle(); } } int num5 = val2.ReadInt(); for (int j = 0; j < num5; j++) { if (val2.ReadBool()) { float num6 = val2.ReadSingle(); float num7 = val2.ReadSingle(); float num8 = val2.ReadSingle(); float num9 = val2.ReadSingle(); if (j == num3) { return new Color(num6, num7, num8, num9); } } else if (j == num3) { return result; } } return result; } private static ZDO? GetCompiler(Vector3 pos) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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) Vector2i zone = ZoneSystem.GetZone(pos); int num = ZDOMan.instance.SectorToIndex(zone); if (num > -1) { List list = ZDOMan.instance.m_objectsBySector[num]; if (list == null) { return null; } foreach (ZDO item in list) { if (item.m_prefab == TerrainCompilerHash) { return item; } } } else if (ZDOMan.instance.m_objectsByOutsideSector.ContainsKey(zone)) { List list2 = ZDOMan.instance.m_objectsByOutsideSector[zone]; if (list2 == null) { return null; } foreach (ZDO item2 in list2) { if (item2.m_prefab == TerrainCompilerHash) { return item2; } } } return null; } } public class PeerManager { private static readonly Dictionary PeersByOwner = new Dictionary(); private static readonly Dictionary PeerIds = new Dictionary(); private static readonly HashSet HandledPeers = new HashSet(); private static readonly int PlayerHash = StringExtensionMethods.GetStableHashCode("Player"); public static ZNetPeer? GetPeer(ZDO zdo) { return GetPeer(zdo.GetOwner()); } public static ZNetPeer? GetPeer(long owner) { if (owner == 0L || !Object.op_Implicit((Object)(object)ZNet.instance)) { return null; } if (PeersByOwner.TryGetValue(owner, out ZNetPeer value)) { return value; } value = ZNet.instance.GetPeer(owner); if (value != null) { PeersByOwner[owner] = value; } return value; } private static void RemoveCachedPeer(long owner, ZNetPeer peer) { if (owner != 0L) { PeersByOwner.Remove(owner); } List list = new List(); foreach (KeyValuePair item in PeersByOwner) { if (item.Value == peer) { list.Add(item.Key); } } foreach (long item2 in list) { PeersByOwner.Remove(item2); } } [HarmonyPatch(typeof(ZNet), "Disconnect")] [HarmonyPrefix] private static void DisconnectPrefix(ZNetPeer peer) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) RemoveCachedPeer(peer.m_uid, peer); PeerIds.Remove(peer); HandledPeers.Remove(peer); ZDO zDO = ZDOMan.instance.GetZDO(peer.m_characterID); if (zDO != null) { Manager.Handle(ActionType.State, new string[1] { "leave" }, zDO); } } public static void HandlePlayerCreatedState(ZDO zdo) { if (zdo.m_prefab != PlayerHash) { return; } ZNetPeer peer = GetPeer(zdo.GetOwner()); if (peer != null) { if (HandledPeers.Contains(peer)) { Manager.Handle(ActionType.State, new string[1] { "respawn" }, zdo); } else { HandledPeers.Add(peer); Manager.Handle(ActionType.State, new string[1] { "join" }, zdo); } } } public static string GetPid(ZDO zdo) { ZNetPeer peer = GetPeer(zdo); if (peer != null && peer.IsReady()) { return GetPeerPid(peer); } if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return "Server"; } return ""; } public static long? GetCid(ZDO zdo) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) ZNetPeer peer = GetPeer(zdo); if (peer != null) { ZDO zDO = ZDOMan.instance.GetZDO(peer.m_characterID); if (zDO != null) { long? num = ZdoHelper.TryGetLong(zDO, ZDOVars.s_playerID); if (num.HasValue) { return num.Value; } } } else if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return Player.m_localPlayer.GetPlayerID(); } return null; } public static string GetPlatform(ZDO zdo) { ZNetPeer peer = GetPeer(zdo); if (peer != null && peer.IsReady()) { return GetPeerPlatform(peer); } if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return "Server"; } return ""; } public static string GetPName(ZDO zdo) { ZNetPeer peer = GetPeer(zdo); if (peer != null) { return peer.m_playerName; } if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return Player.m_localPlayer.GetPlayerName(); } return ""; } public static string GetPChar(ZDO zdo) { ZNetPeer peer = GetPeer(zdo); if (peer != null) { return ((object)(ZDOID)(ref peer.m_characterID)).ToString(); } if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return Player.m_localPlayer.GetPlayerID().ToString(); } return ""; } public static string GetPVisible(ZDO zdo) { ZNetPeer peer = GetPeer(zdo); if (peer != null) { return peer.m_publicRefPos.ToString(); } if (Object.op_Implicit((Object)(object)ZNet.instance)) { return ZNet.instance.IsReferencePositionPublic().ToString(); } return ""; } public static string GetPlayerData(ZDO zdo, string key) { ZNetPeer peer = GetPeer(zdo); if (peer != null) { if (!peer.m_serverSyncedPlayerData.TryGetValue(key, out var value)) { return ""; } return value; } if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { if (!ZNet.instance.m_serverSyncedPlayerData.TryGetValue(key, out var value2)) { return ""; } return value2; } return ""; } public static bool IsAdmin(ZDO zdo) { ZNetPeer peer = GetPeer(zdo); if (peer == null) { return false; } return ZNet.instance.IsAdmin(peer.m_socket.GetHostName()); } private static string GetPeerPid(ZNetPeer peer) { //IL_0022: 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_000f: Unknown result type (might be due to invalid IL or missing references) if (PeerIds.TryGetValue(peer, out var value)) { return value.m_userID.ToString(); } PeerIds[peer] = GetUserId(peer); return PeerIds[peer].m_userID.ToString(); } private static string GetPeerPlatform(ZNetPeer peer) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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) //IL_0045: 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) //IL_0010: 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) Platform platform; if (PeerIds.TryGetValue(peer, out var value)) { platform = value.m_platform; return ((object)(Platform)(ref platform)).ToString(); } PeerIds[peer] = GetUserId(peer); platform = PeerIds[peer].m_platform; return ((object)(Platform)(ref platform)).ToString(); } private static PlatformUserID GetUserId(ZNetPeer peer) { //IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) if ((int)ZNet.m_onlineBackend == 0) { return new PlatformUserID(ZNet.instance.m_steamPlatform, peer.m_socket.GetHostName()); } return new PlatformUserID(peer.m_socket.GetHostName()); } [HarmonyPatch(typeof(ZNet), "ClearPlayerData")] [HarmonyPostfix] private static void ClearPlayerDataPostfix(ZNetPeer peer) { RemoveCachedPeer(peer.m_uid, peer); PeerIds.Remove(peer); HandledPeers.Remove(peer); } } [HarmonyPatch(typeof(ZDOExtraData), "SetConnection")] public class PrefabConnector { private static readonly Dictionary SwappedZDOs = new Dictionary(); private static readonly Dictionary ReverseConnectionTable = new Dictionary(); public static void AddSwap(ZDOID from, ZDOID to) { //IL_0005: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0058: 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) //IL_0068: Expected O, but got Unknown //IL_006d: 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) SwappedZDOs[from] = to; if (ZDOExtraData.s_connections.TryGetValue(from, out var value)) { ZDOExtraData.s_connections.Remove(from); ZDOExtraData.s_connections[to] = value; } if (ReverseConnectionTable.TryGetValue(from, out var value2) && ZDOExtraData.s_connections.TryGetValue(value2, out var value3)) { ZDOExtraData.s_connections[value2] = new ZDOConnection(value3.m_type, to); ZDO zDO = ZDOMan.instance.GetZDO(value2); if (zDO != null) { zDO.DataRevision += 100; ZDOMan.instance.ForceSendZDO(value2); } } } private static void Prefix(ZDOID zid, ref ZDOID target) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: 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_0016: 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_0039: Unknown result type (might be due to invalid IL or missing references) if (SwappedZDOs.TryGetValue(target, out var value)) { target = value; ZDO zDO = ZDOMan.instance.GetZDO(zid); zDO.DataRevision += 100; ZDOMan.instance.ForceSendZDO(zid); } ReverseConnectionTable[target] = zid; } } public class Data { [DefaultValue("")] public string prefab = ""; [DefaultValue("")] public string excludePrefab = ""; public string type = ""; [DefaultValue(null)] public string[]? types; [DefaultValue(false)] public bool fallback; [DefaultValue(false)] public bool separate; [DefaultValue(null)] public string? weight; [DefaultValue(null)] public SpawnData[]? swap; [DefaultValue(null)] public string[]? swaps; [DefaultValue(null)] public SpawnData[]? spawn; [DefaultValue(null)] public string[]? spawns; [DefaultValue(null)] public float? spawnDelay; [DefaultValue(null)] public string? remove; [DefaultValue(null)] public string? removeDelay; [DefaultValue("")] public string drops = ""; [DefaultValue("")] public string data = ""; [DefaultValue(null)] public string? command; [DefaultValue(null)] public string[]? commands; [DefaultValue(null)] public string? day; [DefaultValue(null)] public string? night; [DefaultValue("")] public string biomes = ""; [DefaultValue("")] public string bannedBiomes = ""; [DefaultValue(null)] public string? minDistance; [DefaultValue(null)] public string? maxDistance; [DefaultValue(null)] public string? minAltitude; [DefaultValue(null)] public string? maxAltitude; [DefaultValue(null)] public string? minY; [DefaultValue(null)] public string? maxY; [DefaultValue(null)] public string? minX; [DefaultValue(null)] public string? maxX; [DefaultValue(null)] public string? minZ; [DefaultValue(null)] public string? maxZ; [DefaultValue("")] public string environments = ""; [DefaultValue("")] public string bannedEnvironments = ""; [DefaultValue("")] public string globalKeys = ""; [DefaultValue("")] public string bannedGlobalKeys = ""; [DefaultValue("")] public string keys = ""; [DefaultValue("")] public string bannedKeys = ""; [DefaultValue("")] public string events = ""; [DefaultValue(null)] public float? eventDistance; [DefaultValue(null)] public PokeData[]? poke; [DefaultValue(null)] public string[]? pokes; [DefaultValue(0)] public int pokeLimit; [DefaultValue("")] public string pokeParameter = ""; [DefaultValue(0f)] public float pokeDelay; [DefaultValue(null)] public TerrainData[]? terrain; [DefaultValue(null)] public ObjectData[]? objects; [DefaultValue(null)] public string? objectsLimit; [DefaultValue(null)] public ObjectData[]? bannedObjects; [DefaultValue(null)] public string? bannedObjectsLimit; [DefaultValue(null)] public string? locations; [DefaultValue(null)] public float? locationDistance; [DefaultValue("")] public string? bannedLocations; [DefaultValue(null)] public float? bannedLocationDistance; [DefaultValue(null)] public string? playerEvents; [DefaultValue(null)] public string? bannedPlayerEvents; [DefaultValue(null)] public string? groups; [DefaultValue(null)] public string? bannedGroups; [DefaultValue(null)] public string[]? filters; [DefaultValue(null)] public string[]? bannedFilters; [DefaultValue(null)] public string? filterLimit; [DefaultValue(null)] public float? delay; [DefaultValue(null)] public bool? triggerRules; [DefaultValue(null)] public Dictionary[]? objectRpc; [DefaultValue(null)] public Dictionary[]? clientRpc; [DefaultValue("")] public string minPaint = ""; [DefaultValue("")] public string maxPaint = ""; [DefaultValue("")] public string paint = ""; [DefaultValue(null)] public string? terrainHeight; [DefaultValue(null)] public string? minTerrainHeight; [DefaultValue(null)] public string? maxTerrainHeight; public bool? injectData; [DefaultValue(null)] public string? owner; [DefaultValue("")] public string addItems = ""; [DefaultValue("")] public string removeItems = ""; [DefaultValue(null)] public string? cancel; [DefaultValue(null)] public string? exec; [DefaultValue(null)] public string? admin; [DefaultValue(null)] public string? chance; } public class Info { public string Prefabs = ""; public string ExcludedPrefabs = ""; public ActionType Type; public bool Fallback; public string[] Args = Array.Empty(); public IFloatValue? Weight; public Spawn[]? Swaps; public Spawn[]? WeightedSwaps; public Spawn[]? Spawns; public Spawn[]? WeightedSpawns; public IBoolValue? Remove; public bool Regenerate; public IFloatValue? RemoveDelay; public IStringValue? Drops; public IStringValue? Data; public bool? InjectData; public string[] Commands = Array.Empty(); public IBoolValue? Day; public IBoolValue? Night; public IFloatValue? MinDistance; public IFloatValue? MaxDistance; public IFloatValue? MinY; public IFloatValue? MaxY; public IFloatValue? MinX; public IFloatValue? MaxX; public IFloatValue? MinZ; public IFloatValue? MaxZ; public IFloatValue? MinAltitude; public IFloatValue? MaxAltitude; public Biome Biomes; public Biome BannedBiomes; public float EventDistance; public HashSet Events = new HashSet(); public HashSet Environments = new HashSet(); public HashSet BannedEnvironments = new HashSet(); public List GlobalKeys = new List(); public List BannedGlobalKeys = new List(); public List Keys = new List(); public List BannedKeys = new List(); public Object[]? LegacyPokes; public Poke[]? Pokes; public Poke[]? WeightedPokes; public Terrain[]? Terrains; public int PokeLimit; public string PokeParameter = ""; public float PokeDelay; public Range? ObjectsLimit; public Object[]? Objects; public Range? BannedObjectsLimit; public Object[]? BannedObjects; public HashSet? Locations; public HashSet? BannedLocations; public float LocationDistance; public float BannedLocationDistance; public HashSet? PlayerEvents; public HashSet? BannedPlayerEvents; public HashSet? Groups; public HashSet? BannedGroups; public Filters? Filters; public bool TriggerRules; public ObjectRpcInfo[]? ObjectRpcs; public ObjectRpcInfo[]? WeightedObjectRpcs; public ClientRpcInfo[]? ClientRpcs; public ClientRpcInfo[]? WeightedClientRpcs; public Color? MinPaint; public Color? MaxPaint; public IFloatValue? MinTerrainHeight; public IFloatValue? MaxTerrainHeight; public DataEntry? AddItems; public DataEntry? RemoveItems; public ILongValue? Owner; public IBoolValue? Cancel; public IStringValue? Execute; public IBoolValue? Admin; public IFloatValue? Chance; public Spawn? GetWeightedSpawn(Parameters pars) { return GetWeighted(pars, WeightedSpawns); } public Spawn? GetWeightedSwap(Parameters pars) { return GetWeighted(pars, WeightedSwaps); } private Spawn? GetWeighted(Parameters pars, Spawn[]? candidates) { Parameters pars2 = pars; if (candidates == null || candidates.Length == 0) { return null; } float[] array = candidates.Select((Spawn s) => (s.Weight?.Get(pars2)).GetValueOrDefault()).ToArray(); float num = Mathf.Max(1f, array.Sum((float s) => s)); float num2 = Random.Range(0f, num); for (int i = 0; i < array.Length; i++) { num2 -= array[i]; if (num2 <= 0f) { return candidates[i]; } } return null; } public Poke? GetWeightedPoke(Parameters pars) { Parameters pars2 = pars; if (WeightedPokes == null || WeightedPokes.Length == 0) { return null; } float[] array = WeightedPokes.Select((Poke p) => ((float?)p.Weight?.Get(pars2)) ?? 0f).ToArray(); float num = Mathf.Max(1f, array.Sum((float s) => s)); float num2 = Random.Range(0f, num); for (int i = 0; i < array.Length; i++) { num2 -= array[i]; if (num2 <= 0f) { return WeightedPokes[i]; } } return null; } public ObjectRpcInfo? GetWeightedObjectRpc(Parameters pars) { Parameters pars2 = pars; if (WeightedObjectRpcs == null || WeightedObjectRpcs.Length == 0) { return null; } float[] array = WeightedObjectRpcs.Select((ObjectRpcInfo r) => (r.Weight?.Get(pars2)).GetValueOrDefault()).ToArray(); float num = Mathf.Max(1f, array.Sum((float s) => s)); float num2 = Random.Range(0f, num); for (int i = 0; i < array.Length; i++) { num2 -= array[i]; if (num2 <= 0f) { return WeightedObjectRpcs[i]; } } return null; } public ClientRpcInfo? GetWeightedClientRpc(Parameters pars) { Parameters pars2 = pars; if (WeightedClientRpcs == null || WeightedClientRpcs.Length == 0) { return null; } float[] array = WeightedClientRpcs.Select((ClientRpcInfo r) => (r.Weight?.Get(pars2)).GetValueOrDefault()).ToArray(); float num = Mathf.Max(1f, array.Sum((float s) => s)); float num2 = Random.Range(0f, num); for (int i = 0; i < array.Length; i++) { num2 -= array[i]; if (num2 <= 0f) { return WeightedClientRpcs[i]; } } return null; } } public class SpawnData { [DefaultValue(null)] public string? prefab; [DefaultValue(null)] public string? snap; [DefaultValue(null)] public string? pos; [DefaultValue(null)] public string? position; [DefaultValue(null)] public string? rot; [DefaultValue(null)] public string? rotation; [DefaultValue(null)] public string? data; [DefaultValue(null)] public string? delay; [DefaultValue(null)] public string? repeat; [DefaultValue(null)] public string? repeatInterval; [DefaultValue(null)] public string? repeatChance; [DefaultValue(null)] public string? chance; [DefaultValue(null)] public string? weight; [DefaultValue(null)] public string? owner; [DefaultValue(null)] public string? triggerRules; } public class Spawn { private readonly IPrefabValue Prefab; public readonly IVector3Value? Pos; public readonly IBoolValue? Snap; public readonly IQuaternionValue? Rot; public readonly IStringValue? Data; public readonly IFloatValue? Delay; public readonly IIntValue? Repeat; public readonly IFloatValue? RepeatInterval; public readonly IFloatValue? RepeatChance; public readonly IFloatValue? Chance; public readonly IFloatValue? Weight; public readonly ILongValue? Owner; public readonly IBoolValue? TriggerRules; public Spawn(SpawnData data, float? delay, bool? triggerRules) { IPrefabValue prefab; if (data.prefab != null) { prefab = DataValue.Prefab(data.prefab); } else { IPrefabValue prefabValue = new SimplePrefabValue(0); prefab = prefabValue; } Prefab = prefab; Pos = ((data.pos != null) ? DataValue.Vector3(data.pos) : ((data.position != null) ? DataValue.Vector3(data.position) : null)); Snap = ((data.snap == null) ? null : DataValue.Bool(data.snap)); Rot = ((data.rot != null) ? DataValue.Quaternion(data.rot) : ((data.rotation != null) ? DataValue.Quaternion(data.rotation) : null)); Data = ((data.data == null) ? null : DataValue.String(data.data)); Delay = ((data.delay == null) ? ((!delay.HasValue) ? null : new SimpleFloatValue(delay.Value)) : DataValue.Float(data.delay)); Repeat = ((data.repeat == null) ? null : DataValue.Int(data.repeat)); RepeatInterval = ((data.repeatInterval == null) ? null : DataValue.Float(data.repeatInterval)); RepeatChance = ((data.repeatChance == null) ? null : DataValue.Float(data.repeatChance)); Chance = ((data.chance == null) ? null : DataValue.Float(data.chance)); Weight = ((data.weight == null) ? null : DataValue.Float(data.weight)); Owner = ((data.owner == null) ? null : DataValue.Long(data.owner)); TriggerRules = ((data.triggerRules == null) ? ((!triggerRules.HasValue) ? null : new SimpleBoolValue(triggerRules.Value)) : DataValue.Bool(data.triggerRules)); } public Spawn(string line, float? delay, bool? triggerRules) { //IL_0126: 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) Delay = ((!delay.HasValue) ? null : new SimpleFloatValue(delay.Value)); Repeat = null; RepeatInterval = null; RepeatChance = null; Chance = null; Weight = null; Owner = null; TriggerRules = ((!triggerRules.HasValue) ? null : new SimpleBoolValue(triggerRules.Value)); List list = Parse.ToList(line); Prefab = DataValue.Prefab(list[0]); bool flag = false; for (int i = 1; i < list.Count; i++) { string text = list[i]; float result2; if (Parse.TryBoolean(text, out var result)) { TriggerRules = new SimpleBoolValue(result); } else if (Parse.TryFloat(text, out result2)) { float result3; if (list.Count <= i + 2) { Delay = new SimpleFloatValue(result2); } else if (Parse.TryFloat(list[i + 1], out result3)) { float num = Parse.Float(list[i + 2]); if (flag) { Rot = new SimpleQuaternionValue(Quaternion.Euler(result3, result2, num)); } else { Pos = new SimpleVector3Value(new Vector3(result2, num, result3)); if (list[i + 2] == "snap") { Snap = new SimpleBoolValue(value: true); } flag = true; } i += 2; } else { Delay = new SimpleFloatValue(result2); } } else { Data = new SimpleStringValue(text); } } } public int GetPrefab(Parameters pars) { return Prefab.Get(pars).GetValueOrDefault(); } } public class Poke { public Object Filter = new Object(data); private readonly string? Parameter = data.parameter; private readonly string[]? Parameters = ((data.pars == null) ? null : Parse.ToArr(data.pars)); public IIntValue? Limit = ((data.limit == null) ? null : DataValue.Int(data.limit)); public IFloatValue? Delay = ((data.delay == null) ? null : DataValue.Float(data.delay)); public IIntValue? Weight = ((data.weight == null) ? null : DataValue.Int(data.weight)); public IIntValue? Repeat = ((data.repeat == null) ? null : DataValue.Int(data.repeat)); public IFloatValue? RepeatInterval = ((data.repeatInterval == null) ? null : DataValue.Float(data.repeatInterval)); public IFloatValue? RepeatChance = ((data.repeatChance == null) ? null : DataValue.Float(data.repeatChance)); public IFloatValue? Chance = ((data.chance == null) ? null : DataValue.Float(data.chance)); public IBoolValue? Self = ((data.self == null) ? null : DataValue.Bool(data.self)); public IZdoIdValue? Target = ((data.target == null) ? null : DataValue.ZdoId(data.target)); private readonly IBoolValue? Evaluate = ((data.evaluate == null) ? null : DataValue.Bool(data.evaluate)); public bool HasPrefab = data.prefab != null && data.prefab != ""; public Poke(PokeData data) { } public string[] GetArgs(Parameters pars) { if (Parameters != null) { List list = new List(); list.AddRange(Parameters.Select(pars.Replace)); return list.ToArray(); } string text = pars.Replace(Parameter ?? ""); IBoolValue? evaluate = Evaluate; if (evaluate == null || evaluate.GetBool(pars) != false) { text = PokeEvaluate(text); } return text.Split(new char[1] { ' ' }); } public static string PokeEvaluate(string str) { string[] array = str.Split(new char[1] { ' ' }).ToArray(); bool flag = false; for (int i = 0; i < array.Length; i++) { string text = array[i]; if (text.Length == 0) { continue; } string source = text.Substring(1); if (Enumerable.Contains(source, '*') || Enumerable.Contains(source, '/') || Enumerable.Contains(source, '+') || Enumerable.Contains(source, '-')) { flag = true; float? num = Calculator.EvaluateFloat(text); if (num.HasValue) { array[i] = num.Value.ToString("0.#####", NumberFormatInfo.InvariantInfo); } } } if (!flag) { return str; } return string.Join(" ", array); } } public class Object { private readonly IPrefabValue PrefabsValue; private readonly IFloatValue? MinDistanceValue; private readonly IFloatValue MaxDistanceValue; private readonly IFloatValue? MinHeightValue; private readonly IFloatValue? MaxHeightValue; private readonly IVector3Value? OffsetValue; private readonly Filters? filters; private readonly IIntValue WeightValue = new SimpleIntValue(1); private float? MinDistance; public float MaxDistance; private float? MinHeight; private float? MaxHeight; private Vector3? Offset; public Vector3 CachedPosition; public int Weight; public Object(ObjectData data) { PrefabsValue = DataValue.Prefab(data.prefab); if (data.minDistance != null) { MinDistanceValue = DataValue.Float(data.minDistance); } if (data.maxDistance != null) { MaxDistanceValue = DataValue.Float(data.maxDistance); } else { MaxDistanceValue = new SimpleFloatValue(100f); } if (data.minHeight != null) { MinHeightValue = DataValue.Float(data.minHeight); } if (data.maxHeight != null) { MaxHeightValue = DataValue.Float(data.maxHeight); } if (data.offset != null) { OffsetValue = DataValue.Vector3(data.offset); } if (data.weight != null) { WeightValue = DataValue.Int(data.weight); } if (data.filters != null || data.bannedFilters != null) { filters = new Filters(data.filters, data.bannedFilters, data.filterLimit); } else if (data.data != null) { filters = new Filters(new string[1] { data.data }, null, data.filterLimit); } } public Object(string line) { List list = Parse.ToList(line); PrefabsValue = DataValue.Prefab(list[0]); MaxDistanceValue = new SimpleFloatValue(100f); if (list.Count > 1) { Range range = Parse.StringRange(list[1]); if (range.Min != range.Max) { MinDistanceValue = DataValue.Float(range.Min); } MaxDistanceValue = DataValue.Float(range.Max); } if (list.Count > 2) { filters = new Filters(new string[1] { list[2] }, null, null); } if (list.Count > 3) { WeightValue = DataValue.Int(list[3]); } if (list.Count > 4) { Range range2 = Parse.StringRange(list[4]); if (range2.Min != range2.Max) { MinHeightValue = DataValue.Float(range2.Min); } MaxHeightValue = DataValue.Float(range2.Max); } } public void Roll(Parameters pars, Vector3 pos, Quaternion rot) { //IL_00ea: 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_00cc: 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_00d4: 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_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) MinDistance = MinDistanceValue?.Get(pars); MaxDistance = MaxDistanceValue.Get(pars).GetValueOrDefault(100f); MinHeight = MinHeightValue?.Get(pars); MaxHeight = MaxHeightValue?.Get(pars); Weight = WeightValue.Get(pars).GetValueOrDefault(1); Offset = OffsetValue?.Get(pars); if (Offset.HasValue) { CachedPosition = pos + rot * Offset.Value; } else { CachedPosition = pos; } } public bool IsValid(ZDO zdo, Parameters pars) { //IL_002c: 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_007f: Unknown result type (might be due to invalid IL or missing references) if (PrefabsValue.Match(pars, zdo.GetPrefab()) == false) { return false; } float num = Utils.DistanceXZ(CachedPosition, zdo.GetPosition()); if (MinDistance.HasValue && num < MinDistance) { return false; } if (num > MaxDistance) { return false; } float num2 = Mathf.Abs(CachedPosition.y - zdo.GetPosition().y); if (MinHeight.HasValue && num2 < MinHeight) { return false; } if (MaxHeight.HasValue && num2 > MaxHeight) { return false; } if (filters == null) { return true; } return filters.Match(pars, zdo); } } public class PokeData : ObjectData { [DefaultValue(null)] public string? delay; [DefaultValue(null)] public string? repeat; [DefaultValue(null)] public string? repeatInterval; [DefaultValue(null)] public string? repeatChance; [DefaultValue(null)] public string? chance; [DefaultValue(null)] public string? self; [DefaultValue(null)] public string? target; [DefaultValue(null)] public string? parameter; [DefaultValue(null)] public string? pars; [DefaultValue(null)] public string? limit; [DefaultValue(null)] public string? evaluate; } public class ObjectData { [DefaultValue("")] public string prefab = ""; [DefaultValue(null)] public string? maxDistance; [DefaultValue(null)] public string? minDistance; [DefaultValue(null)] public string? maxHeight; [DefaultValue(null)] public string? minHeight; [DefaultValue(null)] public string? offset; [DefaultValue(null)] public string? data; [DefaultValue(null)] public string[]? filters; [DefaultValue(null)] public string[]? bannedFilters; [DefaultValue(null)] public string? filterLimit; [DefaultValue(null)] public string? weight; } public class InfoType { public readonly ActionType Type; public readonly string[] Parameters; public InfoType(string prefab, string line) { KeyValuePair keyValuePair = Parse.Kvp(line); if (!Enum.TryParse(keyValuePair.Key, ignoreCase: true, out Type)) { if (line == "") { Log.Warning("Missing type for prefab " + prefab + "."); } else { Log.Error($"Invalid type {keyValuePair} for prefab {prefab}."); } Type = ActionType.Create; } Parameters = ((keyValuePair.Value != "") ? keyValuePair.Value.Split(new char[1] { ' ' }) : Array.Empty()); } } public class TerrainData { [DefaultValue(null)] public string? delay; [DefaultValue(null)] public string? pos; [DefaultValue(null)] public string? position; [DefaultValue(null)] public string? square; [DefaultValue(null)] public string? resetRadius; [DefaultValue(null)] public string? levelRadius; [DefaultValue(null)] public string? levelOffset; [DefaultValue(null)] public string? raiseRadius; [DefaultValue(null)] public string? raisePower; [DefaultValue(null)] public string? raiseDelta; [DefaultValue(null)] public string? smoothRadius; [DefaultValue(null)] public string? smoothPower; [DefaultValue(null)] public string? paintRadius; [DefaultValue(null)] public string? paintHeightCheck; [DefaultValue(null)] public string? paint; } public class Filters { public readonly IFloatValue? Limit = ((filterLimit == null) ? new SimpleFloatValue(((float?)filters?.Length) ?? 0f) : DataValue.Float(filterLimit)); public readonly Filter[] Values; public Filters(string[]? filters, string[]? bannedFilters, string? filterLimit) { List list = new List(); list.AddRange(filters?.Select((string f) => new Filter(f, banned: false)) ?? Array.Empty()); list.AddRange(bannedFilters?.Select((string f) => new Filter(f, banned: true)) ?? Array.Empty()); Values = list.ToArray(); base..ctor(); } public bool Match(Parameters parameters, ZDO zdo) { Parameters parameters2 = parameters; ZDO zdo2 = zdo; float? num = Limit?.Get(parameters2); if (!num.HasValue) { return false; } float num2 = Values.Sum((Filter f) => f.Match(parameters2, zdo2)); if (!(num <= num2)) { return Helper.Approx(num2, num.Value); } return true; } } public class Filter { public readonly IStringValue? Data; public readonly bool Banned; public readonly IFloatValue? Weight; public Filter(string filter, bool banned) { List list = Parse.ToList(filter); if (list.Count == 2) { Weight = DataValue.Float(list[1]); filter = list[0]; } else if (list.Count == 4) { Weight = DataValue.Float(list[3]); filter = string.Join(",", list.Take(3)); } else { Weight = (banned ? new SimpleFloatValue(10000f) : new SimpleFloatValue(1f)); } Data = DataValue.String(filter); Banned = banned; } public float Match(Parameters parameters, ZDO zdo) { DataEntry dataEntry = DataHelper.Get(Data, parameters); if (dataEntry == null) { return 0f; } if (!dataEntry.Match(parameters, zdo)) { return 0f; } float valueOrDefault = (Weight?.Get(parameters)).GetValueOrDefault(); if (!Banned) { return valueOrDefault; } return 0f - valueOrDefault; } } public class Terrain { public readonly IFloatValue? Delay = ((data.delay == null) ? null : DataValue.Float(data.delay)); public readonly IFloatValue? ResetRadius = ((data.resetRadius == null) ? null : DataValue.Float(data.resetRadius)); public readonly IVector3Value? Position = ((data.pos != null) ? DataValue.Vector3(data.pos) : ((data.position != null) ? DataValue.Vector3(data.position) : null)); public readonly IBoolValue? Square = ((data.square == null) ? null : DataValue.Bool(data.square)); public readonly IFloatValue? LevelRadius = ((data.levelRadius == null) ? null : DataValue.Float(data.levelRadius)); public readonly IFloatValue? LevelOffset = ((data.levelOffset == null) ? null : DataValue.Float(data.levelOffset)); public readonly IFloatValue? RaiseRadius = ((data.raiseRadius == null) ? null : DataValue.Float(data.raiseRadius)); public readonly IFloatValue? RaisePower = ((data.raisePower == null) ? null : DataValue.Float(data.raisePower)); public readonly IFloatValue? RaiseDelta = ((data.raiseDelta == null) ? null : DataValue.Float(data.raiseDelta)); public readonly IFloatValue? SmoothRadius = ((data.smoothRadius == null) ? null : DataValue.Float(data.smoothRadius)); public readonly IFloatValue? SmoothPower = ((data.smoothPower == null) ? null : DataValue.Float(data.smoothPower)); public readonly IFloatValue? PaintRadius = ((data.paintRadius == null) ? null : DataValue.Float(data.paintRadius)); public readonly IBoolValue? PaintHeightCheck = ((data.paintHeightCheck == null) ? null : DataValue.Bool(data.paintHeightCheck)); public readonly IStringValue? Paint = ((data.paint == null) ? null : DataValue.String(data.paint)); public Terrain(TerrainData data) { } public void Get(Parameters pars, Vector3 basePosition, Quaternion baseRotation, out Vector3 pos, out float size, out float resetRadius, out ZPackage pkg) { //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) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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_0051: 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_005e: Expected O, but got Unknown //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Expected I4, but got Unknown //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Expected I4, but got Unknown pos = basePosition; pos += baseRotation * (Vector3)(((??)Position?.Get(pars)) ?? Vector3.zero); pkg = new ZPackage(); pkg.Write(pos); pkg.Write((LevelOffset?.Get(pars)).GetValueOrDefault()); float valueOrDefault = (LevelRadius?.Get(pars)).GetValueOrDefault(); pkg.Write(valueOrDefault > 0f); pkg.Write(valueOrDefault); pkg.Write(Square?.GetBool(pars).GetValueOrDefault() ?? false); float valueOrDefault2 = (RaiseRadius?.Get(pars)).GetValueOrDefault(); pkg.Write(valueOrDefault2 > 0f); pkg.Write(valueOrDefault2); pkg.Write((RaisePower?.Get(pars)).GetValueOrDefault()); pkg.Write((RaiseDelta?.Get(pars)).GetValueOrDefault()); float valueOrDefault3 = (SmoothRadius?.Get(pars)).GetValueOrDefault(); pkg.Write(valueOrDefault3 > 0f); pkg.Write(valueOrDefault3); pkg.Write((SmoothPower?.Get(pars)).GetValueOrDefault()); float valueOrDefault4 = (PaintRadius?.Get(pars)).GetValueOrDefault(); pkg.Write(valueOrDefault4 > 0f); pkg.Write(PaintHeightCheck?.GetBool(pars).GetValueOrDefault() ?? false); string text = Paint?.Get(pars) ?? "Reset"; PaintType result; int result2; PaintType val = (PaintType)((!Enum.TryParse(text, ignoreCase: true, out result)) ? (int.TryParse(text, out result2) ? result2 : 3) : ((int)result)); pkg.Write((int)val); pkg.Write(valueOrDefault4); resetRadius = (ResetRadius?.Get(pars)).GetValueOrDefault(); size = Mathf.Max(new float[5] { valueOrDefault, valueOrDefault2, valueOrDefault3, valueOrDefault4, resetRadius }); } } public class Loading { private static readonly string FileName = "expand_prefabs.yaml"; private static readonly string FilePath = Path.Combine(Yaml.BaseDirectory, FileName); private static readonly string Pattern = "expand_prefabs*.yaml"; public static void FromFile() { if (!Helper.IsClient()) { if (!File.Exists(FilePath)) { string contents = "# Write your entries here. Good luck!"; File.WriteAllText(FilePath, contents); } else { Load(); } } } private static void Load() { InfoManager.Clear(); if (Helper.IsClient()) { return; } List list = Yaml.Read(Pattern, migrate: true); if (list.Count == 0) { Log.Warning("Failed to load any prefab data."); return; } Log.Info($"Reloading prefab rules ({list.Count} entries)."); foreach (Info item in list.SelectMany(FromData).ToList()) { InfoManager.Add(item); } InfoManager.Patch(); } private static Info[] FromData(Data data) { Data data2 = data; _ = ZoneSystem.instance.m_waterLevel; float? delay = ((!data2.delay.HasValue && !data2.spawnDelay.HasValue) ? null : new float?(Math.Max(data2.delay.GetValueOrDefault(), data2.spawnDelay.GetValueOrDefault()))); bool? triggerRules = data2.triggerRules; Tuple allSwaps = ((data2.swap != null) ? ParseSpawns(data2.swap, delay, triggerRules) : ((data2.swaps == null) ? null : ParseSpawns(data2.swaps, delay, triggerRules))); Tuple allSpawns = ((data2.spawn != null) ? ParseSpawns(data2.spawn, delay, triggerRules) : ((data2.spawns == null) ? null : ParseSpawns(data2.spawns, delay, triggerRules))); InfoType[] source = (data2.types ?? new string[1] { data2.type }).Select((string s) => new InfoType(data2.prefab, s)).ToArray(); if (data2.prefab == "" && source.Any((InfoType t) => t.Type != ActionType.GlobalKey && t.Type != ActionType.Key && t.Type != ActionType.Custom && t.Type != ActionType.Event && t.Type != ActionType.Time && t.Type != ActionType.RealTime)) { Log.Warning("Prefab missing for type " + data2.type); } HashSet hashSet = new HashSet(); foreach (string item in Parse.ToList(data2.events)) { hashSet.Add(item); } HashSet events = hashSet; string[] commands = (string[])(data2.commands ?? ((data2.command == null) ? ((object)Array.Empty()) : ((object)new string[1] { data2.command }))); hashSet = new HashSet(); foreach (string item2 in from s in Parse.ToList(data2.environments) select s.ToLower()) { hashSet.Add(item2); } HashSet environments = hashSet; hashSet = new HashSet(); foreach (string item3 in from s in Parse.ToList(data2.bannedEnvironments) select s.ToLower()) { hashSet.Add(item3); } HashSet bannedEnvironments = hashSet; if (data2.locations == null) { hashSet = null; } else { HashSet hashSet2 = new HashSet(); foreach (string item4 in Parse.ToList(data2.locations)) { hashSet2.Add(item4); } hashSet = hashSet2; } HashSet locations = hashSet; if (data2.bannedLocations == null) { hashSet = null; } else { HashSet hashSet2 = new HashSet(); foreach (string item5 in Parse.ToList(data2.bannedLocations)) { hashSet2.Add(item5); } hashSet = hashSet2; } HashSet bannedLocations = hashSet; if (data2.playerEvents == null) { hashSet = null; } else { HashSet hashSet2 = new HashSet(); foreach (string item6 in Parse.ToList(data2.playerEvents)) { hashSet2.Add(item6); } hashSet = hashSet2; } HashSet playerEvents = hashSet; if (data2.bannedPlayerEvents == null) { hashSet = null; } else { HashSet hashSet2 = new HashSet(); foreach (string item7 in Parse.ToList(data2.bannedPlayerEvents)) { hashSet2.Add(item7); } hashSet = hashSet2; } HashSet bannedPlayerEvents = hashSet; if (data2.groups == null) { hashSet = null; } else { HashSet hashSet2 = new HashSet(); foreach (string item8 in Parse.ToList(data2.groups)) { hashSet2.Add(item8); } hashSet = hashSet2; } HashSet groups = hashSet; if (data2.bannedGroups == null) { hashSet = null; } else { HashSet hashSet2 = new HashSet(); foreach (string item9 in Parse.ToList(data2.bannedGroups)) { hashSet2.Add(item9); } hashSet = hashSet2; } HashSet bannedGroups = hashSet; Range objectsLimit = ParseObjectsLimit(data2.objectsLimit); Object[] objects = ((data2.objects == null) ? null : ParseObjects(data2.objects)); Object[] bannedObjects = ((data2.bannedObjects == null) ? null : ParseObjects(data2.bannedObjects)); Range bannedObjectsLimit = ParseObjectsLimit(data2.bannedObjectsLimit); Filters filters = ((data2.filters == null && data2.bannedFilters == null) ? null : new Filters(data2.filters, data2.bannedFilters, data2.filterLimit)); Object[] legacyPokes = ((data2.pokes == null) ? null : ParseObjects(data2.pokes)); Tuple allPokes = ((data2.poke == null) ? null : ParsePokes(data2.poke)); Terrain[] terrains = ((data2.terrain == null) ? null : data2.terrain.Select((TerrainData s) => new Terrain(s)).ToArray()); Tuple allObjectRpcs = ParseObjectRpcs(data2); Tuple allClientRpcs = ParseClientRpcs(data2); Color? minPaint = ((data2.minPaint != "") ? Parse.Color(data2.minPaint, 0f) : ((data2.paint != "") ? Parse.Color(data2.paint, 0f) : null)); Color? maxPaint = ((data2.maxPaint != "") ? Parse.Color(data2.maxPaint, 1f) : ((data2.paint != "") ? Parse.Color(data2.paint, 0f) : null)); DataEntry addItems = HandleItems(data2.addItems); DataEntry removeItems = HandleItems(data2.removeItems); IFloatValue minTerrainHeight = ((data2.minTerrainHeight == null) ? null : DataValue.Float(data2.minTerrainHeight)); IFloatValue maxTerrainHeight = ((data2.maxTerrainHeight == null) ? null : DataValue.Float(data2.maxTerrainHeight)); if (data2.terrainHeight != null) { KeyValuePair keyValuePair = Parse.Kvp(data2.terrainHeight, ';'); if (keyValuePair.Value == "") { minTerrainHeight = DataValue.Float(keyValuePair.Key); maxTerrainHeight = DataValue.Float(keyValuePair.Key); } else { minTerrainHeight = DataValue.Float(keyValuePair.Key); maxTerrainHeight = DataValue.Float(keyValuePair.Value); } } List list = new List(); list.AddRange(source.Select(delegate(InfoType t) { //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) string text = ((t.Type != ActionType.Destroy) ? data2.data : ""); bool? flag = ((t.Type == ActionType.Destroy) ? new bool?(false) : ((allSwaps != null) ? new bool?(true) : ((data2.remove == "") ? new bool?(false) : null))); Info obj = new Info { Prefabs = data2.prefab, ExcludedPrefabs = data2.excludePrefab, Type = t.Type, Fallback = data2.fallback, Args = t.Parameters }; object remove; if (!flag.HasValue) { remove = ((data2.remove == null) ? null : DataValue.Bool(data2.remove)); } else { IBoolValue boolValue = new SimpleBoolValue(flag.Value); remove = boolValue; } obj.Remove = (IBoolValue?)remove; obj.Regenerate = text != "" || data2.addItems != "" || data2.removeItems != ""; obj.RemoveDelay = ((data2.removeDelay == null) ? null : DataValue.Float(data2.removeDelay)); obj.Drops = ((data2.drops == null) ? null : DataValue.String(data2.drops)); obj.Spawns = allSpawns?.Item1; obj.WeightedSpawns = allSpawns?.Item2; obj.Swaps = allSwaps?.Item1; obj.WeightedSwaps = allSwaps?.Item2; obj.Data = DataValue.String(text); obj.InjectData = data2.injectData; obj.Commands = commands; obj.Weight = ((data2.weight == null) ? null : DataValue.Float(data2.weight)); obj.Chance = ((data2.chance == null) ? null : DataValue.Float(data2.chance)); obj.Day = ((data2.day == null) ? null : DataValue.Bool(data2.day)); obj.Night = ((data2.night == null) ? null : DataValue.Bool(data2.night)); object minDistance; if (data2.minDistance != null) { if (!Parse.TryFloat(data2.minDistance, out var result)) { minDistance = DataValue.Float(data2.minDistance); } else { IFloatValue floatValue = ((result < 1f) ? new SimpleFloatValue(result * 10000f) : new SimpleFloatValue(result)); minDistance = floatValue; } } else { minDistance = null; } obj.MinDistance = (IFloatValue?)minDistance; object maxDistance; if (data2.maxDistance != null) { if (!Parse.TryFloat(data2.maxDistance, out var result2)) { maxDistance = DataValue.Float(data2.maxDistance); } else { IFloatValue floatValue = ((result2 < 1f) ? new SimpleFloatValue(result2 * 10000f) : new SimpleFloatValue(result2)); maxDistance = floatValue; } } else { maxDistance = null; } obj.MaxDistance = (IFloatValue?)maxDistance; obj.MinY = ((data2.minY == null) ? null : DataValue.Float(data2.minY)); obj.MaxY = ((data2.maxY == null) ? null : DataValue.Float(data2.maxY)); obj.MinX = ((data2.minX == null) ? null : DataValue.Float(data2.minX)); obj.MaxX = ((data2.maxX == null) ? null : DataValue.Float(data2.maxX)); obj.MinZ = ((data2.minZ == null) ? null : DataValue.Float(data2.minZ)); obj.MaxZ = ((data2.maxZ == null) ? null : DataValue.Float(data2.maxZ)); obj.MinAltitude = ((data2.minAltitude == null) ? null : DataValue.Float(data2.minAltitude)); obj.MaxAltitude = ((data2.maxAltitude == null) ? null : DataValue.Float(data2.maxAltitude)); obj.Biomes = Yaml.ToBiomes(data2.biomes, defaultAll: true); obj.BannedBiomes = Yaml.ToBiomes(data2.bannedBiomes, defaultAll: false); obj.Environments = environments; obj.BannedEnvironments = bannedEnvironments; List list2 = new List(); list2.AddRange(Parse.ToList(data2.globalKeys).Select(FormatKey)); obj.GlobalKeys = list2; List list3 = new List(); list3.AddRange(Parse.ToList(data2.bannedGlobalKeys).Select(FormatKey)); obj.BannedGlobalKeys = list3; List list4 = new List(); list4.AddRange(Parse.ToList(data2.keys).Select(FormatKey)); obj.Keys = list4; List list5 = new List(); list5.AddRange(Parse.ToList(data2.bannedKeys).Select(FormatKey)); obj.BannedKeys = list5; obj.Events = events; obj.EventDistance = data2.eventDistance ?? ((events.Count > 0) ? 100f : 0f); obj.LocationDistance = data2.locationDistance.GetValueOrDefault(); obj.BannedLocationDistance = data2.bannedLocationDistance ?? data2.locationDistance.GetValueOrDefault(); obj.Locations = locations; obj.BannedLocations = bannedLocations; obj.PlayerEvents = playerEvents; obj.BannedPlayerEvents = bannedPlayerEvents; obj.Groups = groups; obj.BannedGroups = bannedGroups; obj.PokeLimit = data2.pokeLimit; obj.PokeParameter = data2.pokeParameter; obj.Pokes = allPokes?.Item1; obj.WeightedPokes = allPokes?.Item2; obj.Terrains = terrains; obj.LegacyPokes = legacyPokes; obj.PokeDelay = data2.pokeDelay; obj.ObjectsLimit = objectsLimit; obj.Objects = objects; obj.BannedObjects = bannedObjects; obj.BannedObjectsLimit = bannedObjectsLimit; obj.Filters = filters; obj.TriggerRules = triggerRules.GetValueOrDefault(); obj.ObjectRpcs = allObjectRpcs?.Item1; obj.WeightedObjectRpcs = allObjectRpcs?.Item2; obj.ClientRpcs = allClientRpcs?.Item1; obj.WeightedClientRpcs = allClientRpcs?.Item2; obj.MinPaint = minPaint; obj.MaxPaint = maxPaint; obj.AddItems = addItems; obj.RemoveItems = removeItems; obj.Cancel = ((data2.cancel == null) ? null : DataValue.Bool(data2.cancel)); obj.Owner = ((data2.owner == null) ? null : DataValue.Long(data2.owner)); obj.MinTerrainHeight = minTerrainHeight; obj.MaxTerrainHeight = maxTerrainHeight; obj.Execute = ((data2.exec == null) ? null : DataValue.String(data2.exec)); obj.Admin = ((data2.admin == null) ? null : DataValue.Bool(data2.admin)); return obj; })); return list.ToArray(); } private static string FormatKey(string key) { if (key.Contains("<")) { return key; } KeyValuePair keyValuePair = Parse.Kvp(key, ' '); if (keyValuePair.Value == "") { return keyValuePair.Key.ToLowerInvariant(); } return keyValuePair.Key.ToLowerInvariant() + " " + keyValuePair.Value; } private static Tuple ParseSpawns(string[] spawns, float? delay, bool? triggerRules) { Spawn[] source = spawns.Select((string s) => new Spawn(s, delay, triggerRules)).ToArray(); Spawn[] array = source.Where((Spawn s) => s.Weight == null).ToArray(); if (array.Length == 0) { array = null; } Spawn[] array2 = source.Where((Spawn s) => s.Weight != null).ToArray(); if (array2.Length == 0) { array2 = null; } return Tuple.Create(array, array2); } private static Tuple ParseSpawns(SpawnData[] spawns, float? delay, bool? triggerRules) { Spawn[] source = spawns.Select((SpawnData s) => new Spawn(s, delay, triggerRules)).ToArray(); Spawn[] array = source.Where((Spawn s) => s.Weight == null).ToArray(); if (array.Length == 0) { array = null; } Spawn[] array2 = source.Where((Spawn s) => s.Weight != null).ToArray(); if (array2.Length == 0) { array2 = null; } return Tuple.Create(array, array2); } private static Object[] ParseObjects(string[] objects) { List list = new List(); list.AddRange(objects.Select((string s) => new Object(s))); return list.ToArray(); } private static Object[] ParseObjects(ObjectData[] objects) { List list = new List(); list.AddRange(objects.Select((ObjectData s) => new Object(s))); return list.ToArray(); } private static Tuple ParsePokes(PokeData[] objects) { Poke[] source = objects.Select((PokeData s) => new Poke(s)).ToArray(); Poke[] array = source.Where((Poke s) => s.Weight == null).ToArray(); if (array.Length == 0) { array = null; } Poke[] array2 = source.Where((Poke s) => s.Weight != null).ToArray(); if (array2.Length == 0) { array2 = null; } return Tuple.Create(array, array2); } private static Tuple? ParseObjectRpcs(Data data) { if (data.objectRpc == null || data.objectRpc.Length == 0) { return null; } ObjectRpcInfo[] source = data.objectRpc.Select((Dictionary s) => new ObjectRpcInfo(s)).ToArray(); ObjectRpcInfo[] array = source.Where((ObjectRpcInfo s) => s.Weight == null).ToArray(); if (array.Length == 0) { array = null; } ObjectRpcInfo[] array2 = source.Where((ObjectRpcInfo s) => s.Weight != null).ToArray(); if (array2.Length == 0) { array2 = null; } return Tuple.Create(array, array2); } private static Tuple? ParseClientRpcs(Data data) { if (data.clientRpc == null || data.clientRpc.Length == 0) { return null; } ClientRpcInfo[] source = data.clientRpc.Select((Dictionary s) => new ClientRpcInfo(s)).ToArray(); ClientRpcInfo[] array = source.Where((ClientRpcInfo s) => s.Weight == null).ToArray(); if (array.Length == 0) { array = null; } ClientRpcInfo[] array2 = source.Where((ClientRpcInfo s) => s.Weight != null).ToArray(); if (array2.Length == 0) { array2 = null; } return Tuple.Create(array, array2); } private static Range? ParseObjectsLimit(string? str) { if (str != null) { if (!int.TryParse(str, out var result)) { return Parse.IntRange(str); } return new Range(result, 0); } return null; } public static void SetupWatcher() { if (!Directory.Exists(Yaml.BaseDirectory)) { Directory.CreateDirectory(Yaml.BaseDirectory); } Yaml.SetupWatcher(Pattern, FromFile, overwriteBackup: true); } private static DataEntry? HandleItems(string items) { KeyValuePair keyValuePair = Parse.Kvp(items); if (keyValuePair.Value == "") { return DataHelper.Get(items); } DataEntry dataEntry = new DataEntry(); dataEntry.Items = new List(); ItemValue item = new ItemValue(new ItemData { prefab = keyValuePair.Key, stack = keyValuePair.Value }); dataEntry.Items.Add(item); return dataEntry; } } [HarmonyPatch(typeof(ZoneSystem), "Start")] [HarmonyPriority(100)] public class InitializeContent { private static void Postfix() { EWP.Harmony.UnpatchSelf(); if (Helper.IsServer()) { DataLoading.LoadEntries(); Loading.FromFile(); } } } public class Manager { private static readonly int TerrainActionHash = StringExtensionMethods.GetStableHashCode("ApplyOperation"); private static readonly int TerrainCompilerHash = StringExtensionMethods.GetStableHashCode("_TerrainCompiler"); public static void HandleGlobal(ActionType type, string[] args, Vector3 pos, bool remove) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0046: 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_005c: Unknown result type (might be due to invalid IL or missing references) if (!ZNet.instance.IsServer()) { return; } Parameters parameters = new Parameters("", args, pos); Info info = InfoSelector.SelectGlobalWeighted(type, args, parameters, pos, remove); Info[] array = InfoSelector.SelectGlobalSeparate(type, args, parameters, pos, remove); if (info == null && array == null) { info = InfoSelector.SelectGlobalFallback(type, args, parameters, pos, remove); } if (info != null) { HandleGlobal(info, parameters, pos, remove); } if (array != null) { Info[] array2 = array; for (int i = 0; i < array2.Length; i++) { HandleGlobal(array2[i], parameters, pos, remove); } } } private static void HandleGlobal(Info info, Parameters parameters, Vector3 pos, bool remove) { //IL_00a0: Unknown result type (might be due to invalid IL or missing references) if (info.Chance != null) { float? num = info.Chance.Get(parameters); if (num.HasValue && num < 1f && Random.value > num) { return; } } info.Execute?.Get(parameters); if (info.Commands.Length != 0) { Commands.Run(info, parameters); } info.GetWeightedClientRpc(parameters)?.InvokeGlobal(parameters); if (info.ClientRpcs != null) { GlobalClientRpc(info.ClientRpcs, parameters); } PokeGlobal(info, parameters, pos); } public static bool Handle(ActionType type, string[] args, ZDOID id) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) ZDO zDO = ZDOMan.instance.GetZDO(id); if (zDO == null) { return false; } return Handle(type, args, zDO); } public static bool Handle(ActionType type, string[] args, ZDO zdo) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) if (ZDOMan.instance.m_deadZDOs.ContainsKey(zdo.m_uid)) { return false; } if (!ZNet.instance.IsServer()) { return false; } GameObject prefab = ZNetScene.instance.GetPrefab(zdo.m_prefab); ObjectParameters parameters = new ObjectParameters(((prefab != null) ? ((Object)prefab).name : null) ?? "", args, zdo); Info info = InfoSelector.SelectWeighted(type, zdo, args, parameters); Info[] array = InfoSelector.SelectSeparate(type, zdo, args, parameters); if (info == null && array == null) { info = InfoSelector.SelectFallback(type, zdo, args, parameters); } if (info == null && array == null) { return false; } bool flag = false; if (info != null) { flag |= Handle(info, parameters, zdo); } if (array != null) { Info[] array2 = array; foreach (Info info2 in array2) { flag |= Handle(info2, parameters, zdo); } } return flag; } private static bool Handle(Info info, Parameters parameters, ZDO zdo) { //IL_01f1: 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_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) if (info.Chance != null) { float? num = info.Chance.Get(parameters); if (num.HasValue && num < 1f && Random.value > num) { return false; } } info.Execute?.Get(parameters); if (info.Commands.Length != 0) { Commands.Run(info, parameters); } info.GetWeightedObjectRpc(parameters)?.Invoke(zdo, parameters); info.GetWeightedClientRpc(parameters)?.Invoke(zdo, parameters); if (info.ObjectRpcs != null) { ObjectRpc(info.ObjectRpcs, zdo, parameters); } if (info.ClientRpcs != null) { ClientRpc(info.ClientRpcs, zdo, parameters); } bool flag = info.Remove?.GetBool(parameters).GetValueOrDefault() ?? false; DataEntry dataEntry = DataHelper.Get(info.Data, parameters); bool flag2 = info.InjectData ?? dataEntry?.InjectDataByDefault ?? false; bool flag3 = info.Regenerate && !flag2; HandleSpawns(info, zdo, parameters, flag, flag3, dataEntry); Poke(info, zdo, parameters); Terrain(info, zdo, parameters); string text = info.Drops?.Get(parameters); if (text != null && text == "true") { SpawnDrops(zdo); } else if (text != null && text != "false") { SpawnItems(text, zdo, parameters); } if (flag || flag3) { DelayedRemove.Add((info.RemoveDelay?.Get(parameters)).GetValueOrDefault(), zdo.m_uid, flag && info.TriggerRules); } else if (flag2) { if (!info.TriggerRules) { HandleChanged.IgnoreZdo = zdo.m_uid; } DataEntry removeItems = info.RemoveItems; DataEntry addItems = info.AddItems; if (dataEntry != null) { ZdoEntry zdoEntry = new ZdoEntry(zdo); zdoEntry.Load(dataEntry, parameters); zdoEntry.Write(zdo); } removeItems?.RemoveItems(parameters, zdo); addItems?.AddItems(parameters, zdo); long? num2 = info.Owner?.Get(parameters); if (num2.HasValue) { zdo.SetOwner(num2.Value); } if (dataEntry != null || removeItems != null || addItems != null || num2.HasValue) { zdo.DataRevision += 100; ZDOMan.instance.ForceSendZDO(zdo.m_uid); } HandleChanged.IgnoreZdo = ZDOID.None; } return info.Cancel?.GetBool(parameters).GetValueOrDefault() ?? false; } public static bool CheckCancel(ActionType type, string[] args, ZDO zdo) { if (!ZNet.instance.IsServer()) { return false; } GameObject prefab = ZNetScene.instance.GetPrefab(zdo.m_prefab); string prefab2 = ((prefab != null) ? ((Object)prefab).name : null) ?? ""; ObjectParameters parameters = new ObjectParameters(prefab2, args, zdo); Info info = InfoSelector.SelectWeighted(type, zdo, args, parameters); Info[] array = InfoSelector.SelectSeparate(type, zdo, args, parameters); if (info == null && array == null) { info = InfoSelector.SelectFallback(type, zdo, args, parameters); } if (info == null && array == null) { return false; } if (info != null && (info.Cancel?.GetBool(parameters)).GetValueOrDefault()) { return true; } return array?.Any((Info i) => i.Cancel?.GetBool(parameters).GetValueOrDefault() ?? false) ?? false; } private static void HandleSpawns(Info info, ZDO zdo, Parameters pars, bool remove, bool regenerate, DataEntry? customData) { //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) bool flag = !remove && regenerate; Spawn weightedSpawn = info.GetWeightedSpawn(pars); if (weightedSpawn != null) { DelayedSpawn.Add(weightedSpawn, zdo, customData, pars); } if (info.Spawns != null) { Spawn[] spawns = info.Spawns; for (int i = 0; i < spawns.Length; i++) { DelayedSpawn.Add(spawns[i], zdo, customData, pars); } } Spawn weightedSwap = info.GetWeightedSwap(pars); if (info.Swaps == null && info.WeightedSwaps == null && !flag) { return; } DataEntry dataEntry = DataHelper.Merge(new DataEntry(zdo), customData); if (weightedSwap != null) { DelayedSpawn.Add(weightedSwap, zdo, dataEntry, pars); } if (info.Swaps != null) { Spawn[] spawns = info.Swaps; for (int i = 0; i < spawns.Length; i++) { DelayedSpawn.Add(spawns[i], zdo, dataEntry, pars); } } if (flag) { DataEntry removeItems = info.RemoveItems; DataEntry addItems = info.AddItems; ZdoEntry zdoEntry = new ZdoEntry(zdo); if (dataEntry != null) { zdoEntry.Load(dataEntry, pars); } ZDO val = DelayedSpawn.CreateObject(zdoEntry, triggerRules: false); if (val != null) { removeItems?.RemoveItems(pars, val); addItems?.AddItems(pars, val); PrefabConnector.AddSwap(zdo.m_uid, val.m_uid); } } } public static void RemoveZDO(ZDOID id, bool triggerRules) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (!triggerRules) { ZDOMan.instance.m_deadZDOs[id] = ZNet.instance.GetTime().Ticks; } ZDO zDO = ZDOMan.instance.GetZDO(id); if (zDO != null) { zDO.SetOwner(ZDOMan.instance.m_sessionID); ZDOMan.instance.DestroyZDO(zDO); } } public static void SpawnDrops(ZDO zdo) { if (ZNetScene.instance.m_instances.ContainsKey(zdo)) { SpawnDrops(zdo, ((Component)ZNetScene.instance.m_instances[zdo]).gameObject); return; } GameObject val = ZNetScene.instance.CreateObject(zdo); val.GetComponent().m_ghost = true; ZNetScene.instance.m_instances.Remove(zdo); SpawnDrops(zdo, val); Object.Destroy((Object)(object)val); } private static void SpawnDrops(ZDO source, GameObject obj) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) HandleCreated.Skip = true; DropOnDestroyed val = default(DropOnDestroyed); if (obj.TryGetComponent(ref val)) { val.OnDestroyed(); } CharacterDrop val2 = default(CharacterDrop); if (obj.TryGetComponent(ref val2)) { val2.m_character = obj.GetComponent(); if (Object.op_Implicit((Object)(object)val2.m_character)) { val2.OnDeath(); } } Ragdoll val3 = default(Ragdoll); if (obj.TryGetComponent(ref val3)) { val3.SpawnLoot(val3.GetAverageBodyPosition()); } Piece val4 = default(Piece); if (obj.TryGetComponent(ref val4)) { Plant val5 = default(Plant); if (obj.TryGetComponent(ref val5)) { Requirement[] resources = val4.m_resources; for (int i = 0; i < resources.Length; i++) { resources[i].m_recover = true; } } val4.DropResources((HitData)null); } TreeBase val6 = default(TreeBase); if (obj.TryGetComponent(ref val6)) { foreach (GameObject drop in val6.m_dropWhenDestroyed.GetDropList()) { CreateDrop(source, drop); } } TreeLog val7 = default(TreeLog); if (obj.TryGetComponent(ref val7)) { foreach (GameObject drop2 in val7.m_dropWhenDestroyed.GetDropList()) { CreateDrop(source, drop2); } } HandleCreated.Skip = false; } public static void CreateDrop(ZDO source, GameObject item) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) ZdoEntry.Spawn(StringExtensionMethods.GetStableHashCode(((Object)item).name), item.transform.position, Vector3.zero, source.GetOwner()); } public static void SpawnItems(string dataName, ZDO zdo, Parameters pars) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) DataEntry dataEntry = DataHelper.Get(dataName); if (dataEntry == null) { return; } List list = dataEntry.GenerateItems(pars, new Vector2i(10000, 10000)); HandleCreated.Skip = true; foreach (ItemValue item in list) { item.Spawn(zdo, pars); } HandleCreated.Skip = false; } public static void Poke(Info info, ZDO zdo, Parameters pars) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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_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_00a2: Unknown result type (might be due to invalid IL or missing references) Vector3 position = zdo.m_position; Quaternion rotation = zdo.GetRotation(); if (info.LegacyPokes != null) { ZDOID[] nearby = ObjectsFiltering.GetNearby(info.PokeLimit, info.LegacyPokes, position, rotation, pars, null); string[] args = ExpandWorld.Prefab.Poke.PokeEvaluate(pars.Replace(info.PokeParameter)).Split(new char[1] { ' ' }); DelayedPoke.Add(info.PokeDelay, nearby, args); } Poke weightedPoke = info.GetWeightedPoke(pars); if (weightedPoke != null) { DelayedPoke.Add(weightedPoke, zdo.m_uid, position, rotation, pars); } if (info.Pokes != null) { Poke[] pokes = info.Pokes; for (int i = 0; i < pokes.Length; i++) { DelayedPoke.Add(pokes[i], zdo.m_uid, position, rotation, pars); } } } public static void PokeGlobal(Info info, Parameters pars, Vector3 pos) { //IL_0014: 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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_008d: Unknown result type (might be due to invalid IL or missing references) if (info.LegacyPokes != null) { ZDOID[] nearby = ObjectsFiltering.GetNearby(info.PokeLimit, info.LegacyPokes, pos, Quaternion.identity, pars, null); string text = ExpandWorld.Prefab.Poke.PokeEvaluate(pars.Replace(info.PokeParameter)); DelayedPoke.Add(info.PokeDelay, nearby, text.Split(new char[1] { ' ' })); } Poke weightedPoke = info.GetWeightedPoke(pars); if (weightedPoke != null) { DelayedPoke.AddGlobal(weightedPoke, pos, Quaternion.identity, pars); } if (info.Pokes != null) { Poke[] pokes = info.Pokes; for (int i = 0; i < pokes.Length; i++) { DelayedPoke.AddGlobal(pokes[i], pos, Quaternion.identity, pars); } } } public static void Terrain(Info info, ZDO zdo, Parameters pars) { //IL_000a: 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) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) if (info.Terrains != null) { Vector3 position = zdo.m_position; Quaternion baseRotation = Quaternion.Euler(zdo.m_rotation); long owner = zdo.GetOwner(); Terrain[] terrains = info.Terrains; foreach (Terrain obj in terrains) { float valueOrDefault = (obj.Delay?.Get(pars)).GetValueOrDefault(); obj.Get(pars, position, baseRotation, out Vector3 pos, out float size, out float resetRadius, out ZPackage pkg); DelayedTerrain.Add(valueOrDefault, owner, pos, size, pkg, resetRadius); } } } public static void ObjectRpc(ObjectRpcInfo[] info, ZDO zdo, Parameters parameters) { for (int i = 0; i < info.Length; i++) { info[i].Invoke(zdo, parameters); } } public static void ClientRpc(ClientRpcInfo[] info, ZDO zdo, Parameters parameters) { for (int i = 0; i < info.Length; i++) { info[i].Invoke(zdo, parameters); } } public static void GlobalClientRpc(ClientRpcInfo[] info, Parameters parameters) { for (int i = 0; i < info.Length; i++) { info[i].InvokeGlobal(parameters); } } public static void ModifyTerrain(long source, Vector3 pos, float radius, ZPackage pkg, float resetRadius) { //IL_0000: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_001d: 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_0027: 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_0031: 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_003b: 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_0045: Unknown result type (might be due to invalid IL or missing references) //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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_0075: 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_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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00c6: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) Vector3 val = pos + new Vector3(radius, 0f, radius); Vector3 val2 = pos + new Vector3(0f - radius, 0f, 0f - radius); Vector3 val3 = pos + new Vector3(0f - radius, 0f, radius); Vector3 val4 = pos + new Vector3(radius, 0f, 0f - radius); Vector2i zone = ZoneSystem.GetZone(val); Vector2i zone2 = ZoneSystem.GetZone(val2); Vector2i zone3 = ZoneSystem.GetZone(val3); Vector2i zone4 = ZoneSystem.GetZone(val4); int num = Mathf.Min(new int[4] { zone.x, zone2.x, zone3.x, zone4.x }); int num2 = Mathf.Max(new int[4] { zone.x, zone2.x, zone3.x, zone4.x }); int num3 = Mathf.Min(new int[4] { zone.y, zone2.y, zone3.y, zone4.y }); int num4 = Mathf.Max(new int[4] { zone.y, zone2.y, zone3.y, zone4.y }); Vector2i val5 = default(Vector2i); for (int i = num; i <= num2; i++) { for (int j = num3; j <= num4; j++) { ((Vector2i)(ref val5))..ctor(i, j); if (ZoneSystem.instance.IsZoneGenerated(val5)) { ModifyZoneTerrain(source, pos, val5, pkg, resetRadius); } } } } private static void ModifyZoneTerrain(long source, Vector3 pos, Vector2i zone, ZPackage pkg, float resetRadius) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_001e: Unknown result type (might be due to invalid IL or missing references) ZDO val = FindTerrainCompiler(zone); if (val != null && val.HasOwner()) { if (resetRadius > 0f) { ResetTerrainInZdo(pos, resetRadius, zone, val); return; } Rpc(source, val.GetOwner(), val.m_uid, TerrainActionHash, new object[1] { pkg }); } } public static bool GenerateTerrainCompilers(long source, Vector3 pos, float radius) { //IL_0000: 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_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_001d: 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_0027: 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_0031: 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_003b: 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_0045: Unknown result type (might be due to invalid IL or missing references) //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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0066: 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_0075: 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_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_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00c6: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_012e: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) Vector3 val = pos + new Vector3(radius, 0f, radius); Vector3 val2 = pos + new Vector3(0f - radius, 0f, 0f - radius); Vector3 val3 = pos + new Vector3(0f - radius, 0f, radius); Vector3 val4 = pos + new Vector3(radius, 0f, 0f - radius); Vector2i zone = ZoneSystem.GetZone(val); Vector2i zone2 = ZoneSystem.GetZone(val2); Vector2i zone3 = ZoneSystem.GetZone(val3); Vector2i zone4 = ZoneSystem.GetZone(val4); int num = Mathf.Min(new int[4] { zone.x, zone2.x, zone3.x, zone4.x }); int num2 = Mathf.Max(new int[4] { zone.x, zone2.x, zone3.x, zone4.x }); int num3 = Mathf.Min(new int[4] { zone.y, zone2.y, zone3.y, zone4.y }); int num4 = Mathf.Max(new int[4] { zone.y, zone2.y, zone3.y, zone4.y }); bool flag = false; Vector2i val5 = default(Vector2i); for (int i = num; i <= num2; i++) { for (int j = num3; j <= num4; j++) { ((Vector2i)(ref val5))..ctor(i, j); if (ZoneSystem.instance.IsZoneGenerated(val5)) { flag |= GenerateZoneTerrainCompiler(source, val5); } } } return flag; } private static void ResetTerrainInZdo(Vector3 pos, float radius, Vector2i zone, ZDO zdo) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0026: Expected O, but got Unknown //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_004a: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) byte[] byteArray = zdo.GetByteArray(ZDOVars.s_TCData, (byte[])null); if (byteArray == null) { return; } Vector3 zonePos = ZoneSystem.GetZonePos(zone); bool flag = false; ZPackage val = new ZPackage(Utils.Decompress(byteArray)); ZPackage val2 = new ZPackage(); val2.Write(val.ReadInt()); val2.Write(val.ReadInt() + 1); val.ReadVector3(); val2.Write(zonePos); val.ReadSingle(); val2.Write(radius); int num = val.ReadInt(); val2.Write(num); int num2 = (int)Math.Sqrt(num); for (int i = 0; i < num; i++) { bool flag2; bool num3 = (flag2 = val.ReadBool()); int num4 = i / num2; int num5 = i % num2; if (num4 >= 0 && num4 <= num2 - 1 && num5 >= 0 && num5 <= num2 - 1 && Utils.DistanceXZ(VertexToWorld(zonePos, num4, num5), pos) < radius) { flag2 = false; } val2.Write(flag2); if (flag2) { val2.Write(val.ReadSingle()); val2.Write(val.ReadSingle()); } if (num3 && !flag2) { flag = true; val.ReadSingle(); val.ReadSingle(); } } num = val.ReadInt(); val2.Write(num); for (int j = 0; j < num; j++) { bool flag3; bool num6 = (flag3 = val.ReadBool()); int j2 = j / num2; int i2 = j % num2; if (Utils.DistanceXZ(VertexToWorld(zonePos, j2, i2), pos) < radius) { flag3 = false; } val2.Write(flag3); if (flag3) { val2.Write(val.ReadSingle()); val2.Write(val.ReadSingle()); val2.Write(val.ReadSingle()); val2.Write(val.ReadSingle()); } if (num6 && !flag3) { flag = true; val.ReadSingle(); val.ReadSingle(); val.ReadSingle(); val.ReadSingle(); } } if (flag) { byte[] array = Utils.Compress(val2.GetArray()); zdo.DataRevision += 100; zdo.Set(ZDOVars.s_TCData, array); } } private static Vector3 VertexToWorld(Vector3 pos, int j, int i) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) pos.x += (float)i - 32.5f; pos.z += (float)j - 32.5f; return pos; } private static bool GenerateZoneTerrainCompiler(long source, Vector2i zone) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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) ZDO val = FindTerrainCompiler(zone); if (val != null && val.HasOwner()) { return false; } if (val == null) { ZDO obj = ZDOMan.instance.CreateNewZDO(ZoneSystem.GetZonePos(zone), TerrainCompilerHash); ZNetView component = ZNetScene.instance.GetPrefab(TerrainCompilerHash).GetComponent(); obj.m_prefab = TerrainCompilerHash; obj.Persistent = component.m_persistent; obj.Type = component.m_type; obj.Distant = component.m_distant; obj.SetOwnerInternal(source); } return true; } private static ZDO? FindTerrainCompiler(Vector2i zone) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) int num = ZDOMan.instance.SectorToIndex(zone); List value; return ((num >= 0 && num < ZDOMan.instance.m_objectsBySector.Length) ? ZDOMan.instance.m_objectsBySector[num] : (ZDOMan.instance.m_objectsByOutsideSector.TryGetValue(zone, out value) ? value : null))?.FirstOrDefault((Func)((ZDO z) => z.m_prefab == TerrainCompilerHash)); } public static void Rpc(long source, long target, ZDOID id, int hash, object[] parameters) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0038: 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_003a: 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_0047: Expected O, but got Unknown ZRoutedRpc instance = ZRoutedRpc.instance; RoutedRPCData val = new RoutedRPCData(); long id2 = instance.m_id; int rpcMsgID = instance.m_rpcMsgID; instance.m_rpcMsgID = rpcMsgID + 1; val.m_msgID = id2 + rpcMsgID; val.m_senderPeerID = source; val.m_targetPeerID = target; val.m_targetZDO = id; val.m_methodHash = hash; RoutedRPCData val2 = val; ZRpc.Serialize(parameters, ref val2.m_parameters); val2.m_parameters.SetPos(0); if (target == instance.m_id || target == ZRoutedRpc.Everybody) { instance.HandleRoutedRPC(val2); } if (target != instance.m_id) { instance.RouteRPC(val2); } } } public enum RpcTarget { All, Owner, Search, ZDO } public abstract class RpcInfo { private static readonly HashSet Types = new HashSet { "int", "long", "float", "bool", "string", "vec", "quat", "hash", "hit", "enum_reason", "enum_message", "enum_trap", "zdo" }; private readonly int Hash; private readonly RpcTarget Target; private readonly IStringValue? TargetParameter; private readonly IStringValue? SourceParameter; private readonly KeyValuePair[] Parameters; private readonly IFloatValue? Delay; private readonly IIntValue? Repeat; private readonly IFloatValue? RepeatInterval; private readonly IFloatValue? RepeatChance; private readonly IFloatValue? Chance; public readonly IFloatValue? Weight; public readonly IBoolValue? Overwrite; private readonly bool Packaged; public bool IsTarget => Target == RpcTarget.Search; protected abstract ZDOID GetId(ZDO zdo); public static bool IsType(string line) { return Types.Contains(Parse.Kvp(line).Key); } public RpcInfo(Dictionary lines) { Target = RpcTarget.Owner; if (lines.TryGetValue("name", out string value)) { Hash = StringExtensionMethods.GetStableHashCode(value); } if (lines.TryGetValue("source", out string value2)) { SourceParameter = DataValue.String(value2); } if (lines.TryGetValue("packaged", out string value3)) { Packaged = Parse.Boolean(value3); } if (lines.TryGetValue("target", out string value4)) { switch (value4) { case "all": Target = RpcTarget.All; break; case "search": Target = RpcTarget.Search; break; case "owner": Target = RpcTarget.Owner; break; default: Target = RpcTarget.ZDO; TargetParameter = DataValue.String(value4); break; } } if (lines.TryGetValue("delay", out string value5)) { Delay = DataValue.Float(value5); } if (lines.TryGetValue("repeat", out string value6)) { Repeat = DataValue.Int(value6); } if (lines.TryGetValue("repeatInterval", out string value7)) { RepeatInterval = DataValue.Float(value7); } if (lines.TryGetValue("repeatChance", out string value8)) { RepeatChance = DataValue.Float(value8); } if (lines.TryGetValue("chance", out string value9)) { Chance = DataValue.Float(value9); } if (lines.TryGetValue("weight", out string value10)) { Weight = DataValue.Float(value10); } if (lines.TryGetValue("overwrite", out string value11)) { Overwrite = DataValue.Bool(value11); } List> list = new List>(); list.AddRange(from p in lines orderby (!int.TryParse(p.Key, out var result2)) ? 1000 : result2 where Parse.TryInt(p.Key, out var _) select Parse.Kvp(p.Value)); Parameters = list.ToArray(); } public void Invoke(ZDO zdo, Parameters pars) { float valueOrDefault = (Chance?.Get(pars)).GetValueOrDefault(1f); if (valueOrDefault < 1f && Random.value > valueOrDefault) { return; } float valueOrDefault2 = (Delay?.Get(pars)).GetValueOrDefault(); List list = GenerateDelays(valueOrDefault2, pars); bool overwrite = (Overwrite?.GetBool(pars)).GetValueOrDefault(); if (list != null) { foreach (float item in list) { Invoke(zdo, pars, item, overwrite); overwrite = false; } return; } Invoke(zdo, pars, valueOrDefault2, overwrite); } private void Invoke(ZDO zdo, Parameters pars, float delay, bool overwrite) { //IL_0030: 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_003b: Unknown result type (might be due to invalid IL or missing references) //IL_007c: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) long source = ZRoutedRpc.instance.m_id; string text = SourceParameter?.Get(pars); if (text != null && text != "") { ZDOID val = Parse.ZdoId(text); ZDO zDO = ZDOMan.instance.GetZDO(val); source = ((zDO != null) ? zDO.GetOwner() : 0); } object[] parameters = (Packaged ? GetPackagedParameters(pars) : GetParameters(zdo, pars)); if (Target == RpcTarget.Owner) { DelayedRpc.Add(delay, source, zdo.GetOwner(), GetId(zdo), Hash, parameters, overwrite); } else if (Target == RpcTarget.All) { DelayedRpc.Add(delay, source, ZRoutedRpc.Everybody, GetId(zdo), Hash, parameters, overwrite); } else { if (Target != RpcTarget.ZDO) { return; } string text2 = TargetParameter?.Get(pars); if (text2 != null && text2 != "") { ZDOID val2 = Parse.ZdoId(text2); ZDO zDO2 = ZDOMan.instance.GetZDO(val2); long? num = ((zDO2 != null) ? new long?(zDO2.GetOwner()) : null); if (num.HasValue) { DelayedRpc.Add(delay, source, num.Value, GetId(zdo), Hash, parameters, overwrite); } } } } public void InvokeGlobal(Parameters pars) { float valueOrDefault = (Chance?.Get(pars)).GetValueOrDefault(1f); if (valueOrDefault < 1f && Random.value > valueOrDefault) { return; } float valueOrDefault2 = (Delay?.Get(pars)).GetValueOrDefault(); List list = GenerateDelays(valueOrDefault2, pars); if (list != null) { foreach (float item in list) { InvokeGlobal(pars, item); } return; } InvokeGlobal(pars, valueOrDefault2); } private void InvokeGlobal(Parameters pars, float delay) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) long id = ZRoutedRpc.instance.m_id; object[] parameters = (Packaged ? PackagedGetParameters(pars) : GetParameters(pars)); bool valueOrDefault = (Overwrite?.GetBool(pars)).GetValueOrDefault(); DelayedRpc.Add(delay, id, ZRoutedRpc.Everybody, ZDOID.None, Hash, parameters, valueOrDefault); } private List? GenerateDelays(float delay, Parameters pars) { int valueOrDefault = (Repeat?.Get(pars)).GetValueOrDefault(); float valueOrDefault2 = (RepeatInterval?.Get(pars)).GetValueOrDefault(delay); float valueOrDefault3 = (RepeatChance?.Get(pars)).GetValueOrDefault(1f); return Helper.GenerateDelays(delay, valueOrDefault, valueOrDefault2, valueOrDefault3); } private object[] GetParameters(ZDO? zdo, Parameters pars) { //IL_00f3: 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_015b: Unknown result type (might be due to invalid IL or missing references) Parameters pars2 = pars; object[] array = ((IEnumerable)Parameters.Select((KeyValuePair p) => pars2.Replace(p.Value))).ToArray(); for (int i = 0; i < array.Length; i++) { string key = Parameters[i].Key; string text = (string)array[i]; if (key == "int") { array[i] = Calculator.EvaluateInt(text).GetValueOrDefault(); } if (key == "long") { array[i] = Calculator.EvaluateLong(text).GetValueOrDefault(); } if (key == "float") { array[i] = Calculator.EvaluateFloat(text).GetValueOrDefault(); } if (key == "bool") { array[i] = Parse.Boolean(text); } if (key == "string") { array[i] = text; } if (key == "vec") { array[i] = Calculator.EvaluateVector3(text); } if (key == "quat") { array[i] = Calculator.EvaluateQuaternion(text); } if (key == "hash") { array[i] = StringExtensionMethods.GetStableHashCode(text); } if (key == "hit") { array[i] = Parse.Hit(zdo, text); } if (key == "zdo") { array[i] = Parse.ZdoId(text); } if (key == "enum_message") { array[i] = Parse.EnumMessage(text); } if (key == "enum_reason") { array[i] = Parse.EnumReason(text); } if (key == "enum_trap") { array[i] = Parse.EnumTrap(text); } if (key == "enum_damagetext") { array[i] = Parse.EnumDamageText(text); } if (key == "enum_terrainpaint") { array[i] = Parse.EnumTerrainPaint(text); } if (key == "userinfo") { array[i] = GetInfo(text); } } return array; } private UserInfo GetInfo(string arg) { //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_002a: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown return new UserInfo { Name = ((arg == "") ? Game.instance.GetPlayerProfile().GetName() : arg), UserId = ((IUser)PlatformManager.DistributionPlatform.LocalUser).PlatformUserID }; } private object[] GetPackagedParameters(Parameters pars) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) Parameters pars2 = pars; ZPackage val = new ZPackage(); object[] array = ((IEnumerable)Parameters.Select((KeyValuePair p) => pars2.Replace(p.Value))).ToArray(); for (int i = 0; i < array.Length; i++) { string key = Parameters[i].Key; string text = (string)array[i]; if (key == "int") { val.Write(Calculator.EvaluateInt(text).GetValueOrDefault()); } if (key == "long") { val.Write(Calculator.EvaluateLong(text).GetValueOrDefault()); } if (key == "float") { val.Write(Calculator.EvaluateFloat(text).GetValueOrDefault()); } if (key == "bool") { val.Write(Parse.Boolean(text)); } if (key == "string") { val.Write(text); } if (key == "vec") { val.Write(Calculator.EvaluateVector3(text)); } if (key == "quat") { val.Write(Calculator.EvaluateQuaternion(text)); } if (key == "hash") { val.Write(StringExtensionMethods.GetStableHashCode(text)); } if (key == "zdo") { val.Write(Parse.ZdoId(text)); } if (key == "enum_message") { val.Write(Parse.EnumMessage(text)); } if (key == "enum_reason") { val.Write(Parse.EnumReason(text)); } if (key == "enum_trap") { val.Write(Parse.EnumTrap(text)); } if (key == "enum_damagetext") { val.Write(Parse.EnumDamageText(text)); } if (key == "enum_terrainpaint") { val.Write(Parse.EnumTerrainPaint(text)); } } return new object[1] { val }; } private object[] GetParameters(Parameters pars) { return GetParameters(null, pars); } private object[] PackagedGetParameters(Parameters pars) { return GetPackagedParameters(pars); } } public class ObjectRpcInfo : RpcInfo { public ObjectRpcInfo(Dictionary lines) : base(lines) { } protected override ZDOID GetId(ZDO zdo) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return zdo.m_uid; } } public class ClientRpcInfo : RpcInfo { public ClientRpcInfo(Dictionary lines) : base(lines) { } protected override ZDOID GetId(ZDO zdo) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return ZDOID.None; } } } internal sealed class <>z__ReadOnlyList : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { int ICollection.Count => _items.Count; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection.Count => _items.Count; T IReadOnlyList.this[int index] => _items[index]; int ICollection.Count => _items.Count; bool ICollection.IsReadOnly => true; T IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyList(List items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(T item) { return _items.Contains(item); } void ICollection.CopyTo(T[] array, int arrayIndex) { _items.CopyTo(array, arrayIndex); } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { return _items.IndexOf(item); } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } }