using System; 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 BepInEx; using BepInEx.Bootstrap; 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+ce32d2861e4e1cdf5ddbf4e577ca98d76f057516")] [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 Data { public class DataHelper { public static ZDO Regen(ZDO existing, ZDO zdo) { ZNetScene.instance.CreateObject(zdo); Destroy(existing); return zdo; } public static ZDO Regen(ZDO existing, PlainDataEntry data) { ZDO val = CloneBase(existing); data.Write(val); ZNetScene.instance.CreateObject(val); Destroy(existing); return val; } public static void Destroy(ZDO zdo) { zdo.SetOwner(ZDOMan.instance.m_sessionID); if (ZNetScene.instance.m_instances.TryGetValue(zdo, out var value) && Object.op_Implicit((Object)(object)value)) { ZNetScene.instance.Destroy(((Component)value).gameObject); } else { ZDOMan.instance.DestroyZDO(zdo); } } public static ZDO CloneBase(ZDO zdo) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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) ZDO obj = ZDOMan.instance.CreateNewZDO(zdo.m_position, zdo.m_prefab); obj.m_prefab = zdo.m_prefab; obj.m_rotation = zdo.m_rotation; obj.Type = zdo.Type; obj.Distant = zdo.Distant; obj.Persistent = zdo.Persistent; obj.IncreaseDataRevision(); return obj; } public static ZDO CloneWithKeys(ZDO zdo, string[] keys) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: 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) HashSet hashSet = keys.Select((string s) => StringExtensionMethods.GetStableHashCode(s)).ToHashSet(); ZDO val = CloneBase(zdo); ZDOID uid = zdo.m_uid; ZDOID uid2 = val.m_uid; float num = default(float); Vector3 val2 = default(Vector3); Quaternion val3 = default(Quaternion); int num2 = default(int); long num3 = default(long); string text = default(string); byte[] array = default(byte[]); foreach (int item in hashSet) { if (ZDOExtraData.GetFloat(uid, item, ref num)) { ZDOExtraData.Set(uid2, item, num); } if (ZDOExtraData.GetVec3(uid, item, ref val2)) { ZDOExtraData.Set(uid2, item, val2); } if (ZDOExtraData.GetQuaternion(uid, item, ref val3)) { ZDOExtraData.Set(uid2, item, val3); } if (ZDOExtraData.GetInt(uid, item, ref num2)) { ZDOExtraData.Set(uid2, item, num2); } if (ZDOExtraData.GetLong(uid, item, ref num3)) { ZDOExtraData.Set(uid2, item, num3); } if (ZDOExtraData.GetString(uid, item, ref text)) { ZDOExtraData.Set(uid2, item, text); } if (ZDOExtraData.GetByteArray(uid, item, ref array)) { ZDOExtraData.Set(uid2, item, array); } } return val; } public static bool HasKey(ZDO zdo, string[] keys) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) HashSet hashSet = keys.Select((string s) => StringExtensionMethods.GetStableHashCode(s)).ToHashSet(); ZDOID uid = zdo.m_uid; IEnumerable first = from kvp in ZDOExtraData.GetFloats(uid) select kvp.Key; IEnumerable second = from kvp in ZDOExtraData.GetVec3s(uid) select kvp.Key; IEnumerable second2 = from kvp in ZDOExtraData.GetQuaternions(uid) select kvp.Key; IEnumerable second3 = from kvp in ZDOExtraData.GetInts(uid) select kvp.Key; IEnumerable second4 = from kvp in ZDOExtraData.GetLongs(uid) select kvp.Key; IEnumerable second5 = from kvp in ZDOExtraData.GetStrings(uid) select kvp.Key; IEnumerable second6 = from kvp in ZDOExtraData.GetByteArrays(uid) select kvp.Key; return first.Concat(second).Concat(second2).Concat(second3) .Concat(second4) .Concat(second5) .Concat(second6) .Any(hashSet.Contains); } public static ZDO CloneWithoutKeys(ZDO zdo, string[] keys) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_015d: 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_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0271: 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_0321: Unknown result type (might be due to invalid IL or missing references) //IL_032b: 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_036d: Unknown result type (might be due to invalid IL or missing references) //IL_03a5: Unknown result type (might be due to invalid IL or missing references) //IL_03e7: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_046b: Unknown result type (might be due to invalid IL or missing references) HashSet hashed = keys.Select((string s) => StringExtensionMethods.GetStableHashCode(s)).ToHashSet(); ZDO val = CloneBase(zdo); ZDOID uid = zdo.m_uid; ZDOID uid2 = val.m_uid; Dictionary dictionary = (from kvp in ZDOExtraData.GetFloats(uid) where !hashed.Contains(kvp.Key) select kvp).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value); Dictionary dictionary2 = (from kvp in ZDOExtraData.GetVec3s(uid) where !hashed.Contains(kvp.Key) select kvp).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value); Dictionary dictionary3 = (from kvp in ZDOExtraData.GetQuaternions(uid) where !hashed.Contains(kvp.Key) select kvp).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value); Dictionary dictionary4 = (from kvp in ZDOExtraData.GetInts(uid) where !hashed.Contains(kvp.Key) select kvp).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value); Dictionary dictionary5 = (from kvp in ZDOExtraData.GetLongs(uid) where !hashed.Contains(kvp.Key) select kvp).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value); Dictionary dictionary6 = (from kvp in ZDOExtraData.GetStrings(uid) where !hashed.Contains(kvp.Key) select kvp).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value); Dictionary dictionary7 = (from kvp in ZDOExtraData.GetByteArrays(uid) where !hashed.Contains(kvp.Key) select kvp).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value); foreach (KeyValuePair item in dictionary) { ZDOExtraData.Set(uid2, item.Key, item.Value); } foreach (KeyValuePair item2 in dictionary2) { ZDOExtraData.Set(uid2, item2.Key, item2.Value); } foreach (KeyValuePair item3 in dictionary3) { ZDOExtraData.Set(uid2, item3.Key, item3.Value); } foreach (KeyValuePair item4 in dictionary4) { ZDOExtraData.Set(uid2, item4.Key, item4.Value); } foreach (KeyValuePair item5 in dictionary5) { ZDOExtraData.Set(uid2, item5.Key, item5.Value); } foreach (KeyValuePair item6 in dictionary6) { ZDOExtraData.Set(uid2, item6.Key, item6.Value); } foreach (KeyValuePair item7 in dictionary7) { ZDOExtraData.Set(uid2, item7.Key, item7.Value); } return val; } public static List Print(ZDO zdo) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = ZNetScene.instance.GetPrefab(zdo.m_prefab); ZDOID uid = zdo.m_uid; List collection = new List(6) { $"Id: {uid}", "Prefab: " + (Object.op_Implicit((Object)(object)prefab) ? ((Object)prefab).name : "Unknown"), $"Owner: {zdo.GetOwner()}", "Position: " + Helper.PrintVectorXZY(zdo.m_position) + " (vec x,z,y)", "Rotation: " + Helper.PrintVectorYXZ(zdo.m_rotation) + " (quat y,x,z)", $"Revision: {zdo.DataRevision} + {zdo.OwnerRevision}" }; IEnumerable collection2 = from kvp in ZDOExtraData.GetVec3s(uid) select ZDOKeys.Convert(kvp.Key) + ": " + Helper.PrintVectorXZY(kvp.Value) + " (vec x,z,y)"; IEnumerable collection3 = from kvp in ZDOExtraData.GetInts(uid) select $"{ZDOKeys.Convert(kvp.Key)}: {kvp.Value} (int)"; IEnumerable collection4 = from kvp in ZDOExtraData.GetFloats(uid) select $"{ZDOKeys.Convert(kvp.Key)}: {kvp.Value} (float)"; IEnumerable collection5 = from kvp in ZDOExtraData.GetQuaternions(uid) select ZDOKeys.Convert(kvp.Key) + ": " + Helper.PrintAngleYXZ(kvp.Value) + " (quat y,x,z)"; IEnumerable collection6 = from kvp in ZDOExtraData.GetStrings(uid) select ZDOKeys.Convert(kvp.Key) + ": " + kvp.Value + " (string)"; IEnumerable collection7 = from kvp in ZDOExtraData.GetLongs(uid) select $"{ZDOKeys.Convert(kvp.Key)}: {kvp.Value} (long)"; IEnumerable collection8 = from kvp in ZDOExtraData.GetByteArrays(uid) select ZDOKeys.Convert(kvp.Key) + ": " + Convert.ToBase64String(kvp.Value) + " (byte array)"; List list = new List(); list.AddRange(collection); list.AddRange(collection2); list.AddRange(collection3); list.AddRange(collection4); list.AddRange(collection5); list.AddRange(collection6); list.AddRange(collection7); list.AddRange(collection8); return list; } public static ZDO? Init(int prefab, Transform tr, DataEntry? data) { //IL_001d: 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_0029: Unknown result type (might be due to invalid IL or missing references) CleanUp(); GameObject prefab2 = ZNetScene.instance.GetPrefab(prefab); if (!Object.op_Implicit((Object)(object)prefab2)) { return null; } return Init(prefab2, tr.position, tr.rotation, tr.lossyScale, data, new Dictionary()); } public static ZDO? Init(GameObject obj, Vector3 pos, Quaternion rot, Vector3? scale, DataEntry? data, Dictionary pars) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) CleanUp(); if (data == null && !scale.HasValue) { return null; } ZNetView val = default(ZNetView); if (!obj.TryGetComponent(ref val)) { return null; } int stableHashCode = StringExtensionMethods.GetStableHashCode(Utils.GetPrefabName(obj)); ZNetView.m_initZDO = ZDOMan.instance.CreateNewZDO(pos, stableHashCode); 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 && global::WorldEditCommands.WorldEditCommands.IsTweaks) { ZNetView.m_initZDO.Set(Hash.HasFields, true); ZNetView.m_initZDO.Set("HasFieldsZNetView", true); ZNetView.m_initZDO.Set("ZNetView.m_syncInitialScale", true); val.m_syncInitialScale = true; ((Terminal)Console.instance).AddString("Note: Scaling set to true."); } 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(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 DataEntry Get(string name) { int stableHashCode = StringExtensionMethods.GetStableHashCode(name); if (!DataLoading.Data.ContainsKey(stableHashCode)) { try { DataLoading.Data[stableHashCode] = new DataEntry(name); } catch (Exception innerException) { if (name.Contains("=") || name.Length > 32) { throw new InvalidOperationException("Can't load data value: " + name, innerException); } throw new InvalidOperationException("Can't find data entry: " + name, innerException); } } return DataLoading.Data[stableHashCode]; } public static string Base64(Dictionary pars, string data) { if (!DataLoading.Data.TryGetValue(StringExtensionMethods.GetStableHashCode(data), out DataEntry value)) { return data; } return value.GetBase64(pars); } } public class Calculator { 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(), NumberFormatInfo.InvariantInfo); } 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 = ""; [DefaultValue("1")] public string stack = "1"; [DefaultValue("1")] public string quality = "1"; [DefaultValue("0")] public string variant = "0"; [DefaultValue("0")] public string durability = "0"; [DefaultValue("0")] public string crafterID = "0"; [DefaultValue("")] public string crafterName = ""; [DefaultValue("0")] public string worldLevel = "0"; [DefaultValue("false")] public string equipped = "false"; [DefaultValue("false")] public string pickedUp = "false"; [DefaultValue(null)] 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 ZDOID OriginalId = ZDOID.None; public ZDOID TargetConnectionId = ZDOID.None; public IBoolValue? Persistent; public IBoolValue? Distant; public ObjectType? Priority; public HashSet RequiredParameters = new HashSet(); public DataEntry() { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) public DataEntry(string base64) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown this.Load(new ZPackage(base64)); } public DataEntry(DataData data) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) Load(data); } public DataEntry(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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) Load(zdo); } public void Set(int key, string value) { if (Strings == null) { Strings = new Dictionary(); } Strings[key] = new SimpleStringValue(value); } public void Set(int key, float value) { if (Floats == null) { Floats = new Dictionary(); } Floats[key] = new SimpleFloatValue(value); } public void Set(int key, int value) { if (Ints == null) { Ints = new Dictionary(); } Ints[key] = new SimpleIntValue(value); } public void Set(int key, bool value) { if (Bools == null) { Bools = new Dictionary(); } Bools[key] = new SimpleBoolValue(value); } public void Set(int key, long value) { if (Longs == null) { Longs = new Dictionary(); } Longs[key] = new SimpleLongValue(value); } public void Set(int key, Vector3 value) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (Vecs == null) { Vecs = new Dictionary(); } Vecs[key] = new SimpleVector3Value(value); } public void Set(int key, Quaternion value) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (Quats == null) { Quats = new Dictionary(); } Quats[key] = new SimpleQuaternionValue(value); } public void Set(int key, byte[] value) { if (ByteArrays == null) { ByteArrays = new Dictionary(); } ByteArrays[key] = value; } public bool TryGetString(Dictionary pars, int key, out string value) { value = ""; if (Strings == null || !Strings.TryGetValue(key, out IStringValue value2)) { return false; } string text = value2.Get(pars); if (text == null) { return false; } value = text; return true; } public bool TryGetFloat(Dictionary pars, int key, out float value) { value = 0f; if (Floats == null || !Floats.TryGetValue(key, out IFloatValue value2)) { return false; } float? num = value2.Get(pars); if (!num.HasValue) { return false; } value = num.Value; return true; } public bool TryGetInt(Dictionary pars, int key, out int value) { value = 0; if (Ints == null || !Ints.TryGetValue(key, out IIntValue value2)) { return false; } int? num = value2.Get(pars); if (!num.HasValue) { return false; } value = num.Value; return true; } public bool TryGetBool(Dictionary pars, int key, out bool value) { value = false; if (Bools == null || !Bools.TryGetValue(key, out IBoolValue value2)) { return false; } int? num = value2.GetInt(pars); if (!num.HasValue) { return false; } value = num.Value != 0; return true; } public bool TryGetHash(Dictionary pars, int key, out int value) { value = 0; if (Hashes == null || !Hashes.TryGetValue(key, out IHashValue value2)) { return false; } int? num = value2.Get(pars); if (!num.HasValue) { return false; } value = num.Value; return true; } public bool TryGetLong(Dictionary pars, int key, out long value) { value = 0L; if (Longs == null || !Longs.TryGetValue(key, out ILongValue value2)) { return false; } long? num = value2.Get(pars); if (!num.HasValue) { return false; } value = num.Value; return true; } public void Load(DataEntry data) { //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_043a: Unknown result type (might be due to invalid IL or missing references) 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; } foreach (string requiredParameter in data.RequiredParameters) { RequiredParameters.Add(requiredParameter); } } public void Load(ZDO zdo) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: 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_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_035a: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = zdo.m_uid; Floats = (ZDOExtraData.s_floats.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_floats[uid]).ToDictionary((Func, int>)((KeyValuePair kvp) => kvp.Key), (Func, IFloatValue>)((KeyValuePair kvp) => new SimpleFloatValue(kvp.Value))) : null); Vecs = (ZDOExtraData.s_vec3.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_vec3[uid]).ToDictionary((Func, int>)((KeyValuePair kvp) => kvp.Key), (Func, IVector3Value>)((KeyValuePair kvp) => new SimpleVector3Value(kvp.Value))) : null); Quats = (ZDOExtraData.s_quats.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_quats[uid]).ToDictionary((Func, int>)((KeyValuePair kvp) => kvp.Key), (Func, IQuaternionValue>)((KeyValuePair kvp) => new SimpleQuaternionValue(kvp.Value))) : null); Ints = (ZDOExtraData.s_ints.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_ints[uid]).ToDictionary((Func, int>)((KeyValuePair kvp) => kvp.Key), (Func, IIntValue>)((KeyValuePair kvp) => new SimpleIntValue(kvp.Value))) : null); Strings = (ZDOExtraData.s_strings.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_strings[uid]).ToDictionary((Func, int>)((KeyValuePair kvp) => kvp.Key), (Func, IStringValue>)((KeyValuePair kvp) => new SimpleStringValue(kvp.Value))) : null); Longs = (ZDOExtraData.s_longs.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_longs[uid]).ToDictionary((Func, int>)((KeyValuePair kvp) => kvp.Key), (Func, ILongValue>)((KeyValuePair kvp) => new SimpleLongValue(kvp.Value))) : null); ByteArrays = (ZDOExtraData.s_byteArrays.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_byteArrays[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value) : null); if (ZDOExtraData.s_connectionsHashData.TryGetValue(uid, out var value)) { ConnectionType = value.m_type; ConnectionHash = value.m_hash; } OriginalId = uid; if (ZDOExtraData.s_connections.TryGetValue(uid, out var value2) && value2.m_target != ZDOID.None) { TargetConnectionId = value2.m_target; ConnectionType = value2.m_type; } Persistent = (zdo.Persistent ? new SimpleBoolValue(value: true) : null); Distant = (zdo.Distant ? new SimpleBoolValue(value: true) : null); Priority = zdo.Type; } public void Load(DataData data) { //IL_0782: Unknown result type (might be due to invalid IL or missing references) //IL_089d: Unknown result type (might be due to invalid IL or missing references) //IL_08ee: Unknown result type (might be due to invalid IL or missing references) //IL_08f3: 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]); } Floats.Add(ZDOKeys.Hash(keyValuePair.Key), DataValue.Float(keyValuePair.Value, RequiredParameters)); } } 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]); } Ints.Add(ZDOKeys.Hash(keyValuePair2.Key), DataValue.Int(keyValuePair2.Value, RequiredParameters)); } } 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]); } Bools.Add(ZDOKeys.Hash(keyValuePair3.Key), DataValue.Bool(keyValuePair3.Value, RequiredParameters)); } } 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]); } Hashes.Add(ZDOKeys.Hash(keyValuePair4.Key), DataValue.Hash(keyValuePair4.Value, RequiredParameters)); } } 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]); } Longs.Add(ZDOKeys.Hash(keyValuePair5.Key), DataValue.Long(keyValuePair5.Value, RequiredParameters)); } } 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]); } Strings.Add(ZDOKeys.Hash(keyValuePair6.Key), DataValue.String(keyValuePair6.Value, RequiredParameters)); } } 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]); } Vecs.Add(ZDOKeys.Hash(keyValuePair7.Key), DataValue.Vector3(keyValuePair7.Value, RequiredParameters)); } } 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]); } Quats.Add(ZDOKeys.Hash(keyValuePair8.Key), DataValue.Quaternion(keyValuePair8.Value, RequiredParameters)); } } 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]); } ByteArrays.Add(ZDOKeys.Hash(keyValuePair9.Key), Convert.FromBase64String(keyValuePair9.Value)); } } if (data.items != null) { Items = data.items.Select((ItemData item) => new ItemValue(item, RequiredParameters)).ToList(); } if (!string.IsNullOrWhiteSpace(data.containerSize)) { ContainerSize = Parse.Vector2Int(data.containerSize); } if (!string.IsNullOrWhiteSpace(data.itemAmount)) { ItemAmount = DataValue.Int(data.itemAmount, RequiredParameters); } 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 (data.persistent != null) { Persistent = DataValue.Bool(data.persistent, RequiredParameters); } if (data.distant != null) { Distant = DataValue.Bool(data.distant, RequiredParameters); } 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) { List list = array.Take(array.Length - 1).ToList(); string text10 = array[^1]; ConnectionType = ToByteEnum(list); ConnectionHash = Parse.Int(text10, 0); if (ConnectionHash == 0) { ConnectionHash = StringExtensionMethods.GetStableHashCode(text10); } } } public void Load(ZPackage pkg) { //IL_0214: 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()] = DataValue.Float(pkg); } } if ((num & 2) != 0) { if (Vecs == null) { Vecs = new Dictionary(); } byte b2 = pkg.ReadByte(); for (int j = 0; j < b2; j++) { Vecs[pkg.ReadInt()] = DataValue.Vector3(pkg); } } if ((num & 4) != 0) { if (Quats == null) { Quats = new Dictionary(); } byte b3 = pkg.ReadByte(); for (int k = 0; k < b3; k++) { Quats[pkg.ReadInt()] = DataValue.Quaternion(pkg); } } if ((num & 8) != 0) { if (Ints == null) { Ints = new Dictionary(); } byte b4 = pkg.ReadByte(); for (int l = 0; l < b4; l++) { Ints[pkg.ReadInt()] = DataValue.Int(pkg); } } if ((num & 0x40) != 0) { if (Longs == null) { Longs = new Dictionary(); } byte b5 = pkg.ReadByte(); for (int m = 0; m < b5; m++) { Longs[pkg.ReadInt()] = DataValue.Long(pkg); } } if ((num & 0x10) != 0) { if (Strings == null) { Strings = new Dictionary(); } byte b6 = pkg.ReadByte(); for (int n = 0; n < b6; n++) { Strings[pkg.ReadInt()] = DataValue.String(pkg); } } 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 = DataValue.Bool(pkg); } if ((num & 0x400) != 0) { Distant = DataValue.Bool(pkg); } if ((num & 0x800) != 0) { Priority = (ObjectType)pkg.ReadByte(); } } public bool Match(Dictionary pars, ZDO zdo) { //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) AddParameters(pars, zdo); 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; } return true; } public bool Unmatch(Dictionary pars, ZDO zdo) { //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) AddParameters(pars, zdo); 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; } return true; } private void AddParameters(Dictionary pars, ZDO? zdo) { string[] array = pars.Values.ToArray(); foreach (string value in array) { AddNestedParameters(value, pars, zdo); } foreach (string requiredParameter in RequiredParameters) { string key = "<" + requiredParameter + ">"; if (!pars.ContainsKey(key)) { AddParameter(requiredParameter, pars, zdo); } } } private void AddNestedParameters(string value, Dictionary pars, ZDO? zdo) { if (!value.Contains("<")) { return; } string[] array = value.Split('<', '>'); for (int i = 1; i < array.Length; i += 2) { string key = "<" + array[i] + ">"; if (!pars.ContainsKey(key)) { AddParameter(array[i], pars, zdo); } } } private void AddParameter(string par, Dictionary pars, ZDO? zdo) { //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) string text = "<" + par + ">"; if (DataLoading.TryGetValueFromGroup(par, out string value)) { pars[text] = value; AddNestedParameters(value, pars, zdo); } else if (text.Contains("_")) { if (zdo == null) { return; } string[] array = par.Split(new char[1] { '_' }); if (array.Length >= 2) { string text2 = array[0]; string text3 = array[1]; text = "<" + text2 + "_" + text3 + ">"; switch (text2) { case "string": pars[text] = zdo.GetString(text3, ""); break; case "float": pars[text] = zdo.GetFloat(text3, 0f).ToString(CultureInfo.InvariantCulture); break; case "int": pars[text] = zdo.GetInt(text3, 0).ToString(CultureInfo.InvariantCulture); break; case "long": pars[text] = zdo.GetLong(text3, 0L).ToString(CultureInfo.InvariantCulture); break; case "bool": pars[text] = zdo.GetBool(text3, false).ToString(); break; case "hash": pars[text] = zdo.GetInt(text3, 0).ToString(CultureInfo.InvariantCulture); break; case "vec": pars[text] = Helper.PrintVectorXZY(zdo.GetVec3(text3, Vector3.zero)); break; case "quat": pars[text] = Helper.PrintAngleYXZ(zdo.GetQuaternion(text3, Quaternion.identity)); break; case "byte": pars[text] = Convert.ToBase64String(zdo.GetByteArray(text3, (byte[])null)); break; } } } else if (text == "" && zdo != null) { pars[text] = zdo.m_position.x.ToString(CultureInfo.InvariantCulture); } else if (text == "" && zdo != null) { pars[text] = zdo.m_position.y.ToString(CultureInfo.InvariantCulture); } else if (text == "" && zdo != null) { pars[text] = zdo.m_position.z.ToString(CultureInfo.InvariantCulture); } else if (text == "" && zdo != null) { pars[text] = Helper.PrintAngleYXZ(zdo.GetRotation()); } } 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 { ServerDevcommands.Log.LogWarning((object)("Failed to parse value " + text + " as T.")); } } return (T)(object)b; } public void Write(Dictionary pars, ZDO zdo) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_01cd: 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_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) AddParameters(pars, zdo); RollItems(pars); ZDOID uid = zdo.m_uid; 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); HandleHashConnection(zdo); } public string GetBase64(Dictionary pars) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown ZPackage val = new ZPackage(); Write(pars, val); return val.GetBase64(); } public void Write(Dictionary pars, ZPackage pkg) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_0651: Unknown result type (might be due to invalid IL or missing references) //IL_0662: Unknown result type (might be due to invalid IL or missing references) //IL_066c: Expected I4, but got Unknown //IL_06dd: Unknown result type (might be due to invalid IL or missing references) //IL_06e7: Expected I4, but got Unknown AddParameters(pars, null); RollItems(pars); int num = 0; if (Floats != null) { num |= 1; } if (Vecs != null) { num |= 2; } if (Quats != null) { num |= 4; } if (Ints != null || Hashes != null || Bools != null) { num |= 8; } if (Strings != null) { num |= 0x10; } if (Longs != null) { num |= 0x40; } if (ByteArrays != null) { num |= 0x80; } if ((int)ConnectionType != 0 && ConnectionHash != 0) { num |= 0x100; } if (Persistent != null) { num |= 0x200; } if (Distant != null) { num |= 0x400; } if (Priority.HasValue) { num |= 0x800; } pkg.Write(num); if (Floats != null) { KeyValuePair[] array = (from kvp in Floats select new KeyValuePair(kvp.Key, kvp.Value.Get(pars)) into kvp where kvp.Value.HasValue select kvp).ToArray(); pkg.Write((byte)array.Count()); KeyValuePair[] array2 = array; for (int num2 = 0; num2 < array2.Length; num2++) { KeyValuePair keyValuePair = array2[num2]; pkg.Write(keyValuePair.Key); pkg.Write(keyValuePair.Value.Value); } } if (Vecs != null) { KeyValuePair[] array3 = (from kvp in Vecs select new KeyValuePair(kvp.Key, kvp.Value.Get(pars)) into kvp where kvp.Value.HasValue select kvp).ToArray(); pkg.Write((byte)array3.Count()); KeyValuePair[] array4 = array3; for (int num2 = 0; num2 < array4.Length; num2++) { KeyValuePair keyValuePair2 = array4[num2]; pkg.Write(keyValuePair2.Key); pkg.Write(keyValuePair2.Value.Value); } } if (Quats != null) { KeyValuePair[] array5 = (from kvp in Quats select new KeyValuePair(kvp.Key, kvp.Value.Get(pars)) into kvp where kvp.Value.HasValue select kvp).ToArray(); pkg.Write((byte)array5.Count()); KeyValuePair[] array6 = array5; for (int num2 = 0; num2 < array6.Length; num2++) { KeyValuePair keyValuePair3 = array6[num2]; pkg.Write(keyValuePair3.Key); pkg.Write(keyValuePair3.Value.Value); } } if (Ints != null || Hashes != null || Bools != null) { KeyValuePair[] obj = (from kvp in Ints?.Select((KeyValuePair kvp) => new KeyValuePair(kvp.Key, kvp.Value.Get(pars))) where kvp.Value.HasValue select kvp).ToArray() ?? Array.Empty>(); KeyValuePair[] array7 = (from kvp in Hashes?.Select((KeyValuePair kvp) => new KeyValuePair(kvp.Key, kvp.Value.Get(pars))) where kvp.Value.HasValue select kvp).ToArray() ?? Array.Empty>(); KeyValuePair[] array8 = (from kvp in Bools?.Select((KeyValuePair kvp) => new KeyValuePair(kvp.Key, kvp.Value.GetInt(pars))) where kvp.Value.HasValue select kvp).ToArray() ?? Array.Empty>(); int num3 = obj.Length + array7.Length + array8.Length; pkg.Write((byte)num3); KeyValuePair[] array9 = obj; for (int num2 = 0; num2 < array9.Length; num2++) { KeyValuePair keyValuePair4 = array9[num2]; pkg.Write(keyValuePair4.Key); pkg.Write(keyValuePair4.Value.Value); } array9 = array7; for (int num2 = 0; num2 < array9.Length; num2++) { KeyValuePair keyValuePair5 = array9[num2]; pkg.Write(keyValuePair5.Key); pkg.Write(keyValuePair5.Value.Value); } array9 = array8; for (int num2 = 0; num2 < array9.Length; num2++) { KeyValuePair keyValuePair6 = array9[num2]; pkg.Write(keyValuePair6.Key); pkg.Write(keyValuePair6.Value.Value); } } if (Longs != null) { KeyValuePair[] array10 = (from kvp in Longs select new KeyValuePair(kvp.Key, kvp.Value.Get(pars)) into kvp where kvp.Value.HasValue select kvp).ToArray(); pkg.Write((byte)array10.Count()); KeyValuePair[] array11 = array10; for (int num2 = 0; num2 < array11.Length; num2++) { KeyValuePair keyValuePair7 = array11[num2]; pkg.Write(keyValuePair7.Key); pkg.Write(keyValuePair7.Value.Value); } } if (Strings != null) { KeyValuePair[] array12 = (from kvp in Strings select new KeyValuePair(kvp.Key, kvp.Value.Get(pars)) into kvp where kvp.Value != null select kvp).ToArray(); pkg.Write((byte)array12.Count()); KeyValuePair[] array13 = array12; for (int num2 = 0; num2 < array13.Length; num2++) { KeyValuePair keyValuePair8 = array13[num2]; pkg.Write(keyValuePair8.Key); pkg.Write(keyValuePair8.Value); } } if (ByteArrays != null) { pkg.Write((byte)ByteArrays.Count()); foreach (KeyValuePair byteArray in ByteArrays) { pkg.Write(byteArray.Key); pkg.Write(byteArray.Value); } } if ((int)ConnectionType != 0 && ConnectionHash != 0) { pkg.Write((byte)(int)ConnectionType); pkg.Write(ConnectionHash); } if (Persistent != null) { pkg.Write(Persistent.GetBool(pars) ?? true); } if (Distant != null) { pkg.Write(Distant.GetBool(pars) == true); } if (Priority.HasValue) { pkg.Write((byte)(int)Priority.Value); } } private void RollItems(Dictionary pars) { List? items = Items; if (items != null && items.Count > 0) { string value = ItemValue.LoadItems(pars, Items, ContainerSize, (ItemAmount?.Get(pars)).GetValueOrDefault()); if (Strings == null) { Strings = new Dictionary(); } Strings[ZDOVars.s_items] = DataValue.Simple(value); } } private void HandleConnection(ZDO ownZdo) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Invalid comparison between Unknown and I4 //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (OriginalId == ZDOID.None) { return; } ZDOID uid = ownZdo.m_uid; if (TargetConnectionId != ZDOID.None) { ZDO zDO = ZDOMan.instance.GetZDO(TargetConnectionId); if (zDO != null) { ownZdo.SetConnection(ConnectionType, TargetConnectionId); if ((int)ConnectionType == 1) { zDO.SetConnection((ConnectionType)1, uid); } } return; } KeyValuePair keyValuePair = ZDOExtraData.s_connections.FirstOrDefault((KeyValuePair kvp) => kvp.Value.m_target == OriginalId); if (keyValuePair.Value != null) { ZDO zDO2 = ZDOMan.instance.GetZDO(keyValuePair.Key); if (zDO2 != null) { zDO2.SetConnection(keyValuePair.Value.m_type, uid); } } } private void HandleHashConnection(ZDO ownZdo) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Invalid comparison between Unknown and I4 //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Invalid comparison between Unknown and I4 //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Invalid comparison between Unknown and I4 //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) if (ConnectionHash == 0 || (int)ConnectionType == 0) { return; } ZDOID uid = ownZdo.m_uid; ZDOExtraData.SetConnectionData(uid, ConnectionType, ConnectionHash); ? val = ConnectionType ^ 0x10; bool flag = (ConnectionType & 0x10) == 0; ZDOID val2 = ((IEnumerable)ZDOExtraData.GetAllConnectionZDOIDs((ConnectionType)val)).FirstOrDefault((Func)((ZDOID z) => ZDOExtraData.GetConnectionHashData(z, ConnectionType)?.m_hash == ConnectionHash)); if (val2 == ZDOID.None) { return; } ZDO zDO = ZDOMan.instance.GetZDO(val2); if (zDO != null) { if ((ConnectionType & 3) > 0) { ZDO val3 = (ZDO)(flag ? ((object)ownZdo) : ((object)zDO)); ZDOID val4 = (flag ? val2 : uid); val3.SetConnection((ConnectionType)3, val4); } if ((ConnectionType & 2) > 0) { ZDO val5 = (ZDO)(flag ? ((object)ownZdo) : ((object)zDO)); ZDOID val6 = (flag ? val2 : uid); val5.SetConnection((ConnectionType)2, val6); } if ((ConnectionType & 1) > 0) { zDO.SetConnection((ConnectionType)1, uid); ownZdo.SetConnection((ConnectionType)1, val2); } } } } 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 readonly Dictionary Data = new Dictionary(); public static readonly Dictionary> ValueGroups = new Dictionary>(); public static readonly List DataKeys = new List(); private static readonly Dictionary> DefaultValueGroups = new Dictionary>(); private static readonly int WearNTearHash = StringExtensionMethods.GetStableHashCode("wearntear"); private static readonly int HumanoidHash = StringExtensionMethods.GetStableHashCode("humanoid"); private static readonly int CreatureHash = StringExtensionMethods.GetStableHashCode("creature"); private static readonly int StructureHash = StringExtensionMethods.GetStableHashCode("structure"); public static bool TryGetValueFromGroup(string group, out string value) { int stableHashCode = StringExtensionMethods.GetStableHashCode(group.ToLowerInvariant()); if (!ValueGroups.ContainsKey(stableHashCode)) { value = group; return false; } int index = Random.Range(0, ValueGroups[stableHashCode].Count); value = ValueGroups[stableHashCode][index]; return true; } public static void LoadEntries() { if (!Object.op_Implicit((Object)(object)ZNet.instance)) { return; } Data.Clear(); DataKeys.Clear(); ValueGroups.Clear(); string[] array = Directory.GetFiles(GamePath, "*.yaml").Concat(Directory.GetFiles(ProfilePath, "*.yaml")).Select(Path.GetFullPath) .Distinct() .ToArray(); foreach (string text in array) { foreach (DataData item2 in Yaml.LoadList(text)) { if (item2.value != null) { KeyValuePair keyValuePair = Parse.Kvp(item2.value, ','); int stableHashCode = StringExtensionMethods.GetStableHashCode(keyValuePair.Key.ToLowerInvariant()); if (ValueGroups.ContainsKey(stableHashCode)) { ServerDevcommands.Log.LogWarning((object)("Duplicate value group entry: " + keyValuePair.Key + " at " + text)); } if (!ValueGroups.ContainsKey(stableHashCode)) { ValueGroups[stableHashCode] = new List(); } ValueGroups[stableHashCode].Add(keyValuePair.Value); } if (item2.valueGroup != null && item2.values != null) { int stableHashCode2 = StringExtensionMethods.GetStableHashCode(item2.valueGroup.ToLowerInvariant()); if (ValueGroups.ContainsKey(stableHashCode2)) { ServerDevcommands.Log.LogWarning((object)("Duplicate value group entry: " + item2.valueGroup + " at " + text)); } if (!ValueGroups.ContainsKey(stableHashCode2)) { ValueGroups[stableHashCode2] = new List(); } string[] values = item2.values; foreach (string item in values) { ValueGroups[stableHashCode2].Add(item); } } if (item2.name != null) { int stableHashCode3 = StringExtensionMethods.GetStableHashCode(item2.name); if (Data.ContainsKey(stableHashCode3)) { ServerDevcommands.Log.LogWarning((object)("Duplicate data entry: " + item2.name + " at " + text)); } DataKeys.Add(item2.name); Data[stableHashCode3] = new DataEntry(item2); } } } ServerDevcommands.Log.LogInfo((object)$"Loaded {Data.Count} data entries."); if (ValueGroups.Count > 0) { ServerDevcommands.Log.LogInfo((object)$"Loaded {ValueGroups.Count} value groups."); } LoadDefaultValueGroups(); } public static void Save(PlainDataEntry data, string name, bool profile, bool dump) { string path = Path.Combine(profile ? ProfilePath : GamePath, "data.yaml"); if (!File.Exists(path)) { Directory.CreateDirectory(Path.GetDirectoryName(path)); File.Create(path).Close(); } string text = File.ReadAllText(path); text = text + "\n" + Yaml.Serializer().Serialize((object)new DataData[1] { ToData(data, name, dump) }); File.WriteAllText(path, text); } public static DataData ToData(PlainDataEntry zdo, string name, bool dump) { DataData dataData = new DataData { name = name }; zdo.Write(dataData, dump); return dataData; } private static void LoadDefaultValueGroups() { if (DefaultValueGroups.Count == 0) { Type[] types = ComponentInfo.Types; foreach (Type type in types) { int stableHashCode = StringExtensionMethods.GetStableHashCode(type.Name.ToLowerInvariant()); Dictionary> defaultValueGroups = DefaultValueGroups; string[] array = ComponentInfo.PrefabsByComponent(type.Name); List list = new List(array.Length); list.AddRange(array); defaultValueGroups[stableHashCode] = list; } if (DefaultValueGroups.ContainsKey(HumanoidHash)) { DefaultValueGroups[CreatureHash] = DefaultValueGroups[HumanoidHash]; } if (DefaultValueGroups.ContainsKey(WearNTearHash)) { DefaultValueGroups[StructureHash] = DefaultValueGroups[WearNTearHash]; } } foreach (KeyValuePair> defaultValueGroup in DefaultValueGroups) { if (!ValueGroups.ContainsKey(defaultValueGroup.Key)) { ValueGroups[defaultValueGroup.Key] = defaultValueGroup.Value; } } } public static void SetupWatcher() { if (!Directory.Exists(GamePath)) { Directory.CreateDirectory(GamePath); } if (!Directory.Exists(ProfilePath)) { Directory.CreateDirectory(ProfilePath); } Yaml.SetupWatcher(GamePath, "*", (Action)LoadEntries); if (GamePath != ProfilePath) { Yaml.SetupWatcher(ProfilePath, "*", (Action)LoadEntries); } } } public class DataValue { 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(ZPackage pkg) { return new SimpleIntValue(pkg.ReadInt()); } public static IIntValue Int(string values, HashSet requiredParameters) { bool num = CheckParameters(values, requiredParameters); string[] array = Parse.SplitWithEmpty(values, ','); if (!num && array.Length == 1 && int.TryParse(array[0], out var result)) { return new SimpleIntValue(result); } return new IntValue(array); } public static IFloatValue Float(ZPackage pkg) { return new SimpleFloatValue(pkg.ReadSingle()); } public static IFloatValue Float(string values, HashSet requiredParameters) { bool num = CheckParameters(values, requiredParameters); string[] array = Parse.SplitWithEmpty(values, ','); float value = default(float); if (!num && array.Length == 1 && Parse.TryFloat(array[0], ref value)) { return new SimpleFloatValue(value); } return new FloatValue(array); } public static ILongValue Long(ZPackage pkg) { return new SimpleLongValue(pkg.ReadLong()); } public static ILongValue Long(string values, HashSet requiredParameters) { bool num = CheckParameters(values, requiredParameters); string[] array = Parse.SplitWithEmpty(values, ','); if (!num && array.Length == 1 && long.TryParse(array[0], out var result)) { return new SimpleLongValue(result); } return new LongValue(array); } public static IStringValue String(ZPackage pkg) { return new SimpleStringValue(pkg.ReadString()); } public static IStringValue String(string values, HashSet requiredParameters) { bool num = CheckParameters(values, requiredParameters); string[] array = Parse.SplitWithEscape(values, ','); if (!num && array.Length == 1) { return new SimpleStringValue(array[0]); } return new StringValue(array); } public static IBoolValue Bool(bool value) { return new SimpleBoolValue(value); } public static IBoolValue Bool(ZPackage pkg) { return new SimpleBoolValue(pkg.ReadBool()); } public static IBoolValue Bool(string values, HashSet requiredParameters) { bool num = CheckParameters(values, requiredParameters); string[] array = Parse.SplitWithEmpty(values, ','); if (!num && array.Length == 1 && bool.TryParse(array[0], out var result)) { return new SimpleBoolValue(result); } return new BoolValue(array); } public static IHashValue Hash(string value) { return new SimpleHashValue(value); } public static IHashValue Hash(string values, HashSet requiredParameters) { bool num = CheckParameters(values, requiredParameters); string[] array = Parse.SplitWithEmpty(values, ','); if (!num && array.Length == 1) { return new SimpleHashValue(array[0]); } return new HashValue(array); } public static IVector3Value Vector3(ZPackage pkg) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return new SimpleVector3Value(pkg.ReadVector3()); } public static IVector3Value Vector3(string values, HashSet requiredParameters) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) bool num = CheckParameters(values, requiredParameters); string[] values2 = Parse.SplitWithEscape(values, ','); Vector3? val = Parse.VectorXZYNull(values); if (!num && val.HasValue) { return new SimpleVector3Value(val.Value); } return new Vector3Value(values2); } public static IQuaternionValue Quaternion(ZPackage pkg) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return new SimpleQuaternionValue(pkg.ReadQuaternion()); } public static IQuaternionValue Quaternion(string values, HashSet requiredParameters) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) bool num = CheckParameters(values, requiredParameters); string[] values2 = Parse.SplitWithEscape(values, ','); Quaternion? val = Parse.AngleYXZNull(values); if (!num && val.HasValue) { return new SimpleQuaternionValue(val.Value); } return new QuaternionValue(values2); } private static bool CheckParameters(string value, HashSet requiredParameters) { if (!value.Contains("<") || !value.Contains(">")) { return false; } string[] array = value.Split('<', '>'); for (int i = 1; i < array.Length; i += 2) { requiredParameters.Add(array[i]); } return array.Length > 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(Dictionary pars) { string text = RollValue(); if (text == null || text == "") { return null; } return ReplaceParameters(text, pars); } protected string? GetValue() { string text = RollValue(); if (text != null && !(text == "")) { return text; } return null; } protected string[] GetAllValues(Dictionary pars) { return (from v in values select ReplaceParameters(v, pars) into v where v != null && v != " pars) { foreach (KeyValuePair par in pars) { value = value.Replace(par.Key, par.Value); } return value; } } public class ItemValue { public IStringValue Prefab = DataValue.String(data.prefab, requiredParameters); public float Chance = data.chance; public IIntValue Stack = DataValue.Int(data.stack, requiredParameters); public IFloatValue Durability = DataValue.Float(data.durability, requiredParameters); public string Position = data.pos; private Vector2i RolledPosition = Parse.Vector2Int(data.pos); public IBoolValue Equipped = DataValue.Bool(data.equipped, requiredParameters); public IIntValue Quality = DataValue.Int(data.quality, requiredParameters); public IIntValue Variant = DataValue.Int(data.variant, requiredParameters); public ILongValue CrafterID = DataValue.Long(data.crafterID, requiredParameters); public IStringValue CrafterName = DataValue.String(data.crafterName, requiredParameters); public Dictionary CustomData = data.customData?.ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => DataValue.String(kvp.Value, requiredParameters)) ?? new Dictionary(); public IIntValue WorldLevel = DataValue.Int(data.worldLevel, requiredParameters); public IBoolValue PickedUp = DataValue.Bool(data.pickedUp, requiredParameters); private string RolledPrefab = ""; public ItemValue(ItemData data, HashSet requiredParameters) { }//IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) public static string LoadItems(Dictionary 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_0026: 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) ZPackage val = new ZPackage(); val.Write(106); items = Generate(pars, items, (Vector2i)(((??)size) ?? new Vector2i(0, 0)), amount); val.Write(items.Count); foreach (ItemValue item in items) { item.Write(pars, val); } return val.GetBase64(); } private static List Generate(Dictionary 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(Dictionary 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(Dictionary 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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_003f: Unknown result type (might be due to invalid IL or missing references) int num = ((size.x == 0) ? 4 : size.x); int num2 = ((size.y == 0) ? 2 : size.y); Vector2i val = default(Vector2i); for (int i = 0; i < num2; i++) { for (int j = 0; j < num; j++) { ((Vector2i)(ref val))..ctor(j, i); if (!inventory.ContainsKey(val)) { return val; } } } return null; } public bool RollPrefab(Dictionary pars) { RolledPrefab = Prefab.Get(pars) ?? ""; return RolledPrefab != ""; } public bool RollChance() { if (!(Chance >= 1f)) { return Random.value <= Chance; } return true; } public bool Roll(Dictionary pars) { if (RollChance()) { return RollPrefab(pars); } return false; } public void Write(Dictionary pars, ZPackage pkg) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) pkg.Write(RolledPrefab); pkg.Write(Stack.Get(pars) ?? 1); pkg.Write(Durability.Get(pars) ?? 100f); pkg.Write(RolledPosition); pkg.Write(Equipped.GetBool(pars) == true); pkg.Write(Quality.Get(pars) ?? 1); pkg.Write(Variant.Get(pars) ?? 1); pkg.Write(CrafterID.Get(pars).GetValueOrDefault()); pkg.Write(CrafterName.Get(pars) ?? ""); pkg.Write(CustomData?.Count ?? 0); foreach (KeyValuePair item in CustomData ?? new Dictionary()) { pkg.Write(item.Key); pkg.Write(item.Value.Get(pars)); } pkg.Write(WorldLevel.Get(pars).GetValueOrDefault()); pkg.Write(PickedUp.GetBool(pars) == true); } } public class FakeZDO { public readonly PlainDataEntry Data = new PlainDataEntry(zdo); public int Prefab = zdo.m_prefab; public Vector3 Position = zdo.m_position; public Vector3 Rotation = zdo.m_rotation; public ZDOID Id = zdo.m_uid; public FakeZDO(ZDO zdo) { }//IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0037: Unknown result type (might be due to invalid IL or missing references) public ZDO Create() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ZDO val = ZDOMan.instance.CreateNewZDO(Position, Prefab); Write(val); val.DataRevision = 0u; val.IncreaseDataRevision(); return val; } public void Write(ZDO zdo) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) zdo.m_prefab = Prefab; zdo.m_position = Position; zdo.m_rotation = Rotation; Data.Write(zdo); } public void Destroy() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ZDO zDO = ZDOMan.instance.GetZDO(Id); if (zDO != null) { if (!zDO.IsOwner()) { zDO.SetOwner(ZDOMan.instance.m_sessionID); } ZDOMan.instance.DestroyZDO(zDO); } } } public class PlainDataEntry { public Dictionary? Strings; public Dictionary? Floats; public Dictionary? Ints; public Dictionary? Longs; public Dictionary? Vecs; public Dictionary? Quats; public Dictionary? ByteArrays; public ConnectionType ConnectionType; public int ConnectionHash; public ZDOID OriginalId = ZDOID.None; public ZDOID TargetConnectionId = ZDOID.None; public bool Distant; public bool Persistent = true; public ObjectType Priority; private static readonly HashSet HashKeys = new HashSet { ZDOVars.s_helmetItem, ZDOVars.s_chestItem, ZDOVars.s_legItem, ZDOVars.s_shoulderItem, ZDOVars.s_utilityItem, ZDOVars.s_leftItem, ZDOVars.s_rightItem }; public PlainDataEntry(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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) Load(zdo); } public void Load(ZDO zdo) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: 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_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = zdo.m_uid; Floats = (ZDOExtraData.s_floats.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_floats[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value) : null); Ints = (ZDOExtraData.s_ints.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_ints[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value) : null); Longs = (ZDOExtraData.s_longs.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_longs[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value) : null); Strings = (ZDOExtraData.s_strings.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_strings[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value) : null); Vecs = (ZDOExtraData.s_vec3.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_vec3[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value) : null); Quats = (ZDOExtraData.s_quats.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_quats[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value) : null); ByteArrays = (ZDOExtraData.s_byteArrays.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_byteArrays[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value) : null); if (ZDOExtraData.s_connectionsHashData.TryGetValue(uid, out var value)) { ConnectionType = value.m_type; ConnectionHash = value.m_hash; } OriginalId = uid; if (ZDOExtraData.s_connections.TryGetValue(uid, out var value2) && value2.m_target != ZDOID.None) { TargetConnectionId = value2.m_target; ConnectionType = value2.m_type; } Distant = zdo.Distant; Persistent = zdo.Persistent; Priority = zdo.Type; } public void Write(DataData data, bool all) { //IL_02a6: 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_0332: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_0349: 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_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) data.floats = Floats?.Select((KeyValuePair pair) => $"{ZDOKeys.Convert(pair.Key)}, {pair.Value}").ToArray(); data.ints = (from pair in Ints?.Where((KeyValuePair kvp) => !HashKeys.Contains(kvp.Key)) select $"{ZDOKeys.Convert(pair.Key)}, {pair.Value}").ToArray(); string[]? ints = data.ints; if (ints != null && ints.Length == 0) { data.ints = null; } data.hashes = Ints?.Where((KeyValuePair kvp) => HashKeys.Contains(kvp.Key)).Select(delegate(KeyValuePair pair) { string text2 = ZDOKeys.Convert(pair.Key); GameObject prefab2 = ZNetScene.instance.GetPrefab(pair.Value); return text2 + ", " + (((prefab2 != null) ? ((Object)prefab2).name : null) ?? pair.Value.ToString()); }).ToArray(); string[]? hashes = data.hashes; if (hashes != null && hashes.Length == 0) { data.hashes = null; } data.longs = Longs?.Select((KeyValuePair pair) => $"{ZDOKeys.Convert(pair.Key)}, {pair.Value}").ToArray(); data.strings = Strings?.Select((KeyValuePair pair) => ZDOKeys.Convert(pair.Key) + ", " + Serialize(pair.Value)).ToArray(); data.vecs = Vecs?.Select((KeyValuePair pair) => ZDOKeys.Convert(pair.Key) + ", " + Serialize(pair.Value)).ToArray(); data.quats = Quats?.Select((KeyValuePair pair) => ZDOKeys.Convert(pair.Key) + ", " + Serialize(pair.Value)).ToArray(); data.bytes = ByteArrays?.Select((KeyValuePair pair) => ZDOKeys.Convert(pair.Key) + ", " + Convert.ToBase64String(pair.Value)).ToArray(); string text = Strings?.FirstOrDefault((KeyValuePair kvp) => kvp.Key == ZDOVars.s_items).Value; if (text != null) { data.items = GetItems(text); } if ((int)ConnectionType != 0 && ConnectionHash != 0) { data.connection = $"{ConnectionType}, {ConnectionHash}"; } if (all) { data.persistent = (Persistent ? "true" : "false"); data.distant = (Distant ? "true" : "false"); data.priority = ((object)Unsafe.As(ref Priority)/*cast due to .constrained prefix*/).ToString(); return; } bool flag = false; bool flag2 = true; ObjectType val = (ObjectType)0; if (OriginalId != ZDOID.None) { ZDO zDO = ZDOMan.instance.GetZDO(OriginalId); GameObject prefab = ZNetScene.instance.GetPrefab(zDO.m_prefab); ZNetView val2 = ((prefab != null) ? prefab.GetComponent() : null); if ((Object)(object)val2 != (Object)null) { flag = val2.m_distant; flag2 = val2.m_persistent; val = val2.m_type; } } if (Persistent != flag2) { data.persistent = (Persistent ? "true" : "false"); } if (Distant != flag) { data.distant = (Distant ? "true" : "false"); } if (Priority != val) { data.priority = ((object)Unsafe.As(ref Priority)/*cast due to .constrained prefix*/).ToString(); } } private static ItemData[] GetItems(string encoded) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) ZPackage val = new ZPackage(encoded); if (val.ReadInt() != 106) { return Array.Empty(); } int num = val.ReadInt(); ItemData[] array = new ItemData[num]; for (int i = 0; i < num; i++) { string prefab = val.ReadString(); int num2 = val.ReadInt(); float value = val.ReadSingle(); Vector2i val2 = val.ReadVector2i(); bool flag = val.ReadBool(); int num3 = val.ReadInt(); int num4 = val.ReadInt(); long num5 = val.ReadLong(); string crafterName = val.ReadString(); Dictionary dictionary = new Dictionary(); int num6 = val.ReadInt(); for (int j = 0; j < num6; j++) { dictionary[val.ReadString()] = val.ReadString(); } int num7 = val.ReadInt(); bool flag2 = val.ReadBool(); if (num6 > 0) { _ = ", " + string.Join(", ", dictionary.Select((KeyValuePair kvp) => kvp.Key + ": " + kvp.Value)); } array[i] = new ItemData { pos = $"{val2.x}, {val2.y}", prefab = prefab, stack = num2.ToString(), quality = num3.ToString(), variant = num4.ToString(), customData = ((dictionary.Count > 0) ? dictionary : null), equipped = (flag ? "true" : "false"), durability = Serialize(value), crafterID = num5.ToString(), crafterName = crafterName, pickedUp = (flag2 ? "true" : "false"), worldLevel = num7.ToString() }; } return array; } private static string Serialize(string? str) { if (str != null && !(str == "")) { if (!str.Contains(",")) { return str; } return "\"" + str + "\""; } return "\"\""; } private static string Serialize(Quaternion quat) { //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) //IL_0008: 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_004c: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) Vector3 eulerAngles = ((Quaternion)(ref quat)).eulerAngles; if (eulerAngles.x == 0f && eulerAngles.z == 0f) { return Serialize(eulerAngles.y); } return Serialize(eulerAngles.y) + "," + Serialize(eulerAngles.x) + "," + Serialize(eulerAngles.z); } private static string Serialize(float value) { return value.ToString("0.#####", NumberFormatInfo.InvariantInfo); } private static string Serialize(Vector3 vec) { //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 Serialize(vec.x) + "," + Serialize(vec.z) + "," + Serialize(vec.y); } public void Write(ZDO zdo) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0104: 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_00c4: 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_0127: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: 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_025a: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) ZDOID uid = zdo.m_uid; Dictionary? floats = Floats; if (floats != null && floats.Count > 0) { ZDOHelper.Init(ZDOExtraData.s_floats, uid); foreach (KeyValuePair @float in Floats) { ZDOExtraData.s_floats[uid].SetValue(@float.Key, @float.Value); } } Dictionary? vecs = Vecs; if (vecs != null && vecs.Count > 0) { ZDOHelper.Init(ZDOExtraData.s_vec3, uid); foreach (KeyValuePair vec in Vecs) { ZDOExtraData.s_vec3[uid].SetValue(vec.Key, vec.Value); } } Dictionary? quats = Quats; if (quats != null && quats.Count > 0) { ZDOHelper.Init(ZDOExtraData.s_quats, uid); foreach (KeyValuePair quat in Quats) { ZDOExtraData.s_quats[uid].SetValue(quat.Key, quat.Value); } } Dictionary? ints = Ints; if (ints != null && ints.Count > 0) { ZDOHelper.Init(ZDOExtraData.s_ints, uid); foreach (KeyValuePair @int in Ints) { ZDOExtraData.s_ints[uid].SetValue(@int.Key, @int.Value); } } Dictionary? longs = Longs; if (longs != null && longs.Count > 0) { ZDOHelper.Init(ZDOExtraData.s_longs, uid); foreach (KeyValuePair @long in Longs) { ZDOExtraData.s_longs[uid].SetValue(@long.Key, @long.Value); } } Dictionary? strings = Strings; if (strings != null && strings.Count > 0) { ZDOHelper.Init(ZDOExtraData.s_strings, uid); foreach (KeyValuePair @string in Strings) { ZDOExtraData.s_strings[uid].SetValue(@string.Key, @string.Value); } } 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); } } HandleConnection(zdo); HandleHashConnection(zdo); zdo.Distant = Distant; zdo.Persistent = Persistent; zdo.Type = Priority; } private void HandleConnection(ZDO ownZdo) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Invalid comparison between Unknown and I4 //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (OriginalId == ZDOID.None) { return; } ZDOID uid = ownZdo.m_uid; if (TargetConnectionId != ZDOID.None) { ZDO zDO = ZDOMan.instance.GetZDO(TargetConnectionId); if (zDO != null) { ownZdo.SetConnection(ConnectionType, TargetConnectionId); if ((int)ConnectionType == 1) { zDO.SetConnection((ConnectionType)1, uid); } } return; } KeyValuePair keyValuePair = ZDOExtraData.s_connections.FirstOrDefault((KeyValuePair kvp) => kvp.Value.m_target == OriginalId); if (keyValuePair.Value != null) { ZDO zDO2 = ZDOMan.instance.GetZDO(keyValuePair.Key); if (zDO2 != null) { zDO2.SetConnection(keyValuePair.Value.m_type, uid); } } } private void HandleHashConnection(ZDO ownZdo) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Invalid comparison between Unknown and I4 //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Invalid comparison between Unknown and I4 //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Invalid comparison between Unknown and I4 //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Invalid comparison between Unknown and I4 //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) if (ConnectionHash == 0 || (int)ConnectionType == 0) { return; } ZDOID uid = ownZdo.m_uid; ZDOExtraData.SetConnectionData(uid, ConnectionType, ConnectionHash); ? val = ConnectionType ^ 0x10; bool flag = (ConnectionType & 0x10) == 0; ZDOID val2 = ((IEnumerable)ZDOExtraData.GetAllConnectionZDOIDs((ConnectionType)val)).FirstOrDefault((Func)((ZDOID z) => ZDOExtraData.GetConnectionHashData(z, ConnectionType)?.m_hash == ConnectionHash)); if (val2 == ZDOID.None) { return; } ZDO zDO = ZDOMan.instance.GetZDO(val2); if (zDO != null) { if ((ConnectionType & 3) > 0) { ZDO val3 = (ZDO)(flag ? ((object)ownZdo) : ((object)zDO)); ZDOID val4 = (flag ? val2 : uid); val3.SetConnection((ConnectionType)3, val4); } if ((ConnectionType & 2) > 0) { ZDO val5 = (ZDO)(flag ? ((object)ownZdo) : ((object)zDO)); ZDOID val6 = (flag ? val2 : uid); val5.SetConnection((ConnectionType)2, val6); } if ((ConnectionType & 1) > 0) { zDO.SetConnection((ConnectionType)1, uid); ownZdo.SetConnection((ConnectionType)1, val2); } } } } public class BoolValue : AnyValue, IBoolValue { public BoolValue(string[] values) : base(values) { } public int? GetInt(Dictionary pars) { bool? flag = GetBool(pars); if (!flag.HasValue) { return null; } return flag.Value ? 1 : 0; } public bool? GetBool(Dictionary pars) { return Parse.BoolNull(GetValue(pars)); } public bool? Match(Dictionary pars, bool value) { bool flag = true; string[] values = values; foreach (string value2 in values) { string text = ReplaceParameters(value2, pars); if (text != null) { flag = false; if (Parse.BoolNull(text) == value) { return true; } } } if (!flag) { return false; } return null; } } public class SimpleBoolValue(bool value) : IBoolValue { private readonly bool Value = value; public int? GetInt(Dictionary pars) { return value ? 1 : 0; } public bool? GetBool(Dictionary pars) { return value; } public bool? Match(Dictionary pars, bool value) { return value == value; } } public interface IBoolValue { int? GetInt(Dictionary pars); bool? GetBool(Dictionary pars); bool? Match(Dictionary pars, bool value); } public class FloatValue : AnyValue, IFloatValue { public FloatValue(string[] values) : base(values) { } public float? Get(Dictionary pars) { string value = GetValue(pars); if (value == null) { return null; } if (!value.Contains(";")) { return Calculator.EvaluateFloat(value); } string[] array = value.Split(new char[1] { ';' }); if (array.Length < 2) { throw new InvalidOperationException("Invalid range format: " + value); } float? num = Calculator.EvaluateFloat(array[0]); float? num2 = Calculator.EvaluateFloat(array[1]); if (!num.HasValue || !num2.HasValue) { return null; } float? num3; if (array.Length < 3 || array[2] == "") { num3 = Random.Range(num.Value, num2.Value); } else { float? num4 = Calculator.EvaluateFloat(array[2]); if (!num4.HasValue) { num3 = Random.Range(num.Value, num2.Value); } else { int num5 = (int)((num2.Value - num.Value) / num4.Value); int num6 = Random.Range(0, num5 + 1); num3 = num + (float)num6 * num4; } } if (array.Length < 4) { return num3; } return Calculator.EvaluateFloat(array[3].Replace("", num3?.ToString(CultureInfo.InvariantCulture))); } public bool? Match(Dictionary pars, float value) { bool flag = true; string[] values = values; foreach (string value2 in values) { string text = ReplaceParameters(value2, pars); if (!text.Contains(";")) { float? num = Calculator.EvaluateFloat(text); if (num.HasValue) { flag = false; if (Helper.Approx(num.Value, value)) { return true; } } continue; } string[] array = text.Split(new char[1] { ';' }); if (array.Length < 2) { throw new InvalidOperationException("Invalid range format: " + text); } float? num2 = Calculator.EvaluateFloat(array[0]); float? num3 = Calculator.EvaluateFloat(array[1]); if (!num2.HasValue || !num3.HasValue) { continue; } if (array.Length < 3) { flag = false; if (Helper.ApproxBetween(value, num2.Value, num3.Value)) { return true; } continue; } if (array.Length < 4) { float? num4 = Calculator.EvaluateFloat(array[2]); if (!num4.HasValue) { continue; } flag = false; int num5 = (int)((num3.Value - num2.Value) / num4.Value); for (int j = 0; j <= num5; j++) { if (Helper.Approx(num2.Value + (float)j * num4.Value, value)) { return true; } } continue; } if (array[2] == "") { float? num6 = Calculator.EvaluateFloat(array[3].Replace("", num2?.ToString(CultureInfo.InvariantCulture))); float? num7 = Calculator.EvaluateFloat(array[3].Replace("", num3?.ToString(CultureInfo.InvariantCulture))); if (num6.HasValue && num7.HasValue) { flag = false; if (Helper.ApproxBetween(value, num6.Value, num7.Value)) { return true; } } continue; } float? num8 = Calculator.EvaluateFloat(array[2]); if (!num8.HasValue) { continue; } flag = false; int num9 = (int)((num3.Value - num2.Value) / num8.Value); for (int k = 0; k <= num9; k++) { float? num10 = num2; float num11 = k; float? num12 = num8; float? num13 = Calculator.EvaluateFloat(array[3].Replace("", (num10 + num11 * num12)?.ToString(CultureInfo.InvariantCulture))); if (num13.HasValue && Helper.Approx(num13.Value, value)) { return true; } } } if (!flag) { return false; } return null; } } public class SimpleFloatValue(float value) : IFloatValue { private readonly float Value = value; public float? Get(Dictionary pars) { return value; } public bool? Match(Dictionary pars, float value) { return value == value; } } public interface IFloatValue { float? Get(Dictionary pars); bool? Match(Dictionary pars, float value); } public class HashValue : AnyValue, IHashValue { public HashValue(string[] values) : base(values) { } public int? Get(Dictionary pars) { string? value = GetValue(pars); if (value == null) { return null; } return StringExtensionMethods.GetStableHashCode(value); } public bool? Match(Dictionary pars, int value) { string[] allValues = GetAllValues(pars); if (allValues.Length == 0) { return null; } return allValues.Any((string v) => StringExtensionMethods.GetStableHashCode(v) == value); } } public class SimpleHashValue : IHashValue { private readonly int Value = StringExtensionMethods.GetStableHashCode(value); public SimpleHashValue(string value) { } public int? Get(Dictionary pars) { return Value; } public bool? Match(Dictionary pars, int value) { return Value == value; } } public interface IHashValue { int? Get(Dictionary pars); bool? Match(Dictionary pars, int value); } public class IntValue : AnyValue, IIntValue { public IntValue(string[] values) : base(values) { } public int? Get(Dictionary pars) { string value = GetValue(pars); if (value == null) { return null; } if (!value.Contains(";")) { return Calculator.EvaluateInt(value); } string[] array = value.Split(new char[1] { ';' }); if (array.Length < 2) { throw new InvalidOperationException("Invalid range format: " + value); } int? num = Calculator.EvaluateInt(array[0]); int? num2 = Calculator.EvaluateInt(array[1]); if (!num.HasValue || !num2.HasValue) { return null; } int? result; if (array.Length < 3 || array[2] == "") { result = Random.Range(num.Value, num2.Value + 1); } else { int? num3 = Calculator.EvaluateInt(array[2]); if (!num3.HasValue) { result = Random.Range(num.Value, num2.Value + 1); } else { int num4 = Random.Range(0, ((num2 - num) / num3).Value + 1); result = num + num4 * num3; } } if (array.Length < 4) { return result; } return Calculator.EvaluateInt(array[3].Replace("", result.ToString())); } public bool? Match(Dictionary pars, int value) { bool flag = true; string[] values = values; foreach (string value2 in values) { string text = ReplaceParameters(value2, pars); if (!text.Contains(";")) { int? num = Calculator.EvaluateInt(text); if (num.HasValue) { flag = false; if (num.Value == value) { return true; } } continue; } string[] array = text.Split(new char[1] { ';' }); if (array.Length < 2) { throw new InvalidOperationException("Invalid range format: " + text); } int? num2 = Calculator.EvaluateInt(array[0]); int? num3 = Calculator.EvaluateInt(array[1]); if (!num2.HasValue || !num3.HasValue) { continue; } if (array.Length < 3) { flag = false; if (value >= num2.Value && value <= num3.Value) { return true; } continue; } if (array.Length < 4) { int? num4 = Calculator.EvaluateInt(array[2]); if (!num4.HasValue) { continue; } flag = false; int num5 = (num3.Value - num2.Value) / num4.Value; for (int j = 0; j <= num5; j++) { if (num2.Value + j * num4.Value == value) { return true; } } continue; } if (array[2] == "") { int? num6 = Calculator.EvaluateInt(array[3].Replace("", num2?.ToString(CultureInfo.InvariantCulture))); int? num7 = Calculator.EvaluateInt(array[3].Replace("", num3?.ToString(CultureInfo.InvariantCulture))); if (num6.HasValue && num7.HasValue) { flag = false; if (value >= num6.Value && value <= num7.Value) { return true; } } continue; } int? num8 = Calculator.EvaluateInt(array[2]); if (!num8.HasValue) { continue; } flag = false; int num9 = (num3.Value - num2.Value) / num8.Value; for (int k = 0; k <= num9; k++) { int? num10 = num2; int num11 = k; int? num12 = num8; int? num13 = Calculator.EvaluateInt(array[3].Replace("", (num10 + num11 * num12)?.ToString(CultureInfo.InvariantCulture))); if (num13.HasValue && num13.Value == value) { return true; } } } if (!flag) { return false; } return null; } } public class SimpleIntValue(int value) : IIntValue { private readonly int Value = value; public int? Get(Dictionary pars) { return value; } public bool? Match(Dictionary pars, int value) { return value == value; } } public interface IIntValue { int? Get(Dictionary pars); bool? Match(Dictionary pars, int value); } public class LongValue : AnyValue, ILongValue { public LongValue(string[] values) : base(values) { } public long? Get(Dictionary pars) { string value = GetValue(pars); if (value == null) { return null; } if (!value.Contains(";")) { return Calculator.EvaluateLong(value); } string[] array = value.Split(new char[1] { ';' }); if (array.Length < 2) { throw new InvalidOperationException("Invalid range format: " + value); } long? num = Calculator.EvaluateLong(array[0]); long? num2 = Calculator.EvaluateLong(array[1]); if (!num.HasValue || !num2.HasValue) { return null; } long? result; if (array.Length < 3 || array[2] == "") { result = (long)(Random.value * (float)(num2.Value - num.Value) + (float)num.Value); } else { long? num3 = Calculator.EvaluateLong(array[2]); if (!num3.HasValue) { result = (long)(Random.value * (float)(num2.Value - num.Value) + (float)num.Value); } else { float num4 = Random.Range(0f, (float)(((num2 - num) / num3).Value + 1)); result = (long?)((float?)num + num4 * (float?)num3); } } if (array.Length < 4) { return result; } return Calculator.EvaluateLong(array[3].Replace("", result.ToString())); } public bool? Match(Dictionary pars, long value) { bool flag = true; string[] values = values; foreach (string value2 in values) { string text = ReplaceParameters(value2, pars); if (!text.Contains(";")) { long? num = Calculator.EvaluateLong(text); if (num.HasValue) { flag = false; if (num.Value == value) { return true; } } continue; } string[] array = text.Split(new char[1] { ';' }); if (array.Length < 2) { throw new InvalidOperationException("Invalid range format: " + text); } long? num2 = Calculator.EvaluateLong(array[0]); long? num3 = Calculator.EvaluateLong(array[1]); if (!num2.HasValue || !num3.HasValue) { continue; } if (array.Length < 3) { flag = false; if (value >= num2.Value && value <= num3.Value) { return true; } continue; } if (array.Length < 4) { long? num4 = Calculator.EvaluateLong(array[2]); if (!num4.HasValue) { continue; } flag = false; long num5 = (num3.Value - num2.Value) / num4.Value; for (int j = 0; j <= num5; j++) { if (num2.Value + j * num4.Value == value) { return true; } } continue; } if (array[2] == "") { long? num6 = Calculator.EvaluateLong(array[3].Replace("", num2?.ToString(CultureInfo.InvariantCulture))); long? num7 = Calculator.EvaluateLong(array[3].Replace("", num3?.ToString(CultureInfo.InvariantCulture))); if (num6.HasValue && num7.HasValue) { flag = false; if (value >= num6.Value && value <= num7.Value) { return true; } } continue; } long? num8 = Calculator.EvaluateLong(array[2]); if (!num8.HasValue) { continue; } flag = false; long num9 = (num3.Value - num2.Value) / num8.Value; for (int k = 0; k <= num9; k++) { long? num10 = num2; long num11 = k; long? num12 = num8; long? num13 = Calculator.EvaluateLong(array[3].Replace("", (num10 + num11 * num12)?.ToString(CultureInfo.InvariantCulture))); if (num13.HasValue && num13.Value == value) { return true; } } } if (!flag) { return false; } return null; } } public class SimpleLongValue(long value) : ILongValue { private readonly long Value = value; public long? Get(Dictionary pars) { return value; } public bool? Match(Dictionary pars, long value) { return value == value; } } public interface ILongValue { long? Get(Dictionary pars); bool? Match(Dictionary pars, long value); } public class QuaternionValue : AnyValue, IQuaternionValue { public QuaternionValue(string[] values) : base(values) { } public Quaternion? Get(Dictionary pars) { string value = GetValue(pars); if (value != null) { return Parse.AngleYXZNull(value); } return null; } public bool? Match(Dictionary pars, Quaternion value) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) string[] allValues = GetAllValues(pars); if (allValues.Length == 0) { return null; } return allValues.Any(delegate(string v) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Quaternion? val = Parse.AngleYXZNull(v); Quaternion val2 = value; return val.HasValue && val.GetValueOrDefault() == val2; }); } } public class SimpleQuaternionValue(Quaternion value) : IQuaternionValue { private readonly Quaternion Value = value; public Quaternion? Get(Dictionary pars) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return value; } public bool? Match(Dictionary pars, Quaternion value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return value == value; } } public interface IQuaternionValue { Quaternion? Get(Dictionary pars); bool? Match(Dictionary pars, Quaternion value); } public class StringValue : AnyValue, IStringValue { public StringValue(string[] values) : base(values) { } public string? Get(Dictionary pars) { return GetValue(pars); } public bool? Match(Dictionary pars, string value) { string[] allValues = GetAllValues(pars); if (allValues.Length == 0) { return null; } return allValues.Contains(value); } } public class SimpleStringValue(string value) : IStringValue { private readonly string Value = value; public string? Get(Dictionary pars) { return value; } public bool? Match(Dictionary pars, string value) { return value == value; } } public interface IStringValue { string? Get(Dictionary pars); bool? Match(Dictionary pars, string value); } public class Vector3Value : AnyValue, IVector3Value { public Vector3Value(string[] values) : base(values) { } public Vector3? Get(Dictionary pars) { string value = GetValue(pars); if (value != null) { return Parse.VectorXZYNull(value); } return null; } public bool? Match(Dictionary pars, Vector3 value) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) string[] allValues = GetAllValues(pars); if (allValues.Length == 0) { return null; } return allValues.Any(delegate(string v) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Vector3? val = Parse.VectorXZYNull(v); Vector3 val2 = value; return val.HasValue && val.GetValueOrDefault() == val2; }); } } public class SimpleVector3Value(Vector3 value) : IVector3Value { private readonly Vector3 Value = value; public Vector3? Get(Dictionary pars) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return value; } public bool? Match(Dictionary pars, Vector3 value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return value == value; } } public interface IVector3Value { Vector3? Get(Dictionary pars); bool? Match(Dictionary pars, Vector3 value); } public class ZDOKeys { private static string[]? knownKeys; private static readonly string[] StaticKeys = new string[153] { "alive_time", "attachJoint", "body_avel", "body_vel", "bosscount", "emote_oneshot", "HaveSaddle", "haveTarget", "IsBlocking", "max_health", "picked_time", "relPos", "relRot", "scale", "scaleScalar", "vel", "lastWorldTime", "spawntime", "spawnpoint", "HasFields", "user_u", "user_i", "RodOwner_u", "RodOwner_i", "CatchID_u", "CatchID_i", "target_u", "target_i", "rooms", "spawn_id_u", "spawn_id_i", "parent_id_u", "parent_id_i", "CL&LC effect", "CL&LC infusion", "override_amount", "override_attacks", "override_biome", "override_boss", "override_collision", "override_compendium", "override_component", "override_conversion", "override_cover_offset", "override_data", "override_delay", "override_destroy", "override_discover", "override_dungeon_enter_hover", "override_dungeon_enter_text", "override_dungeon_exit_hover", "override_dungeon_exit_text", "override_dungeon_weather", "override_effect", "override_event", "override_faction", "override_fall", "override_far_radius", "override_fuel", "override_fuel_effect", "override_globalkey", "override_growth", "override_health", "override_input_effect", "override_interact", "override_item", "override_item_offset", "override_item_stand_prefix", "override_item_stand_range", "override_items", "override_level_chance", "override_maximum_amount", "override_maximum_cover", "override_maximum_fuel", "override_maximum_level", "override_max_near", "override_max_total", "override_minimum_amount", "override_minimum_level", "override_name", "override_near_radius", "override_output_effect", "override_pickable_spawn", "override_pickable_respawn", "override_render", "override_resistances", "override_respawn", "override_restrict", "override_smoke", "override_spawn", "override_spawn_condition", "override_spawn_effect", "override_spawn_max_y", "override_spawn_offset", "override_spawn_radius", "override_spawnarea_spawn", "override_spawnarea_respawn", "override_spawn_item", "override_start_effect", "override_text", "override_text_biome", "override_text_check", "override_text_extract", "override_text_happy", "override_text_sleep", "override_text_space", "override_topic", "override_trigger_distance", "override_trigger_noise", "override_unlock", "override_use_effect", "override_water", "override_wear", "override_weather", "KGmarketNPC", "KGnpcProfile", "KGnpcModelOverride", "KGnpcNameOverride", "KGnpcDialogue", "KGleftItem", "KGrightItem", "KGhelmetItem", "KGchestItem", "KGlegsItem", "KGcapeItem", "KGhairItem", "KGhairItemColor", "KGLeftItemBack", "KGRightItemBack", "KGinteractAnimation", "KGgreetingAnimation", "KGbyeAnimation", "KGgreetingText", "KGbyeText", "KGskinColor", "KGcraftingAnimation", "KGbeardItem", "KGbeardColor", "KGinteractSound", "KGtextSize", "KGtextHeight", "KGperiodicAnimation", "KGperiodicAnimationTime", "KGperiodicSound", "KGperiodicSoundTime", "KGnpcScale", "itemstand_hide", "itemstand_offset", "itemstand_rotation", "itemstand_scale", "steamName", "steamID", "xray_created" }; private static readonly string[] AnimationKeys = new string[36] { "alert", "footstep", "forward_speed", "sideway_speed", "anim_speed", "statef", "statei", "blocking", "attack", "flapping", "falling", "onGround", "intro", "crouching", "encumbered", "equipping", "attach_bed", "attach_chair", "attach_throne", "attach_sitship", "attach_mast", "attach_dragon", "attach_lox", "bow_aim", "reload_crossbow", "crafting", "visible", "turn_speed", "idle", "flying", "body_forward_speed", "inWater", "onGround", "minoraction", "minoraction_fast", "emote" }; private static Dictionary keyToHash = new Dictionary(); private static Dictionary? hashToKey; private static string[] KnownKeys => knownKeys ?? (knownKeys = GenerateKeys()); private static Dictionary HashToKey => hashToKey ?? (hashToKey = KnownKeys.ToDictionary(CalculateHash, (string x) => x)); private static string[] GenerateKeys() { string[] staticKeys = StaticKeys; List list = new List(staticKeys.Length); list.AddRange(staticKeys); List list2 = list; List list3 = new List(); list3.Add(Assembly.GetAssembly(typeof(ZNetView))); list3.AddRange(from p in Chainloader.PluginInfos.Values where (Object)(object)p.Instance != (Object)null select ((object)p.Instance).GetType().Assembly); Type baseType = typeof(MonoBehaviour); Type[] source = list3.SelectMany(delegate(Assembly s) { try { return s.GetTypes(); } catch (ReflectionTypeLoadException ex) { return ex.Types.Where((Type t) => t != null); } }).Where(delegate(Type t) { try { return baseType.IsAssignableFrom(t); } catch { return false; } }).ToArray(); list2.AddRange(source.Select((Type t) => "HasFields" + t.Name)); list2.AddRange(source.SelectMany((Type t) => from f in t.GetFields(BindingFlags.Instance | BindingFlags.Public) select t.Name + "." + f.Name)); list2.AddRange(from f in typeof(ZDOVars).GetFields(BindingFlags.Static | BindingFlags.Public) select f.Name.Replace("s_", "")); list2.AddRange(from f in typeof(ZDOVars).GetFields(BindingFlags.Static | BindingFlags.Public) select FirstLetterUpper(f.Name.Replace("s_", ""))); for (int num = 0; num < 20; num++) { list2.Add($"MatVar{num}"); list2.Add($"item{num}"); list2.Add($"quality{num}"); list2.Add($"variant{num}"); list2.Add($"data_{num}"); list2.Add($"data__{num}"); list2.Add($"drop_hash{num}"); list2.Add($"drop_amount{num}"); list2.Add($"slot{num}"); list2.Add($"slotstatus{num}"); list2.Add($"{num}_item"); list2.Add($"{num}_durability"); list2.Add($"{num}_stack"); list2.Add($"{num}_quality"); list2.Add($"{num}_variant"); list2.Add($"{num}_crafterID"); list2.Add($"{num}_crafterName"); list2.Add($"{num}_dataCount"); for (int num2 = 0; num2 < 20; num2++) { list2.Add($"{num}_data_{num2}"); list2.Add($"{num}_data__{num2}"); } list2.Add($"{num}_worldLevel"); list2.Add($"{num}_pickedUp"); list2.Add($"pu_id{num}"); list2.Add($"pu_name{num}"); list2.Add($"Health{num}"); list2.Add($"room{num}"); list2.Add($"room{num}_pos"); list2.Add($"room{num}_rot"); list2.Add($"target{num}"); } list2.AddRange(AnimationKeys.Select((string k) => "$" + k)); List list4 = new List(); list4.AddRange(list2.Distinct()); return list4.ToArray(); } public static bool IsRoomPos(string key) { if (key.EndsWith("_pos")) { return key.StartsWith("room"); } return false; } public static bool IsRoomRot(string key) { if (key.EndsWith("_rot")) { return key.StartsWith("room"); } return false; } private static string FirstLetterUpper(string s) { return char.ToUpper(s[0]) + s.Substring(1); } public static string Convert(int hash) { if (!HashToKey.TryGetValue(hash, out string value)) { return hash.ToString(); } return value; } public static int Hash(string key) { if (keyToHash.TryGetValue(key, out var value)) { return value; } value = CalculateHash(key); keyToHash[key] = value; HashToKey[value] = key; return value; } private static int CalculateHash(string key) { if (key.StartsWith("$", StringComparison.InvariantCultureIgnoreCase)) { int hash = ZSyncAnimation.GetHash(key.Substring(1)); if (key == "$anim_speed") { return hash; } return hash + 438569; } return StringExtensionMethods.GetStableHashCode(key); } public static bool Exists(int hash) { if (hashToKey != null) { return HashToKey.ContainsKey(hash); } return true; } } } namespace WorldEditCommands { public static class Actions { private static Dictionary IdToHash = new Dictionary(); private static Dictionary LowerIdToHash = new Dictionary(); private const string DEFAULT = "default"; public static bool? ToggleBool(ZNetView obj, bool? value, int hash) { bool flag = obj.GetZDO().GetBool(hash, false); bool flag2 = value ?? (!flag); obj.GetZDO().Set(hash, flag2); return flag2; } public static GameObject? Refresh(ZDO zdo) { GameObject gameObject = ((Component)ZNetScene.instance.m_instances[zdo]).gameObject; if (!Object.op_Implicit((Object)(object)gameObject) || zdo.GetPrefab() == Hash.Player) { return gameObject; } Object.Destroy((Object)(object)gameObject); GameObject val = ZNetScene.instance.CreateObject(zdo); ZNetScene.instance.m_instances[zdo] = val.GetComponent(); return val; } public static GameObject? Refresh(ZNetView view) { return Refresh(view.GetZDO()); } public static void SetFloat(ZNetView obj, float? value, int hash, bool refresh = false) { if (Object.op_Implicit((Object)(object)obj)) { obj.GetZDO().Set(hash, value ?? (-1f)); if (refresh) { Refresh(obj); } } } public static void SetInt(ZNetView obj, int? value, int hash, bool refresh = false) { if (Object.op_Implicit((Object)(object)obj)) { obj.GetZDO().Set(hash, value ?? (-1), false); if (refresh) { Refresh(obj); } } } public static void SetLong(ZNetView obj, long? value, int hash, bool refresh = false) { if (Object.op_Implicit((Object)(object)obj)) { obj.GetZDO().Set(hash, value ?? (-1)); if (refresh) { Refresh(obj); } } } public static int GetId(string id) { if (IdToHash.Count == 0) { IdToHash = ZNetScene.instance.m_namedPrefabs.ToDictionary((KeyValuePair kvp) => ((Object)kvp.Value).name, (KeyValuePair kvp) => kvp.Key); } if (LowerIdToHash.Count == 0) { LowerIdToHash = ZNetScene.instance.m_namedPrefabs.ToLookup((KeyValuePair kvp) => ((Object)kvp.Value).name.ToLower(), (KeyValuePair kvp) => kvp.Key).ToDictionary((IGrouping kvp) => kvp.Key, (IGrouping kvp) => kvp.FirstOrDefault()); } if (IdToHash.TryGetValue(id, out var value)) { return value; } if (LowerIdToHash.TryGetValue(id.ToLower(), out var value2)) { return value2; } return StringExtensionMethods.GetStableHashCode(id); } public static void SetPrefab(ZNetView obj, string? value, int hash, bool refresh = false) { if (Object.op_Implicit((Object)(object)obj)) { obj.GetZDO().Set(hash, value ?? ""); if (refresh) { Refresh(obj); } } } public static void SetString(ZNetView obj, string? value, int hash, bool refresh = false) { if (Object.op_Implicit((Object)(object)obj)) { obj.GetZDO().Set(hash, value ?? ""); if (refresh) { Refresh(obj); } } } public static void SetTame(GameObject obj, bool tame) { SetTame(obj.GetComponent(), tame); } public static void SetTame(Character obj, bool tame) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)obj)) { return; } obj.SetTamed(tame); BaseAI component = ((Component)obj).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return; } component.SetAlerted(false); if (tame) { SetHunt(component, hunt: false); component.SetPatrolPoint(); } component.SetTargetInfo(ZDOID.None); MonsterAI component2 = ((Component)obj).GetComponent(); if (Object.op_Implicit((Object)(object)component2)) { component2.m_targetCreature = null; component2.m_targetStatic = null; if (tame) { component2.SetDespawnInDay(false); component2.SetEventCreature(false); } } AnimalAI component3 = ((Component)obj).GetComponent(); if (Object.op_Implicit((Object)(object)component3)) { component3.m_target = null; } } public static void SetHunt(GameObject obj, bool hunt) { SetHunt(obj.GetComponent(), hunt); } public static bool SetPrefab(ZNetView obj, string prefab) { if (!Object.op_Implicit((Object)(object)obj)) { return false; } ZDO zDO = obj.GetZDO(); if (zDO == null || !zDO.IsValid()) { return false; } int prefab2 = zDO.GetPrefab(); zDO.SetPrefab(StringExtensionMethods.GetStableHashCode(prefab)); GameObject val = ZNetScene.instance.CreateObject(zDO); if (!Object.op_Implicit((Object)(object)val)) { zDO.SetPrefab(prefab2); return false; } Object.Destroy((Object)(object)((Component)obj).gameObject); ZNetScene.instance.m_instances[zDO] = val.GetComponent(); return true; } public static void SetHunt(BaseAI obj, bool hunt) { if (Object.op_Implicit((Object)(object)obj)) { obj.m_huntPlayer = hunt; obj.m_nview.GetZDO().Set(Hash.HuntPlayer, hunt); } } public static void SetFuel(ZNetView view, float amount) { if (Object.op_Implicit((Object)(object)view)) { view.GetZDO().Set(Hash.Fuel, amount); } } public static void SetSleeping(GameObject obj, bool sleep) { SetSleeping(obj.GetComponent(), sleep); } public static void SetSleeping(MonsterAI obj, bool sleep) { if (Object.op_Implicit((Object)(object)obj)) { obj.m_sleeping = sleep; ((BaseAI)obj).m_nview.GetZDO().Set(Hash.Sleeping, sleep); ((BaseAI)obj).m_animator.SetBool("sleeping", sleep); } } public static void SetBaby(GameObject obj) { SetBaby(obj.GetComponent()); } public static void SetBaby(Growup obj) { if (Object.op_Implicit((Object)(object)obj)) { ZNetView component = ((Component)obj).GetComponent(); if (component != null) { ZDO zDO = component.GetZDO(); int spawnTime = Hash.SpawnTime; DateTime maxValue = DateTime.MaxValue; zDO.Set(spawnTime, maxValue.Ticks); } } } public static void SetLevel(GameObject obj, int level) { if (level >= 1) { SetLevel(obj.GetComponent(), level); SetLevel(obj.GetComponent(), level); } } public static void SetLevel(Character obj, int level) { if (Object.op_Implicit((Object)(object)obj) && obj.GetLevel() != level) { obj.SetLevel(level); } } public static void SetLevel(ItemDrop obj, int level) { if (Object.op_Implicit((Object)(object)obj)) { obj.m_itemData.m_quality = level; obj.m_nview.GetZDO().Set(Hash.Quality, level, false); } } public static float GetHealth(ZNetView obj) { ZDO zDO = obj.GetZDO(); ItemDrop component = ((Component)obj).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { return component.m_itemData.m_durability; } Character component2 = ((Component)obj).GetComponent(); if (Object.op_Implicit((Object)(object)component2)) { return component2.GetHealth(); } WearNTear component3 = ((Component)obj).GetComponent(); if (Object.op_Implicit((Object)(object)component3)) { return zDO.GetFloat(Hash.Health, component3.m_health); } Destructible component4 = ((Component)obj).GetComponent(); if (Object.op_Implicit((Object)(object)component4)) { return zDO.GetFloat(Hash.Health, component4.m_health); } TreeLog component5 = ((Component)obj).GetComponent(); if (Object.op_Implicit((Object)(object)component5)) { return zDO.GetFloat(Hash.Health, component5.m_health); } TreeBase component6 = ((Component)obj).GetComponent(); if (Object.op_Implicit((Object)(object)component6)) { return zDO.GetFloat(Hash.Health, component6.m_health); } return -1f; } public static float SetHealth(GameObject obj, float health, bool isPercentage) { ItemDrop component = obj.GetComponent(); if (Object.op_Implicit((Object)(object)component)) { return SetHealth(component, health, isPercentage); } Character component2 = obj.GetComponent(); if (Object.op_Implicit((Object)(object)component2)) { return SetHealth(component2, health, isPercentage); } WearNTear component3 = obj.GetComponent(); if (Object.op_Implicit((Object)(object)component3)) { return SetHealth(component3, health, isPercentage); } TreeLog component4 = obj.GetComponent(); if (Object.op_Implicit((Object)(object)component4)) { return SetHealth(component4, health, isPercentage); } TreeBase component5 = obj.GetComponent(); if (Object.op_Implicit((Object)(object)component5)) { return SetHealth(component5, health, isPercentage); } Destructible component6 = obj.GetComponent(); if (Object.op_Implicit((Object)(object)component6)) { return SetHealth(component6, health, isPercentage); } return 0f; } public static float SetHealth(Character obj, float health, bool isPercentage) { if (!Object.op_Implicit((Object)(object)obj)) { return 0f; } if (isPercentage) { health *= obj.GetMaxHealth(); } float maxHealth = obj.GetMaxHealth(); if (health == 0f) { obj.SetupMaxHealth(); return maxHealth; } obj.SetMaxHealth(health); obj.SetHealth(health * 1.000001f); return maxHealth; } public static float SetHealth(WearNTear obj, float health, bool isPercentage) { if (!Object.op_Implicit((Object)(object)obj)) { return 0f; } if (isPercentage) { health *= obj.m_health; } if (health == 0f) { health = obj.m_health; } float result = obj.m_nview.GetZDO().GetFloat(Hash.Health, obj.m_health); obj.m_nview.GetZDO().Set(Hash.Health, health); return result; } public static float SetHealth(TreeLog obj, float health, bool isPercentage) { if (!Object.op_Implicit((Object)(object)obj)) { return 0f; } if (isPercentage) { health *= obj.m_health; } if (health == 0f) { health = obj.m_health; } float result = obj.m_nview.GetZDO().GetFloat(Hash.Health, obj.m_health); obj.m_nview.GetZDO().Set(Hash.Health, health); return result; } public static float SetHealth(Destructible obj, float health, bool isPercentage) { if (!Object.op_Implicit((Object)(object)obj)) { return 0f; } if (isPercentage) { health *= obj.m_health; } if (health == 0f) { health = obj.m_health; } float result = obj.m_nview.GetZDO().GetFloat(Hash.Health, obj.m_health); obj.m_nview.GetZDO().Set(Hash.Health, health); return result; } public static float SetHealth(TreeBase obj, float health, bool isPercentage) { if (!Object.op_Implicit((Object)(object)obj)) { return 0f; } if (isPercentage) { health *= obj.m_health; } if (health == 0f) { health = obj.m_health; } float result = obj.m_nview.GetZDO().GetFloat(Hash.Health, obj.m_health); obj.m_nview.GetZDO().Set(Hash.Health, health); return result; } public static float SetHealth(ItemDrop obj, float health, bool isPercentage) { if (!Object.op_Implicit((Object)(object)obj)) { return 0f; } float durability = obj.m_itemData.m_durability; if (isPercentage) { health *= obj.m_itemData.GetMaxDurability(); } if (health == 0f) { health = obj.m_itemData.GetMaxDurability(); } obj.m_itemData.m_durability = health; obj.m_nview.GetZDO().Set(Hash.Durability, obj.m_itemData.m_durability); return durability; } public static float SetCreator(ZNetView obj, long creator) { Piece obj2 = default(Piece); if (((Component)obj).TryGetComponent(ref obj2)) { return SetCreator(obj2, creator); } return 0f; } public static long SetCreator(Piece obj, long creator) { if (!Object.op_Implicit((Object)(object)obj)) { return 0L; } long creator2 = obj.GetCreator(); obj.m_creator = creator; obj.m_nview.GetZDO().Set(Hash.Creator, creator); return creator2; } public static void SetVariant(GameObject obj, int variant) { SetVariant(obj.GetComponent(), variant); } public static void SetVariant(ItemDrop obj, int variant) { if (Object.op_Implicit((Object)(object)obj)) { obj.m_itemData.m_variant = variant; obj.m_nview.GetZDO().Set(Hash.Variant, variant, false); } } public static void SetName(GameObject obj, string name) { SetName(obj.GetComponent(), name); SetName(obj.GetComponent(), name); } public static void SetName(Tameable obj, string name) { if (Object.op_Implicit((Object)(object)obj)) { obj.m_nview.GetZDO().Set(Hash.TamedName, name); } } public static void SetCrafterId(ItemDrop obj, long id) { if (Object.op_Implicit((Object)(object)obj)) { obj.m_itemData.m_crafterID = id; obj.m_nview.GetZDO().Set(Hash.CrafterID, obj.m_itemData.m_crafterID); } } public static void SetName(ItemDrop obj, string name) { if (Object.op_Implicit((Object)(object)obj)) { obj.m_itemData.m_crafterID = ((!(name == "")) ? (-1) : 0); obj.m_nview.GetZDO().Set(Hash.CrafterID, obj.m_itemData.m_crafterID); obj.m_itemData.m_crafterName = name; obj.m_nview.GetZDO().Set(Hash.CrafterName, name); } } public static int SetStack(GameObject obj, int remaining) { if (remaining <= 0) { return 0; } ItemDrop component = obj.GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return 0; } int num = Math.Min(remaining, component.m_itemData.m_shared.m_maxStackSize); component.m_itemData.m_stack = num; component.m_nview.GetZDO().Set(Hash.Stack, num, false); return num; } public static void SetRotation(GameObject obj, Quaternion rotation) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0024: 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) ZNetView component = obj.GetComponent(); if (!((Object)(object)component == (Object)null) && rotation != Quaternion.identity) { component.GetZDO().SetRotation(rotation); obj.transform.rotation = rotation; } } public static void Respawn(GameObject obj) { Respawn(obj.GetComponent()); Respawn(obj.GetComponent()); Respawn(obj.GetComponent()); } public static void Respawn(Container obj) { if (Object.op_Implicit((Object)(object)obj) && obj.m_defaultItems.m_drops.Count != 0) { Inventory inventory = obj.m_inventory; if (inventory != null) { inventory.RemoveAll(); } obj.AddDefaultItems(); } } public static bool CanRespawn(GameObject obj) { if (!Object.op_Implicit((Object)(object)obj.GetComponent()) && !Object.op_Implicit((Object)(object)obj.GetComponent())) { Container component = obj.GetComponent(); if (component == null) { return false; } return component.m_defaultItems.m_drops.Count > 0; } return true; } public static void Respawn(Pickable obj) { if (Object.op_Implicit((Object)(object)obj)) { obj.SetPicked(false); } } public static void Respawn(CreatureSpawner obj) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)obj)) { return; } ZNetView nview = obj.m_nview; ZDO val = ((nview != null) ? nview.GetZDO() : null); if (val != null) { FakeZDO fakeZDO = new FakeZDO(val); ZDOID connectionZDOID = val.GetConnectionZDOID((ConnectionType)3); if (ZDOMan.instance.m_objectsByID.TryGetValue(connectionZDOID, out var value)) { UndoHelper.AddRemoveAction(value); RemoveZDO(value); } UndoHelper.AddRemoveAction(val); RemoveZDO(val); fakeZDO.Data.ConnectionType = (ConnectionType)0; fakeZDO.Data.ConnectionHash = 0; fakeZDO.Data.TargetConnectionId = ZDOID.None; fakeZDO.Data.Longs?.Remove(ZDOVars.s_aliveTime); UndoHelper.AddSpawnAction(fakeZDO.Create()); } } public static void SetModel(GameObject obj, int index) { SetModel(obj.GetComponent(), index); } public static void SetModel(Character obj, int index) { if (Object.op_Implicit((Object)(object)obj)) { VisEquipment component = ((Component)obj).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.SetModel(index); } } } public static void SetVisual(GameObject obj, Item item) { SetVisual(obj.GetComponent(), item); } public static void SetVisual(GameObject obj, VisSlot slot, Item? item) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) SetVisual(obj.GetComponent(), slot, item); } public static void SetDistant(GameObject obj, bool distant) { obj.GetComponent().GetZDO().Distant = distant; } public static void SetPersistent(GameObject obj, bool persistent) { obj.GetComponent().GetZDO().Persistent = persistent; } public static int SetFields(GameObject obj, Dictionary fields) { return SetFields(obj.GetComponent(), fields); } public static int SetFields(ZNetView view, Dictionary fields) { //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) ZDO val = ((view != null) ? view.GetZDO() : null); if ((Object)(object)view == (Object)null || val == null) { return 0; } HashSet hashSet = ComponentInfo.Get(view).ToHashSet(); int num = 0; bool flag = false; foreach (KeyValuePair field in fields) { if (field.Key.Split(new char[1] { '.' }).Length > 1) { string text = field.Key.Split(new char[1] { '.' })[0]; if (!hashSet.Contains(text)) { continue; } val.Set(Hash.HasFields, true); val.Set("HasFields" + text, true); } else { flag = true; } int stableHashCode = StringExtensionMethods.GetStableHashCode(field.Key); if (field.Value is int num2) { val.Set(stableHashCode, num2, false); } else if (field.Value is float num3) { val.Set(stableHashCode, num3); } else if (field.Value is string text2) { val.Set(stableHashCode, text2); } else if (field.Value is bool flag2) { val.Set(stableHashCode, flag2); } else if (field.Value is long num4) { val.Set(stableHashCode, num4); } else if (field.Value is Vector3 pos) { val.Set(stableHashCode, TransformPos(val, field.Key, pos)); } else if (field.Value is Quaternion rot) { val.Set(stableHashCode, TransformRot(val, field.Key, rot)); } num++; } if (flag) { Refresh(view); } else { view.LoadFields(); WearNTear val2 = default(WearNTear); if (((Component)view).TryGetComponent(ref val2)) { val2.m_healthPercentage = val.GetFloat(ZDOVars.s_health, val2.m_health) / val2.m_health; val2.UpdateVisual(false); } } return num; } private static Vector3 TransformPos(ZDO zdo, string key, Vector3 pos) { //IL_0020: 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_000f: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) if (ZDOKeys.IsRoomPos(key)) { return zdo.GetPosition() + zdo.GetRotation() * pos; } return pos; } private static Quaternion TransformRot(ZDO zdo, string key, Quaternion rot) { //IL_0015: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (ZDOKeys.IsRoomRot(key)) { return zdo.GetRotation() * rot; } return rot; } public static void SetVisual(ItemStand obj, Item? item) { if (Object.op_Implicit((Object)(object)obj) && item != null) { obj.m_nview.GetZDO().Set(Hash.Item, item.Name); obj.m_nview.GetZDO().Set(Hash.Variant, item.Variant, false); obj.UpdateVisual(); } } public static void SetVisual(Character obj, VisSlot slot, Item? item) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)obj) && item != null) { VisEquipment component = ((Component)obj).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { component.SetItem(slot, item.Name, item.Variant); } } } public static void Move(ZNetView obj, Vector3 offset, string origin) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: 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_0048: 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) ZDO zDO = obj.GetZDO(); Vector3 position = ((Component)obj).transform.position; Quaternion val = ((Component)Player.m_localPlayer).transform.rotation; if (origin == "world") { val = Quaternion.identity; } if (origin == "object") { val = ((Component)obj).transform.rotation; } position += val * Vector3.right * offset.x; position += val * Vector3.up * offset.y; position += val * Vector3.forward * offset.z; zDO.SetPosition(position); ((Component)obj).transform.position = position; } public static void Rotate(ZNetView obj, Vector3 relative, string origin, Vector3? center = null) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) ZDO zDO = obj.GetZDO(); Quaternion val = ((Component)Player.m_localPlayer).transform.rotation; if (origin == "world") { val = Quaternion.identity; } if (origin == "object") { val = ((Component)obj).transform.rotation; } Transform transform = ((Component)obj).transform; Vector3 val2 = (Vector3)(((??)center) ?? transform.position); transform.RotateAround(val2, val * Vector3.up, relative.y); transform.RotateAround(val2, val * Vector3.forward, relative.x); transform.RotateAround(val2, val * Vector3.right, relative.z); zDO.SetRotation(((Component)obj).transform.rotation); } public static void Mirror(ZNetView obj, Vector3 center) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((Component)obj).transform; transform.position = new Vector3(2f * center.x - transform.position.x, transform.position.y, transform.position.z); Vector3 eulerAngles = transform.eulerAngles; transform.rotation = Quaternion.Euler(eulerAngles.x, 0f - eulerAngles.y, eulerAngles.z); ZDO zDO = obj.GetZDO(); zDO.SetPosition(transform.position); zDO.SetRotation(transform.rotation); } public static void ResetRotation(ZNetView obj) { //IL_0006: 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) obj.GetZDO().SetRotation(Quaternion.identity); ((Component)obj).transform.rotation = Quaternion.identity; } public static bool Scale(ZNetView obj, Vector3 scale) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) bool result = false; if (!obj.m_syncInitialScale && WorldEditCommands.IsTweaks) { SetFields(obj, new Dictionary { { "ZNetView.m_syncInitialScale", true } }); result = true; } if (obj.m_syncInitialScale) { obj.SetLocalScale(scale); } return result; } public static void RemoveZDO(ZDO zdo) { if (zdo != null && zdo.IsValid()) { zdo.SetOwner(ZDOMan.GetSessionID()); if (ZNetScene.instance.m_instances.TryGetValue(zdo, out var value)) { ZNetScene.instance.Destroy(((Component)value).gameObject); Object.DestroyImmediate((Object)(object)value); } else { ZDOMan.instance.DestroyZDO(zdo); } } } private static string Print(T? value) { if (value != null) { return value.ToString(); } return "default"; } public static string Damage(ZNetView view, float? value) { if (!Object.op_Implicit((Object)(object)((Component)view).GetComponent())) { return "Skipped: ยค is not a creature."; } SetFloat(view, value ?? 1f, Hash.Damage); return "ยค damage set to " + Print(value) + "."; } public static string Ammo(ZNetView view, int? value) { if (!Object.op_Implicit((Object)(object)((Component)view).GetComponent())) { return "Skipped: ยค is not a turret."; } SetInt(view, value.GetValueOrDefault(), Hash.Ammo); return "ยค ammo set to " + Print(value) + "."; } public static string AmmoType(ZNetView view, string? value) { if (!Object.op_Implicit((Object)(object)((Component)view).GetComponent())) { return "Skipped: ยค is not a turret."; } SetString(view, value ?? "", Hash.AmmoType); return "ยค ammo type set to " + Print(value) + "."; } } public class AliasesCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__0_0; public static Func> <>9__0_1; internal void <.ctor>b__0_0(ConsoleEventArgs args) { string substitution = Settings.Substitution; if (args.Length > 1 && args[1] == "clear") { args.Context.TryRunCommand("alias move", false, false); args.Context.TryRunCommand("alias rotate", false, false); args.Context.TryRunCommand("alias scal", false, false); args.Context.TryRunCommand("alias stars", false, false); args.Context.TryRunCommand("alias health", false, false); args.Context.TryRunCommand("alias remove", false, false); args.Context.TryRunCommand("alias change_helmet", false, false); args.Context.TryRunCommand("alias change_left", false, false); args.Context.TryRunCommand("alias change_right", false, false); args.Context.TryRunCommand("alias change_legs", false, false); args.Context.TryRunCommand("alias change_chest", false, false); args.Context.TryRunCommand("alias change_shoulders", false, false); args.Context.TryRunCommand("alias change_utility", false, false); args.Context.TryRunCommand("alias essential", false, false); args.Context.TryRunCommand("alias spawn", false, false); return; } args.Context.TryRunCommand("alias move object move=" + substitution + "," + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias rotate object rotate=" + substitution + "," + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias scale object scale=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias stars object stars=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias health object stars=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias remove object remove=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias change_helmet object helmet=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias change_left object left_hand=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias change_right object right_hand=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias change_legs object legs=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias change_chest object chest=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias change_shoulders object shoulders=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias change_utility object utility=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias essential object tame health=1E30 radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias spawn spawn_object " + substitution + " amount=" + substitution + " level=" + substitution, false, false); } internal List <.ctor>b__0_1(int index) { if (index == 0) { return new List(2) { "set", "clear" }; } return ParameterInfo.None; } } public AliasesCommand() { //IL_0038: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { string substitution = Settings.Substitution; if (args.Length > 1 && args[1] == "clear") { args.Context.TryRunCommand("alias move", false, false); args.Context.TryRunCommand("alias rotate", false, false); args.Context.TryRunCommand("alias scal", false, false); args.Context.TryRunCommand("alias stars", false, false); args.Context.TryRunCommand("alias health", false, false); args.Context.TryRunCommand("alias remove", false, false); args.Context.TryRunCommand("alias change_helmet", false, false); args.Context.TryRunCommand("alias change_left", false, false); args.Context.TryRunCommand("alias change_right", false, false); args.Context.TryRunCommand("alias change_legs", false, false); args.Context.TryRunCommand("alias change_chest", false, false); args.Context.TryRunCommand("alias change_shoulders", false, false); args.Context.TryRunCommand("alias change_utility", false, false); args.Context.TryRunCommand("alias essential", false, false); args.Context.TryRunCommand("alias spawn", false, false); } else { args.Context.TryRunCommand("alias move object move=" + substitution + "," + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias rotate object rotate=" + substitution + "," + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias scale object scale=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias stars object stars=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias health object stars=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias remove object remove=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias change_helmet object helmet=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias change_left object left_hand=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias change_right object right_hand=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias change_legs object legs=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias change_chest object chest=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias change_shoulders object shoulders=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias change_utility object utility=" + substitution + " radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias essential object tame health=1E30 radius=" + substitution + " id=" + substitution, false, false); args.Context.TryRunCommand("alias spawn spawn_object " + substitution + " amount=" + substitution + " level=" + substitution, false, false); } }; <>c.<>9__0_0 = val; obj = (object)val; } new ConsoleCommand("world_edit_aliases", "[set/clear] - Sets some useful aliases.", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); AutoComplete.Register("world_edit_aliases", (Func>)((int index) => (index == 0) ? new List(2) { "set", "clear" } : ParameterInfo.None)); } } public abstract class BaseParameters { public Vector3 From; public Vector3? Center; public string[] ConnectionIds = Array.Empty(); public string[] IncludedIds = Array.Empty(); public string[] ExcludedIds = Array.Empty(); public float Angle; public Range? Radius; public Range? Width; public Range? Depth; public float Height; public float Chance = 1f; public string Match = ""; public string Unmatch = ""; public bool Connect; public HashSet Components = new HashSet(); public Dictionary DataParameters = new Dictionary(); private readonly Dictionary SupportedOperations; private Terminal terminal; public Dictionary Operations; public static Random Random = new Random(); protected BaseParameters(Dictionary supportedOperations) { SupportedOperations = supportedOperations; Operations = new Dictionary(); base..ctor(); } public void ParseCommand(ConsoleEventArgs args) { //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) if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { From = ((Component)Player.m_localPlayer).transform.position; } terminal = args.Context; ParseArgs(args.Args); } protected abstract void ParseArg(string arg); protected abstract void ParseArg(string arg, string value); protected virtual void ParseArgs(string[] args) { for (int i = 0; i < args.Length; i++) { string[] array = args[i].Split(new char[1] { '=' }, 2); string text = array[0].ToLower(); ParseArgInternal(text); ParseArg(text); if (array.Length >= 2) { string value = array[1].Trim(); ParseArgInternal(text, value); ParseArg(text, value); } } if (Operations.Count == 0) { throw new InvalidOperationException("Missing the operation."); } if (Radius != null && Depth != null) { throw new InvalidOperationException("circle and rect parameters can't be used together."); } if (Radius != null && Connect) { throw new InvalidOperationException("circle and connect parameters can't be used together."); } if (Depth != null && Connect) { throw new InvalidOperationException("connect and rect parameters can't be used together."); } } private void ParseArgInternal(string name) { if (SupportedOperations.TryGetValue(name, out Type value)) { if (Operations.ContainsKey(name) && value != typeof(string[])) { throw new InvalidOperationException("Operation " + name + " used multiple times."); } if (value == typeof(string[])) { if (!Operations.ContainsKey(name)) { Operations.Add(name, new string[0]); } } else { Operations.Add(name, null); } } if (name == "connect") { Connect = true; } } private void ParseArgInternal(string name, string value) { //IL_0186: Unknown result type (might be due to invalid IL or missing references) if (SupportedOperations.TryGetValue(name, out Type value2)) { if (value2 == typeof(int)) { Operations[name] = Parse.Int(value, 0); } else if (value2 == typeof(float)) { Operations[name] = Parse.Float(value, 0f); } else if (value2 == typeof(bool)) { Operations[name] = Parse.Boolean(value); } else if (value2 == typeof(string[])) { Operations[name] = (Operations[name] as string[]).Append(value).ToArray(); } else { Operations[name] = value; } } string[] array = Parse.Split(value, ','); if (name == "par") { KeyValuePair keyValuePair = Parse.Kvp(value, ','); if (keyValuePair.Key == "") { throw new InvalidOperationException("Invalid data parameter " + value + "."); } DataParameters["<" + keyValuePair.Key + ">"] = keyValuePair.Value; } if (name == "connect") { ConnectionIds = array; } if (name == "center" || name == "from") { Center = Parse.VectorXZY(array); } if (name == "id") { IncludedIds = array; } if (name == "ignore") { ExcludedIds = array; } if (name == "chance") { Chance = Parse.Float(value, 1f); } if (name == "type") { AddComponents(array); } if (name == "match") { Match = value; } if (name == "unmatch") { Unmatch = value; } if (name == "rect") { Range val = Parse.ScaleRange(value); Width = new Range(val.Min.x, val.Max.x); Depth = new Range(val.Min.z, val.Max.z); } switch (name) { case "radius": case "range": case "circle": Radius = Parse.FloatRange(value, 0f); break; } if (name == "height") { Height = Parse.Float(value, 0f); } if (name == "angle") { Angle = Parse.Float(value, 0f) * (float)Math.PI / 180f; } } private void AddComponents(string[] values) { foreach (string text in values) { string text2 = text.ToLowerInvariant(); if (text2 == "structure") { Components.Add("WearNTear"); } else if (text2 == "creature") { Components.Add("Humanoid"); } else { Components.Add(text); } } } public ZNetView[] GetObjects() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) ZNetView[] source; if (Connect) { ZNetView hovered = Selector.GetHovered(50f, IncludedIds, Components, ExcludedIds); if ((Object)(object)hovered == (Object)null) { return Array.Empty(); } source = Selector.GetConnected(hovered, ConnectionIds, IncludedIds, ExcludedIds); } else if (Radius != null) { source = Selector.GetNearby(IncludedIds, Components, ExcludedIds, (Vector3)(((??)Center) ?? From), Radius, Height); } else if (Width != null && Depth != null) { source = Selector.GetNearby(IncludedIds, Components, ExcludedIds, (Vector3)(((??)Center) ?? From), Angle, Width, Depth, Height); } else { ZNetView hovered2 = Selector.GetHovered(50f, IncludedIds, Components, ExcludedIds); if ((Object)(object)hovered2 == (Object)null) { return Array.Empty(); } if (!Selector.GetPrefabs(IncludedIds).Contains(hovered2.GetZDO().GetPrefab())) { Helper.AddMessage(terminal, "Skipped: " + ((Object)hovered2).name + " has invalid id.", false); return Array.Empty(); } source = (ZNetView[])(object)new ZNetView[1] { hovered2 }; } DataEntry matchData = ((Match == "") ? null : DataHelper.Get(Match)); DataEntry unmatchData = ((Unmatch == "") ? null : DataHelper.Get(Unmatch)); List list = new List(); list.AddRange(source.Where(delegate(ZNetView view) { if (!Object.op_Implicit((Object)(object)view)) { return false; } if (!view.GetZDO().IsValid()) { terminal.AddString("Skipped: " + ((Object)view).name + " is not loaded."); return false; } if (matchData != null && !matchData.Match(DataParameters.ToDictionary, string, string>((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value), view.GetZDO())) { terminal.AddString("Skipped: " + ((Object)view).name + " not matching filter."); return false; } if (unmatchData != null && !unmatchData.Unmatch(DataParameters.ToDictionary, string, string>((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value), view.GetZDO())) { terminal.AddString("Skipped: " + ((Object)view).name + " matching filter."); return false; } if (!Roll(Chance)) { terminal.AddString("Skipped: " + ((Object)view).name + " (chance)."); return false; } return true; })); return list.ToArray(); } public static bool Roll(float value) { if (value >= 1f) { return true; } return Random.NextDouble() < (double)value; } } public class DataAutoComplete { public List NamedParameters = new List(); public static List GetOptions() { List list = new List(); list.Add("id"); list.Add("ignore"); list.Add("radius"); list.Add("center"); list.Add("from"); list.Add("rect"); list.Add("angle"); list.Add("chance"); list.Add("type"); list.Add("connect"); list.Add("match"); list.Add("unmatch"); list.Add("par"); list.AddRange(DataParameters.SupportedOperations.Keys); List source = list; List list2 = new List(); list2.AddRange(from s in source.Distinct() orderby s select s); return list2; } public static Dictionary>> GetNamedOptions() { List dataTypes = new List(9) { "array", "bool", "float", "hash", "int", "long", "quat", "string", "vec3" }; return new Dictionary>> { { "type", (int index) => ParameterInfo.Components }, { "connect", (int index) => ParameterInfo.Flag("Connect") }, { "id", (int index) => ParameterInfo.Ids }, { "ignore", (int index) => ParameterInfo.Ids }, { "center", (int index) => ParameterInfo.XZY("center", "Overrides the player position. For rotate sets also the rotation center point.", index) }, { "from", (int index) => ParameterInfo.XZY("center", "Overrides the player position. For rotate sets also the rotation center point.", index) }, { "rect", (int index) => index switch { 0 => ParameterInfo.Create("rect=size or rect=width,depth", "Area of affected objects."), 1 => ParameterInfo.Create("rect=width,depth", "Area of affected objects."), _ => ParameterInfo.None, } }, { "angle", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("angle=degrees", "Direction of the rectangle when used with rect.") }, { "circle", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("circle=number", "Radius of affected objects.") }, { "radius", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("radius=number", "Radius of affected objects.") }, { "chance", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("chance=number", "Chance to affect the object (from 0.0 to 1.0).") }, { "save", (int index) => ParameterInfo.Create("save=name", "Saves the object data to the file.") }, { "dump", (int index) => ParameterInfo.Create("dump=name", "Saves the object data with default fields to the file.") }, { "keep", (int index) => ParameterInfo.Create("keep=key,key,key,...", "Removes all data except given keys.") }, { "clear", (int index) => ParameterInfo.Flag("Removes all data.") }, { "print", (int index) => ParameterInfo.Flag("Prints data.") }, { "remove", (int index) => ParameterInfo.Create("remove=key,key,key,...", "Removes given keys.") }, { "set", (int index) => index switch { 2 => ParameterInfo.Create("set=type,key,value", "Value of the key."), 1 => ParameterInfo.Create("set=type,key,value", "Name of the key."), 0 => dataTypes, _ => ParameterInfo.None, } }, { "load", (int index) => DataLoading.DataKeys }, { "merge", (int index) => DataLoading.DataKeys }, { "match", (int index) => (index != 0) ? ParameterInfo.None : DataLoading.DataKeys }, { "unmatch", (int index) => (index != 0) ? ParameterInfo.None : DataLoading.DataKeys }, { "par", (int index) => (index != 0) ? ParameterInfo.Create("par=key,value", "Value of the parameter.") : GetDataParameters() }, { "copy_raw", (int index) => (index == 0) ? ParameterInfo.Create("copy_raw or copy_raw=all or copy_raw=key1,key2,...", "Prints and copies object data to clipboard. By default excludes some data for better results.") : ParameterInfo.None } }; } public static List GetDataParameters() { HashSet hashSet = DataFromCommand(GetInput()); if (hashSet.Count == 0) { return ParameterInfo.Create("par=key,value", "Name of the parameter."); } HashSet hashSet2 = hashSet; List list = new List(hashSet2.Count); list.AddRange(hashSet2); return list; } public static List GetRawDataParameters() { string[] array = GetInput().Split(new char[1] { ' ' }); if (array.Length < 2) { return ParameterInfo.Create("par=key,value", "Name of the parameter."); } if (DataLoading.Data.TryGetValue(StringExtensionMethods.GetStableHashCode(array[1]), out DataEntry value)) { HashSet requiredParameters = value.RequiredParameters; List list = new List(requiredParameters.Count); list.AddRange(requiredParameters); return list; } return ParameterInfo.Create("par=key,value", "Name of the parameter."); } private static HashSet DataFromCommand(string command) { string[] array = (from s in command.Split(new char[1] { ' ' }) where s.StartsWith("data=", StringComparison.Ordinal) || s.StartsWith("merge=", StringComparison.Ordinal) || s.StartsWith("load=", StringComparison.Ordinal) select s).SelectMany((string s) => Parse.Split(s.Split(new char[1] { '=' })[1], ',')).ToArray(); HashSet hashSet = new HashSet(); string[] array2 = array; foreach (string text in array2) { if (!DataLoading.Data.TryGetValue(StringExtensionMethods.GetStableHashCode(text), out DataEntry value)) { continue; } foreach (string requiredParameter in value.RequiredParameters) { hashSet.Add(requiredParameter); } } return hashSet; } private static string GetInput() { Aliasing.RestoreAlias(((Terminal)Console.m_instance).m_input); string result = Aliasing.Plain(((TMP_InputField)((Terminal)Console.m_instance).m_input).text); Aliasing.RemoveAlias(((Terminal)Console.m_instance).m_input); return result; } } public class DataCommand { public const string Name = "data"; private DataParameters Parameters = new DataParameters(); protected string DoOperation(ZNetView view, string operation, string? value) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown switch (operation) { case "copy_raw": { ZPackage val = new ZPackage(); DataRawCommand.LegacySerialize(view.GetZDO(), val, value ?? ""); string @base = val.GetBase64(); if (@base == "AAAAAA==") { return "ยค raw data is empty."; } GUIUtility.systemCopyBuffer = @base; return "ยค raw data copied to clipboard."; } case "save": if (value == null || value == "") { throw new InvalidOperationException("Save: Missing data entry name."); } DataLoading.Save(new PlainDataEntry(view.GetZDO()), value, profile: false, dump: false); return "ยค data saved."; case "dump": if (value == null || value == "") { throw new InvalidOperationException("Save: Missing data entry name."); } DataLoading.Save(AddDefaultFields(view.GetZDO(), new PlainDataEntry(view.GetZDO())), value, profile: false, dump: true); return "ยค data saved."; default: throw new NotImplementedException(); } } protected string DoOperation(ZNetView view, string operation, float? value) { throw new NotImplementedException(); } protected string DoOperation(ZNetView view, string operation, string[] value) { //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0406: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0459: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Unknown result type (might be due to invalid IL or missing references) //IL_049c: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) switch (operation) { case "merge": { if (value.Length == 0) { throw new InvalidOperationException("Merge: Missing data entry name."); } UndoHelper.AddEditAction(view); string[] array4 = (from s in value.SelectMany((string str) => str.Split(new char[1] { ',' })) select s.Trim()).ToArray(); DataHelper.Merge(array4.Select(DataHelper.Get).ToArray())?.Write(Parameters.DataParameters, view.GetZDO()); Actions.Refresh(view); return "ยค data merged from " + string.Join(", ", array4) + "."; } case "load": { if (value.Length == 0) { throw new InvalidOperationException("Load: Missing data entry name."); } UndoHelper.AddEditAction(view); ZDO zdo = DataHelper.CloneBase(view.GetZDO()); string[] array3 = (from s in value.SelectMany((string str) => str.Split(new char[1] { ',' })) select s.Trim()).ToArray(); DataHelper.Merge(array3.Select(DataHelper.Get).ToArray())?.Write(Parameters.DataParameters, zdo); Regen(view, zdo); return "ยค data loaded from " + string.Join(", ", array3) + "."; } case "keep": { if (value.Length == 0) { throw new InvalidOperationException("Keep: Missing data keys."); } string[] array5 = (from s in value.SelectMany((string str) => str.Split(new char[1] { ',' })) select s.Trim()).ToArray(); if (DataHelper.HasKey(view.GetZDO(), array5)) { UndoHelper.AddEditAction(view); Regen(view, DataHelper.CloneWithKeys(view.GetZDO(), array5)); return "ยค data cleaned except " + string.Join(", ", array5) + "."; } return "ยค skipped, keys " + string.Join(", ", array5) + " not found."; } case "remove": { if (value.Length == 0) { throw new InvalidOperationException("Remove: Missing data keys."); } UndoHelper.AddEditAction(view); string[] array2 = (from s in value.SelectMany((string str) => str.Split(new char[1] { ',' })) select s.Trim()).ToArray(); Regen(view, DataHelper.CloneWithoutKeys(view.GetZDO(), array2)); return "ยค data keys removed " + string.Join(", ", array2) + "."; } case "set": { if (value.Length == 0) { throw new InvalidOperationException("Set: Missing values."); } UndoHelper.AddEditAction(view); ZDO zDO = view.GetZDO(); ZDOID uid = zDO.m_uid; for (int i = 0; i < value.Length; i++) { string[] array = value[i].Split(new char[1] { ',' }, 3); if (array.Length < 2) { throw new InvalidOperationException("Set: Missing value for " + array[0] + "."); } if (array.Length < 3) { throw new InvalidOperationException("Set: Missing key for " + array[1] + "."); } string text = array[0].ToLowerInvariant(); int result; int num = (int.TryParse(array[1], out result) ? result : StringExtensionMethods.GetStableHashCode(array[1])); string text2 = array[2]; switch (text) { case "float": ZDOExtraData.Set(uid, num, Parse.Float(text2, 0f)); break; case "vec3": ZDOExtraData.Set(uid, num, Parse.VectorXZY(text2)); break; case "quat": ZDOExtraData.Set(uid, num, Parse.AngleYXZ(text2)); break; case "int": ZDOExtraData.Set(uid, num, Parse.Int(text2, 0)); break; case "hash": ZDOExtraData.Set(uid, num, StringExtensionMethods.GetStableHashCode(text2)); break; case "bool": ZDOExtraData.Set(uid, num, (Parse.Boolean(text2) == true) ? 1 : 0); break; case "long": ZDOExtraData.Set(uid, num, Parse.Long(text2, 0L)); break; case "string": ZDOExtraData.Set(uid, num, text2); break; case "array": ZDOExtraData.Set(uid, num, Convert.FromBase64String(text2)); break; default: throw new InvalidOperationException("Unknown type " + text + "."); } } zDO.IncreaseDataRevision(); Actions.Refresh(view); return "ยค data set."; } default: throw new NotImplementedException(); } } protected string DoOperation(ZNetView view, string operation, int? value) { throw new NotImplementedException(); } protected string DoOperation(ZNetView view, string operation, bool? value) { if (value == false) { return ""; } if (operation == "clear") { UndoHelper.AddEditAction(view); Regen(view, DataHelper.CloneBase(view.GetZDO())); return "ยค data cleared."; } if (operation == "print") { return "ยค\n" + string.Join("\n", DataHelper.Print(view.GetZDO())); } throw new NotImplementedException(); } protected string DoOperation(ZNetView view, string operation, long? value) { throw new NotImplementedException(); } private void Regen(ZNetView view, ZDO zdo) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) if (zdo.GetPrefab() != Hash.Player) { ZDOID uid = view.GetZDO().m_uid; ZDO zdo2 = DataHelper.Regen(view.GetZDO(), zdo); UndoHelper.RefreshEditAction(uid, zdo2); } } private void Execute(Terminal context, ZNetView[] views) { UndoHelper.BeginAction(); int num = views.Count(); bool flag = Parameters.Operations.Count > 1 || !Parameters.Operations.ContainsKey("print"); foreach (ZNetView val in views) { ZDO zDO = val.GetZDO(); if (flag && zDO.GetPrefab() != Hash.Player) { val.ClaimOwnership(); } foreach (KeyValuePair operation in Parameters.Operations) { Type type = DataParameters.SupportedOperations[operation.Key]; string prefabName = Utils.GetPrefabName(((Component)val).gameObject); string text = ((type == typeof(int)) ? DoOperation(val, operation.Key, (int?)operation.Value) : ((type == typeof(long)) ? DoOperation(val, operation.Key, (long?)operation.Value) : ((type == typeof(float)) ? DoOperation(val, operation.Key, (float?)operation.Value) : ((type == typeof(string[])) ? DoOperation(val, operation.Key, (string[])operation.Value) : ((!(type == typeof(bool))) ? DoOperation(val, operation.Key, (string)operation.Value) : DoOperation(val, operation.Key, (bool?)operation.Value)))))); if (!(text == "")) { string text2 = text.Replace("ยค", prefabName); if (num == 1) { Helper.AddMessage(context, text2, false); } else { context.AddString(text2); } } } } UndoHelper.EndAction(); } private static PlainDataEntry AddDefaultFields(ZDO zdo, PlainDataEntry entry) { //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = ZNetScene.instance.GetPrefab(zdo.GetPrefab()); if (!Object.op_Implicit((Object)(object)prefab)) { return entry; } prefab.GetComponentsInChildren(ZNetView.m_tempComponents); foreach (MonoBehaviour tempComponent in ZNetView.m_tempComponents) { FieldInfo[] fields = ((object)tempComponent).GetType().GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { int stableHashCode = StringExtensionMethods.GetStableHashCode(((object)tempComponent).GetType().Name + "." + fieldInfo.Name); Type fieldType = fieldInfo.FieldType; if (fieldType == typeof(int)) { PlainDataEntry plainDataEntry = entry; if (plainDataEntry.Ints == null) { plainDataEntry.Ints = new Dictionary(); } if (!entry.Ints.ContainsKey(stableHashCode)) { entry.Ints[stableHashCode] = (int)fieldInfo.GetValue(tempComponent); } } if (fieldType == typeof(float)) { PlainDataEntry plainDataEntry = entry; if (plainDataEntry.Floats == null) { plainDataEntry.Floats = new Dictionary(); } if (!entry.Floats.ContainsKey(stableHashCode)) { entry.Floats[stableHashCode] = (float)fieldInfo.GetValue(tempComponent); } } if (fieldType == typeof(string)) { PlainDataEntry plainDataEntry = entry; if (plainDataEntry.Strings == null) { plainDataEntry.Strings = new Dictionary(); } if (!entry.Strings.ContainsKey(stableHashCode)) { entry.Strings[stableHashCode] = (string)fieldInfo.GetValue(tempComponent); } } if (fieldType == typeof(bool)) { PlainDataEntry plainDataEntry = entry; if (plainDataEntry.Ints == null) { plainDataEntry.Ints = new Dictionary(); } if (!entry.Ints.ContainsKey(stableHashCode)) { entry.Ints[stableHashCode] = (((bool)fieldInfo.GetValue(tempComponent)) ? 1 : 0); } } if (fieldType == typeof(Vector3)) { PlainDataEntry plainDataEntry = entry; if (plainDataEntry.Vecs == null) { plainDataEntry.Vecs = new Dictionary(); } if (!entry.Vecs.ContainsKey(stableHashCode)) { entry.Vecs[stableHashCode] = (Vector3)fieldInfo.GetValue(tempComponent); } } if (fieldType == typeof(GameObject)) { PlainDataEntry plainDataEntry = entry; if (plainDataEntry.Strings == null) { plainDataEntry.Strings = new Dictionary(); } if (!entry.Strings.ContainsKey(stableHashCode)) { Dictionary? strings = entry.Strings; GameObject val = (GameObject)fieldInfo.GetValue(tempComponent); strings[stableHashCode] = (((int)val != 0) ? ((Object)val).name : null) ?? ""; } } if (fieldType == typeof(ItemDrop)) { PlainDataEntry plainDataEntry = entry; if (plainDataEntry.Strings == null) { plainDataEntry.Strings = new Dictionary(); } if (!entry.Strings.ContainsKey(stableHashCode)) { Dictionary? strings2 = entry.Strings; ItemDrop val2 = (ItemDrop)fieldInfo.GetValue(tempComponent); strings2[stableHashCode] = (((int)val2 != 0) ? ((Object)val2).name : null) ?? ""; } } } } ZNetView.m_tempComponents.Clear(); return entry; } public DataCommand() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown AutoComplete.Register("data", (Func>)((int index) => DataAutoComplete.GetOptions()), DataAutoComplete.GetNamedOptions()); Helper.Command("data", "Modifies object data.", (ConsoleEvent)delegate(ConsoleEventArgs args) { Parameters = new DataParameters(); Parameters.ParseCommand(args); ZNetView[] objects = Parameters.GetObjects(); if (Parameters.Operations.ContainsKey("save") && objects.Length > 1) { throw new InvalidOperationException("Can't save multiple objects at once."); } Execute(args.Context, objects); }); } } public class DataParameters : BaseParameters { public static Dictionary SupportedOperations = new Dictionary { ["save"] = typeof(string), ["dump"] = typeof(string), ["clear"] = typeof(bool), ["load"] = typeof(string[]), ["merge"] = typeof(string[]), ["set"] = typeof(string[]), ["remove"] = typeof(string[]), ["keep"] = typeof(string[]), ["print"] = typeof(bool), ["copy_raw"] = typeof(string) }; public DataParameters() : base(SupportedOperations) { } protected override void ParseArg(string arg) { } protected override void ParseArg(string arg, string value) { } } public class DataRawCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func> <>9__0_0; public static ConsoleEvent <>9__0_1; public static Func, int> <>9__2_0; public static Func, Vector3> <>9__2_1; public static Func, int> <>9__2_2; public static Func, int> <>9__2_3; public static Func, int> <>9__2_4; public static Func, float> <>9__2_5; public static Func, int> <>9__2_6; public static Func, Quaternion> <>9__2_7; public static Func, int> <>9__2_8; public static Func, string> <>9__2_9; public static Func, int> <>9__2_10; public static Func, long> <>9__2_11; public static Func, int> <>9__2_12; public static Func, byte[]> <>9__2_13; public static Func <>9__2_14; internal List <.ctor>b__0_0(int index) { if (index != 0) { return ParameterInfo.None; } return DataLoading.DataKeys; } internal void <.ctor>b__0_1(ConsoleEventArgs args) { Helper.ArgsCheck(args, 2, "Missing data entry name."); if (!DataLoading.Data.TryGetValue(StringExtensionMethods.GetStableHashCode(args[1]), out DataEntry value)) { throw new InvalidOperationException("Data entry " + args[1] + " not found."); } Dictionary pars = ParseCommand(args); string @base = value.GetBase64(pars); if (@base == "AAAAAA==") { throw new InvalidOperationException("Data entry " + args[1] + " is empty."); } GUIUtility.systemCopyBuffer = @base; Helper.AddMessage(args.Context, "Data entry " + args[1] + " copied to clipboard.", false); } internal int b__2_0(KeyValuePair kvp) { return kvp.Key; } internal Vector3 b__2_1(KeyValuePair kvp) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return kvp.Value; } internal int b__2_2(KeyValuePair kvp) { return kvp.Key; } internal int b__2_3(KeyValuePair kvp) { return kvp.Value; } internal int b__2_4(KeyValuePair kvp) { return kvp.Key; } internal float b__2_5(KeyValuePair kvp) { return kvp.Value; } internal int b__2_6(KeyValuePair kvp) { return kvp.Key; } internal Quaternion b__2_7(KeyValuePair kvp) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return kvp.Value; } internal int b__2_8(KeyValuePair kvp) { return kvp.Key; } internal string b__2_9(KeyValuePair kvp) { return kvp.Value; } internal int b__2_10(KeyValuePair kvp) { return kvp.Key; } internal long b__2_11(KeyValuePair kvp) { return kvp.Value; } internal int b__2_12(KeyValuePair kvp) { return kvp.Key; } internal byte[] b__2_13(KeyValuePair kvp) { return kvp.Value; } internal int b__2_14(string s) { return StringExtensionMethods.GetStableHashCode(s); } } public DataRawCommand() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown AutoComplete.Register("data_raw", (Func>)((int index) => (index != 0) ? ParameterInfo.None : DataLoading.DataKeys)); object obj = <>c.<>9__0_1; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { Helper.ArgsCheck(args, 2, "Missing data entry name."); if (!DataLoading.Data.TryGetValue(StringExtensionMethods.GetStableHashCode(args[1]), out DataEntry value)) { throw new InvalidOperationException("Data entry " + args[1] + " not found."); } Dictionary pars = ParseCommand(args); string @base = value.GetBase64(pars); if (@base == "AAAAAA==") { throw new InvalidOperationException("Data entry " + args[1] + " is empty."); } GUIUtility.systemCopyBuffer = @base; Helper.AddMessage(args.Context, "Data entry " + args[1] + " copied to clipboard.", false); }; <>c.<>9__0_1 = val; obj = (object)val; } Helper.Command("data_raw", "[name] - Copies data entry to clipboard as base64 encoded string.", (ConsoleEvent)obj); } private static Dictionary ParseCommand(ConsoleEventArgs args) { Dictionary dictionary = new Dictionary(); string[] args2 = args.Args; for (int i = 0; i < args2.Length; i++) { string[] array = args2[i].Split(new char[1] { '=' }, 2); if (array.Length >= 2 && array[0].ToLower() == "par") { KeyValuePair keyValuePair = Parse.Kvp(array[1], ','); if (keyValuePair.Key == "") { throw new InvalidOperationException("Invalid data parameter " + array[1] + "."); } dictionary[keyValuePair.Key] = keyValuePair.Value; } } return dictionary; } public static void LegacySerialize(ZDO zdo, ZPackage pkg, string filter) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: 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_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0420: Unknown result type (might be due to invalid IL or missing references) //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_0707: Unknown result type (might be due to invalid IL or missing references) //IL_0711: Expected I4, but got Unknown ZDOID uid = zdo.m_uid; Dictionary dictionary = (ZDOExtraData.s_vec3.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_vec3[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value) : new Dictionary()); Dictionary dictionary2 = (ZDOExtraData.s_ints.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_ints[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value) : new Dictionary()); Dictionary dictionary3 = (ZDOExtraData.s_floats.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_floats[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value) : new Dictionary()); Dictionary dictionary4 = (ZDOExtraData.s_quats.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_quats[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value) : new Dictionary()); Dictionary dictionary5 = (ZDOExtraData.s_strings.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_strings[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value) : new Dictionary()); Dictionary dictionary6 = (ZDOExtraData.s_longs.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_longs[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value) : new Dictionary()); Dictionary dictionary7 = (ZDOExtraData.s_byteArrays.ContainsKey(uid) ? ((IEnumerable>)ZDOExtraData.s_byteArrays[uid]).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value) : new Dictionary()); if (filter == "") { dictionary.Remove(Hash.Scale); dictionary.Remove(Hash.SpawnPoint); dictionary2.Remove(Hash.Seed); dictionary2.Remove(Hash.Location); if (dictionary5.ContainsKey(Hash.OverrideItems)) { dictionary2.Remove(Hash.AddedDefaultItems); dictionary5.Remove(Hash.Items); } } else if (filter != "all") { HashSet filters = (from s in Parse.Split(filter, ',') select StringExtensionMethods.GetStableHashCode(s)).ToHashSet(); dictionary = FilterZdo(dictionary, filters); dictionary4 = FilterZdo(dictionary4, filters); dictionary3 = FilterZdo(dictionary3, filters); dictionary2 = FilterZdo(dictionary2, filters); dictionary6 = FilterZdo(dictionary6, filters); dictionary7 = FilterZdo(dictionary7, filters); } int num = 0; if (dictionary3.Count() > 0) { num |= 1; } if (dictionary.Count() > 0) { num |= 2; } if (dictionary4.Count() > 0) { num |= 4; } if (dictionary2.Count() > 0) { num |= 8; } if (dictionary5.Count() > 0) { num |= 0x10; } if (dictionary6.Count() > 0) { num |= 0x40; } if (dictionary7.Count() > 0) { num |= 0x80; } ZDOConnectionHashData value; ZDOConnectionHashData val = (ZDOExtraData.s_connectionsHashData.TryGetValue(uid, out value) ? value : null); if (val != null && filter == "all" && (int)val.m_type != 0 && val.m_hash != 0) { num |= 0x100; } pkg.Write(num); if (dictionary3.Count() > 0) { pkg.Write((byte)dictionary3.Count()); foreach (KeyValuePair item in dictionary3) { pkg.Write(item.Key); pkg.Write(item.Value); } } if (dictionary.Count() > 0) { pkg.Write((byte)dictionary.Count()); foreach (KeyValuePair item2 in dictionary) { pkg.Write(item2.Key); pkg.Write(item2.Value); } } if (dictionary4.Count() > 0) { pkg.Write((byte)dictionary4.Count()); foreach (KeyValuePair item3 in dictionary4) { pkg.Write(item3.Key); pkg.Write(item3.Value); } } if (dictionary2.Count() > 0) { pkg.Write((byte)dictionary2.Count()); foreach (KeyValuePair item4 in dictionary2) { pkg.Write(item4.Key); pkg.Write(item4.Value); } } if (dictionary6.Count() > 0) { pkg.Write((byte)dictionary6.Count()); foreach (KeyValuePair item5 in dictionary6) { pkg.Write(item5.Key); pkg.Write(item5.Value); } } if (dictionary5.Count() > 0) { pkg.Write((byte)dictionary5.Count()); foreach (KeyValuePair item6 in dictionary5) { pkg.Write(item6.Key); pkg.Write(item6.Value); } } if (dictionary7.Count() > 0) { pkg.Write((byte)dictionary7.Count()); foreach (KeyValuePair item7 in dictionary7) { pkg.Write(item7.Key); pkg.Write(item7.Value); } } if (val != null && (num & 0x100) != 0) { pkg.Write((byte)(int)val.m_type); pkg.Write(val.m_hash); } } private static Dictionary FilterZdo(Dictionary dict, HashSet filters) { return dict.Where>((KeyValuePair kvp) => filters.Contains(kvp.Key)).ToDictionary((KeyValuePair kvp) => kvp.Key, (KeyValuePair pair) => pair.Value); } } public class DungeonCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func <>9__1_1; public static ConsoleEvent <>9__1_0; internal void <.ctor>b__1_0(ConsoleEventArgs args) { <>c__DisplayClass1_0 CS$<>8__locals1 = new <>c__DisplayClass1_0 { player = Helper.GetPlayer() }; ZNetView val = (from view in ZNetScene.instance.m_instances.Values where Object.op_Implicit((Object)(object)((Component)view).GetComponent()) orderby Vector3.Distance(((Component)CS$<>8__locals1.player).transform.position, ((Component)view).transform.position) select view).FirstOrDefault(); if ((Object)(object)val == (Object)null) { Helper.AddError(args.Context, "No dungeon found.", false); } else if (args.Length < 2) { PrintRooms(val); } } internal bool <.ctor>b__1_1(ZNetView view) { return Object.op_Implicit((Object)(object)((Component)view).GetComponent()); } } [CompilerGenerated] private sealed class <>c__DisplayClass1_0 { public Player player; internal float <.ctor>b__2(ZNetView view) { //IL_000b: 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) return Vector3.Distance(((Component)player).transform.position, ((Component)view).transform.position); } } public const string Name = "dungeon"; public DungeonCommand() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown new ObjectAutoComplete(); object obj = <>c.<>9__1_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { Player player = Helper.GetPlayer(); ZNetView val2 = (from view in ZNetScene.instance.m_instances.Values where Object.op_Implicit((Object)(object)((Component)view).GetComponent()) orderby Vector3.Distance(((Component)player).transform.position, ((Component)view).transform.position) select view).FirstOrDefault(); if ((Object)(object)val2 == (Object)null) { Helper.AddError(args.Context, "No dungeon found.", false); } else if (args.Length < 2) { PrintRooms(val2); } }; <>c.<>9__1_0 = val; obj = (object)val; } Helper.Command("dungeon", "Modifies the nearest dungeon.", (ConsoleEvent)obj); } private static RoomData FindRoom(string type) { throw new NotImplementedException(); } private static string EditRoom(ZNetView obj, int i, string type, Vector3 pos, Quaternion rot) { //IL_002e: 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) string text = "room" + i; RoomData val = FindRoom(type); ZDO zDO = obj.GetZDO(); zDO.Set(text, ((object)val).GetHashCode()); zDO.Set(text, pos); zDO.Set(text, rot); return ""; } private static string PrintRooms(ZNetView obj) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00c0: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) List list = new List(); ZDO zDO = obj.GetZDO(); DungeonGenerator component = ((Component)obj).GetComponent(); list.Add($"Dungeon {obj.GetPrefabName()} {component.m_generatedSeed} {Helper.PrintVectorXZY(((Component)obj).transform.position)} {Helper.PrintAngleYXZ(((Component)obj).transform.rotation)}"); int num = zDO.GetInt("rooms", 0); for (int i = 0; i < num; i++) { string text = "room" + i; int num2 = zDO.GetInt(text, 0); Vector3 vec = zDO.GetVec3(text + "_pos", Vector3.zero); Quaternion quaternion = zDO.GetQuaternion(text + "_rot", Quaternion.identity); list.Add($"Room {i}: {((Object)DungeonDB.instance.GetRoom(num2).RoomInPrefab).name} {Helper.PrintVectorXZY(vec)} {Helper.PrintAngleYXZ(quaternion)}"); } return string.Join(", ", list); } } internal class ObjectHash { } internal class LocationHash { } internal class RoomHash { } public class FieldAutoComplete { public static Dictionary> Fields = new Dictionary>(); public static Dictionary> Keys = new Dictionary>(); private static List Components = new List(); private static readonly HashSet ValidTypes = new HashSet { typeof(string), typeof(int), typeof(float), typeof(bool), typeof(Vector3), typeof(GameObject), typeof(ItemDrop) }; private static readonly HashSet ValidTweakTypes; private static readonly Dictionary> ZdoFields; public static void Init() { Fields = LoadFields(); InitZdoFields(); foreach (KeyValuePair> field in Fields) { if (!Keys.ContainsKey(field.Key)) { Keys[field.Key] = new List(); } foreach (KeyValuePair item2 in field.Value) { string item = item2.Key.Replace("m_", ""); if (!Keys[field.Key].Contains(item)) { Keys[field.Key].Add(item); } } } foreach (KeyValuePair> zdoField in ZdoFields) { if (!Keys.ContainsKey(zdoField.Key)) { Keys[zdoField.Key] = new List(); } foreach (KeyValuePair item3 in zdoField.Value) { if (!Keys[zdoField.Key].Contains(item3.Key)) { Keys[zdoField.Key].Add(item3.Key); } } } Dictionary>.KeyCollection keys = Keys.Keys; List list = new List(keys.Count); list.AddRange(keys); Components = list; Components = Components.Distinct().ToList(); } private static Dictionary> LoadFields() { Dictionary> dictionary = new Dictionary>(); Type[] types = ComponentInfo.Types; HashSet hashSet = (WorldEditCommands.IsTweaks ? ValidTweakTypes : ValidTypes); Type[] array = types; foreach (Type type in array) { if (!dictionary.ContainsKey(type.Name)) { dictionary[type.Name] = new Dictionary(); } FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { if (hashSet.Contains(fieldInfo.FieldType)) { dictionary[type.Name][fieldInfo.Name] = fieldInfo.FieldType; PreventStripping.AddKey(type, fieldInfo); } } if (dictionary[type.Name].Count == 0) { dictionary.Remove(type.Name); } } return dictionary; } private static Dictionary> LoadTweakFields() { Dictionary> dictionary = new Dictionary>(); Type[] types = ComponentInfo.Types; HashSet validTweakTypes = ValidTweakTypes; Type[] array = types; foreach (Type type in array) { if (!dictionary.ContainsKey(type.Name)) { dictionary[type.Name] = new Dictionary(); } FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public); foreach (FieldInfo fieldInfo in fields) { if (fieldInfo.FieldType.IsEnum || validTweakTypes.Contains(fieldInfo.FieldType)) { dictionary[type.Name][fieldInfo.Name] = fieldInfo.FieldType; PreventStripping.AddKey(type, fieldInfo); } } if (dictionary[type.Name].Count == 0) { dictionary.Remove(type.Name); } } return dictionary; } public static List GetComponents() { return GetComponents(PrefabFromCommand(GetInput())); } private static string GetInput() { Aliasing.RestoreAlias(((Terminal)Console.m_instance).m_input); string result = Aliasing.Plain(((TMP_InputField)((Terminal)Console.m_instance).m_input).text); Aliasing.RemoveAlias(((Terminal)Console.m_instance).m_input); return result; } public static string PrefabFromCommand(string command) { string[] array = command.Split(new char[1] { ' ' }); string text = array.LastOrDefault((string s) => s.StartsWith("id=", StringComparison.Ordinal)); string result = ""; if (!string.IsNullOrEmpty(text)) { result = text.Split(new char[1] { '=' })[1]; } else if (array.Length > 1 && ZNetScene.instance.m_namedPrefabs.ContainsKey(StringExtensionMethods.GetStableHashCode(array[1]))) { result = array[1]; } else { Player localPlayer = Player.m_localPlayer; GameObject val = ((localPlayer != null) ? ((Humanoid)localPlayer).GetHoverObject() : null); if (Object.op_Implicit((Object)(object)val)) { result = Utils.GetPrefabName(val); } } return result; } public static List GetComponents(string prefab) { return GetComponents(StringExtensionMethods.GetStableHashCode(prefab)); } public static List GetComponents(int prefab) { if (ZNetScene.instance.m_namedPrefabs.TryGetValue(prefab, out var value)) { List list = new List(); list.AddRange(from c in value.GetComponentsInChildren() select ((object)c).GetType().Name); list.Add("zdo"); return list; } return Components; } public static List GetFields() { string input = GetInput(); return GetFields(ComponentFromCommand(PrefabFromCommand(input), input)); } private static string ComponentFromCommand(string prefab, string command) { string text = command.Split(new char[1] { ' ' }).LastOrDefault((string s) => s.StartsWith("field=", StringComparison.Ordinal) || s.StartsWith("f=", StringComparison.Ordinal)); if (text == null) { return ""; } string component = text.Split(new char[1] { '=' })[1].Split(new char[1] { ',' })[0]; return RealComponent(prefab, component); } private static List GetFields(string component) { if (!Keys.TryGetValue(component, out List value)) { return new List(); } return value; } public static List GetTypes(int index) { bool isTweaks = WorldEditCommands.IsTweaks; string input = GetInput(); string prefab = PrefabFromCommand(input); string component = ComponentFromCommand(prefab, input); string field = FieldFromCommand(component, input); bool zdoField; string field2 = RealField(component, field, out zdoField); Type type = GetType(component, field2, zdoField); if (type == typeof(string)) { return new List(1) { "Text" }; } if (type == typeof(int)) { return new List(1) { "Number" }; } if (type == typeof(float)) { return new List(1) { "Decimal" }; } if (type == typeof(long)) { return new List(1) { "Timestamp" }; } if (type == typeof(bool)) { return new List(2) { "true", "false" }; } if (type == typeof(Vector3)) { return ParameterInfo.XZY("Field", index); } if (type == typeof(Quaternion)) { return ParameterInfo.YXZ("Field", index); } if (type == typeof(GameObject)) { if (!isTweaks) { return ParameterInfo.Ids; } return GetIdsOrTransforms(prefab, component, field); } if (type == typeof(ObjectHash)) { return ParameterInfo.ObjectIds; } if (type == typeof(LocationHash)) { return ParameterInfo.LocationIds; } if (type == typeof(RoomHash)) { return ParameterInfo.RoomIds; } if (type == typeof(ItemDrop)) { return ParameterInfo.ItemIds; } if (isTweaks && type.IsEnum) { string[] names = Enum.GetNames(type); List list = new List(names.Length); list.AddRange(names); return list; } if (isTweaks && type == typeof(EffectList)) { return ParameterInfo.Ids; } return new List(); } private static List GetIdsOrTransforms(string prefab, string component, string field) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown GameObject prefab2 = ZNetScene.instance.GetPrefab(prefab); if (!Object.op_Implicit((Object)(object)prefab2)) { return ParameterInfo.Ids; } MonoBehaviour val = ((IEnumerable)prefab2.GetComponents()).FirstOrDefault((Func)((MonoBehaviour c) => ((object)c).GetType().Name == component)); if ((Object)(object)val == (Object)null) { return ParameterInfo.Ids; } bool zdoField; FieldInfo field2 = ((object)val).GetType().GetField(RealField(component, field, out zdoField)); if (field2 == null || field2.FieldType != typeof(GameObject)) { return ParameterInfo.Ids; } GameObject val2 = (GameObject)field2.GetValue(val); if (Object.op_Implicit((Object)(object)val2) && (Object)(object)ZNetScene.instance.GetPrefab(((Object)val2).name) == (Object)(object)val2) { return ParameterInfo.Ids; } List list = new List(); GetChild("/", prefab2.transform, list); return list; } private static void GetChild(string prefix, Transform tr, List trs) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown foreach (Transform item in tr) { Transform val = item; trs.Add(prefix + ((Object)val).name); GetChild(prefix + ((Object)val).name + "/", val, trs); } } private static string FieldFromCommand(string component, string command) { string[] source = command.Split(new char[1] { ' ' }); string text = source.LastOrDefault((string s) => s.StartsWith("field=", StringComparison.Ordinal) || s.StartsWith("f=", StringComparison.Ordinal)); if (text == null) { return ""; } source = text.Split(new char[1] { '=' })[1].Split(new char[1] { ',' }); bool zdoField; if (source.Length >= 2) { return RealField(component, source[1], out zdoField); } return ""; } public static Type GetType(string component, string field, bool zdoField) { if (zdoField) { if (!ZdoFields.TryGetValue("zdo", out Dictionary value)) { return typeof(void); } if (!value.TryGetValue(field, out var value2)) { return typeof(void); } return value2; } if (!Fields.TryGetValue(component, out Dictionary value3)) { return typeof(void); } if (!value3.TryGetValue(field, out var value4)) { return typeof(void); } return value4; } public static string RealComponent(string prefab, string component) { List components = GetComponents(prefab); return components.FirstOrDefault((string s) => s.Equals(component, StringComparison.OrdinalIgnoreCase)) ?? components.FirstOrDefault((string s) => s.StartsWith(component, StringComparison.OrdinalIgnoreCase)) ?? component; } public static string RealField(string component, string field, out bool zdoField) { zdoField = false; string f = "m_" + field; Dictionary value; List source = (Fields.TryGetValue(component, out value) ? value.Keys.ToList() : new List()); string text = source.FirstOrDefault((string s) => s.Equals(f, StringComparison.OrdinalIgnoreCase)); if (text != null) { return text; } zdoField = true; Dictionary value2; List source2 = (ZdoFields.TryGetValue(component, out value2) ? value2.Keys.ToList() : new List()); string text2 = source2.FirstOrDefault((string s) => s.Equals(field, StringComparison.OrdinalIgnoreCase)); if (text2 != null) { return text2; } zdoField = false; string text3 = source.FirstOrDefault((string s) => s.StartsWith(f, StringComparison.OrdinalIgnoreCase) || s.StartsWith(field, StringComparison.OrdinalIgnoreCase)); if (text3 != null) { return text3; } zdoField = true; string text4 = source2.FirstOrDefault((string s) => s.StartsWith(field, StringComparison.OrdinalIgnoreCase)); if (text4 != null) { return text4; } return field; } private static void InitZdoFields() { if (ZdoFields.ContainsKey("zdo")) { return; } if (WorldEditCommands.IsCLLC) { Dictionary dictionary = ZdoFields["MonsterAI"]; dictionary["CL&LC effect"] = typeof(Enum_CLLC_Effect); dictionary["CL&LC infusion"] = typeof(Enum_CLLC_Infusion); } Dictionary dictionary2 = new Dictionary(); foreach (KeyValuePair> zdoField in ZdoFields) { foreach (KeyValuePair item in zdoField.Value) { dictionary2[item.Key] = item.Value; } } ZdoFields["zdo"] = dictionary2; } static FieldAutoComplete() { HashSet hashSet = new HashSet(); foreach (Type validType in ValidTypes) { hashSet.Add(validType); } hashSet.Add(typeof(EffectList)); ValidTweakTypes = hashSet; ZdoFields = new Dictionary> { { "ArmorStand", new Dictionary { { "pose", typeof(int) }, { "0_item", typeof(GameObject) }, { "1_item", typeof(GameObject) }, { "2_item", typeof(GameObject) }, { "0_variant", typeof(int) }, { "1_variant", typeof(int) }, { "2_variant", typeof(int) } } }, { "AnimalAI", new Dictionary { { "aggravated", typeof(bool) }, { "alert", typeof(bool) }, { "bosscount", typeof(bool) }, { "spawntime", typeof(long) }, { "ShownAlertMessage", typeof(bool) }, { "huntplayer", typeof(bool) }, { "lastWorldTime", typeof(long) }, { "spawnpoint", typeof(Vector3) }, { "patrol", typeof(bool) }, { "patrolPoint", typeof(Vector3) } } }, { "Bed", new Dictionary { { "owner", typeof(long) }, { "ownerName", typeof(string) } } }, { "Beehive", new Dictionary { { "lastTime", typeof(long) }, { "level", typeof(int) }, { "product", typeof(float) } } }, { "Catapult", new Dictionary { { "Locked", typeof(bool) }, { "visual", typeof(GameObject) } } }, { "CharacterAnimEvent", new Dictionary { { "LookTarget", typeof(Vector3) } } }, { "Cinder", new Dictionary { { "spread", typeof(bool) } } }, { "CinderSpawner", new Dictionary { { "spread", typeof(bool) } } }, { "Container", new Dictionary { { "addedDefaultItems", typeof(bool) }, { "InUse", typeof(bool) }, { "items", typeof(string) } } }, { "CookingStation", new Dictionary { { "fuel", typeof(float) }, { "StartTime", typeof(long) }, { "slot0", typeof(GameObject) }, { "slot1", typeof(GameObject) }, { "slot2", typeof(GameObject) }, { "slotstatus0", typeof(int) }, { "slotstatus1", typeof(int) }, { "slotstatus2", typeof(int) } } }, { "Corpse", new Dictionary { { "timeOfDeath", typeof(long) } } }, { "CreatureSpawner", new Dictionary { { "alive_time", typeof(long) } } }, { "DungeonGenerator", new Dictionary { { "rooms", typeof(int) }, { "room0", typeof(RoomHash) }, { "room1", typeof(RoomHash) }, { "room2", typeof(RoomHash) }, { "room0_pos", typeof(Vector3) }, { "room1_pos", typeof(Vector3) }, { "room2_pos", typeof(Vector3) }, { "room0_rot", typeof(Quaternion) }, { "room1_rot", typeof(Quaternion) }, { "room2_rot", typeof(Quaternion) } } }, { "Destructible", new Dictionary { { "health", typeof(float) } } }, { "Door", new Dictionary { { "state", typeof(int) } } }, { "EggGrow", new Dictionary { { "GrowStart", typeof(float) } } }, { "Fermenter", new Dictionary { { "Content", typeof(GameObject) }, { "StartTime", typeof(long) } } }, { "Fireplace", new Dictionary { { "fuel", typeof(float) }, { "lastTime", typeof(long) }, { "state", typeof(bool) } } }, { "Fish", new Dictionary { { "escape", typeof(float) }, { "hooked", typeof(bool) }, { "spawnpoint", typeof(Vector3) } } }, { "FishingFloat", new Dictionary { { "Bait", typeof(GameObject) }, { "rodOwner", typeof(long) } } }, { "Gibber", new Dictionary { { "HitPoint", typeof(Vector3) }, { "HitDir", typeof(Vector3) } } }, { "Humanoid", new Dictionary { { "BodyVelocity", typeof(Vector3) }, { "bosscount", typeof(bool) }, { "health", typeof(float) }, { "IsBlocking", typeof(bool) }, { "level", typeof(int) }, { "max_health", typeof(float) }, { "noise", typeof(float) }, { "RandomSkillFactor", typeof(float) }, { "seed", typeof(int) }, { "tamed", typeof(bool) } } }, { "ItemDrop", new Dictionary { { "crafterID", typeof(long) }, { "crafterName", typeof(string) }, { "data_0", typeof(string) }, { "data_1", typeof(string) }, { "data_2", typeof(string) }, { "data__0", typeof(string) }, { "data__1", typeof(string) }, { "data__2", typeof(string) }, { "durability", typeof(float) }, { "pickedUp", typeof(bool) }, { "piece", typeof(bool) }, { "quality", typeof(int) }, { "spawntime", typeof(long) }, { "stack", typeof(int) }, { "variant", typeof(int) }, { "worldLevel", typeof(int) } } }, { "ItemStand", new Dictionary { { "quality", typeof(int) }, { "item", typeof(GameObject) }, { "variant", typeof(int) } } }, { "Leviathan", new Dictionary { { "dead", typeof(bool) } } }, { "LineConnect", new Dictionary { { "line_slack", typeof(float) } } }, { "LocationProxy", new Dictionary { { "location", typeof(LocationHash) }, { "seed", typeof(int) } } }, { "LootSpawner", new Dictionary { { "spawntime", typeof(long) } } }, { "MaterialVariation", new Dictionary { { "MatVar0", typeof(int) }, { "MatVar1", typeof(int) }, { "MatVar2", typeof(int) } } }, { "MineRock", new Dictionary { { "Health0", typeof(float) }, { "Health1", typeof(float) }, { "Health2", typeof(float) } } }, { "MineRock5", new Dictionary { { "health", typeof(float) } } }, { "MonsterAI", new Dictionary { { "aggravated", typeof(bool) }, { "alert", typeof(bool) }, { "bosscount", typeof(bool) }, { "DespawnInDay", typeof(bool) }, { "EventCreature", typeof(bool) }, { "huntplayer", typeof(bool) }, { "lastWorldTime", typeof(long) }, { "patrol", typeof(bool) }, { "patrolPoint", typeof(Vector3) }, { "ShownAlertMessage", typeof(bool) }, { "sleeping", typeof(bool) }, { "spawnpoint", typeof(Vector3) }, { "spawntime", typeof(long) } } }, { "MusicLocation", new Dictionary { { "played", typeof(bool) } } }, { "Pickable", new Dictionary { { "picked", typeof(bool) }, { "picked_time", typeof(long) } } }, { "PickableItem", new Dictionary { { "itemPrefab", typeof(ObjectHash) }, { "itemStack", typeof(int) } } }, { "Piece", new Dictionary { { "creator", typeof(long) } } }, { "Plant", new Dictionary { { "seed", typeof(int) }, { "plantTime", typeof(long) } } }, { "Player", new Dictionary { { "baseValue", typeof(int) }, { "BodyVelocity", typeof(Vector3) }, { "DebugFly", typeof(bool) }, { "dodgeinv", typeof(bool) }, { "dead", typeof(bool) }, { "health", typeof(float) }, { "IsBlocking", typeof(bool) }, { "eitr", typeof(float) }, { "emote", typeof(string) }, { "emoteID", typeof(int) }, { "emote_oneshot", typeof(bool) }, { "inBed", typeof(bool) }, { "noise", typeof(float) }, { "playerID", typeof(long) }, { "playerName", typeof(string) }, { "pvp", typeof(bool) }, { "stamina", typeof(float) }, { "Stealth", typeof(float) }, { "wakeup", typeof(bool) }, { "WeaponLoaded", typeof(bool) } } }, { "PrivateArea", new Dictionary { { "creatorName", typeof(string) }, { "enabled", typeof(bool) }, { "permitted", typeof(int) }, { "pu_id0", typeof(long) }, { "pu_id1", typeof(long) }, { "pu_id2", typeof(long) }, { "pu_name0", typeof(string) }, { "pu_name1", typeof(string) }, { "pu_name2", typeof(string) } } }, { "Procreation", new Dictionary { { "lovePoints", typeof(int) }, { "pregnant", typeof(long) } } }, { "Projectile", new Dictionary { { "visual", typeof(string) } } }, { "Ragdoll", new Dictionary { { "drops", typeof(int) }, { "drop_hash0", typeof(ObjectHash) }, { "drop_hash1", typeof(ObjectHash) }, { "drop_hash2", typeof(ObjectHash) }, { "drop_amount0", typeof(float) }, { "drop_amount1", typeof(float) }, { "drop_amount2", typeof(float) }, { "Hue", typeof(float) }, { "InitVel", typeof(Vector3) }, { "Saturation", typeof(float) }, { "Value", typeof(float) } } }, { "RandomFlyingBird", new Dictionary { { "landed", typeof(bool) }, { "spawnpoint", typeof(Vector3) } } }, { "ResourceRoot", new Dictionary { { "lastTime", typeof(long) }, { "level", typeof(float) } } }, { "Sadle", new Dictionary { { "user", typeof(long) } } }, { "SapCollector", new Dictionary { { "lastTime", typeof(long) }, { "level", typeof(int) }, { "product", typeof(float) } } }, { "SEMan", new Dictionary { { "seAttrib", typeof(int) } } }, { "ShieldGenerator", new Dictionary { { "fuel", typeof(float) }, { "StartTime", typeof(long) } } }, { "Ship", new Dictionary { { "forward", typeof(int) }, { "rudder", typeof(float) } } }, { "ShipConstructor", new Dictionary { { "user", typeof(long) } } }, { "Sign", new Dictionary { { "author", typeof(string) }, { "text", typeof(string) } } }, { "Smelter", new Dictionary { { "accTime", typeof(float) }, { "bakeTimer", typeof(float) }, { "fuel", typeof(float) }, { "item0", typeof(GameObject) }, { "item1", typeof(GameObject) }, { "item2", typeof(GameObject) }, { "queued", typeof(int) }, { "SpawnOre", typeof(GameObject) }, { "SpawnAmount", typeof(int) }, { "StartTime", typeof(long) } } }, { "Tameable", new Dictionary { { "HaveSaddle", typeof(bool) }, { "TamedName", typeof(string) }, { "TamedNameAuthor", typeof(string) } } }, { "TeleportWorld", new Dictionary { { "tag", typeof(string) }, { "tagauthor", typeof(string) } } }, { "Trap", new Dictionary { { "state", typeof(int) }, { "triggered", typeof(float) } } }, { "TreeBase", new Dictionary { { "health", typeof(float) } } }, { "TreeLog", new Dictionary { { "health", typeof(float) } } }, { "TriggerSpawner", new Dictionary { { "spawntime", typeof(long) } } }, { "Turret", new Dictionary { { "ammo", typeof(int) }, { "ammoType", typeof(GameObject) }, { "lastAttack", typeof(float) }, { "targets", typeof(int) }, { "target0", typeof(string) }, { "target1", typeof(string) }, { "target2", typeof(string) } } }, { "Vagon", new Dictionary { { "attachJoint", typeof(bool) } } }, { "WearNTear", new Dictionary { { "health", typeof(float) }, { "support", typeof(float) } } }, { "WispSpawner", new Dictionary { { "LastSpawn", typeof(long) } } } }; } } [HarmonyPatch(typeof(ZDO))] public class PreventStripping { private static readonly HashSet FieldZdoKeys = new HashSet(); public static void AddKey(Type type, FieldInfo fieldInfo) { if (fieldInfo.FieldType == typeof(string) || fieldInfo.FieldType == typeof(int) || fieldInfo.FieldType == typeof(bool)) { string text = type.Name + "." + fieldInfo.Name; FieldZdoKeys.Add(StringExtensionMethods.GetStableHashCode(text)); } } [HarmonyPatch("Strip", new Type[] { typeof(int), typeof(string) })] [HarmonyTranspiler] private static IEnumerable String(IEnumerable instructions, ILGenerator generator) { return Transpile(instructions, generator); } [HarmonyPatch("Strip", new Type[] { typeof(int), typeof(int) })] [HarmonyTranspiler] private static IEnumerable Int(IEnumerable instructions, ILGenerator generator) { return Transpile(instructions, generator); } private static IEnumerable Transpile(IEnumerable instructions, ILGenerator generator) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Expected O, but got Unknown //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown Label label = default(Label); return new CodeMatcher(instructions, generator).CreateLabelAt(0, ref label).Start().InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(PreventStripping), "FieldZdoKeys")) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldarg_0, (object)null) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(HashSet), "Contains", (Type[])null, (Type[])null)) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Brfalse, (object)label) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ldc_I4_0, (object)null) }) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Ret, (object)null) }) .InstructionEnumeration(); } } public class ObjectAutoComplete : SharedObjectAutoComplete { public List NamedParameters; public ObjectAutoComplete() { NamedParameters = SharedObjectAutoComplete.WithSharedParameters(new List(26) { "wild", "info", "sleep", "id", "ignore", "move", "rotate", "remove", "origin", "visual", "fuel", "prefab", "center", "respawn", "from", "rect", "angle", "creator", "chance", "type", "connect", "status", "components", "match", "unmatch", "copy" }); AutoComplete.Register("object", (Func>)((int index) => NamedParameters), SharedObjectAutoComplete.WithSharedFetchers(new Dictionary>> { { "status", (int index) => index switch { 0 => ParameterInfo.StatusEffects, 1 => ParameterInfo.Create("status=name,duration,intensity", "Duration in seconds."), 2 => ParameterInfo.Create("status=name,duration,intensity", "Strength of the effect."), _ => ParameterInfo.None, } }, { "type", (int index) => ParameterInfo.Components }, { "connect", (int index) => ParameterInfo.Flag("Connect") }, { "mirror", (int index) => ParameterInfo.Flag("Mirror") }, { "components", (int index) => ParameterInfo.Flag("Components") }, { "respawn", (int index) => ParameterInfo.Flag("Respawn") }, { "wild", (int index) => ParameterInfo.Flag("Wild") }, { "remove", (int index) => ParameterInfo.Flag("Remove") }, { "sleep", (int index) => ParameterInfo.Flag("Sleep") }, { "info", (int index) => ParameterInfo.Flag("info") }, { "id", (int index) => ParameterInfo.Ids }, { "ignore", (int index) => ParameterInfo.Ids }, { "prefab", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.ObjectIds }, { "fuel", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("fuel", "number", "Sets or gets the fuel amount.") }, { "move", (int index) => ParameterInfo.FRU("move", "Movement offset based on the player rotation (unless origin is given)", index) }, { "rotate", delegate(int index) { string text = "Rotation based on the player rotation (unless origin is given)"; return (index == 0) ? ParameterInfo.Create("rotate=reset or " + ParameterInfo.YawRollPitch("rotate", text, index)[0].Substring(1)) : ParameterInfo.YawRollPitch("rotate", text, index); } }, { "center", (int index) => ParameterInfo.XZY("center", "Overrides the player position. For rotate sets also the rotation center point.", index) }, { "from", (int index) => ParameterInfo.XZY("center", "Overrides the player position. For rotate sets also the rotation center point.", index) }, { "visual", (int index) => SharedObjectAutoComplete.VisualAutoComplete("visual", index) }, { "origin", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Origin }, { "rect", (int index) => index switch { 0 => ParameterInfo.Create("rect=size or rect=width,depth", "Area of affected objects."), 1 => ParameterInfo.Create("rect=width,depth", "Area of affected objects."), _ => ParameterInfo.None, } }, { "angle", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("angle=degrees", "Direction of the rectangle when used with rect.") }, { "circle", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("circle=number", "Radius of affected objects.") }, { "radius", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("radius=number", "Radius of affected objects.") }, { "creator", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("creator=player ID", "Sets creator of objects (0 for no creator).") }, { "chance", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("chance=number", "Chance to affect the object (from 0.0 to 1.0).") }, { "match", (int index) => (index != 0) ? ParameterInfo.None : DataLoading.DataKeys }, { "unmatch", (int index) => (index != 0) ? ParameterInfo.None : DataLoading.DataKeys }, { "copy", (int index) => ParameterInfo.Flag("copy") } })); } } public class ObjectCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func, string> <>9__3_1; public static Func, string> <>9__3_2; public static Func, string> <>9__3_3; public static Func, string> <>9__3_4; public static ConsoleEvent <>9__4_0; internal string b__3_1(KeyValuePair kvp) { return kvp.Key; } internal string b__3_2(KeyValuePair kvp) { return kvp.Value; } internal string b__3_3(KeyValuePair kvp) { return kvp.Key; } internal string b__3_4(KeyValuePair kvp) { return kvp.Value; } internal void <.ctor>b__4_0(ConsoleEventArgs args) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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) ObjectParameters objectParameters = new ObjectParameters(args); ZNetView[] views; if (objectParameters.Connect) { ZNetView hovered = Selector.GetHovered(50f, objectParameters.IncludedIds, objectParameters.Components, objectParameters.ExcludedIds); if ((Object)(object)hovered == (Object)null) { return; } views = Selector.GetConnected(hovered, objectParameters.ConnectionIds, objectParameters.IncludedIds, objectParameters.ExcludedIds); } else if (objectParameters.Radius != null) { views = Selector.GetNearby(objectParameters.IncludedIds, objectParameters.Components, objectParameters.ExcludedIds, (Vector3)(((??)objectParameters.Center) ?? objectParameters.From), objectParameters.Radius, objectParameters.Height); } else if (objectParameters.Width != null && objectParameters.Depth != null) { views = Selector.GetNearby(objectParameters.IncludedIds, objectParameters.Components, objectParameters.ExcludedIds, (Vector3)(((??)objectParameters.Center) ?? objectParameters.From), objectParameters.Angle, objectParameters.Width, objectParameters.Depth, objectParameters.Height); } else { ZNetView hovered2 = Selector.GetHovered(50f, objectParameters.IncludedIds, objectParameters.ExcludedIds); if ((Object)(object)hovered2 == (Object)null) { return; } if (!Selector.GetPrefabs(objectParameters.IncludedIds).Contains(hovered2.GetZDO().GetPrefab())) { Helper.AddMessage(args.Context, "Skipped: " + ((Object)hovered2).name + " has invalid id.", false); return; } views = (ZNetView[])(object)new ZNetView[1] { hovered2 }; } Execute(args.Context, objectParameters, objectParameters.Operations, views); } } public static Random Random = new Random(); public const string Name = "object"; public static bool Roll(float value) { if (value >= 1f) { return true; } return Random.NextDouble() < (double)value; } private static void Execute(Terminal context, ObjectParameters pars, IEnumerable operations, ZNetView[] views) { //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_065a: Unknown result type (might be due to invalid IL or missing references) //IL_061d: Unknown result type (might be due to invalid IL or missing references) _ = ZNetScene.instance; DataEntry matchData = ((pars.Match == "") ? null : DataHelper.Get(pars.Match)); DataEntry unmatchData = ((pars.Unmatch == "") ? null : DataHelper.Get(pars.Unmatch)); views = views.Where(delegate(ZNetView view) { if (!Object.op_Implicit((Object)(object)view)) { return false; } if (!view.GetZDO().IsValid()) { context.AddString("Skipped: " + ((Object)view).name + " is not loaded."); return false; } if (matchData != null && !matchData.Match(pars.DataParameters.ToDictionary, string, string>((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value), view.GetZDO())) { context.AddString("Skipped: " + ((Object)view).name + " not matching filter."); return false; } if (unmatchData != null && !unmatchData.Unmatch(pars.DataParameters.ToDictionary, string, string>((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value), view.GetZDO())) { context.AddString("Skipped: " + ((Object)view).name + " matching filter."); return false; } if (!Roll(pars.Chance)) { context.AddString("Skipped: " + ((Object)view).name + " (chance)."); return false; } return true; }).ToArray(); UndoHelper.BeginAction(); ZNetView[] array = views; foreach (ZNetView val in array) { if (val.GetZDO().GetPrefab() != Hash.Player) { val.ClaimOwnership(); } } int num2 = views.Count(); foreach (string operation in operations) { array = views; foreach (ZNetView val2 in array) { if (!Object.op_Implicit((Object)(object)val2)) { continue; } string text = ""; string prefabName = Utils.GetPrefabName(((Component)val2).gameObject); if (operation == "durability" || operation == "health") { text = ChangeHealth(val2, Helper.RandomValue(pars.Health), pars.isHealthPercentage); } if (operation == "damage") { text = Actions.Damage(val2, Helper.RandomValue(pars.Damage)); } if (operation == "ammo") { text = Actions.Ammo(val2, Helper.RandomValue(pars.Ammo)); } if (operation == "ammotype") { text = Actions.AmmoType(val2, pars.AmmoType); } if (operation == "stars" || operation == "level") { text = SetStars(val2, Helper.RandomValue(pars.Level) - 1); } if (operation == "fuel" && pars.Fuel != null) { text = SetFuel(val2, Helper.RandomValue(pars.Fuel)); } if (operation == "creator") { text = SetCreator(val2, pars.Creator); } if (operation == "fuel" && pars.Fuel == null) { text = PrintFuel(val2); } if (operation == "tame") { text = MakeTame(val2); } if (operation == "wild") { text = MakeWild(val2); } if (operation == "baby") { text = SetBaby(val2); } if (operation == "respawn") { text = Respawn(val2); } if (operation == "info") { text = GetInfo(val2); } if (operation == "components") { text = GetComponents(val2); } if (operation == "sleep") { text = MakeSleep(val2); } if (operation == "visual") { text = SetVisual(val2, pars.Visual); } if (operation == "model") { text = SetModel(val2, Helper.RandomValue(pars.Model)); } if (operation == "helmet") { text = SetHelmet(val2, pars.Helmet); } if (operation == "field" || operation == "f") { SetFields(val2, pars.Fields); } if (operation == "left_hand") { text = SetLeftHand(val2, pars.LeftHand); } if (operation == "right_hand") { text = SetRightHand(val2, pars.RightHand); } if (operation == "chest") { text = SetChest(val2, pars.Chest); } if (operation == "shoulders") { text = SetShoulder(val2, pars.Shoulders); } if (operation == "legs") { text = SetLegs(val2, pars.Legs); } if (operation == "utility") { text = SetUtility(val2, pars.Utility); } if (operation == "prefab") { text = SetPrefab(val2, pars.Prefab); } if (operation == "copy") { text = CopyId(val2); } if (operation == "status" && pars.StatusName != null) { text = SetStatus(val2, pars.StatusName, Helper.RandomValue(pars.StatusDuration), Helper.RandomValue(pars.StatusIntensity)); } if (operation == "move") { text = Move(val2, Helper.RandomValue(pars.Offset), pars.Origin); } if (operation == "mirror" && pars.Center.HasValue) { text = Mirror(val2, pars.Center.Value); } if (operation == "distant" && pars.Distant.HasValue) { text = SetDistant(val2, pars.Distant.Value); } if (operation == "persist" && pars.Persist.HasValue) { text = SetPersistent(val2, pars.Persist.Value); } if (operation == "rotate") { text = ((!pars.ResetRotation) ? Rotate(val2, Helper.RandomValue(pars.Rotation), pars.Origin, pars.Center) : ResetRotation(val2)); } if (operation == "scale") { text = Scale(val2, Helper.RandomValue(pars.Scale)); } if (operation == "remove") { UndoHelper.AddRemoveAction(val2.GetZDO()); Actions.RemoveZDO(val2.GetZDO()); text = "Entity ยค destroyed."; } if (!(text == "")) { string text2 = text.Replace("ยค", prefabName); if (num2 == 1) { Helper.AddMessage(context, text2, false); } else { context.AddString(text2); } } } } if (operations.Contains("move") || operations.Contains("scale") || operations.Contains("rotate") || operations.Contains("mirror")) { array = views; WearNTear val4 = default(WearNTear); foreach (ZNetView val3 in array) { if (Object.op_Implicit((Object)(object)val3) && ((Component)val3).TryGetComponent(ref val4)) { val4.m_colliders = null; } } } UndoHelper.EndAction(); } public ObjectCommand() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown new ObjectAutoComplete(); object obj = <>c.<>9__4_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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) ObjectParameters objectParameters = new ObjectParameters(args); ZNetView[] views; if (objectParameters.Connect) { ZNetView hovered = Selector.GetHovered(50f, objectParameters.IncludedIds, objectParameters.Components, objectParameters.ExcludedIds); if ((Object)(object)hovered == (Object)null) { return; } views = Selector.GetConnected(hovered, objectParameters.ConnectionIds, objectParameters.IncludedIds, objectParameters.ExcludedIds); } else if (objectParameters.Radius != null) { views = Selector.GetNearby(objectParameters.IncludedIds, objectParameters.Components, objectParameters.ExcludedIds, (Vector3)(((??)objectParameters.Center) ?? objectParameters.From), objectParameters.Radius, objectParameters.Height); } else if (objectParameters.Width != null && objectParameters.Depth != null) { views = Selector.GetNearby(objectParameters.IncludedIds, objectParameters.Components, objectParameters.ExcludedIds, (Vector3)(((??)objectParameters.Center) ?? objectParameters.From), objectParameters.Angle, objectParameters.Width, objectParameters.Depth, objectParameters.Height); } else { ZNetView hovered2 = Selector.GetHovered(50f, objectParameters.IncludedIds, objectParameters.ExcludedIds); if ((Object)(object)hovered2 == (Object)null) { return; } if (!Selector.GetPrefabs(objectParameters.IncludedIds).Contains(hovered2.GetZDO().GetPrefab())) { Helper.AddMessage(args.Context, "Skipped: " + ((Object)hovered2).name + " has invalid id.", false); return; } views = (ZNetView[])(object)new ZNetView[1] { hovered2 }; } Execute(args.Context, objectParameters, objectParameters.Operations, views); }; <>c.<>9__4_0 = val; obj = (object)val; } Helper.Command("object", "Modifies objects.", (ConsoleEvent)obj); } private static string ChangeHealth(ZNetView obj, float amount, bool isPercentage) { if (!Object.op_Implicit((Object)(object)((Component)obj).GetComponent()) && !Object.op_Implicit((Object)(object)((Component)obj).GetComponent()) && !Object.op_Implicit((Object)(object)((Component)obj).GetComponent()) && !Object.op_Implicit((Object)(object)((Component)obj).GetComponent()) && !Object.op_Implicit((Object)(object)((Component)obj).GetComponent())) { return "Skipped: ยค is not a creature or a destructible."; } UndoHelper.AddEditAction(obj); float num = Actions.SetHealth(((Component)obj).gameObject, amount, isPercentage); string arg = ((amount == 0f) ? "default" : (isPercentage ? $"{100f * amount:0.##} %" : amount.ToString("F0"))); return $"ยค health changed from {num:F0} to {arg}."; } private static string SetStars(ZNetView view, int amount) { Character component = ((Component)view).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return "Skipped: ยค is not a creature."; } UndoHelper.AddEditAction(view); int num = component.GetLevel() - 1; Actions.SetLevel(component, amount + 1); return $"ยค stars changed from {num} to {amount}."; } private static string PrintFuel(ZNetView view) { Smelter val = default(Smelter); Fireplace val2 = default(Fireplace); CookingStation val3 = default(CookingStation); if (!((((Component)view).TryGetComponent(ref val) && (Object)(object)val.m_fuelItem != (Object)null) | (((Component)view).TryGetComponent(ref val2) && (Object)(object)val2.m_fuelItem != (Object)null) | (((Component)view).TryGetComponent(ref val3) && (Object)(object)val3.m_fuelItem != (Object)null))) { return "Skipped: ยค doesn't use fuel."; } float num = view.GetZDO().GetFloat("fuel", 0f); return $"ยค has {num} fuel."; } private static string SetFields(ZNetView view, Dictionary fields) { UndoHelper.AddEditAction(view); int num = Actions.SetFields(view, fields); if (num == 0) { return "Skipped: ยค doesn't have valid components."; } if (num == fields.Count) { return $"ยค {fields.Count} fields set."; } return $"ยค {num} of {fields.Count} fields set."; } private static string SetFuel(ZNetView view, float amount) { Smelter val = default(Smelter); Fireplace val2 = default(Fireplace); CookingStation val3 = default(CookingStation); if (!((((Component)view).TryGetComponent(ref val) && (Object)(object)val.m_fuelItem != (Object)null) | (((Component)view).TryGetComponent(ref val2) && (Object)(object)val2.m_fuelItem != (Object)null) | (((Component)view).TryGetComponent(ref val3) && (Object)(object)val3.m_fuelItem != (Object)null))) { return "Skipped: ยค doesn't use fuel."; } UndoHelper.AddEditAction(view); float num = view.GetZDO().GetFloat("fuel", 0f); Actions.SetFuel(view, amount); return $"ยค fuel changed from {num} to {amount}."; } private static string Move(ZNetView view, Vector3 offset, string origin) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) UndoHelper.AddEditAction(view); Actions.Move(view, offset, origin); return $"ยค moved {offset:F1} from the {origin}."; } private static string ResetRotation(ZNetView view) { UndoHelper.AddEditAction(view); Actions.ResetRotation(view); return "ยค rotation reseted."; } private static string Mirror(ZNetView view, Vector3 center) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) UndoHelper.AddEditAction(view); Actions.Mirror(view, center); return "ยค mirrored."; } private static string Rotate(ZNetView view, Vector3 rotation, string origin, Vector3? center = null) { //IL_0007: 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) UndoHelper.AddEditAction(view); Actions.Rotate(view, rotation, origin, center); return $"ยค rotated {rotation:F1} from the {origin}."; } private static string Scale(ZNetView view, Vector3 scale) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) UndoHelper.AddEditAction(view); string arg = (Actions.Scale(view, scale) ? " (scaling enabled)" : ""); return $"ยค scaled to {scale:F1}{arg}."; } private static string SetDistant(ZNetView view, bool distant) { UndoHelper.AddEditAction(view); Actions.SetDistant(((Component)view).gameObject, distant); if (!distant) { return "ยค made normally loaded."; } return "ยค made distant loaded."; } private static string SetPersistent(ZNetView view, bool persist) { UndoHelper.AddEditAction(view); Actions.SetPersistent(((Component)view).gameObject, persist); if (!persist) { return "ยค made non-persistent."; } return "ยค made persistent."; } private static string SetBaby(ZNetView view) { Growup component = ((Component)view).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return "Skipped: ยค is not an offspring."; } UndoHelper.AddEditAction(view); Actions.SetBaby(component); return "ยค growth disabled."; } private static string Respawn(ZNetView view) { if (!Actions.CanRespawn(((Component)view).gameObject)) { return "Skipped: ยค is not a loot container, pickable or spawn point."; } UndoHelper.AddEditAction(view); Actions.Respawn(((Component)view).gameObject); return "ยค respawned."; } private static string MakeTame(ZNetView view) { Character component = ((Component)view).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return "Skipped: ยค is not a creature."; } UndoHelper.AddEditAction(view); Actions.SetTame(component, tame: true); return "ยค made tame."; } private static string MakeWild(ZNetView view) { Character component = ((Component)view).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return "Skipped: ยค is not a creature."; } UndoHelper.AddEditAction(view); Actions.SetTame(component, tame: false); return "ยค made wild."; } private static string MakeSleep(ZNetView view) { MonsterAI component = ((Component)view).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return "Skipped: ยค is not a creature."; } UndoHelper.AddEditAction(view); Actions.SetSleeping(component, sleep: true); return "ยค made to sleep."; } private static string SetCreator(ZNetView view, long creator) { Piece component = ((Component)view).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return "Skipped: ยค is not a piece."; } UndoHelper.AddEditAction(view); long num = Actions.SetCreator(component, creator); return $"Creator of ยค set from {num} to {creator}."; } private static string SetPrefab(ZNetView view, string prefab) { UndoHelper.AddEditAction(view); if (Actions.SetPrefab(view, prefab)) { return "Prefab of ยค set to " + prefab + "."; } return "Error: Prefab of ยค was not set to " + prefab + ". Probably invalid prefab name."; } private static string CopyId(ZNetView view) { GUIUtility.systemCopyBuffer = ((Object)ZNetScene.instance.GetPrefab(view.GetZDO().GetPrefab())).name; return "Copied id of ยค."; } private static string SetVisual(ZNetView view, Item? item) { if (item == null) { return "Skipped: Invalid item."; } ItemStand component = ((Component)view).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return "Skipped: ยค is not an item stand."; } UndoHelper.AddEditAction(view); Actions.SetVisual(component, item); return $"Visual of ยค set to {item.Name} with variant {item.Variant}."; } private static string SetHelmet(ZNetView view, Item? item) { if (item == null) { return "Skipped: Invalid item."; } Character component = ((Component)view).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return "Skipped: ยค is not a creature."; } UndoHelper.AddEditAction(view); Actions.SetVisual(component, (VisSlot)6, item); return $"Helmet of ยค set to {item.Name} with variant {item.Variant}."; } private static string SetLeftHand(ZNetView view, Item? item) { if (item == null) { return "Skipped: Invalid item."; } Character component = ((Component)view).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return "Skipped: ยค is not a creature."; } UndoHelper.AddEditAction(view); Actions.SetVisual(component, (VisSlot)0, item); return $"Left hand of ยค set to {item.Name} with variant {item.Variant}."; } private static string SetRightHand(ZNetView view, Item? item) { if (item == null) { return "Skipped: Invalid item."; } Character component = ((Component)view).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return "Skipped: ยค is not a creature."; } UndoHelper.AddEditAction(view); Actions.SetVisual(component, (VisSlot)1, item); return $"Right hand of ยค set to {item.Name} with variant {item.Variant}."; } private static string SetChest(ZNetView view, Item? item) { if (item == null) { return "Skipped: Invalid item."; } Character component = ((Component)view).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return "Skipped: ยค is not a creature."; } UndoHelper.AddEditAction(view); Actions.SetVisual(component, (VisSlot)4, item); return $"Chest of ยค set to {item.Name} with variant {item.Variant}."; } private static string SetShoulder(ZNetView view, Item? item) { if (item == null) { return "Skipped: Invalid item."; } Character component = ((Component)view).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return "Skipped: ยค is not a creature."; } UndoHelper.AddEditAction(view); Actions.SetVisual(component, (VisSlot)7, item); return $"Shoulder of ยค set to {item.Name} with variant {item.Variant}."; } private static string SetLegs(ZNetView view, Item? item) { if (item == null) { return "Skipped: Invalid item."; } Character component = ((Component)view).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return "Skipped: ยค is not a creature."; } UndoHelper.AddEditAction(view); Actions.SetVisual(component, (VisSlot)5, item); return $"Legs of ยค set to {item.Name} with variant {item.Variant}."; } private static string SetModel(ZNetView view, int index) { Character component = ((Component)view).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return "Skipped: ยค is not a creature."; } Actions.SetModel(component, index); return $"Model of ยค set to {index}."; } private static string SetUtility(ZNetView view, Item? item) { if (item == null) { return "Skipped: Invalid item."; } Character component = ((Component)view).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return "Skipped: ยค is not a creature."; } UndoHelper.AddEditAction(view); Actions.SetVisual(component, (VisSlot)8, item); return $"Utility item of ยค set to {item.Name} with variant {item.Variant}."; } private static string SetStatus(ZNetView obj, string name, float duration, float intensity) { Character val = default(Character); if (!((Component)obj).TryGetComponent(ref val)) { return "Skipped: ยค is not a creature."; } obj.ClaimOwnership(); int hashCode = name.GetHashCode(); SEMan sEMan = val.GetSEMan(); if (sEMan != null) { sEMan.AddStatusEffect(hashCode, true, 0, 0f); } SEMan sEMan2 = val.GetSEMan(); StatusEffect val2 = ((sEMan2 != null) ? sEMan2.GetStatusEffect(hashCode) : null); if ((Object)(object)val2 == (Object)null) { return "Failed to set status of ยค to " + name; } val2.m_ttl = duration; SE_Shield val3 = (SE_Shield)(object)((val2 is SE_Shield) ? val2 : null); if (val3 != null) { val3.m_absorbDamage = intensity; } SE_Burning val4 = (SE_Burning)(object)((val2 is SE_Burning) ? val2 : null); if (val4 != null) { if (name == "Burning") { val4.m_fireDamageLeft = 0f; val4.AddFireDamage(intensity); } else { val4.m_spiritDamageLeft = 0f; val4.AddSpiritDamage(intensity); } } SE_Poison val5 = (SE_Poison)(object)((val2 is SE_Poison) ? val2 : null); if (val5 != null) { val5.m_damageLeft = intensity; val5.m_damagePerHit = intensity / val2.m_ttl * val5.m_damageInterval; } return "Status of ยค set to " + name; } private static string GetInfo(ZNetView obj) { //IL_001d: 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_0066: Unknown result type (might be due to invalid IL or missing references) List list = new List(3) { "Id: ยค", "Pos: " + Helper.PrintVectorXZY(((Component)obj).transform.position), "Rot: " + Helper.PrintAngleYXZ(((Component)obj).transform.rotation) }; if (obj.m_syncInitialScale) { list.Add("Scale: " + Helper.PrintVectorXZY(((Component)obj).transform.localScale)); } Character component = ((Component)obj).GetComponent(); if (Object.op_Implicit((Object)(object)component)) { float health = component.GetHealth(); if (health < 0f || health > 1E+17f) { list.Add("Health: Infinite"); } else { list.Add("Health: " + health.ToString("F0") + " / " + component.GetMaxHealth()); } list.Add("Faction: " + ((object)Unsafe.As(ref component.m_faction)/*cast due to .constrained prefix*/).ToString()); list.Add("Stars: " + (component.GetLevel() - 1)); list.Add("Tamed: " + (component.IsTamed() ? "Yes" : "No")); Growup component2 = ((Component)obj).GetComponent(); if (Object.op_Implicit((Object)(object)component2)) { list.Add("Baby: " + ((component2.m_baseAI.GetTimeSinceSpawned().TotalSeconds < 0.0) ? "Yes" : "No")); } } else { float health2 = Actions.GetHealth(obj); if (health2 < 0f || health2 > 1E+17f) { list.Add("Health: Infinite"); } else { list.Add("Health: " + health2.ToString("F0")); } } VisEquipment component3 = ((Component)obj).GetComponent(); if (Object.op_Implicit((Object)(object)component3)) { if (component3.m_rightItem != "") { list.Add("Right hand: " + component3.m_rightItem); } if (component3.m_leftItem != "") { list.Add("Left hand: " + component3.m_leftItem); } if (component3.m_helmetItem != "") { list.Add("Helmet: " + component3.m_helmetItem); } if (component3.m_shoulderItem != "") { list.Add("Shoulders: " + component3.m_shoulderItem); } if (component3.m_chestItem != "") { list.Add("Chest: " + component3.m_chestItem); } if (component3.m_legItem != "") { list.Add("Legs: " + component3.m_legItem); } if (component3.m_utilityItem != "") { list.Add("Utility: " + component3.m_utilityItem); } } Piece component4 = ((Component)obj).GetComponent(); if (Object.op_Implicit((Object)(object)component4)) { list.Add("Creator ID: " + component4.GetCreator()); } return string.Join(", ", list); } private static string GetComponents(ZNetView obj) { return string.Join(", ", ComponentInfo.Get(obj)); } } public class ObjectParameters : SharedObjectParameters { public Range Rotation = new Range(Vector3.zero); public Range Offset = new Range(Vector3.zero); public Vector3 From; public Vector3? Center; public Range? Fuel; public string[] ConnectionIds = Array.Empty(); public string[] IncludedIds = Array.Empty(); public string[] ExcludedIds = Array.Empty(); public string Prefab = ""; public string Origin = "player"; public bool? Remove; public HashSet Operations = new HashSet(); public bool ResetRotation; public bool Respawn; public Item? Visual; public float Angle; public long Creator; public Range? Width; public Range? Depth; public float Height; public float Chance = 1f; public string Match = ""; public string Unmatch = ""; public bool Connect; public HashSet Components = new HashSet(); public string? StatusName; public Range? StatusDuration; public Range? StatusIntensity; public static HashSet SupportedOperations = new HashSet { "status", "health", "damage", "ammo", "ammotype", "durability", "stars", "tame", "wild", "level", "baby", "info", "data", "sleep", "remove", "visual", "model", "helmet", "left_hand", "right_hand", "shoulders", "legs", "utility", "move", "rotate", "scale", "chest", "fuel", "prefab", "respawn", "mirror", "creator", "copy", "field", "f", "components", "copy", "distant", "persist" }; public ObjectParameters(ConsoleEventArgs args) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { From = ((Component)Player.m_localPlayer).transform.position; } ParseArgs(args.Args); } protected override void ParseArgs(string[] args) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) base.ParseArgs(args); for (int i = 0; i < args.Length; i++) { string[] array = args[i].Split(new char[1] { '=' }); string text = array[0].ToLower(); if (SupportedOperations.Contains(text)) { if (text != "field" && text != "f" && Operations.Contains(text)) { throw new InvalidOperationException("Operation " + text + " used multiple times."); } Operations.Add(text); } if (text == "center" || text == "mirror") { Center = From; } if (text == "connect") { Connect = true; } if (array.Length < 2) { continue; } string text2 = array[1]; string[] array2 = Parse.Split(text2, ','); if (text == "rotate") { if (text2 == "reset") { ResetRotation = true; } else { Rotation = Parse.VectorYXZRange(text2, Vector3.zero); } } if (text == "connect") { ConnectionIds = array2; } if (text == "center" || text == "from") { Center = Parse.VectorXZY(array2); } if (text == "move") { Offset = Parse.VectorZXYRange(text2, Vector3.zero); } if (text == "id") { IncludedIds = array2; } if (text == "ignore") { ExcludedIds = array2; } if (text == "prefab") { Prefab = text2; } if (text == "origin") { Origin = text2.ToLower(); } if (text == "visual") { Visual = new Item(text2); } if (text == "fuel") { Fuel = Parse.FloatRange(text2, 0f); } if (text == "chance") { Chance = Parse.Float(text2, 1f); } if (text == "type") { AddComponents(array2); } if (text == "match") { Match = text2; } if (text == "unmatch") { Unmatch = text2; } if (text == "rect") { Range val = Parse.ScaleRange(text2); Width = new Range(val.Min.x, val.Max.x); Depth = new Range(val.Min.z, val.Max.z); } if (text == "height") { Height = Parse.Float(text2, 0f); } if (text == "creator") { Creator = Parse.Long(text2, 0L); } if (text == "angle") { Angle = Parse.Float(text2, 0f) * (float)Math.PI / 180f; } if (text == "status") { StatusName = array2[0]; StatusDuration = Parse.FloatRange(array2, 1, 60f); StatusIntensity = Parse.FloatRange(array2, 2, 100f); } } if (Operations.Contains("remove") && Operations.Count > 1) { throw new InvalidOperationException("Remove can't be used with other operations."); } if (Operations.Count == 0) { throw new InvalidOperationException("Missing the operation."); } if (Radius != null && Depth != null) { throw new InvalidOperationException("circle and rect parameters can't be used together."); } if (Radius != null && Connect) { throw new InvalidOperationException("circle and connect parameters can't be used together."); } if (Depth != null && Connect) { throw new InvalidOperationException("connect and rect parameters can't be used together."); } } private void AddComponents(string[] values) { foreach (string text in values) { string text2 = text.ToLowerInvariant(); if (text2 == "structure") { Components.Add("WearNTear"); } else if (text2 == "creature") { Components.Add("Humanoid"); } else { Components.Add(text); } } } } public class SharedObjectAutoComplete { public static List VisualAutoComplete(string name, int index) { return index switch { 0 => ParameterInfo.ItemIds, 1 => ParameterInfo.Create("$" + name + "=id,integer | Item variant for items that have multiple variants."), _ => ParameterInfo.None, }; } public static List WithSharedParameters(List parameters) { List collection = new List(24) { "baby", "durability", "tame", "left_hand", "right_hand", "helmet", "chest", "shoulders", "legs", "utility", "radius", "health", "stars", "level", "scale", "model", "damage", "ammo", "ammoType", "field", "f", "par", "persist", "distant" }; parameters.AddRange(collection); List list = new List(); list.AddRange(from s in parameters.Distinct() orderby s select s); return list; } public static Dictionary>> WithSharedFetchers(Dictionary>> fetchers) { Dictionary>> dictionary = new Dictionary>> { { "tame", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("tame=true/false or no value for default.", "Sets is the creature tamed.") }, { "baby", (int index) => ParameterInfo.Flag("Baby") }, { "persist", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("persist=true/false.", "Sets if the object is saved to the world file.") }, { "distant", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("distant=true/false or no value for default.", "Sets if the object is loaded from further distance than normally.") }, { "left_hand", (int index) => VisualAutoComplete("left_hand", index) }, { "right_hand", (int index) => VisualAutoComplete("right_hand", index) }, { "helmet", (int index) => VisualAutoComplete("helmet", index) }, { "chest", (int index) => VisualAutoComplete("chest", index) }, { "shoulders", (int index) => VisualAutoComplete("shoulders", index) }, { "legs", (int index) => VisualAutoComplete("legs", index) }, { "utility", (int index) => VisualAutoComplete("utility", index) }, { "durability", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("durability", "number", "Sets current durability/health (+ maximum health for creatures).") }, { "health", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.CreateWithMinMax("health", "number", "Sets current durability/health (+ maximum health for creatures).") }, { "damage", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.CreateWithMinMax("damage", "number", "Sets the damage multiplier.") }, { "ammo", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.CreateWithMinMax("ammo", "number", "Sets the amount of ammo.") }, { "ammoType", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.ItemIds }, { "stars", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("stars", "integer", "Sets creature stars.") }, { "level", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("level", "integer", "Sets creature and item level.") }, { "model", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("model", "integer", "Sets the creature model (0 for male, 1 for female).") }, { "scale", (int index) => ParameterInfo.Scale("scale", "Scaling for objects that support it", index) }, { "field", (int index) => index switch { 1 => FieldAutoComplete.GetFields(), 0 => FieldAutoComplete.GetComponents(), _ => FieldAutoComplete.GetTypes(index - 2), } }, { "f", (int index) => index switch { 1 => FieldAutoComplete.GetFields(), 0 => FieldAutoComplete.GetComponents(), _ => FieldAutoComplete.GetTypes(index - 2), } }, { "par", (int index) => (index != 0) ? ParameterInfo.Create("par=key,value", "Value of the parameter.") : DataAutoComplete.GetDataParameters() } }; foreach (KeyValuePair>> fetcher in fetchers) { dictionary[fetcher.Key] = fetcher.Value; } return dictionary; } } public class Item { public string Name; public int Variant; public Item(string value) { string[] array = Parse.Split(value, ','); Name = Parse.String(array, 0, ""); Variant = Parse.Int(array, 1, 0); } } public class SharedObjectParameters { public Range? Scale; public Range? Level; public Range? Health; public bool isHealthPercentage; public Range? Damage; public Range? Ammo; public string? AmmoType; public bool? Baby; public bool? Persist; public bool? Distant; public Item? Helmet; public Item? LeftHand; public Item? RightHand; public Item? Chest; public Item? Shoulders; public Item? Legs; public Item? Utility; public Range? Radius; public Range? Model; public Dictionary Fields = new Dictionary(); public Dictionary DataParameters = new Dictionary(); protected virtual void ParseArgs(string[] args) { //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_058e: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < args.Length; i++) { string[] array = args[i].Split(new char[1] { '=' }, 2); string text = array[0].ToLower(); if (text == "baby") { Baby = true; } if (text == "persist") { Persist = true; } if (text == "distant") { Distant = true; } if (array.Length < 2) { continue; } string text2 = array[1].Trim(); if (text == "par") { KeyValuePair keyValuePair = Parse.Kvp(text2, ','); if (keyValuePair.Key == "") { throw new InvalidOperationException("Invalid data parameter " + text2 + "."); } DataParameters["<" + keyValuePair.Key + ">"] = keyValuePair.Value; } if (text == "health" || text == "durability") { if (text2.EndsWith("%")) { isHealthPercentage = true; text2 = text2.Substring(0, text2.Length - 1); } Health = Parse.FloatRange(text2, 0f); if (isHealthPercentage) { Range? health = Health; health.Max /= 100f; Range? health2 = Health; health2.Min /= 100f; } } if (text == "damage") { Damage = Parse.FloatRange(text2, 0f); } if (text == "ammo") { Ammo = Parse.IntRange(text2, 0); } if (text == "ammotype") { AmmoType = text2; } if (text == "stars" || text == "star") { Level = Parse.IntRange(text2, 0); Range? level = Level; level.Max++; Range? level2 = Level; level2.Min++; } if (text == "model") { Model = Parse.IntRange(text2, 0); } if (text == "level" || text == "levels") { Level = Parse.IntRange(text2, 0); } switch (text) { case "radius": case "range": case "circle": Radius = Parse.FloatRange(text2, 0f); break; } if (text == "sc" || text == "scale") { Scale = Parse.ScaleRange(text2); } if (text == "helmet") { Helmet = new Item(text2); } if (text == "left_hand") { LeftHand = new Item(text2); } if (text == "right_hand") { RightHand = new Item(text2); } if (text == "chest") { Chest = new Item(text2); } if (text == "shoulders") { Shoulders = new Item(text2); } if (text == "legs") { Legs = new Item(text2); } if (text == "utility") { Utility = new Item(text2); } if (text == "persist") { Persist = Parse.Boolean(text2); } if (text == "distant") { Distant = Parse.Boolean(text2); } if (!(text == "field") && !(text == "f")) { continue; } string[] array2 = text2.Split(new char[1] { ',' }); if (array2.Length < 3) { continue; } string text3 = FieldAutoComplete.RealComponent(FieldAutoComplete.PrefabFromCommand(string.Join(" ", args)), array2[0]); bool zdoField; string text4 = FieldAutoComplete.RealField(text3, array2[1], out zdoField); string text5 = string.Join(",", array2.Skip(2)); Type type = FieldAutoComplete.GetType(text3, text4, zdoField); string text6 = (zdoField ? text4 : (text3 + "." + text4)); if (type == typeof(int)) { Fields.Add(text6, Parse.Int(text5, 0)); continue; } if (type == typeof(long)) { Fields.Add(text6, long.Parse(text5)); continue; } if (type == typeof(float)) { Fields.Add(text6, Parse.Float(text5, 0f)); continue; } if (type == typeof(string)) { Fields.Add(text6, text5); continue; } if (type == typeof(bool)) { Fields.Add(text6, (Parse.BoolNull(text5) == true) ? 1 : 0); continue; } if (type == typeof(Vector3)) { Fields.Add(text6, Parse.VectorXZY(array2, 2)); continue; } if (type == typeof(Quaternion)) { Fields.Add(text6, Parse.AngleYXZ(array2, 2)); continue; } if (type == typeof(GameObject) || type == typeof(ItemDrop) || type == typeof(EffectList)) { Fields.Add(text6, text5); continue; } if (type == typeof(ObjectHash) || type == typeof(LocationHash) || type == typeof(RoomHash)) { Fields.Add(text6, StringExtensionMethods.GetStableHashCode(text5)); continue; } if (type.IsEnum) { Fields.Add(text6, ToEnum(type, text5)); continue; } if (type == typeof(void)) { throw new InvalidOperationException("Field " + text6 + " of component " + text3 + " is not supported."); } throw new InvalidOperationException($"Unhandled type {type} for field {text6}"); } } public static int ToEnum(Type type, string str) { return ToEnum(type, ToList(str)); } public static int ToEnum(Type type, List list) { try { int num = 0; foreach (string item in list) { num += (int)Enum.Parse(type, item, ignoreCase: true); } return num; } catch { throw new InvalidOperationException("Failed to parse enum " + type.Name + " with values " + string.Join(", ", list)); } } public static List ToList(string str, bool removeEmpty = true) { string[] array = Split(str, removeEmpty); List list = new List(array.Length); list.AddRange(array); return list; } public static string[] Split(string arg, bool removeEmpty = true, char split = ',') { return (from s in arg.Split(new char[1] { split }) select s.Trim() into s where !removeEmpty || s != "" select s).ToArray(); } } public class SpawnLocationAutoComplete { public List NamedParameters = new List(6) { "seed", "dungeonSeed", "pos", "rot", "from", "refRot" }; public SpawnLocationAutoComplete() { NamedParameters.Sort(); AutoComplete.Register("spawn_location", (Func>)((int index) => (index == 0) ? ParameterInfo.LocationIds : NamedParameters), new Dictionary>> { { "seed", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("seed", "integer", "Sets the location appearance (if randomized).") }, { "dungeonSeed", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("dungeonSeed", "integer", "Sets the room layout for the next dungeon.") }, { "pos", (int index) => ParameterInfo.XZY("pos", "Offset from the player / reference position", index) }, { "from", (int index) => ParameterInfo.XZY("from", "Overrides the reference position (player's position)", index) }, { "rot", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("rot", "degrees", "Sets the location rotation. Randomized by default.") }, { "refRot", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("refRot", "degrees", "Overrides the reference rotation (player's rotation).") } }); } } public class SpawnLocationCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__1_0; internal void <.ctor>b__1_0(ConsoleEventArgs args) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00ce: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0269: 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_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_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_0294: 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_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_0311: 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_0337: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: 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_01be: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) Helper.ArgsCheck(args, 2, "Missing location id."); ZoneSystem instance = ZoneSystem.instance; string text = args[1]; ZoneLocation val = instance.GetLocation(StringExtensionMethods.GetStableHashCode(text)) ?? throw new InvalidOperationException("Can't find location " + text + "."); if (!val.m_prefab.IsValid) { throw new InvalidOperationException("Can't find prefab for location " + text + "."); } int num = Random.Range(0, 99999); int forceSeed = int.MinValue; float num2 = (float)Random.Range(0, 16) * 22.5f; float num3 = 0f; Vector3 val2 = Vector3.zero; Vector3 val3 = Vector3.zero; Transform transform = ((Component)Player.m_localPlayer).transform; if (Object.op_Implicit((Object)(object)transform)) { val3 = transform.position; val2 = 2f * ((Component)transform).transform.forward; Quaternion rotation = ((Component)transform).transform.rotation; num3 = ((Quaternion)(ref rotation)).eulerAngles.y; } bool flag = true; string[] args2 = args.Args; for (int i = 0; i < args2.Length; i++) { string[] array = args2[i].Split(new char[1] { '=' }); string text2 = array[0].ToLower(); if (array.Length >= 2) { if (text2 == "seed") { num = Parse.Int(array[1], 0); } if (text2 == "dungeonseed") { forceSeed = Parse.Int(array[1], 0); } if (text2 == "rot" || text2 == "rotation") { num2 = Parse.Float(array[1], 0f); } if (text2 == "pos" || text2 == "position") { val2 = Parse.VectorXZY(array[1].Split(new char[1] { ',' })); flag = array[1].Split(new char[1] { ',' }).Length < 3; } if (text2 == "refrot" || text2 == "refrotation") { num3 = Parse.Float(array[1], num3); } if (text2 == "from" || text2 == "refpos") { val3 = Parse.VectorXZY(array[1].Split(new char[1] { ',' }), val3); } } } Quaternion val4 = Quaternion.Euler(0f, num3, 0f); Vector3 val5 = val3; val5 += val4 * Vector3.forward * val2.x; val5 += val4 * Vector3.right * val2.z; val5 += val4 * Vector3.up * val2.y; Quaternion val6 = val4 * Quaternion.Euler(0f, num2, 0f); float y = default(float); if (flag && ZoneSystem.instance.FindFloor(val5, ref y)) { val5.y = y; } DungeonGenerator.m_forceSeed = forceSeed; UndoHelper.BeginAction(); ZoneSystem.instance.SpawnLocation(val, num, val5, val6, (SpawnMode)0, new List()); UndoHelper.EndAction(); args.Context.AddString("Spawned: " + text + " at " + Helper.PrintVectorXZY(val5)); } } public const string Name = "spawn_location"; public SpawnLocationCommand() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown new SpawnLocationAutoComplete(); object obj = <>c.<>9__1_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00ce: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0269: 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_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_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_0294: 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_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_0311: 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_0337: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: 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_01be: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) Helper.ArgsCheck(args, 2, "Missing location id."); ZoneSystem instance = ZoneSystem.instance; string text = args[1]; ZoneLocation val2 = instance.GetLocation(StringExtensionMethods.GetStableHashCode(text)) ?? throw new InvalidOperationException("Can't find location " + text + "."); if (!val2.m_prefab.IsValid) { throw new InvalidOperationException("Can't find prefab for location " + text + "."); } int num = Random.Range(0, 99999); int forceSeed = int.MinValue; float num2 = (float)Random.Range(0, 16) * 22.5f; float num3 = 0f; Vector3 val3 = Vector3.zero; Vector3 val4 = Vector3.zero; Transform transform = ((Component)Player.m_localPlayer).transform; if (Object.op_Implicit((Object)(object)transform)) { val4 = transform.position; val3 = 2f * ((Component)transform).transform.forward; Quaternion rotation = ((Component)transform).transform.rotation; num3 = ((Quaternion)(ref rotation)).eulerAngles.y; } bool flag = true; string[] args2 = args.Args; for (int i = 0; i < args2.Length; i++) { string[] array = args2[i].Split(new char[1] { '=' }); string text2 = array[0].ToLower(); if (array.Length >= 2) { if (text2 == "seed") { num = Parse.Int(array[1], 0); } if (text2 == "dungeonseed") { forceSeed = Parse.Int(array[1], 0); } if (text2 == "rot" || text2 == "rotation") { num2 = Parse.Float(array[1], 0f); } if (text2 == "pos" || text2 == "position") { val3 = Parse.VectorXZY(array[1].Split(new char[1] { ',' })); flag = array[1].Split(new char[1] { ',' }).Length < 3; } if (text2 == "refrot" || text2 == "refrotation") { num3 = Parse.Float(array[1], num3); } if (text2 == "from" || text2 == "refpos") { val4 = Parse.VectorXZY(array[1].Split(new char[1] { ',' }), val4); } } } Quaternion val5 = Quaternion.Euler(0f, num3, 0f); Vector3 val6 = val4; val6 += val5 * Vector3.forward * val3.x; val6 += val5 * Vector3.right * val3.z; val6 += val5 * Vector3.up * val3.y; Quaternion val7 = val5 * Quaternion.Euler(0f, num2, 0f); float y = default(float); if (flag && ZoneSystem.instance.FindFloor(val6, ref y)) { val6.y = y; } DungeonGenerator.m_forceSeed = forceSeed; UndoHelper.BeginAction(); ZoneSystem.instance.SpawnLocation(val2, num, val6, val7, (SpawnMode)0, new List()); UndoHelper.EndAction(); args.Context.AddString("Spawned: " + text + " at " + Helper.PrintVectorXZY(val6)); }; <>c.<>9__1_0 = val; obj = (object)val; } Helper.Command("spawn_location", "Spawns locations", (ConsoleEvent)obj); } } public class SpawnObjectAutoComplete : SharedObjectAutoComplete { public List NamedParameters; public SpawnObjectAutoComplete() { NamedParameters = SharedObjectAutoComplete.WithSharedParameters(new List(14) { "hunt", "durability", "name", "crafter", "variant", "amount", "pos", "rot", "refPlayer", "from", "refRot", "to", "data", "crafterId" }); AutoComplete.Register("spawn_object", (Func>)((int index) => (index != 0) ? NamedParameters : ParameterInfo.ObjectIds), SharedObjectAutoComplete.WithSharedFetchers(new Dictionary>> { { "data", (int index) => DataLoading.DataKeys }, { "crafterId", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("crafterId=number", "Sets the crafter player ID.") }, { "hunt", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("hunt=true/false or no value for true.", "Sets is the creature in aggressive mode.") }, { "name", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("name", "string", "Name for tameable creatures.") }, { "crafter", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("name", "string", "Crafter for items.") }, { "variant", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.CreateWithMinMax("variant", "integer", "Variant for items.") }, { "amount", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.CreateWithMinMax("amount", "integer", "Amount of spawned objects.") }, { "pos", (int index) => ParameterInfo.FRU("pos", "Offset from the player position", index) }, { "to", (int index) => ParameterInfo.XZY("to", "End position for multiple objects", index) }, { "from", (int index) => ParameterInfo.XZY("from", "Overrides the player position", index) }, { "refPlayer", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.PlayerNames }, { "rot", (int index) => ParameterInfo.YawRollPitch("rot", "Rotation from the player rotation", index) }, { "refRot", (int index) => ParameterInfo.YawRollPitch("refRot", "Overrides the player rotation", index) }, { "circle", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("circle=number", "Maximum spawn distance when spawning multiple objects. Default is 0.5 meters.") }, { "radius", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("radius=number", "Maximum spawn distance when spawning multiple objects. Default is 0.5 meters.") } })); } } public class SpawnObjectCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__3_0; internal void <.ctor>b__3_0(ConsoleEventArgs args) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) Helper.ArgsCheck(args, 2, "Missing object id."); string text = args[1]; GameObject prefab = Helper.GetPrefab(text); if ((Object)(object)prefab == (Object)null) { throw new InvalidOperationException("Unable to find the object."); } SpawnObjectParameters spawnObjectParameters = new SpawnObjectParameters(args); ItemDrop component = prefab.GetComponent(); int num = Helper.RandomValue(spawnObjectParameters.Amount); int num2 = num; if (Object.op_Implicit((Object)(object)component)) { num2 = (int)Math.Ceiling((double)num2 / (double)component.m_itemData.m_shared.m_maxStackSize); } UndoHelper.BeginAction(); List list = SpawnObject(spawnObjectParameters, prefab, num2); Manipulate(list, spawnObjectParameters, num); UndoHelper.EndAction(); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, "Spawning object " + text, list.Count, (Sprite)null); } args.Context.AddString("Spawned: " + text + " at " + Helper.PrintVectorXZY(spawnObjectParameters.GetPosition())); } } public const string Name = "spawn_object"; private static List SpawnObject(SpawnObjectParameters pars, GameObject prefab, int count) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) List list = new List(); float num = (float)(count - 1) * 0.5f; float num3 = default(float); for (int i = 0; i < count; i++) { Vector3 position; if (pars.To.HasValue) { position = pars.GetPosition(i, count); } else { position = pars.GetPosition(); Vector2 val = Random.insideUnitCircle * (pars.Radius?.Max ?? num); if (pars.Radius != null && pars.Radius.Min != pars.Radius.Max) { float num2 = Random.Range(0f, (float)Math.PI * 2f); Vector2 val2 = new Vector2(Mathf.Sin(num2), Mathf.Cos(num2)); val = ((Vector2)(ref val2)).normalized * Helper.RandomValue(pars.Radius); } position.x += val.x; position.z += val.y; } if (pars.Snap) { ZoneSystem.instance.FindFloor(position, ref num3); if (num3 == 0f) { Vector3 val3 = position; val3.y += 100f; ZoneSystem.instance.FindFloor(position, ref num3); } position.y = num3; } Quaternion val4 = pars.BaseRotation * Quaternion.Euler(Helper.RandomValue(pars.Rotation)); Vector3? scale = ((pars.Scale == null) ? ((Vector3?)null) : new Vector3?(Helper.RandomValue(pars.Scale))); DataHelper.Init(prefab, position, val4, scale, pars.Data, pars.DataParameters); try { GameObject val5 = Object.Instantiate(prefab, position, val4); list.Add(val5); if (!ZNet.instance.IsServer()) { ZDOMan.instance.ClientChanged(val5.GetComponent().GetZDO().m_uid); } } catch (Exception ex) { Debug.LogError((object)ex); } DataHelper.CleanUp(); } return list; } private static void Manipulate(IEnumerable spawned, SpawnObjectParameters pars, int total) { foreach (GameObject item in spawned) { ZNetView component = item.GetComponent(); if (pars.Baby == true) { Actions.SetBaby(item); } if (pars.Level != null) { Actions.SetLevel(item, Helper.RandomValue(pars.Level)); } if (pars.Damage != null) { Actions.SetFloat(component, Helper.RandomValue(pars.Damage), Hash.Damage); } if (pars.Ammo != null) { Actions.SetInt(component, Helper.RandomValue(pars.Ammo), Hash.Ammo); } if (pars.AmmoType != null) { Actions.SetString(component, pars.AmmoType, Hash.AmmoType); } if (pars.Health != null) { Actions.SetHealth(item, Helper.RandomValue(pars.Health), pars.isHealthPercentage); } if (pars.Variant != null) { Actions.SetVariant(item, Helper.RandomValue(pars.Variant)); } if (pars.Name != null) { Actions.SetName(item, pars.Name); } if (pars.CrafterId.HasValue) { Actions.SetCrafterId(item.GetComponent(), pars.CrafterId.Value); } if (pars.Hunt.HasValue) { Actions.SetHunt(item, pars.Hunt.Value); } if (pars.Tamed.HasValue) { Actions.SetTame(item, pars.Tamed.Value); } total -= Actions.SetStack(item, total); Actions.SetVisual(item, (VisSlot)6, pars.Helmet); Actions.SetVisual(item, (VisSlot)4, pars.Chest); Actions.SetVisual(item, (VisSlot)7, pars.Shoulders); Actions.SetVisual(item, (VisSlot)5, pars.Legs); Actions.SetVisual(item, (VisSlot)8, pars.Utility); Actions.SetVisual(item, (VisSlot)0, pars.LeftHand); Actions.SetVisual(item, (VisSlot)1, pars.RightHand); if (pars.Model != null) { Actions.SetModel(item, Helper.RandomValue(pars.Model)); } if (pars.Helmet != null || pars.Chest != null || pars.Shoulders != null || pars.Legs != null || pars.Utility != null || pars.LeftHand != null || pars.RightHand != null) { ZNetView component2 = item.GetComponent(); ZDO obj = ((component2 != null) ? component2.GetZDO() : null); if (obj != null) { obj.SetOwner(0L); } } if (pars.Distant.HasValue) { Actions.SetDistant(item, pars.Distant.Value); } if (pars.Persist.HasValue) { Actions.SetPersistent(item, pars.Persist.Value); } if (pars.Fields.Count > 0) { Actions.SetFields(item, pars.Fields); } } } public SpawnObjectCommand() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown new SpawnObjectAutoComplete(); object obj = <>c.<>9__3_0; if (obj == null) { ConsoleEvent val = delegate(ConsoleEventArgs args) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) Helper.ArgsCheck(args, 2, "Missing object id."); string text = args[1]; GameObject prefab = Helper.GetPrefab(text); if ((Object)(object)prefab == (Object)null) { throw new InvalidOperationException("Unable to find the object."); } SpawnObjectParameters spawnObjectParameters = new SpawnObjectParameters(args); ItemDrop component = prefab.GetComponent(); int num = Helper.RandomValue(spawnObjectParameters.Amount); int num2 = num; if (Object.op_Implicit((Object)(object)component)) { num2 = (int)Math.Ceiling((double)num2 / (double)component.m_itemData.m_shared.m_maxStackSize); } UndoHelper.BeginAction(); List list = SpawnObject(spawnObjectParameters, prefab, num2); Manipulate(list, spawnObjectParameters, num); UndoHelper.EndAction(); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, "Spawning object " + text, list.Count, (Sprite)null); } args.Context.AddString("Spawned: " + text + " at " + Helper.PrintVectorXZY(spawnObjectParameters.GetPosition())); }; <>c.<>9__3_0 = val; obj = (object)val; } Helper.Command("spawn_object", "Spawns objects", (ConsoleEvent)obj); } } internal class SpawnObjectParameters : SharedObjectParameters { public Quaternion BaseRotation; public Range Rotation = new Range(Vector3.zero); public Range RelativePosition = new Range(Vector3.zero); public Vector3 From = Vector3.zero; public Vector3? To; public Range Amount = new Range(1); public string? Name; public long? CrafterId; public Range? Variant; public bool Snap = true; public bool? Tamed; public bool? Hunt; private bool UseDefaultRelativePosition; public DataEntry? Data; public SpawnObjectParameters(ConsoleEventArgs args) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { From = ((Component)Player.m_localPlayer).transform.position; BaseRotation = ((Component)Player.m_localPlayer).transform.rotation; UseDefaultRelativePosition = true; } ParseArgs(args.Args); } protected override void ParseArgs(string[] args) { //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: 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_01de: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0306: Unknown result type (might be due to invalid IL or missing references) base.ParseArgs(args); for (int i = 0; i < args.Length; i++) { string[] array = args[i].Split(new char[1] { '=' }, 2); string text = array[0].ToLower(); if (text == "tame" || text == "tamed") { Tamed = true; } if (text == "hunt") { Hunt = true; } if (array.Length < 2) { continue; } string text2 = array[1]; if (text == "name" || text == "crafter") { Name = text2.Replace("_", " "); } if (text == "crafterid") { CrafterId = Parse.Long(text2, 0L); } if (text == "variant") { Variant = Parse.IntRange(text2, 0); } if (text == "amount") { Amount = Parse.IntRange(text2, 0); } if (text == "hunt") { Hunt = Parse.Boolean(text2); } if (text == "tame" || text == "tamed") { Tamed = Parse.Boolean(text2); } if (text == "refrot" || text == "refrotation") { BaseRotation = Parse.AngleYXZ(text2, BaseRotation); } if (text == "pos" || text == "position") { UseDefaultRelativePosition = false; RelativePosition = Parse.VectorXZYRange(text2, Vector3.zero); Snap = text2.Split(new char[1] { ',' }).Length < 3; } if (text == "rot" || text == "rotation") { Rotation = Parse.VectorYXZRange(text2, Vector3.zero); } if (text == "from" || text == "refpos") { UseDefaultRelativePosition = false; From = Parse.VectorXZY(text2.Split(new char[1] { ',' }), From); } if (text == "to") { UseDefaultRelativePosition = false; To = Parse.VectorXZY(text2.Split(new char[1] { ',' }), From); } if (text == "data") { Data = DataHelper.Merge(Parse.Split(text2, ',').Select(DataHelper.Get).ToArray()); } if (text == "refplayer") { UseDefaultRelativePosition = false; PlayerInfo val = Helper.FindPlayer(text2, false); if (((ZDOID)(ref val.m_characterID)).IsNone()) { throw new InvalidOperationException("Unable to find the player."); } if (!val.m_publicPosition) { throw new InvalidOperationException("Player doesn't have a public position."); } From = val.m_position; } } if (UseDefaultRelativePosition) { From += BaseRotation * Vector3.forward * 2f; } if (To.HasValue && Radius != null) { throw new InvalidOperationException("radius can't be used with to."); } } public Vector3 GetPosition() { //IL_0001: 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_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) return From + BaseRotation * Helper.RandomValue(RelativePosition); } public Vector3 GetPosition(int index, int max) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (To.HasValue) { return From + (To.Value - From) * (float)index / (float)(max - 1); } return From; } } public class Terrain { private static float CalculateSmooth(float smooth, float distance) { if (!(1f - distance >= smooth)) { return (1f - distance) / smooth; } return 1f; } private static float CalculateSlope(float angle, float distanceWidth, float distanceDepth) { return Mathf.Sin(angle) * distanceWidth + Mathf.Cos(angle) * distanceDepth; } public static void SetTerrain(List nodes, Vector3 pos, float radius, float smooth, float delta) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) DoOperation(nodes, pos, radius, action); void action(TerrainComp compiler, int index, TerrainNode node) { float num = CalculateSmooth(smooth, node.Distance); compiler.m_levelDelta[index] = delta * num; compiler.m_smoothDelta[index] = 0f; compiler.m_modifiedHeight[index] = compiler.m_levelDelta[index] != 0f; } } public static void RaiseTerrain(List nodes, Vector3 pos, float radius, float smooth, float amount) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) DoOperation(nodes, pos, radius, action); void action(TerrainComp compiler, int index, TerrainNode node) { float num = CalculateSmooth(smooth, node.Distance); compiler.m_levelDelta[index] += num * amount + compiler.m_smoothDelta[index]; compiler.m_smoothDelta[index] = 0f; compiler.m_modifiedHeight[index] = compiler.m_levelDelta[index] != 0f; } } public static void VoidTerrain(List nodes, Vector3 pos, float radius) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) DoOperation(nodes, pos, radius, action); static void action(TerrainComp compiler, int index, TerrainNode node) { compiler.m_levelDelta[index] = float.NaN; compiler.m_smoothDelta[index] = 0f; compiler.m_modifiedHeight[index] = true; } } public static void LevelTerrain(List nodes, Vector3 pos, float radius, float smooth, float altitude) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) DoOperation(nodes, pos, radius, action); void action(TerrainComp compiler, int index, TerrainNode node) { float num = CalculateSmooth(smooth, node.Distance); compiler.m_levelDelta[index] += num * (altitude - compiler.m_hmap.m_heights[index]); compiler.m_smoothDelta[index] = 0f; compiler.m_modifiedHeight[index] = compiler.m_levelDelta[index] != 0f; } } public static void MaxTerrain(List nodes, Vector3 pos, float radius, float altitude) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) DoOperation(nodes, pos, radius, action); void action(TerrainComp compiler, int index, TerrainNode node) { float num = Mathf.Min(altitude, compiler.m_hmap.m_heights[index]); compiler.m_levelDelta[index] += num - compiler.m_hmap.m_heights[index]; compiler.m_smoothDelta[index] = 0f; compiler.m_modifiedHeight[index] = compiler.m_levelDelta[index] != 0f; } } public static void MinTerrain(List nodes, Vector3 pos, float radius, float altitude) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) DoOperation(nodes, pos, radius, action); void action(TerrainComp compiler, int index, TerrainNode node) { float num = Mathf.Max(altitude, compiler.m_hmap.m_heights[index]); compiler.m_levelDelta[index] += num - compiler.m_hmap.m_heights[index]; compiler.m_smoothDelta[index] = 0f; compiler.m_modifiedHeight[index] = compiler.m_levelDelta[index] != 0f; } } public static void SlopeTerrain(List nodes, Vector3 pos, float radius, float angle, float smooth, float altitude, float amount) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) DoOperation(nodes, pos, radius, action); void action(TerrainComp compiler, int index, TerrainNode node) { float num = CalculateSlope(angle, node.DistanceWidth, node.DistanceDepth) * CalculateSmooth(smooth, node.Distance); compiler.m_levelDelta[index] += altitude - compiler.m_hmap.m_heights[index] + num * amount / 2f; compiler.m_smoothDelta[index] = 0f; compiler.m_modifiedHeight[index] = compiler.m_levelDelta[index] != 0f; } } public static void PaintTerrain(List nodes, Vector3 pos, float radius, float smooth, Color color) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: 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_001e: Unknown result type (might be due to invalid IL or missing references) DoOperation(nodes, pos, radius, action); void action(TerrainComp compiler, int index, TerrainNode node) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) float num = CalculateSmooth(smooth, node.Distance); Color val = compiler.m_paintMask[index]; _ = compiler.m_hmap; bool flag = WorldGenerator.IsAshlands(pos.x, pos.z); if (flag && !compiler.m_modifiedPaint[index]) { val.a = 0f; } Color val2 = color; if (float.IsNaN(color.r)) { val2.r = val.r; } if (float.IsNaN(color.g)) { val2.g = val.g; } if (float.IsNaN(color.b)) { val2.b = val.b; } if (float.IsNaN(color.a)) { val2.a = val.a; } else if (color.a >= 0f) { if (flag) { val2.a = 1f - color.a; } else { val2.a = color.a; } } else { val2.a = 0f - color.a; } compiler.m_paintMask[index] = Color.Lerp(val, val2, num); compiler.m_modifiedPaint[index] = true; } } public static void ClearPaint(List nodes, Vector3 pos, float radius) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) DoOperation(nodes, pos, radius, action); static void action(TerrainComp compiler, int index, TerrainNode node) { compiler.m_modifiedPaint[index] = false; } } public static void ResetTerrain(List heightNodes, List paintNodes, Vector3 pos, float radius) { //IL_0006: 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_008c: Unknown result type (might be due to invalid IL or missing references) List list = new List(); TerrainModifier.GetModifiers(pos, radius + 1f, list, (TerrainModifier)null); foreach (TerrainModifier item in list) { if (!((Object)(object)item.m_nview == (Object)null)) { item.m_nview.ClaimOwnership(); ZNetScene.instance.Destroy(((Component)item).gameObject); } } DoOperation(heightNodes, pos, radius, action); ClearPaint(paintNodes, pos, radius); static void action(TerrainComp compiler, int index, TerrainNode node) { compiler.m_levelDelta[index] = 0f; compiler.m_smoothDelta[index] = 0f; compiler.m_modifiedHeight[index] = false; } } private static void DoOperation(List nodes, Vector3 pos, float radius, Action action) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) foreach (PaintNode node in nodes) { action(node.Compiler, node.Index, node); } ClutterSystem instance = ClutterSystem.instance; if (instance != null) { instance.ResetGrass(pos, radius); } } private static void DoOperation(List nodes, Vector3 pos, float radius, Action action) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) foreach (HeightNode node in nodes) { action(node.Compiler, node.Index, node); } ClutterSystem instance = ClutterSystem.instance; if (instance != null) { instance.ResetGrass(pos, radius); } } public static Dictionary GetData(List heightNodes, List paintNodes) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0118: 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_015f: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) Dictionary dictionary = new Dictionary(); foreach (HeightNode heightNode in heightNodes) { TerrainComp compiler = heightNode.Compiler; if (!((Object)(object)compiler == (Object)null)) { Vector3 position = ((Component)compiler).transform.position; if (!dictionary.ContainsKey(position)) { dictionary.Add(position, new TerrainUndoData()); } dictionary[position].Heights.Add(new HeightUndoData { Index = heightNode.Index, HeightModified = compiler.m_modifiedHeight[heightNode.Index], Level = compiler.m_levelDelta[heightNode.Index], Smooth = compiler.m_smoothDelta[heightNode.Index] }); } } foreach (PaintNode paintNode in paintNodes) { TerrainComp compiler2 = paintNode.Compiler; if (!((Object)(object)compiler2 == (Object)null)) { Vector3 position2 = ((Component)compiler2).transform.position; if (!dictionary.ContainsKey(position2)) { dictionary.Add(position2, new TerrainUndoData()); } dictionary[position2].Paints.Add(new PaintUndoData { Index = paintNode.Index, PaintModified = compiler2.m_modifiedPaint[paintNode.Index], Paint = compiler2.m_paintMask[paintNode.Index] }); } } return dictionary; } public static void ApplyData(Dictionary data, Vector3 pos, float radius) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair datum in data) { TerrainComp val = TerrainComp.FindTerrainCompiler(datum.Key); if (!Object.op_Implicit((Object)(object)val)) { continue; } foreach (HeightUndoData height in datum.Value.Heights) { val.m_smoothDelta[height.Index] = height.Smooth; val.m_levelDelta[height.Index] = height.Level; val.m_modifiedHeight[height.Index] = height.HeightModified; } foreach (PaintUndoData paint in datum.Value.Paints) { val.m_modifiedPaint[paint.Index] = paint.PaintModified; val.m_paintMask[paint.Index] = paint.Paint; } Save(val); } ClutterSystem instance = ClutterSystem.instance; if (instance != null) { instance.ResetGrass(pos, radius); } } public static void Save(TerrainComp compiler) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) ZNetView component = ((Component)compiler).GetComponent(); if (component != null) { component.ClaimOwnership(); } compiler.m_operations++; compiler.m_lastOpPoint = Vector3.zero; compiler.m_lastOpRadius = 0f; compiler.Save(); compiler.m_hmap.Poke(false); } public static TerrainComp[] GetCompilers(Vector3 position, Range radius) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) List list = new List(); Heightmap.FindHeightmap(position, radius.Max + 1f, list); Vector3 pos = ZNet.instance.GetReferencePosition(); _ = ZNetScene.instance; return (from hmap in list where ZNetScene.InActiveArea(ZoneSystem.GetZone(((Component)hmap).transform.position), pos) select hmap.GetAndCreateTerrainCompiler()).ToArray(); } public static TerrainComp[] GetCompilers(Vector3 position, Range width, Range depth, float angle) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) List list = new List(); float num = Mathf.Max(width.Max, depth.Max); float num2 = Mathf.Abs(Mathf.Sin(angle)) + Mathf.Abs(Mathf.Cos(angle)); float num3 = num * num2; Heightmap.FindHeightmap(position, num3 + 1f, list); Vector3 pos = ZNet.instance.GetReferencePosition(); _ = ZNetScene.instance; return (from hmap in list where ZNetScene.InActiveArea(ZoneSystem.GetZone(((Component)hmap).transform.position), pos) select hmap.GetAndCreateTerrainCompiler()).ToArray(); } public static Func CreateBlockCheckFilter(BlockCheck blockCheck, string[] includedIds, string[] excludedIds) { HashSet included = Selector.GetPrefabs(includedIds); HashSet excluded = Selector.GetAllPrefabs(excludedIds); ZoneSystem zs = ZoneSystem.instance; return delegate(TerrainNode index) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) if (blockCheck == BlockCheck.Off) { return true; } Vector3 position = index.Position; position.y += 2000f; bool flag = ((IEnumerable)Physics.RaycastAll(position, Vector3.down, 10000f, zs.m_blockRayMask)).Select((Func)Selector.GetPrefabFromHit).Any((int prefab) => included.Contains(prefab) && !excluded.Contains(prefab)); if (flag && blockCheck == BlockCheck.On) { return false; } return (flag || blockCheck != BlockCheck.Inverse) ? true : false; }; } public static Func CreateAltitudeFilter(float min, float max) { return delegate(TerrainNode index) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) float groundHeight = ZoneSystem.instance.GetGroundHeight(index.Position); return groundHeight >= min && groundHeight <= max; }; } public static void GetHeightNodesWithCircle(List nodes, TerrainComp compiler, Vector3 centerPos, Range radius) { //IL_002d: 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_0033: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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) if (radius.Max == 0f) { return; } int num = compiler.m_width + 1; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { Vector3 val = VertexToWorld(compiler.m_hmap, i, j); float num2 = val.x - centerPos.x; float num3 = val.z - centerPos.z; float num4 = Utils.DistanceXZ(centerPos, val); if (Helper.Within(radius, num4)) { nodes.Add(new HeightNode { Index = j * num + i, Position = val, DistanceWidth = num2 / radius.Max, DistanceDepth = num3 / radius.Max, Distance = num4 / radius.Max, Compiler = compiler }); } } } } private static Vector3 VertexToWorld(Heightmap hmap, int x, int z) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)hmap).transform.position; position.x += (float)(x - hmap.m_width / 2) * hmap.m_scale; position.z += (float)(z - hmap.m_width / 2) * hmap.m_scale; return position; } private static float GetX(float x, float z, float angle) { return Mathf.Cos(angle) * x - Mathf.Sin(angle) * z; } private static float GetZ(float x, float z, float angle) { return Mathf.Sin(angle) * x + Mathf.Cos(angle) * z; } public static void GetHeightNodesWithRect(List nodes, TerrainComp compiler, Vector3 centerPos, Range width, Range depth, float angle) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if (width.Max == 0f || depth.Max == 0f) { return; } int num = compiler.m_width + 1; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { Vector3 val = VertexToWorld(compiler.m_hmap, i, j); float x = val.x - centerPos.x; float z = val.z - centerPos.z; float x2 = GetX(x, z, angle); float z2 = GetZ(x, z, angle); if (Helper.Within(width, depth, Mathf.Abs(x2), Mathf.Abs(z2))) { float num2 = x2 / width.Max; float num3 = z2 / depth.Max; nodes.Add(new HeightNode { Index = j * num + i, Position = val, DistanceWidth = num2, DistanceDepth = num3, Distance = Mathf.Max(Mathf.Abs(num2), Mathf.Abs(num3)), Compiler = compiler }); } } } } public static void GetPaintNodesWithRect(List nodes, TerrainComp compiler, Vector3 centerPos, Range width, Range depth, float angle) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_0038: 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_009a: Unknown result type (might be due to invalid IL or missing references) int num = compiler.m_width + 1; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { Vector3 val = VertexToWorld(compiler.m_hmap, i, j); float x = val.x - centerPos.x; float z = val.z - centerPos.z; float x2 = GetX(x, z, angle); float z2 = GetZ(x, z, angle); if (Helper.Within(width, depth, Mathf.Abs(x2), Mathf.Abs(z2))) { float num2 = x2 / width.Max; float num3 = z2 / depth.Max; nodes.Add(new PaintNode { Index = j * num + i, Position = val, DistanceWidth = num2, DistanceDepth = num3, Distance = Mathf.Max(Mathf.Abs(num2), Mathf.Abs(num3)), Compiler = compiler }); } } } } public static void GetPaintNodesWithCircle(List nodes, TerrainComp compiler, Vector3 centerPos, Range radius) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) int num = compiler.m_width + 1; for (int i = 0; i < num; i++) { for (int j = 0; j < num; j++) { Vector3 val = VertexToWorld(compiler.m_hmap, i, j); float num2 = val.x - centerPos.x; float num3 = val.z - centerPos.z; float num4 = Utils.DistanceXZ(centerPos, val); if (Helper.Within(radius, num4)) { nodes.Add(new PaintNode { Index = j * num + i, Position = val, DistanceWidth = num2 / radius.Max, DistanceDepth = num3 / radius.Max, Distance = num4 / radius.Max, Compiler = compiler }); } } } } } public abstract class TerrainNode { public int Index; public Vector3 Position; public float DistanceWidth; public float DistanceDepth; public float Distance; public TerrainComp? Compiler; } public class HeightNode : TerrainNode { } public class PaintNode : TerrainNode { } public enum BlockCheck { Off, On, Inverse } public class TerrainAutoComplete { public List NamedParameters = new List(20) { "lower", "level", "raise", "reset", "paint", "delta", "blockcheck", "rect", "circle", "smooth", "slope", "angle", "offset", "step", "from", "to", "min", "max", "within", "chance" }; public TerrainAutoComplete() { NamedParameters.Sort(); List paints = TerrainCommand.Paints.Keys.ToList(); paints.Sort(); AutoComplete.Register("terrain", (Func>)((int index) => NamedParameters), new Dictionary>> { { "chance", (int index) => ParameterInfo.Create("chance=number (from 0.0 to 1.0)", "Chance of the operation being applied to a node.") }, { "reset", (int index) => ParameterInfo.Flag("Reset") }, { "void", (int index) => ParameterInfo.Flag("Void", "Removes all terrain.") }, { "blockcheck", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("blockcheck=inverse/off/on", "When on, excludes terrain under structures. When inverse, only includes terrain under structures.") }, { "rect", (int index) => index switch { 0 => ParameterInfo.Create("rect=size or rect=width,depth", "Size of the included terrain (rectangle)."), 1 => ParameterInfo.Create("rect=width,depth", "Size of the included terrain (rectangle)."), _ => ParameterInfo.None, } }, { "min", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("min", "altitude", "Raises terrain below the given altitude to the altitude.") }, { "max", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("max", "altitude", "Lowers terrain above the given altitude to the altitude.") }, { "angle", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("angle=number/n/ne/e/se/s/sw/w/nw (from 0 to 360)", "Direction of the shape.") }, { "circle", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("circle=number", "Radius of the included terrain.") }, { "offset", (int index) => ParameterInfo.FRU("offset", "Position of the center", index) }, { "from", (int index) => ParameterInfo.XZY("from", "Overrides the player position", index) }, { "to", (int index) => ParameterInfo.XZY("to", "Determines the angle and circle/rect distance.", index) }, { "step", (int index) => ParameterInfo.FRU("step", "Offset based on radius", index) }, { "smooth", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("smooth=number (from 0.0 to 1.0)", "Higher values smoothen the effect near edges.") }, { "slope", (int index) => index switch { 0 => ParameterInfo.Create("slope=meters,angle=0", "Creates a slope with altitude difference of a given amount."), 1 => ParameterInfo.Create("slope=meters,angle", "Changes the slope direction (added to the general angle)."), _ => ParameterInfo.None, } }, { "delta", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("delta", "meters", "Sets the terrain elevation difference from the original.") }, { "raise", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("raise", "meters", "Raises the terrain by a given amount.") }, { "lower", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("lower", "meters", "Lowers the terrain by a given amount.") }, { "level", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("level or level=altitude", "Levels the terrain to a given altitude. Without parameters, levels to the terrain altitude below the player.") }, { "within", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("within", "min-max", "Only includes terrain within the given altitude range.") }, { "paint", (int index) => index switch { 0 => paints, 1 => ParameterInfo.Create("paint=dirt,cultivated,vegetation,paved", "Custom color (values from 0.0 to 1.0)."), 2 => ParameterInfo.Create("paint=dirt,cultivated,paved,vegetation", "Custom color (values from 0.0 to 1.0)."), 3 => ParameterInfo.Create("paint=dirt,cultivated,paved,vegetation", "Custom color (values from 0.0 to 1.0)."), _ => ParameterInfo.None, } }, { "id", (int index) => ParameterInfo.Ids }, { "ignore", (int index) => ParameterInfo.Ids } }); } } public class TerrainCommand { public const string Name = "terrain"; public static Dictionary Paints = new Dictionary { { "grass", Color.black }, { "patches", new Color(0f, 0.75f, 0f) }, { "grass_dark", new Color(0.6f, 0.5f, 0f) }, { "dirt", Color.red }, { "cultivated", Color.green }, { "paved", Color.blue }, { "paved_moss", new Color(0f, 0f, 0.5f) }, { "paved_dirt", new Color(1f, 0f, 0.5f) }, { "paved_dark", new Color(0f, 1f, 0.5f) }, { "lava", new Color(float.NaN, float.NaN, float.NaN, -1f) }, { "lava_shallow", new Color(float.NaN, float.NaN, float.NaN, -0.5f) }, { "lava_light", new Color(float.NaN, float.NaN, float.NaN, -0.25f) } }; private TerrainComp[] GetCompilers(TerrainParameters pars) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (pars.Radius != null) { return Terrain.GetCompilers(pars.Position, pars.Radius); } if (pars.Width != null && pars.Depth != null) { return Terrain.GetCompilers(pars.Position, pars.Width, pars.Depth, pars.Angle); } throw new InvalidOperationException("Unable to select any terrain"); } private List GetHeightNodes(TerrainParameters pars, IEnumerable compilers) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (TerrainComp compiler in compilers) { if (pars.Radius != null) { Terrain.GetHeightNodesWithCircle(list, compiler, pars.Position, pars.Radius); } if (pars.Width != null && pars.Depth != null) { Terrain.GetHeightNodesWithRect(list, compiler, pars.Position, pars.Width, pars.Depth, pars.Angle); } } if (pars.Chance < 1f) { list = list.Where((HeightNode n) => Random.value < pars.Chance).ToList(); } return list; } private List GetPaintNodes(TerrainParameters pars, IEnumerable compilers) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) List list = new List(); foreach (TerrainComp compiler in compilers) { if (pars.Radius != null) { Terrain.GetPaintNodesWithCircle(list, compiler, pars.Position, pars.Radius); } if (pars.Width != null && pars.Depth != null) { Terrain.GetPaintNodesWithRect(list, compiler, pars.Position, pars.Width, pars.Depth, pars.Angle); } } if (pars.Chance < 1f) { list = list.Where((PaintNode n) => Random.value < pars.Chance).ToList(); } return list; } private List> GetFilterers(TerrainParameters pars) { List> list = new List>(); if (pars.BlockCheck != BlockCheck.Off) { list.Add(Terrain.CreateBlockCheckFilter(pars.BlockCheck, pars.IncludedIds, pars.ExcludedIds)); } if (pars.Within != null) { list.Add(Terrain.CreateAltitudeFilter(pars.Within.Min, pars.Within.Max)); } return list; } public TerrainCommand() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Expected O, but got Unknown new TerrainAutoComplete(); Helper.Command("terrain", "Manipulates the terrain.", (ConsoleEvent)delegate(ConsoleEventArgs args) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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_01c3: 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_02a7: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) TerrainParameters terrainParameters = new TerrainParameters(args); TerrainComp[] compilers = GetCompilers(terrainParameters); List> filterers = GetFilterers(terrainParameters); List list = (from n in GetHeightNodes(terrainParameters, compilers) where filterers.All((Func f) => f(n)) select n).ToList(); List list2 = (from n in GetPaintNodes(terrainParameters, compilers) where filterers.All((Func f) => f(n)) select n).ToList(); Dictionary data = Terrain.GetData(list, list2); if (terrainParameters.Reset) { Terrain.ResetTerrain(list, list2, terrainParameters.Position, terrainParameters.Size); } if (terrainParameters.Set.HasValue) { Terrain.SetTerrain(list, terrainParameters.Position, terrainParameters.Size, terrainParameters.Smooth, terrainParameters.Set.Value); } if (terrainParameters.Slope.HasValue && !terrainParameters.Level.HasValue) { Terrain.SlopeTerrain(list, terrainParameters.Position, terrainParameters.Size, terrainParameters.SlopeAngle, terrainParameters.Smooth, terrainParameters.Position.y, terrainParameters.Slope.Value); } if (terrainParameters.Level.HasValue) { Terrain.LevelTerrain(list, terrainParameters.Position, terrainParameters.Size, terrainParameters.Smooth, terrainParameters.Level.Value); } if (terrainParameters.Delta.HasValue) { Terrain.RaiseTerrain(list, terrainParameters.Position, terrainParameters.Size, terrainParameters.Smooth, terrainParameters.Delta.Value); } if (terrainParameters.Min.HasValue) { Terrain.MinTerrain(list, terrainParameters.Position, terrainParameters.Size, terrainParameters.Min.Value); } if (terrainParameters.Max.HasValue) { Terrain.MaxTerrain(list, terrainParameters.Position, terrainParameters.Size, terrainParameters.Max.Value); } if (terrainParameters.Void) { Terrain.VoidTerrain(list, terrainParameters.Position, terrainParameters.Size); } if (terrainParameters.Paint != "") { string[] array = terrainParameters.Paint.Split(new char[1] { ',' }); Color value; if (array.Length > 2) { for (int num = 0; num < array.Length; num++) { if (array[num].StartsWith("*")) { array[num] = "NaN"; } } Color color = default(Color); ((Color)(ref color))..ctor(Parse.Float(array, 0, 0f), Parse.Float(array, 1, 0f), Parse.Float(array, 2, 0f), Parse.Float(array, 3, 1f)); Terrain.PaintTerrain(list2, terrainParameters.Position, terrainParameters.Size, terrainParameters.Smooth, color); } else if (Paints.TryGetValue(terrainParameters.Paint, out value)) { Terrain.PaintTerrain(list2, terrainParameters.Position, terrainParameters.Size, terrainParameters.Smooth, value); } } TerrainComp[] array2 = compilers; for (int num2 = 0; num2 < array2.Length; num2++) { Terrain.Save(array2[num2]); } Dictionary data2 = Terrain.GetData(list, list2); UndoManager.Add((IUndoAction)(object)new UndoTerrain(data, data2, terrainParameters.Position, terrainParameters.Size)); }); } } public class TerrainParameters { public Vector3 Position = Vector3.zero; public Vector3 Offset = Vector3.zero; public Vector3 Step = Vector3.zero; public float Size; public Range? Radius; public Range? Width; public Range? Depth; public string[] IncludedIds = Array.Empty(); public string[] ExcludedIds = Array.Empty(); public float Angle; public float? Set; public bool Reset; public bool Void; public float? Delta; public float? Level; public float? Min; public float? Max; public float Smooth; public float? Slope; public float SlopeAngle; public string Paint = ""; public bool FixedPosition; public bool FixedAngle; public BlockCheck BlockCheck; public Range? Within; public float Chance = 1f; public TerrainParameters(ConsoleEventArgs args) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { float num = (float)Math.PI / 4f; Position = ((Component)Player.m_localPlayer).transform.position; Quaternion rotation = ((Component)Player.m_localPlayer).transform.rotation; Angle = num * Mathf.Round(((Quaternion)(ref rotation)).eulerAngles.y / 45f); } ParseArgs(args.Args); } private float ParseAngle(string value) { return value switch { "n" => 0f, "ne" => 45f, "e" => 90f, "se" => 135f, "s" => 180f, "sw" => 225f, "w" => 270f, "nw" => 315f, _ => Parse.Float(value, 0f), } * ((float)Math.PI / 180f); } protected void ParseArgs(string[] args) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: 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_058b: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_06bc: Unknown result type (might be due to invalid IL or missing references) //IL_06c1: Unknown result type (might be due to invalid IL or missing references) //IL_06d1: Unknown result type (might be due to invalid IL or missing references) //IL_06d6: Unknown result type (might be due to invalid IL or missing references) //IL_06e9: Unknown result type (might be due to invalid IL or missing references) //IL_06fc: Unknown result type (might be due to invalid IL or missing references) //IL_071b: Unknown result type (might be due to invalid IL or missing references) //IL_072e: Unknown result type (might be due to invalid IL or missing references) //IL_073e: Unknown result type (might be due to invalid IL or missing references) //IL_0744: Unknown result type (might be due to invalid IL or missing references) //IL_0749: Unknown result type (might be due to invalid IL or missing references) //IL_074e: Unknown result type (might be due to invalid IL or missing references) //IL_041c: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_0487: Unknown result type (might be due to invalid IL or missing references) bool flag = true; string[] array = args; for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split(new char[1] { '=' }); string text = array2[0].ToLower(); if (array2.Length >= 2) { string text2 = array2[1].ToLower(); if (text == "from") { FixedPosition = true; flag = Parse.Split(text2, ',').Length < 3; Position = Parse.VectorXZY(Parse.Split(text2, ',')); } } } if (flag) { if (!ZoneSystem.instance.IsZoneLoaded(Position)) { throw new InvalidOperationException("Unable to find the ground height. Use from with the y coordinate."); } Position.y = ZoneSystem.instance.GetGroundHeight(Position); } array = args; for (int i = 0; i < array.Length; i++) { string[] array3 = array[i].Split(new char[1] { '=' }); string text3 = array3[0].ToLower(); if (text3 == "reset") { Reset = true; } if (text3 == "void") { Void = true; } if (text3 == "delta") { Set = 0f; } if (text3 == "level") { Level = Position.y; } if (text3 == "blockcheck") { BlockCheck = BlockCheck.On; } if (text3 == "circle") { Radius = new Range(0f); } if (text3 == "rect") { Width = new Range(0f); Depth = new Range(0f); } if (text3 == "slope") { Slope = 0f; } if (array3.Length < 2) { continue; } string text4 = array3[1].ToLower(); string[] array4 = Parse.Split(text4, ','); if (text3 == "chance") { Range val = Parse.FloatRange(text4, 1f); Chance = Helper.RandomValue(val); } if (text3 == "id") { IncludedIds = array4; } if (text3 == "ignore") { ExcludedIds = array4; } if (text3 == "circle") { Radius = Parse.FloatRange(text4, 0f); } if (text3 == "rect") { Range val2 = Parse.ScaleRange(text4); Width = new Range(val2.Min.x, val2.Max.x); Depth = new Range(val2.Min.z, val2.Max.z); } if (text3 == "paint") { Paint = text4; } if (text3 == "angle") { FixedAngle = true; Angle = ParseAngle(text4); } if (text3 == "delta") { Set = Parse.Float(text4, 0f); } if (text3 == "min") { Min = Parse.Float(text4, float.MinValue); } if (text3 == "max") { Max = Parse.Float(text4, float.MaxValue); } if (text3 == "raise") { Delta = Parse.Float(text4, 0f); } if (text3 == "lower") { Delta = 0f - Parse.Float(text4, 0f); } if (text3 == "smooth") { Smooth = Parse.Float(text4, 0f); } if (text3 == "slope") { Slope = Parse.Float(array4, 0, 0f); if (array4.Length > 1) { SlopeAngle = ParseAngle(array4[1]); } } if (text3 == "offset") { Offset = Parse.VectorZXY(array4); } if (text3 == "within") { Within = Parse.FloatRange(text4, 0f); } if (text3 == "level") { Level = Parse.Float(text4, Position.y); } if (text3 == "step") { Step = Parse.VectorZXY(array4); } if (text3 == "blockcheck") { switch (text4) { case "on": BlockCheck = BlockCheck.On; break; case "inverse": BlockCheck = BlockCheck.Inverse; break; case "off": BlockCheck = BlockCheck.Off; break; default: throw new InvalidOperationException("Invalid value " + text4 + " for blockcheck."); } } } HandleTo(args); if (Radius != null && Depth != null) { throw new InvalidOperationException("circle and rect parameters can't be used together."); } if (Radius == null && Depth == null) { throw new InvalidOperationException("circle or rect parameter must be used."); } if (Radius != null) { Size = Radius.Max; } if (Depth != null && Width != null) { Size = Mathf.Max(Depth.Max, Width.Max); } if (Step != Vector3.zero) { float num = Size; float num2 = Size; if (Width != null) { num = Width.Max; } if (Depth != null) { num2 = Depth.Max; } Offset.x += Step.x * num * 2f; Offset.z += Step.z * num2 * 2f; if (Slope.HasValue) { Offset.y = Slope.Value * (Step.z + Step.y); if (Level.HasValue) { Level += Offset.y - 0.5f * Slope.Value; } } } if (Offset != Vector3.zero) { Vector3 offset = Offset; Offset.x = Mathf.Cos(Angle) * offset.x + Mathf.Sin(Angle) * offset.z; Offset.z = Mathf.Cos(Angle) * offset.z - Mathf.Sin(Angle) * offset.x; Position += Offset; } if (Radius != null) { SlopeAngle += Angle; } } private void HandleTo(string[] args) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < args.Length; i++) { string[] array = args[i].Split(new char[1] { '=' }); string text = array[0].ToLower(); if (array.Length < 2) { continue; } string text2 = array[1].ToLower(); if (!(text == "to")) { continue; } Vector3 val = Parse.VectorXZY(Parse.Split(text2, ',')); if (Slope == 0f && Parse.Split(text2, ',').Length < 3) { if (!ZoneSystem.instance.IsZoneLoaded(val)) { throw new InvalidOperationException("Unable to find the ground height. Use to with the y coordinate."); } val.y = ZoneSystem.instance.GetGroundHeight(val); } float num = Utils.DistanceXZ(Position, val); if (Radius != null) { Radius = new Range(num / 2f); } Range? width = Width; if (width != null && width.Max == 0f) { Width = new Range(num / 2f); } if (Depth != null) { Depth = new Range(num / 2f); } FixedAngle = true; Angle = Vector3.SignedAngle(Vector3.forward, Utils.DirectionXZ(val - Position), Vector3.up) * (float)Math.PI / 180f; Position.x = (Position.x + val.x) / 2f; Position.z = (Position.z + val.z) / 2f; if (Slope.HasValue) { if (Slope == 0f) { Slope = val.y - Position.y; } Position.y += Slope.Value / 2f; } } } } public enum Growth { Default, HealthyGrown, UnhealthyGrown, Healthy, Unhealthy } public enum Wear { Default, Broken, Damaged, Healthy } public enum Fall { Default, Off, Terrain, Solid } public enum Enum_CLLC_Boss { None, Reflective, Shielded, Mending, Summoner, Elementalist, Enraged, Twin } public enum Enum_CLLC_Infusion { None, Lightning, Fire, Frost, Poison, Chaos, Spirit } public enum Enum_CLLC_Effect { None, Aggressive, Quick, Regenerating, Curious, Splitting, Armored } public static class TweakActions { private const string DEFAULT = "default"; private static int BiomeToInt(string value) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected I4, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) string[] array = value.Split(new char[1] { ',' }); Biome val = (Biome)0; string[] array2 = array; for (int i = 0; i < array2.Length; i++) { if (Enum.TryParse(array2[i], ignoreCase: true, out Biome result)) { val |= result; } } return (int)val; } private static string Print(T? value) { if (value != null) { return value.ToString(); } return "default"; } private static bool? Reverse(bool? value) { if (value.HasValue) { return !value; } return null; } public static string Render(ZNetView view, bool? value) { value = !Actions.ToggleBool(view, Reverse(value), Hash.NoRender); return "ยค render set to " + Print(value) + "."; } public static string Interact(ZNetView view, bool? value) { value = !Actions.ToggleBool(view, Reverse(value), Hash.NoInteract); return "ยค interact set to " + Print(value) + "."; } public static string Collision(ZNetView view, bool? value) { value = !Actions.ToggleBool(view, Reverse(value), Hash.NoCollision); return "ยค collision set to " + Print(value) + "."; } public static string Wear(ZNetView view, string? value) { Actions.SetInt(view, WearNumber(value), Hash.Wear); return "ยค wear set to " + Print(value) + "."; } private static int WearNumber(string? wear) { return wear switch { "broken" => 3, "damaged" => 1, "healthy" => 2, _ => 0, }; } public static string Status(ZNetView view, string? value) { Actions.SetString(view, value, Hash.Status); return "ยค status set to " + Print(value) + "."; } public static string Event(ZNetView view, string? value) { Actions.SetString(view, value, Hash.Event); return "ยค event set to " + Print(value) + "."; } public static string Effect(ZNetView view, string? value) { Actions.SetString(view, value, Hash.Effect); return "ยค effect set to " + Print(value) + "."; } public static string Weather(ZNetView view, int hash, string? value) { if (!EnvMan.instance.m_environments.Any((EnvSetup env) => env.m_name == value)) { value = value?.Replace("_", " "); } Actions.SetString(view, value, hash); return "ยค weather set to " + Print(value) + "."; } public static string Water(ZNetView view, string? value) { Actions.SetString(view, value, Hash.Water); return "ยค water set to " + Print(value) + "."; } public static string EnterText(ZNetView view, string? value) { Actions.SetString(view, value, Hash.DungeonEnterText); return "ยค enter text set to " + Print(value) + "."; } public static string ExitText(ZNetView view, string? value) { Actions.SetString(view, value, Hash.DungeonExitText); return "ยค exit text set to " + Print(value) + "."; } public static string EnterHover(ZNetView view, string? value) { Actions.SetString(view, value, Hash.DungeonEnterHover); return "ยค enter hover set to " + Print(value) + "."; } public static string ExitHover(ZNetView view, string? value) { Actions.SetString(view, value, Hash.DungeonExitHover); return "ยค exit hover set to " + Print(value) + "."; } public static string Fall(ZNetView view, string? value) { Actions.SetInt(view, FallNumber(value), Hash.Fall); return "ยค fall set to " + Print(value) + "."; } private static int FallNumber(string? fall) { if (fall == null) { return 0; } return fall switch { "off" => 3, "terrain" => 1, "solid" => 2, _ => 0, }; } public static string Growth(ZNetView view, string? value) { int num = GrowthNumber(value); Actions.SetInt(view, num, Hash.Growth); long num2; if (num >= 0) { DateTime maxValue = DateTime.MaxValue; num2 = maxValue.Ticks / 2; } else { num2 = ZNet.instance.GetTime().Ticks; } long num3 = num2; view.GetZDO().Set(Hash.PlantTime, num3); return "ยค growth set to " + Print(value) + "."; } private static int GrowthNumber(string? growth) { return growth switch { "big" => 4, "big_bad" => 1, "small" => 2, "small_bad" => 3, _ => 0, }; } public static string Component(ZNetView view, string? value) { Actions.SetString(view, value, Hash.Component); return "ยค component set to " + Print(value) + "."; } public static string AddComponent(ZNetView view, string value) { HashSet hashSet = Parse.Split(view.GetZDO().GetString(Hash.Component, ""), ',').ToHashSet(); hashSet.Add(value); Actions.SetString(view, string.Join(",", hashSet), Hash.Component); return "ยค component set to " + Print(value) + "."; } public static string Restrict(ZNetView view, bool? value) { value = !Actions.ToggleBool(view, Reverse(value), Hash.NoRestrict); return "ยค restrict set to " + Print(value) + "."; } public static string Boss(ZNetView view, bool? value) { value = Actions.ToggleBool(view, value, Hash.Boss); return "ยค boss set to " + Print(value) + "."; } public static string Hunt(ZNetView view, bool? value) { value = Actions.ToggleBool(view, value, Hash.HuntPlayer); return "ยค hunt set to " + Print(value) + "."; } public static string Tame(ZNetView view, bool? value) { value = Actions.ToggleBool(view, value, Hash.Tamed); return "ยค tamed set to " + Print(value) + "."; } public static string Unlock(ZNetView view, bool? value) { value = Actions.ToggleBool(view, value, Hash.Unlock); return "ยค unlock set to " + Print(value) + "."; } public static string Consume(ZNetView view, bool? value) { value = Actions.ToggleBool(view, value, Hash.DoorConsume); return "ยค consume set to " + Print(value) + "."; } public static string NoClose(ZNetView view, bool? value) { value = Actions.ToggleBool(view, value, Hash.DoorNoClose); return "ยค no close set to " + Print(value) + "."; } public static string DoorKey(ZNetView view, string? value) { Actions.SetString(view, value, Hash.DoorKey); return "ยค door key set to " + Print(value) + "."; } public static string Creator(ZNetView view, long? value) { Actions.SetLong(view, value.GetValueOrDefault(), Hash.Creator); return "ยค creator set to " + Print(value) + "."; } public static string Smoke(ZNetView view, string? value) { int value2 = 0; if (value == "off") { value2 = 1; } if (value == "ignore") { value2 = 2; } Actions.SetInt(view, value2, Hash.Smoke); return "ยค smoke set to " + Print(value) + "."; } public static string CLLC_BossEffect(ZNetView view, string[] values) { Enum_CLLC_Boss enum_CLLC_Boss = Enum_CLLC_Boss.None; for (int i = 0; i < values.Length; i++) { if (Enum.TryParse(values[i], ignoreCase: true, out var result)) { enum_CLLC_Boss |= result; } } Actions.SetInt(view, (int)enum_CLLC_Boss, Hash.CLLC_BossEffect); return "ยค CLLC affix set to " + Print(enum_CLLC_Boss) + "."; } public static string CLLC_Effect(ZNetView view, string[] values) { Enum_CLLC_Effect enum_CLLC_Effect = Enum_CLLC_Effect.None; for (int i = 0; i < values.Length; i++) { if (Enum.TryParse(values[i], ignoreCase: true, out var result)) { enum_CLLC_Effect |= result; } } Actions.SetInt(view, (int)enum_CLLC_Effect, Hash.CLLC_Effect); return "ยค CLLC effect set to " + Print(enum_CLLC_Effect) + "."; } public static string CLLC_Infusion(ZNetView view, string[] values) { Enum_CLLC_Infusion enum_CLLC_Infusion = Enum_CLLC_Infusion.None; for (int i = 0; i < values.Length; i++) { if (Enum.TryParse(values[i], ignoreCase: true, out var result)) { enum_CLLC_Infusion |= result; } } Actions.SetInt(view, (int)enum_CLLC_Infusion, Hash.CLLC_Infusion); return "ยค CLLC infusion set to " + Print(enum_CLLC_Infusion) + "."; } public static string SpawnData(ZNetView view, string? value) { Actions.SetString(view, (value == null) ? null : DataHelper.Base64(new Dictionary(), value), Hash.Data); return "ยค spawn data set to " + Print(value) + "."; } public static string Spawn(ZNetView view, int hash, string? value) { Actions.SetPrefab(view, value, hash); return "ยค spawn prefab set to " + Print(value) + "."; } public static string Biome(ZNetView view, string? value) { Actions.SetInt(view, BiomeToInt(value ?? ""), Hash.Biome); return "ยค biome set to " + Print(value) + "."; } public static string Fuel(ZNetView view, string? value) { Actions.SetPrefab(view, value, Hash.OverrideFuel); return "ยค fuel prefab set to " + Print(value) + "."; } public static string ItemOffset(ZNetView view, string? value) { Actions.SetString(view, value, Hash.ItemOffset); return "ยค item offset set to " + Print(value) + "."; } public static string CoverOffset(ZNetView view, string? value) { Actions.SetString(view, value, Hash.CoverOffset); return "ยค cover offset set to " + Print(value) + "."; } public static string SpawnOffset(ZNetView view, string? value) { Actions.SetString(view, value, Hash.SpawnOffset); return "ยค spawn offset set to " + Print(value) + "."; } public static string ItemStandPrefix(ZNetView view, string? value) { Actions.SetString(view, value, Hash.ItemStandPrefix); return "ยค item stand prefix set to " + Print(value) + "."; } public static string GlobalKey(ZNetView view, string? value) { Actions.SetString(view, value, Hash.GlobalKey); return "ยค global key set to " + Print(value) + "."; } public static string Name(ZNetView view, string? value) { Actions.SetString(view, value, Hash.OverrideName); return "ยค name set to " + Print(value) + "."; } public static string Text(ZNetView view, string? value) { Actions.SetString(view, value, Hash.OverrideText); return "ยค text set to " + Print(value) + "."; } public static string TextBiome(ZNetView view, string? value) { Actions.SetString(view, value, Hash.TextBiome); return "ยค biome text set to " + Print(value) + "."; } public static string TextSpace(ZNetView view, string? value) { Actions.SetString(view, value, Hash.TextSpace); return "ยค space text set to " + Print(value) + "."; } public static string TextSleep(ZNetView view, string? value) { Actions.SetString(view, value, Hash.TextSleep); return "ยค sleep text set to " + Print(value) + "."; } public static string TextHappy(ZNetView view, string? value) { Actions.SetString(view, value, Hash.TextHappy); return "ยค happy text set to " + Print(value) + "."; } public static string TextCheck(ZNetView view, string? value) { Actions.SetString(view, value, Hash.TextCheck); return "ยค check text set to " + Print(value) + "."; } public static string TextExtract(ZNetView view, string? value) { Actions.SetString(view, value, Hash.TextExtract); return "ยค extract text set to " + Print(value) + "."; } public static string Compendium(ZNetView view, string[] value) { string value2 = ((value.Length == 0) ? null : string.Join("|", value)); Actions.SetString(view, value2, Hash.Compendium); return "ยค compendium set to " + Print(value) + "."; } public static string Topic(ZNetView view, string? value) { Actions.SetString(view, value, Hash.Topic); return "ยค topic set to " + Print(value) + "."; } public static string Discover(ZNetView view, string? value) { Actions.SetString(view, value, Hash.Discover); return "ยค discover set to " + Print(value) + "."; } public static string Spawns(ZNetView view, string[] value) { float num = default(float); if (value.Length > 4 && !Parse.TryFloat(value[4], ref num)) { value[4] = DataHelper.Base64(new Dictionary(), value[4]); } string value2 = ((value.Length == 0) ? null : string.Join("|", value)); Actions.SetString(view, value2, Hash.SpawnSpawnArea); return "ยค spawn prefabs set to " + Print(value2) + "."; } public static string Conversions(ZNetView view, string[] value) { string value2 = ((value.Length == 0) ? null : string.Join("|", value)); Actions.SetString(view, value2, Hash.Conversion); return "ยค conversions set to " + Print(value2) + "."; } public static string Items(ZNetView view, string[] value) { string value2 = ((value.Length == 0) ? null : string.Join("|", value)); Actions.SetString(view, value2, Hash.OverrideItems); return "ยค items set to " + Print(value2) + "."; } public static string SpawnEffect(ZNetView view, string[] value) { string value2 = ((value.Length == 0) ? null : string.Join("|", value)); Actions.SetString(view, value2, Hash.SpawnEffect); return "ยค spawn effect set to " + Print(value2) + "."; } public static string DestroyEffect(ZNetView view, string[] value) { string value2 = ((value.Length == 0) ? null : string.Join("|", value)); Actions.SetString(view, value2, Hash.DestroyEffect); return "ยค destroy effect set to " + Print(value2) + "."; } public static string UseEffect(ZNetView view, string[] value) { string value2 = ((value.Length == 0) ? null : string.Join("|", value)); Actions.SetString(view, value2, Hash.UseEffect); return "ยค use effect set to " + Print(value2) + "."; } public static string InputEffect(ZNetView view, string[] value) { string value2 = ((value.Length == 0) ? null : string.Join("|", value)); Actions.SetString(view, value2, Hash.InputEffect); return "ยค input effect set to " + Print(value2) + "."; } public static string OpenEffect(ZNetView view, string[] value) { string value2 = ((value.Length == 0) ? null : string.Join("|", value)); Actions.SetString(view, value2, Hash.OpenEffect); return "ยค open effect set to " + Print(value2) + "."; } public static string CloseEffect(ZNetView view, string[] value) { string value2 = ((value.Length == 0) ? null : string.Join("|", value)); Actions.SetString(view, value2, Hash.CloseEffect); return "ยค close effect set to " + Print(value2) + "."; } public static string LockedEffect(ZNetView view, string[] value) { string value2 = ((value.Length == 0) ? null : string.Join("|", value)); Actions.SetString(view, value2, Hash.LockedEffect); return "ยค locked effect set to " + Print(value2) + "."; } public static string OutputEffect(ZNetView view, string[] value) { string value2 = ((value.Length == 0) ? null : string.Join("|", value)); Actions.SetString(view, value2, Hash.OutputEffect); return "ยค output effect set to " + Print(value2) + "."; } public static string FuelEffect(ZNetView view, string[] value) { string value2 = ((value.Length == 0) ? null : string.Join("|", value)); Actions.SetString(view, value2, Hash.FuelEffect); return "ยค fuel effect set to " + Print(value2) + "."; } public static string StartEffect(ZNetView view, string[] value) { string value2 = ((value.Length == 0) ? null : string.Join("|", value)); Actions.SetString(view, value2, Hash.StartEffect); return "ยค start effect set to " + Print(value2) + "."; } public static string SpawnItem(ZNetView view, string? value) { Actions.SetPrefab(view, value, Hash.SpawnItem); return "ยค spawn item prefab set to " + Print(value) + "."; } public static string Item(ZNetView view, string? value) { Actions.SetString(view, value, Hash.OverrideItem); return "ยค item set to " + Print(value) + "."; } public static string Faction(ZNetView view, string? value) { Actions.SetString(view, value, Hash.Faction); return "ยค faction set to " + Print(value) + "."; } public static string Command(ZNetView view, string? value) { Actions.SetString(view, value, Hash.Command); return "ยค command set to " + Print(value) + "."; } private static string Resistance(string value) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected I4, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected I4, but got Unknown string[] array = value.Split(new char[1] { ',' }); if (array.Length < 2) { return ""; } if (!Enum.TryParse(array[0], ignoreCase: true, out DamageType result)) { return ""; } if (!Enum.TryParse(array[1], ignoreCase: true, out DamageModifier result2)) { return ""; } return (int)result + "," + (int)result2; } public static string Resistances(ZNetView view, string[] value) { string value2 = ((value.Length == 0) ? null : string.Join("|", from s in value.Select(Resistance) where s != "" select s)); Actions.SetString(view, value2, Hash.Resistances); return "ยค resistances set to " + Print(string.Join("|", value)) + "."; } public static string Attacks(ZNetView view, string[] value) { string value2 = ((value.Length == 0) ? null : string.Join("|", value)); Actions.SetString(view, value2, Hash.Attacks); return "ยค attacks set to " + Print(string.Join("|", value)) + "."; } public static string MinLevel(ZNetView view, int? value) { Actions.SetInt(view, value, Hash.MinLevel); return "ยค minimum level set to " + Print(value) + "."; } public static string MaxLevel(ZNetView view, int? value) { Actions.SetInt(view, value, Hash.MaxLevel); return "ยค maximum level set to " + Print(value) + "."; } public static string MinAmount(ZNetView view, int? value) { Actions.SetInt(view, value, Hash.MinAmount); return "ยค minimum amount set to " + Print(value) + "."; } public static string Level(ZNetView view, int? value) { Actions.SetInt(view, value, Hash.Level); return "ยค level set to " + Print(value) + "."; } public static string Health(ZNetView view, float? value) { Actions.SetFloat(view, value, Hash.Health); return "ยค health set to " + Print(value) + "."; } public static string MaxAmount(ZNetView view, int? value) { Actions.SetInt(view, value, Hash.MaxAmount); return "ยค maximum amount set to " + Print(value) + "."; } public static string Amount(ZNetView view, int? value) { Actions.SetInt(view, value, Hash.Amount); return "ยค amount set to " + Print(value) + "."; } public static string MaxNear(ZNetView view, int? value) { Actions.SetInt(view, value, Hash.MaxNear); return "ยค max near set to " + Print(value) + "."; } public static string MaxTotal(ZNetView view, int? value) { Actions.SetInt(view, value, Hash.MaxTotal); return "ยค max total set to " + Print(value) + "."; } public static string SpawnCondition(ZNetView view, int? value) { Actions.SetInt(view, value, Hash.SpawnCondition); return "ยค spawn condition set to " + Print(value) + "."; } public static string MaxFuel(ZNetView view, int? value) { Actions.SetInt(view, value, Hash.MaxFuel); return "ยค maximum fuel set to " + Print(value) + "."; } public static string FuelUsage(ZNetView view, int? value) { Actions.SetInt(view, value, Hash.FuelUsage); return "ยค fuel usage set to " + Print(value) + "."; } public static string Speed(ZNetView view, float? value) { Actions.SetFloat(view, value, Hash.Speed); return "ยค speed set to " + Print(value) + " seconds."; } public static string MaxCover(ZNetView view, float? value) { Actions.SetFloat(view, value, Hash.MaxCover); return "ยค max cover set to " + Print(value) + " seconds."; } public static string Respawn(ZNetView view, int hash, float? value) { Actions.SetFloat(view, value, hash); return "ยค respawn time set to " + Print(value) + " minutes."; } public static string Delay(ZNetView view, float? value) { Actions.SetFloat(view, value, Hash.Delay); return "ยค delay set to " + Print(value) + " seconds."; } public static string ItemStandRange(ZNetView view, float? value) { Actions.SetFloat(view, value, Hash.ItemStandRange); return "ยค item stand range set to " + Print(value) + " meters."; } public static string SpawnMaxY(ZNetView view, float? value) { Actions.SetFloat(view, value, Hash.SpawnMaxY); return "ยค spawn max y set to " + Print(value) + " meters."; } public static string RespawnSeconds(ZNetView view, int hash, float? value) { Actions.SetFloat(view, value, hash); return "ยค respawn time set to " + Print(value) + " seconds."; } public static string SpawnHealth(ZNetView view, float? value) { Actions.SetFloat(view, value, Hash.SpawnHealth); return "ยค spawn health set to " + Print(value) + "."; } public static string TriggerDistance(ZNetView view, float? value) { Actions.SetFloat(view, value, Hash.TriggerDistance); return "ยค trigger distance set to " + Print(value) + "."; } public static string TriggerNoise(ZNetView view, float? value) { Actions.SetFloat(view, value, Hash.TriggerNoise); return "ยค trigger noise set to " + Print(value) + " meters."; } public static string LevelChance(ZNetView view, float? value) { Actions.SetFloat(view, value, Hash.LevelChance); return "ยค level up chance set to " + Print(value) + " %."; } public static string SpawnRadius(ZNetView view, float? value) { Actions.SetFloat(view, value, Hash.SpawnRadius); return "ยค spawn radius set to " + Print(value) + " meters."; } public static string NearRadius(ZNetView view, float? value) { Actions.SetFloat(view, value, Hash.NearRadius); return "ยค near radius set to " + Print(value) + " meters."; } public static string FarRadius(ZNetView view, float? value) { Actions.SetFloat(view, value, Hash.FarRadius); return "ยค far radius set to " + Print(value) + " meters."; } public static string SpawnOffset(ZNetView view, float? value) { Actions.SetFloat(view, value, Hash.SpawnOffset); return "ยค spawn offset to " + Print(value) + " meters."; } public static string Destroy(ZNetView view, float? value) { Actions.SetFloat(view, value, Hash.Destroy); return "ยค timed destroy set to " + Print(value) + " seconds."; } } public class TweakAltarCommand : TweakCommand { protected override string DoOperation(ZNetView view, string operation, string? value) { return operation switch { "spawndata" => TweakActions.SpawnData(view, value), "spawn" => TweakActions.Spawn(view, Hash.Spawn, value), "spawnitem" => TweakActions.SpawnItem(view, value), "name" => TweakActions.Name(view, value), "text" => TweakActions.Text(view, value), "globalkey" => TweakActions.GlobalKey(view, value), "itemstandprefix" => TweakActions.ItemStandPrefix(view, value), "itemoffset" => TweakActions.ItemOffset(view, value), "faction" => TweakActions.Faction(view, value), "command" => TweakActions.Command(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, float? value) { return operation switch { "levelchance" => TweakActions.LevelChance(view, value), "respawn" => TweakActions.Respawn(view, Hash.Respawn, value), "spawnhealth" => TweakActions.SpawnHealth(view, value), "delay" => TweakActions.Delay(view, value), "spawnoffset" => TweakActions.SpawnOffset(view, value), "spawnradius" => TweakActions.SpawnRadius(view, value), "spawnmaxy" => TweakActions.SpawnMaxY(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, int? value) { return operation switch { "minlevel" => TweakActions.MinLevel(view, value), "maxlevel" => TweakActions.MaxLevel(view, value), "amount" => TweakActions.Amount(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, string[] value) { return operation switch { "starteffect" => TweakActions.StartEffect(view, value), "spawneffect" => TweakActions.SpawnEffect(view, value), "useeffect" => TweakActions.UseEffect(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, bool? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, long? value) { throw new NotImplementedException(); } public TweakAltarCommand() { Component = typeof(OfferingBowl); ComponentName = "altar"; SupportedOperations.Add("minlevel", typeof(int)); SupportedOperations.Add("maxlevel", typeof(int)); SupportedOperations.Add("delay", typeof(float)); SupportedOperations.Add("spawnradius", typeof(float)); SupportedOperations.Add("amount", typeof(int)); SupportedOperations.Add("spawnoffset", typeof(float)); SupportedOperations.Add("levelchance", typeof(float)); SupportedOperations.Add("spawnmaxy", typeof(float)); SupportedOperations.Add("spawn", typeof(string)); SupportedOperations.Add("spawnitem", typeof(string)); SupportedOperations.Add("starteffect", typeof(string[])); SupportedOperations.Add("useeffect", typeof(string[])); SupportedOperations.Add("spawneffect", typeof(string[])); SupportedOperations.Add("spawnhealth", typeof(float)); SupportedOperations.Add("respawn", typeof(float)); SupportedOperations.Add("name", typeof(string)); SupportedOperations.Add("text", typeof(string)); SupportedOperations.Add("itemoffset", typeof(string)); SupportedOperations.Add("itemstandprefix", typeof(string)); SupportedOperations.Add("globalkey", typeof(string)); SupportedOperations.Add("faction", typeof(string)); SupportedOperations.Add("spawndata", typeof(string)); SupportedOperations.Add("command", typeof(string)); AutoComplete.Add("minlevel", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("minlevel=number", "Minimum level (level 1 = no star). No value to reset.")); AutoComplete.Add("maxlevel", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("maxlevel=number", "Maximum level (level 1 = no star). No value to reset.")); AutoComplete.Add("amount", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("amount=number", "Amount of needed items. No value to reset.")); AutoComplete.Add("spawnmaxy", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("spawnmaxy=number", "Maximum height difference from the altar. No value to reset.")); AutoComplete.Add("delay", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("delay=seconds", "Duration of the spawning. No value to reset.")); AutoComplete.Add("spawnoffset", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("spawnoffset=meters", "Spawn distance from the ground. No value to reset.")); AutoComplete.Add("spawnradius", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("spawnradius=meters", "Maximum spawn radius. No value to reset.")); AutoComplete.Add("spawnhealth", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("spawnhealth=number", "Overrides the creature health. No value to reset.")); AutoComplete.Add("itemstandrange", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("itemstandrange=meters", "Radius for included item stands. No value to reset.")); AutoComplete.Add("text", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("text=text", "Use text. Use _ as the space. No value to reset.")); AutoComplete.Add("name", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("name=text", "Display name. Use _ as the space. No value to reset.")); AutoComplete.Add("faction", delegate(int index) { if (index == 0) { string[] names = Enum.GetNames(typeof(Faction)); List list = new List(names.Length); list.AddRange(names); return list; } return ParameterInfo.None; }); AutoComplete.Add("itemstandprefix", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("itemstandprefix=text", "Prefix for included item stands. No value to reset.")); AutoComplete.Add("globalkey", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("text=key", "Sets the global key when used. Start with - to remove the key. No value to reset.")); AutoComplete.Add("spawn", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.ObjectIds); AutoComplete.Add("spawnitem", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.ItemIds); AutoComplete.Add("respawn", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("respawn=minutes/false", "Respawn time. No value to reset.")); AutoComplete.Add("levelchance", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("levelchance=percent", "Level up chance (from 0 to 100). No value to reset.")); AutoComplete.Add("command", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("command=text", "Command to run when interacted. No value to reset.")); AutoComplete.Add("spawneffect", (int index) => TweakAutoComplete.Effect("spawneffect", index)); AutoComplete.Add("starteffect", (int index) => TweakAutoComplete.Effect("starteffect", index)); AutoComplete.Add("useeffect", (int index) => TweakAutoComplete.Effect("useeffect", index)); AutoComplete.Add("itemoffset", (int index) => ParameterInfo.XZY("itemoffset", "Offset when spawning items. Also sets the useeffect position.", index)); AutoComplete.Add("spawndata", (int index) => (index != 0) ? ParameterInfo.None : DataLoading.DataKeys); Init("tweak_altar", "Modify altars"); } } public class TweakAutoComplete { public List NamedParameters = new List(); public static List WithFilters(List parameters) { List collection = new List(11) { "id", "ignore", "radius", "center", "from", "rect", "angle", "chance", "type", "connect", "force" }; parameters.AddRange(collection); List list = new List(); list.AddRange(from s in parameters.Distinct() orderby s select s); return list; } public static Dictionary>> WithFilters(Dictionary>> fetchers) { Dictionary>> dictionary = new Dictionary>> { { "type", (int index) => ParameterInfo.Components }, { "connect", (int index) => ParameterInfo.Flag("Connect") }, { "force", (int index) => ParameterInfo.Flag("Force", "Sets the component if missing.") }, { "id", (int index) => ParameterInfo.Ids }, { "ignore", (int index) => ParameterInfo.Ids }, { "center", (int index) => ParameterInfo.XZY("center", "Overrides the player position. For rotate sets also the rotation center point.", index) }, { "from", (int index) => ParameterInfo.XZY("center", "Overrides the player position. For rotate sets also the rotation center point.", index) }, { "rect", (int index) => index switch { 0 => ParameterInfo.Create("rect=size or rect=width,depth", "Area of affected objects."), 1 => ParameterInfo.Create("rect=width,depth", "Area of affected objects."), _ => ParameterInfo.None, } }, { "angle", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("angle=degrees", "Direction of the rectangle when used with rect.") }, { "circle", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("circle=number", "Radius of affected objects.") }, { "radius", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("radius=number", "Radius of affected objects.") }, { "chance", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("chance=number", "Chance to affect the object (from 0.0 to 1.0).") } }; foreach (KeyValuePair>> fetcher in fetchers) { dictionary[fetcher.Key] = fetcher.Value; } return dictionary; } public static List Effect(string name, int index) { return index switch { 0 => ParameterInfo.Ids, 1 => ParameterInfo.Create(name + "=id,flag", "1 = random rotation"), _ => ParameterInfo.Create("For additional entries, add more " + name + "=... parameters."), }; } public static List EffectFull(string name, int index) { return index switch { 0 => ParameterInfo.Ids, 1 => ParameterInfo.Create(name + "=id,flag,variant,childTransform", "Sum up: 1 = random rotation, 2 = inherit rotation, 4 = allow scaling, 8 = inherit scale, 16 = attach to the provided object."), 2 => ParameterInfo.Create(name + "t=id,flag,variant,childTransform", "Variant number (very rarely needed)."), 3 => ParameterInfo.Create(name + "=id,flag,variant,childTransform", "Name of the transformation to attach."), _ => ParameterInfo.Create("For additional entries, add more " + name + "=... parameters."), }; } } public class TweakBeehiveCommand : TweakCommand { protected override string DoOperation(ZNetView view, string operation, string? value) { return operation switch { "spawn" => TweakActions.Spawn(view, Hash.Spawn, value), "spawnoffset" => TweakActions.SpawnOffset(view, value), "coveroffset" => TweakActions.CoverOffset(view, value), "biome" => TweakActions.Biome(view, value), "name" => TweakActions.Name(view, value), "textbiome" => TweakActions.TextBiome(view, value), "textcheck" => TweakActions.TextCheck(view, value), "textextract" => TweakActions.TextExtract(view, value), "texthappy" => TweakActions.TextHappy(view, value), "textsleep" => TweakActions.TextSleep(view, value), "textspace" => TweakActions.TextSpace(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, float? value) { if (operation == "speed") { return TweakActions.Speed(view, value); } if (operation == "maxcover") { return TweakActions.MaxCover(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, int? value) { if (operation == "maxamount") { return TweakActions.MaxAmount(view, value); } if (operation == "spawncondition") { return TweakActions.SpawnCondition(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, string[] value) { if (operation == "spawneffect") { return TweakActions.OutputEffect(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, bool? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, long? value) { throw new NotImplementedException(); } public TweakBeehiveCommand() { Component = typeof(Beehive); ComponentName = "beehive"; SupportedOperations.Add("maxamount", typeof(int)); SupportedOperations.Add("maxcover", typeof(float)); SupportedOperations.Add("spawncondition", typeof(int)); SupportedOperations.Add("spawn", typeof(string)); SupportedOperations.Add("speed", typeof(float)); SupportedOperations.Add("biome", typeof(string)); SupportedOperations.Add("name", typeof(string)); SupportedOperations.Add("textbiome", typeof(string)); SupportedOperations.Add("textcheck", typeof(string)); SupportedOperations.Add("textextract", typeof(string)); SupportedOperations.Add("texthappy", typeof(string)); SupportedOperations.Add("textsleep", typeof(string)); SupportedOperations.Add("textspace", typeof(string)); SupportedOperations.Add("spawnoffset", typeof(string)); SupportedOperations.Add("coveroffset", typeof(string)); SupportedOperations.Add("spawneffect", typeof(string[])); AutoComplete.Add("maxamount", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("maxamount=number", "Maximum amount of stored items. No value to reset.")); AutoComplete.Add("maxcover", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("maxcover=number", "Coverage limit (from 0.0 to 1.0). No value to reset.")); AutoComplete.Add("name", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("name=text", "Display name. No value to reset.")); AutoComplete.Add("textbiome", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("textbiome=text", "Text for wrong biome No value to reset.")); AutoComplete.Add("textcheck", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("textcheck=text", "Text for checking the amount. No value to reset.")); AutoComplete.Add("textextract", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("textextract=text", "Text for taking the items. No value to reset.")); AutoComplete.Add("texthappy", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("texthappy=text", "Text when being happy. No value to reset.")); AutoComplete.Add("textsleep", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("textsleep=text", "Text when sleeping. No value to reset.")); AutoComplete.Add("textspace", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("textspace=text", "Text when covered. No value to reset.")); AutoComplete.Add("spawn", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.ItemIds); AutoComplete.Add("biome", delegate { string[] names = Enum.GetNames(typeof(Biome)); List list = new List(names.Length); list.AddRange(names); return list; }); AutoComplete.Add("speed", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("speed=number", "Production speed in seconds. No value to reset.")); AutoComplete.Add("spawncondition", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("spawncondition=flag", "Sum up: 1 = produces also during the night.")); AutoComplete.Add("coveroffset", (int index) => ParameterInfo.XZY("coveroffset", "Offset for calculating cover.", index)); AutoComplete.Add("spawnoffset", (int index) => ParameterInfo.XZY("spawnoffset", "Offset for spawning items. Also sets the spawneffect position.", index)); AutoComplete.Add("spawneffect", (int index) => TweakAutoComplete.Effect("spawneffect", index)); Init("tweak_beehive", "Modify beehives"); } } public class TweakChestCommand : TweakCommand { protected override string DoOperation(ZNetView view, string operation, string? value) { if (operation == "name") { return TweakActions.Name(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, float? value) { if (operation == "respawn") { return TweakActions.Respawn(view, Hash.Respawn, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, int? value) { if (operation == "minamount") { return TweakActions.MinAmount(view, value); } if (operation == "maxamount") { return TweakActions.MaxAmount(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, string[] value) { if (operation == "item") { return TweakActions.Items(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, bool? value) { if (operation == "unlock") { return TweakActions.Unlock(view, value); } throw new NotImplementedException(); } protected override Dictionary Postprocess(ZNetView view, Dictionary operations) { if (!operations.ContainsKey("respawn") || operations.ContainsKey("item")) { return operations; } Container component = ((Component)view).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return operations; } string[] array = (from item in component.GetInventory().GetAllItems() select $"{((Object)item.m_dropPrefab).name},1,{item.m_stack}").ToArray(); Dictionary dictionary = operations.ToDictionary, string, object>((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value); dictionary["item"] = array; if (!dictionary.ContainsKey("minamount")) { dictionary["minamount"] = array.Count(); } if (!dictionary.ContainsKey("maxamount")) { dictionary["maxamount"] = array.Count(); } return dictionary; } protected override string DoOperation(ZNetView view, string operation, long? value) { throw new NotImplementedException(); } public TweakChestCommand() { Component = typeof(Container); ComponentName = "chest"; SupportedOperations.Add("name", typeof(string)); if (WorldEditCommands.IsStructureTweaks) { SupportedOperations.Add("unlock", typeof(bool)); } if (WorldEditCommands.IsSpawnerTweaks) { SupportedOperations.Add("respawn", typeof(float)); SupportedOperations.Add("minamount", typeof(int)); SupportedOperations.Add("maxamount", typeof(int)); SupportedOperations.Add("item", typeof(string[])); } AutoComplete.Add("name", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("name=text", "Display name. Use _ as the space. No value to reset.")); if (WorldEditCommands.IsStructureTweaks) { AutoComplete.Add("unlock", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("unlock=true/false", "Ignores wards. No value to toggle.")); } if (WorldEditCommands.IsSpawnerTweaks) { AutoComplete.Add("respawn", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("respawn=minutes", "Respawn time. No value to reset.")); AutoComplete.Add("minamount", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("minamount=number", "Minimum amount of items. No value to reset.")); AutoComplete.Add("maxamount", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("maxamount=number", "Maximum amount of items. No value to reset.")); AutoComplete.Add("item", (int index) => index switch { 0 => ParameterInfo.ItemIds, 1 => ParameterInfo.Create("item=id,weight,minamount,maxamount", "Chance relative to other items."), 2 => ParameterInfo.Create("item=id,weight,minamount,maxamount", "Minimum amount."), 3 => ParameterInfo.Create("item=id,weight,minamount,maxamount", "Maximum amount."), _ => ParameterInfo.Create("For additional entries, add more item=... parameters."), }); } Init("tweak_chest", "Modify chests"); } } public abstract class TweakCommand { public static Random Random = new Random(); protected Type Component = typeof(int); protected string ComponentName = ""; public bool AddComponentAutomatically = true; public Dictionary SupportedOperations = new Dictionary(); public Dictionary>> AutoComplete = new Dictionary>>(); private TweakParameters Parameters = new TweakParameters(new Dictionary()); public static bool Roll(float value) { if (value >= 1f) { return true; } return Random.NextDouble() < (double)value; } protected abstract string DoOperation(ZNetView view, string operation, string? value); protected abstract string DoOperation(ZNetView view, string operation, float? value); protected abstract string DoOperation(ZNetView view, string operation, string[] value); protected abstract string DoOperation(ZNetView view, string operation, int? value); protected abstract string DoOperation(ZNetView view, string operation, bool? value); protected abstract string DoOperation(ZNetView view, string operation, long? value); protected virtual Dictionary Postprocess(ZNetView view, Dictionary operations) { return operations; } protected virtual void Postprocess(GameObject? obj) { } protected virtual ZNetView Preprocess(Terminal context, ZNetView view) { return view; } private void Execute(Terminal context, float chance, bool force, Dictionary operations, ZNetView[] views) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) _ = ZNetScene.instance; Dictionary dictionary = new Dictionary(); views = (from view2 in views.Where(delegate(ZNetView val3) { if (!Object.op_Implicit((Object)(object)val3)) { return false; } if (!val3.GetZDO().IsValid()) { context.AddString("Skipped: " + ((Object)val3).name + " is not loaded."); return false; } if (!Roll(chance)) { context.AddString("Skipped: " + ((Object)val3).name + " (chance)."); return false; } return true; }) select Preprocess(context, view2)).Where(delegate(ZNetView val3) { if (!Object.op_Implicit((Object)(object)val3)) { return false; } if (ComponentName != "" && !Object.op_Implicit((Object)(object)((Component)val3).GetComponentInChildren(Component))) { if (force || (views.Length == 1 && AddComponentAutomatically)) { return true; } context.AddString("Skipped: " + ((Object)val3).name + " doesn't have the component. Use force to add it."); return false; } return true; }).ToArray(); UndoHelper.BeginAction(); ZNetView[] array = views; foreach (ZNetView obj in array) { ZDO zDO = obj.GetZDO(); UndoHelper.AddEditAction(zDO); dictionary.Add(zDO.m_uid, zDO.GetOwner()); obj.ClaimOwnership(); } int num2 = views.Count(); array = views; foreach (ZNetView val in array) { if (ComponentName != "" && !Object.op_Implicit((Object)(object)((Component)val).GetComponentInChildren(Component)) && (force || (views.Length == 1 && AddComponentAutomatically)) && !Object.op_Implicit((Object)(object)((Component)val).GetComponent())) { TweakActions.AddComponent(val, ComponentName); } foreach (KeyValuePair item in Postprocess(val, operations)) { Type type = SupportedOperations[item.Key]; string prefabName = Utils.GetPrefabName(((Component)val).gameObject); string text = ""; text = ((type == typeof(int)) ? DoOperation(val, item.Key, (int?)item.Value) : ((type == typeof(long)) ? DoOperation(val, item.Key, (long?)item.Value) : ((type == typeof(float)) ? DoOperation(val, item.Key, (float?)item.Value) : ((type == typeof(string[])) ? DoOperation(val, item.Key, (string[])item.Value) : ((!(type == typeof(bool))) ? DoOperation(val, item.Key, (string)item.Value) : DoOperation(val, item.Key, (bool?)item.Value)))))); if (!(text == "")) { string text2 = text.Replace("ยค", prefabName); if (num2 == 1) { Helper.AddMessage(context, text2, false); } else { context.AddString(text2); } } } } array = views; foreach (ZNetView val2 in array) { val2.GetZDO().SetOwner(dictionary[val2.GetZDO().m_uid]); } UndoHelper.EndAction(); array = views; foreach (ZNetView view in array) { Postprocess(Actions.Refresh(view)); } } protected void Init(string name, string description) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown List namedParameters = TweakAutoComplete.WithFilters(AutoComplete.Keys.ToList()); AutoComplete.Register(name, (Func>)((int index) => namedParameters), TweakAutoComplete.WithFilters(AutoComplete)); Helper.Command(name, description, (ConsoleEvent)delegate(ConsoleEventArgs args) { Parameters = new TweakParameters(SupportedOperations); Parameters.ParseCommand(args); ZNetView[] objects = Parameters.GetObjects(); Execute(args.Context, Parameters.Chance, Parameters.Force, Parameters.Operations, objects); }); } public TweakCommand() { } } public class TweakCreatureCommand : TweakCommand { protected override string DoOperation(ZNetView view, string operation, string? value) { if (operation == "name") { return TweakActions.Name(view, value); } if (operation == "faction") { return TweakActions.Faction(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, float? value) { if (operation == "health") { return TweakActions.Health(view, value); } if (operation == "damage") { return Actions.Damage(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, int? value) { if (operation == "level") { return TweakActions.Level(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, string[] value) { return operation switch { "item" => TweakActions.Items(view, value), "affix" => TweakActions.CLLC_BossEffect(view, value), "effect" => TweakActions.CLLC_Effect(view, value), "infusion" => TweakActions.CLLC_Infusion(view, value), "resistance" => TweakActions.Resistances(view, value), "attacks" => TweakActions.Attacks(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, bool? value) { return operation switch { "boss" => TweakActions.Boss(view, value), "hunt" => TweakActions.Hunt(view, value), "tame" => TweakActions.Tame(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, long? value) { throw new NotImplementedException(); } public TweakCreatureCommand() { Component = typeof(Character); ComponentName = "character"; SupportedOperations.Add("damage", typeof(float)); SupportedOperations.Add("faction", typeof(string)); SupportedOperations.Add("tame", typeof(bool)); SupportedOperations.Add("health", typeof(float)); SupportedOperations.Add("level", typeof(int)); SupportedOperations.Add("hunt", typeof(bool)); if (WorldEditCommands.IsSpawnerTweaks) { SupportedOperations.Add("boss", typeof(bool)); SupportedOperations.Add("resistance", typeof(string[])); SupportedOperations.Add("name", typeof(string)); SupportedOperations.Add("item", typeof(string[])); SupportedOperations.Add("attacks", typeof(string[])); } if (WorldEditCommands.IsCLLC) { SupportedOperations.Add("affix", typeof(string[])); SupportedOperations.Add("effect", typeof(string[])); SupportedOperations.Add("infusion", typeof(string[])); } if (WorldEditCommands.IsCLLC) { AutoComplete.Add("affix", delegate { string[] names = Enum.GetNames(typeof(Enum_CLLC_Boss)); List list = new List(names.Length); list.AddRange(names); return list; }); AutoComplete.Add("effect", delegate { string[] names = Enum.GetNames(typeof(Enum_CLLC_Effect)); List list = new List(names.Length); list.AddRange(names); return list; }); AutoComplete.Add("infusion", delegate { string[] names = Enum.GetNames(typeof(Enum_CLLC_Infusion)); List list = new List(names.Length); list.AddRange(names); return list; }); } AutoComplete.Add("name", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("name=text", "Display name. Use _ as the space. No value to reset.")); AutoComplete.Add("faction", delegate(int index) { if (index == 0) { string[] names = Enum.GetNames(typeof(Faction)); List list = new List(names.Length); list.AddRange(names); return list; } return ParameterInfo.None; }); AutoComplete.Add("boss", (int index) => ParameterInfo.Create("boss=true/false ", "Sets the boss health bar. No value to reset.")); AutoComplete.Add("tame", (int index) => ParameterInfo.Create("tame=true/false ", "Sets the tamed status. No value to toggle.")); AutoComplete.Add("hunt", (int index) => ParameterInfo.Create("hunt=true/false", "Sets the extra aggressiveness. No value to toggle.")); AutoComplete.Add("level", (int index) => ParameterInfo.Create("level=number", "Sets the level (level 1 = 0 star)")); AutoComplete.Add("health", (int index) => ParameterInfo.Create("health=number", "Sets the health.")); AutoComplete.Add("damage", (int index) => ParameterInfo.Create("damage=number", "Sets the damage multiplier.")); AutoComplete.Add("resistance", delegate(int index) { switch (index) { case 0: { string[] names = Enum.GetNames(typeof(DamageType)); List list2 = new List(names.Length); list2.AddRange(names); return list2; } case 1: { string[] names = Enum.GetNames(typeof(DamageModifier)); List list = new List(names.Length); list.AddRange(names); return list; } default: return ParameterInfo.Create("For additional entries, add more resistance=... parameters."); } }); AutoComplete.Add("item", (int index) => index switch { 0 => ParameterInfo.ItemIds, 1 => ParameterInfo.Create("item=id,chance,minamount,maxamount,flag", "Drop chance."), 2 => ParameterInfo.Create("item=id,chance,minamount,maxamount,flag", "Minimum amount."), 3 => ParameterInfo.Create("item=id,chance,minamount,maxamount,flag", "Maximum amount."), 4 => ParameterInfo.Create("item=id,chance,minamount,maxamount,flag", "Sum up: 1 = star multiplier, 2 = one per player."), _ => ParameterInfo.Create("For additional entries, add more item=... parameters."), }); AutoComplete.Add("attacks", (int index) => ParameterInfo.ItemIds); Init("tweak_creature", "Modify creatures"); } } public class TweakDoorCommand : TweakCommand { protected override string DoOperation(ZNetView view, string operation, string? value) { if (operation == "key") { return TweakActions.DoorKey(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, float? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, int? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, string[] value) { return operation switch { "openeffect" => TweakActions.OpenEffect(view, value), "closeeffect" => TweakActions.CloseEffect(view, value), "lockedeffect" => TweakActions.LockedEffect(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, bool? value) { return operation switch { "unlock" => TweakActions.Unlock(view, value), "consume" => TweakActions.Consume(view, value), "noclose" => TweakActions.NoClose(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, long? value) { throw new NotImplementedException(); } public TweakDoorCommand() { Component = typeof(Door); ComponentName = "door"; SupportedOperations.Add("unlock", typeof(bool)); SupportedOperations.Add("consume", typeof(bool)); SupportedOperations.Add("noclose", typeof(bool)); SupportedOperations.Add("key", typeof(string)); SupportedOperations.Add("openeffect", typeof(string[])); SupportedOperations.Add("closeeffect", typeof(string[])); SupportedOperations.Add("lockedeffect", typeof(string[])); AutoComplete.Add("unlock", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("unlock=true/false", "Ignores wards. No value to toggle.")); AutoComplete.Add("consume", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("consume=true/false", "Usage consumes the key. No value to toggle.")); AutoComplete.Add("noclose", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("noclose=true/false", "Door can't be closed. No value to toggle.")); AutoComplete.Add("key", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.ItemIds); AutoComplete.Add("openeffect", (int index) => TweakAutoComplete.Effect("openeffect", index)); AutoComplete.Add("closeeffect", (int index) => TweakAutoComplete.Effect("closeeffect", index)); AutoComplete.Add("lockedeffect", (int index) => TweakAutoComplete.Effect("lockedeffect", index)); Init("tweak_door", "Modify doors"); } } public class TweakDungeonCommand : TweakCommand { protected override string DoOperation(ZNetView view, string operation, string? value) { return operation switch { "enter_text" => TweakActions.EnterText(view, value), "enter_hover" => TweakActions.EnterHover(view, value), "exit_text" => TweakActions.ExitText(view, value), "exit_hover" => TweakActions.ExitHover(view, value), "weather" => TweakActions.Weather(view, Hash.DungeonWeather, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, float? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, int? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, string[] value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, bool? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, long? value) { throw new NotImplementedException(); } protected override ZNetView Preprocess(Terminal context, ZNetView view) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)((Component)view).GetComponent())) { return view; } if (Object.op_Implicit((Object)(object)((Component)view).GetComponent())) { Vector2i zone = ZoneSystem.GetZone(((Component)view).transform.position); Location val = ((IEnumerable)Location.s_allLocations).FirstOrDefault((Func)((Location l) => ZoneSystem.GetZone(((Component)l).transform.position) == zone)); if (Object.op_Implicit((Object)(object)val)) { return ((Component)val).GetComponentInParent(); } } context.AddString("Skipped: " + ((Object)view).name + " is not a location."); return null; } public TweakDungeonCommand() { SupportedOperations.Add("enter_text", typeof(string)); SupportedOperations.Add("enter_hover", typeof(string)); SupportedOperations.Add("exit_text", typeof(string)); SupportedOperations.Add("exit_hover", typeof(string)); SupportedOperations.Add("weather", typeof(string)); AutoComplete.Add("enter_text", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("enter_text=text", "Text when entering the dungeon.")); AutoComplete.Add("enter_hover", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("enter_hover=text", "Text when entering the dungeon.")); AutoComplete.Add("exit_text", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("exit_text=text", "Text when entering the dungeon.")); AutoComplete.Add("exit_hover", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("exit_hover=text", "Text when entering the dungeon.")); AutoComplete.Add("weather", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Environments); Init("tweak_dungeon", "Modify dungeons"); } } public class TweakFermenterCommand : TweakCommand { protected override string DoOperation(ZNetView view, string operation, string? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, float? value) { if (operation == "speed") { return TweakActions.Speed(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, int? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, string[] value) { return operation switch { "conversion" => TweakActions.Conversions(view, value), "inputeffect" => TweakActions.InputEffect(view, value), "useeffect" => TweakActions.UseEffect(view, value), "outputeffect" => TweakActions.OutputEffect(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, bool? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, long? value) { throw new NotImplementedException(); } public TweakFermenterCommand() { AddComponentAutomatically = false; Component = typeof(Fermenter); ComponentName = "fermenter"; SupportedOperations.Add("speed", typeof(float)); SupportedOperations.Add("conversion", typeof(string[])); SupportedOperations.Add("inputeffect", typeof(string[])); SupportedOperations.Add("useeffect", typeof(string[])); SupportedOperations.Add("outputeffect", typeof(string[])); AutoComplete.Add("speed", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("speed=number", "Conversion speed in seconds. No value to reset.")); AutoComplete.Add("conversion", (int index) => index switch { 0 => ParameterInfo.ItemIds, 1 => ParameterInfo.ItemIds, 2 => ParameterInfo.Create("conversion=from,to,amount", "Amount of output."), _ => ParameterInfo.Create("For additional entries, add more conversion=... parameters."), }); AutoComplete.Add("inputeffect", (int index) => TweakAutoComplete.Effect("inputeffect", index)); AutoComplete.Add("useeffect", (int index) => TweakAutoComplete.Effect("useeffect", index)); AutoComplete.Add("outputeffect", (int index) => TweakAutoComplete.Effect("outputeffect", index)); Init("tweak_fermenter", "Modify fermenters"); } } public class TweakFireplaceCommand : TweakCommand { public static List SmokeTypes = new List(3) { "off", "on", "ignore" }; protected override string DoOperation(ZNetView view, string operation, string? value) { if (operation == "smoke") { return TweakActions.Smoke(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, float? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, int? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, string[] value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, bool? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, long? value) { throw new NotImplementedException(); } public TweakFireplaceCommand() { Component = typeof(Fireplace); ComponentName = "fireplace"; SupportedOperations.Add("smoke", typeof(string)); AutoComplete.Add("smoke", (int index) => (index != 0) ? ParameterInfo.None : SmokeTypes); Init("tweak_fireplace", "Modify fireplaces"); } } public class TweakItemStandCommand : TweakCommand { protected override string DoOperation(ZNetView view, string operation, string? value) { if (operation == "item") { return TweakActions.Item(view, value); } if (operation == "name") { return TweakActions.Name(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, float? value) { if (operation == "respawn") { return TweakActions.Respawn(view, Hash.Respawn, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, int? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, string[] value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, bool? value) { throw new NotImplementedException(); } protected override Dictionary Postprocess(ZNetView view, Dictionary operations) { if (!operations.ContainsKey("respawn") || operations.ContainsKey("item")) { return operations; } ItemStand component = ((Component)view).GetComponent(); if (!Object.op_Implicit((Object)(object)component)) { return operations; } string value = component.m_visualName + "," + component.m_visualVariant; Dictionary dictionary = operations.ToDictionary, string, object>((KeyValuePair kvp) => kvp.Key, (KeyValuePair kvp) => kvp.Value); dictionary["item"] = value; return dictionary; } protected override string DoOperation(ZNetView view, string operation, long? value) { throw new NotImplementedException(); } public TweakItemStandCommand() { Component = typeof(ItemStand); ComponentName = "itemstand"; SupportedOperations.Add("respawn", typeof(float)); SupportedOperations.Add("name", typeof(string)); SupportedOperations.Add("item", typeof(string)); AutoComplete.Add("name", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("name=text", "Display name. Use _ as the space. No value to reset.")); AutoComplete.Add("respawn", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("respawn=minutes", "Respawn time. No value to reset.")); AutoComplete.Add("item", (int index) => index switch { 0 => ParameterInfo.ItemIds, 1 => ParameterInfo.Create("item=id,variant", "Item variant (number)."), _ => ParameterInfo.None, }); Init("tweak_itemstand", "Modify item stands"); } } public class TweakObjectCommand : TweakCommand { public static List Wears = new List(4) { "default", "broken", "damaged", "healthy" }; public static List Growths = new List(5) { "big", "big_bad", "default", "small", "small_bad" }; public static List Smokes = new List(3) { "off", "on", "ignore" }; public static List FallTypes = new List(3) { "off", "solid", "terrain" }; public static List Waters = new List(2) { "cave", "crypt" }; public static List Components = new List(10) { "altar", "beehive", "chest", "fermenter", "itemstand", "pickable", "runestone", "smelter", "spawner", "spawnpoint" }; protected override string DoOperation(ZNetView view, string operation, string? value) { return operation switch { "wear" => TweakActions.Wear(view, value), "growth" => TweakActions.Growth(view, value), "component" => TweakActions.Component(view, value), "status" => TweakActions.Status(view, value), "event" => TweakActions.Event(view, value), "effect" => TweakActions.Effect(view, value), "weather" => TweakActions.Weather(view, Hash.Weather, value), "water" => TweakActions.Water(view, value), "fall" => TweakActions.Fall(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, float? value) { if (operation == "destroy") { return TweakActions.Destroy(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, int? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, string[] value) { if (operation == "destroyeffect") { return TweakActions.DestroyEffect(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, bool? value) { return operation switch { "show" => TweakActions.Render(view, value), "interact" => TweakActions.Interact(view, value), "collision" => TweakActions.Collision(view, value), "restrict" => TweakActions.Restrict(view, value), "unlock" => TweakActions.Unlock(view, value), _ => throw new NotImplementedException(), }; } protected override void Postprocess(GameObject? obj) { //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) StaticPhysics val = default(StaticPhysics); if (Object.op_Implicit((Object)(object)obj) && obj.TryGetComponent(ref val)) { val.m_updateTime = Time.time - 30f; ((SlowUpdate)val).SUpdate(Time.time, ZoneSystem.GetZone(obj.transform.position)); } } protected override string DoOperation(ZNetView view, string operation, long? value) { if (operation == "creator") { return TweakActions.Creator(view, value); } throw new NotImplementedException(); } public TweakObjectCommand() { SupportedOperations.Add("component", typeof(string)); SupportedOperations.Add("status", typeof(string)); SupportedOperations.Add("effect", typeof(string)); SupportedOperations.Add("weather", typeof(string)); SupportedOperations.Add("event", typeof(string)); SupportedOperations.Add("collision", typeof(bool)); SupportedOperations.Add("show", typeof(bool)); SupportedOperations.Add("interact", typeof(bool)); SupportedOperations.Add("fall", typeof(string)); SupportedOperations.Add("wear", typeof(string)); SupportedOperations.Add("growth", typeof(string)); SupportedOperations.Add("water", typeof(string)); SupportedOperations.Add("creator", typeof(long)); SupportedOperations.Add("destroy", typeof(float)); SupportedOperations.Add("destroyeffect", typeof(string[])); AutoComplete.Add("component", (int index) => Components); AutoComplete.Add("status", (int index) => index switch { 1 => ParameterInfo.StatusEffects, 0 => ParameterInfo.Create("status=radius,id,playeronly", "Adds status area."), _ => ParameterInfo.None, }); AutoComplete.Add("effect", (int index) => (index != 0) ? ParameterInfo.EffectAreas : ParameterInfo.Create("effect=radius,id,playeronly", "Adds effect area.")); AutoComplete.Add("weather", (int index) => index switch { 2 => ParameterInfo.Create("weather=radius,id,instant,dungeon", "If given, the weather is changed instantly."), 1 => ParameterInfo.Environments, 0 => ParameterInfo.Create("weather=radius,id,instant,dungeon", "Adds weather area."), _ => ParameterInfo.None, }); AutoComplete.Add("event", (int index) => index switch { 1 => ParameterInfo.Events, 0 => ParameterInfo.Create("event=radius,id", "Adds event area."), _ => ParameterInfo.None, }); AutoComplete.Add("collision", (int index) => ParameterInfo.Create("collision=true/false or no value to toggle.", "Sets object collision.")); AutoComplete.Add("fall", (int index) => (index != 0) ? ParameterInfo.None : FallTypes); AutoComplete.Add("show", (int index) => ParameterInfo.Create("show=true/false or no value to toggle.", "Sets object visibility.")); AutoComplete.Add("interact", (int index) => ParameterInfo.Create("interact=true/false or no value to toggle.", "Sets object interactability.")); AutoComplete.Add("wear", (int index) => (index != 0) ? ParameterInfo.None : Wears); AutoComplete.Add("growth", (int index) => (index != 0) ? ParameterInfo.None : Growths); AutoComplete.Add("water", (int index) => (index != 0) ? ParameterInfo.XZY("water", "Scale", index - 1) : Waters); AutoComplete.Add("creator", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("creator=player ID", "Sets creator of objects (0 for no creator).")); AutoComplete.Add("destroy", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("destroy=seconds", "Timed destruction after seconds.")); AutoComplete.Add("destroyeffect", (int index) => TweakAutoComplete.Effect("destroyeffect", index)); Init("tweak_object", "Modify objects"); } } public class TweakParameters : BaseParameters { public long Creator; public bool Force; public TweakParameters(Dictionary supportedOperations) : base(supportedOperations) { } protected override void ParseArg(string arg) { if (arg == "force") { Force = true; } } protected override void ParseArg(string arg, string value) { if (arg == "creator") { Creator = Parse.Long(value, 0L); } } } public class TweakPickableCommand : TweakCommand { protected override string DoOperation(ZNetView view, string operation, string? value) { if (operation == "spawn") { return TweakActions.Spawn(view, Hash.SpawnPickable, value); } if (operation == "name") { return TweakActions.Name(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, float? value) { if (operation == "respawn") { return TweakActions.Respawn(view, Hash.RespawnPickable, value); } if (operation == "spawnoffset") { return TweakActions.SpawnOffset(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, int? value) { if (operation == "amount") { return TweakActions.Amount(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, string[] value) { if (operation == "useeffect") { return TweakActions.UseEffect(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, bool? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, long? value) { throw new NotImplementedException(); } public TweakPickableCommand() { Component = typeof(Pickable); ComponentName = "pickable"; SupportedOperations.Add("amount", typeof(int)); SupportedOperations.Add("respawn", typeof(float)); SupportedOperations.Add("spawnoffset", typeof(float)); SupportedOperations.Add("spawn", typeof(string)); SupportedOperations.Add("useeffect", typeof(string[])); SupportedOperations.Add("name", typeof(string)); AutoComplete.Add("amount", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("amount=number", "Amount of dropped items. No value to reset.")); AutoComplete.Add("respawn", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("respawn=minutes", "Respawn time. No value to reset.")); AutoComplete.Add("spawnoffset", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("spawnoffset=meters", "Spawn distance from the ground.. No value to reset.")); AutoComplete.Add("name", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("name=text", "Display name. Use _ as the space. No value to reset.")); AutoComplete.Add("spawn", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.ObjectIds); AutoComplete.Add("useeffect", (int index) => TweakAutoComplete.Effect("useeffect", index)); Init("tweak_pickable", "Modify pickables"); } } public class TweakPortalCommand : TweakCommand { protected override string DoOperation(ZNetView view, string operation, string? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, float? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, int? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, string[] value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, bool? value) { if (operation == "restrict") { return TweakActions.Restrict(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, long? value) { throw new NotImplementedException(); } public TweakPortalCommand() { Component = typeof(TeleportWorld); ComponentName = "portal"; SupportedOperations.Add("restrict", typeof(bool)); AutoComplete.Add("restrict", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("restrict=false", "Allows teleporting with any items. No value to reset.")); Init("tweak_portal", "Modify portals"); } } public class TweakRunestoneCommand : TweakCommand { protected override string DoOperation(ZNetView view, string operation, string? value) { return operation switch { "text" => TweakActions.Text(view, value), "name" => TweakActions.Name(view, value), "topic" => TweakActions.Topic(view, value), "discover" => TweakActions.Discover(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, float? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, int? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, string[] value) { if (operation == "compendium") { return TweakActions.Compendium(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, bool? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, long? value) { throw new NotImplementedException(); } public TweakRunestoneCommand() { Component = typeof(RuneStone); ComponentName = "runestone"; SupportedOperations.Add("name", typeof(string)); SupportedOperations.Add("text", typeof(string)); SupportedOperations.Add("compendium", typeof(string[])); SupportedOperations.Add("topic", typeof(string)); SupportedOperations.Add("discover", typeof(string)); AutoComplete.Add("name", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("name=text", "Display name. Use _ as the space. No value to reset.")); AutoComplete.Add("text", (int index) => ParameterInfo.Create("text=text", "Shown text. Use _ as the space. No value to reset.")); AutoComplete.Add("compendium", (int index) => ParameterInfo.Create("compendium=text", "Entry in the compendium. Use _ as the space. No value to reset. Add new parameter for more entries.")); AutoComplete.Add("topic", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("topic=text", "Show text topic. Use _ as the space. No value to reset.")); AutoComplete.Add("discover", delegate(int index) { switch (index) { case 0: return ParameterInfo.LocationIds; case 1: return ParameterInfo.Create("discover=id,pinName,pinType,openMap", "Pin name on the map."); case 2: { string[] names = Enum.GetNames(typeof(PinType)); List list = new List(names.Length); list.AddRange(names); return list; } case 3: return ParameterInfo.Create("discover=id,pinName,pinType,openMap", "1 = automatically open the map."); default: return ParameterInfo.None; } }); Init("tweak_runestone", "Modify runestones"); } } public class TweakSmelterCommand : TweakCommand { protected override string DoOperation(ZNetView view, string operation, string? value) { if (operation == "fuel") { return TweakActions.Fuel(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, float? value) { if (operation == "speed") { return TweakActions.Speed(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, int? value) { return operation switch { "maxamount" => TweakActions.MaxAmount(view, value), "maxfuel" => TweakActions.MaxFuel(view, value), "fuelusage" => TweakActions.FuelUsage(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, string[] value) { return operation switch { "conversion" => TweakActions.Conversions(view, value), "inputeffect" => TweakActions.InputEffect(view, value), "fueleffect" => TweakActions.FuelEffect(view, value), "outputeffect" => TweakActions.OutputEffect(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, bool? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, long? value) { throw new NotImplementedException(); } public TweakSmelterCommand() { AddComponentAutomatically = false; Component = typeof(Smelter); ComponentName = "smelter"; SupportedOperations.Add("maxamount", typeof(int)); SupportedOperations.Add("maxfuel", typeof(int)); SupportedOperations.Add("fuel", typeof(string)); SupportedOperations.Add("fuelusage", typeof(int)); SupportedOperations.Add("speed", typeof(float)); SupportedOperations.Add("conversion", typeof(string[])); SupportedOperations.Add("inputeffect", typeof(string[])); SupportedOperations.Add("fueleffect", typeof(string[])); SupportedOperations.Add("outputeffect", typeof(string[])); AutoComplete.Add("maxamount", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("maxamount=number", "Maximum amount of queued items. No value to reset.")); AutoComplete.Add("maxfuel", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("maxfuel=number", "Maximum amount of fuel. No value to reset.")); AutoComplete.Add("fuelusage", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("fuelusage=number", "Required fuel per conversion. No value to reset.")); AutoComplete.Add("speed", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("speed=number", "Conversion speed in seconds. No value to reset.")); AutoComplete.Add("fuel", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.ItemIds); AutoComplete.Add("conversion", (int index) => index switch { 0 => ParameterInfo.ItemIds, 1 => ParameterInfo.ItemIds, _ => ParameterInfo.Create("For additional entries, add more conversion=... parameters."), }); AutoComplete.Add("inputeffect", (int index) => TweakAutoComplete.Effect("inputeffect", index)); AutoComplete.Add("fueleffect", (int index) => TweakAutoComplete.Effect("fueleffect", index)); AutoComplete.Add("outputeffect", (int index) => TweakAutoComplete.Effect("outputeffect", index)); Init("tweak_smelter", "Modify smelters"); } } public class TweakSpawnerCommand : TweakCommand { protected override string DoOperation(ZNetView view, string operation, string? value) { if (operation == "globalkey") { return TweakActions.GlobalKey(view, value); } if (operation == "faction") { return TweakActions.Faction(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, float? value) { return operation switch { "spawnhealth" => TweakActions.SpawnHealth(view, value), "levelchance" => TweakActions.LevelChance(view, value), "spawnradius" => TweakActions.SpawnRadius(view, value), "nearradius" => TweakActions.NearRadius(view, value), "farradius" => TweakActions.FarRadius(view, value), "triggerdistance" => TweakActions.TriggerDistance(view, value), "respawn" => TweakActions.RespawnSeconds(view, Hash.RespawnSpawnArea, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, int? value) { return operation switch { "minlevel" => TweakActions.MinLevel(view, value), "maxlevel" => TweakActions.MaxLevel(view, value), "maxnear" => TweakActions.MaxNear(view, value), "maxtotal" => TweakActions.MaxTotal(view, value), "spawncondition" => TweakActions.SpawnCondition(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, string[] value) { if (operation == "spawn") { return TweakActions.Spawns(view, value); } if (operation == "spawneffect") { return TweakActions.SpawnEffect(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, bool? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, long? value) { throw new NotImplementedException(); } public TweakSpawnerCommand() { Component = typeof(SpawnArea); ComponentName = "spawner"; SupportedOperations.Add("globalkey", typeof(string)); SupportedOperations.Add("maxnear", typeof(int)); SupportedOperations.Add("maxtotal", typeof(int)); SupportedOperations.Add("minlevel", typeof(int)); SupportedOperations.Add("maxlevel", typeof(int)); SupportedOperations.Add("spawncondition", typeof(int)); SupportedOperations.Add("triggerdistance", typeof(float)); SupportedOperations.Add("respawn", typeof(float)); SupportedOperations.Add("spawnhealth", typeof(float)); SupportedOperations.Add("levelchance", typeof(float)); SupportedOperations.Add("spawnradius", typeof(float)); SupportedOperations.Add("nearradius", typeof(float)); SupportedOperations.Add("farradius", typeof(float)); SupportedOperations.Add("spawn", typeof(string[])); SupportedOperations.Add("spawneffect", typeof(string[])); SupportedOperations.Add("faction", typeof(string)); AutoComplete.Add("minlevel", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("minlevel=number", "Minimum level (level 1 = no star). No value to reset.")); AutoComplete.Add("maxlevel", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("maxlevel=number", "Maximum level (level 1 = no star). No value to reset.")); AutoComplete.Add("globalkey", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("text=key", "Required global keys to work. Start with - to remove the key. No value to reset.")); AutoComplete.Add("maxnear", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("maxnear=number", "Maximum amount of spawns within the nearradius. No value to reset.")); AutoComplete.Add("maxtotal", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("maxtotal=number", "Maximum amount of spawns within the farradius. No value to reset.")); AutoComplete.Add("spawncondition", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("spawncondition=flag", "Sum up: 1 = day only, 2 = night only, 4 = ground only.")); AutoComplete.Add("spawnhealth", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("spawnhealth=number", "Overrides the creature health. No value to reset.")); AutoComplete.Add("respawn", (int index) => ParameterInfo.Create("respawn=seconds", "Sets the respawn time. No value to reset.")); AutoComplete.Add("levelchance", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("levelchance=percent", "Level up chance (from 0 to 100). No value to reset.")); AutoComplete.Add("faction", delegate(int index) { if (index == 0) { string[] names = Enum.GetNames(typeof(Faction)); List list = new List(names.Length); list.AddRange(names); return list; } return ParameterInfo.None; }); AutoComplete.Add("triggerdistance", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("triggerdistance=meters", "Player distance to activate the spawner. No value to reset.")); AutoComplete.Add("spawnradius", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("spawnradius=meters", "Maximum spawn radius. No value to reset.")); AutoComplete.Add("nearradius", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("nearradius=meters", "Radius for maxnear. No value to reset.")); AutoComplete.Add("farradius", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("farradius=meters", "Radius for maxtotal. No value to reset.")); AutoComplete.Add("spawn", (int index) => index switch { 0 => ParameterInfo.Ids, 1 => ParameterInfo.Create("spawn=id,weight,minlevel,maxlevel,health/data", "Spawn chance relative to other spawns."), 2 => ParameterInfo.Create("spawn=id,weight,minlevel,maxlevel,health/data", "Minimum level (level 1 = 0 star)."), 3 => ParameterInfo.Create("spawn=id,weight,minlevel,maxlevel,health/data", "Maximum level (level 1 = 0 star)."), 4 => DataLoading.DataKeys, _ => ParameterInfo.Create("For additional entries, add more spawn=... parameters."), }); AutoComplete.Add("spawneffect", (int index) => TweakAutoComplete.Effect("spawneffect", index)); Init("tweak_spawner", "Modify spawners"); } } public class TweakSpawnPointCommand : TweakCommand { protected override string DoOperation(ZNetView view, string operation, string? value) { return operation switch { "spawndata" => TweakActions.SpawnData(view, value), "spawn" => TweakActions.Spawn(view, Hash.Spawn, value), "faction" => TweakActions.Faction(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, float? value) { return operation switch { "levelchance" => TweakActions.LevelChance(view, value), "respawn" => TweakActions.Respawn(view, Hash.Respawn, value), "spawnhealth" => TweakActions.SpawnHealth(view, value), "triggerdistance" => TweakActions.TriggerDistance(view, value), "triggernoise" => TweakActions.TriggerNoise(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, int? value) { return operation switch { "minlevel" => TweakActions.MinLevel(view, value), "maxlevel" => TweakActions.MaxLevel(view, value), "spawncondition" => TweakActions.SpawnCondition(view, value), _ => throw new NotImplementedException(), }; } protected override string DoOperation(ZNetView view, string operation, string[] value) { if (operation == "spawneffect") { return TweakActions.SpawnEffect(view, value); } throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, bool? value) { throw new NotImplementedException(); } protected override string DoOperation(ZNetView view, string operation, long? value) { throw new NotImplementedException(); } public TweakSpawnPointCommand() { Component = typeof(CreatureSpawner); ComponentName = "spawnpoint"; SupportedOperations.Add("minlevel", typeof(int)); SupportedOperations.Add("maxlevel", typeof(int)); SupportedOperations.Add("spawncondition", typeof(int)); SupportedOperations.Add("levelchance", typeof(float)); SupportedOperations.Add("triggerdistance", typeof(float)); SupportedOperations.Add("respawn", typeof(float)); SupportedOperations.Add("spawnhealth", typeof(float)); SupportedOperations.Add("spawn", typeof(string)); SupportedOperations.Add("spawneffect", typeof(string[])); SupportedOperations.Add("faction", typeof(string)); SupportedOperations.Add("spawndata", typeof(string)); AutoComplete.Add("faction", delegate(int index) { if (index == 0) { string[] names = Enum.GetNames(typeof(Faction)); List list = new List(names.Length); list.AddRange(names); return list; } return ParameterInfo.None; }); AutoComplete.Add("minlevel", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("minlevel=number", "Minimum level (level 1 = no star). No value to reset.")); AutoComplete.Add("maxlevel", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("maxlevel=number", "Maximum level (level 1 = no star). No value to reset.")); AutoComplete.Add("triggernoise", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("triggernoise=meters", "Required noise to activate the spawn point. No value to reset.")); AutoComplete.Add("triggerdistance", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("triggerdistance=meters", "Required distance to activate the spawn point. No value to reset.")); AutoComplete.Add("spawncondition", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("spawncondition=flag", "1 = day only, 2 = night only.")); AutoComplete.Add("respawn", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("respawn=minutes/false", "Respawn time. No value to reset.")); AutoComplete.Add("levelchance", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("levelchance=percent", "Level up chance (from 0 to 100). No value to reset.")); AutoComplete.Add("spawnhealth", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.Create("spawnhealth=number", "Overrides the creature health. No value to reset.")); AutoComplete.Add("spawn", (int index) => (index != 0) ? ParameterInfo.None : ParameterInfo.ObjectIds); AutoComplete.Add("spawneffect", (int index) => TweakAutoComplete.Effect("spawneffect", index)); AutoComplete.Add("spawndata", (int index) => (index != 0) ? ParameterInfo.None : DataLoading.DataKeys); Init("tweak_spawnpoint", "Modify spawn points"); } } public class UndoHelper { private static readonly Dictionary EditedInfo = new Dictionary(); private static readonly List RemovedInfo = new List(); private static readonly List SpawnedInfo = new List(); private static int SubStack = 0; private static readonly Dictionary Regenerated = new Dictionary(); public static void BeginAction() { SubStack = 0; AddedZDOs.Track = true; EditedInfo.Clear(); RemovedInfo.Clear(); SpawnedInfo.Clear(); } public static List GetSpawned() { return SpawnedInfo; } public static void BeginSubAction() { if (SubStack == 0) { BeginAction(); } SubStack++; } public static void EndSubAction() { SubStack--; if (SubStack == 0) { EndAction(); } } public static void AddRemoveAction(ZDO zdo) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) RemovedInfo.Add(new RemoveData(zdo)); EditedInfo.Remove(zdo.m_uid); } public static void AddSpawnAction(ZDO zdo) { SpawnedInfo.Add(zdo); } public static void AddEditAction(ZNetView view) { AddEditAction(view.GetZDO()); } public static void AddEditAction(ZDO zdo) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) if (zdo.GetPrefab() != Hash.Player && !EditedInfo.ContainsKey(zdo.m_uid)) { EditedInfo[zdo.m_uid] = new EditData(zdo); } } public static void RefreshEditAction(ZDOID original, ZDO zdo) { //IL_0005: 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_0029: Unknown result type (might be due to invalid IL or missing references) EditData editData = EditedInfo[original]; editData.Original = zdo; EditedInfo[zdo.m_uid] = editData; EditedInfo.Remove(original); } public static void EndAction() { SubStack = 0; AddedZDOs.Track = false; if (EditedInfo.Count == 0 && RemovedInfo.Count == 0 && SpawnedInfo.Count == 0) { return; } foreach (EditData value in EditedInfo.Values) { value.Update(); } List list = new List(); list.AddRange(EditedInfo.Values); list.AddRange(RemovedInfo); list.AddRange(from s in SpawnedInfo where s != null && s.IsValid() select new SpawnData(s)); UndoData[] array = list.ToArray(); if (array.Length != 0) { UndoManager.Add((IUndoAction)(object)new UndoAction(array)); } } public static void Place(FakeZDO zdo) { //IL_0034: 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_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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) GameObject prefab = ZNetScene.instance.GetPrefab(zdo.Prefab); if (!Object.op_Implicit((Object)(object)prefab)) { throw new InvalidOperationException("Error: Prefab not found."); } ZNetView.m_initZDO = zdo.Create(); Regenerated[zdo.Id] = ZNetView.m_initZDO.m_uid; zdo.Id = ZNetView.m_initZDO.m_uid; Object.Instantiate(prefab, ZNetView.m_initZDO.GetPosition(), ZNetView.m_initZDO.GetRotation()); } public static void Destroy(FakeZDO zdo) { //IL_001e: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) while (Regenerated.ContainsKey(zdo.Id)) { zdo.Id = Regenerated[zdo.Id]; } zdo.Destroy(); } public static string Name(int hash) { return Utils.GetPrefabName(ZNetScene.instance.GetPrefab(hash)); } public static string Print(IEnumerable zdos) { return Print(zdos.Select((FakeZDO zdo) => zdo.Prefab)); } public static string Print(IEnumerable data) { if (data.Count() == 1) { return Name(data.First()); } IEnumerable> source = data.GroupBy(Name); if (source.Count() == 1) { return $"{source.First().Key} {source.First().Count()}x"; } return $" objects {data.Count()}x"; } } public class EditData : UndoData { public FakeZDO Previous; public ZDO Original; public EditData(ZDO zdo) : base(new FakeZDO(zdo)) { Original = zdo; Previous = Current; } public void Update() { Current = new FakeZDO(Original); } public override void Undo() { UndoHelper.Destroy(Current); UndoHelper.Place(Previous); } public override void Redo() { UndoHelper.Destroy(Previous); UndoHelper.Place(Current); } } public class RemoveData : UndoData { public RemoveData(ZDO zdo) : base(new FakeZDO(zdo)) { } public override void Undo() { UndoHelper.Place(Current); } public override void Redo() { UndoHelper.Destroy(Current); } } public class SpawnData : UndoData { public SpawnData(ZDO zdo) : base(new FakeZDO(zdo)) { } public override void Undo() { UndoHelper.Destroy(Current); } public override void Redo() { UndoHelper.Place(Current); } } public abstract class UndoData(FakeZDO zdo) { public FakeZDO Current = zdo; public abstract void Undo(); public abstract void Redo(); } public class UndoAction : MonoBehaviour, IUndoAction { public readonly UndoData[] Data = data.ToArray(); public UndoAction(IEnumerable data) { } public string Undo() { string result = "Changed " + UndoHelper.Print(Data.Select((UndoData undoData) => undoData.zdo)); UndoData[] data = Data; for (int num = 0; num < data.Length; num++) { data[num].Undo(); } return result; } public string Redo() { string result = "Changed " + UndoHelper.Print(Data.Select((UndoData undoData) => undoData.zdo)); UndoData[] data = Data; for (int num = 0; num < data.Length; num++) { data[num].Redo(); } return result; } } [HarmonyPatch(typeof(ZNetView), "Awake")] public class AddedZDOs { public static bool Track; public static void Postfix(ZNetView __instance) { if (Track) { UndoHelper.AddSpawnAction(__instance.GetZDO()); } } } public class HeightUndoData { public float Smooth; public float Level; public int Index = -1; public bool HeightModified; } public class PaintUndoData { public bool PaintModified; public Color Paint = Color.black; public int Index = -1; } public class TerrainUndoData { public List Heights = new List(); public List Paints = new List(); } public class UndoTerrain : IUndoAction { private readonly Dictionary Before = new Dictionary(); private readonly Dictionary After = new Dictionary(); public Vector3 Position; public float Radius; public UndoTerrain(Dictionary before, Dictionary after, Vector3 position, float radius) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) Before = before; After = after; Position = position; Radius = radius; } public string Undo() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Terrain.ApplyData(Before, Position, Radius); return "Undoing terrain changes"; } public string Redo() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Terrain.ApplyData(After, Position, Radius); return "Redoing terrain changes"; } } [BepInPlugin("world_edit_commands", "World Edit Commands", "1.72")] [BepInDependency("server_devcommands", "1.100")] public class WorldEditCommands : BaseUnityPlugin { public const string GUID = "world_edit_commands"; public const string NAME = "World Edit Commands"; public const string VERSION = "1.72"; public static bool IsSpawnerTweaks; public static bool IsStructureTweaks; public static bool IsCLLC; public static bool IsTweaks; public static bool IsEWFactions; public void Awake() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) new Harmony("world_edit_commands").PatchAll(); } public void Start() { IsSpawnerTweaks = Chainloader.PluginInfos.ContainsKey("spawner_tweaks") || Chainloader.PluginInfos.ContainsKey("logic_tweaks"); IsStructureTweaks = Chainloader.PluginInfos.ContainsKey("structure_tweaks") || Chainloader.PluginInfos.ContainsKey("logic_tweaks"); IsCLLC = Chainloader.PluginInfos.ContainsKey("rg.bepinex.plugins.creaturelevelcontrol"); IsTweaks = Chainloader.PluginInfos.ContainsKey("world_edit_tweaks"); IsEWFactions = Chainloader.PluginInfos.ContainsKey("expand_world_factions"); DataLoading.SetupWatcher(); } } [HarmonyPatch(typeof(ZoneSystem), "Start")] public class ZoneSystemStart { private static void Postfix() { FieldAutoComplete.Init(); DataLoading.LoadEntries(); } } [HarmonyPatch(typeof(Terminal), "InitTerminal")] public class SetCommands { private static void Postfix() { new SpawnLocationCommand(); new SpawnObjectCommand(); new ObjectCommand(); new TerrainCommand(); new AliasesCommand(); new DungeonCommand(); new DataCommand(); new DataRawCommand(); if (WorldEditCommands.IsSpawnerTweaks || WorldEditCommands.IsStructureTweaks) { new TweakObjectCommand(); } if (WorldEditCommands.IsSpawnerTweaks) { new TweakAltarCommand(); new TweakBeehiveCommand(); new TweakPickableCommand(); new TweakSpawnerCommand(); new TweakSpawnPointCommand(); new TweakItemStandCommand(); new TweakChestCommand(); new TweakSmelterCommand(); new TweakFermenterCommand(); } if (WorldEditCommands.IsSpawnerTweaks || WorldEditCommands.IsEWFactions) { new TweakCreatureCommand(); } if (WorldEditCommands.IsStructureTweaks) { new TweakDungeonCommand(); new TweakRunestoneCommand(); new TweakPortalCommand(); new TweakFireplaceCommand(); new TweakChestCommand(); new TweakDoorCommand(); } } } }