Decompiled source of GenesisBook v3.0.14
patchers/ProjectGenesis.Preloader.dll
Decompiled 3 weeks agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using Mono.Cecil; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("3.0.14.0")] namespace ProjectGenesis; public static class Preloader { public static IEnumerable<string> TargetDLLs { get; } = new string[1] { "Assembly-CSharp.dll" }; private static TypeDefinition GetTypeByName(this AssemblyDefinition assembly, string name) { return ((IEnumerable<TypeDefinition>)assembly.MainModule.Types).FirstOrDefault((Func<TypeDefinition, bool>)((TypeDefinition t) => ((MemberReference)t).FullName == name)); } private static FieldDefinition GetFieldByName(this TypeDefinition type, string name) { return ((IEnumerable<FieldDefinition>)type.Fields).FirstOrDefault((Func<FieldDefinition, bool>)((FieldDefinition t) => ((MemberReference)t).Name == name)); } private static void AddEnumField(this TypeDefinition type, string name, object constant, FieldAttributes fieldAttributes) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown type.Fields.Add(new FieldDefinition(name, fieldAttributes, (TypeReference)(object)type) { Constant = constant }); } private static void AddTypeField(this AssemblyDefinition assembly, string typeName, string oriFieldName, string newFieldName) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown TypeDefinition typeByName = assembly.GetTypeByName(typeName); FieldDefinition fieldByName = typeByName.GetFieldByName(oriFieldName); typeByName.Fields.Add(new FieldDefinition(newFieldName, fieldByName.Attributes, ((FieldReference)fieldByName).FieldType)); } public static void Patch(AssemblyDefinition assembly) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) TypeDefinition typeByName = assembly.GetTypeByName("EVeinType"); FieldDefinition val = ((IEnumerable<FieldDefinition>)typeByName.Fields).FirstOrDefault((Func<FieldDefinition, bool>)((FieldDefinition i) => i.HasDefault && (byte)i.Constant == 15)); if (val != null) { typeByName.Fields.Remove(val); } FieldAttributes fieldAttributes = (FieldAttributes)32854; typeByName.AddEnumField("Aluminum", 15, fieldAttributes); typeByName.AddEnumField("Radioactive", 16, fieldAttributes); typeByName.AddEnumField("Tungsten", 17, fieldAttributes); typeByName.AddEnumField("Sulfur", 18, fieldAttributes); assembly.AddTypeField("PlanetData", "birthResourcePoint0", "birthResourcePoint2"); assembly.AddTypeField("PlanetData", "birthResourcePoint0", "birthResourcePoint3"); assembly.AddTypeField("PlanetData", "birthResourcePoint0", "birthResourcePoint4"); assembly.AddTypeField("GameDesc", "isSandboxMode", "isFastStartMode"); } }
plugins/Newtonsoft.Json.dll
Decompiled 3 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.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.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.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.IgnoreSymbolStoreSequencePoints)] [assembly: AllowPartiallyTrustedCallers] [assembly: InternalsVisibleTo("Newtonsoft.Json.Schema, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f561df277c6c0b497d629032b410cdcf286e537c054724f7ffa0164345f62b3e642029d7a80cc351918955328c4adc8a048823ef90b0cf38ea7db0d729caf2b633c3babe08b0310198c1081995c19029bc675193744eab9d7345b8a67258ec17d112cebdbbb2a281487dceeafb9d83aa930f32103fbe1d2911425bc5744002c7")] [assembly: InternalsVisibleTo("Newtonsoft.Json.Tests, PublicKey=0024000004800000940000000602000000240000525341310004000001000100f561df277c6c0b497d629032b410cdcf286e537c054724f7ffa0164345f62b3e642029d7a80cc351918955328c4adc8a048823ef90b0cf38ea7db0d729caf2b633c3babe08b0310198c1081995c19029bc675193744eab9d7345b8a67258ec17d112cebdbbb2a281487dceeafb9d83aa930f32103fbe1d2911425bc5744002c7")] [assembly: InternalsVisibleTo("Newtonsoft.Json.Dynamic, PublicKey=0024000004800000940000000602000000240000525341310004000001000100cbd8d53b9d7de30f1f1278f636ec462cf9c254991291e66ebb157a885638a517887633b898ccbcf0d5c5ff7be85a6abe9e765d0ac7cd33c68dac67e7e64530e8222101109f154ab14a941c490ac155cd1d4fcba0fabb49016b4ef28593b015cab5937da31172f03f67d09edda404b88a60023f062ae71d0b2e4438b74cc11dc9")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("9ca358aa-317b-4925-8ada-4a29e943a363")] [assembly: CLSCompliant(true)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")] [assembly: AssemblyCompany("Newtonsoft")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © James Newton-King 2008")] [assembly: AssemblyDescription("Json.NET is a popular high-performance JSON framework for .NET")] [assembly: AssemblyFileVersion("12.0.3.23909")] [assembly: AssemblyInformationalVersion("12.0.3+7c3d7f8da7e35dde8fa74188b0decff70f8f10e3")] [assembly: AssemblyProduct("Json.NET")] [assembly: AssemblyTitle("Json.NET .NET Standard 2.0")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: AssemblyVersion("12.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.Module | 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; 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) { if (!value) { return False; } return True; } 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) { if (nullable) { return Null; } return "0.0"; } 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) { StringWriter stringWriter = new StringWriter(new StringBuilder(256), 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] [return: MaybeNull] public static T DeserializeObject<T>(string value, params JsonConverter[] converters) { return (T)DeserializeObject(value, typeof(T), converters); } [DebuggerStepThrough] [return: MaybeNull] 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) { 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, [AllowNull] 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, [AllowNull] 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; 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) { if (type != JsonContainerType.Array) { return type == JsonContainerType.Constructor; } return true; } 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[] array = buffer.ToArray(); SetToken(JsonToken.Bytes, array, updateIndex: false); return array; } 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; if (tokenType == JsonToken.None || tokenType == JsonToken.Comment) { return MoveToContentFromNonContentAsync(cancellationToken); } return AsyncUtils.True; } private async Task<bool> MoveToContentFromNonContentAsync(CancellationToken cancellationToken) { JsonToken tokenType; do { if (!(await ReadAsync(cancellationToken).ConfigureAwait(continueOnCapturedContext: false))) { return false; } tokenType = TokenType; } while (tokenType == JsonToken.None || tokenType == 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; 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) { return (int)value; } 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[] array2 = ReadAsBytes(); ReaderReadAndAssert(); if (TokenType != JsonToken.EndObject) { throw JsonReaderException.Create(this, "Error reading bytes. Unexpected token: {0}.".FormatWith(CultureInfo.InvariantCulture, TokenType)); } SetToken(JsonToken.Bytes, array2, updateIndex: false); return array2; } case JsonToken.String: { string text = (string)Value; Guid g; byte[] array3 = ((text.Length == 0) ? CollectionUtils.ArrayEmpty<byte>() : ((!ConvertUtils.TryConvertGuid(text, out g)) ? Convert.FromBase64String(text) : g.ToByteArray())); SetToken(JsonToken.Bytes, array3, updateIndex: false); return array3; } 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) { return (double)value; } double num = ((!(value is BigInteger bigInteger)) ? 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)) ? 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) { return (decimal)value; } 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() { if (Read()) { return MoveToContent(); } return false; } 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() { return Create(JsonConvert.DefaultSettings?.Invoke()); } 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); new JsonSerializerInternalReader(this).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] [return: MaybeNull] 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); object? result = new JsonSerializerInternalReader(this).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; } private 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); new JsonSerializerInternalWriter(this).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) { 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 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 TypeNameHandling { get { return _typeNameHandling.GetValueOrDefault(); } set { _typeNameHandling = value; } } public MetadataPropertyHandling MetadataPropertyHandling { get { return _metadataPropertyHandling.GetValu
plugins/ProjectGenesis.dll
Decompiled 3 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using CommonAPI; using CommonAPI.Systems; using CommonAPI.Systems.ModLocalization; using CommonAPI.Systems.UI; using GalacticScale; using HarmonyLib; using NGPT; using NebulaAPI; using NebulaAPI.Interfaces; using NebulaAPI.Networking; using NebulaAPI.Packets; using Newtonsoft.Json; using PCGSharp; using PowerNetworkStructures; using ProjectGenesis.Compatibility; using ProjectGenesis.Patches.Logic; using ProjectGenesis.Patches.Logic.AddVein; using ProjectGenesis.Patches.Logic.MegaAssembler; using ProjectGenesis.Patches.Logic.PlanetFocus; using ProjectGenesis.Patches.Logic.QTools; using ProjectGenesis.Patches.Logic.QuantumStorage; using ProjectGenesis.Patches.UI; using ProjectGenesis.Patches.UI.PlanetFocus; using ProjectGenesis.Patches.UI.QTools; using ProjectGenesis.Patches.UI.QTools.MyComboBox; using ProjectGenesis.Patches.UI.Utils; using ProjectGenesis.Utils; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; using crecheng.DSPModSave; using xiaoye97; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.0.0.0")] [module: UnverifiableCode] namespace ProjectGenesis { [BepInPlugin("org.LoShin.GenesisBook", "GenesisBook", "3.0.14")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [CommonAPISubmoduleDependency(new string[] { "ProtoRegistry", "TabSystem", "LocalizationModule" })] [ModSaveSettings(/*Could not decode attribute arguments.*/)] public class ProjectGenesis : BaseUnityPlugin, IModCanSave, IMultiplayerMod { public const string MODGUID = "org.LoShin.GenesisBook"; public const string MODNAME = "GenesisBook"; public const string VERSION = "3.0.14"; public const string DEBUGVERSION = ""; public static bool LoadCompleted; internal static ManualLogSource logger; internal static ConfigFile configFile; internal static UIPlanetFocusWindow PlanetFocusWindow; internal static UIQToolsWindow QToolsWindow; internal static int[] TableID; internal static string ModPath; internal static ConfigEntry<bool> LDBToolCacheEntry; internal static ConfigEntry<bool> HideTechModeEntry; internal static ConfigEntry<bool> ShowMessageBoxEntry; internal static ConfigEntry<int> ProductOverflowEntry; internal static ConfigEntry<KeyboardShortcut> QToolsHotkey; private Harmony Harmony; public string Version => "3.0.14"; public void Awake() { //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Expected O, but got Unknown //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Expected O, but got Unknown //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02ad: Expected O, but got Unknown //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Expected O, but got Unknown //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Expected O, but got Unknown logger = ((BaseUnityPlugin)this).Logger; logger.Log((LogLevel)16, (object)"GenesisBook Awake"); configFile = ((BaseUnityPlugin)this).Config; LDBToolCacheEntry = ((BaseUnityPlugin)this).Config.Bind<bool>("config", "UseLDBToolCache", false, "Enable LDBTool Cache, which allows you use config to fix some compatibility issues.\n启用LDBTool缓存,允许使用配置文件修复部分兼容性问题"); HideTechModeEntry = ((BaseUnityPlugin)this).Config.Bind<bool>("config", "HideTechMode", true, "Enable Tech Exploration Mode, which will hide locked techs in tech tree.\n启用科技探索模式,启用后将隐藏未解锁的科技"); ShowMessageBoxEntry = ((BaseUnityPlugin)this).Config.Bind<bool>("config", "ShowMessageBox", true, "Show message when GenesisBook is loaded.\n首次加载时的提示信息"); ProductOverflowEntry = ((BaseUnityPlugin)this).Config.Bind<int>("config", "ProductOverflow", 0, "Changing the condition for stopping production of some recipes from single product pile up to all product pile up.\n将部分配方停止生产的条件由单产物堆积改为所有产物均堆积"); QToolsHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("config", "QToolsHotkey", KeyboardShortcut.Deserialize("BackQuote"), "Shortcut to open QTools window"); ((BaseUnityPlugin)this).Config.Save(); Assembly executingAssembly = Assembly.GetExecutingAssembly(); ModPath = Path.GetDirectoryName(executingAssembly.Location); ResourceData val = new ResourceData("org.LoShin.GenesisBook", "texpack", ModPath); val.LoadAssetBundle("texpack"); ProtoRegistry.AddResource(val); ResourceData val2 = new ResourceData("org.LoShin.GenesisBook", "genesis-models", ModPath); val2.LoadAssetBundle("genesis-models"); ProtoRegistry.AddResource(val2); ResourceData val3 = new ResourceData("org.LoShin.GenesisBook", "genesis-models-lab", ModPath); val3.LoadAssetBundle("genesis-models-lab"); ProtoRegistry.AddResource(val3); Shader replacementShader = val2.bundle.LoadAsset<Shader>("Assets/genesis-models/shaders/PBR Standard Vein Stone COLOR.shader"); SwapShaderPatches.AddSwapShaderMapping("VF Shaders/Forward/PBR Standard Vein Stone", replacementShader); Shader replacementShader2 = val2.bundle.LoadAsset<Shader>("Assets/genesis-models/shaders/PBR Standard Vein Metal COLOR.shader"); SwapShaderPatches.AddSwapShaderMapping("VF Shaders/Forward/PBR Standard Vein Metal", replacementShader2); Shader replacementShader3 = val3.bundle.LoadAsset<Shader>("Assets/genesis-models/shaders/PBR Standard Vertex Toggle Lab REPLACE.shader"); SwapShaderPatches.AddSwapShaderMapping("VF Shaders/Forward/PBR Standard Vertex Toggle Lab", replacementShader3); NebulaModAPI.RegisterPackets(executingAssembly); NebulaModAPI.OnPlanetLoadRequest = (Action<int>)Delegate.Combine(NebulaModAPI.OnPlanetLoadRequest, (Action<int>)delegate(int planetId) { NebulaModAPI.MultiplayerSession.Network.SendPacket<GenesisBookPlanetLoadRequest>(new GenesisBookPlanetLoadRequest(planetId)); }); NebulaModAPI.OnPlanetLoadFinished = (Action<int>)Delegate.Combine(NebulaModAPI.OnPlanetLoadFinished, new Action<int>(GenesisBookPlanetDataProcessor.ProcessBytesLater)); Harmony = new Harmony("org.LoShin.GenesisBook"); Type[] types = executingAssembly.GetTypes(); foreach (Type type in types) { string? @namespace = type.Namespace; if (@namespace != null && @namespace.StartsWith("ProjectGenesis.Patches", StringComparison.Ordinal)) { Harmony.PatchAll(type); } } TableID = new int[3] { TabSystem.RegisterTab("org.LoShin.GenesisBook:org.LoShin.GenesisBookTab1", new TabData("精炼页面".TranslateFromJsonSpecial(), "Assets/texpack/矿物处理")), TabSystem.RegisterTab("org.LoShin.GenesisBook:org.LoShin.GenesisBookTab2", new TabData("化工页面".TranslateFromJsonSpecial(), "Assets/texpack/化工科技")), TabSystem.RegisterTab("org.LoShin.GenesisBook:org.LoShin.GenesisBookTab3", new TabData("防御页面".TranslateFromJsonSpecial(), "Assets/texpack/防御")) }; TranslateUtils.RegisterStrings(); AddVeinPatches.ModifyVeinData(); LDBTool.PreAddDataAction = (Action)Delegate.Combine(LDBTool.PreAddDataAction, new Action(PreAddDataAction)); LDBTool.PostAddDataAction = (Action)Delegate.Combine(LDBTool.PostAddDataAction, new Action(PostAddDataAction)); LoadCompleted = true; } private void Update() { if (!VFInput.inputing && Object.op_Implicit((Object)(object)QToolsWindow)) { ((ManualBehaviour)QToolsWindow)._OnUpdate(); } } public void Export(BinaryWriter w) { w.Write(VersionNumber()); MegaAssemblerPatches.Export(w); PlanetFocusPatches.Export(w); QuantumStoragePatches.Export(w); AdvancedLaserPatches.Export(w); GlobalPowerSupplyPatches.Export(w); } public void Import(BinaryReader r) { int num = r.ReadInt32(); MegaAssemblerPatches.Import(r); PlanetFocusPatches.Import(r); QuantumStoragePatches.Import(r); AdvancedLaserPatches.Import(r); GlobalPowerSupplyPatches.Import(r); } public void IntoOtherSave() { MegaAssemblerPatches.IntoOtherSave(); PlanetFocusPatches.IntoOtherSave(); QuantumStoragePatches.IntoOtherSave(); AdvancedLaserPatches.IntoOtherSave(); GlobalPowerSupplyPatches.IntoOtherSave(); } public bool CheckVersion(string hostVersion, string clientVersion) { return hostVersion.Equals(clientVersion); } private void PreAddDataAction() { ((ProtoSet<ItemProto>)(object)LDB.items).OnAfterDeserialize(); ModifyPlanetTheme.ModifyPlanetThemeDataVanilla(); CopyModelUtils.AddCopiedModelProto(); AddVeinPatches.AddEffectEmitterProto(); JsonDataUtils.ImportJson(TableID); ModifyUpgradeTech.ModifyUpgradeTeches(); } private void PostAddDataAction() { VegeProto val = ((ProtoSet<VegeProto>)(object)LDB.veges).Select(9999); val.MiningItem = new int[4] { 6216, 1101, 1104, 6203 }; val.MiningCount = new int[4] { 10, 100, 100, 100 }; val.MiningChance = new float[4] { 1f, 1f, 1f, 1f }; val.Preload(); LabComponent.matrixIds = new int[9] { 6001, 6002, 6003, 6004, 6005, 6006, 6278, 6279, 6280 }; LabComponent.matrixShaderStates = new float[10] { 0f, 11111.2f, 22222.2f, 33333.2f, 44444.2f, 55555.2f, 66666.2f, 77777.2f, 88888.2f, 271826f / (float)Math.E }; ((ProtoSet<ItemProto>)(object)LDB.items).OnAfterDeserialize(); ((ProtoSet<RecipeProto>)(object)LDB.recipes).OnAfterDeserialize(); ((ProtoSet<TechProto>)(object)LDB.techs).OnAfterDeserialize(); ((ProtoSet<ModelProto>)(object)LDB.models).OnAfterDeserialize(); ((ProtoSet<MilestoneProto>)(object)LDB.milestones).OnAfterDeserialize(); ((ProtoSet<JournalPatternProto>)(object)LDB.journalPatterns).OnAfterDeserialize(); ((ProtoSet<ThemeProto>)(object)LDB.themes).OnAfterDeserialize(); ((ProtoSet<VeinProto>)(object)LDB.veins).OnAfterDeserialize(); if ((Object)(object)GameMain.instance != (Object)null) { GameMain.instance.CreateGPUInstancing(); GameMain.instance.CreateBPGPUInstancing(); GameMain.instance.CreateMultithreadSystem(); } JsonDataUtils.PrefabDescPostFix(); CopyModelUtils.ModelPostFix(); ProtoPreload(); CopyModelUtils.ModifyEnemyHpUpgrade(); AddVeinPatches.SetMinerMk2Color(); ChemicalRecipeFcolPatches.SetChemicalRecipeFcol(); AddVeinPatches.SetEffectEmitterProto(); VFEffectEmitter.Init(); ItemProto.InitFuelNeeds(); ItemProto.InitTurretNeeds(); ItemProto.InitFluids(); ItemProto.InitTurrets(); ItemProto.InitEnemyDropTables(); ItemProto.InitConstructableItems(); ItemProto.InitItemIds(); ItemProto.InitItemIndices(); ItemProto.InitMechaMaterials(); ItemProto.InitFighterIndices(); ModelProto.InitMaxModelIndex(); ModelProto.InitModelIndices(); ModelProto.InitModelOrders(); RecipeProto.InitFractionatorNeeds(); RaycastLogic.LoadStatic(); ref int[] reference = ref ItemProto.turretNeeds[1]; reference[1] = 7607; reference[2] = 1603; ItemProto.stationCollectorId = 2105; CopyModelUtils.ItemPostFix(); StorageComponent.staticLoaded = false; StorageComponent.LoadStatic(); UIBuildMenu.staticLoaded = false; UIBuildMenu.StaticLoad(); SpaceSector.PrefabDescByModelIndex = null; SpaceSector.InitPrefabDescArray(); PlanetFactory.PrefabDescByModelIndex = null; PlanetFactory.InitPrefabDescArray(); ref MechaMaterialSetting reference2 = ref Configs.builtin.mechaArmorMaterials[21]; reference2.itemId = 7705; reference2.density = 19.35f; reference2.durability = 4.35f; } private static void ProtoPreload() { MilestoneProto[] dataArray = ((ProtoSet<MilestoneProto>)(object)LDB.milestones).dataArray; foreach (MilestoneProto val in dataArray) { val.Preload(); } JournalPatternProto[] dataArray2 = ((ProtoSet<JournalPatternProto>)(object)LDB.journalPatterns).dataArray; foreach (JournalPatternProto val2 in dataArray2) { val2.Preload(); } VeinProto[] dataArray3 = ((ProtoSet<VeinProto>)(object)LDB.veins).dataArray; foreach (VeinProto val3 in dataArray3) { val3.Preload(); ((Proto)val3).name = Localization.Translate(((Proto)val3).Name); } TechProto[] dataArray4 = ((ProtoSet<TechProto>)(object)LDB.techs).dataArray; foreach (TechProto val4 in dataArray4) { val4.Preload(); } for (int m = 0; m < ((ProtoSet<ItemProto>)(object)LDB.items).dataArray.Length; m++) { ((ProtoSet<ItemProto>)(object)LDB.items).dataArray[m].recipes = null; ((ProtoSet<ItemProto>)(object)LDB.items).dataArray[m].rawMats = null; ((ProtoSet<ItemProto>)(object)LDB.items).dataArray[m].Preload(m); } for (int n = 0; n < ((ProtoSet<RecipeProto>)(object)LDB.recipes).dataArray.Length; n++) { ((ProtoSet<RecipeProto>)(object)LDB.recipes).dataArray[n].Preload(n); } TechProto[] dataArray5 = ((ProtoSet<TechProto>)(object)LDB.techs).dataArray; foreach (TechProto val5 in dataArray5) { val5.PreTechsImplicit = val5.PreTechsImplicit.Except(val5.PreTechs).ToArray(); val5.UnlockRecipes = val5.UnlockRecipes.Distinct().ToArray(); val5.Preload2(); } } internal static void SetConfig(bool currentLDBToolCache, bool currentHideTechMode, bool currentShowMessageBox, int currentProductOverflow) { LDBToolCacheEntry.Value = currentLDBToolCache; HideTechModeEntry.Value = currentHideTechMode; ShowMessageBoxEntry.Value = currentShowMessageBox; ProductOverflowEntry.Value = currentProductOverflow; logger.LogInfo((object)"SettingChanged"); configFile.Save(); } internal static void LogInfo(object data) { logger.LogInfo(data); } internal static int VersionNumber() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) Version val = default(Version); ((Version)(ref val)).FromFullString("3.0.14"); return ((Version)(ref val)).sig; } } } namespace ProjectGenesis.Utils { internal static class CopyModelUtils { internal static void AddCopiedModelProto() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) CopyModelProto(121, 801, Color.HSVToRGB(0.5571f, 0.3188f, 0.898f)); CopyModelProto(194, 802, Color.HSVToRGB(0.2035f, 0.8326f, 0.9373f)); CopyModelProto(49, 803, Color.HSVToRGB(0.071f, 0.7412f, 0.8941f)); CopyModelProto(49, 804, Color.HSVToRGB(0.6174f, 0.6842f, 0.9686f)); CopyModelProto(49, 805, Color.HSVToRGB(0.1404f, 0.8294f, 0.9882f)); CopyModelProto(49, 806, Color.HSVToRGB(0.9814f, 0.662f, 0.8471f)); CopyModelProto(56, 807); CopyModelProto(119, 808, Color.HSVToRGB(0.6174f, 0.6842f, 0.9686f)); CopyModelProto(46, 809, Color.HSVToRGB(0.4174f, 0.742f, 0.9686f)); CopyModelProto(49, 810, (Color?)new Color(0.3216f, 0.8157f, 0.0902f)); CopyModelProto(49, 811, (Color?)new Color(0.3059f, 0.2196f, 0.4941f)); CopyModelProto(52, 814, (Color?)new Color(0.7373f, 0.2118f, 0.851f)); CopyModelProto(432, 813, (Color?)new Color(0.3059f, 0.2196f, 0.4941f)); CopyModelProto(375, 815, (Color?)new Color(0.2275f, 0.3804f, 0.6431f)); CopyModelProto(373, 816, (Color?)new Color(0.5765f, 0.4392f, 0.8588f)); CopyModelProto(490, 817); CopyModelProto(488, 818); AddAtmosphericCollectStation(); } private static void AddAtmosphericCollectStation() { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) ModelProto val = ((ProtoSet<ModelProto>)(object)LDB.models).Select(50); PrefabDesc prefabDesc = val.prefabDesc; List<Material> list = new List<Material>(); Material[][] lodMaterials = prefabDesc.lodMaterials; foreach (Material[] array in lodMaterials) { if (array == null) { continue; } Material[] array2 = array; foreach (Material val2 in array2) { if (!((Object)(object)val2 == (Object)null)) { Material val3 = new Material(val2); val3.SetColor("_Color", Color32.op_Implicit(new Color32((byte)60, (byte)179, (byte)113, byte.MaxValue))); list.Add(val3); } } } val = ((ProtoSet<ModelProto>)(object)LDB.models).Select(73); Material val4 = new Material(val.prefabDesc.lodMaterials[0][3]); val4.SetColor("_TintColor", Color32.op_Implicit(new Color32((byte)131, (byte)127, (byte)197, byte.MaxValue))); val4.SetColor("_PolarColor", Color32.op_Implicit(new Color32((byte)234, byte.MaxValue, (byte)253, (byte)170))); val4.SetVector("_Aurora", new Vector4(75f, 1f, 20f, 0.1f)); val4.SetVector("_Beam", new Vector4(12f, 78f, 24f, 1f)); val4.SetVector("_Particle", new Vector4(2f, 30f, 5f, 0.8f)); val4.SetVector("_Circle", new Vector4(2.5f, 34f, 1f, 0.04f)); list.Add(val4); ModelProto val5 = ProtoRegistry.RegisterModel(812, "Assets/genesis-models/entities/prefabs/atmospheric-collect-station", list.ToArray(), 0); val5.HpMax = 300000; val5.RuinId = 384; val5.RuinType = (ERuinType)2; val5.RuinCount = 1; } private static void CopyModelProto(int oriId, int id, Color? color = null) { //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) ModelProto val = ((ProtoSet<ModelProto>)(object)LDB.models).Select(oriId); ModelProto val2 = val.Copy(); ((Proto)val2).Name = id.ToString(); ((Proto)val2).ID = id; PrefabDesc prefabDesc = val.prefabDesc; GameObject val3 = (Object.op_Implicit((Object)(object)prefabDesc.prefab) ? prefabDesc.prefab : Resources.Load<GameObject>(val.PrefabPath)); GameObject val4 = (Object.op_Implicit((Object)(object)prefabDesc.colliderPrefab) ? prefabDesc.colliderPrefab : Resources.Load<GameObject>(val._colliderPath)); ref PrefabDesc prefabDesc2 = ref val2.prefabDesc; prefabDesc2 = (PrefabDesc)(((Object)(object)val3 == (Object)null) ? ((object)PrefabDesc.none) : ((object)(((Object)(object)val4 == (Object)null) ? new PrefabDesc(id, val3) : new PrefabDesc(id, val3, val4)))); Material[][] lodMaterials = prefabDesc2.lodMaterials; foreach (Material[] array in lodMaterials) { if (array == null) { continue; } for (int j = 0; j < array.Length; j++) { ref Material reference = ref array[j]; if (!((Object)(object)reference == (Object)null)) { reference = new Material(reference); if (color.HasValue) { reference.SetColor("_Color", color.Value); } } } } prefabDesc2.modelIndex = id; prefabDesc2.hasBuildCollider = prefabDesc.hasBuildCollider; prefabDesc2.colliders = prefabDesc.colliders; prefabDesc2.buildCollider = prefabDesc.buildCollider; prefabDesc2.buildColliders = prefabDesc.buildColliders; prefabDesc2.colliderPrefab = prefabDesc.colliderPrefab; prefabDesc2.dragBuild = prefabDesc.dragBuild; prefabDesc2.dragBuildDist = prefabDesc.dragBuildDist; prefabDesc2.blueprintBoxSize = prefabDesc.blueprintBoxSize; prefabDesc2.roughHeight = prefabDesc.roughHeight; prefabDesc2.roughWidth = prefabDesc.roughWidth; prefabDesc2.roughRadius = prefabDesc.roughRadius; prefabDesc2.barHeight = prefabDesc.barHeight; prefabDesc2.barWidth = prefabDesc.barWidth; ((Proto)val2).sid = ""; ((Proto)val2).SID = ""; LDBTool.PreAddProto((Proto)(object)val2); } private static ModelProto Copy(this ModelProto proto) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown return new ModelProto { ObjectType = proto.ObjectType, RuinType = proto.RuinType, RendererType = proto.RendererType, HpMax = proto.HpMax, HpUpgrade = proto.HpUpgrade, HpRecover = proto.HpRecover, RuinId = proto.RuinId, RuinCount = proto.RuinCount, RuinLifeTime = proto.RuinLifeTime, PrefabPath = proto.PrefabPath, _colliderPath = proto._colliderPath, _ruinPath = proto._ruinPath, _wreckagePath = proto._wreckagePath, _ruinOriginModelIndex = proto._ruinOriginModelIndex }; } internal static void ModelPostFix() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) ModelProto val = ((ProtoSet<ModelProto>)(object)LDB.models).Select(812); val._ruinPath = "Entities/Prefabs/Ruins/interstellar-logistic-station-ruins"; val._wreckagePath = "Entities/Prefabs/Wreckages/interstellar-logistic-station-wreckages"; PrefabDesc prefabDesc = ((ProtoSet<ModelProto>)(object)LDB.models).Select(809).prefabDesc; prefabDesc.lodMaterials[0][2].SetColor("_TintColor", new Color(0.2715f, 1.7394f, 0.193f)); prefabDesc = ((ProtoSet<ModelProto>)(object)LDB.models).Select(807).prefabDesc; Texture val2 = Resources.Load<Texture>("Assets/texpack/人造恒星MK2材质"); ref Material[] reference = ref prefabDesc.lodMaterials[0]; reference[0].SetTexture("_EmissionTex", val2); reference[1].SetColor("_TintColor", new Color(0.1804f, 0.4953f, 1.3584f)); reference[1].SetColor("_TintColor1", new Color(0.1294f, 0.313f, 1.1508f)); reference[1].SetColor("_RimColor", new Color(0.4157f, 0.6784f, 1f)); prefabDesc = ((ProtoSet<ModelProto>)(object)LDB.models).Select(70).prefabDesc; reference = ref prefabDesc.lodMaterials[0]; ModifyLabColor(reference[0]); ModifyLabColor(reference[2]); reference = ref prefabDesc.lodMaterials[1]; ModifyLabColor(reference[0]); ModifyLabColor(reference[2]); ModifyLabColor(prefabDesc.lodMaterials[2][0]); prefabDesc = ((ProtoSet<ModelProto>)(object)LDB.models).Select(455).prefabDesc; reference = ref prefabDesc.lodMaterials[0]; ModifyLabColor(reference[0]); ModifyLabColor(reference[2]); reference = ref prefabDesc.lodMaterials[1]; ModifyLabColor(reference[0]); ModifyLabColor(reference[2]); ModifyLabColor(prefabDesc.lodMaterials[2][0]); } private static void ModifyLabColor(Material material) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) material.SetColor("_LabColor7", new Color(1f, 0.451f, 0.0039f)); material.SetColor("_LabColor8", new Color(1f, 0.0431f, 0.5843f)); material.SetColor("_LabColor9", new Color(0.402f, 0.402f, 0.402f)); } internal static void ItemPostFix() { ((ProtoSet<ItemProto>)(object)LDB.items).Select(1000).recipes = new List<RecipeProto> { ((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(801) }; ((ProtoSet<ItemProto>)(object)LDB.items).Select(1120).isRaw = true; } internal static void ModifyEnemyHpUpgrade() { for (int i = 292; i <= 299; i++) { ModelProto val = ((ProtoSet<ModelProto>)(object)LDB.models).Select(i); val.HpMax *= 2; val.HpUpgrade *= 2; val.HpRecover *= 2; } ModelProto val2 = ((ProtoSet<ModelProto>)(object)LDB.models).Select(300); val2.HpUpgrade = 1000; val2 = ((ProtoSet<ModelProto>)(object)LDB.models).Select(301); val2.HpUpgrade = 800; val2 = ((ProtoSet<ModelProto>)(object)LDB.models).Select(302); val2.HpUpgrade = 800; } } internal static class DictionaryExtend { public static void TryAddOrInsert<TKey, TValue>(this ConcurrentDictionary<TKey, List<TValue>> dict, TKey key, TValue value) { if (dict.ContainsKey(key)) { dict[key].Add(value); return; } dict[key] = new List<TValue> { value }; } public static void TryRemove<TKey, TValue>(this ConcurrentDictionary<TKey, List<TValue>> dict, TKey key, TValue value) { if (dict.ContainsKey(key)) { dict[key].Remove(value); } } public static bool Contains<TKey, TValue>(this ConcurrentDictionary<TKey, List<TValue>> dict, TKey key, TValue value) { List<TValue> value2; return dict.TryGetValue(key, out value2) && value2.Contains(value); } } public enum ERecipeType { None = 0, Smelt = 1, Chemical = 2, Refine = 3, Assemble = 4, Particle = 5, Exchange = 6, PhotonStore = 7, Fractionate = 8, 标准制造 = 9, 高精度加工 = 10, 矿物处理 = 11, 所有制造 = 12, 垃圾回收 = 14, Research = 15, 高分子化工 = 16, 所有化工 = 17, 复合制造 = 18, 所有熔炉 = 19 } internal static class IconDescUtils { internal abstract class ModIconDesc { internal Color Color; protected ModIconDesc(Color color) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) Color = color; } internal abstract IconDesc ToIconDesc(); } internal class FluidIconDesc : ModIconDesc { public FluidIconDesc(Color color) : base(color) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, reserved0 = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = new Color(0.2f, 0.2f, 0.2f, 1f), metallic = 1f, smoothness = 0.302f, liquidity = 1f, solidAlpha = 0f, iconAlpha = 1f }; } } internal class NoIconFluidIconDesc : ModIconDesc { internal NoIconFluidIconDesc(Color color) : base(color) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, reserved0 = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = Color.clear, metallic = 1f, liquidity = 1f, smoothness = 0.302f, solidAlpha = 0f, iconAlpha = 0f }; } } internal class OreIconDesc : ModIconDesc { public OreIconDesc(Color color) : base(color) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, reserved0 = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = Color.clear, metallic = 0.8f, smoothness = 0.5f, solidAlpha = 1f, iconAlpha = 1f }; } } internal class NoIconMetalIconDesc : ModIconDesc { public NoIconMetalIconDesc(Color color) : base(color) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = Color.clear, metallic = 1f, smoothness = 0.6f, solidAlpha = 1f, iconAlpha = 0f }; } } internal class FullIconDesc : ModIconDesc { public FullIconDesc(Color color) : base(color) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = Color.clear, metallic = 0f, smoothness = 0.5f, solidAlpha = 1f, iconAlpha = 1f }; } } internal class ComponentIconDesc : ModIconDesc { public ComponentIconDesc(Color color) : base(color) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown return new IconDesc { faceColor = Color.white, sideColor = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = Color.clear, metallic = 0.8f, smoothness = 0.5f, solidAlpha = 1f, iconAlpha = 1f }; } } internal class GlassIconDesc : ModIconDesc { public GlassIconDesc(Color color) : base(color) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, reserved0 = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = Color.clear, metallic = 1f, smoothness = 0.5f, solidAlpha = 0.8f, iconAlpha = 0f }; } } internal class RodIconDesc : ModIconDesc { public RodIconDesc(Color color) : base(color) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, reserved0 = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = Color.clear, metallic = 1f, smoothness = 0.5f, solidAlpha = 0.6f, iconAlpha = 1f }; } } internal class WhiteIconDesc : ModIconDesc { public WhiteIconDesc() : base(Color.white) { }//IL_0001: Unknown result type (might be due to invalid IL or missing references) internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_007f: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, faceEmission = Color.black, sideEmission = Color.black, iconEmission = new Color(0.2f, 0.2f, 0.2f, 1f), metallic = 0.8f, smoothness = 0.5f, solidAlpha = 1f, iconAlpha = 1f }; } } internal class MartixIconDesc : ModIconDesc { private readonly Color _emission; public MartixIconDesc(Color color, Color emission) : base(color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) _emission = emission; } internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, faceEmission = _emission, sideEmission = _emission, iconEmission = Color.clear, metallic = 0f, smoothness = 0f, solidAlpha = 0.5f, iconAlpha = 0f }; } } internal class DefaultIconDesc : ModIconDesc { private readonly Color _emission; public DefaultIconDesc(Color color, Color emission) : base(color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) _emission = emission; } internal override IconDesc ToIconDesc() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown return new IconDesc { faceColor = Color, sideColor = Color, faceEmission = _emission, sideEmission = _emission, iconEmission = new Color(0.2f, 0.2f, 0.2f, 1f), metallic = 0.8f, smoothness = 0.5f, solidAlpha = 1f, iconAlpha = 1f }; } } internal static readonly Dictionary<int, ModIconDesc> IconDescs = new Dictionary<int, ModIconDesc> { { 7019, new FluidIconDesc(Color32.op_Implicit(new Color32((byte)129, (byte)199, (byte)241, byte.MaxValue))) }, { 6220, new FluidIconDesc(Color32.op_Implicit(new Color32((byte)137, (byte)242, (byte)178, byte.MaxValue))) }, { 6234, new FluidIconDesc(Color32.op_Implicit(new Color32((byte)244, byte.MaxValue, (byte)183, byte.MaxValue))) }, { 6235, new FluidIconDesc(Color32.op_Implicit(new Color32((byte)210, (byte)222, (byte)142, byte.MaxValue))) }, { 1114, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32((byte)138, (byte)83, (byte)43, byte.MaxValue))) }, { 7018, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32((byte)97, (byte)132, (byte)186, byte.MaxValue))) }, { 7006, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32((byte)218, (byte)56, (byte)70, byte.MaxValue))) }, { 7009, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32((byte)167, byte.MaxValue, (byte)39, byte.MaxValue))) }, { 6206, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32((byte)191, (byte)227, byte.MaxValue, byte.MaxValue))) }, { 6205, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32(byte.MaxValue, (byte)128, (byte)52, byte.MaxValue))) }, { 6212, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32((byte)188, (byte)182, (byte)5, byte.MaxValue))) }, { 7014, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32((byte)104, (byte)187, (byte)154, byte.MaxValue))) }, { 7015, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32((byte)42, (byte)97, (byte)32, byte.MaxValue))) }, { 7002, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32((byte)195, (byte)198, (byte)234, byte.MaxValue))) }, { 7017, new NoIconFluidIconDesc(Color32.op_Implicit(new Color32((byte)157, (byte)56, (byte)157, byte.MaxValue))) }, { 6202, new OreIconDesc(Color32.op_Implicit(new Color32((byte)210, (byte)184, (byte)147, byte.MaxValue))) }, { 6207, new OreIconDesc(Color32.op_Implicit(new Color32((byte)230, (byte)239, (byte)137, byte.MaxValue))) }, { 6222, new OreIconDesc(Color32.op_Implicit(new Color32((byte)106, (byte)175, (byte)78, byte.MaxValue))) }, { 6225, new OreIconDesc(Color32.op_Implicit(new Color32((byte)130, (byte)235, (byte)139, byte.MaxValue))) }, { 6226, new OreIconDesc(Color32.op_Implicit(new Color32((byte)243, (byte)98, (byte)113, byte.MaxValue))) }, { 6201, new OreIconDesc(Color32.op_Implicit(new Color32((byte)30, (byte)29, (byte)30, byte.MaxValue))) }, { 7803, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)228, (byte)153, byte.MaxValue, byte.MaxValue))) }, { 7804, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)228, (byte)153, byte.MaxValue, byte.MaxValue))) }, { 7805, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)93, (byte)191, byte.MaxValue, byte.MaxValue))) }, { 7806, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)228, (byte)153, byte.MaxValue, byte.MaxValue))) }, { 6263, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)150, (byte)173, (byte)240, byte.MaxValue))) }, { 6267, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)147, (byte)244, (byte)241, byte.MaxValue))) }, { 6221, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)122, (byte)227, (byte)130, byte.MaxValue))) }, { 6261, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)41, (byte)221, byte.MaxValue, byte.MaxValue))) }, { 6229, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)164, (byte)218, byte.MaxValue, byte.MaxValue))) }, { 6231, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)213, (byte)82, byte.MaxValue, byte.MaxValue))) }, { 6230, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)196, byte.MaxValue, (byte)106, byte.MaxValue))) }, { 7617, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)77, (byte)182, (byte)241, byte.MaxValue))) }, { 7618, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)140, (byte)64, (byte)219, byte.MaxValue))) }, { 6501, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)234, (byte)163, (byte)87, byte.MaxValue))) }, { 6502, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)87, byte.MaxValue, (byte)191, byte.MaxValue))) }, { 6503, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)53, (byte)206, byte.MaxValue, byte.MaxValue))) }, { 7501, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)210, (byte)157, (byte)118, byte.MaxValue))) }, { 7504, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)109, (byte)196, byte.MaxValue, byte.MaxValue))) }, { 6257, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)241, (byte)158, (byte)60, byte.MaxValue))) }, { 6258, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)71, (byte)132, (byte)253, byte.MaxValue))) }, { 6259, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)249, byte.MaxValue, (byte)89, byte.MaxValue))) }, { 6260, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)201, (byte)50, (byte)65, byte.MaxValue))) }, { 6264, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)71, (byte)188, (byte)84, byte.MaxValue))) }, { 6265, new ComponentIconDesc(Color32.op_Implicit(new Color32((byte)106, (byte)61, (byte)172, byte.MaxValue))) }, { 7612, new FullIconDesc(Color32.op_Implicit(new Color32((byte)173, (byte)207, (byte)172, byte.MaxValue))) }, { 7613, new FullIconDesc(Color32.op_Implicit(new Color32((byte)187, (byte)172, (byte)252, byte.MaxValue))) }, { 7615, new FullIconDesc(Color32.op_Implicit(new Color32((byte)187, (byte)172, (byte)252, byte.MaxValue))) }, { 6204, new FullIconDesc(Color32.op_Implicit(new Color32((byte)161, (byte)157, (byte)152, byte.MaxValue))) }, { 7707, new FullIconDesc(Color32.op_Implicit(new Color32((byte)51, (byte)51, (byte)57, byte.MaxValue))) }, { 6271, new FullIconDesc(Color32.op_Implicit(new Color32((byte)221, (byte)218, byte.MaxValue, byte.MaxValue))) }, { 7608, new FullIconDesc(Color32.op_Implicit(new Color32((byte)81, (byte)83, (byte)90, byte.MaxValue))) }, { 7609, new FullIconDesc(Color32.op_Implicit(new Color32((byte)221, (byte)218, byte.MaxValue, byte.MaxValue))) }, { 7616, new FullIconDesc(Color32.op_Implicit(new Color32((byte)187, (byte)172, (byte)252, byte.MaxValue))) }, { 6252, new FullIconDesc(Color32.op_Implicit(new Color32((byte)160, (byte)216, byte.MaxValue, byte.MaxValue))) }, { 6253, new FullIconDesc(Color32.op_Implicit(new Color32((byte)237, (byte)176, (byte)150, byte.MaxValue))) }, { 6273, new FullIconDesc(Color32.op_Implicit(new Color32((byte)218, (byte)212, (byte)195, byte.MaxValue))) }, { 6254, new FullIconDesc(Color32.op_Implicit(new Color32((byte)153, (byte)236, (byte)182, byte.MaxValue))) }, { 6255, new FullIconDesc(Color32.op_Implicit(new Color32((byte)232, (byte)236, byte.MaxValue, byte.MaxValue))) }, { 6281, new FullIconDesc(Color32.op_Implicit(new Color32((byte)32, (byte)33, (byte)36, byte.MaxValue))) }, { 6256, new FullIconDesc(Color32.op_Implicit(new Color32((byte)56, (byte)57, (byte)62, byte.MaxValue))) }, { 6251, new FullIconDesc(Color32.op_Implicit(new Color32((byte)181, (byte)184, (byte)198, byte.MaxValue))) }, { 6277, new FullIconDesc(Color32.op_Implicit(new Color32(byte.MaxValue, byte.MaxValue, (byte)142, byte.MaxValue))) }, { 6203, new NoIconMetalIconDesc(Color32.op_Implicit(new Color32((byte)186, (byte)176, (byte)144, byte.MaxValue))) }, { 7705, new NoIconMetalIconDesc(Color32.op_Implicit(new Color32((byte)43, (byte)44, (byte)48, byte.MaxValue))) }, { 6227, new NoIconMetalIconDesc(Color32.op_Implicit(new Color32((byte)66, (byte)222, (byte)87, byte.MaxValue))) }, { 6228, new NoIconMetalIconDesc(Color32.op_Implicit(new Color32((byte)239, (byte)83, (byte)90, byte.MaxValue))) }, { 6208, new NoIconMetalIconDesc(Color32.op_Implicit(new Color32((byte)93, (byte)91, (byte)83, byte.MaxValue))) }, { 6217, new RodIconDesc(Color32.op_Implicit(new Color32((byte)163, (byte)145, (byte)85, byte.MaxValue))) }, { 6216, new RodIconDesc(Color32.op_Implicit(new Color32((byte)198, (byte)207, (byte)111, byte.MaxValue))) }, { 6242, new RodIconDesc(Color32.op_Implicit(new Color32((byte)33, (byte)170, (byte)87, byte.MaxValue))) }, { 6241, new RodIconDesc(Color32.op_Implicit(new Color32((byte)204, (byte)74, (byte)78, byte.MaxValue))) }, { 6243, new RodIconDesc(Color32.op_Implicit(new Color32((byte)153, (byte)157, (byte)169, byte.MaxValue))) }, { 6244, new RodIconDesc(Color32.op_Implicit(new Color32((byte)245, (byte)250, (byte)105, byte.MaxValue))) }, { 6245, new RodIconDesc(Color32.op_Implicit(new Color32((byte)147, (byte)77, byte.MaxValue, byte.MaxValue))) }, { 6278, new MartixIconDesc(new Color(1f, 0.4117f, 0.3137f, 0.1961f), new Color(1f, 0.2706f, 0f, 0f)) }, { 6279, new MartixIconDesc(new Color(1f, 0.753f, 0.7961f, 0.1961f), new Color(0.7804f, 0.0824f, 0.5216f, 0f)) }, { 6280, new MartixIconDesc(new Color(0.402f, 0.402f, 0.402f, 0.1961f), new Color(0.3f, 0.3f, 0.3f, 0f)) }, { 7610, new WhiteIconDesc() }, { 7611, new WhiteIconDesc() }, { 7706, new GlassIconDesc(Color32.op_Implicit(new Color32((byte)91, (byte)91, (byte)91, byte.MaxValue))) } }; private static readonly IconDesc Default = new IconDesc { faceColor = Color.white, sideColor = new Color(0.4667f, 0.5333f, 0.6f, 1f), faceEmission = Color.black, sideEmission = Color.black, iconEmission = new Color(0.2f, 0.2f, 0.2f, 1f), metallic = 0.8f, smoothness = 0.5f, solidAlpha = 1f, iconAlpha = 1f }; internal static IconDesc GetIconDesc(int itemid) { ModIconDesc value; return IconDescs.TryGetValue(itemid, out value) ? value.ToIconDesc() : Default; } internal static IconDesc ExportIconDesc(int itemId) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0114: Unknown result type (might be due to invalid IL or missing references) IconSet iconSet = GameMain.iconSet; IconDesc val = new IconDesc(); uint num = iconSet.itemIconIndex[itemId]; if (num == 0) { return val; } FieldInfo[] fields = typeof(IconDesc).GetFields(BindingFlags.Instance | BindingFlags.Public); uint num2 = 0u; FieldInfo[] array = fields; foreach (FieldInfo fieldInfo in array) { if (fieldInfo.FieldType == typeof(float)) { fieldInfo.SetValue(val, iconSet.itemDescArr[num * 40 + num2++]); } else if (fieldInfo.FieldType == typeof(Color)) { float num3 = iconSet.itemDescArr[num * 40 + num2++]; float num4 = iconSet.itemDescArr[num * 40 + num2++]; float num5 = iconSet.itemDescArr[num * 40 + num2++]; float num6 = iconSet.itemDescArr[num * 40 + num2++]; fieldInfo.SetValue(val, (object)new Color(num3, num4, num5, num6)); } } return val; } } internal static class JsonDataUtils { internal static void ImportJson(int[] tableID) { ref Dictionary<int, IconDesc> reference = ref AccessTools.StaticFieldRefAccess<Dictionary<int, IconDesc>>(typeof(ProtoRegistry), "itemIconDescs"); JsonHelper.TechProtoJson[] array = JsonHelper.TechProtos(); foreach (JsonHelper.TechProtoJson techProtoJson in array) { if (((ProtoSet<TechProto>)(object)LDB.techs).Exist(techProtoJson.ID)) { techProtoJson.ToProto(((ProtoSet<TechProto>)(object)LDB.techs).Select(techProtoJson.ID)); } else { LDBTool.PreAddProto((Proto)(object)techProtoJson.ToProto()); } } JsonHelper.ItemProtoJson[] array2 = JsonHelper.ItemModProtos(); foreach (JsonHelper.ItemProtoJson itemProtoJson in array2) { itemProtoJson.GridIndex = GetTableID(itemProtoJson.GridIndex); reference.Add(itemProtoJson.ID, IconDescUtils.GetIconDesc(itemProtoJson.ID)); LDBTool.PreAddProto((Proto)(object)itemProtoJson.ToProto()); } JsonHelper.ItemProtoJson[] array3 = JsonHelper.ItemVanillaProtos(); foreach (JsonHelper.ItemProtoJson itemProtoJson2 in array3) { itemProtoJson2.GridIndex = GetTableID(itemProtoJson2.GridIndex); ItemProto val = ((ProtoSet<ItemProto>)(object)LDB.items).Select(itemProtoJson2.ID); if (val.IconPath != itemProtoJson2.IconPath) { reference.Add(itemProtoJson2.ID, IconDescUtils.GetIconDesc(itemProtoJson2.ID)); } itemProtoJson2.ToProto(val); } JsonHelper.RecipeProtoJson[] array4 = JsonHelper.RecipeProtos(); foreach (JsonHelper.RecipeProtoJson recipeProtoJson in array4) { recipeProtoJson.GridIndex = GetTableID(recipeProtoJson.GridIndex); if (((ProtoSet<RecipeProto>)(object)LDB.recipes).Exist(recipeProtoJson.ID)) { recipeProtoJson.ToProto(((ProtoSet<RecipeProto>)(object)LDB.recipes).Select(recipeProtoJson.ID)); } else { LDBTool.PreAddProto((Proto)(object)recipeProtoJson.ToProto()); } } JsonHelper.TutorialProtoJson[] array5 = JsonHelper.TutorialProtos(); JsonHelper.TutorialProtoJson[] array6 = array5; foreach (JsonHelper.TutorialProtoJson tutorialProtoJson in array6) { LDBTool.PreAddProto((Proto)(object)tutorialProtoJson.ToProto()); } int GetTableID(int gridIndex) { if (gridIndex >= 5000) { return (tableID[2] - 5) * 1000 + gridIndex; } if (gridIndex >= 4000) { return (tableID[1] - 4) * 1000 + gridIndex; } if (gridIndex >= 3000) { return (tableID[0] - 3) * 1000 + gridIndex; } return gridIndex; } } internal static void PrefabDescPostFix() { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) JsonHelper.PrefabDescJson[] array = JsonHelper.PrefabDescs(); JsonHelper.PrefabDescJson[] array2 = array; foreach (JsonHelper.PrefabDescJson prefabDescJson in array2) { prefabDescJson.ToPrefabDesc(((ProtoSet<ModelProto>)(object)LDB.models).Select(prefabDescJson.ModelID).prefabDesc); } PrefabDesc prefabDesc = ((ProtoSet<ModelProto>)(object)LDB.models).Select(808).prefabDesc; prefabDesc.waterPoints = (Vector3[])(object)new Vector3[1] { Vector3.zero }; prefabDesc.portPoses = (Pose[])(object)new Pose[1] { prefabDesc.portPoses[0] }; } } internal static class JsonHelper { [Serializable] public class ItemProtoJson { public int ID { get; set; } public string Name { get; set; } public string Description { get; set; } public string IconPath { get; set; } public int GridIndex { get; set; } public int StackSize { get; set; } public int Type { get; set; } public int PreTechOverride { get; set; } public int[] DescFields { get; set; } public int FuelType { get; set; } public long HeatValue { get; set; } public float ReactorInc { get; set; } public bool IsFluid { get; set; } public bool Productive { get; set; } public int SubID { get; set; } public string MiningFrom { get; set; } public string ProduceFrom { get; set; } public int Grade { get; set; } public int[] Upgrades { get; set; } public bool IsEntity { get; set; } public bool CanBuild { get; set; } public bool BuildInGas { get; set; } public int ModelIndex { get; set; } public int ModelCount { get; set; } public int HpMax { get; set; } public int Ability { get; set; } public long Potential { get; set; } public int BuildIndex { get; set; } public int BuildMode { get; set; } public int UnlockKey { get; set; } public int MechaMaterialID { get; set; } public int AmmoType { get; set; } public int BombType { get; set; } public int CraftType { get; set; } public float DropRate { get; set; } public int EnemyDropLevel { get; set; } public float[] EnemyDropRange { get; set; } public float EnemyDropCount { get; set; } public int EnemyDropMask { get; set; } public float EnemyDropMaskRatio { get; set; } public static ItemProtoJson FromProto(ItemProto i) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected I4, but got Unknown //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected I4, but got Unknown //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected I4, but got Unknown ItemProtoJson itemProtoJson = new ItemProtoJson(); itemProtoJson.ID = ((Proto)i).ID; itemProtoJson.Name = ((Proto)i).Name; itemProtoJson.Description = i.Description; itemProtoJson.IconPath = i.IconPath; itemProtoJson.GridIndex = i.GridIndex; itemProtoJson.StackSize = i.StackSize; itemProtoJson.FuelType = i.FuelType; itemProtoJson.HeatValue = i.HeatValue; itemProtoJson.ReactorInc = i.ReactorInc; itemProtoJson.DescFields = i.DescFields; itemProtoJson.IsFluid = i.IsFluid; itemProtoJson.Type = (int)i.Type; itemProtoJson.SubID = i.SubID; itemProtoJson.MiningFrom = i.MiningFrom; itemProtoJson.ProduceFrom = i.ProduceFrom; itemProtoJson.Grade = i.Grade; itemProtoJson.Upgrades = i.Upgrades; itemProtoJson.IsEntity = i.IsEntity; itemProtoJson.CanBuild = i.CanBuild; itemProtoJson.BuildInGas = i.BuildInGas; itemProtoJson.ModelIndex = i.ModelIndex; itemProtoJson.ModelCount = i.ModelCount; itemProtoJson.HpMax = i.HpMax; itemProtoJson.Ability = i.Ability; itemProtoJson.Potential = i.Potential; itemProtoJson.BuildIndex = i.BuildIndex; itemProtoJson.BuildMode = i.BuildMode; itemProtoJson.UnlockKey = i.UnlockKey; itemProtoJson.PreTechOverride = i.PreTechOverride; itemProtoJson.Productive = i.Productive; itemProtoJson.MechaMaterialID = i.MechaMaterialID; itemProtoJson.AmmoType = (int)i.AmmoType; itemProtoJson.BombType = (int)i.BombType; itemProtoJson.CraftType = i.CraftType; itemProtoJson.DropRate = i.DropRate; itemProtoJson.EnemyDropLevel = i.EnemyDropLevel; itemProtoJson.EnemyDropRange = new float[2] { i.EnemyDropRange.x, i.EnemyDropRange.y }; itemProtoJson.EnemyDropCount = i.EnemyDropCount; itemProtoJson.EnemyDropMask = i.EnemyDropMask; itemProtoJson.EnemyDropMaskRatio = i.EnemyDropMaskRatio; return itemProtoJson; } public ItemProto ToProto() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown return ToProto(new ItemProto()); } public ItemProto ToProto(ItemProto proto) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) ((Proto)proto).ID = ID; ((Proto)proto).Name = Name; proto.Description = Description; proto.IconPath = IconPath; proto.GridIndex = GridIndex; proto.StackSize = StackSize; proto.FuelType = FuelType; proto.HeatValue = HeatValue; proto.ReactorInc = ReactorInc; proto.DescFields = DescFields ?? Array.Empty<int>(); proto.IsFluid = IsFluid; proto.Type = (EItemType)Type; proto.SubID = SubID; proto.MiningFrom = MiningFrom; proto.ProduceFrom = ProduceFrom; proto.Grade = Grade; proto.Upgrades = Upgrades ?? Array.Empty<int>(); proto.IsEntity = IsEntity; proto.CanBuild = CanBuild; proto.BuildInGas = BuildInGas; proto.ModelIndex = ModelIndex; proto.ModelCount = ModelCount; proto.HpMax = HpMax; proto.Ability = Ability; proto.Potential = Potential; proto.BuildIndex = BuildIndex; proto.BuildMode = BuildMode; proto.UnlockKey = UnlockKey; proto.MechaMaterialID = MechaMaterialID; proto.PreTechOverride = PreTechOverride; proto.Productive = Productive; proto.AmmoType = (EAmmoType)(byte)AmmoType; proto.BombType = (EBombType)BombType; proto.CraftType = CraftType; proto.DropRate = DropRate; proto.EnemyDropLevel = EnemyDropLevel; proto.EnemyDropRange = new Vector2(EnemyDropRange[0], EnemyDropRange[1]); proto.EnemyDropCount = EnemyDropCount; proto.EnemyDropMask = EnemyDropMask; proto.EnemyDropMaskRatio = EnemyDropMaskRatio; return proto; } } [Serializable] public class RecipeProtoJson { public int ID { get; set; } public string Name { get; set; } public string Description { get; set; } public string IconPath { get; set; } public int Type { get; set; } public int GridIndex { get; set; } public int Time { get; set; } public int[] Input { get; set; } public int[] InCounts { get; set; } public int[] Output { get; set; } public int[] OutCounts { get; set; } public bool Explicit { get; set; } public bool Handcraft { get; set; } public bool NonProductive { get; set; } public static RecipeProtoJson FromProto(RecipeProto i) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected I4, but got Unknown return new RecipeProtoJson { ID = ((Proto)i).ID, Explicit = i.Explicit, Name = ((Proto)i).Name, Handcraft = i.Handcraft, Type = (int)i.Type, Time = i.TimeSpend, Input = (i.Items ?? Array.Empty<int>()), InCounts = (i.ItemCounts ?? Array.Empty<int>()), Output = (i.Results ?? Array.Empty<int>()), OutCounts = (i.ResultCounts ?? Array.Empty<int>()), Description = i.Description, GridIndex = i.GridIndex, IconPath = i.IconPath, NonProductive = i.NonProductive }; } public RecipeProto ToProto() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown return ToProto(new RecipeProto()); } public RecipeProto ToProto(RecipeProto proto) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) ((Proto)proto).ID = ID; proto.Explicit = Explicit; ((Proto)proto).Name = Name; proto.Handcraft = Handcraft; proto.Type = (ERecipeType)Type; proto.TimeSpend = Time; proto.Items = Input; proto.ItemCounts = InCounts; proto.Results = Output ?? Array.Empty<int>(); proto.ResultCounts = OutCounts ?? Array.Empty<int>(); proto.Description = Description; proto.GridIndex = GridIndex; proto.IconPath = IconPath; proto.NonProductive = NonProductive; return proto; } } [Serializable] public class TechProtoJson { public int ID { get; set; } public string Name { get; set; } public string IconPath { get; set; } public string Desc { get; set; } public string Conclusion { get; set; } public bool IsHiddenTech { get; set; } public int[] PreItem { get; set; } public float[] Position { get; set; } public int[] PreTechs { get; set; } public int[] PreTechsImplicit { get; set; } public int[] Items { get; set; } public int[] ItemPoints { get; set; } public long HashNeeded { get; set; } public int[] UnlockRecipes { get; set; } public int[] UnlockFunctions { get; set; } public double[] UnlockValues { get; set; } public bool Published { get; set; } public int Level { get; set; } public int MaxLevel { get; set; } public int LevelCoef1 { get; set; } public int LevelCoef2 { get; set; } public bool IsLabTech { get; set; } public bool PreTechsMax { get; set; } public int[] AddItems { get; set; } public int[] AddItemCounts { get; set; } public int[] PropertyOverrideItems { get; set; } public int[] PropertyItemCounts { get; set; } public static TechProtoJson FromProto(TechProto i) { TechProtoJson techProtoJson = new TechProtoJson(); techProtoJson.ID = ((Proto)i).ID; techProtoJson.Name = ((Proto)i).Name; techProtoJson.Desc = i.Desc; techProtoJson.Conclusion = i.Conclusion; techProtoJson.IsHiddenTech = i.IsHiddenTech; techProtoJson.PreItem = i.PreItem; techProtoJson.Published = i.Published; techProtoJson.Level = i.Level; techProtoJson.MaxLevel = i.MaxLevel; techProtoJson.LevelCoef1 = i.LevelCoef1; techProtoJson.LevelCoef2 = i.LevelCoef2; techProtoJson.IconPath = i.IconPath; techProtoJson.IsLabTech = i.IsLabTech; techProtoJson.PreTechs = i.PreTechs; techProtoJson.PreTechsImplicit = i.PreTechsImplicit; techProtoJson.PreTechsMax = i.PreTechsMax; techProtoJson.Items = i.Items; techProtoJson.ItemPoints = i.ItemPoints; techProtoJson.HashNeeded = i.HashNeeded; techProtoJson.UnlockRecipes = i.UnlockRecipes; techProtoJson.UnlockFunctions = i.UnlockFunctions; techProtoJson.UnlockValues = i.UnlockValues; techProtoJson.AddItems = i.AddItems; techProtoJson.AddItemCounts = i.AddItemCounts; techProtoJson.Position = new float[2] { i.Position.x, i.Position.y }; techProtoJson.PropertyOverrideItems = i.PropertyOverrideItems; techProtoJson.PropertyItemCounts = i.PropertyItemCounts; return techProtoJson; } public TechProto ToProto() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown return ToProto(new TechProto()); } public TechProto ToProto(TechProto proto) { //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) ((Proto)proto).ID = ID; ((Proto)proto).Name = Name; proto.Desc = Desc; proto.Conclusion = Conclusion; proto.IsHiddenTech = IsHiddenTech; proto.PreItem = PreItem ?? Array.Empty<int>(); proto.Published = Published; proto.IconPath = IconPath; proto.IsLabTech = IsLabTech; proto.PreTechs = PreTechs ?? Array.Empty<int>(); proto.PreTechsImplicit = PreTechsImplicit ?? Array.Empty<int>(); proto.PreTechsMax = PreTechsMax; proto.Items = Items ?? Array.Empty<int>(); proto.ItemPoints = ItemPoints ?? Array.Empty<int>(); proto.AddItems = AddItems ?? Array.Empty<int>(); proto.AddItemCounts = AddItemCounts ?? Array.Empty<int>(); proto.Position = new Vector2(Position[0], Position[1]); proto.HashNeeded = HashNeeded; proto.UnlockRecipes = UnlockRecipes ?? Array.Empty<int>(); proto.UnlockFunctions = UnlockFunctions ?? Array.Empty<int>(); proto.UnlockValues = UnlockValues ?? Array.Empty<double>(); proto.Level = Level; proto.MaxLevel = MaxLevel; proto.LevelCoef1 = LevelCoef1; proto.LevelCoef2 = LevelCoef2; proto.PropertyOverrideItems = PropertyOverrideItems ?? Array.Empty<int>(); proto.PropertyItemCounts = PropertyItemCounts ?? Array.Empty<int>(); return proto; } } [Serializable] public class StringProtoJson { public string Name { get; set; } public string ZHCN { get; set; } public string ENUS { get; set; } } [Serializable] public class TutorialProtoJson { public int ID { get; set; } public string Name { get; set; } public string PreText { get; set; } public string DeterminatorName { get; set; } public long[] DeterminatorParams { get; set; } public TutorialProto ToProto() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown return new TutorialProto { ID = ID, Name = Name, PreText = PreText, DeterminatorName = DeterminatorName, DeterminatorParams = DeterminatorParams }; } } [Serializable] public class PrefabDescJson { public int ItemID { get; set; } public int ModelID { get; set; } public bool? isAccumulator { get; set; } = null; public bool? isAssembler { get; set; } = null; public bool? isCollectStation { get; set; } = null; public bool? isFractionator { get; set; } = null; public bool? isPowerGen { get; set; } = null; public bool? isPowerConsumer { get; set; } = null; public bool? isStation { get; set; } = null; public bool? isStellarStation { get; set; } = null; public int? assemblerRecipeType { get; set; } = null; public long? idleEnergyPerTick { get; set; } = null; public long? workEnergyPerTick { get; set; } = null; public int? assemblerSpeed { get; set; } = null; public int? minerPeriod { get; set; } = null; public int? ejectorChargeFrame { get; set; } = null; public int? ejectorColdFrame { get; set; } = null; public int? siloChargeFrame { get; set; } = null; public int? siloColdFrame { get; set; } = null; public int? labAssembleSpeed { get; set; } = null; public float? labResearchSpeed { get; set; } = null; public float? powerConnectDistance { get; set; } = null; public float? powerCoverRadius { get; set; } = null; public long? genEnergyPerTick { get; set; } = null; public long? useFuelPerTick { get; set; } = null; public int? beltSpeed { get; set; } = null; public int? inserterSTT { get; set; } = null; public int? fluidStorageCount { get; set; } = null; public int? fuelMask { get; set; } = null; public int? minerType { get; set; } = null; public int? minimapType { get; set; } = null; public int? stationCollectSpeed { get; set; } = null; public long? maxAcuEnergy { get; set; } = null; public long? inputEnergyPerTick { get; set; } = null; public long? outputEnergyPerTick { get; set; } = null; public long? maxExcEnergy { get; set; } = null; public long? exchangeEnergyPerTick { get; set; } = null; public long? stationMaxEnergyAcc { get; set; } = null; public int? stationMaxItemCount { get; set; } = null; public int? stationMaxItemKinds { get; set; } = null; public int? stationMaxDroneCount { get; set; } = null; public int? stationMaxShipCount { get; set; } = null; public float? AmmoBlastRadius1 { get; set; } = null; public float? AmmoMoveAcc { get; set; } = null; public float? AmmoTurnAcc { get; set; } = null; public int? turretMuzzleInterval { get; set; } = null; public int? turretRoundInterval { get; set; } = null; public float? turretMaxAttackRange { get; set; } = null; public float? turretDamageScale { get; set; } = null; public float? turretSpaceAttackRange { get; set; } = null; public int? turretAddEnemyExppBase { get; set; } = null; public float? turretAddEnemyExppCoef { get; set; } = null; public int? turretAddEnemyHatredBase { get; set; } = null; public float? turretAddEnemyHatredCoef { get; set; } = null; public int? turretAddEnemyThreatBase { get; set; } = null; public float? turretAddEnemyThreatCoef { get; set; } = null; public int? enemyGenMatter { get; set; } = null; public bool? multiLevel { get; set; } = null; public int? storageCol { get; set; } = null; public int? storageRow { get; set; } = null; public bool? isStorage { get; set; } = null; public bool? allowBuildInWater { get; set; } = null; public bool? needBuildInWaterTech { get; set; } = null; public int[] waterTypes { get; set; } = null; public float? turretMinAttackRange { get; set; } = null; public static PrefabDescJson FromPrefabDesc(PrefabDesc i, int itemID, int modelID) { //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected I4, but got Unknown //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected I4, but got Unknown return new PrefabDescJson { ItemID = itemID, ModelID = modelID, isAccumulator = i.isAccumulator, isAssembler = i.isAssembler, isFractionator = i.isFractionator, isPowerGen = i.isPowerGen, isStation = i.isStation, isStellarStation = i.isStellarStation, isCollectStation = i.isCollectStation, isPowerConsumer = i.isPowerConsumer, assemblerSpeed = i.assemblerSpeed, assemblerRecipeType = (int)i.assemblerRecipeType, workEnergyPerTick = i.workEnergyPerTick, idleEnergyPerTick = i.idleEnergyPerTick, minerPeriod = i.minerPeriod, ejectorChargeFrame = i.ejectorChargeFrame, ejectorColdFrame = i.ejectorColdFrame, siloChargeFrame = i.siloChargeFrame, siloColdFrame = i.siloColdFrame, labAssembleSpeed = i.labAssembleSpeed, labResearchSpeed = i.labResearchSpeed, powerConnectDistance = i.powerConnectDistance, powerCoverRadius = i.powerCoverRadius, genEnergyPerTick = i.genEnergyPerTick, useFuelPerTick = i.useFuelPerTick, beltSpeed = i.beltSpeed, inserterSTT = i.inserterSTT, fluidStorageCount = i.fluidStorageCount, fuelMask = i.fuelMask, minerType = (int)i.minerType, minimapType = i.minimapType, maxAcuEnergy = i.maxAcuEnergy, maxExcEnergy = i.maxExcEnergy, inputEnergyPerTick = i.inputEnergyPerTick, outputEnergyPerTick = i.outputEnergyPerTick, exchangeEnergyPerTick = i.exchangeEnergyPerTick, stationCollectSpeed = i.stationCollectSpeed, stationMaxEnergyAcc = i.stationMaxEnergyAcc, stationMaxItemCount = i.stationMaxItemCount, stationMaxItemKinds = i.stationMaxItemKinds, stationMaxShipCount = i.stationMaxShipCount, stationMaxDroneCount = i.stationMaxDroneCount, AmmoBlastRadius1 = i.AmmoBlastRadius1, AmmoMoveAcc = i.AmmoMoveAcc, AmmoTurnAcc = i.AmmoTurnAcc, turretMuzzleInterval = i.turretMuzzleInterval, turretRoundInterval = i.turretRoundInterval, turretMaxAttackRange = i.turretMaxAttackRange, turretDamageScale = i.turretDamageScale, turretSpaceAttackRange = i.turretSpaceAttackRange, turretAddEnemyExppBase = i.turretAddEnemyExppBase, turretAddEnemyExppCoef = i.turretAddEnemyExppCoef, turretAddEnemyHatredBase = i.turretAddEnemyHatredBase, turretAddEnemyHatredCoef = i.turretAddEnemyHatredCoef, turretAddEnemyThreatBase = i.turretAddEnemyThreatBase, turretAddEnemyThreatCoef = i.turretAddEnemyThreatCoef, enemyGenMatter = i.enemyGenMatter, multiLevel = i.multiLevel, storageCol = i.storageCol, storageRow = i.storageRow, isStorage = i.isStorage, allowBuildInWater = i.allowBuildInWater, needBuildInWaterTech = i.needBuildInWaterTech, waterTypes = i.waterTypes, turretMinAttackRange = i.turretMinAttackRange }; } public void ToPrefabDesc(PrefabDesc desc) { //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Unknown result type (might be due to invalid IL or missing references) if (isAccumulator.HasValue) { desc.isAccumulator = isAccumulator.Value; } if (isAssembler.HasValue) { desc.isAssembler = isAssembler.Value; } if (isFractionator.HasValue) { desc.isFractionator = isFractionator.Value; } if (isPowerGen.HasValue) { desc.isPowerGen = isPowerGen.Value; } if (isStation.HasValue) { desc.isStation = isStation.Value; } if (isStellarStation.HasValue) { desc.isStellarStation = isStellarStation.Value; } if (isCollectStation.HasValue) { desc.isCollectStation = isCollectStation.Value; } if (isPowerConsumer.HasValue) { desc.isPowerConsumer = isPowerConsumer.Value; } if (assemblerSpeed.HasValue) { desc.assemblerSpeed = assemblerSpeed.Value; } if (assemblerRecipeType.HasValue) { desc.assemblerRecipeType = (ERecipeType)assemblerRecipeType.Value; } if (workEnergyPerTick.HasValue) { desc.workEnergyPerTick = workEnergyPerTick.Value; } if (idleEnergyPerTick.HasValue) { desc.idleEnergyPerTick = idleEnergyPerTick.Value; } if (minerPeriod.HasValue) { desc.minerPeriod = minerPeriod.Value; } if (ejectorChargeFrame.HasValue) { desc.ejectorChargeFrame = ejectorChargeFrame.Value; } if (ejectorColdFrame.HasValue) { desc.ejectorColdFrame = ejectorColdFrame.Value; } if (siloChargeFrame.HasValue) { desc.siloChargeFrame = siloChargeFrame.Value; } if (siloColdFrame.HasValue) { desc.siloColdFrame = siloColdFrame.Value; } if (labAssembleSpeed.HasValue) { desc.labAssembleSpeed = labAssembleSpeed.Value; } if (labResearchSpeed.HasValue) { desc.labResearchSpeed = labResearchSpeed.Value; } if (powerConnectDistance.HasValue) { desc.powerConnectDistance = powerConnectDistance.Value; } if (powerCoverRadius.HasValue) { desc.powerCoverRadius = powerCoverRadius.Value; } if (genEnergyPerTick.HasValue) { desc.genEnergyPerTick = genEnergyPerTick.Value; } if (useFuelPerTick.HasValue) { desc.useFuelPerTick = useFuelPerTick.Value; } if (beltSpeed.HasValue) { desc.beltSpeed = beltSpeed.Value; } if (inserterSTT.HasValue) { desc.inserterSTT = inserterSTT.Value; } if (fluidStorageCount.HasValue) { desc.fluidStorageCount = fluidStorageCount.Value; } if (fuelMask.HasValue) { desc.fuelMask = fuelMask.Value; } if (minerType.HasValue) { desc.minerType = (EMinerType)minerType.Value; } if (minimapType.HasValue) { desc.minimapType = minimapType.Value; } if (maxAcuEnergy.HasValue) { desc.maxAcuEnergy = maxAcuEnergy.Value; } if (maxExcEnergy.HasValue) { desc.maxExcEnergy = maxExcEnergy.Value; } if (inputEnergyPerTick.HasValue) { desc.inputEnergyPerTick = inputEnergyPerTick.Value; } if (outputEnergyPerTick.HasValue) { desc.outputEnergyPerTick = outputEnergyPerTick.Value; } if (exchangeEnergyPerTick.HasValue) { desc.exchangeEnergyPerTick = exchangeEnergyPerTick.Value; } if (stationCollectSpeed.HasValue) { desc.stationCollectSpeed = stationCollectSpeed.Value; } if (stationMaxEnergyAcc.HasValue) { desc.stationMaxEnergyAcc = stationMaxEnergyAcc.Value; } if (stationMaxItemCount.HasValue) { desc.stationMaxItemCount = stationMaxItemCount.Value; } if (stationMaxItemKinds.HasValue) { desc.stationMaxItemKinds = stationMaxItemKinds.Value; } if (stationMaxShipCount.HasValue) { desc.stationMaxShipCount = stationMaxShipCount.Value; } if (stationMaxDroneCount.HasValue) { desc.stationMaxDroneCount = stationMaxDroneCount.Value; } if (AmmoBlastRadius1.HasValue) { desc.AmmoBlastRadius1 = AmmoBlastRadius1.Value; } if (AmmoMoveAcc.HasValue) { desc.AmmoMoveAcc = AmmoMoveAcc.Value; } if (AmmoTurnAcc.HasValue) { desc.AmmoTurnAcc = AmmoTurnAcc.Value; } if (turretMuzzleInterval.HasValue) { desc.turretMuzzleInterval = turretMuzzleInterval.Value; } if (turretRoundInterval.HasValue) { desc.turretRoundInterval = turretRoundInterval.Value; } if (turretMaxAttackRange.HasValue) { desc.turretMaxAttackRange = turretMaxAttackRange.Value; } if (turretDamageScale.HasValue) { desc.turretDamageScale = turretDamageScale.Value; } if (turretSpaceAttackRange.HasValue) { desc.turretSpaceAttackRange = turretSpaceAttackRange.Value; } if (turretAddEnemyExppBase.HasValue) { desc.turretAddEnemyExppBase = turretAddEnemyExppBase.Value; } if (turretAddEnemyExppCoef.HasValue) { desc.turretAddEnemyExppCoef = turretAddEnemyExppCoef.Value; } if (turretAddEnemyHatredBase.HasValue) { desc.turretAddEnemyHatredBase = turretAddEnemyHatredBase.Value; } if (turretAddEnemyHatredCoef.HasValue) { desc.turretAddEnemyHatredCoef = turretAddEnemyHatredCoef.Value; } if (turretAddEnemyThreatBase.HasValue) { desc.turretAddEnemyThreatBase = turretAddEnemyThreatBase.Value; } if (turretAddEnemyThreatCoef.HasValue) { desc.turretAddEnemyThreatCoef = turretAddEnemyThreatCoef.Value; } if (enemyGenMatter.HasValue) { desc.enemyGenMatter = enemyGenMatter.Value; } if (multiLevel.HasValue) { desc.multiLevel = multiLevel.Value; } if (storageCol.HasValue) { desc.storageCol = storageCol.Value; } if (storageRow.HasValue) { desc.storageRow = storageRow.Value; } if (isStorage.HasValue) { desc.isStorage = isStorage.Value; } if (allowBuildInWater.HasValue) { desc.allowBuildInWater = allowBuildInWater.Value; } if (needBuildInWaterTech.HasValue) { desc.needBuildInWaterTech = needBuildInWaterTech.Value; } if (waterTypes != null) { desc.waterTypes = waterTypes; } if (turretMinAttackRange.HasValue) { desc.turretMinAttackRange = turretMinAttackRange.Value; } } } private static readonly Assembly Assembly = Assembly.GetExecutingAssembly(); internal static ItemProtoJson[] ItemModProtos() { return GetJsonContent<ItemProtoJson>("items_mod"); } internal static ItemProtoJson[] ItemVanillaProtos() { return GetJsonContent<ItemProtoJson>("items_vanilla"); } internal static RecipeProtoJson[] RecipeProtos() { return GetJsonContent<RecipeProtoJson>("recipes"); } internal static TechProtoJson[] TechProtos() { return GetJsonContent<TechProtoJson>("techs"); } internal static StringProtoJson[] StringProtos() { return GetJsonContent<StringProtoJson>("strings"); } internal static StringProtoJson[] StringModProtos() { return GetJsonContent<StringProtoJson>("strings_mod"); } internal static TutorialProtoJson[] TutorialProtos() { return GetJsonContent<TutorialProtoJson>("tutorials"); } internal static PrefabDescJson[] PrefabDescs() { return GetJsonContent<PrefabDescJson>("prefabDescs"); } internal static T[] GetJsonContent<T>(string json) { return JsonConvert.DeserializeObject<T[]>(new StreamReader(Assembly.GetManifestResourceStream("ProjectGene