Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of World Edit Commands v1.81.0
WorldEditCommands.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.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 Common; using Data; using HarmonyLib; using Microsoft.CodeAnalysis; using ServerDevcommands; using Service; using TMPro; using UnityEngine; using WorldEditCommands; [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("WorldEditCommands")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+8d743ea77c2c9960178bbc738f0b7328d5e21a4d")] [assembly: AssemblyProduct("WorldEditCommands")] [assembly: AssemblyTitle("WorldEditCommands")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] 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; } } } public static class Hash { public static int Damage = StringExtensionMethods.GetStableHashCode("RandomSkillFactor"); public static int Ammo = StringExtensionMethods.GetStableHashCode("ammo"); public static int AmmoType = StringExtensionMethods.GetStableHashCode("ammoType"); public static int PlantTime = StringExtensionMethods.GetStableHashCode("plantTime"); public static int Status = StringExtensionMethods.GetStableHashCode("override_status"); public static int Weather = StringExtensionMethods.GetStableHashCode("override_weather"); public static int DungeonWeather = StringExtensionMethods.GetStableHashCode("override_dungeon_weather"); public static int DungeonEnterText = StringExtensionMethods.GetStableHashCode("override_dungeon_enter_text"); public static int DungeonEnterHover = StringExtensionMethods.GetStableHashCode("override_dungeon_enter_hover"); public static int DungeonExitText = StringExtensionMethods.GetStableHashCode("override_dungeon_exit_text"); public static int DungeonExitHover = StringExtensionMethods.GetStableHashCode("override_dungeon_exit_hover"); public static int Water = StringExtensionMethods.GetStableHashCode("override_water"); public static int Event = StringExtensionMethods.GetStableHashCode("override_event"); public static int Effect = StringExtensionMethods.GetStableHashCode("override_effect"); public static int Respawn = StringExtensionMethods.GetStableHashCode("override_respawn"); public static int RespawnSpawnArea = StringExtensionMethods.GetStableHashCode("override_spawnarea_respawn"); public static int RespawnPickable = StringExtensionMethods.GetStableHashCode("override_pickable_respawn"); public static int SpawnHealth = StringExtensionMethods.GetStableHashCode("override_health"); public static int TriggerNoise = StringExtensionMethods.GetStableHashCode("override_trigger_noise"); public static int Spawn = StringExtensionMethods.GetStableHashCode("override_spawn"); public static int SpawnSpawnArea = StringExtensionMethods.GetStableHashCode("override_spawnarea_spawn"); public static int SpawnPickable = StringExtensionMethods.GetStableHashCode("override_pickable_spawn"); public static int Biome = StringExtensionMethods.GetStableHashCode("override_biome"); public static int Data = StringExtensionMethods.GetStableHashCode("override_data"); public static int OverrideItem = StringExtensionMethods.GetStableHashCode("override_item"); public static int OverrideItems = StringExtensionMethods.GetStableHashCode("override_items"); public static int Items = StringExtensionMethods.GetStableHashCode("items"); public static int SpawnEffect = StringExtensionMethods.GetStableHashCode("override_spawn_effect"); public static int DestroyEffect = StringExtensionMethods.GetStableHashCode("override_destroy_effect"); public static int UseEffect = StringExtensionMethods.GetStableHashCode("override_use_effect"); public static int StartEffect = StringExtensionMethods.GetStableHashCode("override_start_effect"); public static int SpawnItem = StringExtensionMethods.GetStableHashCode("override_spawn_item"); public static int Faction = StringExtensionMethods.GetStableHashCode("faction"); public static int Command = StringExtensionMethods.GetStableHashCode("override_command"); public static int Resistances = StringExtensionMethods.GetStableHashCode("override_resistances"); public static int Attacks = StringExtensionMethods.GetStableHashCode("override_attacks"); public static int SpawnOffset = StringExtensionMethods.GetStableHashCode("override_spawn_offset"); public static int Component = StringExtensionMethods.GetStableHashCode("override_component"); public static int MinAmount = StringExtensionMethods.GetStableHashCode("override_minimum_amount"); public static int MaxAmount = StringExtensionMethods.GetStableHashCode("override_maximum_amount"); public static int MinLevel = StringExtensionMethods.GetStableHashCode("override_minimum_level"); public static int MaxLevel = StringExtensionMethods.GetStableHashCode("override_maximum_level"); public static int Conversion = StringExtensionMethods.GetStableHashCode("override_conversion"); public static int MaxFuel = StringExtensionMethods.GetStableHashCode("override_maximum_fuel"); public static int FuelUsage = StringExtensionMethods.GetStableHashCode("override_fuel_usage"); public static int Speed = StringExtensionMethods.GetStableHashCode("override_speed"); public static int MaxCover = StringExtensionMethods.GetStableHashCode("override_maximum_cover"); public static int InputEffect = StringExtensionMethods.GetStableHashCode("override_input_effect"); public static int OpenEffect = StringExtensionMethods.GetStableHashCode("override_open_effect"); public static int CloseEffect = StringExtensionMethods.GetStableHashCode("override_close_effect"); public static int LockedEffect = StringExtensionMethods.GetStableHashCode("override_locked_effect"); public static int FuelEffect = StringExtensionMethods.GetStableHashCode("override_fuel_effect"); public static int OutputEffect = StringExtensionMethods.GetStableHashCode("override_output_effect"); public static int MaxNear = StringExtensionMethods.GetStableHashCode("override_max_near"); public static int MaxTotal = StringExtensionMethods.GetStableHashCode("override_max_total"); public static int LevelChance = StringExtensionMethods.GetStableHashCode("override_level_chance"); public static int TriggerDistance = StringExtensionMethods.GetStableHashCode("override_trigger_distance"); public static int OverrideText = StringExtensionMethods.GetStableHashCode("override_text"); public static int Compendium = StringExtensionMethods.GetStableHashCode("override_compendium"); public static int Topic = StringExtensionMethods.GetStableHashCode("override_topic"); public static int Discover = StringExtensionMethods.GetStableHashCode("override_discover"); public static int Delay = StringExtensionMethods.GetStableHashCode("override_delay"); public static int ItemOffset = StringExtensionMethods.GetStableHashCode("override_item_offset"); public static int CoverOffset = StringExtensionMethods.GetStableHashCode("override_cover_offset"); public static int SpawnMaxY = StringExtensionMethods.GetStableHashCode("override_spawn_max_y"); public static int Destroy = StringExtensionMethods.GetStableHashCode("override_destroy"); public static int ItemStandPrefix = StringExtensionMethods.GetStableHashCode("override_item_stand_prefix"); public static int ItemStandRange = StringExtensionMethods.GetStableHashCode("override_item_stand_range"); public static int GlobalKey = StringExtensionMethods.GetStableHashCode("override_globalkey"); public static int SpawnRadius = StringExtensionMethods.GetStableHashCode("override_spawn_radius"); public static int NearRadius = StringExtensionMethods.GetStableHashCode("override_near_radius"); public static int FarRadius = StringExtensionMethods.GetStableHashCode("override_far_radius"); public static int OverrideName = StringExtensionMethods.GetStableHashCode("override_name"); public static int TextBiome = StringExtensionMethods.GetStableHashCode("override_text_biome"); public static int TextSpace = StringExtensionMethods.GetStableHashCode("override_text_space"); public static int TextSleep = StringExtensionMethods.GetStableHashCode("override_text_sleep"); public static int TextHappy = StringExtensionMethods.GetStableHashCode("override_text_happy"); public static int TextCheck = StringExtensionMethods.GetStableHashCode("override_text_check"); public static int TextExtract = StringExtensionMethods.GetStableHashCode("override_text_extract"); public static int SpawnCondition = StringExtensionMethods.GetStableHashCode("override_spawn_condition"); public static int Amount = StringExtensionMethods.GetStableHashCode("override_amount"); public static int Wear = StringExtensionMethods.GetStableHashCode("override_wear"); public static int Fall = StringExtensionMethods.GetStableHashCode("override_fall"); public static int Growth = StringExtensionMethods.GetStableHashCode("override_growth"); public static int NoInteract = StringExtensionMethods.GetStableHashCode("override_interact"); public static int NoRender = StringExtensionMethods.GetStableHashCode("override_render"); public static int NoCollision = StringExtensionMethods.GetStableHashCode("override_collision"); public static int NoRestrict = StringExtensionMethods.GetStableHashCode("override_restrict"); public static int Boss = StringExtensionMethods.GetStableHashCode("override_boss"); public static int Smoke = StringExtensionMethods.GetStableHashCode("override_smoke"); public static int CLLC_BossEffect = StringExtensionMethods.GetStableHashCode("CL&LC effect"); public static int CLLC_Infusion = StringExtensionMethods.GetStableHashCode("CL&LC infusion"); public static int CLLC_Effect = StringExtensionMethods.GetStableHashCode("CL&LC effect"); public static int Unlock = StringExtensionMethods.GetStableHashCode("override_unlock"); public static int DoorConsume = StringExtensionMethods.GetStableHashCode("override_door_consume"); public static int DoorNoClose = StringExtensionMethods.GetStableHashCode("override_door_no_close"); public static int DoorKey = StringExtensionMethods.GetStableHashCode("override_door_key"); public static int Health = StringExtensionMethods.GetStableHashCode("health"); public static int Level = StringExtensionMethods.GetStableHashCode("level"); public static int Text = StringExtensionMethods.GetStableHashCode("text"); public static int Pose = StringExtensionMethods.GetStableHashCode("pose"); public static int Item = StringExtensionMethods.GetStableHashCode("item"); public static int HasFields = StringExtensionMethods.GetStableHashCode("HasFields"); public static int Variant = StringExtensionMethods.GetStableHashCode("variant"); public static int Tamed = StringExtensionMethods.GetStableHashCode("tamed"); public static int HuntPlayer = StringExtensionMethods.GetStableHashCode("huntplayer"); public static int Quality = StringExtensionMethods.GetStableHashCode("quality"); public static int Creator = StringExtensionMethods.GetStableHashCode("creator"); public static int Stack = StringExtensionMethods.GetStableHashCode("stack"); public static int AliveTime = StringExtensionMethods.GetStableHashCode("alive_time"); public static int CrafterID = StringExtensionMethods.GetStableHashCode("crafterID"); public static int CrafterName = StringExtensionMethods.GetStableHashCode("crafterName"); public static int AddedDefaultItems = StringExtensionMethods.GetStableHashCode("addedDefaultItems"); public static int OverrideFuel = StringExtensionMethods.GetStableHashCode("override_fuel"); public static int Fuel = StringExtensionMethods.GetStableHashCode("fuel"); public static int Durability = StringExtensionMethods.GetStableHashCode("durability"); public static int Sleeping = StringExtensionMethods.GetStableHashCode("sleeping"); public static int SpawnTime = StringExtensionMethods.GetStableHashCode("spawntime"); public static int TamedName = StringExtensionMethods.GetStableHashCode("TamedName"); public static int Tag = StringExtensionMethods.GetStableHashCode("tag"); public static int Seed = StringExtensionMethods.GetStableHashCode("seed"); public static int Location = StringExtensionMethods.GetStableHashCode("location"); public static int SpawnPoint = StringExtensionMethods.GetStableHashCode("spawnpoint"); public static int Scale = StringExtensionMethods.GetStableHashCode("scale"); public static int Player = StringExtensionMethods.GetStableHashCode("Player"); public static int BuildingSkillLevel = StringExtensionMethods.GetStableHashCode("BuildingSkill Level"); public static int Interact = StringExtensionMethods.GetStableHashCode("override_interact"); public static int Restrict = StringExtensionMethods.GetStableHashCode("override_restrict"); public static int Render = StringExtensionMethods.GetStableHashCode("override_render"); public static int Collision = StringExtensionMethods.GetStableHashCode("override_collision"); public static int Portal = StringExtensionMethods.GetStableHashCode("portal_wood"); } namespace Common { public static class FloatCompare { 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 class Formatting { 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 class ValueRange<T> { public T Min; public T Max; public bool Uniform = true; public ValueRange(T value) { Min = value; Max = value; } public ValueRange(T min, T max) { Min = min; Max = max; } } public static class Parse { private static Dictionary<string, Color> Paints = new Dictionary<string, Color> { { "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<string> ToList(string str, bool removeEmpty = true) { string[] array = Split(str, removeEmpty); List<string> list = new List<string>(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 TryDistanceAngle(string arg, out Vector3 vector) { return TryDistanceAngle(Split(arg), out vector); } public static bool TryDistanceAngle(string[] values, out Vector3 vector) { //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) vector = Vector3.zero; if (values.Length < 2 || values.Length > 3) { return false; } if (values[1] == null || !HasAngleSuffix(values[1].Trim())) { return false; } if (!TryDistanceAngle(values[0], values[1], out vector)) { return false; } if (values.Length > 2 && !TryFloat(values[2], out vector.y)) { return false; } return true; } private static bool TryDistanceAngle(string distanceValue, string angleValue, out Vector3 vector) { //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_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) vector = Vector3.zero; if (!TryFloat(distanceValue, out var result)) { return false; } if (!TryAngleRadians(angleValue, out var radians)) { return false; } vector = new Vector3(Mathf.Cos(radians) * result, 0f, Mathf.Sin(radians) * result); return true; } private static bool HasAngleSuffix(string arg) { if (!arg.EndsWith("deg", StringComparison.OrdinalIgnoreCase)) { return arg.EndsWith("rad", StringComparison.OrdinalIgnoreCase); } return true; } public static bool TryAngleRadians(string arg, out float radians) { radians = 0f; if (arg == null) { return false; } string text = arg.Trim(); if (text.EndsWith("deg", StringComparison.OrdinalIgnoreCase)) { if (!TryFloat(text.Substring(0, text.Length - 3).Trim(), out var result)) { return false; } radians = result * ((float)Math.PI / 180f); return true; } if (text.EndsWith("rad", StringComparison.OrdinalIgnoreCase)) { if (!TryFloat(text.Substring(0, text.Length - 3).Trim(), out radians)) { return false; } return true; } return TryFloat(text, out radians); } public static bool TryAngleDegrees(string arg, out float degrees) { degrees = 0f; if (arg == null) { return false; } string text = arg.Trim(); if (text.EndsWith("deg", StringComparison.OrdinalIgnoreCase)) { return TryFloat(text.Substring(0, text.Length - 3).Trim(), out degrees); } if (text.EndsWith("rad", StringComparison.OrdinalIgnoreCase)) { if (!TryFloat(text.Substring(0, text.Length - 3).Trim(), out var result)) { return false; } degrees = result * 57.29578f; return true; } return TryFloat(text, out degrees); } 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<string> list; if (!removeEmpty) { list = new List<string>(); list.AddRange(from s in arg.Split(new char[1] { split }) select s.Trim()); return list.ToArray(); } list = new List<string>(); 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<string, string> Kvp(string str, char separator = ',') { int num = str.IndexOf(separator); if (num < 0) { return new KeyValuePair<string, string>(str, ""); } return new KeyValuePair<string, string>(str.Substring(0, num), str.Substring(num + 1).Trim()); } public static bool TryKvp(string str, out KeyValuePair<string, string> kvp, char separator = ',') { kvp = Kvp(str, separator); return kvp.Value != ""; } public static string[] SplitWithEmpty(string arg, char split = ',') { List<string> list = new List<string>(); 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<string> list = new List<string>(); string[] array = arg.Split(new char[1] { separator }); for (int i = 0; i < array.Length; i++) { string text = array[i].TrimStart(Array.Empty<char>()); if (text.StartsWith("\"")) { array[i] = text.Substring(1); int j; for (j = i; j < array.Length; j++) { text = array[j].TrimEnd(Array.Empty<char>()); 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_001d: 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) string[] array = Split(arg); if (!TryDistanceAngle(array, out var vector)) { return VectorXZY(array, 0, defaultValue); } return vector; } 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 ValueRange<string> StringRange(string arg) { string[] array = Split(arg, removeEmpty: true, ';'); if (array.Length > 1) { return new ValueRange<string>(array[0], array[1]); } return new ValueRange<string>(array[0], array[0]); } public static ValueRange<int> IntRange(string arg) { ValueRange<string> valueRange = StringRange(arg); return new ValueRange<int>(Int(valueRange.Min), Int(valueRange.Max)); } public static ValueRange<float> FloatRange(string arg) { ValueRange<string> valueRange = StringRange(arg); return new ValueRange<float>(Float(valueRange.Min), Float(valueRange.Max)); } public static ValueRange<long> LongRange(string arg) { ValueRange<string> valueRange = StringRange(arg); return new ValueRange<long>(Long(valueRange.Min, 0L), Long(valueRange.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_000a: 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) if (TryDistanceAngle(args, out var vector)) { return vector; } 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_00d2: 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_0071: Unknown result type (might be due to invalid IL or missing references) if (values.Length >= 4) { float? num = FloatNull(values, 0); float? num2 = FloatNull(values, 1); float? num3 = FloatNull(values, 2); float? num4 = FloatNull(values, 3); if (!num.HasValue && !num2.HasValue && !num3.HasValue && !num4.HasValue) { return null; } return new Quaternion(num.GetValueOrDefault(), num2.GetValueOrDefault(), num3.GetValueOrDefault(), num4.GetValueOrDefault()); } float? num5 = FloatNull(values, 0); float? num6 = FloatNull(values, 1); float? num7 = FloatNull(values, 2); if (!num5.HasValue && !num6.HasValue && !num7.HasValue) { return null; } return Quaternion.Euler(new Vector3(num6.GetValueOrDefault(), num5.GetValueOrDefault(), num7.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 ZDOID ZdoId(string arg) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrWhiteSpace(arg)) { return ZDOID.None; } string text = arg.Trim().Trim('(', ')', '[', ']', '{', '}'); string[] array = (from value in text.Split(new char[2] { ':', ',' }, StringSplitOptions.RemoveEmptyEntries) select value.Trim()).ToArray(); if (array.Length < 2) { array = text.Split((char[]?)null, StringSplitOptions.RemoveEmptyEntries); } if (array.Length < 2 || !long.TryParse(array[0], out var result) || !uint.TryParse(array[1], out var result2)) { return ZDOID.None; } return new ZDOID(result, result2); } 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) 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<string, string> keyValuePair = Kvp(array[i], '='); string key = keyValuePair.Key; string value = keyValuePair.Value; if (key == "damage") { val.m_damage.m_damage = Float(value); } if (key == "blunt") { val.m_damage.m_blunt = Float(value); } if (key == "slash") { val.m_damage.m_slash = Float(value); } if (key == "pierce") { val.m_damage.m_pierce = Float(value); } if (key == "chop") { val.m_damage.m_chop = Float(value); } if (key == "pickaxe") { val.m_damage.m_pickaxe = Float(value); } if (key == "fire") { val.m_damage.m_fire = Float(value); } if (key == "frost") { val.m_damage.m_frost = Float(value); } if (key == "lightning") { val.m_damage.m_lightning = Float(value); } if (key == "poison") { val.m_damage.m_poison = Float(value); } if (key == "spirit") { val.m_damage.m_spirit = Float(value); } if (key == "tier") { val.m_toolTier = (short)Int(value); } if (key == "force") { val.m_pushForce = Float(value); } if (key == "backstab") { val.m_backstabBonus = Float(value); } if (key == "stagger") { val.m_staggerMultiplier = Float(value); } if (key == "dodge") { val.m_dodgeable = Boolean(value); } if (key == "block") { val.m_blockable = Boolean(value); } if (key == "dir") { val.m_dir = VectorXZY(value); } if (key == "ranged") { val.m_ranged = Boolean(value); } if (key == "pvp") { val.m_ignorePVP = Boolean(value); } if (key == "pos") { val.m_point = VectorXZY(value); } if (key == "status") { val.m_statusEffectHash = StringExtensionMethods.GetStableHashCode(value); } if (key == "attacker") { val.m_attacker = ZdoId(value); } if (key == "skill") { val.m_skillLevel = Float(value); } if (key == "level") { val.m_itemLevel = (short)Int(value); } if (key == "world") { val.m_itemWorldLevel = (byte)Int(value); } if (key == "type") { val.m_hitType = (HitType)(Enum.TryParse<HitType>(value, ignoreCase: true, out HitType result) ? ((int)result) : 0); } if (key == "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<MessageType>(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<AggravatedReason>(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<TrapState>(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<TextType>(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<PaintType>(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 static class Wildcard { public static bool IsPattern(string value) { return value.IndexOf('*') >= 0; } public static bool Match(string value, string pattern, bool ignoreCase = false) { StringComparison comparisonType = (ignoreCase ? StringComparison.OrdinalIgnoreCase : StringComparison.Ordinal); if (string.Equals(value, pattern, comparisonType)) { return true; } if (pattern == "") { return false; } if (pattern == "*") { return true; } bool flag = pattern[0] == '*'; bool flag2 = pattern[pattern.Length - 1] == '*'; if (flag && flag2) { return value.IndexOf(pattern.Substring(1, pattern.Length - 2), comparisonType) >= 0; } if (flag) { return value.EndsWith(pattern.Substring(1), comparisonType); } if (flag2) { return value.StartsWith(pattern.Substring(0, pattern.Length - 1), comparisonType); } int num = pattern.IndexOf('*'); if (num < 0) { return false; } if (value.Length >= pattern.Length - 1 && value.StartsWith(pattern.Substring(0, num), comparisonType)) { return value.EndsWith(pattern.Substring(num + 1), comparisonType); } return false; } } } namespace Data { public class Calculator { private sealed class DoubleParser(string expression) { private readonly string expression = expression; private int index; public double Parse() { double result = ParseExpression(); SkipWhiteSpace(); if (index != expression.Length) { throw new InvalidOperationException("Failed to parse expression: " + expression); } return result; } private double ParseExpression() { double num = ParseTerm(); while (true) { SkipWhiteSpace(); if (TryRead('+')) { num += ParseTerm(); continue; } if (!TryRead('-')) { break; } num -= ParseTerm(); } return num; } private double ParseTerm() { double num = ParseUnary(); while (true) { SkipWhiteSpace(); if (TryRead('*')) { num *= ParseUnary(); continue; } if (!TryRead('/')) { break; } num /= ParseUnary(); } return num; } private double ParseUnary() { SkipWhiteSpace(); if (TryRead('+')) { return ParseUnary(); } if (TryRead('-')) { return 0.0 - ParseUnary(); } return ParsePower(); } private double ParsePower() { double num = ParsePrimary(); SkipWhiteSpace(); if (TryRead('^')) { num = Math.Pow(num, ParseUnary()); } return num; } private double ParsePrimary() { SkipWhiteSpace(); if (TryRead('(')) { double result = ParseExpression(); SkipWhiteSpace(); if (!TryRead(')')) { throw new InvalidOperationException("Failed to parse expression: " + expression); } return result; } return ParseNumber(); } private double ParseNumber() { SkipWhiteSpace(); int num = index; bool flag = false; while (index < expression.Length && char.IsDigit(expression[index])) { flag = true; index++; } if (index < expression.Length && expression[index] == '.') { index++; while (index < expression.Length && char.IsDigit(expression[index])) { flag = true; index++; } } if (index < expression.Length && (expression[index] == 'e' || expression[index] == 'E')) { int num2 = index; index++; if (index < expression.Length && (expression[index] == '+' || expression[index] == '-')) { index++; } int num3 = index; while (index < expression.Length && char.IsDigit(expression[index])) { index++; } if (num3 == index) { index = num2; } } if (!flag) { throw new InvalidOperationException("Failed to parse expression: " + expression); } return double.Parse(expression.Substring(num, index - num), NumberFormatInfo.InvariantInfo); } private bool TryRead(char c) { if (index >= expression.Length || expression[index] != c) { return false; } index++; return true; } private void SkipWhiteSpace() { while (index < expression.Length && char.IsWhiteSpace(expression[index])) { index++; } } } private sealed class LongParser(string expression) { private readonly string expression = expression; private int index; public long Parse() { long result = ParseExpression(); SkipWhiteSpace(); if (index != expression.Length) { throw new InvalidOperationException("Failed to parse expression: " + expression); } return result; } private long ParseExpression() { long num = ParseTerm(); while (true) { SkipWhiteSpace(); if (TryRead('+')) { num += ParseTerm(); continue; } if (!TryRead('-')) { break; } num -= ParseTerm(); } return num; } private long ParseTerm() { long num = ParseUnary(); while (true) { SkipWhiteSpace(); if (TryRead('*')) { num *= ParseUnary(); continue; } if (!TryRead('/')) { break; } num /= ParseUnary(); } return num; } private long ParseUnary() { SkipWhiteSpace(); if (TryRead('+')) { return ParseUnary(); } if (TryRead('-')) { return -ParseUnary(); } return ParsePower(); } private long ParsePower() { long num = ParsePrimary(); SkipWhiteSpace(); if (TryRead('^')) { long num2 = ParseUnary(); if (num2 < 0) { throw new InvalidOperationException("Failed to parse expression: " + expression); } num = Pow(num, num2); } return num; } private long ParsePrimary() { SkipWhiteSpace(); if (TryRead('(')) { long result = ParseExpression(); SkipWhiteSpace(); if (!TryRead(')')) { throw new InvalidOperationException("Failed to parse expression: " + expression); } return result; } return ParseNumber(); } private long ParseNumber() { SkipWhiteSpace(); int num = index; while (index < expression.Length && char.IsDigit(expression[index])) { index++; } if (num == index) { throw new InvalidOperationException("Failed to parse expression: " + expression); } return long.Parse(expression.Substring(num, index - num), NumberFormatInfo.InvariantInfo); } private static long Pow(long value, long exponent) { long num = 1L; checked { while (exponent > 0) { if ((exponent & 1) == 1) { num *= value; } exponent >>= 1; if (exponent > 0) { value *= value; } } return num; } } private bool TryRead(char c) { if (index >= expression.Length || expression[index] != c) { return false; } index++; return true; } private void SkipWhiteSpace() { while (index < expression.Length && char.IsWhiteSpace(expression[index])) { index++; } } } public static Vector3 EvaluateVector3(string expression) { //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_0014: 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) string[] array = Parse.Split(expression); if (Parse.TryDistanceAngle(array, out var vector)) { return vector; } Vector3 zero = Vector3.zero; 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 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 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) { return new DoubleParser(expression.Replace("**", "^")).Parse(); } public static long? EvaluateLong(string expression) { try { return EvalLong(expression); } catch { return null; } } private static long EvalLong(string expression) { return new LongParser(expression.Replace("**", "^")).Parse(); } } public class DataEntry { private static readonly int HasFieldsHash = ZdoHelper.Hash("HasFields"); public bool CanBeInjected = true; public Dictionary<int, IStringValue>? Strings; public Dictionary<int, IFloatValue>? Floats; public Dictionary<int, IIntValue>? Ints; public Dictionary<int, IIntValue>? Components; public Dictionary<int, IBoolValue>? Bools; public Dictionary<int, IHashValue>? Hashes; public Dictionary<int, ILongValue>? Longs; public Dictionary<int, IVector3Value>? Vecs; public Dictionary<int, IQuaternionValue>? Quats; public Dictionary<int, IBytesValue>? ByteArrays; public List<ItemValue>? Items; public ItemValue? Item; 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<string> SupportedTypes = new HashSet<string> { "float", "int", "bool", "hash", "long", "string", "vec", "vec3", "quat", "bytes" }; public DataEntry() { } public DataEntry(string[] typeKeyValues) { Load(typeKeyValues); } public DataEntry(DataYaml data) { Load(data); } public DataEntry(ZDO zdo) { Load(zdo); } public DataEntry(ZPackage pkg) { Load(pkg); } public void Load(DataEntry data) { if (data.Floats != null) { if (Floats == null) { Floats = new Dictionary<int, IFloatValue>(); } foreach (KeyValuePair<int, IFloatValue> @float in data.Floats) { Floats[@float.Key] = @float.Value; } } if (data.Vecs != null) { if (Vecs == null) { Vecs = new Dictionary<int, IVector3Value>(); } foreach (KeyValuePair<int, IVector3Value> vec in data.Vecs) { Vecs[vec.Key] = vec.Value; } } if (data.Quats != null) { if (Quats == null) { Quats = new Dictionary<int, IQuaternionValue>(); } foreach (KeyValuePair<int, IQuaternionValue> quat in data.Quats) { Quats[quat.Key] = quat.Value; } } if (data.Ints != null) { if (Ints == null) { Ints = new Dictionary<int, IIntValue>(); } foreach (KeyValuePair<int, IIntValue> @int in data.Ints) { Ints[@int.Key] = @int.Value; } } if (data.Strings != null) { if (Strings == null) { Strings = new Dictionary<int, IStringValue>(); } foreach (KeyValuePair<int, IStringValue> @string in data.Strings) { Strings[@string.Key] = @string.Value; } } if (data.ByteArrays != null) { if (ByteArrays == null) { ByteArrays = new Dictionary<int, IBytesValue>(); } foreach (KeyValuePair<int, IBytesValue> byteArray in data.ByteArrays) { ByteArrays[byteArray.Key] = byteArray.Value; } } if (data.Longs != null) { if (Longs == null) { Longs = new Dictionary<int, ILongValue>(); } foreach (KeyValuePair<int, ILongValue> @long in data.Longs) { Longs[@long.Key] = @long.Value; } } if (data.Bools != null) { if (Bools == null) { Bools = new Dictionary<int, IBoolValue>(); } foreach (KeyValuePair<int, IBoolValue> @bool in data.Bools) { Bools[@bool.Key] = @bool.Value; } } if (data.Hashes != null) { if (Hashes == null) { Hashes = new Dictionary<int, IHashValue>(); } foreach (KeyValuePair<int, IHashValue> hash in data.Hashes) { Hashes[hash.Key] = hash.Value; } } if (data.Components != null) { if (Components == null) { Components = new Dictionary<int, IIntValue>(); } foreach (KeyValuePair<int, IIntValue> component in data.Components) { Components[component.Key] = component.Value; } } if (data.Items != null) { if (Items == null) { Items = new List<ItemValue>(); } foreach (ItemValue item in data.Items) { Items.Add(item); } } if (data.Item != null) { Item = data.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; } CanBeInjected = data.CanBeInjected; } public DataEntry Reset(DataYaml data) { CanBeInjected = true; Floats = null; Vecs = null; Quats = null; Ints = null; Strings = null; ByteArrays = null; Longs = null; Bools = null; Hashes = null; Items = null; Item = 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; } private bool CheckCanBeInjected() { if ((Ints == null || (!Ints.ContainsKey(HasFieldsHash) && !Ints.ContainsKey(ZDOVars.s_level))) && Components == null && Position == null) { return Rotation == null; } return false; } public byte[]? CreateItemData(Functions f, ZDO? zdo) { if (zdo != null) { return Item?.Create(f, zdo); } return null; } public byte[]? CreateInventory(Functions f, 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) if (Items == null || Items.Count == 0) { return null; } Vector2i size = (Vector2i)(((??)ContainerSize) ?? ZdoHelper.GetInventorySize(this, f, zdo)); return ItemValue.LoadItemBytes(f, Items, size, (ItemAmount?.Get(f)).GetValueOrDefault()); } 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_01db: 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_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: 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_02da: 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_02ee: 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) ZDOID uid = zdo.m_uid; Floats = (ZDOExtraData.s_floats.TryGetValue(uid, out var value) ? ((IEnumerable<KeyValuePair<int, float>>)value).ToDictionary((KeyValuePair<int, float> kvp) => kvp.Key, (KeyValuePair<int, float> kvp) => DataValue.Constant(kvp.Value)) : null); Ints = (ZDOExtraData.s_ints.TryGetValue(uid, out var value2) ? ((IEnumerable<KeyValuePair<int, int>>)value2).ToDictionary((KeyValuePair<int, int> kvp) => kvp.Key, (KeyValuePair<int, int> kvp) => DataValue.Constant(kvp.Value)) : null); Longs = (ZDOExtraData.s_longs.TryGetValue(uid, out var value3) ? ((IEnumerable<KeyValuePair<int, long>>)value3).ToDictionary((KeyValuePair<int, long> kvp) => kvp.Key, (KeyValuePair<int, long> kvp) => DataValue.Constant(kvp.Value)) : null); Strings = (ZDOExtraData.s_strings.TryGetValue(uid, out var value4) ? ((IEnumerable<KeyValuePair<int, string>>)value4).ToDictionary((KeyValuePair<int, string> kvp) => kvp.Key, (KeyValuePair<int, string> kvp) => DataValue.Constant(kvp.Value)) : null); Vecs = (ZDOExtraData.s_vec3.TryGetValue(uid, out var value5) ? ((IEnumerable<KeyValuePair<int, Vector3>>)value5).ToDictionary((KeyValuePair<int, Vector3> kvp) => kvp.Key, (KeyValuePair<int, Vector3> kvp) => DataValue.Constant(kvp.Value)) : null); Quats = (ZDOExtraData.s_quats.TryGetValue(uid, out var value6) ? ((IEnumerable<KeyValuePair<int, Quaternion>>)value6).ToDictionary((KeyValuePair<int, Quaternion> kvp) => kvp.Key, (KeyValuePair<int, Quaternion> kvp) => DataValue.Constant(kvp.Value)) : null); ByteArrays = (ZDOExtraData.s_byteArrays.TryGetValue(uid, out var value7) ? ((IEnumerable<KeyValuePair<int, byte[]>>)value7).ToDictionary((KeyValuePair<int, byte[]> kvp) => kvp.Key, (KeyValuePair<int, byte[]> kvp) => DataValue.Constant(kvp.Value)) : null); if (ZDOExtraData.s_connectionsHashData.TryGetValue(uid, out var value8)) { ConnectionType = value8.m_type; ConnectionHash = value8.m_hash; } OriginalId = new ConstantZdoIdValue(uid); if (ZDOExtraData.s_connections.TryGetValue(uid, out var value9) && value9.m_target != ZDOID.None) { TargetConnectionId = new ConstantZdoIdValue(value9.m_target); ConnectionType = value9.m_type; } Persistent = null; Distant = null; Priority = null; CanBeInjected = CheckCanBeInjected(); } public void Load(DataYaml data) { //IL_0ac3: Unknown result type (might be due to invalid IL or missing references) //IL_0c17: Unknown result type (might be due to invalid IL or missing references) //IL_0c8e: Unknown result type (might be due to invalid IL or missing references) //IL_0c5c: Unknown result type (might be due to invalid IL or missing references) HashSet<string> hashSet = new HashSet<string>(); if (data.floats != null) { if (Floats == null) { Floats = new Dictionary<int, IFloatValue>(); } string[] floats = data.floats; foreach (string text in floats) { KeyValuePair<string, string> 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<int, IIntValue>(); } string[] floats = data.ints; foreach (string text2 in floats) { KeyValuePair<string, string> 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<int, IBoolValue>(); } string[] floats = data.bools; foreach (string text3 in floats) { KeyValuePair<string, string> 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<int, IHashValue>(); } string[] floats = data.hashes; foreach (string text4 in floats) { KeyValuePair<string, string> 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<int, ILongValue>(); } string[] floats = data.longs; foreach (string text5 in floats) { KeyValuePair<string, string> 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<int, IStringValue>(); } string[] floats = data.strings; foreach (string text6 in floats) { KeyValuePair<string, string> 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 num = ZdoHelper.Hash(keyValuePair6.Key); if (num == ZDOVars.s_items) { if (ByteArrays == null) { ByteArrays = new Dictionary<int, IBytesValue>(); } if (ByteArrays.ContainsKey(num)) { Log.Warning("Data " + data.name + ": Duplicate string key " + keyValuePair6.Key + "."); } ByteArrays[num] = DataValue.Bytes(keyValuePair6.Value); } else { if (Strings.ContainsKey(num)) { Log.Warning("Data " + data.name + ": Duplicate string key " + keyValuePair6.Key + "."); } Strings[num] = DataValue.String(keyValuePair6.Value); } } } if (data.vecs != null) { if (Vecs == null) { Vecs = new Dictionary<int, IVector3Value>(); } string[] floats = data.vecs; foreach (string text7 in floats) { KeyValuePair<string, string> 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 key6 = ZdoHelper.Hash(keyValuePair7.Key); if (Vecs.ContainsKey(key6)) { Log.Warning("Data " + data.name + ": Duplicate vector key " + keyValuePair7.Key + "."); } Vecs[key6] = DataValue.Vector3(keyValuePair7.Value); } } if (data.quats != null) { if (Quats == null) { Quats = new Dictionary<int, IQuaternionValue>(); } string[] floats = data.quats; foreach (string text8 in floats) { KeyValuePair<string, string> 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 key7 = ZdoHelper.Hash(keyValuePair8.Key); if (Quats.ContainsKey(key7)) { Log.Warning("Data " + data.name + ": Duplicate quaternion key " + keyValuePair8.Key + "."); } Quats[key7] = DataValue.Quaternion(keyValuePair8.Value); } } if (data.bytes != null) { if (ByteArrays == null) { ByteArrays = new Dictionary<int, IBytesValue>(); } string[] floats = data.bytes; foreach (string text9 in floats) { KeyValuePair<string, string> 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 key8 = ZdoHelper.Hash(keyValuePair9.Key); if (ByteArrays.ContainsKey(key8)) { Log.Warning("Data " + data.name + ": Duplicate byte array key " + keyValuePair9.Key + "."); } ByteArrays[key8] = DataValue.Bytes(keyValuePair9.Value); } } if (data.items != null) { List<ItemValue> list = new List<ItemValue>(); list.AddRange(data.items.Select((ItemYaml item) => new ItemValue(item))); Items = list; } if (data.item != null) { Item = new ItemValue(data.item); } if (!string.IsNullOrWhiteSpace(data.containerSize)) { ContainerSize = Parse.Vector2Int(data.containerSize); } if (!string.IsNullOrWhiteSpace(data.itemAmount)) { ItemAmount = DataValue.Int(data.itemAmount); } CanBeInjected = hashSet.Count == 0; if (hashSet.Count > 0) { if (Components == null) { Components = new Dictionary<int, IIntValue>(); } Components[ZdoHelper.Hash("HasFields")] = DataValue.Constant(1); foreach (string item in hashSet) { Components[ZdoHelper.Hash("HasFields" + item)] = DataValue.Constant(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<ObjectType>(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<string> list2 = new List<string>(floats.Length); list2.AddRange(floats); ConnectionType = ToByteEnum<ConnectionType>(list2); return; } List<string> list3 = array.Take(array.Length - 1).ToList(); string text10 = array[^1]; ConnectionType = ToByteEnum<ConnectionType>(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[] typeKeyValues) { if (typeKeyValues.Length != 3) { throw new InvalidOperationException("Failed to parse type, field, value."); } string text = typeKeyValues[0].ToLowerInvariant(); string text2 = typeKeyValues[1]; string values = typeKeyValues[2]; if (text2.Contains(".")) { CanBeInjected = false; string text3 = text2.Split(new char[1] { '.' })[0]; if (Ints == null) { Ints = new Dictionary<int, IIntValue>(); } Ints[ZdoHelper.Hash("HasFields")] = DataValue.Constant(1); Ints[ZdoHelper.Hash("HasFields" + text3)] = DataValue.Constant(1); } switch (text) { case "float": if (Floats == null) { Floats = new Dictionary<int, IFloatValue>(); } Floats[ZdoHelper.Hash(text2)] = DataValue.Float(values); break; case "int": if (Ints == null) { Ints = new Dictionary<int, IIntValue>(); } Ints[ZdoHelper.Hash(text2)] = DataValue.Int(values); break; case "bool": if (Bools == null) { Bools = new Dictionary<int, IBoolValue>(); } Bools[ZdoHelper.Hash(text2)] = DataValue.Bool(values); break; case "hash": if (Hashes == null) { Hashes = new Dictionary<int, IHashValue>(); } Hashes[ZdoHelper.Hash(text2)] = DataValue.Hash(values); break; case "long": if (Longs == null) { Longs = new Dictionary<int, ILongValue>(); } Longs[ZdoHelper.Hash(text2)] = DataValue.Long(values); break; case "string": if (Strings == null) { Strings = new Dictionary<int, IStringValue>(); } Strings[ZdoHelper.Hash(text2)] = DataValue.String(values); break; case "vec": case "vec3": if (Vecs == null) { Vecs = new Dictionary<int, IVector3Value>(); } Vecs[ZdoHelper.Hash(text2)] = DataValue.Vector3(values); break; case "quat": if (Quats == null) { Quats = new Dictionary<int, IQuaternionValue>(); } Quats[ZdoHelper.Hash(text2)] = DataValue.Quaternion(values); break; case "bytes": if (ByteArrays == null) { ByteArrays = new Dictionary<int, IBytesValue>(); } 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 ((num & 1) != 0) { if (Floats == null) { Floats = new Dictionary<int, IFloatValue>(); } byte b = pkg.ReadByte(); for (int i = 0; i < b; i++) { Floats[pkg.ReadInt()] = new ConstantFloatValue(pkg.ReadSingle()); } } if ((num & 2) != 0) { if (Vecs == null) { Vecs = new Dictionary<int, IVector3Value>(); } byte b2 = pkg.ReadByte(); for (int j = 0; j < b2; j++) { Vecs[pkg.ReadInt()] = new ConstantVector3Value(pkg.ReadVector3()); } } if ((num & 4) != 0) { if (Quats == null) { Quats = new Dictionary<int, IQuaternionValue>(); } byte b3 = pkg.ReadByte(); for (int k = 0; k < b3; k++) { Quats[pkg.ReadInt()] = new ConstantQuaternionValue(pkg.ReadQuaternion()); } } if ((num & 8) != 0) { if (Ints == null) { Ints = new Dictionary<int, IIntValue>(); } byte b4 = pkg.ReadByte(); for (int l = 0; l < b4; l++) { Ints[pkg.ReadInt()] = new ConstantIntValue(pkg.ReadInt()); } } if ((num & 0x40) != 0) { if (Longs == null) { Longs = new Dictionary<int, ILongValue>(); } byte b5 = pkg.ReadByte(); for (int m = 0; m < b5; m++) { Longs[pkg.ReadInt()] = new ConstantLongValue(pkg.ReadLong()); } } if ((num & 0x10) != 0) { if (Strings == null) { Strings = new Dictionary<int, IStringValue>(); } byte b6 = pkg.ReadByte(); for (int n = 0; n < b6; n++) { Strings[pkg.ReadInt()] = new ConstantStringValue(pkg.ReadString()); } } if ((num & 0x80) != 0) { if (ByteArrays == null) { ByteArrays = new Dictionary<int, IBytesValue>(); } byte b7 = pkg.ReadByte(); for (int num2 = 0; num2 < b7; num2++) { ByteArrays[pkg.ReadInt()] = new ConstantBytesValue(pkg.ReadByteArray()); } } if ((num & 0x100) != 0) { ConnectionType = (ConnectionType)pkg.ReadByte(); ConnectionHash = pkg.ReadInt(); } if ((num & 0x200) != 0) { Persistent = new ConstantBoolValue(pkg.ReadBool()); } if ((num & 0x400) != 0) { Distant = new ConstantBoolValue(pkg.ReadBool()); } if ((num & 0x800) != 0) { Priority = (ObjectType)pkg.ReadByte(); } CanBeInjected = CheckCanBeInjected(); } private static T ToByteEnum<T>(List<string> list) where T : struct, Enum { byte b = 0; foreach (string item in list) { string text = item.Trim(); if (Enum.TryParse<T>(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 bool Match(Functions f, ZDO zdo) { return Matches(f, zdo, failOn: false); } public bool MatchNone(Functions f, ZDO zdo) { return Matches(f, zdo, failOn: true); } private bool Matches(Functions f, ZDO zdo, bool failOn) { //IL_0329: 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) //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: 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_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03c0: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) if (Fails(Strings, f, zdo, failOn, GetString, (IStringValue v, Functions ctx, string data) => v.Match(ctx, data))) { return false; } if (Fails(Floats, f, zdo, failOn, GetFloat, (IFloatValue v, Functions ctx, float data) => v.Match(ctx, data))) { return false; } if (Fails(Ints, f, zdo, failOn, GetInt, (IIntValue v, Functions ctx, int data) => v.Match(ctx, data))) { return false; } if (Fails(Longs, f, zdo, failOn, GetLong, (ILongValue v, Functions ctx, long data) => v.Match(ctx, data))) { return false; } if (Fails(Bools, f, zdo, failOn, GetBool, (IBoolValue v, Functions ctx, bool data) => v.Match(ctx, data))) { return false; } if (Fails(Hashes, f, zdo, failOn, GetInt, (IHashValue v, Functions ctx, int data) => v.Match(ctx, data))) { return false; } if (Fails(Vecs, f, zdo, failOn, GetVec, (IVector3Value v, Functions ctx, Vector3 data) => v.Match(ctx, data))) { return false; } if (Fails(Quats, f, zdo, failOn, GetQuaternion, (IQuaternionValue v, Functions ctx, Quaternion data) => v.Match(ctx, data))) { return false; } if (Fails(ByteArrays, f, zdo, failOn, (ZDO z, int key) => z.GetByteArray(key, (byte[])null), (IBytesValue v, Functions ctx, byte[] data) => v.Match(ctx, data))) { return false; } if (Persistent != null && Persistent.Match(f, zdo.Persistent) == failOn) { return false; } if (Distant != null && Distant.Match(f, zdo.Distant) == failOn) { return false; } if (Priority.HasValue && Priority.Value == zdo.Type == failOn) { return false; } if (Item != null && Item.MatchSingle(f, zdo) == failOn) { return false; } if (Items != null) { return ItemValue.Match(f, Items, zdo, ItemAmount) != failOn; } if (ItemAmount != null) { return ItemValue.Match(f, zdo, ItemAmount) != failOn; } if (ConnectionType.HasValue) { if ((int)ConnectionType.Value == 0) { ZDOConnection connection = zdo.GetConnection(); if ((connection == null || connection.m_target == ZDOID.None) == failOn) { return false; } } else { ZDOID connectionZDOID = zdo.GetConnectionZDOID(ConnectionType.Value); if (TargetConnectionId == null) { if (connectionZDOID != ZDOID.None == failOn) { return false; } } else { ZDOID? val = TargetConnectionId.Get(f); if (val.HasValue) { ZDOID val2 = connectionZDOID; ZDOID? val3 = val; if ((val3.HasValue && val2 == val3.GetValueOrDefault()) == failOn) { return false; } } } } } return true; } private static bool Fails<TValue, TData>(Dictionary<int, TValue>? values, Functions f, ZDO zdo, bool failOn, Func<ZDO, int, TData> read, Func<TValue, Functions, TData, bool?> match) { if (values == null) { return false; } foreach (KeyValuePair<int, TValue> value in values) { if (match(value.Value, f, read(zdo, value.Key)) == failOn) { return true; } } return false; } private static string GetString(ZDO zdo, int key) { return ZdoHelper.TryGetString(zdo, key) ?? ""; } private static float GetFloat(ZDO zdo, int key) { return ZdoHelper.TryGetFloat(zdo, key).GetValueOrDefault(); } private static int GetInt(ZDO zdo, int key) { return ZdoHelper.TryGetInt(zdo, key).GetValueOrDefault(); } private static long GetLong(ZDO zdo, int key) { return ZdoHelper.TryGetLong(zdo, key).GetValueOrDefault(); } private static bool GetBool(ZDO zdo, int key) { return ZdoHelper.TryGetBool(zdo, key) == true; } private static 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 static 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 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 ConstantZdoIdValue(val); } return new ZdoIdValue(array); } public static IIntValue Constant(int value) { return new ConstantIntValue(value); } public static IStringValue Constant(string value) { return new ConstantStringValue(value); } public static IFloatValue Constant(float value) { return new ConstantFloatValue(value); } public static ILongValue Constant(long value) { return new ConstantLongValue(value); } public static IVector3Value Constant(Vector3 value) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return new ConstantVector3Value(value); } public static IQuaternionValue Constant(Quaternion value) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return new ConstantQuaternionValue(value); } public static IBytesValue Constant(byte[]? value) { return new ConstantBytesValue(value); } public static IIntValue Int(string values) { string[] array = SplitWithValues(values); if (array.Length == 1 && Parse.TryInt(array[0], out var result)) { return new ConstantIntValue(result); } return new IntValue(array); } public static IRangeIntValue RangeInt(string values) { string[] array = SplitWithValues(values); if (array.Length == 1 && !HasFunctions(array[0])) { if (Parse.TryInt(array[0], out var result)) { return new ConstantRangeIntValue(new ValueRange<int>(result, 0)); } return new ConstantRangeIntValue(Parse.IntRange(array[0])); } return new RangeIntValue(array); } public static IFloatValue Float(string values) { string[] array = SplitWithValues(values); if (array.Length == 1 && Parse.TryFloat(array[0], out var result)) { return new ConstantFloatValue(result); } return new FloatValue(array); } public static ILongValue Long(string values) { string[] array = SplitWithValues(values); if (array.Length == 1 && Parse.TryLong(array[0], out var result)) { return new ConstantLongValue(result); } return new LongValue(array); } public static IStringValue String(string values) { if (values.Length > 2 && values[0] == '"' && values[values.Length - 1] == '"') { return new ConstantStringValue(values.Substring(1, values.Length - 2)); } string[] array = SplitWithValues(values); if (array.Length == 1 && !HasFunctions(array[0])) { return new ConstantStringValue(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 ConstantBoolValue(result); } return new BoolValue(array); } public static IBytesValue Bytes(string values) { string[] array = SplitWithValues(values); if (array.Length == 1 && !HasFunctions(array[0])) { if (string.IsNullOrEmpty(array[0])) { return new ConstantBytesValue(null); } try { return new ConstantBytesValue(Convert.FromBase64String(array[0])); } catch (FormatException) { } } return new BytesValue(array); } public static IHashValue Hash(string values) { string[] array = SplitWithValues(values); if (array.Length == 1 && !HasFunctions(array[0])) { return new ConstantHashValue(array[0]); } return new HashValue(array); } public static IPrefabValue Prefab(string values) { if (HasFunctions(values)) { return new PrefabValue(SplitWithValues(values)); } List<int> prefabs = PrefabHelper.GetPrefabs(values, ""); if (prefabs.Count == 0) { return new ConstantPrefabValue(null); } if (prefabs.Count == 1) { return new ConstantPrefabValue(prefabs[0]); } return new ConstantPrefabListValue(prefabs); } public static IVector3Value Vector3(string values) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) string[] array = SplitWithValues(values); if (HasFunctions(values) || array.Length > 3) { List<string> list = new List<string>(); for (int i = 0; i < array.Length; i += 3) { string[] array2; if (i + 3 >= array.Length) { List<string> list2 = new List<string>(); 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()); } if (Parse.TryDistanceAngle(array, out var vector)) { return new ConstantVector3Value(vector); } Vector3? val = Parse.VectorXZYNull(array); return new ConstantVector3Value(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 (HasFunctions(values) || array.Length > 3) { List<string> list = new List<string>(); for (int i = 0; i < array.Length; i += 3) { string[] array2; if (i + 3 >= array.Length) { List<string> list2 = new List<string>(); 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 ConstantQuaternionValue(val.HasValue ? val.Value : Quaternion.identity); } private static bool HasFunctions(string value) { if (value.Contains("<")) { return value.Contains(">"); } return false; } private static string[] SplitWithValues(string str) { List<string> list = new List<string>(); string[] array = Parse.SplitWithEmpty(str); foreach (string text in array) { if (!HasFunctions(text)) { list.Add(text); continue; } string[] array2 = text.Split('<', '>'); List<string> list2 = new List<string>(); List<int> list3 = new List<int>(); for (int j = 1; j < array2.Length; j += 2) { int num = ValueGroups.Hash(array2[j]); if (ValueGroups.Contains(num)) { list2.Add("<" + array2[j] + ">"); list3.Add(num); } } if (list2.Count == 0) { list.Add(text); if (list.Count > 1000) { break; } } else { SubstituteValues(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 SubstituteValues(List<string> result, string format, List<string> parameters, List<int> hashes, int index) { if (!ValueGroups.TryGet(hashes[index], out List<string> values)) { return; } foreach (string item in values) { string text = format.Replace(parameters[index], item); if (index == parameters.Count - 1) { result.Add(text); if (result.Count > 1000) { break; } } else { SubstituteValues(result, text, parameters, hashes, index + 1); } } } } public class DataYaml { [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 ItemYaml[]? items; [DefaultValue(null)] public ItemYaml? item; [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 ItemYaml { [DefaultValue("")] public string pos = ""; [DefaultValue(1f)] public float chance = 1f; [DefaultValue("")] public string prefab = ""; [DefaultValue(null)] public string? stack; [DefaultValue(null)] public string? quality; [DefaultValue(null)] public string? variant; [DefaultValue(null)] public string? durability; [DefaultValue(null)] public string? crafterID; [DefaultValue(null)] public string? crafterName; [DefaultValue(null)] public string? worldLevel; [DefaultValue(null)] public string? equipped; [DefaultValue(null)] public string? pickedUp; [DefaultValue(null)] public string? cheated; [DefaultValue(null)] public Dictionary<string, string>? customData; } public class Functions(string prefab, string[] args, Vector3 pos) { protected const char Separator = '_'; public static Func<string, string?> ExecuteCode = (string key) => (string?)null; public static Func<string, string, string?> ExecuteCodeWithValue = (string key, string value) => (string?)null; private readonly double time = ZNet.instance.GetTimeSeconds(); public int Amount; private List<ZDOID>? pokeTargets; private Dictionary<string, int>? pokeCounts; 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<float> 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)) { return defaultValue; } List<float> list = (from v in array.Skip(1) select Parse.Float(v, float.MaxValue)).ToList(); list.Sort(); if (result < 1) { return list[0].ToString(CultureInfo.InvariantCulture); } if (result > list.Count) { return list[list.Count - 1].ToString(CultureInfo.InvariantCulture); } return list[result - 1].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)) { return defaultValue; } List<float> list = (from v in array.Skip(1) select Parse.Float(v, float.MinValue)).ToList(); list.Sort(); if (result < 1) { return list[list.Count - 1].ToString(CultureInfo.InvariantCulture); } if (result > list.Count) { return list[0].ToString(CultureInfo.InvariantCulture); } return list[list.Count - result].ToString(CultureInfo.InvariantCulture); } private string HandleEqual(string value, string defaultValue) { KeyValuePair<string, string> 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<string, string> 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<string, string> 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<string, string> 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<string, string> 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<string, string> 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<char> list = new List<char>(); 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<char> list = new List<char>(); list.AddRange(value.Where(char.IsLower)); return new string(list.ToArray()); } private string LoadStored(string key, string defaultValue) { return null ?? defaultValue; } private string IncrementStored(string key, long amount) { return null ?? ""; } public void SetPokeTargets(List<ZDOID> targets) { pokeTargets = targets; pokeCounts = null; Amount = targets.Count; } public string Replace(string str) { return Replace(str, preventInjections: false, allValues: false); } public string Replace(string str, bool preventInjections, bool allValues) { 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 = ResolveFunctions(str2, allValues); 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 ResolveFunctions(string str, bool allValues) { 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 (TryReplaceFunction(str.Substring(num3, num4), allValues, out string resolved)) { str = str.Remove(num3, num4); str = str.Insert(num3, resolved); num = num3 - 1; } else { num = num2; } } } return str; } private bool TryReplaceFunction(string rawKey, bool allValues, out string? resolved) { string text = rawKey.Substring(1, rawKey.Length - 2); KeyValuePair<string, string> keyValuePair = Parse.Kvp(text, '='); string text2 = keyValuePair.Value; if (text2.All((char c) => c == '=')) { text2 = ""; } else { text = keyValuePair.Key; } resolved = GetFunction(text, text2); if (resolved == null) { resolved = (allValues ? ResolveConditionValue(rawKey) : ResolveValue(rawKey)); } return resolved != rawKey; } protected virtual string? GetFunction(string key, string defaultValue) { string text = null; if (text != null) { return text; } text = ExecuteCode(key); if (text != null) { return text; } text = GetGeneralFunction(key, defaultValue); if (text != null) { return text; } KeyValuePair<string, string> keyValuePair = Parse.Kvp(key, '_'); if (keyValuePair.Value == "") { return null; } key = keyValuePair.Key; string value = keyValuePair.Value; if (text != null) { return text; } text = ExecuteCodeWithValue(key, value); if (text != null) { return text; } return GetValueFunction(key, value, defaultValue); } private string? GetGeneralFunction(string key, string defaultValue) { return key switch { "prefab" => prefab, "safeprefab" => prefab.Replace('_', '-'), "par" => string.Join(" ", args), "par0" => GetArg(0, defaultValue), "par1" => GetArg(1, defaul