using System; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Serialization; 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 ExpandWorldData; using ExpandWorldData.Dungeon; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using ServerSync; using Service; using SoftReferenceableAssets; using TMPro; 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("ExpandWorldData")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+a31d4055e77a751901d5913340852395ad62079f")] [assembly: AssemblyProduct("ExpandWorldData")] [assembly: AssemblyTitle("ExpandWorldData")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [CompilerGenerated] internal delegate TResult <>f__AnonymousDelegate0(T1 arg1, T2 arg2, T3 arg3, out T4 arg4, T5 arg5 = false); namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 num3 = 0; num3 < array3.Length; num3++) { if (!(array3[num3] == "") || num3 + 1 >= array3.Length) { num2 = (num2.HasValue ? (num2 - EvaluateDouble(array3[num3])) : new double?(EvaluateDouble(array3[num3]))); } else { array3[num3 + 1] = "-" + array3[num3 + 1]; } } return num2.GetValueOrDefault(); } string[] array4 = expression.Split(new char[1] { '*' }); if (array4.Length > 1) { double num4 = 1.0; string[] array2 = array4; foreach (string expression3 in array2) { num4 *= EvaluateDouble(expression3); } return num4; } string[] array5 = expression.Split(new char[1] { '/' }); if (array5.Length > 1) { double num5 = EvaluateDouble(array5[0]); for (int num6 = 1; num6 < array5.Length; num6++) { num5 /= EvaluateDouble(array5[num6]); } return num5; } 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 num3 = 0; num3 < array3.Length; num3++) { if (!(array3[num3] == "") || num3 + 1 >= array3.Length) { num2 = (num2.HasValue ? (num2 - EvalLong(array3[num3])) : new long?(EvalLong(array3[num3]))); } else { array3[num3 + 1] = "-" + array3[num3 + 1]; } } return num2.GetValueOrDefault(); } string[] array4 = expression.Split(new char[1] { '*' }); if (array4.Length > 1) { long num4 = 1L; string[] array2 = array4; foreach (string expression3 in array2) { num4 *= EvalLong(expression3); } return num4; } string[] array5 = expression.Split(new char[1] { '/' }); if (array5.Length > 1) { long num5 = EvalLong(array5[0]); for (int num6 = 1; num6 < array5.Length; num6++) { num5 /= EvalLong(array5[num6]); } return num5; } 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 Dictionary? Strings; public Dictionary? Floats; public Dictionary? Ints; 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 DataEntry() { } public DataEntry(string base64) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown Load(new ZPackage(base64)); } public DataEntry(DataData data) { Load(data); } private Vector2i GetContainerSize() { //IL_001a: 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) return (Vector2i)(((??)ContainerSize) ?? new Vector2i(4, 2)); } 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.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; 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = 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 = Hash(keyValuePair9.Key); if (ByteArrays.ContainsKey(key9)) { Log.Warning("Data " + data.name + ": Duplicate byte array key " + keyValuePair9.Key + "."); } ByteArrays[key9] = Convert.FromBase64String(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 (Ints == null) { Ints = new Dictionary(); } Ints[StringExtensionMethods.GetStableHashCode("HasFields")] = DataValue.Simple(1); foreach (string item in hashSet) { Ints[StringExtensionMethods.GetStableHashCode("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) : ((ObjectType?)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(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 ((num & 1) != 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 ((num & 2) != 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 ((num & 4) != 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 ((num & 8) != 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 ((num & 0x40) != 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 ((num & 0x10) != 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 ((num & 0x80) != 0) { if (ByteArrays == null) { ByteArrays = new Dictionary(); } byte b7 = pkg.ReadByte(); for (int num2 = 0; num2 < b7; num2++) { ByteArrays[pkg.ReadInt()] = pkg.ReadByteArray(); } } if ((num & 0x100) != 0) { ConnectionType = (ConnectionType)pkg.ReadByte(); ConnectionHash = pkg.ReadInt(); } if ((num & 0x200) != 0) { Persistent = new SimpleBoolValue(pkg.ReadBool()); } if ((num & 0x400) != 0) { Distant = new SimpleBoolValue(pkg.ReadBool()); } if ((num & 0x800) != 0) { Priority = (ObjectType)pkg.ReadByte(); } } public bool Match(Parameters pars, ZDO zdo) { //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028f: 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_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: 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_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02dd: Unknown result type (might be due to invalid IL or missing references) if (Strings != null && Strings.Any>((KeyValuePair pair) => pair.Value.Match(pars, zdo.GetString(pair.Key, "")) == false)) { return false; } if (Floats != null && Floats.Any>((KeyValuePair pair) => pair.Value.Match(pars, zdo.GetFloat(pair.Key, 0f)) == false)) { return false; } if (Ints != null && Ints.Any>((KeyValuePair pair) => pair.Value.Match(pars, zdo.GetInt(pair.Key, 0)) == false)) { return false; } if (Longs != null && Longs.Any>((KeyValuePair pair) => pair.Value.Match(pars, zdo.GetLong(pair.Key, 0L)) == false)) { return false; } if (Bools != null && Bools.Any>((KeyValuePair pair) => pair.Value.Match(pars, zdo.GetBool(pair.Key, false)) == false)) { return false; } if (Hashes != null && Hashes.Any>((KeyValuePair pair) => pair.Value.Match(pars, zdo.GetInt(pair.Key, 0)) == false)) { return false; } if (Vecs != null && Vecs.Any>((KeyValuePair pair) => pair.Value.Match(pars, zdo.GetVec3(pair.Key, Vector3.zero)) == false)) { return false; } if (Quats != null && Quats.Any>((KeyValuePair pair) => pair.Value.Match(pars, zdo.GetQuaternion(pair.Key, Quaternion.identity)) == false)) { return false; } if (ByteArrays != null && ByteArrays.Any>((KeyValuePair pair) => !pair.Value.SequenceEqual(zdo.GetByteArray(pair.Key, (byte[])null)))) { return false; } if (Persistent != null && Persistent.Match(pars, zdo.Persistent) == false) { return false; } if (Distant != null && Distant.Match(pars, zdo.Distant) == false) { return false; } if (Priority.HasValue && Priority.Value != zdo.Type) { return false; } if (Items != null) { return ItemValue.Match(pars, Items, zdo, ItemAmount); } if (ItemAmount != null) { return ItemValue.Match(pars, zdo, ItemAmount); } if (ConnectionType.HasValue) { if ((int)ConnectionType.Value == 0) { ZDOConnection connection = zdo.GetConnection(); if (connection != null && connection.m_target != ZDOID.None) { return false; } } else { ZDOID connectionZDOID = zdo.GetConnectionZDOID(ConnectionType.Value); if (TargetConnectionId == null) { if (connectionZDOID == ZDOID.None) { return false; } } else { ZDOID? val = TargetConnectionId.Get(pars); 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_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) if (Strings != null && Strings.Any>((KeyValuePair pair) => pair.Value.Match(pars, zdo.GetString(pair.Key, "")) == true)) { return false; } if (Floats != null && Floats.Any>((KeyValuePair pair) => pair.Value.Match(pars, zdo.GetFloat(pair.Key, 0f)) == true)) { return false; } if (Ints != null && Ints.Any>((KeyValuePair pair) => pair.Value.Match(pars, zdo.GetInt(pair.Key, 0)) == true)) { return false; } if (Longs != null && Longs.Any>((KeyValuePair pair) => pair.Value.Match(pars, zdo.GetLong(pair.Key, 0L)) == true)) { return false; } if (Bools != null && Bools.Any>((KeyValuePair pair) => pair.Value.Match(pars, zdo.GetBool(pair.Key, false)) == true)) { return false; } if (Hashes != null && Hashes.Any>((KeyValuePair pair) => pair.Value.Match(pars, zdo.GetInt(pair.Key, 0)) == true)) { return false; } if (Vecs != null && Vecs.Any>((KeyValuePair pair) => pair.Value.Match(pars, zdo.GetVec3(pair.Key, Vector3.zero)) == true)) { return false; } if (Quats != null && Quats.Any>((KeyValuePair pair) => pair.Value.Match(pars, zdo.GetQuaternion(pair.Key, Quaternion.identity)) == true)) { return false; } if (ByteArrays != null && ByteArrays.Any>((KeyValuePair pair) => pair.Value.SequenceEqual(zdo.GetByteArray(pair.Key, (byte[])null)))) { return false; } if (Persistent != null && Persistent.Match(pars, zdo.Persistent) == true) { return false; } if (Distant != null && Distant.Match(pars, zdo.Distant) == true) { return false; } if (Priority.HasValue && Priority.Value == zdo.Type) { return false; } if (Items != null) { return !ItemValue.Match(pars, Items, zdo, ItemAmount); } if (ItemAmount != null) { return !ItemValue.Match(pars, zdo, ItemAmount); } if (ConnectionType.HasValue) { if ((int)ConnectionType.Value == 0) { ZDOConnection connection = zdo.GetConnection(); if (connection == null || connection.m_target == ZDOID.None) { return false; } } else { ZDOID connectionZDOID = zdo.GetConnectionZDOID(ConnectionType.Value); if (TargetConnectionId == null) { if (connectionZDOID != ZDOID.None) { return false; } } else { ZDOID? val = TargetConnectionId.Get(pars); if (val.HasValue) { ZDOID val2 = connectionZDOID; ZDOID? val3 = val; if (val3.HasValue && val2 == val3.GetValueOrDefault()) { return false; } } } } } return true; } 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) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) List? items = Items; if (items != null && items.Count > 0) { string value = ItemValue.LoadItems(pars, Items, GetContainerSize(), (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_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_001e: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown if (Items == null || Items.Count == 0) { return; } Vector2i containerSize = GetContainerSize(); Inventory val = ItemValue.CreateInventory(zdo, containerSize.x, containerSize.y); foreach (ItemValue item in GenerateItems(parameters, containerSize)) { item.AddTo(parameters, val); } ZPackage val2 = new ZPackage(); val.Save(val2); zdo.Set(ZDOVars.s_items, val2.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 static int Hash(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 void Write(Parameters pars, 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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) //IL_013b: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_0363: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_046d: Unknown result type (might be due to invalid IL or missing references) //IL_0423: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_057a: Unknown result type (might be due to invalid IL or missing references) //IL_057f: Unknown result type (might be due to invalid IL or missing references) //IL_0587: Unknown result type (might be due to invalid IL or missing references) //IL_058c: Unknown result type (might be due to invalid IL or missing references) //IL_05b8: Unknown result type (might be due to invalid IL or missing references) //IL_05bd: Unknown result type (might be due to invalid IL or missing references) //IL_05c1: Unknown result type (might be due to invalid IL or missing references) //IL_05c6: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = zdo.m_uid; RollItems(pars); Dictionary? floats = Floats; if (floats != null && floats.Count > 0) { ZDOHelper.Init(ZDOExtraData.s_floats, uid); foreach (KeyValuePair @float in Floats) { float? num = @float.Value.Get(pars); if (num.HasValue) { ZDOExtraData.s_floats[uid].SetValue(@float.Key, num.Value); } } } Dictionary? vecs = Vecs; if (vecs != null && vecs.Count > 0) { ZDOHelper.Init(ZDOExtraData.s_vec3, uid); foreach (KeyValuePair vec in Vecs) { Vector3? val = vec.Value.Get(pars); if (val.HasValue) { ZDOExtraData.s_vec3[uid].SetValue(vec.Key, val.Value); } } } Dictionary? quats = Quats; if (quats != null && quats.Count > 0) { ZDOHelper.Init(ZDOExtraData.s_quats, uid); foreach (KeyValuePair quat in Quats) { Quaternion? val2 = quat.Value.Get(pars); if (val2.HasValue) { ZDOExtraData.s_quats[uid].SetValue(quat.Key, val2.Value); } } } Dictionary? ints = Ints; if (ints != null && ints.Count > 0) { ZDOHelper.Init(ZDOExtraData.s_ints, uid); foreach (KeyValuePair @int in Ints) { int? num2 = @int.Value.Get(pars); if (num2.HasValue) { ZDOExtraData.s_ints[uid].SetValue(@int.Key, num2.Value); } } } Dictionary? hashes = Hashes; if (hashes != null && hashes.Count > 0) { ZDOHelper.Init(ZDOExtraData.s_ints, uid); foreach (KeyValuePair hash in Hashes) { int? num3 = hash.Value.Get(pars); if (num3.HasValue) { ZDOExtraData.s_ints[uid].SetValue(hash.Key, num3.Value); } } } Dictionary? bools = Bools; if (bools != null && bools.Count > 0) { ZDOHelper.Init(ZDOExtraData.s_ints, uid); foreach (KeyValuePair @bool in Bools) { int? num4 = @bool.Value.GetInt(pars); if (num4.HasValue) { ZDOExtraData.s_ints[uid].SetValue(@bool.Key, num4.Value); } } } Dictionary? longs = Longs; if (longs != null && longs.Count > 0) { ZDOHelper.Init(ZDOExtraData.s_longs, uid); foreach (KeyValuePair @long in Longs) { long? num5 = @long.Value.Get(pars); if (num5.HasValue) { ZDOExtraData.s_longs[uid].SetValue(@long.Key, num5.Value); } } } Dictionary? strings = Strings; if (strings != null && strings.Count > 0) { ZDOHelper.Init(ZDOExtraData.s_strings, uid); foreach (KeyValuePair @string in Strings) { string text = @string.Value.Get(pars); if (text != null) { ZDOExtraData.s_strings[uid].SetValue(@string.Key, text); } } } Dictionary? byteArrays = ByteArrays; if (byteArrays != null && byteArrays.Count > 0) { ZDOHelper.Init(ZDOExtraData.s_byteArrays, uid); foreach (KeyValuePair byteArray in ByteArrays) { ZDOExtraData.s_byteArrays[uid].SetValue(byteArray.Key, byteArray.Value); } } if (Persistent != null) { zdo.Persistent = Persistent.GetBool(pars) ?? zdo.Persistent; } if (Distant != null) { zdo.Distant = Distant.GetBool(pars) ?? zdo.Distant; } if (Priority.HasValue) { zdo.Type = Priority.Value; } HandleConnection(zdo, pars); HandleHashConnection(zdo); if (Position != null) { Vector3? val3 = Position.Get(pars); if (val3.HasValue) { zdo.m_position = val3.Value; zdo.SetSector(ZoneSystem.GetZone(val3.Value)); } } if (Rotation != null) { Quaternion? val4 = Rotation.Get(pars); if (val4.HasValue) { Quaternion value = val4.Value; zdo.m_rotation = ((Quaternion)(ref value)).eulerAngles; } } } private void HandleConnection(ZDO ownZdo, Parameters pars) { //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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_005a: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) if (OriginalId == null || !ConnectionType.HasValue) { return; } ZDOID uid = ownZdo.m_uid; if (TargetConnectionId != null) { ZDOID? val = TargetConnectionId.Get(pars); if (!val.HasValue) { return; } ZDO zDO = ZDOMan.instance.GetZDO(val.Value); if (zDO != null) { ownZdo.SetConnection(ConnectionType.Value, val.Value); if (ConnectionType == (ConnectionType?)1) { zDO.SetConnection((ConnectionType)1, uid); } } return; } ZDOID? originalId = OriginalId.Get(pars); if (!originalId.HasValue) { return; } KeyValuePair keyValuePair = ZDOExtraData.s_connections.FirstOrDefault((KeyValuePair kvp) => kvp.Value.m_target == originalId.Value); 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_001f: 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_0028: 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_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_0074: 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_00a1: 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_00b1: 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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0124: 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) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: 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_0219: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) if (ConnectionHash == 0 || !ConnectionType.HasValue || ConnectionType == (ConnectionType?)0) { return; } ZDOID uid = ownZdo.m_uid; ZDOExtraData.SetConnectionData(uid, ConnectionType.Value, ConnectionHash); ConnectionType? val = (ConnectionType?)((??)ConnectionType ^ 0x10); bool flag = (??)((??)ConnectionType & 0x10) == (??)0; ZDOID val2 = ((IEnumerable)ZDOExtraData.GetAllConnectionZDOIDs(val.Value)).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 & 3) > 0) { ZDO val3 = (ZDO)(flag ? ((object)ownZdo) : ((object)zDO)); ZDOID val4 = (flag ? val2 : uid); val3.SetConnection((ConnectionType)3, val4); } if (((??)ConnectionType & 2) > 0) { ZDO val5 = (ZDO)(flag ? ((object)ownZdo) : ((object)zDO)); ZDOID val6 = (flag ? val2 : uid); val5.SetConnection((ConnectionType)2, val6); } if (((??)ConnectionType & 1) > 0) { zDO.SetConnection((ConnectionType)1, uid); ownZdo.SetConnection((ConnectionType)1, val2); } } } } public class DataHelper { public static ZDO? Init(GameObject obj, Vector3 pos, Quaternion rot, Vector3? scale, DataEntry? data) { //IL_002d: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) if (data == null && !scale.HasValue) { return null; } ZNetView val = default(ZNetView); if (!obj.TryGetComponent(ref val)) { return null; } string prefabName = Utils.GetPrefabName(obj); int stableHashCode = StringExtensionMethods.GetStableHashCode(prefabName); ZNetView.m_initZDO = ZDOMan.instance.CreateNewZDO(pos, stableHashCode); ObjectParameters pars = new ObjectParameters(prefabName, "", ZNetView.m_initZDO); data?.Write(pars, ZNetView.m_initZDO); ZNetView.m_initZDO.m_rotation = ((Quaternion)(ref rot)).eulerAngles; ZNetView.m_initZDO.Type = (ObjectType)(((??)data?.Priority) ?? val.m_type); ZNetView.m_initZDO.Distant = data?.Distant?.GetBool(pars) ?? val.m_distant; ZNetView.m_initZDO.Persistent = data?.Persistent?.GetBool(pars) ?? val.m_persistent; ZNetView.m_initZDO.m_prefab = stableHashCode; if (val.m_syncInitialScale && scale.HasValue) { ZNetView.m_initZDO.Set(ZDOVars.s_scaleHash, scale.Value); } ZNetView.m_initZDO.DataRevision = 0u; ZNetView.m_initZDO.IncreaseDataRevision(); return ZNetView.m_initZDO; } public static void CleanUp() { ZNetView.m_initZDO = null; } public static DataEntry? Merge(DataEntry? first, DataEntry? second) { if (first == null) { return second; } if (second == null) { return first; } DataEntry dataEntry = new DataEntry(); dataEntry.Load(first); dataEntry.Load(second); return dataEntry; } 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, string fileName) { if (!(name == "")) { return DataLoading.Get(name, fileName); } return null; } 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 List ResolvePrefabs(string values) { HashSet hashSet = new HashSet(); ResolvePrefabsSub(hashSet, values); HashSet hashSet2 = hashSet; List list = new List(hashSet2.Count); list.AddRange(hashSet2); return list; } private static void ResolvePrefabsSub(HashSet prefabs, string value) { if (value == "all" || DataLoading.IsComponentGroup(value)) { prefabs.Add(value.ToLowerInvariant()); return; } if (ZNetScene.instance.m_namedPrefabs.ContainsKey(StringExtensionMethods.GetStableHashCode(value))) { prefabs.Add(value); return; } List valuesFromGroup = GetValuesFromGroup(value); if (valuesFromGroup != null) { foreach (string item in valuesFromGroup) { ResolvePrefabsSub(prefabs, item); } return; } Log.Warning("Failed to resolve prefab: " + value); } 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 Dictionary> DefaultPrefabComponents = 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 DataEntry? Get(string name, string fileName) { int stableHashCode = StringExtensionMethods.GetStableHashCode(name); if (!Data.ContainsKey(stableHashCode)) { try { Data[stableHashCode] = new DataEntry(name); } catch { if (name.Contains("=") || name.Length > 32) { Log.Warning(fileName + ": Can't load data value: " + name); } else { Log.Warning(fileName + ": Can't find data entry: " + name); } return null; } } return Data[stableHashCode]; } public static DataEntry? Get(int hash) { if (!Data.ContainsKey(hash)) { return null; } return Data[hash]; } public static void LoadEntries() { Dictionary data = Data; Data = new Dictionary(); ValueGroups.Clear(); List list = Yaml.Read(Directory.GetFiles(GamePath, "*.yaml", SearchOption.AllDirectories).Concat(Directory.GetFiles(ProfilePath, "*.yaml", SearchOption.AllDirectories)).Concat(Directory.GetFiles(Yaml.BaseDirectory, Pattern, SearchOption.AllDirectories)) .Select(Path.GetFullPath) .Distinct() .ToList()); 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)); } } public static bool IsComponentGroup(string group) { return DefaultValueGroups.ContainsKey(StringExtensionMethods.GetStableHashCode(group.ToLowerInvariant())); } public static List GetDefaultComponents(string prefabName) { if (DefaultPrefabComponents.TryGetValue(prefabName, out List value)) { return value; } return new List(); } private static void LoadDefaultValueGroups() { if (DefaultValueGroups.Count != 0) { return; } foreach (GameObject value in ZNetScene.instance.m_namedPrefabs.Values) { if (!Object.op_Implicit((Object)(object)value)) { continue; } string name = ((Object)value).name; if (!DefaultPrefabComponents.ContainsKey(name)) { DefaultPrefabComponents[name] = new List(); } value.GetComponentsInChildren(ZNetView.m_tempComponents); foreach (MonoBehaviour tempComponent in ZNetView.m_tempComponents) { string text = ((object)tempComponent).GetType().Name.ToLowerInvariant(); int stableHashCode = StringExtensionMethods.GetStableHashCode(text); if (!DefaultValueGroups.ContainsKey(stableHashCode)) { DefaultValueGroups[stableHashCode] = new List(); } DefaultValueGroups[stableHashCode].Add(((Object)value).name); DefaultPrefabComponents[name].Add(text); if (text == "humanoid") { DefaultPrefabComponents[name].Add("character"); } if (text == "wearntear") { DefaultPrefabComponents[name].Add("structure"); } } } DefaultValueGroups[CreatureHash] = DefaultValueGroups[HumanoidHash]; DefaultValueGroups[StructureHash] = DefaultValueGroups[WearNTearHash]; } 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); if (GamePath != ProfilePath) { Yaml.SetupWatcher(ProfilePath, "*", LoadEntries); } Yaml.SetupWatcher(Pattern, LoadEntries); } } 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 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) { 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 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_008a: 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) string[] array = SplitWithValues(values); if (HasParameters(values) || array.Length > 3) { List list = new List(); for (int i = 0; i < array.Length; i += 3) { string[] value = ((i + 3 < array.Length) ? array.Skip(i).Take(3).ToArray() : array.Skip(i).ToArray()); 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_008a: 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) string[] array = SplitWithValues(values); if (HasParameters(values) || array.Length > 3) { List list = new List(); for (int i = 0; i < array.Length; i += 3) { string[] value = ((i + 3 < array.Length) ? array.Skip(i).Take(3).ToArray() : array.Skip(i).ToArray()); 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); } else { SubstitueValues(list, text, list2, list3, 0); } } return list.ToArray(); } 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); } else { SubstitueValues(result, text, parameters, hashes, index + 1); } } } } public class AnyValue(string[] values) { protected readonly string[] Values = values; 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) { return (from v in values.Select(pars.Replace) where v != null && v != "? 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) { Inventory inv = CreateInventory(zdo); int num = data.Where((ItemValue item) => item.Match(pars, inv)).Count(); if (amount == null) { if (num == data.Count) { return inv.m_inventory.Count == 0; } return false; } return amount.Match(pars, num) == true; } public static bool Match(Parameters pars, ZDO zdo, IIntValue amount) { Inventory val = CreateInventory(zdo); return amount.Match(pars, val.m_inventory.Count) == true; } 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 text = zdo.GetString(ZDOVars.s_items, ""); if (text != "") { ZPackage val2 = new ZPackage(text); 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 num2 = 0; num2 < amount; num2++) { 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) ?? 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 num = Quality?.Get(pars) ?? 1; float? num2 = Durability?.Get(pars); if (!num2.HasValue) { ItemDrop val = default(ItemDrop); num2 = ((!((Object)(object)itemPrefab != (Object)null) || !itemPrefab.TryGetComponent(ref val)) ? new float?(100f) : new float?(val.m_itemData.GetMaxDurability(num))); } pkg.Write(RolledStack); pkg.Write(num2.Value); pkg.Write(RolledPosition); pkg.Write(Equipped?.GetBool(pars) == true); pkg.Write(num); 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) == true); } public void AddTo(Parameters pars, Inventory inv) { int stack = Stack?.Get(pars) ?? 1; stack = StackTo(pars, stack, inv); InsertTo(pars, stack, 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_02ba: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: 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_0293: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: 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) ItemDrop val = default(ItemDrop); while (stack > 0) { int valueOrDefault = Prefab.Get(pars).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(pars) ?? 1; val2.m_variant = (Variant?.Get(pars)).GetValueOrDefault(); val2.m_crafterID = (CrafterID?.Get(pars)).GetValueOrDefault(); val2.m_crafterName = CrafterName?.Get(pars) ?? ""; val2.m_worldLevel = (WorldLevel?.Get(pars)).GetValueOrDefault(); val2.m_durability = Durability?.Get(pars) ?? val2.GetMaxDurability(val2.m_quality); val2.m_equipped = Equipped?.GetBool(pars) == true; val2.m_pickedUp = PickedUp?.GetBool(pars) == true; val2.m_customData = CustomData.ToDictionary, string, string>((KeyValuePair x) => x.Key, (KeyValuePair x) => x.Value.Get(pars) ?? ""); 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) ?? 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 Parameters(string prefab, string arg, Vector3 pos) { protected string[]? args; private readonly double time = ZNet.instance.GetTimeSeconds(); public string Replace(string str) { 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] == '>') { if (num == 1) { string str2 = str.Substring(num2, i - num2 + 1); stringBuilder.Append(ResolveParameters(str2)); 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 key, out string? resolved) { resolved = GetParameter(key); if (resolved == null) { resolved = ResolveValue(key); } return resolved != key; } protected virtual string? GetParameter(string key) { return key switch { "" => prefab, "" => arg, "" => GetArg(0), "" => GetArg(1), "" => GetArg(2), "" => GetArg(3), "" => GetArg(4), "" => GetArg(5), "" => GetArg(6), "" => GetArg(7), "" => GetArg(8), "" => GetArg(9), "