Decompiled source of OutwardArchipelago v0.2.0
plugins/Archipelago.MultiClient.Net.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Net; using System.Net.WebSockets; using System.Numerics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Text; using System.Threading; using System.Threading.Tasks; using Archipelago.MultiClient.Net.Colors; using Archipelago.MultiClient.Net.ConcurrentCollection; using Archipelago.MultiClient.Net.Converters; using Archipelago.MultiClient.Net.DataPackage; using Archipelago.MultiClient.Net.Enums; using Archipelago.MultiClient.Net.Exceptions; using Archipelago.MultiClient.Net.Extensions; using Archipelago.MultiClient.Net.Helpers; using Archipelago.MultiClient.Net.MessageLog.Messages; using Archipelago.MultiClient.Net.MessageLog.Parts; using Archipelago.MultiClient.Net.Models; using Archipelago.MultiClient.Net.Packets; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Serialization; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: ComVisible(false)] [assembly: Guid("35a803ad-85ed-42e9-b1e3-c6b72096f0c1")] [assembly: InternalsVisibleTo("Archipelago.MultiClient.Net.Tests")] [assembly: InternalsVisibleTo("DynamicProxyGenAssembly2")] [assembly: TargetFramework(".NETFramework,Version=v4.5", FrameworkDisplayName = ".NET Framework 4.5")] [assembly: AssemblyCompany("Jarno Westhof, Hussein Farran, Zach Parks")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyDescription("A client library for use with .NET based prog-langs for interfacing with Archipelago hosts.")] [assembly: AssemblyFileVersion("6.7.0.0")] [assembly: AssemblyInformationalVersion("6.7.0+c807746b6f1774cf1afe12af819acb078b55a333")] [assembly: AssemblyProduct("Archipelago.MultiClient.Net")] [assembly: AssemblyTitle("Archipelago.MultiClient.Net")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ArchipelagoMW/Archipelago.MultiClient.Net")] [assembly: AssemblyVersion("6.7.0.0")] internal interface IConcurrentHashSet<T> { bool TryAdd(T item); bool Contains(T item); void UnionWith(T[] otherSet); T[] ToArray(); ReadOnlyCollection<T> AsToReadOnlyCollection(); ReadOnlyCollection<T> AsToReadOnlyCollectionExcept(IConcurrentHashSet<T> otherSet); } public class AttemptingStringEnumConverter : StringEnumConverter { public AttemptingStringEnumConverter() { } public AttemptingStringEnumConverter(Type namingStrategyType) : base(namingStrategyType) { } public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { try { return ((StringEnumConverter)this).ReadJson(reader, objectType, existingValue, serializer); } catch (JsonSerializationException) { return objectType.IsValueType ? Activator.CreateInstance(objectType) : null; } } } namespace Archipelago.MultiClient.Net { [Serializable] public abstract class ArchipelagoPacketBase { [JsonIgnore] internal JObject jobject; [JsonProperty("cmd")] [JsonConverter(typeof(StringEnumConverter))] public abstract ArchipelagoPacketType PacketType { get; } public JObject ToJObject() { return jobject; } } public interface IArchipelagoSession : IArchipelagoSessionActions { IArchipelagoSocketHelper Socket { get; } IReceivedItemsHelper Items { get; } ILocationCheckHelper Locations { get; } IPlayerHelper Players { get; } IDataStorageHelper DataStorage { get; } IConnectionInfoProvider ConnectionInfo { get; } IRoomStateHelper RoomState { get; } IMessageLogHelper MessageLog { get; } IHintsHelper Hints { get; } Task<RoomInfoPacket> ConnectAsync(); Task<LoginResult> LoginAsync(string game, string name, ItemsHandlingFlags itemsHandlingFlags, Version version = null, string[] tags = null, string uuid = null, string password = null, bool requestSlotData = true); LoginResult TryConnectAndLogin(string game, string name, ItemsHandlingFlags itemsHandlingFlags, Version version = null, string[] tags = null, string uuid = null, string password = null, bool requestSlotData = true); } public class ArchipelagoSession : IArchipelagoSession, IArchipelagoSessionActions { private const int ArchipelagoConnectionTimeoutInSeconds = 4; private ConnectionInfoHelper connectionInfo; private TaskCompletionSource<LoginResult> loginResultTask = new TaskCompletionSource<LoginResult>(); private TaskCompletionSource<RoomInfoPacket> roomInfoPacketTask = new TaskCompletionSource<RoomInfoPacket>(); public IArchipelagoSocketHelper Socket { get; } public IReceivedItemsHelper Items { get; } public ILocationCheckHelper Locations { get; } public IPlayerHelper Players { get; } public IDataStorageHelper DataStorage { get; } public IConnectionInfoProvider ConnectionInfo => connectionInfo; public IRoomStateHelper RoomState { get; } public IMessageLogHelper MessageLog { get; } public IHintsHelper Hints { get; } internal ArchipelagoSession(IArchipelagoSocketHelper socket, IReceivedItemsHelper items, ILocationCheckHelper locations, IPlayerHelper players, IRoomStateHelper roomState, ConnectionInfoHelper connectionInfoHelper, IDataStorageHelper dataStorage, IMessageLogHelper messageLog, IHintsHelper createHints) { Socket = socket; Items = items; Locations = locations; Players = players; RoomState = roomState; connectionInfo = connectionInfoHelper; DataStorage = dataStorage; MessageLog = messageLog; Hints = createHints; socket.PacketReceived += Socket_PacketReceived; } private void Socket_PacketReceived(ArchipelagoPacketBase packet) { if (!(packet is ConnectedPacket) && !(packet is ConnectionRefusedPacket)) { if (packet is RoomInfoPacket result) { roomInfoPacketTask.TrySetResult(result); } } else { loginResultTask.TrySetResult(LoginResult.FromPacket(packet)); } } public Task<RoomInfoPacket> ConnectAsync() { roomInfoPacketTask = new TaskCompletionSource<RoomInfoPacket>(); Task.Factory.StartNew(delegate { try { Task task = Socket.ConnectAsync(); task.Wait(TimeSpan.FromSeconds(4.0)); if (!task.IsCompleted) { roomInfoPacketTask.TrySetCanceled(); } } catch (AggregateException) { roomInfoPacketTask.TrySetCanceled(); } }); return roomInfoPacketTask.Task; } public Task<LoginResult> LoginAsync(string game, string name, ItemsHandlingFlags itemsHandlingFlags, Version version = null, string[] tags = null, string uuid = null, string password = null, bool requestSlotData = true) { loginResultTask = new TaskCompletionSource<LoginResult>(); if (!roomInfoPacketTask.Task.IsCompleted) { loginResultTask.TrySetResult(new LoginFailure("You are not connected, run ConnectAsync() first")); return loginResultTask.Task; } connectionInfo.SetConnectionParameters(game, tags, itemsHandlingFlags, uuid); try { Socket.SendPacket(BuildConnectPacket(name, password, version, requestSlotData)); } catch (ArchipelagoSocketClosedException) { loginResultTask.TrySetResult(new LoginFailure("You are not connected, run ConnectAsync() first")); return loginResultTask.Task; } SetResultAfterTimeout(loginResultTask, 4, new LoginFailure("Connection timed out.")); return loginResultTask.Task; } private static void SetResultAfterTimeout<T>(TaskCompletionSource<T> task, int timeoutInSeconds, T result) { new CancellationTokenSource(TimeSpan.FromSeconds(timeoutInSeconds)).Token.Register(delegate { task.TrySetResult(result); }); } public LoginResult TryConnectAndLogin(string game, string name, ItemsHandlingFlags itemsHandlingFlags, Version version = null, string[] tags = null, string uuid = null, string password = null, bool requestSlotData = true) { Task<RoomInfoPacket> task = ConnectAsync(); try { task.Wait(TimeSpan.FromSeconds(4.0)); } catch (AggregateException ex) { if (ex.GetBaseException() is OperationCanceledException) { return new LoginFailure("Connection timed out."); } return new LoginFailure(ex.GetBaseException().Message); } if (!task.IsCompleted) { return new LoginFailure("Connection timed out."); } return LoginAsync(game, name, itemsHandlingFlags, version, tags, uuid, password, requestSlotData).Result; } private ConnectPacket BuildConnectPacket(string name, string password, Version version, bool requestSlotData) { return new ConnectPacket { Game = ConnectionInfo.Game, Name = name, Password = password, Tags = ConnectionInfo.Tags, Uuid = ConnectionInfo.Uuid, Version = ((version != null) ? new NetworkVersion(version) : new NetworkVersion(0, 6, 0)), ItemsHandling = ConnectionInfo.ItemsHandlingFlags, RequestSlotData = requestSlotData }; } public void Say(string message) { Socket.SendPacket(new SayPacket { Text = message }); } public void SetClientState(ArchipelagoClientState state) { Socket.SendPacket(new StatusUpdatePacket { Status = state }); } public void SetGoalAchieved() { SetClientState(ArchipelagoClientState.ClientGoal); } } public interface IArchipelagoSessionActions { void Say(string message); void SetClientState(ArchipelagoClientState state); void SetGoalAchieved(); } public static class ArchipelagoSessionFactory { public static ArchipelagoSession CreateSession(Uri uri) { ArchipelagoSocketHelper socket = new ArchipelagoSocketHelper(uri); DataPackageCache cache = new DataPackageCache(socket); ConnectionInfoHelper connectionInfoHelper = new ConnectionInfoHelper(socket); PlayerHelper playerHelper = new PlayerHelper(socket, connectionInfoHelper); ItemInfoResolver itemInfoResolver = new ItemInfoResolver(cache, connectionInfoHelper); LocationCheckHelper locationCheckHelper = new LocationCheckHelper(socket, itemInfoResolver, connectionInfoHelper, playerHelper); ReceivedItemsHelper items = new ReceivedItemsHelper(socket, locationCheckHelper, itemInfoResolver, connectionInfoHelper, playerHelper); RoomStateHelper roomStateHelper = new RoomStateHelper(socket, locationCheckHelper); DataStorageHelper dataStorageHelper = new DataStorageHelper(socket, connectionInfoHelper); MessageLogHelper messageLog = new MessageLogHelper(socket, itemInfoResolver, playerHelper, connectionInfoHelper); HintsHelper createHints = new HintsHelper(socket, playerHelper, locationCheckHelper, roomStateHelper, dataStorageHelper); return new ArchipelagoSession(socket, items, locationCheckHelper, playerHelper, roomStateHelper, connectionInfoHelper, dataStorageHelper, messageLog, createHints); } public static ArchipelagoSession CreateSession(string hostname, int port = 38281) { return CreateSession(ParseUri(hostname, port)); } internal static Uri ParseUri(string hostname, int port) { string text = hostname; if (!text.StartsWith("ws://") && !text.StartsWith("wss://")) { text = "unspecified://" + text; } if (!text.Substring(text.IndexOf("://", StringComparison.Ordinal) + 3).Contains(":")) { text += $":{port}"; } if (text.EndsWith(":")) { text += port; } return new Uri(text); } } public abstract class LoginResult { public abstract bool Successful { get; } public static LoginResult FromPacket(ArchipelagoPacketBase packet) { if (!(packet is ConnectedPacket connectedPacket)) { if (packet is ConnectionRefusedPacket connectionRefusedPacket) { return new LoginFailure(connectionRefusedPacket); } throw new ArgumentOutOfRangeException("packet", "packet is not a connection result packet"); } return new LoginSuccessful(connectedPacket); } } public class LoginSuccessful : LoginResult { public override bool Successful => true; public int Team { get; } public int Slot { get; } public Dictionary<string, object> SlotData { get; } public LoginSuccessful(ConnectedPacket connectedPacket) { Team = connectedPacket.Team; Slot = connectedPacket.Slot; SlotData = connectedPacket.SlotData; } } public class LoginFailure : LoginResult { public override bool Successful => false; public ConnectionRefusedError[] ErrorCodes { get; } public string[] Errors { get; } public LoginFailure(ConnectionRefusedPacket connectionRefusedPacket) { if (connectionRefusedPacket.Errors != null) { ErrorCodes = connectionRefusedPacket.Errors.ToArray(); Errors = ErrorCodes.Select(GetErrorMessage).ToArray(); } else { ErrorCodes = new ConnectionRefusedError[0]; Errors = new string[0]; } } public LoginFailure(string message) { ErrorCodes = new ConnectionRefusedError[0]; Errors = new string[1] { message }; } private static string GetErrorMessage(ConnectionRefusedError errorCode) { return errorCode switch { ConnectionRefusedError.InvalidSlot => "The slot name did not match any slot on the server.", ConnectionRefusedError.InvalidGame => "The slot is set to a different game on the server.", ConnectionRefusedError.SlotAlreadyTaken => "The slot already has a connection with a different uuid established.", ConnectionRefusedError.IncompatibleVersion => "The client and server version mismatch.", ConnectionRefusedError.InvalidPassword => "The password is invalid.", ConnectionRefusedError.InvalidItemsHandling => "The item handling flags provided are invalid.", _ => $"Unknown error: {errorCode}.", }; } } internal class TwoWayLookup<TA, TB> : IEnumerable<KeyValuePair<TB, TA>>, IEnumerable { private readonly Dictionary<TA, TB> aToB = new Dictionary<TA, TB>(); private readonly Dictionary<TB, TA> bToA = new Dictionary<TB, TA>(); public TA this[TB b] => bToA[b]; public TB this[TA a] => aToB[a]; public void Add(TA a, TB b) { aToB[a] = b; bToA[b] = a; } public void Add(TB b, TA a) { Add(a, b); } public bool TryGetValue(TA a, out TB b) { return aToB.TryGetValue(a, out b); } public bool TryGetValue(TB b, out TA a) { return bToA.TryGetValue(b, out a); } public IEnumerator<KeyValuePair<TB, TA>> GetEnumerator() { return bToA.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } } } namespace Archipelago.MultiClient.Net.Packets { public class BouncedPacket : BouncePacket { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.Bounced; } public class BouncePacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.Bounce; [JsonProperty("games")] public List<string> Games { get; set; } = new List<string>(); [JsonProperty("slots")] public List<int> Slots { get; set; } = new List<int>(); [JsonProperty("tags")] public List<string> Tags { get; set; } = new List<string>(); [JsonProperty("data")] public Dictionary<string, JToken> Data { get; set; } } public class ConnectedPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.Connected; [JsonProperty("team")] public int Team { get; set; } [JsonProperty("slot")] public int Slot { get; set; } [JsonProperty("players")] public NetworkPlayer[] Players { get; set; } [JsonProperty("missing_locations")] public long[] MissingChecks { get; set; } [JsonProperty("checked_locations")] public long[] LocationsChecked { get; set; } [JsonProperty("slot_data")] public Dictionary<string, object> SlotData { get; set; } [JsonProperty("slot_info")] public Dictionary<int, NetworkSlot> SlotInfo { get; set; } [JsonProperty("hint_points")] public int? HintPoints { get; set; } } public class ConnectionRefusedPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.ConnectionRefused; [JsonProperty("errors", ItemConverterType = typeof(AttemptingStringEnumConverter))] public ConnectionRefusedError[] Errors { get; set; } } public class ConnectPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.Connect; [JsonProperty("password")] public string Password { get; set; } [JsonProperty("game")] public string Game { get; set; } [JsonProperty("name")] public string Name { get; set; } [JsonProperty("uuid")] public string Uuid { get; set; } [JsonProperty("version")] public NetworkVersion Version { get; set; } [JsonProperty("tags")] public string[] Tags { get; set; } [JsonProperty("items_handling")] public ItemsHandlingFlags ItemsHandling { get; set; } [JsonProperty("slot_data")] public bool RequestSlotData { get; set; } } public class ConnectUpdatePacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.ConnectUpdate; [JsonProperty("tags")] public string[] Tags { get; set; } [JsonProperty("items_handling")] public ItemsHandlingFlags? ItemsHandling { get; set; } } public class CreateHintsPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.CreateHints; [JsonProperty("locations")] public long[] Locations { get; set; } [JsonProperty("player")] public int Player { get; set; } [JsonProperty("status")] public HintStatus Status { get; set; } } public class DataPackagePacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.DataPackage; [JsonProperty("data")] public Archipelago.MultiClient.Net.Models.DataPackage DataPackage { get; set; } } public class GetDataPackagePacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.GetDataPackage; [JsonProperty("games")] public string[] Games { get; set; } } public class GetPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.Get; [JsonProperty("keys")] public string[] Keys { get; set; } } public class InvalidPacketPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.InvalidPacket; [JsonProperty("type")] public InvalidPacketErrorType ErrorType { get; set; } [JsonProperty("text")] public string ErrorText { get; set; } [JsonProperty("original_cmd")] public ArchipelagoPacketType OriginalCmd { get; set; } } public class LocationChecksPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.LocationChecks; [JsonProperty("locations")] public long[] Locations { get; set; } } public class LocationInfoPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.LocationInfo; [JsonProperty("locations")] public NetworkItem[] Locations { get; set; } } public class LocationScoutsPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.LocationScouts; [JsonProperty("locations")] public long[] Locations { get; set; } [JsonProperty("create_as_hint")] public int CreateAsHint { get; set; } } public class PrintJsonPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.PrintJSON; [JsonProperty("data")] public JsonMessagePart[] Data { get; set; } [JsonProperty("type")] [JsonConverter(typeof(AttemptingStringEnumConverter))] public JsonMessageType? MessageType { get; set; } } public class ItemPrintJsonPacket : PrintJsonPacket { [JsonProperty("receiving")] public int ReceivingPlayer { get; set; } [JsonProperty("item")] public NetworkItem Item { get; set; } } public class ItemCheatPrintJsonPacket : PrintJsonPacket { [JsonProperty("receiving")] public int ReceivingPlayer { get; set; } [JsonProperty("item")] public NetworkItem Item { get; set; } [JsonProperty("team")] public int Team { get; set; } } public class HintPrintJsonPacket : PrintJsonPacket { [JsonProperty("receiving")] public int ReceivingPlayer { get; set; } [JsonProperty("item")] public NetworkItem Item { get; set; } [JsonProperty("found")] public bool? Found { get; set; } } public class JoinPrintJsonPacket : PrintJsonPacket { [JsonProperty("team")] public int Team { get; set; } [JsonProperty("slot")] public int Slot { get; set; } [JsonProperty("tags")] public string[] Tags { get; set; } } public class LeavePrintJsonPacket : PrintJsonPacket { [JsonProperty("team")] public int Team { get; set; } [JsonProperty("slot")] public int Slot { get; set; } } public class ChatPrintJsonPacket : PrintJsonPacket { [JsonProperty("team")] public int Team { get; set; } [JsonProperty("slot")] public int Slot { get; set; } [JsonProperty("message")] public string Message { get; set; } } public class ServerChatPrintJsonPacket : PrintJsonPacket { [JsonProperty("message")] public string Message { get; set; } } public class TutorialPrintJsonPacket : PrintJsonPacket { } public class TagsChangedPrintJsonPacket : PrintJsonPacket { [JsonProperty("team")] public int Team { get; set; } [JsonProperty("slot")] public int Slot { get; set; } [JsonProperty("tags")] public string[] Tags { get; set; } } public class CommandResultPrintJsonPacket : PrintJsonPacket { } public class AdminCommandResultPrintJsonPacket : PrintJsonPacket { } public class GoalPrintJsonPacket : PrintJsonPacket { [JsonProperty("team")] public int Team { get; set; } [JsonProperty("slot")] public int Slot { get; set; } } public class ReleasePrintJsonPacket : PrintJsonPacket { [JsonProperty("team")] public int Team { get; set; } [JsonProperty("slot")] public int Slot { get; set; } } public class CollectPrintJsonPacket : PrintJsonPacket { [JsonProperty("team")] public int Team { get; set; } [JsonProperty("slot")] public int Slot { get; set; } } public class CountdownPrintJsonPacket : PrintJsonPacket { [JsonProperty("countdown")] public int RemainingSeconds { get; set; } } public class ReceivedItemsPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.ReceivedItems; [JsonProperty("index")] public int Index { get; set; } [JsonProperty("items")] public NetworkItem[] Items { get; set; } } public class RetrievedPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.Retrieved; [JsonProperty("keys")] public Dictionary<string, JToken> Data { get; set; } } public class RoomInfoPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.RoomInfo; [JsonProperty("version")] public NetworkVersion Version { get; set; } [JsonProperty("generator_version")] public NetworkVersion GeneratorVersion { get; set; } [JsonProperty("tags")] public string[] Tags { get; set; } [JsonProperty("password")] public bool Password { get; set; } [JsonProperty("permissions")] public Dictionary<string, Permissions> Permissions { get; set; } [JsonProperty("hint_cost")] public int HintCostPercentage { get; set; } [JsonProperty("location_check_points")] public int LocationCheckPoints { get; set; } [JsonProperty("players")] public NetworkPlayer[] Players { get; set; } [JsonProperty("games")] public string[] Games { get; set; } [JsonProperty("datapackage_checksums")] public Dictionary<string, string> DataPackageChecksums { get; set; } [JsonProperty("seed_name")] public string SeedName { get; set; } [JsonProperty("time")] public double Timestamp { get; set; } } public class RoomUpdatePacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.RoomUpdate; [JsonProperty("tags")] public string[] Tags { get; set; } [JsonProperty("password")] public bool? Password { get; set; } [JsonProperty("permissions")] public Dictionary<string, Permissions> Permissions { get; set; } = new Dictionary<string, Permissions>(); [JsonProperty("hint_cost")] public int? HintCostPercentage { get; set; } [JsonProperty("location_check_points")] public int? LocationCheckPoints { get; set; } [JsonProperty("players")] public NetworkPlayer[] Players { get; set; } [JsonProperty("hint_points")] public int? HintPoints { get; set; } [JsonProperty("checked_locations")] public long[] CheckedLocations { get; set; } } public class SayPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.Say; [JsonProperty("text")] public string Text { get; set; } } public class SetNotifyPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.SetNotify; [JsonProperty("keys")] public string[] Keys { get; set; } } public class SetPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.Set; [JsonProperty("key")] public string Key { get; set; } [JsonProperty("default")] public JToken DefaultValue { get; set; } [JsonProperty("operations")] public OperationSpecification[] Operations { get; set; } [JsonProperty("want_reply")] public bool WantReply { get; set; } [JsonExtensionData] public Dictionary<string, JToken> AdditionalArguments { get; set; } [OnDeserialized] internal void OnDeserializedMethod(StreamingContext context) { AdditionalArguments?.Remove("cmd"); } } public class SetReplyPacket : SetPacket { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.SetReply; [JsonProperty("value")] public JToken Value { get; set; } [JsonProperty("original_value")] public JToken OriginalValue { get; set; } } public class StatusUpdatePacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.StatusUpdate; [JsonProperty("status")] public ArchipelagoClientState Status { get; set; } } public class SyncPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.Sync; } internal class UnknownPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.Unknown; } public class UpdateHintPacket : ArchipelagoPacketBase { public override ArchipelagoPacketType PacketType => ArchipelagoPacketType.UpdateHint; [JsonProperty("player")] public int Player { get; set; } [JsonProperty("location")] public long Location { get; set; } [JsonProperty("status")] public HintStatus Status { get; set; } } } namespace Archipelago.MultiClient.Net.Models { public struct Color : IEquatable<Color> { public static Color Red = new Color(byte.MaxValue, 0, 0); public static Color Green = new Color(0, 128, 0); public static Color Yellow = new Color(byte.MaxValue, byte.MaxValue, 0); public static Color Blue = new Color(0, 0, byte.MaxValue); public static Color Magenta = new Color(byte.MaxValue, 0, byte.MaxValue); public static Color Cyan = new Color(0, byte.MaxValue, byte.MaxValue); public static Color Black = new Color(0, 0, 0); public static Color White = new Color(byte.MaxValue, byte.MaxValue, byte.MaxValue); public static Color SlateBlue = new Color(106, 90, 205); public static Color Salmon = new Color(250, 128, 114); public static Color Plum = new Color(221, 160, 221); public byte R { get; set; } public byte G { get; set; } public byte B { get; set; } public Color(byte r, byte g, byte b) { R = r; G = g; B = b; } public override bool Equals(object obj) { if (obj is Color color && R == color.R && G == color.G) { return B == color.B; } return false; } public bool Equals(Color other) { if (R == other.R && G == other.G) { return B == other.B; } return false; } public override int GetHashCode() { return ((-1520100960 * -1521134295 + R.GetHashCode()) * -1521134295 + G.GetHashCode()) * -1521134295 + B.GetHashCode(); } public static bool operator ==(Color left, Color right) { return left.Equals(right); } public static bool operator !=(Color left, Color right) { return !(left == right); } } public class DataPackage { [JsonProperty("games")] public Dictionary<string, GameData> Games { get; set; } = new Dictionary<string, GameData>(); } public class DataStorageElement { internal DataStorageElementContext Context; internal List<OperationSpecification> Operations = new List<OperationSpecification>(0); internal DataStorageHelper.DataStorageUpdatedHandler Callbacks; internal Dictionary<string, JToken> AdditionalArguments = new Dictionary<string, JToken>(0); private JToken cachedValue; public event DataStorageHelper.DataStorageUpdatedHandler OnValueChanged { add { Context.AddHandler(Context.Key, value); } remove { Context.RemoveHandler(Context.Key, value); } } internal DataStorageElement(DataStorageElementContext context) { Context = context; } internal DataStorageElement(OperationType operationType, JToken value) { Operations = new List<OperationSpecification>(1) { new OperationSpecification { OperationType = operationType, Value = value } }; } internal DataStorageElement(DataStorageElement source, OperationType operationType, JToken value) : this(source.Context) { Operations = source.Operations.ToList(); Callbacks = source.Callbacks; AdditionalArguments = source.AdditionalArguments; Operations.Add(new OperationSpecification { OperationType = operationType, Value = value }); } internal DataStorageElement(DataStorageElement source, Callback callback) : this(source.Context) { Operations = source.Operations.ToList(); Callbacks = source.Callbacks; AdditionalArguments = source.AdditionalArguments; Callbacks = (DataStorageHelper.DataStorageUpdatedHandler)Delegate.Combine(Callbacks, callback.Method); } internal DataStorageElement(DataStorageElement source, AdditionalArgument additionalArgument) : this(source.Context) { Operations = source.Operations.ToList(); Callbacks = source.Callbacks; AdditionalArguments = source.AdditionalArguments; AdditionalArguments[additionalArgument.Key] = additionalArgument.Value; } public static DataStorageElement operator ++(DataStorageElement a) { return new DataStorageElement(a, OperationType.Add, JToken.op_Implicit(1)); } public static DataStorageElement operator --(DataStorageElement a) { return new DataStorageElement(a, OperationType.Add, JToken.op_Implicit(-1)); } public static DataStorageElement operator +(DataStorageElement a, int b) { return new DataStorageElement(a, OperationType.Add, JToken.op_Implicit(b)); } public static DataStorageElement operator +(DataStorageElement a, long b) { return new DataStorageElement(a, OperationType.Add, JToken.op_Implicit(b)); } public static DataStorageElement operator +(DataStorageElement a, float b) { return new DataStorageElement(a, OperationType.Add, JToken.op_Implicit(b)); } public static DataStorageElement operator +(DataStorageElement a, double b) { return new DataStorageElement(a, OperationType.Add, JToken.op_Implicit(b)); } public static DataStorageElement operator +(DataStorageElement a, decimal b) { return new DataStorageElement(a, OperationType.Add, JToken.op_Implicit(b)); } public static DataStorageElement operator +(DataStorageElement a, string b) { return new DataStorageElement(a, OperationType.Add, JToken.op_Implicit(b)); } public static DataStorageElement operator +(DataStorageElement a, JToken b) { return new DataStorageElement(a, OperationType.Add, b); } public static DataStorageElement operator +(DataStorageElement a, IEnumerable b) { return new DataStorageElement(a, OperationType.Add, (JToken)(object)JArray.FromObject((object)b)); } public static DataStorageElement operator +(DataStorageElement a, OperationSpecification s) { return new DataStorageElement(a, s.OperationType, s.Value); } public static DataStorageElement operator +(DataStorageElement a, Callback c) { return new DataStorageElement(a, c); } public static DataStorageElement operator +(DataStorageElement a, AdditionalArgument arg) { return new DataStorageElement(a, arg); } public static DataStorageElement operator *(DataStorageElement a, int b) { return new DataStorageElement(a, OperationType.Mul, JToken.op_Implicit(b)); } public static DataStorageElement operator *(DataStorageElement a, long b) { return new DataStorageElement(a, OperationType.Mul, JToken.op_Implicit(b)); } public static DataStorageElement operator *(DataStorageElement a, float b) { return new DataStorageElement(a, OperationType.Mul, JToken.op_Implicit(b)); } public static DataStorageElement operator *(DataStorageElement a, double b) { return new DataStorageElement(a, OperationType.Mul, JToken.op_Implicit(b)); } public static DataStorageElement operator *(DataStorageElement a, decimal b) { return new DataStorageElement(a, OperationType.Mul, JToken.op_Implicit(b)); } public static DataStorageElement operator %(DataStorageElement a, int b) { return new DataStorageElement(a, OperationType.Mod, JToken.op_Implicit(b)); } public static DataStorageElement operator %(DataStorageElement a, long b) { return new DataStorageElement(a, OperationType.Mod, JToken.op_Implicit(b)); } public static DataStorageElement operator %(DataStorageElement a, float b) { return new DataStorageElement(a, OperationType.Mod, JToken.op_Implicit(b)); } public static DataStorageElement operator %(DataStorageElement a, double b) { return new DataStorageElement(a, OperationType.Mod, JToken.op_Implicit(b)); } public static DataStorageElement operator %(DataStorageElement a, decimal b) { return new DataStorageElement(a, OperationType.Mod, JToken.op_Implicit(b)); } public static DataStorageElement operator ^(DataStorageElement a, int b) { return new DataStorageElement(a, OperationType.Pow, JToken.op_Implicit(b)); } public static DataStorageElement operator ^(DataStorageElement a, long b) { return new DataStorageElement(a, OperationType.Pow, JToken.op_Implicit(b)); } public static DataStorageElement operator ^(DataStorageElement a, float b) { return new DataStorageElement(a, OperationType.Pow, JToken.op_Implicit(b)); } public static DataStorageElement operator ^(DataStorageElement a, double b) { return new DataStorageElement(a, OperationType.Pow, JToken.op_Implicit(b)); } public static DataStorageElement operator ^(DataStorageElement a, decimal b) { return new DataStorageElement(a, OperationType.Pow, JToken.op_Implicit(b)); } public static DataStorageElement operator -(DataStorageElement a, int b) { return new DataStorageElement(a, OperationType.Add, JToken.FromObject((object)(-b))); } public static DataStorageElement operator -(DataStorageElement a, long b) { return new DataStorageElement(a, OperationType.Add, JToken.FromObject((object)(-b))); } public static DataStorageElement operator -(DataStorageElement a, float b) { return new DataStorageElement(a, OperationType.Add, JToken.FromObject((object)(0f - b))); } public static DataStorageElement operator -(DataStorageElement a, double b) { return new DataStorageElement(a, OperationType.Add, JToken.FromObject((object)(0.0 - b))); } public static DataStorageElement operator -(DataStorageElement a, decimal b) { return new DataStorageElement(a, OperationType.Add, JToken.FromObject((object)(-b))); } public static DataStorageElement operator /(DataStorageElement a, int b) { return new DataStorageElement(a, OperationType.Mul, JToken.FromObject((object)(1m / (decimal)b))); } public static DataStorageElement operator /(DataStorageElement a, long b) { return new DataStorageElement(a, OperationType.Mul, JToken.FromObject((object)(1m / (decimal)b))); } public static DataStorageElement operator /(DataStorageElement a, float b) { return new DataStorageElement(a, OperationType.Mul, JToken.FromObject((object)(1.0 / (double)b))); } public static DataStorageElement operator /(DataStorageElement a, double b) { return new DataStorageElement(a, OperationType.Mul, JToken.FromObject((object)(1.0 / b))); } public static DataStorageElement operator /(DataStorageElement a, decimal b) { return new DataStorageElement(a, OperationType.Mul, JToken.FromObject((object)(1m / b))); } public static implicit operator DataStorageElement(bool b) { return new DataStorageElement(OperationType.Replace, JToken.op_Implicit(b)); } public static implicit operator DataStorageElement(int i) { return new DataStorageElement(OperationType.Replace, JToken.op_Implicit(i)); } public static implicit operator DataStorageElement(long l) { return new DataStorageElement(OperationType.Replace, JToken.op_Implicit(l)); } public static implicit operator DataStorageElement(decimal m) { return new DataStorageElement(OperationType.Replace, JToken.op_Implicit(m)); } public static implicit operator DataStorageElement(double d) { return new DataStorageElement(OperationType.Replace, JToken.op_Implicit(d)); } public static implicit operator DataStorageElement(float f) { return new DataStorageElement(OperationType.Replace, JToken.op_Implicit(f)); } public static implicit operator DataStorageElement(string s) { if (s != null) { return new DataStorageElement(OperationType.Replace, JToken.op_Implicit(s)); } return new DataStorageElement(OperationType.Replace, (JToken)(object)JValue.CreateNull()); } public static implicit operator DataStorageElement(JToken o) { return new DataStorageElement(OperationType.Replace, o); } public static implicit operator DataStorageElement(Array a) { return new DataStorageElement(OperationType.Replace, (JToken)(object)JArray.FromObject((object)a)); } public static implicit operator DataStorageElement(List<bool> l) { return new DataStorageElement(OperationType.Replace, (JToken)(object)JArray.FromObject((object)l)); } public static implicit operator DataStorageElement(List<int> l) { return new DataStorageElement(OperationType.Replace, (JToken)(object)JArray.FromObject((object)l)); } public static implicit operator DataStorageElement(List<long> l) { return new DataStorageElement(OperationType.Replace, (JToken)(object)JArray.FromObject((object)l)); } public static implicit operator DataStorageElement(List<decimal> l) { return new DataStorageElement(OperationType.Replace, (JToken)(object)JArray.FromObject((object)l)); } public static implicit operator DataStorageElement(List<double> l) { return new DataStorageElement(OperationType.Replace, (JToken)(object)JArray.FromObject((object)l)); } public static implicit operator DataStorageElement(List<float> l) { return new DataStorageElement(OperationType.Replace, (JToken)(object)JArray.FromObject((object)l)); } public static implicit operator DataStorageElement(List<string> l) { return new DataStorageElement(OperationType.Replace, (JToken)(object)JArray.FromObject((object)l)); } public static implicit operator DataStorageElement(List<object> l) { return new DataStorageElement(OperationType.Replace, (JToken)(object)JArray.FromObject((object)l)); } public static implicit operator bool(DataStorageElement e) { return RetrieveAndReturnBoolValue<bool>(e); } public static implicit operator bool?(DataStorageElement e) { return RetrieveAndReturnBoolValue<bool?>(e); } public static implicit operator int(DataStorageElement e) { return RetrieveAndReturnDecimalValue<int>(e); } public static implicit operator int?(DataStorageElement e) { return RetrieveAndReturnDecimalValue<int?>(e); } public static implicit operator long(DataStorageElement e) { return RetrieveAndReturnDecimalValue<long>(e); } public static implicit operator long?(DataStorageElement e) { return RetrieveAndReturnDecimalValue<long?>(e); } public static implicit operator float(DataStorageElement e) { return RetrieveAndReturnDecimalValue<float>(e); } public static implicit operator float?(DataStorageElement e) { return RetrieveAndReturnDecimalValue<float?>(e); } public static implicit operator double(DataStorageElement e) { return RetrieveAndReturnDecimalValue<double>(e); } public static implicit operator double?(DataStorageElement e) { return RetrieveAndReturnDecimalValue<double?>(e); } public static implicit operator decimal(DataStorageElement e) { return RetrieveAndReturnDecimalValue<decimal>(e); } public static implicit operator decimal?(DataStorageElement e) { return RetrieveAndReturnDecimalValue<decimal?>(e); } public static implicit operator string(DataStorageElement e) { return RetrieveAndReturnStringValue(e); } public static implicit operator bool[](DataStorageElement e) { return RetrieveAndReturnArrayValue<bool[]>(e); } public static implicit operator int[](DataStorageElement e) { return RetrieveAndReturnArrayValue<int[]>(e); } public static implicit operator long[](DataStorageElement e) { return RetrieveAndReturnArrayValue<long[]>(e); } public static implicit operator decimal[](DataStorageElement e) { return RetrieveAndReturnArrayValue<decimal[]>(e); } public static implicit operator double[](DataStorageElement e) { return RetrieveAndReturnArrayValue<double[]>(e); } public static implicit operator float[](DataStorageElement e) { return RetrieveAndReturnArrayValue<float[]>(e); } public static implicit operator string[](DataStorageElement e) { return RetrieveAndReturnArrayValue<string[]>(e); } public static implicit operator object[](DataStorageElement e) { return RetrieveAndReturnArrayValue<object[]>(e); } public static implicit operator List<bool>(DataStorageElement e) { return RetrieveAndReturnArrayValue<List<bool>>(e); } public static implicit operator List<int>(DataStorageElement e) { return RetrieveAndReturnArrayValue<List<int>>(e); } public static implicit operator List<long>(DataStorageElement e) { return RetrieveAndReturnArrayValue<List<long>>(e); } public static implicit operator List<decimal>(DataStorageElement e) { return RetrieveAndReturnArrayValue<List<decimal>>(e); } public static implicit operator List<double>(DataStorageElement e) { return RetrieveAndReturnArrayValue<List<double>>(e); } public static implicit operator List<float>(DataStorageElement e) { return RetrieveAndReturnArrayValue<List<float>>(e); } public static implicit operator List<string>(DataStorageElement e) { return RetrieveAndReturnArrayValue<List<string>>(e); } public static implicit operator List<object>(DataStorageElement e) { return RetrieveAndReturnArrayValue<List<object>>(e); } public static implicit operator Array(DataStorageElement e) { return RetrieveAndReturnArrayValue<Array>(e); } public static implicit operator JArray(DataStorageElement e) { return RetrieveAndReturnArrayValue<JArray>(e); } public static implicit operator JToken(DataStorageElement e) { return e.Context.GetData(e.Context.Key); } public static DataStorageElement operator +(DataStorageElement a, BigInteger b) { return new DataStorageElement(a, OperationType.Add, JToken.Parse(b.ToString())); } public static DataStorageElement operator *(DataStorageElement a, BigInteger b) { return new DataStorageElement(a, OperationType.Mul, JToken.Parse(b.ToString())); } public static DataStorageElement operator %(DataStorageElement a, BigInteger b) { return new DataStorageElement(a, OperationType.Mod, JToken.Parse(b.ToString())); } public static DataStorageElement operator ^(DataStorageElement a, BigInteger b) { return new DataStorageElement(a, OperationType.Pow, JToken.Parse(b.ToString())); } public static DataStorageElement operator -(DataStorageElement a, BigInteger b) { return new DataStorageElement(a, OperationType.Add, JToken.Parse((-b).ToString())); } public static DataStorageElement operator /(DataStorageElement a, BigInteger b) { throw new InvalidOperationException("DataStorage[Key] / BigInterger is not supported, due to loss of precision when using integer division"); } public static implicit operator DataStorageElement(BigInteger bi) { return new DataStorageElement(OperationType.Replace, JToken.Parse(bi.ToString())); } public static implicit operator BigInteger(DataStorageElement e) { return RetrieveAndReturnBigIntegerValue<BigInteger>(e); } public static implicit operator BigInteger?(DataStorageElement e) { return RetrieveAndReturnBigIntegerValue<BigInteger?>(e); } private static T RetrieveAndReturnBigIntegerValue<T>(DataStorageElement e) { if (e.cachedValue != null) { if (!BigInteger.TryParse(((object)e.cachedValue).ToString(), out var result)) { return default(T); } return (T)Convert.ChangeType(result, IsNullable<T>() ? Nullable.GetUnderlyingType(typeof(T)) : typeof(T)); } BigInteger result2; BigInteger? bigInteger = (BigInteger.TryParse(((object)e.Context.GetData(e.Context.Key)).ToString(), out result2) ? new BigInteger?(result2) : null); if (!bigInteger.HasValue && !IsNullable<T>()) { bigInteger = Activator.CreateInstance<BigInteger>(); } foreach (OperationSpecification operation in e.Operations) { if (operation.OperationType == OperationType.Floor || operation.OperationType == OperationType.Ceil) { continue; } if (!BigInteger.TryParse(((object)operation.Value).ToString(), NumberStyles.AllowLeadingSign, null, out var result3)) { throw new InvalidOperationException($"DataStorage[Key] cannot be converted to BigInterger as its value its not an integer number, value: {operation.Value}"); } switch (operation.OperationType) { case OperationType.Replace: bigInteger = result3; break; case OperationType.Add: bigInteger += result3; break; case OperationType.Mul: bigInteger *= result3; break; case OperationType.Mod: bigInteger %= result3; break; case OperationType.Pow: bigInteger = BigInteger.Pow(bigInteger.Value, (int)operation.Value); break; case OperationType.Max: { BigInteger value = result3; BigInteger? bigInteger2 = bigInteger; if (value > bigInteger2) { bigInteger = result3; } break; } case OperationType.Min: { BigInteger value = result3; BigInteger? bigInteger2 = bigInteger; if (value < bigInteger2) { bigInteger = result3; } break; } case OperationType.Xor: bigInteger ^= result3; break; case OperationType.Or: bigInteger |= result3; break; case OperationType.And: bigInteger &= result3; break; case OperationType.LeftShift: bigInteger <<= (int)operation.Value; break; case OperationType.RightShift: bigInteger >>= (int)operation.Value; break; } } e.cachedValue = JToken.Parse(bigInteger.ToString()); if (!bigInteger.HasValue) { return default(T); } return (T)Convert.ChangeType(bigInteger.Value, IsNullable<T>() ? Nullable.GetUnderlyingType(typeof(T)) : typeof(T)); } public void Initialize(JToken value) { Context.Initialize(Context.Key, value); } public void Initialize(IEnumerable value) { Context.Initialize(Context.Key, (JToken)(object)JArray.FromObject((object)value)); } public Task<T> GetAsync<T>() { return GetAsync().ContinueWith((Task<JToken> r) => r.Result.ToObject<T>()); } public Task<JToken> GetAsync() { return Context.GetAsync(Context.Key); } private static T RetrieveAndReturnArrayValue<T>(DataStorageElement e) { //IL_000e: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Invalid comparison between Unknown and I4 //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Invalid comparison between Unknown and I4 //IL_00d8: Unknown result type (might be due to invalid IL or missing references) if (e.cachedValue != null) { return ((JToken)(JArray)e.cachedValue).ToObject<T>(); } JArray val = (JArray)(((object)e.Context.GetData(e.Context.Key).ToObject<JArray>()) ?? ((object)new JArray())); foreach (OperationSpecification operation in e.Operations) { switch (operation.OperationType) { case OperationType.Add: if ((int)operation.Value.Type != 2) { throw new InvalidOperationException($"Cannot perform operation {OperationType.Add} on Array value, with a non Array value: {operation.Value}"); } ((JContainer)val).Merge((object)operation.Value); break; case OperationType.Replace: if ((int)operation.Value.Type != 2) { throw new InvalidOperationException($"Cannot replace Array value, with a non Array value: {operation.Value}"); } val = (JArray)(((object)operation.Value.ToObject<JArray>()) ?? ((object)new JArray())); break; default: throw new InvalidOperationException($"Cannot perform operation {operation.OperationType} on Array value"); } } e.cachedValue = (JToken)(object)val; return ((JToken)val).ToObject<T>(); } private static string RetrieveAndReturnStringValue(DataStorageElement e) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Invalid comparison between Unknown and I4 if (e.cachedValue != null) { return (string)e.cachedValue; } JToken val = e.Context.GetData(e.Context.Key); string text = (((int)val.Type == 10) ? null : ((object)val).ToString()); foreach (OperationSpecification operation in e.Operations) { switch (operation.OperationType) { case OperationType.Add: text += (string)operation.Value; break; case OperationType.Mul: if ((int)operation.Value.Type != 6) { throw new InvalidOperationException($"Cannot perform operation {OperationType.Mul} on string value, with a non interger value: {operation.Value}"); } text = string.Concat(Enumerable.Repeat(text, (int)operation.Value)); break; case OperationType.Replace: text = (string)operation.Value; break; default: throw new InvalidOperationException($"Cannot perform operation {operation.OperationType} on string value"); } } if (text == null) { e.cachedValue = (JToken)(object)JValue.CreateNull(); } else { e.cachedValue = JToken.op_Implicit(text); } return (string)e.cachedValue; } private static T RetrieveAndReturnBoolValue<T>(DataStorageElement e) { if (e.cachedValue != null) { return e.cachedValue.ToObject<T>(); } bool? flag = e.Context.GetData(e.Context.Key).ToObject<bool?>() ?? ((bool?)Activator.CreateInstance(typeof(T))); foreach (OperationSpecification operation in e.Operations) { if (operation.OperationType == OperationType.Replace) { flag = (bool?)operation.Value; continue; } throw new InvalidOperationException($"Cannot perform operation {operation.OperationType} on boolean value"); } e.cachedValue = JToken.op_Implicit(flag); if (!flag.HasValue) { return default(T); } return (T)Convert.ChangeType(flag.Value, IsNullable<T>() ? Nullable.GetUnderlyingType(typeof(T)) : typeof(T)); } private static T RetrieveAndReturnDecimalValue<T>(DataStorageElement e) { if (e.cachedValue != null) { return e.cachedValue.ToObject<T>(); } decimal? num = e.Context.GetData(e.Context.Key).ToObject<decimal?>(); if (!num.HasValue && !IsNullable<T>()) { num = Activator.CreateInstance<decimal>(); } foreach (OperationSpecification operation in e.Operations) { switch (operation.OperationType) { case OperationType.Replace: num = (decimal)operation.Value; break; case OperationType.Add: num += (decimal?)(decimal)operation.Value; break; case OperationType.Mul: num *= (decimal?)(decimal)operation.Value; break; case OperationType.Mod: num %= (decimal?)(decimal)operation.Value; break; case OperationType.Pow: num = (decimal)Math.Pow((double)num.Value, (double)operation.Value); break; case OperationType.Max: num = Math.Max(num.Value, (decimal)operation.Value); break; case OperationType.Min: num = Math.Min(num.Value, (decimal)operation.Value); break; case OperationType.Xor: num = (long)num.Value ^ (long)operation.Value; break; case OperationType.Or: num = (long)num.Value | (long)operation.Value; break; case OperationType.And: num = (long)num.Value & (long)operation.Value; break; case OperationType.LeftShift: num = (long)num.Value << (int)operation.Value; break; case OperationType.RightShift: num = (long)num.Value >> (int)operation.Value; break; case OperationType.Floor: num = Math.Floor(num.Value); break; case OperationType.Ceil: num = Math.Ceiling(num.Value); break; } } e.cachedValue = JToken.op_Implicit(num); if (!num.HasValue) { return default(T); } return (T)Convert.ChangeType(num.Value, IsNullable<T>() ? Nullable.GetUnderlyingType(typeof(T)) : typeof(T)); } private static bool IsNullable<T>() { if (typeof(T).IsGenericType) { return typeof(T).GetGenericTypeDefinition() == typeof(Nullable<>).GetGenericTypeDefinition(); } return false; } public T To<T>() { if (Operations.Count != 0) { throw new InvalidOperationException("DataStorageElement.To<T>() cannot be used together with other operations on the DataStorageElement"); } return Context.GetData(Context.Key).ToObject<T>(); } public override string ToString() { return (Context?.ToString() ?? "(null)") + ", (" + ListOperations() + ")"; } private string ListOperations() { if (Operations != null) { return string.Join(", ", Operations.Select((OperationSpecification o) => o.ToString()).ToArray()); } return "none"; } } internal class DataStorageElementContext { internal string Key { get; set; } internal Action<string, DataStorageHelper.DataStorageUpdatedHandler> AddHandler { get; set; } internal Action<string, DataStorageHelper.DataStorageUpdatedHandler> RemoveHandler { get; set; } internal Func<string, JToken> GetData { get; set; } internal Action<string, JToken> Initialize { get; set; } internal Func<string, Task<JToken>> GetAsync { get; set; } public override string ToString() { return "Key: " + Key; } } public class GameData { [JsonProperty("location_name_to_id")] public Dictionary<string, long> LocationLookup { get; set; } = new Dictionary<string, long>(); [JsonProperty("item_name_to_id")] public Dictionary<string, long> ItemLookup { get; set; } = new Dictionary<string, long>(); [Obsolete("use Checksum instead")] [JsonProperty("version")] public int Version { get; set; } [JsonProperty("checksum")] public string Checksum { get; set; } } public class Hint { [JsonProperty("receiving_player")] public int ReceivingPlayer { get; set; } [JsonProperty("finding_player")] public int FindingPlayer { get; set; } [JsonProperty("item")] public long ItemId { get; set; } [JsonProperty("location")] public long LocationId { get; set; } [JsonProperty("item_flags")] public ItemFlags ItemFlags { get; set; } [JsonProperty("found")] public bool Found { get; set; } [JsonProperty("entrance")] public string Entrance { get; set; } [JsonProperty("status")] public HintStatus Status { get; set; } } public class ItemInfo { private readonly IItemInfoResolver itemInfoResolver; public long ItemId { get; } public long LocationId { get; } public PlayerInfo Player { get; } public ItemFlags Flags { get; } public string ItemName => itemInfoResolver.GetItemName(ItemId, ItemGame); public string ItemDisplayName => ItemName ?? $"Item: {ItemId}"; public string LocationName => itemInfoResolver.GetLocationName(LocationId, LocationGame); public string LocationDisplayName => LocationName ?? $"Location: {LocationId}"; public string ItemGame { get; } public string LocationGame { get; } public ItemInfo(NetworkItem item, string receiverGame, string senderGame, IItemInfoResolver itemInfoResolver, PlayerInfo player) { this.itemInfoResolver = itemInfoResolver; ItemGame = receiverGame; LocationGame = senderGame; ItemId = item.Item; LocationId = item.Location; Flags = item.Flags; Player = player; } public SerializableItemInfo ToSerializable() { return new SerializableItemInfo { IsScout = (GetType() == typeof(ScoutedItemInfo)), ItemId = ItemId, LocationId = LocationId, PlayerSlot = Player, Player = Player, Flags = Flags, ItemGame = ItemGame, ItemName = ItemName, LocationGame = LocationGame, LocationName = LocationName }; } } public class ScoutedItemInfo : ItemInfo { public new PlayerInfo Player => base.Player; public bool IsReceiverRelatedToActivePlayer { get; } public ScoutedItemInfo(NetworkItem item, string receiverGame, string senderGame, IItemInfoResolver itemInfoResolver, IPlayerHelper players, PlayerInfo player) : base(item, receiverGame, senderGame, itemInfoResolver, player) { IsReceiverRelatedToActivePlayer = (players.ActivePlayer ?? new PlayerInfo()).IsRelatedTo(player); } } public class JsonMessagePart { [JsonProperty("type")] [JsonConverter(typeof(AttemptingStringEnumConverter), new object[] { typeof(SnakeCaseNamingStrategy) })] public JsonMessagePartType? Type { get; set; } [JsonProperty("color")] [JsonConverter(typeof(AttemptingStringEnumConverter), new object[] { typeof(SnakeCaseNamingStrategy) })] public JsonMessagePartColor? Color { get; set; } [JsonProperty("text")] public string Text { get; set; } [JsonProperty("player")] public int? Player { get; set; } [JsonProperty("flags")] public ItemFlags? Flags { get; set; } [JsonProperty("hint_status")] public HintStatus? HintStatus { get; set; } } public struct NetworkItem { [JsonProperty("item")] public long Item { get; set; } [JsonProperty("location")] public long Location { get; set; } [JsonProperty("player")] public int Player { get; set; } [JsonProperty("flags")] public ItemFlags Flags { get; set; } } public struct NetworkPlayer { [JsonProperty("team")] public int Team { get; set; } [JsonProperty("slot")] public int Slot { get; set; } [JsonProperty("alias")] public string Alias { get; set; } [JsonProperty("name")] public string Name { get; set; } } public struct NetworkSlot { [JsonProperty("name")] public string Name { get; set; } [JsonProperty("game")] public string Game { get; set; } [JsonProperty("type")] public SlotType Type { get; set; } [JsonProperty("group_members")] public int[] GroupMembers { get; set; } } public class NetworkVersion { [JsonProperty("major")] public int Major { get; set; } [JsonProperty("minor")] public int Minor { get; set; } [JsonProperty("build")] public int Build { get; set; } [JsonProperty("class")] public string Class => "Version"; public NetworkVersion() { } public NetworkVersion(int major, int minor, int build) { Major = major; Minor = minor; Build = build; } public NetworkVersion(Version version) { Major = version.Major; Minor = version.Minor; Build = version.Build; } public Version ToVersion() { return new Version(Major, Minor, Build); } } public class OperationSpecification { [JsonProperty("operation")] [JsonConverter(typeof(AttemptingStringEnumConverter), new object[] { typeof(SnakeCaseNamingStrategy) })] public OperationType OperationType; [JsonProperty("value")] public JToken Value { get; set; } public override string ToString() { return $"{OperationType}: {Value}"; } } public static class Operation { public static OperationSpecification Min(int i) { return new OperationSpecification { OperationType = OperationType.Min, Value = JToken.op_Implicit(i) }; } public static OperationSpecification Min(long i) { return new OperationSpecification { OperationType = OperationType.Min, Value = JToken.op_Implicit(i) }; } public static OperationSpecification Min(float i) { return new OperationSpecification { OperationType = OperationType.Min, Value = JToken.op_Implicit(i) }; } public static OperationSpecification Min(double i) { return new OperationSpecification { OperationType = OperationType.Min, Value = JToken.op_Implicit(i) }; } public static OperationSpecification Min(decimal i) { return new OperationSpecification { OperationType = OperationType.Min, Value = JToken.op_Implicit(i) }; } public static OperationSpecification Min(JToken i) { return new OperationSpecification { OperationType = OperationType.Min, Value = i }; } public static OperationSpecification Min(BigInteger i) { return new OperationSpecification { OperationType = OperationType.Min, Value = JToken.Parse(i.ToString()) }; } public static OperationSpecification Max(int i) { return new OperationSpecification { OperationType = OperationType.Max, Value = JToken.op_Implicit(i) }; } public static OperationSpecification Max(long i) { return new OperationSpecification { OperationType = OperationType.Max, Value = JToken.op_Implicit(i) }; } public static OperationSpecification Max(float i) { return new OperationSpecification { OperationType = OperationType.Max, Value = JToken.op_Implicit(i) }; } public static OperationSpecification Max(double i) { return new OperationSpecification { OperationType = OperationType.Max, Value = JToken.op_Implicit(i) }; } public static OperationSpecification Max(decimal i) { return new OperationSpecification { OperationType = OperationType.Max, Value = JToken.op_Implicit(i) }; } public static OperationSpecification Max(JToken i) { return new OperationSpecification { OperationType = OperationType.Max, Value = i }; } public static OperationSpecification Max(BigInteger i) { return new OperationSpecification { OperationType = OperationType.Max, Value = JToken.Parse(i.ToString()) }; } public static OperationSpecification Remove(JToken value) { return new OperationSpecification { OperationType = OperationType.Remove, Value = value }; } public static OperationSpecification Pop(int value) { return new OperationSpecification { OperationType = OperationType.Pop, Value = JToken.op_Implicit(value) }; } public static OperationSpecification Pop(JToken value) { return new OperationSpecification { OperationType = OperationType.Pop, Value = value }; } public static OperationSpecification Update(IDictionary dictionary) { return new OperationSpecification { OperationType = OperationType.Update, Value = (JToken)(object)JObject.FromObject((object)dictionary) }; } public static OperationSpecification Floor() { return new OperationSpecification { OperationType = OperationType.Floor, Value = null }; } public static OperationSpecification Ceiling() { return new OperationSpecification { OperationType = OperationType.Ceil, Value = null }; } } public static class Bitwise { public static OperationSpecification Xor(long i) { return new OperationSpecification { OperationType = OperationType.Xor, Value = JToken.op_Implicit(i) }; } public static OperationSpecification Xor(BigInteger i) { return new OperationSpecification { OperationType = OperationType.Xor, Value = JToken.Parse(i.ToString()) }; } public static OperationSpecification Or(long i) { return new OperationSpecification { OperationType = OperationType.Or, Value = JToken.op_Implicit(i) }; } public static OperationSpecification Or(BigInteger i) { return new OperationSpecification { OperationType = OperationType.Or, Value = JToken.Parse(i.ToString()) }; } public static OperationSpecification And(long i) { return new OperationSpecification { OperationType = OperationType.And, Value = JToken.op_Implicit(i) }; } public static OperationSpecification And(BigInteger i) { return new OperationSpecification { OperationType = OperationType.And, Value = JToken.Parse(i.ToString()) }; } public static OperationSpecification LeftShift(long i) { return new OperationSpecification { OperationType = OperationType.LeftShift, Value = JToken.op_Implicit(i) }; } public static OperationSpecification RightShift(long i) { return new OperationSpecification { OperationType = OperationType.RightShift, Value = JToken.op_Implicit(i) }; } } public class Callback { internal DataStorageHelper.DataStorageUpdatedHandler Method { get; set; } private Callback() { } public static Callback Add(DataStorageHelper.DataStorageUpdatedHandler callback) { return new Callback { Method = callback }; } } public class AdditionalArgument { internal string Key { get; set; } internal JToken Value { get; set; } private AdditionalArgument() { } public static AdditionalArgument Add(string name, JToken value) { return new AdditionalArgument { Key = name, Value = value }; } } public class MinimalSerializableItemInfo { public long ItemId { get; set; } public long LocationId { get; set; } public int PlayerSlot { get; set; } public ItemFlags Flags { get; set; } public string ItemGame { get; set; } public string LocationGame { get; set; } } public class SerializableItemInfo : MinimalSerializableItemInfo { public bool IsScout { get; set; } public PlayerInfo Player { get; set; } public string ItemName { get; set; } public string LocationName { get; set; } [JsonIgnore] public string ItemDisplayName => ItemName ?? $"Item: {base.ItemId}"; [JsonIgnore] public string LocationDisplayName => LocationName ?? $"Location: {base.LocationId}"; public string ToJson(bool full = false) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown MinimalSerializableItemInfo minimalSerializableItemInfo = this; if (!full) { minimalSerializableItemInfo = new MinimalSerializableItemInfo { ItemId = base.ItemId, LocationId = base.LocationId, PlayerSlot = base.PlayerSlot, Flags = base.Flags }; if (IsScout) { minimalSerializableItemInfo.ItemGame = base.ItemGame; } else { minimalSerializableItemInfo.LocationGame = base.LocationGame; } } JsonSerializerSettings val = new JsonSerializerSettings { NullValueHandling = (NullValueHandling)1, Formatting = (Formatting)0 }; return JsonConvert.SerializeObject((object)minimalSerializableItemInfo, val); } public static SerializableItemInfo FromJson(string json, IArchipelagoSession session = null) { //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_0050: Expected O, but got Unknown ItemInfoStreamingContext additional = ((session != null) ? new ItemInfoStreamingContext { Items = session.Items, Locations = session.Locations, PlayerHelper = session.Players, ConnectionInfo = session.ConnectionInfo } : null); JsonSerializerSettings val = new JsonSerializerSettings { Context = new StreamingContext(StreamingContextStates.Other, additional) }; return JsonConvert.DeserializeObject<SerializableItemInfo>(json, val); } [OnDeserialized] internal void OnDeserializedMethod(StreamingContext streamingContext) { if (base.ItemGame == null && base.LocationGame != null) { IsScout = false; } else if (base.ItemGame != null && base.LocationGame == null) { IsScout = true; } if (streamingContext.Context is ItemInfoStreamingContext itemInfoStreamingContext) { if (IsScout && base.LocationGame == null) { base.LocationGame = itemInfoStreamingContext.ConnectionInfo.Game; } else if (!IsScout && base.ItemGame == null) { base.ItemGame = itemInfoStreamingContext.ConnectionInfo.Game; } if (ItemName == null) { ItemName = itemInfoStreamingContext.Items.GetItemName(base.ItemId, base.ItemGame); } if (LocationName == null) { LocationName = itemInfoStreamingContext.Locations.GetLocationNameFromId(base.LocationId, base.LocationGame); } if (Player == null) { Player = itemInfoStreamingContext.PlayerHelper.GetPlayerInfo(base.PlayerSlot); } } } } internal class ItemInfoStreamingContext { public IReceivedItemsHelper Items { get; set; } public ILocationCheckHelper Locations { get; set; } public IPlayerHelper PlayerHelper { get; set; } public IConnectionInfoProvider ConnectionInfo { get; set; } } } namespace Archipelago.MultiClient.Net.MessageLog.Parts { public class EntranceMessagePart : MessagePart { internal EntranceMessagePart(JsonMessagePart messagePart) : base(MessagePartType.Entrance, messagePart, Archipelago.MultiClient.Net.Colors.PaletteColor.Blue) { base.Text = messagePart.Text; } } public class HintStatusMessagePart : MessagePart { internal HintStatusMessagePart(JsonMessagePart messagePart) : base(MessagePartType.HintStatus, messagePart) { base.Text = messagePart.Text; if (messagePart.HintStatus.HasValue) { base.PaletteColor = ColorUtils.GetColor(messagePart.HintStatus.Value); } } } public class ItemMessagePart : MessagePart { public ItemFlags Flags { get; } public long ItemId { get; } public int Player { get; } internal ItemMessagePart(IPlayerHelper players, IItemInfoResolver items, JsonMessagePart part) : base(MessagePartType.Item, part) { Flags = part.Flags.GetValueOrDefault(); base.PaletteColor = ColorUtils.GetColor(Flags); Player = part.Player.GetValueOrDefault(); string game = (players.GetPlayerInfo(Player) ?? new PlayerInfo()).Game; JsonMessagePartType? type = part.Type; if (type.HasValue) { switch (type.GetValueOrDefault()) { case JsonMessagePartType.ItemId: ItemId = long.Parse(part.Text); base.Text = items.GetItemName(ItemId, game) ?? $"Item: {ItemId}"; break; case JsonMessagePartType.ItemName: ItemId = 0L; base.Text = part.Text; break; } } } } public class LocationMessagePart : MessagePart { public long LocationId { get; } public int Player { get; } internal LocationMessagePart(IPlayerHelper players, IItemInfoResolver itemInfoResolver, JsonMessagePart part) : base(MessagePartType.Location, part, Archipelago.MultiClient.Net.Colors.PaletteColor.Green) { Player = part.Player.GetValueOrDefault(); string game = (players.GetPlayerInfo(Player) ?? new PlayerInfo()).Game; JsonMessagePartType? type = part.Type; if (type.HasValue) { switch (type.GetValueOrDefault()) { case JsonMessagePartType.LocationId: LocationId = long.Parse(part.Text); base.Text = itemInfoResolver.GetLocationName(LocationId, game) ?? $"Location: {LocationId}"; break; case JsonMessagePartType.LocationName: LocationId = itemInfoResolver.GetLocationId(part.Text, game); base.Text = part.Text; break; } } } } public class MessagePart { public string Text { get; internal set; } public MessagePartType Type { get; internal set; } public Color Color => GetColor(BuiltInPalettes.Dark); public PaletteColor? PaletteColor { get; protected set; } public bool IsBackgroundColor { get; internal set; } internal MessagePart(MessagePartType type, JsonMessagePart messagePart, PaletteColor? color = null) { Type = type; Text = messagePart.Text; if (color.HasValue) { PaletteColor = color.Value; } else if (messagePart.Color.HasValue) { PaletteColor = ColorUtils.GetColor(messagePart.Color.Value); IsBackgroundColor = messagePart.Color.Value >= JsonMessagePartColor.BlackBg; } else { PaletteColor = null; } } public T GetColor<T>(Palette<T> palette) { return palette[PaletteColor]; } public override string ToString() { return Text; } } public enum MessagePartType { Text, Player, Item, Location, Entrance, HintStatus } public class PlayerMessagePart : MessagePart { public bool IsActivePlayer { get; } public int SlotId { get; } internal PlayerMessagePart(IPlayerHelper players, IConnectionInfoProvider connectionInfo, JsonMessagePart part) : base(MessagePartType.Player, part) { switch (part.Type) { case JsonMessagePartType.PlayerId: SlotId = int.Parse(part.Text); IsActivePlayer = SlotId == connectionInfo.Slot; base.Text = players.GetPlayerAlias(SlotId) ?? $"Player {SlotId}"; break; case JsonMessagePartType.PlayerName: SlotId = 0; IsActivePlayer = false; base.Text = part.Text; break; } base.PaletteColor = (IsActivePlayer ? Archipelago.MultiClient.Net.Colors.PaletteColor.Magenta : Archipelago.MultiClient.Net.Colors.PaletteColor.Yellow); } } } namespace Archipelago.MultiClient.Net.MessageLog.Messages { public class AdminCommandResultLogMessage : LogMessage { internal AdminCommandResultLogMessage(MessagePart[] parts) : base(parts) { } } public class ChatLogMessage : PlayerSpecificLogMessage { public string Message { get; } internal ChatLogMessage(MessagePart[] parts, IPlayerHelper players, int team, int slot, string message) : base(parts, players, team, slot) { Message = message; } } public class CollectLogMessage : PlayerSpecificLogMessage { internal CollectLogMessage(MessagePart[] parts, IPlayerHelper players, int team, int slot) : base(parts, players, team, slot) { } } public class CommandResultLogMessage : LogMessage { internal CommandResultLogMessage(MessagePart[] parts) : base(parts) { } } public class CountdownLogMessage : LogMessage { public int RemainingSeconds { get; } internal CountdownLogMessage(MessagePart[] parts, int remainingSeconds) : base(parts) { RemainingSeconds = remainingSeconds; } } public class GoalLogMessage : PlayerSpecificLogMessage { internal GoalLogMessage(MessagePart[] parts, IPlayerHelper players, int team, int slot) : base(parts, players, team, slot) { } } public class HintItemSendLogMessage : ItemSendLogMessage { public bool IsFound { get; } internal HintItemSendLogMessage(MessagePart[] parts, IPlayerHelper players, int receiver, int sender, NetworkItem item, bool found, IItemInfoResolver itemInfoResolver) : base(parts, players, receiver, sender, item, itemInfoResolver) { IsFound = found; } } public class ItemCheatLogMessage : ItemSendLogMessage { internal ItemCheatLogMessage(MessagePart[] parts, IPlayerHelper players, int team, int slot, NetworkItem item, IItemInfoResolver itemInfoResolver) : base(parts, players, slot, 0, item, team, itemInfoResolver) { } } public class ItemSendLogMessage : LogMessage { private PlayerInfo ActivePlayer { get; } public PlayerInfo Receiver { get; } public PlayerInfo Sender { get; } public bool IsReceiverTheActivePlayer => Receiver == ActivePlayer; public bool IsSenderTheActivePlayer => Sender == ActivePlayer; public bool IsRelatedToActivePlayer { get { if (!ActivePlayer.IsRelatedTo(Receiver)) { return ActivePlayer.IsRelatedTo(Sender); } return true; } } public ItemInfo Item { get; } internal ItemSendLogMessage(MessagePart[] parts, IPlayerHelper players, int receiver, int sender, NetworkItem item, IItemInfoResolver itemInfoResolver) : this(parts, players, receiver, sender, item, players.ActivePlayer.Team, itemInfoResolver) { } internal ItemSendLogMessage(MessagePart[] parts, IPlayerHelper players, int receiver, int sender, NetworkItem item, int team, IItemInfoResolver itemInfoResolver) : base(parts) { ActivePlayer = players.ActivePlayer ?? new PlayerInfo(); Receiver = players.GetPlayerInfo(team, receiver) ?? new PlayerInfo(); Sender = players.GetPlayerInfo(team, sender) ?? new PlayerInfo(); PlayerInfo player = players.GetPlayerInfo(team, item.Player) ?? new PlayerInfo(); Item = new ItemInfo(item, Receiver.Game, Sender.Game, itemInfoResolver, player); } } public class JoinLogMessage : PlayerSpecificLogMessage { public string[] Tags { get; } internal JoinLogMessage(MessagePart[] parts, IPlayerHelper players, int team, int slot, string[] tags) : base(parts, players, team, slot) { Tags = tags; } } public class LeaveLogMessage : PlayerSpecificLogMessage { internal LeaveLogMessage(MessagePart[] parts, IPlayerHelper players, int team, int slot) : base(parts, players, team, slot) { } } public class LogMessage { public MessagePart[] Parts { get; } internal LogMessage(MessagePart[] parts) { Parts = parts; } public override string ToString() { if (Parts.Length == 1) { return Parts[0].Text; } StringBuilder stringBuilder = new StringBuilder(); MessagePart[] parts = Parts; foreach (MessagePart messagePart in parts) { stringBuilder.Append(messagePart.Text); } return stringBuilder.ToString(); } } public abstract class PlayerSpecificLogMessage : LogMessage { private PlayerInfo ActivePlayer { get; } public PlayerInfo Player { get; } public bool IsActivePlayer => Player == ActivePlayer; public bool IsRelatedToActivePlayer => ActivePlayer.IsRelatedTo(Player); internal PlayerSpecificLogMessage(MessagePart[] parts, IPlayerHelper players, int team, int slot) : base(parts) { ActivePlayer = players.ActivePlayer ?? new PlayerInfo(); Player = players.GetPlayerInfo(team, slot) ?? new PlayerInfo(); } } public class ReleaseLogMessage : PlayerSpecificLogMessage { internal ReleaseLogMessage(MessagePart[] parts, IPlayerHelper players, int team, int slot) : base(parts, players, team, slot) { } } public class ServerChatLogMessage : LogMessage { public string Message { get; } internal ServerChatLogMessage(MessagePart[] parts, string message) : base(parts) { Message = message; } } public class TagsChangedLogMessage : PlayerSpecificLogMessage { public string[] Tags { get; } internal TagsChangedLogMessage(MessagePart[] parts, IPlayerHelper players, int team, int slot, string[] tags) : base(parts, players, team, slot) { Tags = tags; } } public class TutorialLogMessage : LogMessage { internal TutorialLogMessage(MessagePart[] parts) : base(parts) { } } } namespace Archipelago.MultiClient.Net.Helpers { public class ArchipelagoSocketHelper : BaseArchipelagoSocketHelper<ClientWebSocket>, IArchipelagoSocketHelper { public Uri Uri { get; } internal ArchipelagoSocketHelper(Uri hostUri) : base(CreateWebSocket(), 1024) { Uri = hostUri; SecurityProtocolType securityProtocolType = SecurityProtocolType.Tls13; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12 | securityProtocolType; } private static ClientWebSocket CreateWebSocket() { return new ClientWebSocket(); } public async Task ConnectAsync() { await ConnectToProvidedUri(Uri); StartPolling(); } private async Task ConnectToProvidedUri(Uri uri) { if (uri.Scheme != "unspecified") { try { await Socket.ConnectAsync(uri, CancellationToken.None); return; } catch (Exception e) { OnError(e); throw; } } List<Exception> errors = new List<Exception>(0); try { await Socket.ConnectAsync(uri.AsWss(), CancellationToken.None); if (Socket.State == WebSocketState.Open) { return; } } catch (Exception item) { errors.Add(item); Socket = CreateWebSocket(); } try { await Socket.ConnectAsync(uri.AsWs(), CancellationToken.None); } catch (Exception item2) { errors.Add(item2); OnError(new AggregateException(errors)); throw; } } } public class BaseArchipelagoSocketHelper<T> where T : WebSocket { private static readonly ArchipelagoPacketConverter Converter = new ArchipelagoPacketConverter(); private readonly BlockingCollection<Tuple<ArchipelagoPacketBase, TaskCompletionSource<bool>>> sendQueue = new BlockingCollection<Tuple<ArchipelagoPacketBase, TaskCompletionSource<bool>>>(); internal T Socket; private readonly int bufferSize; public bool Connected { get { if (Socket.State != WebSocketState.Open) { return Socket.State == WebSocketState.CloseReceived; } return true; } } public event ArchipelagoSocketHelperDelagates.PacketReceivedHandler PacketReceived; public event ArchipelagoSocketHelperDelagates.PacketsSentHandler PacketsSent; public event ArchipelagoSocketHelperDelagates.ErrorReceivedHandler ErrorReceived; public event ArchipelagoSocketHelperDelagates.SocketClosedHandler SocketClosed; public event ArchipelagoSocketHelperDelagates.SocketOpenedHandler SocketOpened; internal BaseArchipelagoSocketHelper(T socket, int bufferSize = 1024) { Socket = socket; this.bufferSize = bufferSize; } internal void StartPolling() { if (this.SocketOpened != null) { this.SocketOpened(); } Task.Run((Func<Task?>)PollingLoop); Task.Run((Func<Task?>)SendLoop); } private async Task PollingLoop() { byte[] buffer = new byte[bufferSize]; while (Socket.State == WebSocketState.Open) { string message = null; try { message = await ReadMessageAsync(buffer); } catch (Exception e) { OnError(e); } OnMessageReceived(message); } } private async Task SendLoop() { while (Socket.State == WebSocketState.Open) { try { await HandleSendBuffer(); } catch (Exception e) { OnError(e); } await Task.Delay(20); } } private async Task<string> ReadMessageAsync(byte[] buffer) { using MemoryStream readStream = new MemoryStream(buffer.Length); WebSocketReceiveResult result; do { result = await Socket.ReceiveAsync(new ArraySegment<byte>(buffer), CancellationToken.None); if (result.MessageType == WebSocketMessageType.Close) { try { await Socket.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None); } catch { } OnSocketClosed(); } else { readStream.Write(buffer, 0, result.Count); } } while (!result.EndOfMessage); return Encoding.UTF8.GetString(readStream.ToArray()); } public async Task DisconnectAsync() { await Socket.CloseAsync(WebSocketCloseStatus.NormalClosure, "Closure requested by client", CancellationToken.None); OnSocketClosed(); } public void SendPacket(ArchipelagoPacketBase packet) { SendMultiplePackets(new List<ArchipelagoPacketBase> { packet }); } public void SendMultiplePackets(List<ArchipelagoPacketBase> packets) { SendMultiplePackets(packets.ToArray()); } public void SendMultiplePackets(params ArchipelagoPacketBase[] packets) { SendMultiplePacketsAsync(packets).Wait(); } public Task SendPacketAsync(ArchipelagoPacketBase packet) { return SendMultiplePacketsAsync(new List<ArchipelagoPacketBase> { packet }); } public Task SendMultiplePacketsAsync(List<ArchipelagoPacketBase> packets) { return SendMultiplePacketsAsync(packets.ToArray()); } public Task SendMultiplePacketsAsync(params ArchipelagoPacketBase[] packets) { TaskCompletionSource<bool> taskCompletionSource = new TaskCompletionSource<bool>(); foreach (ArchipelagoPacketBase item in packets) { sendQueue.Add(new Tuple<ArchipelagoPacketBase, TaskCompletionSource<bool>>(item, taskCompletionSource)); } return taskCompletionSource.Task; } private async Task HandleSendBuffer() { List<ArchipelagoPacketBase> list = new List<ArchipelagoPacketBase>(); List<TaskCompletionSource<bool>> tasks = new List<TaskCompletionSource<bool>>(); Tuple<ArchipelagoPacketBase, TaskCompletionSource<bool>> tuple = sendQueue.Take(); list.Add(tuple.Item1); tasks.Add(tuple.Item2); Tuple<ArchipelagoPacketBase, TaskCompletionSource<bool>> item; while (sendQueue.TryTake(out item)) { list.Add(item.Item1); tasks.Add(item.Item2); } if (!list.Any()) { return; } if (Socket.State != WebSocketState.Open) { throw new ArchipelagoSocketClosedException(); } ArchipelagoPacketBase[] packets = list.ToArray(); string s = JsonConvert.SerializeObject((object)packets); byte[] messageBuffer = Encoding.UTF8.GetBytes(s); int messagesCount = (int)Math.Ceiling((double)messageBuffer.Length / (double)bufferSize); for (int i = 0; i < messagesCount; i++) { int num = bufferSize * i; int num2 = bufferSize; bool endOfMessage = i + 1 == messagesCount; if (num2 * (i + 1) > messageBuffer.Length) { num2 = messageBuffer.Length - num; } await Socket.SendAsync(new ArraySegment<byte>(messageBuffer, num, num2), WebSocketMessageType.Text, endOfMessage, CancellationToken.None); } foreach (TaskCompletionSource<bool> item2 in tasks) { item2.TrySetResult(result: true); } OnPacketSend(packets); } private void OnPacketSend(ArchipelagoPacketBase[] packets) { try { if (this.PacketsSent != null) { this.PacketsSent(packets); } } catch (Exception e) { OnError(e); } } private void OnSocketClosed() { try { if (this.SocketClosed != null) { this.SocketClosed(""); } } catch (Exception e) { OnError(e); } } private void OnMessageReceived(string message) { try { if (string.IsNullOrEmpty(message) || this.PacketReceived == null) { return; } List<ArchipelagoPacketBase> list = null; try { list = JsonConvert.DeserializeObject<List<ArchipelagoPacketBase>>(message, (JsonConverter[])(object)new JsonConverter[1] { Converter }); } catch (Exception e) { OnError(e); } if (list == null) { return; } foreach (ArchipelagoPacketBase item in list) { this.PacketReceived(item); } } catch (Exception e2) { OnError(e2); } } protected void OnError(Exception e) { try { if (this.ErrorReceived != null) { this.ErrorReceived(e, e.Message); } } catch (Exception ex) { Console.Out.WriteLine("Error occured during reporting of errorOuter Errror: " + e.Message + " " + e.StackTrace + "Inner Errror: " + ex.Message + " " + ex.StackTrace); } } } public interface IConnectionInfoProvider { string Game { get; } int Team { get; } int Slot { get; } string[] Tags { get; } ItemsHandlingFlags ItemsHandlingFlags { get; } string Uuid { get; } void UpdateConnectionOptions(string[] tags); void UpdateConnectionOptions(ItemsHandlingFlags itemsHandlingFlags); void UpdateConnectionOptions(string[] tags, ItemsHandlingFlags itemsHandlingFlags); } public class ConnectionInfoHelper : IConnectionInfoProvider { private readonly IArchipelagoSocketHelper socket; public string Game { get; private set; } public int Team { get; private set; } public int Slot { get; private set; } public string[] Tags { get; internal set; } public ItemsHandlingFlags ItemsHandlingFlags { get; internal set; } public string Uuid { get; private set; } internal ConnectionInfoHelper(IArchipelagoSocketHelper socket) { this.socket = socket; Reset(); socket.PacketReceived += PacketReceived; } private void PacketReceived(ArchipelagoPacketBase packet) { if (!(packet is ConnectedPacket connectedPacket)) { if (packet is ConnectionRefusedPacket) { Reset(); } return; } Team = connectedPacket.Team; Slot = connectedPacket.Slot; if (connectedPacket.SlotInfo != null && connectedPacket.SlotInfo.ContainsKey(Slot)) { Game = connectedPacket.SlotInfo[Slot].Game; } } internal void SetConnectionParameters(string game, string[] tags, ItemsHandlingFlags itemsHandlingFlags, string uuid) { Game = game; Tags = tags ?? new string[0]; ItemsHandlingFlags = itemsHandlingFlags; Uuid = uuid ?? Guid.NewGuid().ToString(); } private void Reset() { Game = null; Team = -1; Slot = -1; Tags = new string[0]; ItemsHandlingFlags = ItemsHandlingFlags.NoItems; Uuid = null; } public void UpdateConnectionOptions(string[] tags) { UpdateConnectionOptions(tags, ItemsHandlingFlags); } public void UpdateConnectionOptions(ItemsHandlingFlags itemsHandlingFlags) { UpdateConnectionOptions(Tags, ItemsHandlingFlags); } public void UpdateConnectionOptions(string[] tags, ItemsHandlingFlags itemsHandlingFlags) { SetConnectionParameters(Game, tags, itemsHandlingFlags, Uuid); socket.SendPacket(new ConnectUpdatePacket { Tags = Tags, ItemsHandling = ItemsHandlingFlags }); } } public interface IDataStorageHelper : IDataStorageWrapper { DataStorageElement this[Scope scope, string key] { get; set; } DataStorageElement this[string key] { get; set; } } public class DataStorageHelper : IDataStorageHelper, IDataStorageWrapper { public delegate void DataStorageUpdatedHandler(JToken originalValue, JToken newValue, Dictionary<string, JToken> additionalArguments); private readonly Dictionary<string, DataStorageUpdatedHandler> onValueChangedEventHandlers = new Dictionary<string, DataStorageUpdatedHandler>(); private readonly Dictionary<Guid, DataStorageUpdatedHandler> operationSpecificCallbacks = new Dictionary<Guid, DataStorageUpdatedHandler>(); private readonly Dictionary<string, TaskCompletionSource<JToken>> asyncRetrievalTasks = new Dictionary<string, TaskCompletionSource<JToken>>(); private readonly IArchipelagoSocketHelper socket; private readonly IConnectionInfoProvider connectionInfoProvider; public DataStorageElement this[Scope scope, string key] { get { return this[AddScope(scope, key)]; } set { this[AddScope(scope, key)] = value; } } public DataStorageElement this[string key] { get { return new DataStorageElement(GetContextForKey(key)); } set { SetValue(key, value); } } internal DataStorageHelper(IArchipelagoSocketHelper socket, IConnectionInfoProvider connectionInfoProvider) { this.socket = socket; this.connectionInfoProvider = connectionInfoProvider; socket.PacketReceived += OnPacketReceived; } private void OnPacketReceived(ArchipelagoPacketBase packet) { //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Invalid comparison between Unknown and I4 if (!(packet is RetrievedPacket retrievedPacket)) { if (packet is SetReplyPacket setReplyPacket) { if (setReplyPacket.AdditionalArguments != null && setReplyPacket.AdditionalArguments.ContainsKey("Reference") && (int)setReplyPacket.AdditionalArguments["Reference"].Type == 8 && ((string)setReplyPacket.AdditionalArguments["Reference"]).TryParseNGuid(out var g) && operationSpecificCallbacks.TryGetValue(g, out var value)) { value(setReplyPacket.OriginalValue, setReplyPacket.Value, setReplyPacket.AdditionalArguments); operationSpecificCallbacks.Remove(g); } if (onValueChangedEventHandlers.TryGetValue(setReplyPacket.Key, out var value2)) { value2(setReplyPacket.OriginalValue, setReplyPacket.Value, setReplyPacket.AdditionalArguments); } } return; } foreach (KeyValuePair<string, JToken> datum in retrievedPacket.Data) { if (asyncRetrievalTasks.TryGetValue(datum.Key, out var value3)) { value3.TrySetResult(datum.Value); asyncRetrievalTasks.Remove(datum.Key); } } } private Task<JToken> GetAsync(string key) { if (asyncRetrievalTasks.TryGetValue(key, out var value)) { return value.Task; } TaskCompletionSource<JToken> taskCompletionSource = new TaskCompletionSource<JToken>(); asyncRetrievalTasks[key] = taskCompletionSource; socket.SendPacketAsync(new GetPacket { Keys = new string[1] { key } }); return taskCompletionSource.Task; } private void Initialize(string key, JToken value) { socket.SendPacketAsync(new SetPacket { Key = key, DefaultValue = value, Operations = new OperationSpecification[1] { new OperationSpecification { OperationType = OperationType.Default } } }); } private JToken GetValue(string key) { Task<JToken> async = GetAsync(key); if (!async.Wait(TimeSpan.FromSeconds(2.0))) { throw new TimeoutException("Timed out retrieving data for key `" + key + "`. This may be due to an attempt to retrieve a value from the DataStorageHelper in a synchronous fashion from within a PacketReceived handler. When using the DataStorageHelper from within code which runs on the websocket thread then use the asynchronous getters. Ex: `DataStorageHelper[\"" + key + "\"].GetAsync().ContinueWith(x => {});`Be aware that DataStorageHelper calls tend to cause packet responses, so making a call from within a PacketReceived handler may cause an infinite loop."); } return async.Result; } private void SetValue(string key, DataStorageElement e) { if (key.StartsWith("_read_")) { throw new InvalidOperationException("DataStorage write operation on readonly key '" + key + "' is not allowed"); } if (e == null) { e = new DataStorageElement(OperationType.Replace, (JToken)(object)JValue.CreateNull()); } if (e.Context == null) { e.Context = GetContextForKey(key); } else if (e.Context.Key != key) { e.Operations.Insert(0, new OperationSpecification { OperationType = OperationType.Replace, Value = GetValue(e.Context.Key) }); } Dictionary<string, JToken> dictionary = e.AdditionalArguments ?? new Dictionary<string, JToken>(0); if (e.Callbacks != null) { Guid key2 = Guid.NewGuid(); operationSpecificCallbacks[key2] = e.Callbacks; dictionary["Reference"] = JToken.op_Implicit(key2.ToString("N")); socket.SendPacketAsync(new SetPacket { Key = key, Operations = e.Operations.ToArray(), WantReply = true, AdditionalArguments = dictionary }); } else { socket.SendPacketAsync(new SetPacket { Key = key, Operations = e.Operations.ToArray(), AdditionalArguments = dictionary }); } } private DataStorageElementContext GetContextForKey(string key) { return new DataStorageElementContext { Key = key, GetData = GetValue, GetAsync = GetAsync, Initialize = Initialize, AddHandler = AddHandler, RemoveHandler = RemoveHandler }; } private void AddHandler(string key, DataStorageUpdatedHandler handler) { if (onValueChangedEventHandlers.ContainsKey(key)) { Dictionary<string, DataStorageUpdatedHandler> dictionary = onValueChangedEventHandlers; dictionary[key] = (DataStorageUpdatedHandler)Delegate.Combine(dictionary[key], handler); } else { onValueChangedEventHandlers[key] = handler; } socket.SendPacketAsync(new SetNotifyPacket { Keys = new string[1] { key } }); } private void RemoveHandler(string key, DataStorageUpdatedHandler handler) { if (onValueChangedEventHandlers.ContainsKey(key)) { Dictionary<string, DataStorageUpdatedHandler> dictionary = onValueChangedEventHandlers; dictionary[key] = (DataStorageUpdatedHandler)Delegate.Remove(dictionary[key], handler); if (onValueChangedEventHandlers[key] == null) { onValueChangedEventHandlers.Remove(key); } } } private string AddScope(Scope scope, string key) { return scope switch { Scope.Global => key, Scope.Game => $"{scope}:{connectionInfoProvider.Game}:{key}", Scope.Team => $"{scope}:{connectionInfoProvider.Team}:{key}", Scope.Slot => $"{scope}:{connectionInfoProvider.Slot}:{key}", Scope.ReadOnly => "_read_" + key, _ => throw new ArgumentOutOfRangeException("scope", scope, "Invalid scope for key " + key), }; } private DataStorageElement GetHintsElement(int? slot = null, int? team = null) { return this[Scope.ReadOnly, $"hints_{team ?? connectionInfoProvider.Team}_{slot ?? connectionInfoProvider.Slot}"]; } private DataStorageElement GetSlotDataElement(int? slot = null) { return this[Scope.ReadOnly, $"slot_data_{slot ?? connectionInfoProvider.Slot}"]; } private DataStorageElement GetItemNameGroupsElement(string game = null) { return this[Scope.ReadOnly, "item_name_groups_" + (game ?? connectionInfoProvider.Game)]; } private DataStorageElement GetLocationNameGroupsElement(string game = null) { return this[Scope.ReadOnly, "location_name_groups_" + (game ?? connectionInfoProvider.Game)]; } private DataStorageElement GetClientStatusElement(int? slot = null, int? team = null) { return this[Scope.ReadOnly, $"client_status_{team ?? connectionInfoProvider.Team}_{slot ?? connectionInfoProvider.Slot}"]; } private DataStorageElement GetRaceModeElement() { return this[Scope.ReadOnly, "race_mode"]; } public Hint[] GetHints(int? slot = null, int? team = null) { return GetHintsElement(slot, team).To<Hint[]>(); } public Task<Hint[]> GetHintsAsync(int? slot = null, int? team = null) { return GetHintsElement(slot, team).GetAsync<Hint[]>(); } public void TrackHints(Action<Hint[]> onHintsUpdated, bool retrieveCurrentlyUnlockedHints = true, int? slot = null, int? team = null) { GetHintsElement(slot, team).OnValueChanged += delegate(JToken _, JToken newValue, Dictionary<string, JToken> x) { onHintsUpdated(newValue.ToObject<Hint[]>()); }; if (retrieveCurrentlyUnlockedHints) { GetHintsAsync(slot, team).ContinueWith(delegate(Task<Hint[]> t) { onHintsUpdated(t.Result); }); } } public Dictionary<string, object> GetSlotData(int? slot = null) { return GetSlotData<Dictionary<string, object>>(slot); } public T GetSlotData<T>(int? slot = null) where T : class { return GetSlotDataElement(slot).To<T>(); } public Task<Dictionary<string, object>> GetSlotDataAsync(int? slot = null) { return GetSlotDataAsync<Dictionary<string, object>>(slot); } public Task<T> GetSlotDataAsync<T>(int? slot = null) where T : class { return GetSlotDataElement(slot).GetAsync<T>(); } public Dictionary<string, string[]> GetItemNameGroups(string game = null) { return GetItemNameGroupsElement(game).To<Dictionary<string, string[]>>(); } public Task<Dictionary<string, string[]>> GetItemNameGroupsAsync(string game = null) { return GetItemNameGroupsElement(game).GetAsync<Dictionary<string, string[]>>(); } public Dictionary<string, string[]> GetLocationNameGroups(string game = null) { return GetLocationNameGroupsElement(game).To<Dictionary<string, string[]>>(); } public Task<Dictionary<string, string[]>> GetLocationNameGroupsAsync(string game = null) { return GetLocationNameGroupsElement(game).GetAsync<Dictionary<string, string[]>>(); } public ArchipelagoClientState GetClientStatus(int? slot = null, int? team = null) { return GetClientStatusElement(slot, team).To<ArchipelagoClientState?>().GetValueOrDefault(); } public Task<ArchipelagoClientState> GetClientStatusAsync(int? slot = null, int? team = null) { return GetClientStatusElement(slot, team).GetAsync<ArchipelagoClientState?>().ContinueWith((Task<ArchipelagoClientState?> r) => r.Result.GetValueOrDefault()); } public void TrackClientStatus(Action<ArchipelagoClientState> onStatusUpdated, bool retrieveCurrentClientStatus = true, int? slot = null, int? team = null) { Get
plugins/Newtonsoft.Json.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
#define DEBUG using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; using System.Data; using System.Data.SqlTypes; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Dynamic; using System.Globalization; using System.IO; using System.Linq; using System.Linq.Expressions; using System.Numerics; using System.Reflection; using System.Reflection.Emit; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Xml; using System.Xml.Linq; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Bson; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq.JsonPath; using Newtonsoft.Json.Schema; using Newtonsoft.Json.Serialization; using Newtonsoft.Json.Utilities; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AllowPartiallyTrustedCallers] [assembly: InternalsVisibleTo("Newtonsoft.Json.Schema")] [assembly: InternalsVisibleTo("Newtonsoft.Json.Tests")] [assembly: InternalsVisibleTo("Newtonsoft.Json.Dynamic, PublicKey=0024000004800000940000000602000000240000525341310004000001000100cbd8d53b9d7de30f1f1278f636ec462cf9c254991291e66ebb157a885638a517887633b898ccbcf0d5c5ff7be85a6abe9e765d0ac7cd33c68dac67e7e64530e8222101109f154ab14a941c490ac155cd1d4fcba0fabb49016b4ef28593b015cab5937da31172f03f67d09edda404b88a60023f062ae71d0b2e4438b74cc11dc9")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("9ca358aa-317b-4925-8ada-4a29e943a363")] [assembly: CLSCompliant(true)] [assembly: TargetFramework(".NETFramework,Version=v4.5", FrameworkDisplayName = ".NET Framework 4.5")] [assembly: AssemblyCompany("Newtonsoft")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyCopyright("Copyright © James Newton-King 2008")] [assembly: AssemblyDescription("Json.NET is a popular high-performance JSON framework for .NET")] [assembly: AssemblyFileVersion("11.0.1")] [assembly: AssemblyInformationalVersion("11.0.1-beta2+0eb477a285cdf06aa7bf5e103583768eba37fed6")] [assembly: AssemblyProduct("Json.NET")] [assembly: AssemblyTitle("Json.NET")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ArchipelagoMW/Archipelago.MultiClient.Net.git")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: AssemblyVersion("11.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class IsReadOnlyAttribute : Attribute { } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace System.Diagnostics.CodeAnalysis { [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, AllowMultiple = true)] internal sealed class NotNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false)] internal sealed class NotNullWhenAttribute : Attribute { public bool ReturnValue { get; } public NotNullWhenAttribute(bool returnValue) { ReturnValue = returnValue; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter | AttributeTargets.ReturnValue, Inherited = false)] internal sealed class MaybeNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, Inherited = false)] internal sealed class AllowNullAttribute : Attribute { } [AttributeUsage(AttributeTargets.Parameter, Inherited = false)] internal class DoesNotReturnIfAttribute : Attribute { public bool ParameterValue { get; } public DoesNotReturnIfAttribute(bool parameterValue) { ParameterValue = parameterValue; } } } namespace Newtonsoft.Json { public enum ConstructorHandling { Default, AllowNonPublicDefaultConstructor } public enum DateFormatHandling { IsoDateFormat, MicrosoftDateFormat } public enum DateParseHandling { None, DateTime, DateTimeOffset } public enum DateTimeZoneHandling { Local, Utc, Unspecified, RoundtripKind } public class DefaultJsonNameTable : JsonNameTable { private class Entry { internal readonly string Value; internal readonly int HashCode; internal Entry Next; internal Entry(string value, int hashCode, Entry next) { Value = value; HashCode = hashCode; Next = next; } } private static readonly int HashCodeRandomizer; private int _count; private Entry[] _entries; private int _mask = 31; static DefaultJsonNameTable() { HashCodeRandomizer = Environment.TickCount; } public DefaultJsonNameTable() { _entries = new Entry[_mask + 1]; } public override string? Get(char[] key, int start, int length) { if (length == 0) { return string.Empty; } int num = length + HashCodeRandomizer; num += (num << 7) ^ key[start]; int num2 = start + length; for (int i = start + 1; i < num2; i++) { num += (num << 7) ^ key[i]; } num -= num >> 17; num -= num >> 11; num -= num >> 5; int num3 = num & _mask; Entry[] entries = _entries; for (Entry entry = entries[num3]; entry != null; entry = entry.Next) { if (entry.HashCode == num && TextEquals(entry.Value, key, start, length)) { return entry.Value; } } return null; } public string Add(string key) { if (key == null) { throw new ArgumentNullException("key"); } int length = key.Length; if (length == 0) { return string.Empty; } int num = length + HashCodeRandomizer; for (int i = 0; i < key.Length; i++) { num += (num << 7) ^ key[i]; } num -= num >> 17; num -= num >> 11; num -= num >> 5; for (Entry entry = _entries[num & _mask]; entry != null; entry = entry.Next) { if (entry.HashCode == num && entry.Value.Equals(key, StringComparison.Ordinal)) { return entry.Value; } } return AddEntry(key, num); } private string AddEntry(string str, int hashCode) { int num = hashCode & _mask; Entry entry = new Entry(str, hashCode, _entries[num]); _entries[num] = entry; if (_count++ == _mask) { Grow(); } return entry.Value; } private void Grow() { Entry[] entries = _entries; int num = _mask * 2 + 1; Entry[] array = new Entry[num + 1]; for (int i = 0; i < entries.Length; i++) { Entry entry = entries[i]; while (entry != null) { int num2 = entry.HashCode & num; Entry next = entry.Next; entry.Next = array[num2]; array[num2] = entry; entry = next; } } _entries = array; _mask = num; } private static bool TextEquals(string str1, char[] str2, int str2Start, int str2Length) { if (str1.Length != str2Length) { return false; } for (int i = 0; i < str1.Length; i++) { if (str1[i] != str2[str2Start + i]) { return false; } } return true; } } [Flags] public enum DefaultValueHandling { Include = 0, Ignore = 1, Populate = 2, IgnoreAndPopulate = 3 } public enum FloatFormatHandling { String, Symbol, DefaultValue } public enum FloatParseHandling { Double, Decimal } public enum Formatting { None, Indented } public interface IArrayPool<T> { T[] Rent(int minimumLength); void Return(T[]? array); } public interface IJsonLineInfo { int LineNumber { get; } int LinePosition { get; } bool HasLineInfo(); } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)] public sealed class JsonArrayAttribute : JsonContainerAttribute { private bool _allowNullItems; public bool AllowNullItems { get { return _allowNullItems; } set { _allowNullItems = value; } } public JsonArrayAttribute() { } public JsonArrayAttribute(bool allowNullItems) { _allowNullItems = allowNullItems; } public JsonArrayAttribute(string id) : base(id) { } } [AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false)] public sealed class JsonConstructorAttribute : Attribute { } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)] public abstract class JsonContainerAttribute : Attribute { internal bool? _isReference; internal bool? _itemIsReference; internal ReferenceLoopHandling? _itemReferenceLoopHandling; internal TypeNameHandling? _itemTypeNameHandling; private Type? _namingStrategyType; private object[]? _namingStrategyParameters; public string? Id { get; set; } public string? Title { get; set; } public string? Description { get; set; } public Type? ItemConverterType { get; set; } public object[]? ItemConverterParameters { get; set; } public Type? NamingStrategyType { get { return _namingStrategyType; } set { _namingStrategyType = value; NamingStrategyInstance = null; } } public object[]? NamingStrategyParameters { get { return _namingStrategyParameters; } set { _namingStrategyParameters = value; NamingStrategyInstance = null; } } internal NamingStrategy? NamingStrategyInstance { get; set; } public bool IsReference { get { return _isReference.GetValueOrDefault(); } set { _isReference = value; } } public bool ItemIsReference { get { return _itemIsReference.GetValueOrDefault(); } set { _itemIsReference = value; } } public ReferenceLoopHandling ItemReferenceLoopHandling { get { return _itemReferenceLoopHandling.GetValueOrDefault(); } set { _itemReferenceLoopHandling = value; } } public TypeNameHandling ItemTypeNameHandling { get { return _itemTypeNameHandling.GetValueOrDefault(); } set { _itemTypeNameHandling = value; } } protected JsonContainerAttribute() { } protected JsonContainerAttribute(string id) { Id = id; } } public static class JsonConvert { public static readonly string True = "true"; public static readonly string False = "false"; public static readonly string Null = "null"; public static readonly string Undefined = "undefined"; public static readonly string PositiveInfinity = "Infinity"; public static readonly string NegativeInfinity = "-Infinity"; public static readonly string NaN = "NaN"; public static Func<JsonSerializerSettings>? DefaultSettings { get; set; } public static string ToString(DateTime value) { return ToString(value, DateFormatHandling.IsoDateFormat, DateTimeZoneHandling.RoundtripKind); } public static string ToString(DateTime value, DateFormatHandling format, DateTimeZoneHandling timeZoneHandling) { DateTime value2 = DateTimeUtils.EnsureDateTime(value, timeZoneHandling); using StringWriter stringWriter = StringUtils.CreateStringWriter(64); stringWriter.Write('"'); DateTimeUtils.WriteDateTimeString(stringWriter, value2, format, null, CultureInfo.InvariantCulture); stringWriter.Write('"'); return stringWriter.ToString(); } public static string ToString(DateTimeOffset value) { return ToString(value, DateFormatHandling.IsoDateFormat); } public static string ToString(DateTimeOffset value, DateFormatHandling format) { using StringWriter stringWriter = StringUtils.CreateStringWriter(64); stringWriter.Write('"'); DateTimeUtils.WriteDateTimeOffsetString(stringWriter, value, format, null, CultureInfo.InvariantCulture); stringWriter.Write('"'); return stringWriter.ToString(); } public static string ToString(bool value) { return value ? True : False; } public static string ToString(char value) { return ToString(char.ToString(value)); } public static string ToString(Enum value) { return value.ToString("D"); } public static string ToString(int value) { return value.ToString(null, CultureInfo.InvariantCulture); } public static string ToString(short value) { return value.ToString(null, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public static string ToString(ushort value) { return value.ToString(null, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public static string ToString(uint value) { return value.ToString(null, CultureInfo.InvariantCulture); } public static string ToString(long value) { return value.ToString(null, CultureInfo.InvariantCulture); } private static string ToStringInternal(BigInteger value) { return value.ToString(null, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public static string ToString(ulong value) { return value.ToString(null, CultureInfo.InvariantCulture); } public static string ToString(float value) { return EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)); } internal static string ToString(float value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable) { return EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable); } private static string EnsureFloatFormat(double value, string text, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable) { if (floatFormatHandling == FloatFormatHandling.Symbol || (!double.IsInfinity(value) && !double.IsNaN(value))) { return text; } if (floatFormatHandling == FloatFormatHandling.DefaultValue) { return (!nullable) ? "0.0" : Null; } return quoteChar + text + quoteChar; } public static string ToString(double value) { return EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)); } internal static string ToString(double value, FloatFormatHandling floatFormatHandling, char quoteChar, bool nullable) { return EnsureFloatFormat(value, EnsureDecimalPlace(value, value.ToString("R", CultureInfo.InvariantCulture)), floatFormatHandling, quoteChar, nullable); } private static string EnsureDecimalPlace(double value, string text) { if (double.IsNaN(value) || double.IsInfinity(value) || text.IndexOf('.') != -1 || text.IndexOf('E') != -1 || text.IndexOf('e') != -1) { return text; } return text + ".0"; } private static string EnsureDecimalPlace(string text) { if (text.IndexOf('.') != -1) { return text; } return text + ".0"; } public static string ToString(byte value) { return value.ToString(null, CultureInfo.InvariantCulture); } [CLSCompliant(false)] public static string ToString(sbyte value) { return value.ToString(null, CultureInfo.InvariantCulture); } public static string ToString(decimal value) { return EnsureDecimalPlace(value.ToString(null, CultureInfo.InvariantCulture)); } public static string ToString(Guid value) { return ToString(value, '"'); } internal static string ToString(Guid value, char quoteChar) { string text = value.ToString("D", CultureInfo.InvariantCulture); string text2 = quoteChar.ToString(CultureInfo.InvariantCulture); return text2 + text + text2; } public static string ToString(TimeSpan value) { return ToString(value, '"'); } internal static string ToString(TimeSpan value, char quoteChar) { return ToString(value.ToString(), quoteChar); } public static string ToString(Uri? value) { if (value == null) { return Null; } return ToString(value, '"'); } internal static string ToString(Uri value, char quoteChar) { return ToString(value.OriginalString, quoteChar); } public static string ToString(string? value) { return ToString(value, '"'); } public static string ToString(string? value, char delimiter) { return ToString(value, delimiter, StringEscapeHandling.Default); } public static string ToString(string? value, char delimiter, StringEscapeHandling stringEscapeHandling) { if (delimiter != '"' && delimiter != '\'') { throw new ArgumentException("Delimiter must be a single or double quote.", "delimiter"); } return JavaScriptUtils.ToEscapedJavaScriptString(value, delimiter, appendDelimiters: true, stringEscapeHandling); } public static string ToString(object? value) { if (value == null) { return Null; } return ConvertUtils.GetTypeCode(value.GetType()) switch { PrimitiveTypeCode.String => ToString((string)value), PrimitiveTypeCode.Char => ToString((char)value), PrimitiveTypeCode.Boolean => ToString((bool)value), PrimitiveTypeCode.SByte => ToString((sbyte)value), PrimitiveTypeCode.Int16 => ToString((short)value), PrimitiveTypeCode.UInt16 => ToString((ushort)value), PrimitiveTypeCode.Int32 => ToString((int)value), PrimitiveTypeCode.Byte => ToString((byte)value), PrimitiveTypeCode.UInt32 => ToString((uint)value), PrimitiveTypeCode.Int64 => ToString((long)value), PrimitiveTypeCode.UInt64 => ToString((ulong)value), PrimitiveTypeCode.Single => ToString((float)value), PrimitiveTypeCode.Double => ToString((double)value), PrimitiveTypeCode.DateTime => ToString((DateTime)value), PrimitiveTypeCode.Decimal => ToString((decimal)value), PrimitiveTypeCode.DBNull => Null, PrimitiveTypeCode.DateTimeOffset => ToString((DateTimeOffset)value), PrimitiveTypeCode.Guid => ToString((Guid)value), PrimitiveTypeCode.Uri => ToString((Uri)value), PrimitiveTypeCode.TimeSpan => ToString((TimeSpan)value), PrimitiveTypeCode.BigInteger => ToStringInternal((BigInteger)value), _ => throw new ArgumentException("Unsupported type: {0}. Use the JsonSerializer class to get the object's JSON representation.".FormatWith(CultureInfo.InvariantCulture, value.GetType())), }; } [DebuggerStepThrough] public static string SerializeObject(object? value) { return SerializeObject(value, (Type?)null, (JsonSerializerSettings?)null); } [DebuggerStepThrough] public static string SerializeObject(object? value, Formatting formatting) { return SerializeObject(value, formatting, (JsonSerializerSettings?)null); } [DebuggerStepThrough] public static string SerializeObject(object? value, params JsonConverter[] converters) { JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings { Converters = converters } : null); return SerializeObject(value, null, settings); } [DebuggerStepThrough] public static string SerializeObject(object? value, Formatting formatting, params JsonConverter[] converters) { JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings { Converters = converters } : null); return SerializeObject(value, null, formatting, settings); } [DebuggerStepThrough] public static string SerializeObject(object? value, JsonSerializerSettings? settings) { return SerializeObject(value, null, settings); } [DebuggerStepThrough] public static string SerializeObject(object? value, Type? type, JsonSerializerSettings? settings) { JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings); return SerializeObjectInternal(value, type, jsonSerializer); } [DebuggerStepThrough] public static string SerializeObject(object? value, Formatting formatting, JsonSerializerSettings? settings) { return SerializeObject(value, null, formatting, settings); } [DebuggerStepThrough] public static string SerializeObject(object? value, Type? type, Formatting formatting, JsonSerializerSettings? settings) { JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings); jsonSerializer.Formatting = formatting; return SerializeObjectInternal(value, type, jsonSerializer); } private static string SerializeObjectInternal(object? value, Type? type, JsonSerializer jsonSerializer) { StringBuilder sb = new StringBuilder(256); StringWriter stringWriter = new StringWriter(sb, CultureInfo.InvariantCulture); using (JsonTextWriter jsonTextWriter = new JsonTextWriter(stringWriter)) { jsonTextWriter.Formatting = jsonSerializer.Formatting; jsonSerializer.Serialize(jsonTextWriter, value, type); } return stringWriter.ToString(); } [DebuggerStepThrough] public static object? DeserializeObject(string value) { return DeserializeObject(value, (Type?)null, (JsonSerializerSettings?)null); } [DebuggerStepThrough] public static object? DeserializeObject(string value, JsonSerializerSettings settings) { return DeserializeObject(value, null, settings); } [DebuggerStepThrough] public static object? DeserializeObject(string value, Type type) { return DeserializeObject(value, type, (JsonSerializerSettings?)null); } [DebuggerStepThrough] public static T? DeserializeObject<T>(string value) { return JsonConvert.DeserializeObject<T>(value, (JsonSerializerSettings?)null); } [DebuggerStepThrough] public static T? DeserializeAnonymousType<T>(string value, T anonymousTypeObject) { return DeserializeObject<T>(value); } [DebuggerStepThrough] public static T? DeserializeAnonymousType<T>(string value, T anonymousTypeObject, JsonSerializerSettings settings) { return DeserializeObject<T>(value, settings); } [DebuggerStepThrough] public static T? DeserializeObject<T>(string value, params JsonConverter[] converters) { return (T)DeserializeObject(value, typeof(T), converters); } [DebuggerStepThrough] public static T? DeserializeObject<T>(string value, JsonSerializerSettings? settings) { return (T)DeserializeObject(value, typeof(T), settings); } [DebuggerStepThrough] public static object? DeserializeObject(string value, Type type, params JsonConverter[] converters) { JsonSerializerSettings settings = ((converters != null && converters.Length != 0) ? new JsonSerializerSettings { Converters = converters } : null); return DeserializeObject(value, type, settings); } public static object? DeserializeObject(string value, Type? type, JsonSerializerSettings? settings) { ValidationUtils.ArgumentNotNull(value, "value"); JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings); if (!jsonSerializer.IsCheckAdditionalContentSet()) { jsonSerializer.CheckAdditionalContent = true; } using JsonTextReader reader = new JsonTextReader(new StringReader(value)); return jsonSerializer.Deserialize(reader, type); } [DebuggerStepThrough] public static void PopulateObject(string value, object target) { PopulateObject(value, target, null); } public static void PopulateObject(string value, object target, JsonSerializerSettings? settings) { JsonSerializer jsonSerializer = JsonSerializer.CreateDefault(settings); using JsonReader jsonReader = new JsonTextReader(new StringReader(value)); jsonSerializer.Populate(jsonReader, target); if (settings == null || !settings.CheckAdditionalContent) { return; } while (jsonReader.Read()) { if (jsonReader.TokenType != JsonToken.Comment) { throw JsonSerializationException.Create(jsonReader, "Additional text found in JSON string after finishing deserializing object."); } } } public static string SerializeXmlNode(XmlNode? node) { return SerializeXmlNode(node, Formatting.None); } public static string SerializeXmlNode(XmlNode? node, Formatting formatting) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter(); return SerializeObject(node, formatting, xmlNodeConverter); } public static string SerializeXmlNode(XmlNode? node, Formatting formatting, bool omitRootObject) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter { OmitRootObject = omitRootObject }; return SerializeObject(node, formatting, xmlNodeConverter); } public static XmlDocument? DeserializeXmlNode(string value) { return DeserializeXmlNode(value, null); } public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName) { return DeserializeXmlNode(value, deserializeRootElementName, writeArrayAttribute: false); } public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName, bool writeArrayAttribute) { return DeserializeXmlNode(value, deserializeRootElementName, writeArrayAttribute, encodeSpecialCharacters: false); } public static XmlDocument? DeserializeXmlNode(string value, string? deserializeRootElementName, bool writeArrayAttribute, bool encodeSpecialCharacters) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter(); xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName; xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute; xmlNodeConverter.EncodeSpecialCharacters = encodeSpecialCharacters; return (XmlDocument)DeserializeObject(value, typeof(XmlDocument), xmlNodeConverter); } public static string SerializeXNode(XObject? node) { return SerializeXNode(node, Formatting.None); } public static string SerializeXNode(XObject? node, Formatting formatting) { return SerializeXNode(node, formatting, omitRootObject: false); } public static string SerializeXNode(XObject? node, Formatting formatting, bool omitRootObject) { XmlNodeConverter xmlNodeConverter = new XmlNodeConverter { OmitRootObject = omitRootObject }; return SerializeObject(node, formatting, xmlNodeConverter); } public static XDocument? DeserializeXNode(string value) { return DeserializeXNode(value, null); } public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName) { return DeserializeXNode(value, deserializeRootElementName, writeArrayAttribute: false); } public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName, bool writeArrayAttribute) { return DeserializeXNode(value, deserializeRootElementName, writeArrayAttribute, encodeSpecialCharacters: false); } public static XDocument? DeserializeXNode(string value, string? deserializeRootElementName, bool writeArrayAttribute, bool encodeSpecialCharacters) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown XmlNodeConverter xmlNodeConverter = new XmlNodeConverter(); xmlNodeConverter.DeserializeRootElementName = deserializeRootElementName; xmlNodeConverter.WriteArrayAttribute = writeArrayAttribute; xmlNodeConverter.EncodeSpecialCharacters = encodeSpecialCharacters; return (XDocument)DeserializeObject(value, typeof(XDocument), xmlNodeConverter); } } public abstract class JsonConverter { public virtual bool CanRead => true; public virtual bool CanWrite => true; public abstract void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer); public abstract object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer); public abstract bool CanConvert(Type objectType); } public abstract class JsonConverter<T> : JsonConverter { public sealed override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { if (!((value != null) ? (value is T) : ReflectionUtils.IsNullable(typeof(T)))) { throw new JsonSerializationException("Converter cannot write specified value to JSON. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T))); } WriteJson(writer, (T)value, serializer); } public abstract void WriteJson(JsonWriter writer, T? value, JsonSerializer serializer); public sealed override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { bool flag = existingValue == null; if (!flag && !(existingValue is T)) { throw new JsonSerializationException("Converter cannot read JSON with the specified existing value. {0} is required.".FormatWith(CultureInfo.InvariantCulture, typeof(T))); } return ReadJson(reader, objectType, flag ? default(T) : ((T)existingValue), !flag, serializer); } public abstract T? ReadJson(JsonReader reader, Type objectType, T? existingValue, bool hasExistingValue, JsonSerializer serializer); public sealed override bool CanConvert(Type objectType) { return typeof(T).IsAssignableFrom(objectType); } } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Interface | AttributeTargets.Parameter, AllowMultiple = false)] public sealed class JsonConverterAttribute : Attribute { private readonly Type _converterType; public Type ConverterType => _converterType; public object[]? ConverterParameters { get; } public JsonConverterAttribute(Type converterType) { if (converterType == null) { throw new ArgumentNullException("converterType"); } _converterType = converterType; } public JsonConverterAttribute(Type converterType, params object[] converterParameters) : this(converterType) { ConverterParameters = converterParameters; } } public class JsonConverterCollection : Collection<JsonConverter> { } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface, AllowMultiple = false)] public sealed class JsonDictionaryAttribute : JsonContainerAttribute { public JsonDictionaryAttribute() { } public JsonDictionaryAttribute(string id) : base(id) { } } [Serializable] public class JsonException : Exception { public JsonException() { } public JsonException(string message) : base(message) { } public JsonException(string message, Exception? innerException) : base(message, innerException) { } public JsonException(SerializationInfo info, StreamingContext context) : base(info, context) { } internal static JsonException Create(IJsonLineInfo lineInfo, string path, string message) { message = JsonPosition.FormatMessage(lineInfo, path, message); return new JsonException(message); } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] public class JsonExtensionDataAttribute : Attribute { public bool WriteData { get; set; } public bool ReadData { get; set; } public JsonExtensionDataAttribute() { WriteData = true; ReadData = true; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] public sealed class JsonIgnoreAttribute : Attribute { } public abstract class JsonNameTable { public abstract string? Get(char[] key, int start, int length); } [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, AllowMultiple = false)] public sealed class JsonObjectAttribute : JsonContainerAttribute { private MemberSerialization _memberSerialization = MemberSerialization.OptOut; internal MissingMemberHandling? _missingMemberHandling; internal Required? _itemRequired; internal NullValueHandling? _itemNullValueHandling; public MemberSerialization MemberSerialization { get { return _memberSerialization; } set { _memberSerialization = value; } } public MissingMemberHandling MissingMemberHandling { get { return _missingMemberHandling.GetValueOrDefault(); } set { _missingMemberHandling = value; } } public NullValueHandling ItemNullValueHandling { get { return _itemNullValueHandling.GetValueOrDefault(); } set { _itemNullValueHandling = value; } } public Required ItemRequired { get { return _itemRequired.GetValueOrDefault(); } set { _itemRequired = value; } } public JsonObjectAttribute() { } public JsonObjectAttribute(MemberSerialization memberSerialization) { MemberSerialization = memberSerialization; } public JsonObjectAttribute(string id) : base(id) { } } internal enum JsonContainerType { None, Object, Array, Constructor } internal struct JsonPosition { private static readonly char[] SpecialCharacters = new char[18] { '.', ' ', '\'', '/', '"', '[', ']', '(', ')', '\t', '\n', '\r', '\f', '\b', '\\', '\u0085', '\u2028', '\u2029' }; internal JsonContainerType Type; internal int Position; internal string? PropertyName; internal bool HasIndex; public JsonPosition(JsonContainerType type) { Type = type; HasIndex = TypeHasIndex(type); Position = -1; PropertyName = null; } internal int CalculateLength() { switch (Type) { case JsonContainerType.Object: return PropertyName.Length + 5; case JsonContainerType.Array: case JsonContainerType.Constructor: return MathUtils.IntLength((ulong)Position) + 2; default: throw new ArgumentOutOfRangeException("Type"); } } internal void WriteTo(StringBuilder sb, ref StringWriter? writer, ref char[]? buffer) { switch (Type) { case JsonContainerType.Object: { string propertyName = PropertyName; if (propertyName.IndexOfAny(SpecialCharacters) != -1) { sb.Append("['"); if (writer == null) { writer = new StringWriter(sb); } JavaScriptUtils.WriteEscapedJavaScriptString(writer, propertyName, '\'', appendDelimiters: false, JavaScriptUtils.SingleQuoteCharEscapeFlags, StringEscapeHandling.Default, null, ref buffer); sb.Append("']"); } else { if (sb.Length > 0) { sb.Append('.'); } sb.Append(propertyName); } break; } case JsonContainerType.Array: case JsonContainerType.Constructor: sb.Append('['); sb.Append(Position); sb.Append(']'); break; } } internal static bool TypeHasIndex(JsonContainerType type) { return type == JsonContainerType.Array || type == JsonContainerType.Constructor; } internal static string BuildPath(List<JsonPosition> positions, JsonPosition? currentPosition) { int num = 0; if (positions != null) { for (int i = 0; i < positions.Count; i++) { num += positions[i].CalculateLength(); } } if (currentPosition.HasValue) { num += currentPosition.GetValueOrDefault().CalculateLength(); } StringBuilder stringBuilder = new StringBuilder(num); StringWriter writer = null; char[] buffer = null; if (positions != null) { foreach (JsonPosition position in positions) { position.WriteTo(stringBuilder, ref writer, ref buffer); } } currentPosition?.WriteTo(stringBuilder, ref writer, ref buffer); return stringBuilder.ToString(); } internal static string FormatMessage(IJsonLineInfo? lineInfo, string path, string message) { if (!message.EndsWith(Environment.NewLine, StringComparison.Ordinal)) { message = message.Trim(); if (!StringUtils.EndsWith(message, '.')) { message += "."; } message += " "; } message += "Path '{0}'".FormatWith(CultureInfo.InvariantCulture, path); if (lineInfo != null && lineInfo.HasLineInfo()) { message += ", line {0}, position {1}".FormatWith(CultureInfo.InvariantCulture, lineInfo.LineNumber, lineInfo.LinePosition); } message += "."; return message; } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)] public sealed class JsonPropertyAttribute : Attribute { internal NullValueHandling? _nullValueHandling; internal DefaultValueHandling? _defaultValueHandling; internal ReferenceLoopHandling? _referenceLoopHandling; internal ObjectCreationHandling? _objectCreationHandling; internal TypeNameHandling? _typeNameHandling; internal bool? _isReference; internal int? _order; internal Required? _required; internal bool? _itemIsReference; internal ReferenceLoopHandling? _itemReferenceLoopHandling; internal TypeNameHandling? _itemTypeNameHandling; public Type? ItemConverterType { get; set; } public object[]? ItemConverterParameters { get; set; } public Type? NamingStrategyType { get; set; } public object[]? NamingStrategyParameters { get; set; } public NullValueHandling NullValueHandling { get { return _nullValueHandling.GetValueOrDefault(); } set { _nullValueHandling = value; } } public DefaultValueHandling DefaultValueHandling { get { return _defaultValueHandling.GetValueOrDefault(); } set { _defaultValueHandling = value; } } public ReferenceLoopHandling ReferenceLoopHandling { get { return _referenceLoopHandling.GetValueOrDefault(); } set { _referenceLoopHandling = value; } } public ObjectCreationHandling ObjectCreationHandling { get { return _objectCreationHandling.GetValueOrDefault(); } set { _objectCreationHandling = value; } } public TypeNameHandling TypeNameHandling { get { return _typeNameHandling.GetValueOrDefault(); } set { _typeNameHandling = value; } } public bool IsReference { get { return _isReference.GetValueOrDefault(); } set { _isReference = value; } } public int Order { get { return _order.GetValueOrDefault(); } set { _order = value; } } public Required Required { get { return _required.GetValueOrDefault(); } set { _required = value; } } public string? PropertyName { get; set; } public ReferenceLoopHandling ItemReferenceLoopHandling { get { return _itemReferenceLoopHandling.GetValueOrDefault(); } set { _itemReferenceLoopHandling = value; } } public TypeNameHandling ItemTypeNameHandling { get { return _itemTypeNameHandling.GetValueOrDefault(); } set { _itemTypeNameHandling = value; } } public bool ItemIsReference { get { return _itemIsReference.GetValueOrDefault(); } set { _itemIsReference = value; } } public JsonPropertyAttribute() { } public JsonPropertyAttribute(string propertyName) { PropertyName = propertyName; } } public abstract class JsonReader : IDisposable { protected internal enum State { Start, Complete, Property, ObjectStart, Object, ArrayStart, Array, Closed, PostValue, ConstructorStart, Constructor, Error, Finished } private JsonToken _tokenType; private object? _value; internal char _quoteChar; internal State _currentState; private JsonPosition _currentPosition; private CultureInfo? _culture; private DateTimeZoneHandling _dateTimeZoneHandling; private int? _maxDepth; private bool _hasExceededMaxDepth; internal DateParseHandling _dateParseHandling; internal FloatParseHandling _floatParseHandling; private string? _dateFormatString; private List<JsonPosition>? _stack; protected State CurrentState => _currentState; public bool CloseInput { get; set; } public bool SupportMultipleContent { get; set; } public virtual char QuoteChar { get { return _quoteChar; } protected internal set { _quoteChar = value; } } public DateTimeZoneHandling DateTimeZoneHandling { get { return _dateTimeZoneHandling; } set { if (value < DateTimeZoneHandling.Local || value > DateTimeZoneHandling.RoundtripKind) { throw new ArgumentOutOfRangeException("value"); } _dateTimeZoneHandling = value; } } public DateParseHandling DateParseHandling { get { return _dateParseHandling; } set { if (value < DateParseHandling.None || value > DateParseHandling.DateTimeOffset) { throw new ArgumentOutOfRangeException("value"); } _dateParseHandling = value; } } public FloatParseHandling FloatParseHandling { get { return _floatParseHandling; } set { if (value < FloatParseHandling.Double || value > FloatParseHandling.Decimal) { throw new ArgumentOutOfRangeException("value"); } _floatParseHandling = value; } } public string? DateFormatString { get { return _dateFormatString; } set { _dateFormatString = value; } } public int? MaxDepth { get { return _maxDepth; } set { if (value <= 0) { throw new ArgumentException("Value must be positive.", "value"); } _maxDepth = value; } } public virtual JsonToken TokenType => _tokenType; public virtual object? Value => _value; public virtual Type? ValueType => _value?.GetType(); public virtual int Depth { get { int num = _stack?.Count ?? 0; if (JsonTokenUtils.IsStartToken(TokenType) || _currentPosition.Type == JsonContainerType.None) { return num; } return num + 1; } } public virtual string Path { get { if (_currentPosition.Type == JsonContainerType.None) { return string.Empty; } JsonPosition? currentPosition = ((_currentState != State.ArrayStart && _currentState != State.ConstructorStart && _currentState != State.ObjectStart) ? new JsonPosition?(_currentPosition) : null); return JsonPosition.BuildPath(_stack, currentPosition); } } public CultureInfo Culture { get { return _culture ?? CultureInfo.InvariantCulture; } set { _culture = value; } } public virtual Task<bool> ReadAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<bool>() ?? Read().ToAsync(); } public async Task SkipAsync(CancellationToken cancellationToken = default(CancellationToken)) { if (TokenType == JsonToken.PropertyName) { await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false); } if (JsonTokenUtils.IsStartToken(TokenType)) { int depth = Depth; while (await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false) && depth < Depth) { } } } internal async Task ReaderReadAndAssertAsync(CancellationToken cancellationToken) { if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false))) { throw CreateUnexpectedEndException(); } } public virtual Task<bool?> ReadAsBooleanAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<bool?>() ?? Task.FromResult(ReadAsBoolean()); } public virtual Task<byte[]?> ReadAsBytesAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<byte[]>() ?? Task.FromResult(ReadAsBytes()); } internal async Task<byte[]?> ReadArrayIntoByteArrayAsync(CancellationToken cancellationToken) { List<byte> buffer = new List<byte>(); do { if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false))) { SetToken(JsonToken.None); } } while (!ReadArrayElementIntoByteArrayReportDone(buffer)); byte[] d = buffer.ToArray(); SetToken(JsonToken.Bytes, d, updateIndex: false); return d; } public virtual Task<DateTime?> ReadAsDateTimeAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<DateTime?>() ?? Task.FromResult(ReadAsDateTime()); } public virtual Task<DateTimeOffset?> ReadAsDateTimeOffsetAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<DateTimeOffset?>() ?? Task.FromResult(ReadAsDateTimeOffset()); } public virtual Task<decimal?> ReadAsDecimalAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<decimal?>() ?? Task.FromResult(ReadAsDecimal()); } public virtual Task<double?> ReadAsDoubleAsync(CancellationToken cancellationToken = default(CancellationToken)) { return Task.FromResult(ReadAsDouble()); } public virtual Task<int?> ReadAsInt32Async(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<int?>() ?? Task.FromResult(ReadAsInt32()); } public virtual Task<string?> ReadAsStringAsync(CancellationToken cancellationToken = default(CancellationToken)) { return cancellationToken.CancelIfRequestedAsync<string>() ?? Task.FromResult(ReadAsString()); } internal async Task<bool> ReadAndMoveToContentAsync(CancellationToken cancellationToken) { bool flag = await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false); if (flag) { flag = await MoveToContentAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false); } return flag; } internal Task<bool> MoveToContentAsync(CancellationToken cancellationToken) { JsonToken tokenType = TokenType; JsonToken jsonToken = tokenType; if (jsonToken == JsonToken.None || jsonToken == JsonToken.Comment) { return MoveToContentFromNonContentAsync(cancellationToken); } return AsyncUtils.True; } private async Task<bool> MoveToContentFromNonContentAsync(CancellationToken cancellationToken) { JsonToken jsonToken2; do { if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false))) { return false; } JsonToken tokenType = TokenType; JsonToken jsonToken = tokenType; jsonToken2 = jsonToken; } while (jsonToken2 == JsonToken.None || jsonToken2 == JsonToken.Comment); return true; } internal JsonPosition GetPosition(int depth) { if (_stack != null && depth < _stack.Count) { return _stack[depth]; } return _currentPosition; } protected JsonReader() { _currentState = State.Start; _dateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind; _dateParseHandling = DateParseHandling.DateTime; _floatParseHandling = FloatParseHandling.Double; _maxDepth = 64; CloseInput = true; } private void Push(JsonContainerType value) { UpdateScopeWithFinishedValue(); if (_currentPosition.Type == JsonContainerType.None) { _currentPosition = new JsonPosition(value); return; } if (_stack == null) { _stack = new List<JsonPosition>(); } _stack.Add(_currentPosition); _currentPosition = new JsonPosition(value); if (!_maxDepth.HasValue || !(Depth + 1 > _maxDepth) || _hasExceededMaxDepth) { return; } _hasExceededMaxDepth = true; throw JsonReaderException.Create(this, "The reader's MaxDepth of {0} has been exceeded.".FormatWith(CultureInfo.InvariantCulture, _maxDepth)); } private JsonContainerType Pop() { JsonPosition currentPosition; if (_stack != null && _stack.Count > 0) { currentPosition = _currentPosition; _currentPosition = _stack[_stack.Count - 1]; _stack.RemoveAt(_stack.Count - 1); } else { currentPosition = _currentPosition; _currentPosition = default(JsonPosition); } if (_maxDepth.HasValue && Depth <= _maxDepth) { _hasExceededMaxDepth = false; } return currentPosition.Type; } private JsonContainerType Peek() { return _currentPosition.Type; } public abstract bool Read(); public virtual int? ReadAsInt32() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Integer: case JsonToken.Float: { object value = Value; if (value is int value2) { return value2; } int num; if (value is BigInteger bigInteger) { num = (int)bigInteger; } else { try { num = Convert.ToInt32(value, CultureInfo.InvariantCulture); } catch (Exception ex) { throw JsonReaderException.Create(this, "Could not convert to integer: {0}.".FormatWith(CultureInfo.InvariantCulture, value), ex); } } SetToken(JsonToken.Integer, num, updateIndex: false); return num; } case JsonToken.String: { string s = (string)Value; return ReadInt32String(s); } default: throw JsonReaderException.Create(this, "Error reading integer. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal int? ReadInt32String(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (int.TryParse(s, NumberStyles.Integer, Culture, out var result)) { SetToken(JsonToken.Integer, result, updateIndex: false); return result; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to integer: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual string? ReadAsString() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.String: return (string)Value; default: if (JsonTokenUtils.IsPrimitiveToken(contentToken)) { object value = Value; if (value != null) { string text = ((!(value is IFormattable formattable)) ? ((value is Uri uri) ? uri.OriginalString : value.ToString()) : formattable.ToString(null, Culture)); SetToken(JsonToken.String, text, updateIndex: false); return text; } } throw JsonReaderException.Create(this, "Error reading string. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } public virtual byte[]? ReadAsBytes() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.StartObject: { ReadIntoWrappedTypeObject(); byte[] array3 = ReadAsBytes(); ReaderReadAndAssert(); if (TokenType != JsonToken.EndObject) { throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType)); } SetToken(JsonToken.Bytes, array3, updateIndex: false); return array3; } case JsonToken.String: { string text = (string)Value; Guid g; byte[] array2 = ((text.Length == 0) ? CollectionUtils.ArrayEmpty<byte>() : ((!ConvertUtils.TryConvertGuid(text, out g)) ? Convert.FromBase64String(text) : g.ToByteArray())); SetToken(JsonToken.Bytes, array2, updateIndex: false); return array2; } case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Bytes: if (Value is Guid guid) { byte[] array = guid.ToByteArray(); SetToken(JsonToken.Bytes, array, updateIndex: false); return array; } return (byte[])Value; case JsonToken.StartArray: return ReadArrayIntoByteArray(); default: throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal byte[] ReadArrayIntoByteArray() { List<byte> list = new List<byte>(); do { if (!Read()) { SetToken(JsonToken.None); } } while (!ReadArrayElementIntoByteArrayReportDone(list)); byte[] array = list.ToArray(); SetToken(JsonToken.Bytes, array, updateIndex: false); return array; } private bool ReadArrayElementIntoByteArrayReportDone(List<byte> buffer) { switch (TokenType) { case JsonToken.None: throw JsonReaderException.Create(this, "Unexpected end when reading bytes."); case JsonToken.Integer: buffer.Add(Convert.ToByte(Value, CultureInfo.InvariantCulture)); return false; case JsonToken.EndArray: return true; case JsonToken.Comment: return false; default: throw JsonReaderException.Create(this, "Unexpected token when reading bytes: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType)); } } public virtual double? ReadAsDouble() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Integer: case JsonToken.Float: { object value = Value; if (value is double value2) { return value2; } double num = ((!(value is BigInteger bigInteger) || 1 == 0) ? Convert.ToDouble(value, CultureInfo.InvariantCulture) : ((double)bigInteger)); SetToken(JsonToken.Float, num, updateIndex: false); return num; } case JsonToken.String: return ReadDoubleString((string)Value); default: throw JsonReaderException.Create(this, "Error reading double. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal double? ReadDoubleString(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (double.TryParse(s, NumberStyles.Float | NumberStyles.AllowThousands, Culture, out var result)) { SetToken(JsonToken.Float, result, updateIndex: false); return result; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to double: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual bool? ReadAsBoolean() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Integer: case JsonToken.Float: { bool flag = ((!(Value is BigInteger bigInteger) || 1 == 0) ? Convert.ToBoolean(Value, CultureInfo.InvariantCulture) : (bigInteger != 0L)); SetToken(JsonToken.Boolean, flag, updateIndex: false); return flag; } case JsonToken.String: return ReadBooleanString((string)Value); case JsonToken.Boolean: return (bool)Value; default: throw JsonReaderException.Create(this, "Error reading boolean. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal bool? ReadBooleanString(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (bool.TryParse(s, out var result)) { SetToken(JsonToken.Boolean, result, updateIndex: false); return result; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to boolean: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual decimal? ReadAsDecimal() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Integer: case JsonToken.Float: { object value = Value; if (value is decimal value2) { return value2; } decimal num; if (value is BigInteger bigInteger) { num = (decimal)bigInteger; } else { try { num = Convert.ToDecimal(value, CultureInfo.InvariantCulture); } catch (Exception ex) { throw JsonReaderException.Create(this, "Could not convert to decimal: {0}.".FormatWith(CultureInfo.InvariantCulture, value), ex); } } SetToken(JsonToken.Float, num, updateIndex: false); return num; } case JsonToken.String: return ReadDecimalString((string)Value); default: throw JsonReaderException.Create(this, "Error reading decimal. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal decimal? ReadDecimalString(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (decimal.TryParse(s, NumberStyles.Number, Culture, out var result)) { SetToken(JsonToken.Float, result, updateIndex: false); return result; } if (ConvertUtils.DecimalTryParse(s.ToCharArray(), 0, s.Length, out result) == ParseResult.Success) { SetToken(JsonToken.Float, result, updateIndex: false); return result; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to decimal: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual DateTime? ReadAsDateTime() { switch (GetContentToken()) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Date: if (Value is DateTimeOffset dateTimeOffset) { SetToken(JsonToken.Date, dateTimeOffset.DateTime, updateIndex: false); } return (DateTime)Value; case JsonToken.String: return ReadDateTimeString((string)Value); default: throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType)); } } internal DateTime? ReadDateTimeString(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (DateTimeUtils.TryParseDateTime(s, DateTimeZoneHandling, _dateFormatString, Culture, out var dt)) { dt = DateTimeUtils.EnsureDateTime(dt, DateTimeZoneHandling); SetToken(JsonToken.Date, dt, updateIndex: false); return dt; } if (DateTime.TryParse(s, Culture, DateTimeStyles.RoundtripKind, out dt)) { dt = DateTimeUtils.EnsureDateTime(dt, DateTimeZoneHandling); SetToken(JsonToken.Date, dt, updateIndex: false); return dt; } throw JsonReaderException.Create(this, "Could not convert string to DateTime: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } public virtual DateTimeOffset? ReadAsDateTimeOffset() { JsonToken contentToken = GetContentToken(); switch (contentToken) { case JsonToken.None: case JsonToken.Null: case JsonToken.EndArray: return null; case JsonToken.Date: if (Value is DateTime dateTime) { SetToken(JsonToken.Date, new DateTimeOffset(dateTime), updateIndex: false); } return (DateTimeOffset)Value; case JsonToken.String: { string s = (string)Value; return ReadDateTimeOffsetString(s); } default: throw JsonReaderException.Create(this, "Error reading date. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, contentToken)); } } internal DateTimeOffset? ReadDateTimeOffsetString(string? s) { if (StringUtils.IsNullOrEmpty(s)) { SetToken(JsonToken.Null, null, updateIndex: false); return null; } if (DateTimeUtils.TryParseDateTimeOffset(s, _dateFormatString, Culture, out var dt)) { SetToken(JsonToken.Date, dt, updateIndex: false); return dt; } if (DateTimeOffset.TryParse(s, Culture, DateTimeStyles.RoundtripKind, out dt)) { SetToken(JsonToken.Date, dt, updateIndex: false); return dt; } SetToken(JsonToken.String, s, updateIndex: false); throw JsonReaderException.Create(this, "Could not convert string to DateTimeOffset: {0}.".FormatWith(CultureInfo.InvariantCulture, s)); } internal void ReaderReadAndAssert() { if (!Read()) { throw CreateUnexpectedEndException(); } } internal JsonReaderException CreateUnexpectedEndException() { return JsonReaderException.Create(this, "Unexpected end when reading JSON."); } internal void ReadIntoWrappedTypeObject() { ReaderReadAndAssert(); if (Value != null && Value.ToString() == "$type") { ReaderReadAndAssert(); if (Value != null && Value.ToString().StartsWith("System.Byte[]", StringComparison.Ordinal)) { ReaderReadAndAssert(); if (Value.ToString() == "$value") { return; } } } throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, JsonToken.StartObject)); } public void Skip() { if (TokenType == JsonToken.PropertyName) { Read(); } if (JsonTokenUtils.IsStartToken(TokenType)) { int depth = Depth; while (Read() && depth < Depth) { } } } protected void SetToken(JsonToken newToken) { SetToken(newToken, null, updateIndex: true); } protected void SetToken(JsonToken newToken, object? value) { SetToken(newToken, value, updateIndex: true); } protected void SetToken(JsonToken newToken, object? value, bool updateIndex) { _tokenType = newToken; _value = value; switch (newToken) { case JsonToken.StartObject: _currentState = State.ObjectStart; Push(JsonContainerType.Object); break; case JsonToken.StartArray: _currentState = State.ArrayStart; Push(JsonContainerType.Array); break; case JsonToken.StartConstructor: _currentState = State.ConstructorStart; Push(JsonContainerType.Constructor); break; case JsonToken.EndObject: ValidateEnd(JsonToken.EndObject); break; case JsonToken.EndArray: ValidateEnd(JsonToken.EndArray); break; case JsonToken.EndConstructor: ValidateEnd(JsonToken.EndConstructor); break; case JsonToken.PropertyName: _currentState = State.Property; _currentPosition.PropertyName = (string)value; break; case JsonToken.Raw: case JsonToken.Integer: case JsonToken.Float: case JsonToken.String: case JsonToken.Boolean: case JsonToken.Null: case JsonToken.Undefined: case JsonToken.Date: case JsonToken.Bytes: SetPostValueState(updateIndex); break; case JsonToken.Comment: break; } } internal void SetPostValueState(bool updateIndex) { if (Peek() != 0 || SupportMultipleContent) { _currentState = State.PostValue; } else { SetFinished(); } if (updateIndex) { UpdateScopeWithFinishedValue(); } } private void UpdateScopeWithFinishedValue() { if (_currentPosition.HasIndex) { _currentPosition.Position++; } } private void ValidateEnd(JsonToken endToken) { JsonContainerType jsonContainerType = Pop(); if (GetTypeForCloseToken(endToken) != jsonContainerType) { throw JsonReaderException.Create(this, "JsonToken {0} is not valid for closing JsonType {1}.".FormatWith(CultureInfo.InvariantCulture, endToken, jsonContainerType)); } if (Peek() != 0 || SupportMultipleContent) { _currentState = State.PostValue; } else { SetFinished(); } } protected void SetStateBasedOnCurrent() { JsonContainerType jsonContainerType = Peek(); switch (jsonContainerType) { case JsonContainerType.Object: _currentState = State.Object; break; case JsonContainerType.Array: _currentState = State.Array; break; case JsonContainerType.Constructor: _currentState = State.Constructor; break; case JsonContainerType.None: SetFinished(); break; default: throw JsonReaderException.Create(this, "While setting the reader state back to current object an unexpected JsonType was encountered: {0}".FormatWith(CultureInfo.InvariantCulture, jsonContainerType)); } } private void SetFinished() { _currentState = ((!SupportMultipleContent) ? State.Finished : State.Start); } private JsonContainerType GetTypeForCloseToken(JsonToken token) { return token switch { JsonToken.EndObject => JsonContainerType.Object, JsonToken.EndArray => JsonContainerType.Array, JsonToken.EndConstructor => JsonContainerType.Constructor, _ => throw JsonReaderException.Create(this, "Not a valid close JsonToken: {0}".FormatWith(CultureInfo.InvariantCulture, token)), }; } void IDisposable.Dispose() { Dispose(disposing: true); GC.SuppressFinalize(this); } protected virtual void Dispose(bool disposing) { if (_currentState != State.Closed && disposing) { Close(); } } public virtual void Close() { _currentState = State.Closed; _tokenType = JsonToken.None; _value = null; } internal void ReadAndAssert() { if (!Read()) { throw JsonSerializationException.Create(this, "Unexpected end when reading JSON."); } } internal void ReadForTypeAndAssert(JsonContract? contract, bool hasConverter) { if (!ReadForType(contract, hasConverter)) { throw JsonSerializationException.Create(this, "Unexpected end when reading JSON."); } } internal bool ReadForType(JsonContract? contract, bool hasConverter) { if (hasConverter) { return Read(); } switch (contract?.InternalReadType ?? ReadType.Read) { case ReadType.Read: return ReadAndMoveToContent(); case ReadType.ReadAsInt32: ReadAsInt32(); break; case ReadType.ReadAsInt64: { bool result = ReadAndMoveToContent(); if (TokenType == JsonToken.Undefined) { throw JsonReaderException.Create(this, "An undefined token is not a valid {0}.".FormatWith(CultureInfo.InvariantCulture, contract?.UnderlyingType ?? typeof(long))); } return result; } case ReadType.ReadAsDecimal: ReadAsDecimal(); break; case ReadType.ReadAsDouble: ReadAsDouble(); break; case ReadType.ReadAsBytes: ReadAsBytes(); break; case ReadType.ReadAsBoolean: ReadAsBoolean(); break; case ReadType.ReadAsString: ReadAsString(); break; case ReadType.ReadAsDateTime: ReadAsDateTime(); break; case ReadType.ReadAsDateTimeOffset: ReadAsDateTimeOffset(); break; default: throw new ArgumentOutOfRangeException(); } return TokenType != JsonToken.None; } internal bool ReadAndMoveToContent() { return Read() && MoveToContent(); } internal bool MoveToContent() { JsonToken tokenType = TokenType; while (tokenType == JsonToken.None || tokenType == JsonToken.Comment) { if (!Read()) { return false; } tokenType = TokenType; } return true; } private JsonToken GetContentToken() { JsonToken tokenType; do { if (!Read()) { SetToken(JsonToken.None); return JsonToken.None; } tokenType = TokenType; } while (tokenType == JsonToken.Comment); return tokenType; } } [Serializable] public class JsonReaderException : JsonException { public int LineNumber { get; } public int LinePosition { get; } public string? Path { get; } public JsonReaderException() { } public JsonReaderException(string message) : base(message) { } public JsonReaderException(string message, Exception innerException) : base(message, innerException) { } public JsonReaderException(SerializationInfo info, StreamingContext context) : base(info, context) { } public JsonReaderException(string message, string path, int lineNumber, int linePosition, Exception? innerException) : base(message, innerException) { Path = path; LineNumber = lineNumber; LinePosition = linePosition; } internal static JsonReaderException Create(JsonReader reader, string message) { return Create(reader, message, null); } internal static JsonReaderException Create(JsonReader reader, string message, Exception? ex) { return Create(reader as IJsonLineInfo, reader.Path, message, ex); } internal static JsonReaderException Create(IJsonLineInfo? lineInfo, string path, string message, Exception? ex) { message = JsonPosition.FormatMessage(lineInfo, path, message); int lineNumber; int linePosition; if (lineInfo != null && lineInfo.HasLineInfo()) { lineNumber = lineInfo.LineNumber; linePosition = lineInfo.LinePosition; } else { lineNumber = 0; linePosition = 0; } return new JsonReaderException(message, path, lineNumber, linePosition, ex); } } [AttributeUsage(AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false)] public sealed class JsonRequiredAttribute : Attribute { } [Serializable] public class JsonSerializationException : JsonException { public int LineNumber { get; } public int LinePosition { get; } public string? Path { get; } public JsonSerializationException() { } public JsonSerializationException(string message) : base(message) { } public JsonSerializationException(string message, Exception innerException) : base(message, innerException) { } public JsonSerializationException(SerializationInfo info, StreamingContext context) : base(info, context) { } public JsonSerializationException(string message, string path, int lineNumber, int linePosition, Exception? innerException) : base(message, innerException) { Path = path; LineNumber = lineNumber; LinePosition = linePosition; } internal static JsonSerializationException Create(JsonReader reader, string message) { return Create(reader, message, null); } internal static JsonSerializationException Create(JsonReader reader, string message, Exception? ex) { return Create(reader as IJsonLineInfo, reader.Path, message, ex); } internal static JsonSerializationException Create(IJsonLineInfo? lineInfo, string path, string message, Exception? ex) { message = JsonPosition.FormatMessage(lineInfo, path, message); int lineNumber; int linePosition; if (lineInfo != null && lineInfo.HasLineInfo()) { lineNumber = lineInfo.LineNumber; linePosition = lineInfo.LinePosition; } else { lineNumber = 0; linePosition = 0; } return new JsonSerializationException(message, path, lineNumber, linePosition, ex); } } public class JsonSerializer { internal TypeNameHandling _typeNameHandling; internal TypeNameAssemblyFormatHandling _typeNameAssemblyFormatHandling; internal PreserveReferencesHandling _preserveReferencesHandling; internal ReferenceLoopHandling _referenceLoopHandling; internal MissingMemberHandling _missingMemberHandling; internal ObjectCreationHandling _objectCreationHandling; internal NullValueHandling _nullValueHandling; internal DefaultValueHandling _defaultValueHandling; internal ConstructorHandling _constructorHandling; internal MetadataPropertyHandling _metadataPropertyHandling; internal JsonConverterCollection? _converters; internal IContractResolver _contractResolver; internal ITraceWriter? _traceWriter; internal IEqualityComparer? _equalityComparer; internal ISerializationBinder _serializationBinder; internal StreamingContext _context; private IReferenceResolver? _referenceResolver; private Formatting? _formatting; private DateFormatHandling? _dateFormatHandling; private DateTimeZoneHandling? _dateTimeZoneHandling; private DateParseHandling? _dateParseHandling; private FloatFormatHandling? _floatFormatHandling; private FloatParseHandling? _floatParseHandling; private StringEscapeHandling? _stringEscapeHandling; private CultureInfo _culture; private int? _maxDepth; private bool _maxDepthSet; private bool? _checkAdditionalContent; private string? _dateFormatString; private bool _dateFormatStringSet; public virtual IReferenceResolver? ReferenceResolver { get { return GetReferenceResolver(); } set { if (value == null) { throw new ArgumentNullException("value", "Reference resolver cannot be null."); } _referenceResolver = value; } } [Obsolete("Binder is obsolete. Use SerializationBinder instead.")] public virtual SerializationBinder Binder { get { if (_serializationBinder is SerializationBinder result) { return result; } if (_serializationBinder is SerializationBinderAdapter serializationBinderAdapter) { return serializationBinderAdapter.SerializationBinder; } throw new InvalidOperationException("Cannot get SerializationBinder because an ISerializationBinder was previously set."); } set { if (value == null) { throw new ArgumentNullException("value", "Serialization binder cannot be null."); } _serializationBinder = (value as ISerializationBinder) ?? new SerializationBinderAdapter(value); } } public virtual ISerializationBinder SerializationBinder { get { return _serializationBinder; } set { if (value == null) { throw new ArgumentNullException("value", "Serialization binder cannot be null."); } _serializationBinder = value; } } public virtual ITraceWriter? TraceWriter { get { return _traceWriter; } set { _traceWriter = value; } } public virtual IEqualityComparer? EqualityComparer { get { return _equalityComparer; } set { _equalityComparer = value; } } public virtual TypeNameHandling TypeNameHandling { get { return _typeNameHandling; } set { if (value < TypeNameHandling.None || value > TypeNameHandling.Auto) { throw new ArgumentOutOfRangeException("value"); } _typeNameHandling = value; } } [Obsolete("TypeNameAssemblyFormat is obsolete. Use TypeNameAssemblyFormatHandling instead.")] public virtual FormatterAssemblyStyle TypeNameAssemblyFormat { get { return (FormatterAssemblyStyle)_typeNameAssemblyFormatHandling; } set { if (value < FormatterAssemblyStyle.Simple || value > FormatterAssemblyStyle.Full) { throw new ArgumentOutOfRangeException("value"); } _typeNameAssemblyFormatHandling = (TypeNameAssemblyFormatHandling)value; } } public virtual TypeNameAssemblyFormatHandling TypeNameAssemblyFormatHandling { get { return _typeNameAssemblyFormatHandling; } set { if (value < TypeNameAssemblyFormatHandling.Simple || value > TypeNameAssemblyFormatHandling.Full) { throw new ArgumentOutOfRangeException("value"); } _typeNameAssemblyFormatHandling = value; } } public virtual PreserveReferencesHandling PreserveReferencesHandling { get { return _preserveReferencesHandling; } set { if (value < PreserveReferencesHandling.None || value > PreserveReferencesHandling.All) { throw new ArgumentOutOfRangeException("value"); } _preserveReferencesHandling = value; } } public virtual ReferenceLoopHandling ReferenceLoopHandling { get { return _referenceLoopHandling; } set { if (value < ReferenceLoopHandling.Error || value > ReferenceLoopHandling.Serialize) { throw new ArgumentOutOfRangeException("value"); } _referenceLoopHandling = value; } } public virtual MissingMemberHandling MissingMemberHandling { get { return _missingMemberHandling; } set { if (value < MissingMemberHandling.Ignore || value > MissingMemberHandling.Error) { throw new ArgumentOutOfRangeException("value"); } _missingMemberHandling = value; } } public virtual NullValueHandling NullValueHandling { get { return _nullValueHandling; } set { if (value < NullValueHandling.Include || value > NullValueHandling.Ignore) { throw new ArgumentOutOfRangeException("value"); } _nullValueHandling = value; } } public virtual DefaultValueHandling DefaultValueHandling { get { return _defaultValueHandling; } set { if (value < DefaultValueHandling.Include || value > DefaultValueHandling.IgnoreAndPopulate) { throw new ArgumentOutOfRangeException("value"); } _defaultValueHandling = value; } } public virtual ObjectCreationHandling ObjectCreationHandling { get { return _objectCreationHandling; } set { if (value < ObjectCreationHandling.Auto || value > ObjectCreationHandling.Replace) { throw new ArgumentOutOfRangeException("value"); } _objectCreationHandling = value; } } public virtual ConstructorHandling ConstructorHandling { get { return _constructorHandling; } set { if (value < ConstructorHandling.Default || value > ConstructorHandling.AllowNonPublicDefaultConstructor) { throw new ArgumentOutOfRangeException("value"); } _constructorHandling = value; } } public virtual MetadataPropertyHandling MetadataPropertyHandling { get { return _metadataPropertyHandling; } set { if (value < MetadataPropertyHandling.Default || value > MetadataPropertyHandling.Ignore) { throw new ArgumentOutOfRangeException("value"); } _metadataPropertyHandling = value; } } public virtual JsonConverterCollection Converters { get { if (_converters == null) { _converters = new JsonConverterCollection(); } return _converters; } } public virtual IContractResolver ContractResolver { get { return _contractResolver; } set { _contractResolver = value ?? DefaultContractResolver.Instance; } } public virtual StreamingContext Context { get { return _context; } set { _context = value; } } public virtual Formatting Formatting { get { return _formatting.GetValueOrDefault(); } set { _formatting = value; } } public virtual DateFormatHandling DateFormatHandling { get { return _dateFormatHandling.GetValueOrDefault(); } set { _dateFormatHandling = value; } } public virtual DateTimeZoneHandling DateTimeZoneHandling { get { return _dateTimeZoneHandling ?? DateTimeZoneHandling.RoundtripKind; } set { _dateTimeZoneHandling = value; } } public virtual DateParseHandling DateParseHandling { get { return _dateParseHandling ?? DateParseHandling.DateTime; } set { _dateParseHandling = value; } } public virtual FloatParseHandling FloatParseHandling { get { return _floatParseHandling.GetValueOrDefault(); } set { _floatParseHandling = value; } } public virtual FloatFormatHandling FloatFormatHandling { get { return _floatFormatHandling.GetValueOrDefault(); } set { _floatFormatHandling = value; } } public virtual StringEscapeHandling StringEscapeHandling { get { return _stringEscapeHandling.GetValueOrDefault(); } set { _stringEscapeHandling = value; } } public virtual string DateFormatString { get { return _dateFormatString ?? "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK"; } set { _dateFormatString = value; _dateFormatStringSet = true; } } public virtual CultureInfo Culture { get { return _culture ?? JsonSerializerSettings.DefaultCulture; } set { _culture = value; } } public virtual int? MaxDepth { get { return _maxDepth; } set { if (value <= 0) { throw new ArgumentException("Value must be positive.", "value"); } _maxDepth = value; _maxDepthSet = true; } } public virtual bool CheckAdditionalContent { get { return _checkAdditionalContent.GetValueOrDefault(); } set { _checkAdditionalContent = value; } } public virtual event EventHandler<Newtonsoft.Json.Serialization.ErrorEventArgs>? Error; internal bool IsCheckAdditionalContentSet() { return _checkAdditionalContent.HasValue; } public JsonSerializer() { _referenceLoopHandling = ReferenceLoopHandling.Error; _missingMemberHandling = MissingMemberHandling.Ignore; _nullValueHandling = NullValueHandling.Include; _defaultValueHandling = DefaultValueHandling.Include; _objectCreationHandling = ObjectCreationHandling.Auto; _preserveReferencesHandling = PreserveReferencesHandling.None; _constructorHandling = ConstructorHandling.Default; _typeNameHandling = TypeNameHandling.None; _metadataPropertyHandling = MetadataPropertyHandling.Default; _context = JsonSerializerSettings.DefaultContext; _serializationBinder = DefaultSerializationBinder.Instance; _culture = JsonSerializerSettings.DefaultCulture; _contractResolver = DefaultContractResolver.Instance; } public static JsonSerializer Create() { return new JsonSerializer(); } public static JsonSerializer Create(JsonSerializerSettings? settings) { JsonSerializer jsonSerializer = Create(); if (settings != null) { ApplySerializerSettings(jsonSerializer, settings); } return jsonSerializer; } public static JsonSerializer CreateDefault() { JsonSerializerSettings settings = JsonConvert.DefaultSettings?.Invoke(); return Create(settings); } public static JsonSerializer CreateDefault(JsonSerializerSettings? settings) { JsonSerializer jsonSerializer = CreateDefault(); if (settings != null) { ApplySerializerSettings(jsonSerializer, settings); } return jsonSerializer; } private static void ApplySerializerSettings(JsonSerializer serializer, JsonSerializerSettings settings) { if (!CollectionUtils.IsNullOrEmpty(settings.Converters)) { for (int i = 0; i < settings.Converters.Count; i++) { serializer.Converters.Insert(i, settings.Converters[i]); } } if (settings._typeNameHandling.HasValue) { serializer.TypeNameHandling = settings.TypeNameHandling; } if (settings._metadataPropertyHandling.HasValue) { serializer.MetadataPropertyHandling = settings.MetadataPropertyHandling; } if (settings._typeNameAssemblyFormatHandling.HasValue) { serializer.TypeNameAssemblyFormatHandling = settings.TypeNameAssemblyFormatHandling; } if (settings._preserveReferencesHandling.HasValue) { serializer.PreserveReferencesHandling = settings.PreserveReferencesHandling; } if (settings._referenceLoopHandling.HasValue) { serializer.ReferenceLoopHandling = settings.ReferenceLoopHandling; } if (settings._missingMemberHandling.HasValue) { serializer.MissingMemberHandling = settings.MissingMemberHandling; } if (settings._objectCreationHandling.HasValue) { serializer.ObjectCreationHandling = settings.ObjectCreationHandling; } if (settings._nullValueHandling.HasValue) { serializer.NullValueHandling = settings.NullValueHandling; } if (settings._defaultValueHandling.HasValue) { serializer.DefaultValueHandling = settings.DefaultValueHandling; } if (settings._constructorHandling.HasValue) { serializer.ConstructorHandling = settings.ConstructorHandling; } if (settings._context.HasValue) { serializer.Context = settings.Context; } if (settings._checkAdditionalContent.HasValue) { serializer._checkAdditionalContent = settings._checkAdditionalContent; } if (settings.Error != null) { serializer.Error += settings.Error; } if (settings.ContractResolver != null) { serializer.ContractResolver = settings.ContractResolver; } if (settings.ReferenceResolverProvider != null) { serializer.ReferenceResolver = settings.ReferenceResolverProvider(); } if (settings.TraceWriter != null) { serializer.TraceWriter = settings.TraceWriter; } if (settings.EqualityComparer != null) { serializer.EqualityComparer = settings.EqualityComparer; } if (settings.SerializationBinder != null) { serializer.SerializationBinder = settings.SerializationBinder; } if (settings._formatting.HasValue) { serializer._formatting = settings._formatting; } if (settings._dateFormatHandling.HasValue) { serializer._dateFormatHandling = settings._dateFormatHandling; } if (settings._dateTimeZoneHandling.HasValue) { serializer._dateTimeZoneHandling = settings._dateTimeZoneHandling; } if (settings._dateParseHandling.HasValue) { serializer._dateParseHandling = settings._dateParseHandling; } if (settings._dateFormatStringSet) { serializer._dateFormatString = settings._dateFormatString; serializer._dateFormatStringSet = settings._dateFormatStringSet; } if (settings._floatFormatHandling.HasValue) { serializer._floatFormatHandling = settings._floatFormatHandling; } if (settings._floatParseHandling.HasValue) { serializer._floatParseHandling = settings._floatParseHandling; } if (settings._stringEscapeHandling.HasValue) { serializer._stringEscapeHandling = settings._stringEscapeHandling; } if (settings._culture != null) { serializer._culture = settings._culture; } if (settings._maxDepthSet) { serializer._maxDepth = settings._maxDepth; serializer._maxDepthSet = settings._maxDepthSet; } } [DebuggerStepThrough] public void Populate(TextReader reader, object target) { Populate(new JsonTextReader(reader), target); } [DebuggerStepThrough] public void Populate(JsonReader reader, object target) { PopulateInternal(reader, target); } internal virtual void PopulateInternal(JsonReader reader, object target) { ValidationUtils.ArgumentNotNull(reader, "reader"); ValidationUtils.ArgumentNotNull(target, "target"); SetupReader(reader, out CultureInfo previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string previousDateFormatString); TraceJsonReader traceJsonReader = ((TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Verbose) ? CreateTraceJsonReader(reader) : null); JsonSerializerInternalReader jsonSerializerInternalReader = new JsonSerializerInternalReader(this); jsonSerializerInternalReader.Populate(traceJsonReader ?? reader, target); if (traceJsonReader != null) { TraceWriter.Trace(TraceLevel.Verbose, traceJsonReader.GetDeserializedJsonMessage(), null); } ResetReader(reader, previousCulture, previousDateTimeZoneHandling, previousDateParseHandling, previousFloatParseHandling, previousMaxDepth, previousDateFormatString); } [DebuggerStepThrough] public object? Deserialize(JsonReader reader) { return Deserialize(reader, null); } [DebuggerStepThrough] public object? Deserialize(TextReader reader, Type objectType) { return Deserialize(new JsonTextReader(reader), objectType); } [DebuggerStepThrough] public T? Deserialize<T>(JsonReader reader) { return (T)Deserialize(reader, typeof(T)); } [DebuggerStepThrough] public object? Deserialize(JsonReader reader, Type? objectType) { return DeserializeInternal(reader, objectType); } internal virtual object? DeserializeInternal(JsonReader reader, Type? objectType) { ValidationUtils.ArgumentNotNull(reader, "reader"); SetupReader(reader, out CultureInfo previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string previousDateFormatString); TraceJsonReader traceJsonReader = ((TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Verbose) ? CreateTraceJsonReader(reader) : null); JsonSerializerInternalReader jsonSerializerInternalReader = new JsonSerializerInternalReader(this); object result = jsonSerializerInternalReader.Deserialize(traceJsonReader ?? reader, objectType, CheckAdditionalContent); if (traceJsonReader != null) { TraceWriter.Trace(TraceLevel.Verbose, traceJsonReader.GetDeserializedJsonMessage(), null); } ResetReader(reader, previousCulture, previousDateTimeZoneHandling, previousDateParseHandling, previousFloatParseHandling, previousMaxDepth, previousDateFormatString); return result; } internal void SetupReader(JsonReader reader, out CultureInfo? previousCulture, out DateTimeZoneHandling? previousDateTimeZoneHandling, out DateParseHandling? previousDateParseHandling, out FloatParseHandling? previousFloatParseHandling, out int? previousMaxDepth, out string? previousDateFormatString) { if (_culture != null && !_culture.Equals(reader.Culture)) { previousCulture = reader.Culture; reader.Culture = _culture; } else { previousCulture = null; } if (_dateTimeZoneHandling.HasValue && reader.DateTimeZoneHandling != _dateTimeZoneHandling) { previousDateTimeZoneHandling = reader.DateTimeZoneHandling; reader.DateTimeZoneHandling = _dateTimeZoneHandling.GetValueOrDefault(); } else { previousDateTimeZoneHandling = null; } if (_dateParseHandling.HasValue && reader.DateParseHandling != _dateParseHandling) { previousDateParseHandling = reader.DateParseHandling; reader.DateParseHandling = _dateParseHandling.GetValueOrDefault(); } else { previousDateParseHandling = null; } if (_floatParseHandling.HasValue && reader.FloatParseHandling != _floatParseHandling) { previousFloatParseHandling = reader.FloatParseHandling; reader.FloatParseHandling = _floatParseHandling.GetValueOrDefault(); } else { previousFloatParseHandling = null; } if (_maxDepthSet && reader.MaxDepth != _maxDepth) { previousMaxDepth = reader.MaxDepth; reader.MaxDepth = _maxDepth; } else { previousMaxDepth = null; } if (_dateFormatStringSet && reader.DateFormatString != _dateFormatString) { previousDateFormatString = reader.DateFormatString; reader.DateFormatString = _dateFormatString; } else { previousDateFormatString = null; } if (reader is JsonTextReader jsonTextReader && jsonTextReader.PropertyNameTable == null && _contractResolver is DefaultContractResolver defaultContractResolver) { jsonTextReader.PropertyNameTable = defaultContractResolver.GetNameTable(); } } private void ResetReader(JsonReader reader, CultureInfo? previousCulture, DateTimeZoneHandling? previousDateTimeZoneHandling, DateParseHandling? previousDateParseHandling, FloatParseHandling? previousFloatParseHandling, int? previousMaxDepth, string? previousDateFormatString) { if (previousCulture != null) { reader.Culture = previousCulture; } if (previousDateTimeZoneHandling.HasValue) { reader.DateTimeZoneHandling = previousDateTimeZoneHandling.GetValueOrDefault(); } if (previousDateParseHandling.HasValue) { reader.DateParseHandling = previousDateParseHandling.GetValueOrDefault(); } if (previousFloatParseHandling.HasValue) { reader.FloatParseHandling = previousFloatParseHandling.GetValueOrDefault(); } if (_maxDepthSet) { reader.MaxDepth = previousMaxDepth; } if (_dateFormatStringSet) { reader.DateFormatString = previousDateFormatString; } if (reader is JsonTextReader jsonTextReader && jsonTextReader.PropertyNameTable != null && _contractResolver is DefaultContractResolver defaultContractResolver && jsonTextReader.PropertyNameTable == defaultContractResolver.GetNameTable()) { jsonTextReader.PropertyNameTable = null; } } public void Serialize(TextWriter textWriter, object? value) { Serialize(new JsonTextWriter(textWriter), value); } public void Serialize(JsonWriter jsonWriter, object? value, Type? objectType) { SerializeInternal(jsonWriter, value, objectType); } public void Serialize(TextWriter textWriter, object? value, Type objectType) { Serialize(new JsonTextWriter(textWriter), value, objectType); } public void Serialize(JsonWriter jsonWriter, object? value) { SerializeInternal(jsonWriter, value, null); } private TraceJsonReader CreateTraceJsonReader(JsonReader reader) { TraceJsonReader traceJsonReader = new TraceJsonReader(reader); if (reader.TokenType != 0) { traceJsonReader.WriteCurrentToken(); } return traceJsonReader; } internal virtual void SerializeInternal(JsonWriter jsonWriter, object? value, Type? objectType) { ValidationUtils.ArgumentNotNull(jsonWriter, "jsonWriter"); Formatting? formatting = null; if (_formatting.HasValue && jsonWriter.Formatting != _formatting) { formatting = jsonWriter.Formatting; jsonWriter.Formatting = _formatting.GetValueOrDefault(); } DateFormatHandling? dateFormatHandling = null; if (_dateFormatHandling.HasValue && jsonWriter.DateFormatHandling != _dateFormatHandling) { dateFormatHandling = jsonWriter.DateFormatHandling; jsonWriter.DateFormatHandling = _dateFormatHandling.GetValueOrDefault(); } DateTimeZoneHandling? dateTimeZoneHandling = null; if (_dateTimeZoneHandling.HasValue && jsonWriter.DateTimeZoneHandling != _dateTimeZoneHandling) { dateTimeZoneHandling = jsonWriter.DateTimeZoneHandling; jsonWriter.DateTimeZoneHandling = _dateTimeZoneHandling.GetValueOrDefault(); } FloatFormatHandling? floatFormatHandling = null; if (_floatFormatHandling.HasValue && jsonWriter.FloatFormatHandling != _floatFormatHandling) { floatFormatHandling = jsonWriter.FloatFormatHandling; jsonWriter.FloatFormatHandling = _floatFormatHandling.GetValueOrDefault(); } StringEscapeHandling? stringEscapeHandling = null; if (_stringEscapeHandling.HasValue && jsonWriter.StringEscapeHandling != _stringEscapeHandling) { stringEscapeHandling = jsonWriter.StringEscapeHandling; jsonWriter.StringEscapeHandling = _stringEscapeHandling.GetValueOrDefault(); } CultureInfo cultureInfo = null; if (_culture != null && !_culture.Equals(jsonWriter.Culture)) { cultureInfo = jsonWriter.Culture; jsonWriter.Culture = _culture; } string dateFormatString = null; if (_dateFormatStringSet && jsonWriter.DateFormatString != _dateFormatString) { dateFormatString = jsonWriter.DateFormatString; jsonWriter.DateFormatString = _dateFormatString; } TraceJsonWriter traceJsonWriter = ((TraceWriter != null && TraceWriter.LevelFilter >= TraceLevel.Verbose) ? new TraceJsonWriter(jsonWriter) : null); JsonSerializerInternalWriter jsonSerializerInternalWriter = new JsonSerializerInternalWriter(this); jsonSerializerInternalWriter.Serialize(traceJsonWriter ?? jsonWriter, value, objectType); if (traceJsonWriter != null) { TraceWriter.Trace(TraceLevel.Verbose, traceJsonWriter.GetSerializedJsonMessage(), null); } if (formatting.HasValue) { jsonWriter.Formatting = formatting.GetValueOrDefault(); } if (dateFormatHandling.HasValue) { jsonWriter.DateFormatHandling = dateFormatHandling.GetValueOrDefault(); } if (dateTimeZoneHandling.HasValue) { jsonWriter.DateTimeZoneHandling = dateTimeZoneHandling.GetValueOrDefault(); } if (floatFormatHandling.HasValue) { jsonWriter.FloatFormatHandling = floatFormatHandling.GetValueOrDefault(); } if (stringEscapeHandling.HasValue) { jsonWriter.StringEscapeHandling = stringEscapeHandling.GetValueOrDefault(); } if (_dateFormatStringSet) { jsonWriter.DateFormatString = dateFormatString; } if (cultureInfo != null) { jsonWriter.Culture = cultureInfo; } } internal IReferenceResolver GetReferenceResolver() { if (_referenceResolver == null) { _referenceResolver = new DefaultReferenceResolver(); } return _referenceResolver; } internal JsonConverter? GetMatchingConverter(Type type) { return GetMatchingConverter(_converters, type); } internal static JsonConverter? GetMatchingConverter(IList<JsonConverter>? converters, Type objectType) { ValidationUtils.ArgumentNotNull(objectType, "objectType"); if (converters != null) { for (int i = 0; i < converters.Count; i++) { JsonConverter jsonConverter = converters[i]; if (jsonConverter.CanConvert(objectType)) { return jsonConverter; } } } return null; } internal void OnError(Newtonsoft.Json.Serialization.ErrorEventArgs e) { this.Error?.Invoke(this, e); } } public class JsonSerializerSettings { internal const ReferenceLoopHandling DefaultReferenceLoopHandling = ReferenceLoopHandling.Error; internal const MissingMemberHandling DefaultMissingMemberHandling = MissingMemberHandling.Ignore; internal const NullValueHandling DefaultNullValueHandling = NullValueHandling.Include; internal const DefaultValueHandling DefaultDefaultValueHandling = DefaultValueHandling.Include; internal const ObjectCreationHandling DefaultObjectCreationHandling = ObjectCreationHandling.Auto; internal const PreserveReferencesHandling DefaultPreserveReferencesHandling = PreserveReferencesHandling.None; internal const ConstructorHandling DefaultConstructorHandling = ConstructorHandling.Default; internal const TypeNameHandling DefaultTypeNameHandling = TypeNameHandling.None; internal const MetadataPropertyHandling DefaultMetadataPropertyHandling = MetadataPropertyHandling.Default; internal static readonly StreamingContext DefaultContext; internal const Formatting DefaultFormatting = Formatting.None; internal const DateFormatHandling DefaultDateFormatHandling = DateFormatHandling.IsoDateFormat; internal const DateTimeZoneHandling DefaultDateTimeZoneHandling = DateTimeZoneHandling.RoundtripKind; internal const DateParseHandling DefaultDateParseHandling = DateParseHandling.DateTime; internal const FloatParseHandling DefaultFloatParseHandling = FloatParseHandling.Double; internal const FloatFormatHandling DefaultFloatFormatHandling = FloatFormatHandling.String; internal const StringEscapeHandling DefaultStringEscapeHandling = StringEscapeHandling.Default; internal const TypeNameAssemblyFormatHandling DefaultTypeNameAssemblyFormatHandling = TypeNameAssemblyFormatHandling.Simple; internal static readonly CultureInfo DefaultCulture; internal const bool DefaultCheckAdditionalContent = false; internal const string DefaultDateFormatString = "yyyy'-'MM'-'dd'T'HH':'mm':'ss.FFFFFFFK"; internal const int DefaultMaxDepth = 64; internal Formatting? _formatting; internal DateFormatHandling? _dateFormatHandling; internal DateTimeZoneHandling? _dateTimeZoneHandling; internal DateParseHandling? _dateParseHandling; internal FloatFormatHandling? _floatFormatHandling; internal FloatParseHandling? _floatParseHandling; internal StringEscapeHandling? _stringEscapeHandling; internal CultureInfo? _culture; internal bool? _checkAdditionalContent; internal int? _maxDepth; internal bool _maxDepthSet; internal string? _dateFormatString; internal bool _dateFormatStringSet; internal TypeNameAssemblyFormatHandling? _typeNameAssemblyFormatHandling; internal DefaultValueHandling? _defaultValueHandling; internal PreserveReferencesHandling? _preserveReferencesHandling; internal NullValueHandling? _nullValueHandling; internal ObjectCreationHandling? _objectCreationHandling; internal MissingMemberHandling? _missingMemberHandling; internal ReferenceLoopHandling? _referenceLoopHandling; internal StreamingContext? _context; internal ConstructorHandling? _constructorHandling; internal TypeNameHandling? _typeNameHandling; internal MetadataPropertyHandling? _metadataPropertyHandling; public ReferenceLoopHandling ReferenceLoopHandling { get { return _referenceLoopHandling.GetValueOrDefault(); } set { _referenceLoopHandling = value; } } public MissingMemberHandling MissingMemberHandling { get { return _missingMemberHandling.GetValueOrDefault(); } set { _missingMemberHandling = value; } } public ObjectCreationHandling ObjectCreationHandling { get { return _objectCreationHandling.GetValueOrDefault(); } set { _objectCreationHandling = value; } } public NullValueHandling NullValueHandling { get { return _nullValueHandling.GetValueOrDefault(); } set { _nullValueHandling = value; } } public DefaultValueHandling DefaultValueHandling { get { return _defaultValueHandling.GetValueOrDefault(); } set { _defaultValueHandling = value; } } public IList<JsonConverter> Converters { get; set; } public PreserveReferencesHandling PreserveReferencesHandling { get { return _preserveReferencesHandling.GetValueOrDefault(); } set { _preserveReferencesHandling = value; } } public TypeNameHandling TypeName
plugins/OutwardArchipelago.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading.Tasks; using Archipelago.MultiClient.Net; using Archipelago.MultiClient.Net.BounceFeatures.DeathLink; using Archipelago.MultiClient.Net.Enums; using Archipelago.MultiClient.Net.Exceptions; using Archipelago.MultiClient.Net.Helpers; using Archipelago.MultiClient.Net.MessageLog.Messages; using Archipelago.MultiClient.Net.MessageLog.Parts; using Archipelago.MultiClient.Net.Models; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using NodeCanvas.DialogueTrees; using NodeCanvas.Framework; using NodeCanvas.Tasks.Actions; using NodeCanvas.Tasks.Conditions; using OutwardArchipelago.Archipelago; using OutwardArchipelago.Archipelago.APItemGivers; using OutwardArchipelago.Dialogue; using OutwardArchipelago.Dialogue.Actions; using OutwardArchipelago.Dialogue.Builders.Actions; using OutwardArchipelago.Dialogue.Builders.BBParameters; using OutwardArchipelago.Dialogue.Builders.Conditions; using OutwardArchipelago.Dialogue.Builders.Nodes; using OutwardArchipelago.Dialogue.Builders.Statements; using OutwardArchipelago.Dialogue.Conditions; using OutwardArchipelago.Dialogue.Patches; using OutwardArchipelago.QuestEvents; using OutwardArchipelago.Utils; using ParadoxNotion; using UnityEngine; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("OutwardArchipelago")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OutwardArchipelago")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("c5450fe0-edcf-483f-b9ea-4b1ef9d36da7")] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.2.0.0")] [module: UnverifiableCode] public class RgbShaderEffect : MonoBehaviour { public float Speed = 0.5f; public float Intensity = 2f; private MeshRenderer _renderer; private int _emissionID; private void Awake() { _renderer = ((Component)this).GetComponentInChildren<MeshRenderer>(); _emissionID = Shader.PropertyToID("_Color"); } private void Update() { //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_0046: 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) if (!((Object)(object)_renderer == (Object)null)) { Color val = Color.HSVToRGB(Mathf.Repeat(Time.time * Speed, 1f), 1f, 1f); ((Renderer)_renderer).material.SetColor(_emissionID, val * Intensity); } } } namespace OutwardArchipelago { internal static class BreakthroughPointManager { [HarmonyPatch(/*Could not decode attribute arguments.*/)] private static class Patch_PlayerCharacterStats_RemainingBreakthough_Getter { private static bool Prefix(ref int __result, PlayerCharacterStats __instance) { __result = Mathf.Clamp(AcquiredBreakthoughPoints - __instance.m_usedBreakthroughCount, 0, 20); return false; } } public static int AcquiredBreakthoughPoints => ArchipelagoConnector.Instance.Items.GetCount(APWorld.Item.BreakthroughPoint); } internal class ChatPanelManager { private static readonly ChatPanelManager _instance = new ChatPanelManager(); public static ChatPanelManager Instance => _instance; private ChatPanelManager() { } public void SendSystemMessage(string message, Character character = null) { if (character == null) { character = CharacterManager.Instance.GetFirstLocalCharacter(); } ChatPanel chatPanel = character.CharacterUI.ChatPanel; ChatEntry val; if (chatPanel.m_messageArchive.Count < chatPanel.MaxMessageCount) { val = Object.Instantiate<ChatEntry>(UIUtilities.ChatEntryPrefab); ((Component)val).transform.SetParent((Transform)(object)chatPanel.m_chatDisplay.content); UnityEngineExtensions.ResetLocal(((Component)val).transform, true); ((UIElement)val).SetCharacterUI(((UIElement)chatPanel).m_characterUI); chatPanel.m_messageArchive.Insert(0, val); } else { val = chatPanel.m_messageArchive[chatPanel.m_messageArchive.Count - 1]; chatPanel.m_messageArchive.RemoveAt(chatPanel.m_messageArchive.Count - 1); chatPanel.m_messageArchive.Insert(0, val); } if (val != null) { ((Component)chatPanel.m_messageArchive[0]).transform.SetAsLastSibling(); if (val.m_lblPlayerName != null) { val.m_lblPlayerName.text = string.Empty; } if (val.m_lblMessage != null) { val.m_lblMessage.text = message; } } chatPanel.m_lastHideTime = Time.time; if (!((UIElement)chatPanel).IsDisplayed) { ((UIElement)chatPanel).Show(); } ((MonoBehaviour)chatPanel).Invoke("DelayedScroll", 0.1f); } public bool ChatPanel_SendChatMessage(ChatPanel chatPanel) { string text = chatPanel.m_chatEntry.text; if (text.StartsWith("/ap ", StringComparison.InvariantCultureIgnoreCase)) { string message = text.Substring("/ap ".Length); ArchipelagoConnector.Instance.Messages.SendMessage(message); chatPanel.m_chatEntry.text = string.Empty; chatPanel.HideInput(); return false; } return true; } } internal class LocationCheckQuestEventAddedListener : IQuestEventAddedListener { [HarmonyPatch(typeof(QuestEventManager), "Awake")] public static class QuestEventManager_Awake { private static void Postfix(QuestEventManager __instance) { OutwardArchipelagoMod.Log.LogDebug((object)"QuestEventManager Awake postfix called."); RegisterAll(); } } public string OutwardEventId { get; private set; } public APWorld.Location Location { get; private set; } public int StackCount { get; private set; } public LocationCheckQuestEventAddedListener(string outwardEventId, APWorld.Location location, int stackCount = 1) { OutwardEventId = outwardEventId; Location = location; StackCount = stackCount; } public void OnQuestEventAdded(QuestEventData _eventData) { OutwardArchipelagoMod.Log.LogInfo((object)("LocationCheckQuestEventAddedListener received OnQuestEventAdded for EventUID = " + _eventData.EventUID + ".")); if (string.Equals(_eventData.EventUID, OutwardEventId, StringComparison.Ordinal) && _eventData.StackCount >= StackCount) { OutwardArchipelagoMod.Log.LogInfo((object)("LocationCheckQuestEventAddedListener triggered for EventUID = " + OutwardEventId + ".")); ArchipelagoConnector.Instance.Locations.Complete(Location); } } public void Register() { OutwardArchipelagoMod.Log.LogInfo((object)("Registering LocationCheckQuestEventAddedListener for OutwardEventId = " + OutwardEventId + ".")); QuestEventManager.Instance.RegisterOnQEAddedListener(OutwardEventId, (IQuestEventAddedListener)(object)this); } private static void RegisterAll() { if (!Object.op_Implicit((Object)(object)QuestEventManager.Instance)) { return; } OutwardArchipelagoMod.Log.LogInfo((object)"Registering all LocationCheckQuestEventAddedListeners."); foreach (LocationCheckQuestEventAddedListener item in new List<LocationCheckQuestEventAddedListener> { new LocationCheckQuestEventAddedListener("HteYicnCK0atCgd4j5TV1Q", APWorld.Location.QuestMain01), new LocationCheckQuestEventAddedListener("ZYzrMi1skUiJ4BgXXQ3sfw", APWorld.Location.QuestMain02), new LocationCheckQuestEventAddedListener("P2rqNERqN0O1RhkD1ff7_w", APWorld.Location.QuestMain03), new LocationCheckQuestEventAddedListener("HbTd6ustoU-VhQeidJcAEw", APWorld.Location.QuestMain04), new LocationCheckQuestEventAddedListener("Wl08NWMJokemPVfTEyT3UA", APWorld.Location.QuestMain05), new LocationCheckQuestEventAddedListener("Og71f8G5a0eVmLxZB0yOKg", APWorld.Location.QuestMain06), new LocationCheckQuestEventAddedListener("1nGk1TyMbUi3VmSdn32zCg", APWorld.Location.QuestMain07), new LocationCheckQuestEventAddedListener("uEg8NE3nckWyTs_Y7jSTrQ", APWorld.Location.QuestMain08), new LocationCheckQuestEventAddedListener("kXbeBrICkEWs8GS6YTfKRA", APWorld.Location.QuestMain09), new LocationCheckQuestEventAddedListener("QVkuDH0_nkKwVNaCEy5Zww", APWorld.Location.QuestMain10), new LocationCheckQuestEventAddedListener("hedPnIOK20iOKSVgWk8cFw", APWorld.Location.QuestMain11), new LocationCheckQuestEventAddedListener("gSCCl5ZSXkC-2awJWrCAFw", APWorld.Location.QuestMain12), new LocationCheckQuestEventAddedListener("dFHmqMB8fEuUB0qRW", APWorld.Location.QuestParallelBloodUnderTheSun), new LocationCheckQuestEventAddedListener("cScnPPdRMEKaGZXNS4-gyQ", APWorld.Location.QuestParallelPurifier), new LocationCheckQuestEventAddedListener("HQkEW3Dz2U-MFBNzI73tqg", APWorld.Location.QuestParallelPurifier), new LocationCheckQuestEventAddedListener("WvGjemEntk6quLjy4rLrJQ", APWorld.Location.QuestParallelPurifier), new LocationCheckQuestEventAddedListener("3ghaq31OMECM4M-WdFnGcQ", APWorld.Location.QuestMinorAcquireMana), new LocationCheckQuestEventAddedListener("awSSujcoqUWqbbzX1ZjJXQ", APWorld.Location.QuestMinorArcaneMachine), new LocationCheckQuestEventAddedListener("DGExeNT-PE-ML4c654P9pA", APWorld.Location.QuestMinorCraftBlueSandArmor), new LocationCheckQuestEventAddedListener("MOSnQaJ9aUi8VNaciTKQHg", APWorld.Location.QuestMinorCraftCopalAndPetrifiedArmor), new LocationCheckQuestEventAddedListener("ap4aHgZ2aUKQh_rvXgulJg", APWorld.Location.QuestMinorCraftPalladiumArmor), new LocationCheckQuestEventAddedListener("uogu2mPV_k-JOYNGnU6jqw", APWorld.Location.QuestMinorCraftTsarAndTenebrousArmor), new LocationCheckQuestEventAddedListener("TgeCOUjVVEqbAr5Yn4iEkA", APWorld.Location.QuestMinorCraftAntiquePlateGarbArmor), new LocationCheckQuestEventAddedListener("fXICR4YvV0-v-fjujtU4tA", APWorld.Location.QuestMinorLostMerchant), new LocationCheckQuestEventAddedListener("ANSbO0nz7EiswqDPr3iMeQ", APWorld.Location.QuestMinorPurifyTheWater), new LocationCheckQuestEventAddedListener("x7hF_Sx8BEWFuEOf3KohGQ", APWorld.Location.QuestMinorRedIdol), new LocationCheckQuestEventAddedListener("FVym6FbQp0SCJA4jtY9Ldw", APWorld.Location.QuestMinorSilverForTheSlums, 5) }) { item.Register(); } } } internal static class MainScreenWarning { [HarmonyPatch(typeof(MainScreen), "OnContinueClicked", new Type[] { })] private static class Patch_MainScreen_OnContinueClicked { private static bool Prefix(MainScreen __instance) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown return ShowArchipelagoNotConnectedWarning(__instance, (UnityAction)delegate { __instance.OnContinueClicked(); }); } } [HarmonyPatch(typeof(MainScreen), "OnNewGameClicked", new Type[] { })] private static class Patch_MainScreen_OnNewGameClicked { private static bool Prefix(MainScreen __instance) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown return ShowArchipelagoNotConnectedWarning(__instance, (UnityAction)delegate { __instance.OnNewGameClicked(); }); } } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UnityAction <>9__1_1; internal void <ShowArchipelagoNotConnectedWarning>b__1_1() { } } private static bool doWarn = true; private static bool ShowArchipelagoNotConnectedWarning(MainScreen mainScreen, UnityAction acceptCallback) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown if (doWarn && !ArchipelagoConnector.Instance.IsConnected) { string localizedModString = OutwardArchipelagoMod.Instance.GetLocalizedModString("notification.warn_start_game_without_connection"); MessagePanel messagePanel = ((UIElement)mainScreen).CharacterUI.MessagePanel; string empty = string.Empty; UnityAction val = delegate { try { doWarn = false; acceptCallback.Invoke(); } finally { doWarn = true; } }; object obj = <>c.<>9__1_1; if (obj == null) { UnityAction val2 = delegate { }; <>c.<>9__1_1 = val2; obj = (object)val2; } messagePanel.Show(localizedModString, empty, val, (UnityAction)obj, true, -1f, (UnityAction)null); return false; } return true; } } internal class ModSceneManager { [HarmonyPatch(typeof(NetworkLevelLoader), "FinishLoadLevel", new Type[] { })] private static class NetworkLevelLoader_FinishLoadLevel { [CompilerGenerated] private sealed class <Postfix>d__0 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public IEnumerator __result; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Postfix>d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { switch (<>1__state) { default: return false; case 0: <>1__state = -1; goto IL_0045; case 1: <>1__state = -1; goto IL_0045; case 2: { <>1__state = -1; Instance?.OnFinishLoadLevel(); return false; } IL_0045: if (__result.MoveNext()) { <>2__current = __result.Current; <>1__state = 1; return true; } <>2__current = null; <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [IteratorStateMachine(typeof(<Postfix>d__0))] private static IEnumerator Postfix(IEnumerator __result) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Postfix>d__0(0) { __result = __result }; } } private static readonly ModSceneManager _instance = new ModSceneManager(); private const string MAIN_MENU_SCENE_NAME = "MainMenu_Empty"; private bool _isInMainMenu = true; public static ModSceneManager Instance => _instance; public event Action OnArchipelagoSceneReady; public event Action OnArchipelagoSceneReadyFirstTime; public event Action OnEnterArchipelagoGame; public event Action OnEnterMainMenu; private ModSceneManager() { SceneManager.sceneLoaded += OnSceneManagerSceneLoaded; } private void OnSceneManagerSceneLoaded(Scene scene, LoadSceneMode loadSceneMode) { if (((Scene)(ref scene)).name == "MainMenu_Empty" && !_isInMainMenu) { _isInMainMenu = true; this.OnEnterMainMenu?.Invoke(); } } private void OnFinishLoadLevel() { if (OutwardArchipelagoMod.Instance != null && OutwardArchipelagoMod.Instance.IsArchipelagoEnabled) { if (_isInMainMenu) { _isInMainMenu = false; OutwardArchipelagoMod.Log.LogDebug((object)("ModSceneManager.OnEnterArchipelagoGame " + SceneManagerHelper.ActiveSceneName)); this.OnEnterArchipelagoGame?.Invoke(); } NetworkLevelLoader instance = NetworkLevelLoader.Instance; if (instance != null && instance.LevelLoadedForFirstTime) { OutwardArchipelagoMod.Log.LogDebug((object)("ModSceneManager.OnArchipelagoSceneReadyFirstTime " + SceneManagerHelper.ActiveSceneName)); this.OnArchipelagoSceneReadyFirstTime?.Invoke(); } OutwardArchipelagoMod.Log.LogDebug((object)("ModSceneManager.OnArchipelagoSceneReady " + SceneManagerHelper.ActiveSceneName)); this.OnArchipelagoSceneReady?.Invoke(); } } } [BepInPlugin("com.daemonarium.apoutward", "Outward Archipelago", "0.2.0")] public class OutwardArchipelagoMod : BaseUnityPlugin { public const string GUID = "com.daemonarium.apoutward"; public const string NAME = "Outward Archipelago"; public const string VERSION = "0.2.0"; public static OutwardArchipelagoMod Instance; internal static ManualLogSource Log; public static ConfigEntry<string> ArchipelagoHost; public static ConfigEntry<int> ArchipelagoPort; public static ConfigEntry<string> ArchipelagoPassword; public static ConfigEntry<string> ArchipelagoSlotName; public bool IsInMainMenu => Global.Lobby.PlayersInLobbyCount == 0; public bool IsArchipelagoEnabled => PhotonNetwork.isMasterClient; public bool IsInGame { get { if (!IsInMainMenu && NetworkLevelLoader.Instance.IsOverallLoadingDone) { return !NetworkLevelLoader.Instance.IsGameplayPaused; } return false; } } public bool IsInArchipelagoGame { get { if (IsArchipelagoEnabled) { return IsInGame; } return false; } } private void BindConfig() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown ArchipelagoHost = ((BaseUnityPlugin)this).Config.Bind<string>("Archipelago", "Host", "archipelago.gg", "Archipelago server host name."); ArchipelagoPort = ((BaseUnityPlugin)this).Config.Bind<int>("Archipelago", "Port", 38281, new ConfigDescription("Archipelago server port.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 65535), Array.Empty<object>())); ArchipelagoPassword = ((BaseUnityPlugin)this).Config.Bind<string>("Archipelago", "Password", "", "The password to use when logging into the Archipelago server. Leave blank for no password."); ArchipelagoSlotName = ((BaseUnityPlugin)this).Config.Bind<string>("Archipelago", "Slot", "Player1", "The name of the slot to connect to on the Archipelago server."); } internal void Awake() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) Instance = this; Log = ((BaseUnityPlugin)this).Logger; Log.LogMessage((object)"Starting Outward Archipelago 0.2.0..."); BindConfig(); ArchipelagoConnector.Create(); DialoguePatcher.Instance.Awake(); ModSceneManager.Instance.OnArchipelagoSceneReadyFirstTime += InitScene; new Harmony("com.daemonarium.apoutward").PatchAll(); Log.LogMessage((object)"Outward Archipelago 0.2.0 started successfully"); } public byte[] LoadAsset(string fileName) { string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "assets", fileName); if (File.Exists(text)) { return File.ReadAllBytes(text); } Log.LogError((object)("Could not find asset at: " + text)); return null; } public string GetLocalizedModString(string key) { string text = "com.daemonarium.apoutward." + key; string result = default(string); if (!LocalizationManager.Instance.TryGetLoc(text, ref result)) { Log.LogError((object)("Failed to find localized string: " + text)); return "[LOC] " + text; } return result; } private void InitScene() { //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) Item[] array = ItemManager.Instance.WorldItems.Values.ToArray(); foreach (Item val in array) { if (!((Object)(object)val != (Object)null)) { continue; } Transform transform = ((Component)val).transform; if (((transform != null) ? transform.parent : null) == null || !APWorld.ItemToLocation.TryGetValue(val.ItemID, out var value)) { continue; } bool flag = true; Transform val2 = ((Component)val).transform; while ((Object)(object)val2 != (Object)null) { if (((Object)val2).name == "Content" || ((Object)val2).name == "EquipmentSlots" || ((Object)val2).name.StartsWith("PlayerChar ")) { flag = false; break; } val2 = val2.parent; } if (flag) { List<string> list = new List<string>(); Transform val3 = ((Component)val).transform; while ((Object)(object)val3 != (Object)null) { list.Add(((Object)val3).name); val3 = val3.parent; } Log.LogInfo((object)string.Format("world spawned item ({0}) associated with location ({1}) with transform {2}; replacing with AP Item", val.ItemID, value, string.Join(" > ", list))); Item obj = ItemManager.Instance.GenerateItemNetwork(8861511); obj.SetSideData("AP_Location", value); obj.ChangeParent(((Component)val).transform.parent, ((Component)val).transform.position, ((Component)val).transform.rotation); ItemManager.Instance.DestroyItem(val); } } } } internal static class OutwardItem { internal const int APItem = 8861511; internal const int TestWeaponOfDooooom = 504; internal const int IronSword = 2000010; internal const int SteelSabre = 2000020; internal const int CeruleanSaber = 2000021; internal const int WolfSword = 2000030; internal const int RadiantWolfSword = 2000031; internal const int FangSword = 2000050; internal const int SavageSword = 2000051; internal const int Machete = 2000060; internal const int GoldMachete = 2000061; internal const int MarbleSword = 2000070; internal const int GoldLichSword = 2000080; internal const int OldLegionGladius = 2000090; internal const int DesertKhopesh = 2000110; internal const int JadeScimitar = 2000120; internal const int AssassinSword = 2000130; internal const int PalladiumSword = 2000140; internal const int Brand = 2000150; internal const int StrangeRustedSword = 2000151; internal const int TsarSword = 2000160; internal const int MaelstromBlade = 2000170; internal const int HorrorSword = 2000180; internal const int VampiricSword = 2000190; internal const int VirginSword = 2000200; internal const int KaziteBlade = 2000210; internal const int DamasceneSword = 2000230; internal const int MasterpieceSword = 2000235; internal const int AstralSword = 2000240; internal const int ForgedGlassSword = 2000250; internal const int ObsidianSword = 2000260; internal const int MeteoricSword = 2000265; internal const int ChalcedonySword = 2000270; internal const int HailfrostSword = 2000280; internal const int SmokeSword = 2000290; internal const int MilitiaSword = 2000300; internal const int VigilanteSword = 2000305; internal const int GepsBlade = 2000310; internal const int MysteriousBlade = 2000320; internal const int IronAxe = 2010000; internal const int LivingWoodAxe = 2010020; internal const int BrutalAxe = 2010030; internal const int FangAxe = 2010040; internal const int SavageAxe = 2010041; internal const int Hatchet = 2010050; internal const int GoldHatchet = 2010051; internal const int MarbleAxe = 2010060; internal const int SunfallAxe = 2010070; internal const int BeastGolemAxe = 2010080; internal const int TuanosaurAxe = 2010090; internal const int HorrorAxe = 2010100; internal const int PalladiumAxe = 2010110; internal const int TsarAxe = 2010120; internal const int PainInTheAxe = 2010130; internal const int ButcherCleaver = 2010140; internal const int GalvanicAxe = 2010150; internal const int VampiricAxe = 2010160; internal const int VirginAxe = 2010170; internal const int KaziteCleaver = 2010180; internal const int WolfAxe = 2010190; internal const int DamasceneAxe = 2010200; internal const int MasterpieceAxe = 2010205; internal const int AstralAxe = 2010210; internal const int ForgedGlassAxe = 2010220; internal const int ObsidianAxe = 2010230; internal const int MeteoricAxe = 2010235; internal const int ChalcedonyAxe = 2010240; internal const int HailfrostAxe = 2010250; internal const int SmokeAxe = 2010260; internal const int MilitiaAxe = 2010270; internal const int VigilanteAxe = 2010275; internal const int WarmAxe = 2010280; internal const int Sandrose = 2010285; internal const int IronMace = 2020010; internal const int BrutalClub = 2020020; internal const int JadeLichMace = 2020030; internal const int MarbleMorningstar = 2020040; internal const int FangClub = 2020050; internal const int SavageClub = 2020051; internal const int GoldLichMace = 2020060; internal const int MertonsFirepoker = 2020070; internal const int GiantIronKey = 2020080; internal const int BlacksmithsHammer = 2020090; internal const int BlacksmithsVintageHammer = 2020091; internal const int PalladiumMace = 2020100; internal const int ObsidianMace = 2020110; internal const int MeteoricMace = 2020115; internal const int TsarMace = 2020120; internal const int PrimitiveClub = 2020130; internal const int GoldClub = 2020131; internal const int SkycrownMace = 2020140; internal const int MaceOfSeasons = 2020160; internal const int Calixamacegun = 2020170; internal const int HorrorMace = 2020180; internal const int VampiricMace = 2020190; internal const int GalvanicMace = 2020200; internal const int VirginMace = 2020210; internal const int KaziteHammer = 2020220; internal const int WolfMace = 2020230; internal const int DamasceneMace = 2020240; internal const int MasterpieceMace = 2020245; internal const int AstralMace = 2020250; internal const int ForgedGlassMace = 2020260; internal const int ChalcedonyMace = 2020280; internal const int HailfrostMace = 2020290; internal const int SmokeMace = 2020300; internal const int MilitiaMace = 2020310; internal const int VigilanteMace = 2020315; internal const int CalygreyMace = 2020320; internal const int AncientCalygreyMace = 2020325; internal const int SealedMace = 2020330; internal const int ScepterOfTheCruelPriest = 2020335; internal const int PrayerClaymore = 2100000; internal const int SinnerClaymore = 2100001; internal const int WolfClaymore = 2100010; internal const int FangGreatsword = 2100020; internal const int SavageGreatsword = 2100021; internal const int ZagisSaw = 2100030; internal const int MarbleClaymore = 2100040; internal const int GoldLichClaymore = 2100050; internal const int GolemRapier = 2100060; internal const int BrokenGolemRapier = 2100061; internal const int ThornyClaymore = 2100070; internal const int IronClaymore = 2100080; internal const int StarchildClaymore = 2100100; internal const int AssassinClaymore = 2100110; internal const int PalladiumClaymore = 2100120; internal const int PathfinderClaymore = 2100130; internal const int TsarClaymore = 2100140; internal const int RoyalGreatKopesh = 2100150; internal const int ThermalClaymore = 2100160; internal const int HorrorGreatsword = 2100170; internal const int VampiricGreatsword = 2100180; internal const int VirginGreatsword = 2100190; internal const int KaziteGreatblade = 2100200; internal const int JunkClaymore = 2100210; internal const int GoldenJunkClaymore = 2100211; internal const int DamasceneClaymore = 2100220; internal const int MasterpieceClaymore = 2100225; internal const int AstralClaymore = 2100230; internal const int ForgedGlassClaymore = 2100240; internal const int ObsidianClaymore = 2100250; internal const int MeteoricClaymore = 2100255; internal const int ChalcedonyClaymore = 2100260; internal const int HailfrostClaymore = 2100270; internal const int SmokeClaymore = 2100280; internal const int MilitiaClaymore = 2100290; internal const int MilitiaClaymoreDorion = 2100291; internal const int VigilanteClaymore = 2100295; internal const int MysteriousLongBlade = 2100300; internal const int GepsLongblade = 2100305; internal const int BrutalGreataxe = 2110000; internal const int FangGreataxe = 2110010; internal const int SavageGreataxe = 2110011; internal const int MarbleGreataxe = 2110020; internal const int IronGreataxe = 2110030; internal const int FellingGreataxe = 2110040; internal const int GoldGreataxe = 2110041; internal const int CrescentGreataxe = 2110050; internal const int TuanosaurGreataxe = 2110060; internal const int GiantkindGreataxe = 2110070; internal const int PalladiumGreataxe = 2110080; internal const int TsarGreataxe = 2110090; internal const int WorldedgeGreataxe = 2110100; internal const int KelvinsGreataxe = 2110110; internal const int HorrorGreataxe = 2110120; internal const int VampiricGreataxe = 2110130; internal const int GalvanicGreataxe = 2110140; internal const int VirginGreataxe = 2110150; internal const int KaziteGreatcleaver = 2110160; internal const int WolfGreataxe = 2110170; internal const int DamasceneGreataxe = 2110180; internal const int MasterpieceGreataxe = 2110185; internal const int AstralGreataxe = 2110190; internal const int ForgedGlassGreataxe = 2110200; internal const int ObsidianGreataxe = 2110210; internal const int MeteoricGreataxe = 2110215; internal const int ChalcedonyGreataxe = 2110220; internal const int HailfrostGreataxe = 2110230; internal const int SmokeGreataxe = 2110240; internal const int MilitiaGreataxe = 2110250; internal const int VigilanteGreataxe = 2110255; internal const int FossilizedGreataxe = 2110260; internal const int Grind = 2110265; internal const int BrutalGreatmace = 2120000; internal const int WolfGreathammer = 2120010; internal const int FangGreatclub = 2120020; internal const int SavageGreatclub = 2120021; internal const int MarbleGreathammer = 2120030; internal const int MantisGreatpick = 2120040; internal const int MiningPick = 2120050; internal const int GoldMiningPick = 2120051; internal const int PyriteGreathammer = 2120060; internal const int PillarGreathammer = 2120070; internal const int IronGreathammer = 2120080; internal const int ManticoreGreatmace = 2120090; internal const int PalladiumGreathammer = 2120110; internal const int ObsidianGreatmace = 2120120; internal const int MeteoricHammer = 2120125; internal const int TsarGreathammer = 2120130; internal const int ChallengerGreathammer = 2120140; internal const int HorrorGreatmace = 2120150; internal const int VampiricGreatmace = 2120160; internal const int GalvanicGreatmace = 2120170; internal const int VirginGreatmace = 2120180; internal const int KaziteGreathammer = 2120190; internal const int DamasceneHammer = 2120200; internal const int MasterpieceHammer = 2120205; internal const int AstralGreatmace = 2120210; internal const int ForgedGlassGreatmace = 2120220; internal const int ChalcedonyHammer = 2120230; internal const int HailfrostHammer = 2120240; internal const int SmokeHammer = 2120250; internal const int MilitiaHammer = 2120260; internal const int VigilanteHammer = 2120265; internal const int DepoweredBludgeon = 2120270; internal const int GhostParallel = 2120275; internal const int BrutalSpear = 2130000; internal const int WornGuisarme = 2130010; internal const int GoldGuisarme = 2130011; internal const int FangTrident = 2130020; internal const int WerligSpear = 2130021; internal const int SavageTrident = 2130022; internal const int Quarterstaff = 2130030; internal const int GoldQuarterstaff = 2130031; internal const int Pitchfork = 2130040; internal const int GoldPitchfork = 2130041; internal const int MarbleSpear = 2130050; internal const int GoldLichSpear = 2130060; internal const int OldLegionSpear = 2130070; internal const int TroglodyteTrident = 2130080; internal const int TroglodytePoleMace = 2130081; internal const int TroglodyteHalberd = 2130082; internal const int WitheringTrident = 2130083; internal const int WitheringPoleMace = 2130084; internal const int ThornySpear = 2130100; internal const int IronSpear = 2130110; internal const int PhytosaurSpear = 2130120; internal const int FishingHarpoon = 2130130; internal const int GoldHarpoon = 2130131; internal const int PalladiumSpear = 2130140; internal const int TsarSpear = 2130150; internal const int GriigmerkKramerk = 2130160; internal const int HorrorSpear = 2130170; internal const int VampiricSpear = 2130180; internal const int GalvanicSpear = 2130190; internal const int VirginSpear = 2130200; internal const int KaziteLance = 2130210; internal const int WolfSpear = 2130220; internal const int DamasceneSpear = 2130235; internal const int MasterpieceSpear = 2130237; internal const int AstralSpear = 2130240; internal const int ForgedGlassSpear = 2130250; internal const int ObsidianSpear = 2130260; internal const int MeteoricSpear = 2130265; internal const int ChalcedonySpear = 2130270; internal const int HailfrostSpear = 2130280; internal const int SmokeSpear = 2130290; internal const int MilitiaSpear = 2130300; internal const int VigilanteSpear = 2130305; internal const int RustedSpear = 2130310; internal const int Shriek = 2130315; internal const int IronHalberd = 2140000; internal const int CleaverHalberd = 2140010; internal const int SanguineCleaver = 2140011; internal const int FangHalberd = 2140020; internal const int SavageHalberd = 2140021; internal const int MarbleHalberd = 2140030; internal const int MushroomHalberd = 2140050; internal const int SporeHalberd = 2140051; internal const int ThriceWroughtHalberd = 2140060; internal const int CrescentScythe = 2140070; internal const int BeastGolemHalberd = 2140080; internal const int GiantkindHalberd = 2140090; internal const int PalladiumHalberd = 2140100; internal const int TsarHalberd = 2140110; internal const int DreamerHalberd = 2140120; internal const int GhostReaper = 2140130; internal const int HorrorHalberd = 2140135; internal const int VampiricHalberd = 2140140; internal const int GalvanicHalberd = 2140150; internal const int VirginHalberd = 2140160; internal const int KazitePartizan = 2140170; internal const int WolfHalberd = 2140180; internal const int ScholarsStaff = 2150000; internal const int MagesPokingStick = 2150001; internal const int JadeLichStaff = 2150010; internal const int CompasswoodStaff = 2150030; internal const int RotwoodStaff = 2150031; internal const int TroglodyteStaff = 2150040; internal const int CrystalStaff = 2150041; internal const int EliteQueenTrogManaStaff = 2150042; internal const int MastersStaff = 2150050; internal const int IvoryMastersStaff = 2150051; internal const int DamasceneHalberd = 2150060; internal const int MasterpieceHalberd = 2150065; internal const int AstralHalberd = 2150070; internal const int ForgedGlassHalberd = 2150080; internal const int ObsidianHalberd = 2150090; internal const int MeteoricHalberd = 2150095; internal const int ChalcedonyHalberd = 2150100; internal const int HailfrostHalberd = 2150110; internal const int SmokeHalberd = 2150120; internal const int MilitiaHalberd = 2150130; internal const int VigilanteHalberd = 2150135; internal const int AstralStaff = 2150140; internal const int FrostburnStaff = 2150150; internal const int CalygreyStaff = 2150160; internal const int AncientCalygreyStaff = 2150165; internal const int RuinedHalberd = 2150170; internal const int Duty = 2150175; internal const int CrackedRedMoon = 2150180; internal const int RevenantMoon = 2150185; internal const int IronKnuckles = 2160000; internal const int BrutalKnuckles = 2160010; internal const int ClothKnuckles = 2160020; internal const int GoldenIronKnuckles = 2160021; internal const int FangKnuckles = 2160030; internal const int SavageFangKnuckles = 2160031; internal const int GalvanicFists = 2160040; internal const int GoldLichKnuckles = 2160050; internal const int HorrorFists = 2160060; internal const int MarbleFists = 2160070; internal const int PalladiumKnuckles = 2160080; internal const int PorcelainFists = 2160090; internal const int TsarFists = 2160100; internal const int WolfKnuckles = 2160110; internal const int KaziteCestus = 2160120; internal const int VirginKnuckles = 2160130; internal const int VampiricKnuckles = 2160140; internal const int DamasceneKnuckles = 2160150; internal const int MasterpieceKnuckles = 2160155; internal const int AstralKnuckles = 2160160; internal const int ForgedGlassKnuckles = 2160170; internal const int ObsidianKnuckles = 2160180; internal const int MeteoricKnuckles = 2160185; internal const int ChalcedonyKnuckles = 2160190; internal const int HailfrostKnuckles = 2160200; internal const int SmokeKnuckles = 2160210; internal const int MilitiaKnuckles = 2160220; internal const int VigilanteKnuckles = 2160225; internal const int UnusualKnuckles = 2160230; internal const int Tokebakicit = 2160235; internal const int SimpleBow = 2200000; internal const int GoldBow = 2200001; internal const int RecurveBow = 2200010; internal const int WarBow = 2200020; internal const int HorrorBow = 2200030; internal const int CoralhornBow = 2200040; internal const int VampiricBow = 2200050; internal const int GalvanicBow = 2200060; internal const int VirginBow = 2200070; internal const int KaziteBow = 2200080; internal const int WolfBow = 2200090; internal const int TsarBow = 2200100; internal const int AstralBow = 2200110; internal const int ForgedGlassBow = 2200120; internal const int DamasceneBow = 2200130; internal const int MasterpieceBow = 2200135; internal const int SmokeBow = 2200140; internal const int MilitiaBow = 2200150; internal const int VigilanteBow = 2200155; internal const int HailfrostBow = 2200160; internal const int ChalcedonyBow = 2200170; internal const int ObsidianBow = 2200180; internal const int MeteoricBow = 2200185; internal const int CeremonialBow = 2200190; internal const int Murmure = 2200191; internal const int RoundShield = 2300000; internal const int ZhornsDemonShield = 2300030; internal const int TowerShield = 2300040; internal const int WolfShield = 2300050; internal const int FangShield = 2300060; internal const int OldLegionShield = 2300070; internal const int PlankShield = 2300080; internal const int MarbleShield = 2300090; internal const int InnerMarbleShield = 2300091; internal const int GoldLichShield = 2300100; internal const int DragonShield = 2300120; internal const int CrimsonShield = 2300130; internal const int SteelShield = 2300140; internal const int MushroomShield = 2300150; internal const int HorrorShield = 2300160; internal const int PalladiumShield = 2300170; internal const int FabulousPalladiumShield = 2300171; internal const int OrnateBoneShield = 2300180; internal const int TsarShield = 2300190; internal const int GoldenShield = 2300200; internal const int SavageShield = 2300210; internal const int SporeShield = 2300220; internal const int GalvanicShield = 2300230; internal const int VampiricShield = 2300240; internal const int VirginShield = 2300250; internal const int KaziteScutum = 2300260; internal const int EnchantingTableShield = 2300270; internal const int AstralShield = 2300290; internal const int ForgedGlassShield = 2300300; internal const int SmokeShield = 2300340; internal const int MilitiaShield = 2300350; internal const int VigilanteShield = 2300355; internal const int SlumberingShield = 2300360; internal const int AnglerShield = 2300365; internal const int TheWillOWisp = 2300600; internal const int KrypteiaGiantkindHalberd = 2400530; internal const int KrypteiaPalladiumMace = 2400531; internal const int Slughellshell = 2400550; internal const int Slughellvolcanicshell = 2400551; internal const int TraderGarb = 3000000; internal const int StrawHat = 3000001; internal const int TraderBoots = 3000002; internal const int BeigeGarb = 3000003; internal const int SimpleShoes = 3000004; internal const int DarkGreenGarb = 3000005; internal const int GrayGarb = 3000006; internal const int DarkRedGarb = 3000007; internal const int GreenGarb = 3000008; internal const int StripedGarb = 3000009; internal const int PaddedArmor = 3000010; internal const int PaddedHelm = 3000011; internal const int PaddedBoots = 3000012; internal const int AdventurerArmor = 3000020; internal const int AdventurersHelm = 3000021; internal const int AdventurerBoots = 3000022; internal const int ScavengerCoat = 3000030; internal const int ScavengerMask = 3000031; internal const int ScavengerHood = 3000032; internal const int ScavengerScarf = 3000033; internal const int ScavengerBoots = 3000034; internal const int BrigandCoat = 3000035; internal const int BrigandsHat = 3000036; internal const int EliteHood = 3000037; internal const int LooterArmor = 3000038; internal const int LooterMask = 3000039; internal const int JadeLichRobes = 3000040; internal const int JadeLichMask = 3000041; internal const int JadeMasterCowl = 3000042; internal const int JadeLichBoots = 3000043; internal const int JadeAcolyteRobes = 3000044; internal const int JadeAcolyteCowl = 3000045; internal const int JadeAcolyteBoots = 3000046; internal const int WhitePriestRobes = 3000060; internal const int WhitePriestMitre = 3000061; internal const int WhitePriestBoots = 3000062; internal const int WhitePriestHood = 3000063; internal const int NoviceRobe = 3000070; internal const int NoviceHat = 3000071; internal const int DarkWorkerAttire = 3000080; internal const int PatternedWorkerAttire = 3000081; internal const int GreenWorkerAttire = 3000082; internal const int WorkerBoots = 3000083; internal const int BlackWorkerBoots = 3000084; internal const int DarkWorkerHood = 3000085; internal const int PatternedWorkerHood = 3000086; internal const int PaleWorkersHood = 3000087; internal const int RedFestiveAttire = 3000090; internal const int PurpleFestiveAttire = 3000091; internal const int RedFestiveHat = 3000092; internal const int PurpleFestiveHat = 3000093; internal const int CoralhornMask = 3000100; internal const int ScarabMask = 3000101; internal const int TuanosaurMask = 3000102; internal const int HoundMask = 3000103; internal const int BrightNoblemanAttire = 3000110; internal const int DarkNoblemanAttire = 3000111; internal const int EntomberArmor = 3000112; internal const int BrightNoblemanHat = 3000113; internal const int DarkNoblemanHat = 3000114; internal const int EntomberHat = 3000115; internal const int BrightNoblemanBoots = 3000116; internal const int DarkNoblemanBoots = 3000117; internal const int EntomberBoots = 3000118; internal const int BrightRichAttire = 3000120; internal const int DarkRichAttire = 3000121; internal const int BrightRichHat = 3000122; internal const int DarkRichHat = 3000123; internal const int TatteredAttireA = 3000130; internal const int TatteredAttireB = 3000131; internal const int TatteredAttireC = 3000132; internal const int TatteredHoodA = 3000133; internal const int TatteredHoodB = 3000134; internal const int TatteredHoodC = 3000135; internal const int TatteredBoots = 3000136; internal const int TenebrousArmor = 3000140; internal const int TenebrousHelm = 3000141; internal const int TenebrousBoots = 3000142; internal const int PearlescentMail = 3000150; internal const int CopalArmor = 3000160; internal const int CopalHelm = 3000161; internal const int CopalBoots = 3000162; internal const int BlueLightClothes = 3000170; internal const int RedLightClothes = 3000171; internal const int PaleLightClothes = 3000172; internal const int Sandals = 3000174; internal const int PurpleDancerClothes = 3000180; internal const int BlackDancerClothes = 3000181; internal const int CrimsonDancerClothes = 3000182; internal const int DancerMask = 3000183; internal const int DancerLeggings = 3000184; internal const int ScholarAttire = 3000190; internal const int ScholarCirclet = 3000191; internal const int ScholarBoots = 3000192; internal const int DesertTunic = 3000200; internal const int ChitinDesertTunic = 3000201; internal const int EliteDesertTunic = 3000202; internal const int DesertVeil = 3000203; internal const int EliteDesertVeil = 3000204; internal const int DesertBoots = 3000205; internal const int GoldLichArmor = 3000210; internal const int GoldLichMask = 3000211; internal const int GoldLichBoots = 3000212; internal const int AshArmor = 3000220; internal const int AshFilterMask = 3000221; internal const int AshBoots = 3000222; internal const int PathfinderArmor = 3000224; internal const int PathfinderMask = 3000225; internal const int PathfinderBoots = 3000226; internal const int MasterTraderGarb = 3000230; internal const int MasterTraderHat = 3000231; internal const int MasterTraderBoots = 3000232; internal const int FurArmor = 3000240; internal const int FurHelm = 3000241; internal const int FurBoots = 3000242; internal const int PearlbirdMask = 3000250; internal const int BlackPearlbirdMask = 3000251; internal const int JewelBirdMask = 3000252; internal const int ArcaneRobe = 3000260; internal const int ArcaneHood = 3000261; internal const int ClansageRobe = 3000270; internal const int MakeshiftLeatherAttire = 3000280; internal const int MakeshiftLeatherHat = 3000281; internal const int MakeshiftLeatherBoots = 3000282; internal const int ScaledLeatherAttire = 3000290; internal const int ScaledLeatherHat = 3000291; internal const int ScaledLeatherBoots = 3000292; internal const int WideBlueHat = 3000300; internal const int WideBlackHat = 3000301; internal const int RedWideHat = 3000302; internal const int WhiteWideHat = 3000303; internal const int GreenCopalArmor = 3000310; internal const int GreenCopalHelmet = 3000311; internal const int GreenCopalBoots = 3000312; internal const int MasterDesertTunic = 3000320; internal const int MasterDesertVeil = 3000321; internal const int MasterDesertBoots = 3000322; internal const int BlackFurArmor = 3000330; internal const int BlackFurHelmet = 3000331; internal const int BlackFurBoots = 3000332; internal const int WhiteArcaneRobe = 3000340; internal const int WhiteArcaneHood = 3000341; internal const int RedClansageRobe = 3000350; internal const int RustLichArmor = 3000360; internal const int RustLichHelmet = 3000361; internal const int RustLichBoots = 3000362; internal const int ElitePlateArmor = 3100000; internal const int ElitePlateHelm = 3100001; internal const int ElitePlateBoots = 3100002; internal const int PlateArmor = 3100003; internal const int PlateHelm = 3100004; internal const int PlateBoots = 3100005; internal const int HalfplateArmor = 3100006; internal const int HalfplateHelm = 3100007; internal const int HalfplateBoots = 3100008; internal const int WolfPlateArmor = 3100010; internal const int WolfPlateHelm = 3100011; internal const int WolfPlateFullHelm = 3100012; internal const int WolfPlateBoots = 3100013; internal const int PetrifiedWoodArmor = 3100020; internal const int PetrifiedWoodHelm = 3100021; internal const int PetrifiedWoodBoots = 3100022; internal const int ZagisMask = 3100030; internal const int ZagisArmor = 3100031; internal const int CandlePlateArmor = 3100040; internal const int CandlePlateHelm = 3100041; internal const int CandlePlateBoots = 3100042; internal const int CauldronHelm = 3100050; internal const int PalladiumArmor = 3100060; internal const int PalladiumHelm = 3100061; internal const int PalladiumBoots = 3100062; internal const int KintsugiArmor = 3100070; internal const int KintsugiHelm = 3100071; internal const int KintsugiBoots = 3100072; internal const int BlueSandArmor = 3100080; internal const int BlueSandHelm = 3100081; internal const int BlueSandBoots = 3100082; internal const int CrimsonPlateArmor = 3100090; internal const int CrimsonPlateMask = 3100091; internal const int CrimsonPlateBoots = 3100092; internal const int BlackPlateArmor = 3100093; internal const int BlackPlateHelm = 3100094; internal const int BlackPlateBoots = 3100095; internal const int SilverArmor = 3100100; internal const int SilverHelm = 3100101; internal const int SilverBoots = 3100102; internal const int KaziteArmor = 3100110; internal const int KaziteMask = 3100111; internal const int KaziteCatMask = 3100112; internal const int KaziteOniMask = 3100113; internal const int KaziteBoots = 3100114; internal const int RunicArmor = 3100120; internal const int RunicHelm = 3100121; internal const int RunicBoots = 3100122; internal const int AmmoliteArmor = 3100130; internal const int AmmoliteHelm = 3100131; internal const int AmmoliteBoots = 3100132; internal const int TsarArmor = 3100140; internal const int TsarHelm = 3100141; internal const int TsarBoots = 3100142; internal const int SquireAttire = 3100150; internal const int SquireHeadband = 3100151; internal const int SquireBoots = 3100152; internal const int PilgrimArmor = 3100160; internal const int PilgrimHelmet = 3100161; internal const int PilgrimBoots = 3100162; internal const int ShockArmor = 3100170; internal const int ShockHelmet = 3100171; internal const int ShockBoots = 3100172; internal const int OrichalcumArmor = 3100180; internal const int OrichalcumHelmet = 3100181; internal const int OrichalcumBoots = 3100182; internal const int MasterKaziteArmor = 3100190; internal const int MasterKaziteMask = 3100191; internal const int MasterKaziteBoots = 3100192; internal const int MasterKaziteCatMask = 3100193; internal const int MasterKaziteOniMask = 3100194; internal const int WhiteKintsugiArmor = 3100200; internal const int WhiteKintsugiHelmet = 3100201; internal const int WhiteKintsugiBoots = 3100202; internal const int WolfMageArmor = 3100210; internal const int WolfMageHelmet = 3100211; internal const int WolfMageBoots = 3100212; internal const int WolfMedicArmor = 3100220; internal const int WolfMedicHelmet = 3100221; internal const int WolfMedicBoots = 3100222; internal const int HorrorArmor = 3100230; internal const int HorrorHelm = 3100231; internal const int HorrorGreaves = 3100232; internal const int KaziteLightArmor = 3100240; internal const int KaziteLightHelmet = 3100241; internal const int KaziteLightBoots = 3100242; internal const int ShadowKaziteLightArmor = 3100243; internal const int ShadowKaziteLightHelmet = 3100244; internal const int ShadowKaziteLightBoots = 3100245; internal const int LightKaziteShirt = 3100246; internal const int ShadowLightKaziteShirt = 3100247; internal const int AntiquePlateGarb = 3100250; internal const int AntiquePlateSallet = 3100251; internal const int AntiquePlateBoots = 3100252; internal const int VirginArmor = 3100260; internal const int VirginHelmet = 3100261; internal const int VirginBoots = 3100262; internal const int CagedArmorChestplate = 3100270; internal const int CagedArmorHelm = 3100271; internal const int CagedArmorBoots = 3100272; internal const int ChalcedonyArmor = 3100400; internal const int ChalcedonyHelmet = 3100401; internal const int ChalcedonyBoots = 3100402; internal const int SlayersArmor = 3100410; internal const int SlayersHelmet = 3100411; internal const int SlayersBoots = 3100412; internal const int MinerArmor = 3100420; internal const int MinerHelmet = 3100421; internal const int MinerBoots = 3100422; internal const int NobleClothes = 3100430; internal const int NobleMask = 3100431; internal const int NobleShoes = 3100432; internal const int BarrierArmor = 3100440; internal const int BarrierHelm = 3100441; internal const int BarrierBoots = 3100442; internal const int ManawallArmor = 3100445; internal const int ManawallHelm = 3100446; internal const int ManawallBoots = 3100447; internal const int CalderaMailArmor = 3100450; internal const int CalderaMailHelm = 3100451; internal const int CalderaMailBoots = 3100452; internal const int MilitiaArmor = 3100460; internal const int MilitiaHelm = 3100461; internal const int MilitiaBoots = 3100462; internal const int VigilanteArmor = 3100465; internal const int VigilanteHelm = 3100466; internal const int VigilanteBoots = 3100467; internal const int KrypteiaArmor = 3100470; internal const int KrypteiaMask = 3100471; internal const int KrypteiaBoots = 3100472; internal const int ScarletRobes = 3100480; internal const int ScarletMask = 3100481; internal const int ScarletBoots = 3100482; internal const int ZagisBoots = 3100490; internal const int MertonsRibcage = 3200030; internal const int MertonsSkull = 3200031; internal const int MertonsShinbones = 3200032; internal const int MertonsSkullAndHat = 3200033; internal const int SkeletonHelmWithHat = 3200034; internal const int Ergagruk = 3900000; internal const int Gorkkrog = 3900001; internal const int Gargargar = 3900002; internal const int Goulggalog = 3900003; internal const int Gogo = 3900004; internal const int Garganak = 3900005; internal const int Gaberries = 4000010; internal const int CrabeyeSeed = 4000020; internal const int Turmmip = 4000030; internal const int RawMeat = 4000050; internal const int RawAlphaMeat = 4000060; internal const int LarvaEgg = 4000070; internal const int AzureShrimp = 4000090; internal const int RawRainbowTrout = 4000110; internal const int RawSalmon = 4000130; internal const int BloodMushroom = 4000150; internal const int StarMushroom = 4000180; internal const int Marshmelon = 4000190; internal const int CactusFruit = 4000200; internal const int OchreSpiceBeetle = 4000210; internal const int GravelBeetle = 4000211; internal const int CommonMushroom = 4000220; internal const int BirdEgg = 4000230; internal const int Woolshroom = 4000240; internal const int Miasmapod = 4000250; internal const int RawJewelMeat = 4000260; internal const int SmokeRoot = 4000270; internal const int KrimpNut = 4000280; internal const int Crawlberry = 4000290; internal const int CrawlberryTartine = 4000291; internal const int Purpkin = 4000300; internal const int BoozusMeat = 4000310; internal const int AntiqueEel = 4000320; internal const int ManaheartBass = 4000330; internal const int NightmareMushroom = 4000340; internal const int VeabersEgg = 4000350; internal const int DreamersRoot = 4000360; internal const int BoozusMilk = 4000380; internal const int RainbowPeach = 4000390; internal const int GoldenCrescent = 4000400; internal const int Maize = 4000410; internal const int Pypherfish = 4000420; internal const int Ambraine = 4000430; internal const int Ableroot = 4000440; internal const int CrysocollaBeetle = 4000450; internal const int FunnelBeetle = 4000460; internal const int RawTorcrabMeat = 4000470; internal const int TorcrabEgg = 4000480; internal const int BoreoBlubber = 4000500; internal const int FoodWaste = 4100000; internal const int CookedMeat = 4100010; internal const int CookedAlphaMeat = 4100011; internal const int Jerky = 4100012; internal const int AlphaJerky = 4100013; internal const int AlphaSandwich = 4100020; internal const int GaberryJam = 4100030; internal const int GrilledSalmon = 4100040; internal const int GrilledRainbowTrout = 4100090; internal const int Bread = 4100170; internal const int CierzoCeviche = 4100180; internal const int PungentPaste = 4100190; internal const int MeatStew = 4100220; internal const int OceanFricassee = 4100230; internal const int LuxeLichette = 4100240; internal const int DryMushroomBar = 4100250; internal const int PotAuFeuDuPirate = 4100260; internal const int TurmmipPotage = 4100270; internal const int MinersOmelet = 4100280; internal const int CookedLarvaEgg = 4100290; internal const int CookedBirdEgg = 4100300; internal const int GaberryTartine = 4100310; internal const int BoiledGaberries = 4100320; internal const int BoiledTurmmip = 4100330; internal const int GrilledMushroom = 4100340; internal const int CookedJewelMeat = 4100360; internal const int BoiledMiasmapod = 4100370; internal const int GrilledMarshmelon = 4100380; internal const int BoiledCactusFruit = 4100390; internal const int RagotDuMarais = 4100400; internal const int SavageStew = 4100410; internal const int MarshmelonJelly = 4100420; internal const int MarshmelonTartine = 4100430; internal const int SearedRoot = 4100440; internal const int GrilledWoolshroom = 4100450; internal const int Toast = 4100460; internal const int DiadmeDeGibier = 4100470; internal const int SpinyMeringue = 4100480; internal const int CactusPie = 4100490; internal const int BreadOfTheWild = 4100500; internal const int FungalCleanser = 4100510; internal const int StringySalad = 4100520; internal const int Poutine = 4100530; internal const int BoiledAzureShrimp = 4100540; internal const int TravelRation = 4100550; internal const int RoastedKrimpNut = 4100560; internal const int GrilledCrabeyeSeed = 4100570; internal const int BouillonDuPredateur = 4100580; internal const int GaberryWine = 4100590; internal const int BoiledCrawlberry = 4100600; internal const int BoiledPurpkin = 4100610; internal const int CookedBoozusMeat = 4100620; internal const int GrilledEel = 4100630; internal const int GrilledManaheartBass = 4100640; internal const int GrilledNightmareMushroom = 4100650; internal const int BoiledVeaberEgg = 4100660; internal const int BoiledDreamersRoot = 4100670; internal const int WarmBoozusMilk = 4100680; internal const int Flour = 4100690; internal const int FreshCream = 4100700; internal const int CrawlberryJam = 4100710; internal const int PurpkinPie = 4100720; internal const int PoudingChomeur = 4100730; internal const int AngelFoodCake = 4100740; internal const int Bagatelle = 4100750; internal const int CheeseCake = 4100760; internal const int Cipate = 4100770; internal const int PoppedMaize = 4100780; internal const int BakedCrescent = 4100790; internal const int GoldenJam = 4100800; internal const int GoldenTartine = 4100810; internal const int GrilledPypherfish = 4100820; internal const int GrilledTorcrabMeat = 4100830; internal const int TorcrabSandwich = 4100840; internal const int BatteredMaize = 4100850; internal const int CoolRainbowJam = 4100860; internal const int FrostedCrescent = 4100870; internal const int FrostedMaize = 4100880; internal const int TorcrabJerky = 4100890; internal const int CuredPypherfish = 4100900; internal const int MaizeMash = 4100910; internal const int FrostedDelight = 4100920; internal const int VagabondsGelatin = 4100930; internal const int VagabondsTartine = 4100940; internal const int CookedTorcrabEgg = 4100950; internal const int RainbowTartine = 4100960; internal const int Waterskin = 4200040; internal const int BitterSpicyTea = 4200050; internal const int SoothingTea = 4200060; internal const int NeedleTea = 4200070; internal const int MineralTea = 4200080; internal const int AbleTea = 4200090; internal const int IcedTea = 4200100; internal const int GreasyTea = 4200110; internal const int LifePotion = 4300010; internal const int AstralPotion = 4300020; internal const int EndurancePotion = 4300030; internal const int GepsDrink = 4300040; internal const int RagePotion = 4300050; internal const int DisciplinePotion = 4300060; internal const int WarmPotion = 4300070; internal const int CoolPotion = 4300080; internal const int MistPotion = 4300090; internal const int BlessedPotion = 4300100; internal const int Antidote = 4300110; internal const int PossessedPotion = 4300120; internal const int StealthPotion = 4300130; internal const int ElementalResistancePotion = 4300140; internal const int ElementalImmunityPotion = 4300150; internal const int WeatherDefensePotion = 4300160; internal const int StabilityPotion = 4300170; internal const int AssassinElixir = 4300180; internal const int HexCleaner = 4300190; internal const int StonefleshElixir = 4300200; internal const int WarriorElixir = 4300210; internal const int SurvivorElixir = 4300220; internal const int GolemElixir = 4300230; internal const int GreatLifePotion = 4300240; internal const int GreatAstralPotion = 4300250; internal const int GreatEndurancePotion = 4300260; internal const int PeacemakerElixir = 4300270; internal const int InvigoratingPotion = 4300280; internal const int EnergizingPotion = 4300281; internal const int PurityPotion = 4300290; internal const int QuartzPotion = 4300300; internal const int SanctifierPotion = 4300310; internal const int InnocencePotion = 4300320; internal const int IlluminatingPotion = 4300330; internal const int HorrorsPotion = 4300340; internal const int AlertnessPotion = 4300350; internal const int SpikedAlertnessPotion = 4300360; internal const int Panacea = 4300370; internal const int SulphurPotion = 4300380; internal const int BracingPotion = 4300390; internal const int ShimmerPotion = 4300400; internal const int ManaBellyPotion = 4300410; internal const int MarathonPotion = 4300420; internal const int BarrierPotion = 4300430; internal const int FrostedPowder = 4300440; internal const int ManticoreEgg = 4300490; internal const int BlackPearlbirdEgg = 4300495; internal const int Bandages = 4400010; internal const int PoisonRag = 4400020; internal const int PoisonVarnish = 4400021; internal const int BoltRag = 4400030; internal const int BoltVarnish = 4400031; internal const int FireRag = 4400040; internal const int FireVarnish = 4400041; internal const int IceRag = 4400050; internal const int IceVarnish = 4400051; internal const int SpiritualVarnish = 4400060; internal const int DarkVarnish = 4400070; internal const int Bullet = 4400080; internal const int BombKit = 4400090; internal const int ArrowheadKit = 4400100; internal const int ScarletGem = 4400110; internal const int Grenade = 4600000; internal const int OilBomb = 4600010; internal const int FragmentBomb = 4600020; internal const int FrostBomb = 4600030; internal const int SparkBomb = 4600040; internal const int ToxinBomb = 4600050; internal const int NerveBomb = 4600060; internal const int BlazingBomb = 4600070; internal const int FlamingBomb = 4600080; internal const int SimpleTent = 5000010; internal const int ImprovisedBedroll = 5000020; internal const int CamouflagedTent = 5000030; internal const int FurTent = 5000040; internal const int LuxuryTent = 5000050; internal const int MageTent = 5000060; internal const int PlantTent = 5000070; internal const int ScourgeCocoon = 5000080; internal const int CampfireKit = 5000101; internal const int EnchantingPedestal = 5000200; internal const int EnchantingPillar = 5000203; internal const int CalygreyBoneCage = 5000210; internal const int EtherealTotemicLodge = 5000220; internal const int CorruptionTotemicLodge = 5000222; internal const int LightningTotemicLodge = 5000224; internal const int FireTotemicLodge = 5000226; internal const int IceTotemicLodge = 5000228; internal const int GhostDrum = 5000300; internal const int SkyChimes = 5000302; internal const int CookingPot = 5010100; internal const int LightweightCookingPot = 5010105; internal const int AlchemyKit = 5010200; internal const int LightweightAlchemyKit = 5010205; internal const int TripwireTrap = 5020010; internal const int PressurePlateTrap = 5020020; internal const int ExplorerLantern = 5100000; internal const int OldLantern = 5100010; internal const int GlowstoneLantern = 5100020; internal const int FireflyLantern = 5100030; internal const int MakeshiftTorch = 5100060; internal const int IceFlameTorch = 5100070; internal const int LanternOfSouls = 5100080; internal const int CoilLantern = 5100090; internal const int VirginLantern = 5100100; internal const int DjinnsLamp = 5100110; internal const int Lexicon = 5100500; internal const int LightMendersLexicon = 5100510; internal const int RondelDagger = 5110000; internal const int BroadDagger = 5110001; internal const int RedLadysDagger = 5110002; internal const int ShivDagger = 5110003; internal const int ManticoreDagger = 5110004; internal const int ZhornsGlowstoneDagger = 5110005; internal const int HorrorDagger = 5110006; internal const int VampiricDagger = 5110007; internal const int GalvanicDagger = 5110008; internal const int WolfDagger = 5110009; internal const int AstralDagger = 5110011; internal const int ForgedGlassDagger = 5110012; internal const int HailfrostDagger = 5110015; internal const int SmokeDagger = 5110016; internal const int MilitiaDagger = 5110017; internal const int VigilanteDagger = 5110018; internal const int Chakram = 5110030; internal const int OrnateChakram = 5110040; internal const int KaziteChakram = 5110050; internal const int FrozenChakram = 5110060; internal const int MysteriousChakram = 5110070; internal const int ThornChakram = 5110090; internal const int HorrorChakram = 5110091; internal const int GalvanicChakram = 5110092; internal const int VampireChakram = 5110093; internal const int VirginChakram = 5110094; internal const int WolfChakram = 5110096; internal const int TsarChakram = 5110097; internal const int AstralChakram = 5110099; internal const int FlintlockPistol = 5110100; internal const int ObsidianChakram = 5110101; internal const int ChalcedonyChakram = 5110102; internal const int SmokeChakram = 5110104; internal const int ForgedGlassChakram = 5110105; internal const int MilitiaChakram = 5110106; internal const int VigilanteChakram = 5110107; internal const int MeteoricChakram = 5110108; internal const int CannonPistol = 5110110; internal const int DistortedExperiment = 5110111; internal const int ExperimentalChakram = 5110112; internal const int OrnatePistol = 5110120; internal const int ChimeraPistol = 5110130; internal const int BonePistol = 5110140; internal const int ObsidianPistol = 5110150; internal const int HorrorPistol = 5110160; internal const int VampiricPistol = 5110170; internal const int GalvanicPistol = 5110180; internal const int CagePistol = 5110190; internal const int KazitePistol = 5110200; internal const int WolfPistol = 5110210; internal const int AstralPistol = 5110230; internal const int ForgedGlassPistol = 5110240; internal const int ChalcedonyPistol = 5110260; internal const int HailfrostPistol = 5110270; internal const int SmokePistol = 5110280; internal const int MilitiaPistol = 5110290; internal const int VigilantePistol = 5110300; internal const int MeteoricPistol = 5110310; internal const int ScarredDagger = 5110340; internal const int GildedShiverOfTramontane = 5110345; internal const int Arrow = 5200001; internal const int FlamingArrow = 5200002; internal const int PoisonArrow = 5200003; internal const int VenomArrow = 5200004; internal const int PalladiumArrow = 5200005; internal const int ExplosiveArrow = 5200007; internal const int ForgedArrow = 5200008; internal const int HolyRageArrow = 5200009; internal const int SoulRuptureArrow = 5200010; internal const int ManaArrow = 5200019; internal const int AdventurerBackpack = 5300000; internal const int MefinosTradeBackpack = 5300030; internal const int ProspectorBackpack = 5300040; internal const int GlowstoneBackpack = 5300050; internal const int AlchemistBackpack = 5300060; internal const int BrassWolfBackpack = 5300070; internal const int NomadBackpack = 5300110; internal const int PrimitiveSatchel = 5300120; internal const int StrongboxBackpack = 5300130; internal const int TraderBackpack = 5300140; internal const int ScaledSatchel = 5300150; internal const int PreservationBackpack = 5300160; internal const int LightMendersBackpack = 5300170; internal const int ZhornsHuntingBackpack = 5300180; internal const int BoozuHideBackpack = 5300190; internal const int LargeChalcedonyStone = 5380000; internal const int ChargedForgeStone = 5380001; internal const int ChalcedonyBackpack = 5380002; internal const int WeaversBackpack = 5380003; internal const int DuskBackpack = 5380004; internal const int BrigandsBackpack = 5380005; internal const int IronWristband = 5400100; internal const int PalladiumWristband = 5400101; internal const int CleanWater = 5600000; internal const int RiverWater = 5600001; internal const int SaltWater = 5600002; internal const int RancidWater = 5600003; internal const int LeylineWater = 5600004; internal const int SparklingWater = 5600005; internal const int HealingWater = 5600006; internal const int FlintAndSteel = 5600010; internal const int HangmansKey = 5600020; internal const int OldLevantsKey = 5600021; internal const int JadeLichsIdol = 5600022; internal const int BanditCampKey = 5600023; internal const int EnmerkarTombKey = 5600024; internal const int VigilLockKey = 5600025; internal const int DeadRootsKey = 5600026; internal const int VendavelKey = 5600027; internal const int VendavelPrisonKey = 5600028; internal const int CierzoTownKey = 5600029; internal const int ScarletLichsIdol = 5600030; internal const int PalacePassageKey = 5600031; internal const int KrypteiaTombKey = 5600032; internal const int SkillStorageTablet = 5600040; internal const int WritOfTribalFavor = 5600050; internal const int MontcalmKey = 5600060; internal const int LowerLivingQuartersKey = 5600070; internal const int TrainKeyB = 5600080; internal const int GemstoneKeyA = 5600090; internal const int GemstoneKeyB = 5600091; internal const int GemstoneKeyC = 5600092; internal const int GemstoneKeyD = 5600093; internal const int FoundryAssemblyLineKey = 5600100; internal const int LowerFoundryKey = 5600101; internal const int LoadingDocksElevatorKey = 5600110; internal const int LoadingDocksKey = 5600111; internal const int WarehouseKey = 5600120; internal const int TrainKeyA = 5600121; internal const int LowerTestChamberKey = 5600122; internal const int LowerLaboratoryKey = 5600130; internal const int MisplacedLabLever = 5600140; internal const int OldHarmattanSouthKey = 5600150; internal const int OldHarmattanNorthKey = 5600151; internal const int ManaTransferElevatorKey = 5600160; internal const int TroglodyteCageKey = 5600170; internal const int BanditCageKey = 5600171; internal const int RefineryKeyDepths = 5600172; internal const int RefineryKeyUpper = 5600173; internal const int SmellySealedBox = 5600174; internal const int MyrmitaurHavenGateKey = 5600175; internal const int ConquerorsMedal = 5600176; internal const int GepsNote = 5601001; internal const int WatchersNote = 5601003; internal const int ChemistsBrokenFlask = 5601010; internal const int CookingBitterSpicyTea = 5700011; internal const int CookingOceanFricassee = 5700013; internal const int CookingMinersOmelet = 5700015; internal const int CookingPungentPaste = 5700016; internal const int CookingGaberriesJam = 5700017; internal const int CookingJerky = 5700018; internal const int CookingAlphaJerky = 5700019; internal const int CookingDryMushroomBar = 5700020; internal const int CookingTurmmipPotage = 5700021; internal const int CraftingFangAxe = 5700022; internal const int CraftingFangSword = 5700023; internal const int CraftingFangClub = 5700024; internal const int CraftingFangTrident = 5700025; internal const int CraftingFangGreataxe = 5700026; internal const int CraftingFangGreatsword = 5700027; internal const int CraftingFangGreatclub = 5700028; internal const int CraftingFangHalberd = 5700029; internal const int CraftingFangShield = 5700030; internal const int CraftingTripwireTrap = 5700038; internal const int CookingCierzoCeviche = 5700046; internal const int CookingLuxeLichette = 5700047; internal const int CookingPotAuFeuDuPirate = 5700048; internal const int CookingAlphaSandwich = 5700049; internal const int CookingGaberryTartine = 5700050; internal const int CookingRagoutDuMarais = 5700058; internal const int CookingSavageStew = 5700059; internal const int CookingMarshmelonJelly = 5700060; internal const int CookingMarshmelonTartine = 5700061; internal const int CookingDiademeDeGibier = 5700065; internal const int CookingSpinyMeringue = 5700066; internal const int CookingCactusPie = 5700067; internal const int CookingBreadOfTheWild = 5700068; internal const int CookingFungalCleanser = 5700069; internal const int CookingStringySalad = 5700070; internal const int CookingSoothingTea = 5700073; internal const int CookingNeedleTea = 5700074; internal const int CookingMineralTea = 5700075; internal const int AlchemyFireStone = 5700076; internal const int CraftingHorrorBow = 5700077; internal const int CraftingHorrorAxe = 5700078; internal const int CraftingHorrorShield = 5700079; internal const int CraftingManticoreGreatmace = 5700080; internal const int CraftingAssassinSword = 5700081; internal const int CraftingAssassinClaymore = 5700082; internal const int CraftingMantisGreatpick = 5700083; internal const int CraftingCrescentGreataxe = 5700084; internal const int CraftingCrescentScythe = 5700085; internal const int CraftingThornySpear = 5700086; internal const int CraftingThornyClaymore = 5700087; internal const int CraftingBeastGolemAxe = 5700088; internal const int CraftingBeastGolemHalberd = 5700089; internal const int CraftingTuanosaurAxe = 5700090; internal const int CraftingTuanosaurGreataxe = 5700091; internal const int CraftingPhytosaurSpear = 5700092; internal const int CraftingMakeshiftLeatherHat = 5700093; internal const int CraftingMakeshiftLeatherAttire = 5700094; internal const int CraftingMakeshiftLeatherBoots = 5700095; internal const int CraftingScaledLeatherHat = 5700096; internal const int CraftingScaledLeatherAttire = 5700097; internal const int CraftingScaledLeatherBoots = 5700098; internal const int CraftingPoisonRag = 5700099; internal const int CraftingBoltRag = 5700100; internal const int CraftingFireRag = 5700101; internal const int CraftingIceRag = 5700102; internal const int AlchemyPoisonVarnish = 5700103; internal const int AlchemyBoltVarnish = 5700104; internal const int AlchemyFireVarnish = 5700105; internal const int AlchemyIceVarnish = 5700106; internal const int AlchemySpiritualVarnish = 5700107; internal const int AlchemyAstralPotion = 5700108; internal const int AlchemyEndurancePotion = 5700109; internal const int AlchemyLifePotion = 5700110; internal const int AlchemyAntidote = 5700111; internal const int AlchemyRagePotion = 5700112; internal const int AlchemyDisciplinePotion = 5700113; internal const int AlchemyWarmPotion = 5700114; internal const int AlchemyCoolPotion = 5700115; internal const int AlchemyMistPotion = 5700116; internal const int AlchemyBlessedPotion = 5700117; internal const int AlchemyPossessedPotion = 5700118; internal const int AlchemyStealthPotion = 5700119; internal const int CraftingCoralhornBow = 5700120; internal const int AlchemyElementalImmunityPotion = 5700121; internal const int AlchemyElementalResPotion = 5700122; internal const int AlchemyWeatherDefPotion = 5700123; internal const int AlchemyStabilityPotion = 5700124; internal const int AlchemyAssassinsElixir = 5700125; internal const int AlchemyHexCleaner = 5700126; internal const int AlchemyStonefleshElixir = 5700127; internal const int AlchemyWarriorElixir = 5700128; internal const int AlchemySurvivorElixir = 5700129; internal const int AlchemyGolemElixir = 5700130; internal const int AlchemyDarkVarnish = 5700132; internal const int CraftingIceFlameTorch = 5700137; internal const int CraftingGolemRapier = 5700138; internal const int CraftingBullets = 5700139; internal const int AlchemyGreatLifePotion = 5700146; internal const int AlchemyGreatAstralPotion = 5700147; internal const int AlchemyGreatEndurancePotion = 5700148; internal const int CookingBouillonDuPredateur = 5700152; internal const int CraftingObsidianMace = 5700157; internal const int CraftingObsidianGreatmace = 5700158; internal const int CraftingObsidianPistol = 5700159; internal const int CraftingManticoreDagger = 5700161; internal const int CraftingShivDagger = 5700162; internal const int CraftingBonePistol = 5700163; internal const int CraftingGoldLichClaymore = 5700166; internal const int CraftingGoldLichSpear = 5700167; internal const int CraftingGoldLichSword = 5700168; internal const int CraftingGoldLichMace = 5700169; internal const int CraftingGoldLichShield = 5700170; internal const int CraftingSpikesIron = 5700171; internal const int CraftingSpikesPalladium = 5700172; internal const int AlchemyChargeIncendiary = 5700173; internal const int AlchemyChargeToxic = 5700174; internal const int AlchemyChargeNerveGas = 5700175; internal const int AlchemyColdStone = 5700178; internal const int CraftingScaledSatchel = 5700180; internal const int CraftingAmmoliteArmor = 5700182; internal const int CraftingAmmoliteHelm = 5700183; internal const int CraftingAmmoliteBoots = 5700184; internal const int CraftingOldLantern = 5700187; internal const int CraftingChitinDesertTunic = 5700189; internal const int AlchemyEnergizePotion = 5700190; internal const int AlchemyInvigoratePotion = 5700191; internal const int AlchemyPurityPotion = 5700192; internal const int AlchemyQuartzPotion = 5700193; internal const int AlchemySanctifierPotion = 5700194; internal const int AlchemyInnocencePotion = 5700195; internal const int AlchemyIlluminatingPotion = 5700196; internal const int AlchemyHorrorsPotion = 5700197; internal const int AlchemyAlertnessPotion = 5700198; internal const int AlchemySpikedAlertnessPotion = 5700199; internal const int CookingFlour = 5700200; internal const int CookingFreshCream = 5700210; internal const int CookingCrawlberryJam = 5700220; internal const int CookingPurpkinPie = 5700230; internal const int CookingPoudingChomeur = 5700240; internal const int CookingAngelFoodCake = 5700250; internal const int CookingBagatelle = 5700260; internal const int CookingCheeseCake = 5700270; internal const int CookingCipate = 5700280; internal const int CraftingPressurePlateArcaneDampener = 5700290; internal const int RecipeVirginSword = 5700300; internal const int RecipeVirginClaymore = 5700301; internal const int RecipeVirginMace = 5700302; internal const int RecipeVirginGreathammer = 5700303; internal const int RecipeVirginAxe = 5700304; internal const int RecipeVirginGreataxe = 5700305; internal const int RecipeVirginChakram = 5700306; internal const int RecipeVirginBow = 5700307; internal const int RecipeVirginHalberd = 5700308; internal const int RecipeVirginSpear = 5700309; internal const int RecipeVirginShield = 5700310; internal const int CraftingGalvanicMace = 5700311; internal const int CraftingGalvanicGreatMace = 5700312; internal const int CraftingGalvanicAxe = 5700313; internal const int CraftingGalvanicGreatAxe = 5700314; internal const int CraftingGalvanicDagger = 5700315; internal const int CraftingGalvanicPistol = 5700316; internal const int CraftingGalvanicBow = 5700317; internal const int CraftingGalvanicHalberd = 5700318; internal const int CraftingGalvanicSpear = 5700319; internal const int CraftingGalvanicShield = 5700320; internal const int CraftingGalvanicFists = 5700321; internal const int CraftingHorrorSword = 5700322; internal const int CraftingHorrorGreatsword = 5700323; internal const int CraftingHorrorMace = 5700324; internal const int CraftingHorrorGreatMace = 5700325; internal const int CraftingHorrorGreatAxe = 5700326; internal const int CraftingHorrorSpear = 5700327; internal const int CraftingHorrorHalberd = 5700328; internal const int CraftingHorrorPistol = 5700329; internal const int CraftingHorrorChakram = 5700330; internal const int CraftingHorrorFist = 5700331; internal const int CraftingHorrorArmor = 5700332; internal const int CraftingHorrorHelmet = 5700333; internal const int CraftingHorrorBoots = 5700334; internal const int CraftingClothKnuckles = 5700335; internal const int CraftingIronKnuckles = 5700336; internal const int CraftingFangKnuckles = 5700337; internal const int CraftingScourgeCocoon = 5700338; internal const int CraftingBoozuBackpack = 5700339; internal const int CraftingVirginLanternRefill = 5700340; internal const int AlchemyMonarchIncense = 5700341; internal const int AlchemyAdmiralIncense = 5700342; internal const int AlchemyPaleBeautyIncense = 5700343; internal const int AlchemyChysalisIncense = 5700344; internal const int AlchemyCecropiaIncense = 5700345; internal const int AlchemyMorphoIncense = 5700346; internal const int AlchemySylphinaIncense = 5700347; internal const int AlchemyCometIncense = 5700348; internal const int AlchemyLunaIncense = 5700349; internal const int AlchemyApolloIncense = 5700350; internal const int CookingBread = 5700351; internal const int CookingCrawlberryTartine = 5700352; internal const int AlchemyAlphaMeat = 5700353; internal const int CraftingGoldLichKnuckles = 5700397; internal const int CraftingSlayersHelm = 5700398; internal const int CraftingSlayersArmor = 5700399; internal const int CraftingSlayersBoots = 5700400; internal const int CraftingFireTotemicLodge = 5700401; internal const int CraftingIceTotemicLodge = 5700402; internal const int CraftingLightningTotemicLodge = 5700403; internal const int CraftingCorruptionTotemicLodge = 5700404; internal const int CraftingEtherealTotemicLodge = 5700405; internal const int CookingGoldenJam = 5700406; internal const int CookingGoldenTartine = 5700407; internal const int CookingTorcrabSandwich = 5700408; internal const int CookingBatteredMaize = 5700409; internal const int CookingCoolRainbowJam = 5700410; internal const int CookingFrostedCrescent = 5700411; internal const int CookingFrostedMaize = 5700412; internal const int CookingTorcrabJerky = 5700413; internal const int CookingCuredPypherfish = 5700415; internal const int CookingMaizeMash = 5700416; internal const int CookingFrostedDelight = 5700417; internal const int CookingVagabondsGelatin = 5700418; internal const int CookingVagabondsTartine = 5700419; internal const int CookingRainbowTartine = 5700420; internal const int CookingAbleTea = 5700421; internal const int CookingIcedTea = 5700422; internal const int RecipeGreasyTea = 5700423; internal const int CraftingObsidianSword = 5700424; internal const int CraftingObsidianClaymore = 5700425; internal const int CraftingObsidianAxe = 5700426; internal const int CraftingObsidianGreataxe = 5700427; internal const int CraftingObsidianSpear = 5700428; internal const int CraftingObsidianHalberd = 5700429; internal const int CraftingObsidianBow = 5700430; internal const int CraftingObsidianKnuckles = 5700431; internal const int CraftingObsidianChakram = 5700434; internal const int CraftingChalcedonySword = 5700435; internal const int CraftingChalcedonyClaymore = 5700436; internal const int CraftingChalcedonyAxe = 5700437; internal const int CraftingChalcedonyGreataxe = 5700438; internal const int CraftingChalcedonySpear = 5700439; internal const int CraftingChalcedonyHalberd = 5700440; internal const int CraftingChalcedonyBow = 5700441; internal const int CraftingChalcedonyKnuckles = 5700442; internal const int CraftingChalcedonyChakram = 5700445; internal const int CraftingAstralSword = 5700446; internal const int CraftingAstralClaymore = 5700447; internal const int CraftingAstralMace = 5700448; internal const int CraftingAstralGreatmace = 5700449; internal const int CraftingAstralAxe = 5700450; internal const int CraftingAstralGreataxe = 5700451; internal const int CraftingAstralSpear = 5700452; internal const int CraftingAstralHalberd = 5700453; internal const int CraftingAstralBow = 5700454; internal const int CraftingAstralKnuckles = 5700455; internal const int CraftingAstralStaff = 5700456; internal const int CraftingAstralShield = 5700457; internal const int CraftingAstralDagger = 5700458; internal const int CraftingAstralPistol = 5700459; internal const int CraftingAstralChakram = 5700460; internal const int AlchemyPanacea = 5700461; internal const int AlchemyBracingPotion = 5700462; internal const int AlchemyBarrierPotion = 5700463; internal const int AlchemyShimmerPotion = 5700464; internal const int AlchemyManaBellyPotion = 5700465; internal const int AlchemyMarathonPotion = 5700466; internal const int AlchemyFrostedPowder = 5700467; internal const int CraftingChalcedonyMace = 5700468; internal const int CraftingChalcedonyHammer = 5700469; internal const int AlchemyOilBomb = 5700470; internal const int AlchemyFragmentBomb = 5700471; internal const int AlchemyFrostBomb = 5700472; internal const int AlchemySparkBomb = 5700473; internal const int AlchemyFlamingBomb = 5700474; internal const int AlchemyToxinBomb = 5700475; internal const int AlchemyNerveBomb = 5700476; internal const int AlchemyBlazingBomb = 5700477; internal const int AlchemyFlamingArrow = 5700478; internal const int AlchemyPoisonArrow = 5700479; internal const int AlchemyVenomArrow = 5700480; internal const int AlchemyPalladiumArrow = 5700481; internal const int AlchemyManaArrow = 5700483; internal const int AlchemyHolyRageArrow = 5700484; internal const int AlchemySoulRuptureArrow = 5700485; internal const int CraftingChalcedonyPistol = 5700486; internal const int AlchemySulphurPotion = 5700487; internal const int EnchantingCastigation = 5800001; internal const int EnchantingHumiliation = 5800002; internal const int EnchantingThirst = 5800003; internal const int EnchantingFavorableWind = 5800004; internal const int EnchantingForgeFire = 5800005; internal const int EnchantingWendigosBreath = 5800006; internal const int EnchantingPriestsPrayers = 5800007; internal const int EnchantingScourgesOutbreak = 5800008; internal const int EnchantingSpectersWail = 5800009; internal const int EnchantingDesertsSun = 5800010; internal const int EnchantingWintersCruelty = 5800011; internal const int EnchantingFoggyMemories = 5800012; internal const int EnchantingRot = 5800013; internal const int EnchantingStorm = 5800014; internal const int EnchantingTheGoodMoon = 5800015; internal const int EnchantingForbiddenKnowledge = 5800016; internal const int EnchantingSanguineFlame = 5800017; internal const int EnchantingCopperFlame = 5800018; internal const int EnchantingAngelLight = 5800019; internal const int EnchantingBlazeBlue = 5800020; internal const int EnchantingRain = 5800021; internal const int EnchantingCompass = 5800022; internal const int EnchantingGuidanceOfWind = 5800023; internal const int EnchantingSpiritOfCierzo = 5800024; internal const int EnchantingSpiritOfBerg = 5800025; internal const int EnchantingSpiritOfLevant = 5800026; internal const int EnchantingSpiritOfHarmattan = 5800027; internal const int EnchantingSpiritOfMonsoon = 5800028; internal const int EnchantingInstinct = 5800029; internal const int EnchantingAdrenaline = 5800030; internal const int EnchantingMusingOfAPhilosopher = 5800031; internal const int EnchantingIrrepressibleAnger = 5800032; internal const int EnchantingWhiplash = 5800033; internal const int EnchantingAegis = 5800034; internal const int EnchantingIsolatedRumination = 5800035; internal const int EnchantingPrimalWind = 5800036; internal const int EnchantingAbundance = 5800037; internal const int EnchantingLightAsWind = 5800038; internal const int EnchantingUnexpectedResilience = 5800039; internal const int EnchantingUnsuspectedStrength = 5800040; internal const int EnchantingUnassumingIngenuity = 5800041; internal const int EnchantingUnwaveringDetermination = 5800042; internal const int EnchantingCrumblingAnger = 5800043; internal const int EnchantingWarMemento = 5800044; internal const int EnchantingElattsSanctity = 5800045; internal const int EnchantingTwang = 5800046; internal const int EnchantingFilter = 5800047; internal const int EnchantingFlux = 5800048; internal const int EnchantingWarmaster = 5800049; internal const int EnchantingInnerCool = 5800050; internal const int EnchantingInnerWarmth = 5800051; internal const int EnchantingCocoon = 5800052; internal const int EnchantingAssassin = 5800053; internal const int EnchantingEconomy = 5800054; internal const int EnchantingFormlessMaterial = 5800055; internal const int EnchantingArcaneUnison = 5800056; internal const int EnchantingRascalsVerve = 5800057; internal const int EnchantingBeastOfBurden = 5800058; internal const int EnchantingEnkindle = 5800059; internal const int EnchantingSnow = 5800060; internal const int EnchantingRainbowHex = 5800061; internal const int EnchantingAbomination = 5800062; internal const int EnchantingRedemption = 5800063; internal const int EnchantingWeightless = 5800064; internal const int EnchantingPoltergeist = 5800065; internal const int EnchantingStabilizingForces = 5800066; internal const int EnchantingSpeedAndEfficiency = 5800067; internal const int EnchantingOrderAndDiscipline = 5800068; internal const int EnchantingChaosAndCreativity = 5800069; internal const int EnchantmentInferno = 5800070; internal const int EnchantmentMolepigsigh = 5800071; internal const int EnchantmentFulmination = 5800072; internal const int EnchantmentFreedom = 5800073; internal const int EnchantmentCalmsoul = 5800074; internal const int EnchantmentSangfroid = 5800075; internal const int EnchantmentContagion = 5800076; internal const int EnchantmentShelter = 5800077; internal const int EnchantmentEtherwave = 5800078; internal const int EnchantmentLevantinesecret = 5800079; internal const int EnchantmentTrauma = 5800080; internal const int EnchantmentTelekinesis = 5800081; internal const int EnchantmentProtectivepresence = 5800082; internal const int EnchantmentGuidedarm = 5800083; internal const int EnchantmentTunnelsend = 5800084; internal const int EnchantmentMidnightdance = 5800085; internal const int EnchantmentFetchbuch = 5800086; internal const int EnchantmentInheritanceofthepast = 5800087; internal const int FireflyPowder = 6000010; internal const int GreasyFern = 6000020; internal const int Livweedi = 6000030; internal const int GhostsEye = 6000040; internal const int Seaweed = 6000060; internal const int Salt = 6000070; internal const int Frankincense = 6000100; internal const int ElementalParticleFire = 6000110; internal const int ElementalParticleIce = 6000120; internal const int ElementalParticleLight = 6000130; internal const int ElementalParticleDecay = 6000140; internal const int ElementalParticleEther = 6000150; internal const int LiquidCorruption = 6000160; internal const int PurifyingQuartz = 6000170; internal const int ApolloIncense = 6000180; internal const int AdmiralIncense = 6000190; internal const int MonarchIncense = 6000200; internal const int PaleBeautyIncense = 6000210; internal const int ChrysalisIncense = 6000220; internal const int LunaIncense = 6000230; internal const int MorphoIncense = 6000240; internal const int SylphinaIncense = 6000250; internal const int CometIncense = 6000260; internal const int CecropiaIncense = 6000270; internal const int SulphuricMushroom = 6000280; internal const int CalygreyHairs = 6000290; internal const int MyrmTongue = 6000300; internal const int DwellersBrain = 6000310; internal const int GargoyleUrnShard = 6000320; internal const int PeachSeeds = 6000330; internal const int OreSample = 6000340; internal const int DiamondDust = 6000350; internal const int ChromiumShards = 6000360; internal const int AmethystGeode = 6000370; internal const int PlantSample = 6000380; internal const int FlashMoss = 6000390; internal const int Bloodroot = 6000400; internal const int VoltaicVines = 6000410; internal const int MolepigSpecimen = 6000420; internal const int Ectoplasm = 6000430; internal const int PetrifiedOrgans = 6000440; internal const int DigestedManaStone = 6000450; internal const int ShortHandle = 6000460; internal const int LongHandle = 6000470; internal const int TrinketHandle = 6000480; internal const int ShaftHandle = 6000490; internal const int BladePrism = 6000500; internal const int BluntPrism = 6000510; internal const int FlatPrism = 6000520; internal const int SpikePrism = 6000530; internal const int BoreoTusk = 6005340; internal const int WaningTentacle = 6005350; internal const int NephriteGemstone = 6005360; internal const int Wood = 6100010; internal const int TsarStone = 6200010; internal const int Cobalt = 6200030; internal const int ButchersAmethyst = 6200040; internal const int Ammolite = 6200050; internal const int Copal = 6200060; internal const int TinyAquamarine = 6200070; internal const int Diamond = 6200080; internal const int LargeEmerald = 6200090; internal const int SmallSapphire = 6200100; internal const int MediumRuby = 6200110; internal const int Onyx = 6200120; internal const int Hackmanite = 6200130; internal const int Topaz = 6200140; internal const int PowerCoil = 6200150; internal const int BlueSkullEffigy = 6200160; internal const int Tourmaline = 6200170; internal const int GoldIngot = 6300030; internal const int PalladiumScrap = 6400070; internal const int PetrifiedWood = 6400080; internal const int BlueSand = 6400110; internal const int ManaStone = 6400130; internal const int IronScrap = 6400140; internal const int ShieldGolemScraps = 6400141; internal const int Chalcedony = 6400160; internal const int HexaStone = 6400170; internal const int FireStone = 6500010; internal const int ColdStone = 6500020; internal const int DarkStone = 6500031; internal const int LinenCloth = 6500090; internal const int SpikesIron = 6500100; internal const int SpikesPalladium = 6500110; internal const int ChargeIncendiary = 6500120; internal const int ChargeToxic = 6500130; internal const int ChargeNerveGas = 6500140; internal const int SpikesWood = 6500150; internal const int ArcaneDampener = 6500160; internal const int Wheat = 6600010; internal const int Sugar = 6600011; internal const int Stingleaf = 6600012; internal const int Hide = 6600020; internal const int BoozusHide = 6600021; internal const int ScaledLeather = 6600030; internal const int CrystalPowder = 6600040; internal const int PredatorBones = 6600050; internal const int CoralhornAntler = 6600060; internal const int ThickOil = 6600070; internal const int InsectHusk = 6600080; internal const int MantisGranite = 6600090; internal const int OccultRemains = 6600110; internal const int HorrorChitin = 6600120; internal const int GreenHorrorChitin = 6600121; internal const int PureChitin = 6600122; internal const int BeastGolemScraps = 6600130; internal const int ThornyCartilage = 6600140; internal const int ManticoreTail = 6600150; internal const int PhytosaurHorn = 6600160; internal const int SharkCartilage = 6600170; internal const int AssassinTongue = 6600180; internal const int AlphaTuanosaurTail = 6600190; internal const int ObsidianShard = 6600200; internal const int GoldLichMechanism = 6600210; internal const int GepsGenerosity = 6600220; internal const int PearlbirdsCourage = 6600221; internal const int ElattsRelic = 6600222; internal const int ScourgesTears = 6600223; internal const int HauntedMemory = 6600224; internal const int CalixasRelic = 6600225; internal const int LeylineFigment = 6600226; internal const int VendavelsHospitality = 6600227; internal const int FloweringCorruption = 6600228; internal const int EnchantedMask = 6600229; internal const int MetalizedBones = 6600230; internal const int ScarletWhisper = 6600231; internal const int NoblesGreed = 6600232; internal const int CalygreysWisdom = 6600233; internal const int GiantHeartGarnet = 7400050; internal const int Silver = 9000010; internal const int BlueprintHouseA = 9400010; internal const int BlueprintHouseB = 9400020; internal const int BlueprintHouseC = 9400030; internal const int BlueprintStockpile = 9400100; internal const int BlueprintStockpileUpgradeWarehouse = 9400102; internal const int BlueprintCityHall = 9400120; internal const int BlueprintCityHallUpgradeEmbassy = 9400122; internal const int BlueprintCityHallUpgradeKrypteiaHideout = 9400123; internal const int BlueprintHuntingLodge = 9400130; internal const int BlueprintHuntingLodgeUpgradeHuntingGuild = 9400132; internal const int BlueprintHuntingLodgeUpgradeHuntingHall = 9400133; internal const int BlueprintMasonsWorkshop = 9400140; internal const int BlueprintMasonsWorkshopUpgradeStonecutterGuild = 9400142; internal const int BlueprintMasonsWorkshopUpgradeStonecutterHall = 9400143; internal const int BlueprintWoodcuttersLodge = 9400150; internal const int BlueprintWoodcuttersLodgeUpgradeCarpenterGuild = 9400152; internal const int BlueprintWoodcuttersLodgeUpgradeCarpenterHall = 9400153; internal const int BlueprintBlacksmithShop = 9400160; internal const int BlueprintBlacksmithShopUpgradeWeaponForge = 9400162; internal const int BlueprintBlacksmithShopUpgradeArmorForge = 9400163; internal const int BlueprintAlchemistShop = 9400170; internal const int BlueprintAlchemistShopUpgradeFletchersWorkshop = 9400172; internal const int BlueprintAlchemistShopUpgradeLevantinLaboratory = 9400173; internal const int BlueprintEnchantingGuild = 9400180; internal const int BlueprintEnchantingGuildUpgradeExpandedLibrary = 9400182; internal const int BlueprintEnchantingGuildUpgradeSoroboreanLaboratory = 9400183; internal const int BlueprintFoodStore = 9400190; internal const int BlueprintFoodStoreUpgradeInnExpansion = 9400192; internal const int BlueprintFoodStoreUpgradeCommunalGarden = 9400193; internal const int BlueprintGladiatorsArena = 9400200; internal const int BlueprintGladiatorsArenaUpgradeTrainingGrounds = 9400202; internal const int BlueprintGladiatorsArenaUpgradeCombatAcademy = 9400203; internal const int BlueprintChapel = 9400210; internal const int BlueprintChapelUpgradeTempleExpansion = 9400212; internal const int BlueprintChapelUpgradeLotusOfLight = 9400213; internal const int BlueprintGeneralStore = 9400220; internal const int BlueprintGeneralStoreUpgradeCourierWagon = 9400222; internal const int BlueprintGeneralStoreUpgradeCaravanWagon = 9400223;