Decompiled source of ULTRAKIT Reloaded v2.3.1
plugins/Humanizer.dll
Decompiled 8 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using System.Threading; using Humanizer.Bytes; using Humanizer.Configuration; using Humanizer.DateTimeHumanizeStrategy; using Humanizer.Inflections; using Humanizer.Localisation; using Humanizer.Localisation.CollectionFormatters; using Humanizer.Localisation.DateToOrdinalWords; using Humanizer.Localisation.Formatters; using Humanizer.Localisation.GrammaticalNumber; using Humanizer.Localisation.NumberToWords; using Humanizer.Localisation.NumberToWords.Italian; using Humanizer.Localisation.NumberToWords.Romanian; using Humanizer.Localisation.Ordinalizers; using Microsoft.CodeAnalysis; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyFileVersion("2.14.1.48190")] [assembly: AssemblyInformationalVersion("2.14.1+3ebc38de58")] [assembly: NeutralResourcesLanguage("en")] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")] [assembly: AssemblyMetadata("CommitHash", "3ebc38de585fc641a04b0e78ed69468453b0f8a1")] [assembly: AssemblyCompany("Mehdi Khalili, Claire Novotny")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © .NET Foundation and Contributors")] [assembly: AssemblyDescription("A micro-framework that turns your normal strings, type names, enum fields, date fields ETC into a human friendly format")] [assembly: AssemblyProduct("Humanizer (netstandard2.0)")] [assembly: AssemblyTitle("Humanizer")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Humanizr/Humanizer")] [assembly: AssemblyVersion("2.14.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 { } } [GeneratedCode("Nerdbank.GitVersioning.Tasks", "3.4.255.64262")] [ExcludeFromCodeCoverage] internal static class ThisAssembly { internal const string AssemblyConfiguration = "Release"; internal const string AssemblyFileVersion = "2.14.1.48190"; internal const string AssemblyInformationalVersion = "2.14.1+3ebc38de58"; internal const string AssemblyName = "Humanizer"; internal const string AssemblyTitle = "Humanizer"; internal const string AssemblyVersion = "2.14.0.0"; internal static readonly DateTime GitCommitDate = new DateTime(637790650430000000L, DateTimeKind.Utc); internal const string GitCommitId = "3ebc38de585fc641a04b0e78ed69468453b0f8a1"; internal const bool IsPrerelease = false; internal const bool IsPublicRelease = true; internal const string PublicKey = "0024000004800000940000000602000000240000525341310004000001000100f9104f5f9bdb168ae140366eb1cd84c469b020ea3423d5d29996d5214ce2bd9b7c0ba3ead1ca545c4399668ab8911e61cc1cc83c7df6d50fd6b781365b467e65173f40a11c957d27c5aa0cb0f8da9c91c988203cc8aef1468c74a472839d0fd870da8d13a4dc6b3aafdaf0384d8e18e393c613d88bf02a64467a119902204fcc"; internal const string PublicKeyToken = "979442b78dfc278e"; internal const string RootNamespace = "Humanizer"; } namespace Humanizer { public static class EnglishArticle { public static string[] AppendArticlePrefix(string[] items) { if (items.Length == 0) { throw new ArgumentOutOfRangeException("items"); } Regex regex = new Regex("^((The)|(the)|(a)|(A)|(An)|(an))\\s\\w+"); string[] array = new string[items.Length]; for (int i = 0; i < items.Length; i++) { if (regex.IsMatch(items[i])) { string text = items[i].Substring(0, items[i].IndexOf(" ", StringComparison.CurrentCulture)); string text2 = items[i].Remove(0, items[i].IndexOf(" ", StringComparison.CurrentCulture)) + " " + text; array[i] = text2.Trim(); } else { array[i] = items[i].Trim(); } } Array.Sort(array); return array; } public static string[] PrependArticleSuffix(string[] appended) { string[] array = new string[appended.Length]; for (int i = 0; i < appended.Length; i++) { if (appended[i].EndsWith(EnglishArticles.The.ToString())) { string suffix = appended[i].Substring(appended[i].IndexOf(" The", StringComparison.CurrentCulture)); string text = ToOriginalFormat(appended, suffix, i); array[i] = text; } else if (appended[i].EndsWith(EnglishArticles.A.ToString())) { string suffix = appended[i].Substring(appended[i].IndexOf(" A", StringComparison.CurrentCulture)); string text = ToOriginalFormat(appended, suffix, i); array[i] = text; } else if (appended[i].EndsWith(EnglishArticles.An.ToString())) { string suffix = appended[i].Substring(appended[i].IndexOf(" An", StringComparison.CurrentCulture)); string text = ToOriginalFormat(appended, suffix, i); array[i] = text; } else if (appended[i].EndsWith(EnglishArticles.A.ToString().ToLowerInvariant())) { string suffix = appended[i].Substring(appended[i].IndexOf(" a", StringComparison.CurrentCulture)); string text = ToOriginalFormat(appended, suffix, i); array[i] = text; } else if (appended[i].EndsWith(EnglishArticles.An.ToString().ToLowerInvariant())) { string suffix = appended[i].Substring(appended[i].IndexOf(" an", StringComparison.CurrentCulture)); string text = ToOriginalFormat(appended, suffix, i); array[i] = text; } else if (appended[i].EndsWith(EnglishArticles.The.ToString().ToLowerInvariant())) { string suffix = appended[i].Substring(appended[i].IndexOf(" the", StringComparison.CurrentCulture)); string text = ToOriginalFormat(appended, suffix, i); array[i] = text; } else { array[i] = appended[i]; } } return array; } private static string ToOriginalFormat(string[] appended, string suffix, int i) { string text = appended[i].Remove(appended[i].IndexOf(suffix, StringComparison.CurrentCulture)); return (suffix + " " + text).Trim(); } } public enum EnglishArticles { A, An, The } public static class ByteSizeExtensions { public static ByteSize Bits(this byte input) { return ByteSize.FromBits(input); } public static ByteSize Bits(this sbyte input) { return ByteSize.FromBits(input); } public static ByteSize Bits(this short input) { return ByteSize.FromBits(input); } public static ByteSize Bits(this ushort input) { return ByteSize.FromBits(input); } public static ByteSize Bits(this int input) { return ByteSize.FromBits(input); } public static ByteSize Bits(this uint input) { return ByteSize.FromBits(input); } public static ByteSize Bits(this long input) { return ByteSize.FromBits(input); } public static ByteSize Bytes(this byte input) { return ByteSize.FromBytes((int)input); } public static ByteSize Bytes(this sbyte input) { return ByteSize.FromBytes(input); } public static ByteSize Bytes(this short input) { return ByteSize.FromBytes(input); } public static ByteSize Bytes(this ushort input) { return ByteSize.FromBytes((int)input); } public static ByteSize Bytes(this int input) { return ByteSize.FromBytes(input); } public static ByteSize Bytes(this uint input) { return ByteSize.FromBytes(input); } public static ByteSize Bytes(this double input) { return ByteSize.FromBytes(input); } public static ByteSize Bytes(this long input) { return ByteSize.FromBytes(input); } public static ByteSize Kilobytes(this byte input) { return ByteSize.FromKilobytes((int)input); } public static ByteSize Kilobytes(this sbyte input) { return ByteSize.FromKilobytes(input); } public static ByteSize Kilobytes(this short input) { return ByteSize.FromKilobytes(input); } public static ByteSize Kilobytes(this ushort input) { return ByteSize.FromKilobytes((int)input); } public static ByteSize Kilobytes(this int input) { return ByteSize.FromKilobytes(input); } public static ByteSize Kilobytes(this uint input) { return ByteSize.FromKilobytes(input); } public static ByteSize Kilobytes(this double input) { return ByteSize.FromKilobytes(input); } public static ByteSize Kilobytes(this long input) { return ByteSize.FromKilobytes(input); } public static ByteSize Megabytes(this byte input) { return ByteSize.FromMegabytes((int)input); } public static ByteSize Megabytes(this sbyte input) { return ByteSize.FromMegabytes(input); } public static ByteSize Megabytes(this short input) { return ByteSize.FromMegabytes(input); } public static ByteSize Megabytes(this ushort input) { return ByteSize.FromMegabytes((int)input); } public static ByteSize Megabytes(this int input) { return ByteSize.FromMegabytes(input); } public static ByteSize Megabytes(this uint input) { return ByteSize.FromMegabytes(input); } public static ByteSize Megabytes(this double input) { return ByteSize.FromMegabytes(input); } public static ByteSize Megabytes(this long input) { return ByteSize.FromMegabytes(input); } public static ByteSize Gigabytes(this byte input) { return ByteSize.FromGigabytes((int)input); } public static ByteSize Gigabytes(this sbyte input) { return ByteSize.FromGigabytes(input); } public static ByteSize Gigabytes(this short input) { return ByteSize.FromGigabytes(input); } public static ByteSize Gigabytes(this ushort input) { return ByteSize.FromGigabytes((int)input); } public static ByteSize Gigabytes(this int input) { return ByteSize.FromGigabytes(input); } public static ByteSize Gigabytes(this uint input) { return ByteSize.FromGigabytes(input); } public static ByteSize Gigabytes(this double input) { return ByteSize.FromGigabytes(input); } public static ByteSize Gigabytes(this long input) { return ByteSize.FromGigabytes(input); } public static ByteSize Terabytes(this byte input) { return ByteSize.FromTerabytes((int)input); } public static ByteSize Terabytes(this sbyte input) { return ByteSize.FromTerabytes(input); } public static ByteSize Terabytes(this short input) { return ByteSize.FromTerabytes(input); } public static ByteSize Terabytes(this ushort input) { return ByteSize.FromTerabytes((int)input); } public static ByteSize Terabytes(this int input) { return ByteSize.FromTerabytes(input); } public static ByteSize Terabytes(this uint input) { return ByteSize.FromTerabytes(input); } public static ByteSize Terabytes(this double input) { return ByteSize.FromTerabytes(input); } public static ByteSize Terabytes(this long input) { return ByteSize.FromTerabytes(input); } public static string Humanize(this ByteSize input, string format = null) { if (!string.IsNullOrWhiteSpace(format)) { return input.ToString(format); } return input.ToString(); } public static string Humanize(this ByteSize input, IFormatProvider formatProvider) { return input.ToString(formatProvider); } public static string Humanize(this ByteSize input, string format, IFormatProvider formatProvider) { if (!string.IsNullOrWhiteSpace(format)) { return input.ToString(format, formatProvider); } return input.ToString(formatProvider); } public static ByteRate Per(this ByteSize size, TimeSpan interval) { return new ByteRate(size, interval); } } public static class CasingExtensions { public static string ApplyCase(this string input, LetterCasing casing) { return casing switch { LetterCasing.Title => input.Transform(To.TitleCase), LetterCasing.LowerCase => input.Transform(To.LowerCase), LetterCasing.AllCaps => input.Transform(To.UpperCase), LetterCasing.Sentence => input.Transform(To.SentenceCase), _ => throw new ArgumentOutOfRangeException("casing"), }; } } public enum ClockNotationRounding { None, NearestFiveMinutes } public static class CollectionHumanizeExtensions { public static string Humanize<T>(this IEnumerable<T> collection) { return Configurator.CollectionFormatter.Humanize(collection); } public static string Humanize<T>(this IEnumerable<T> collection, Func<T, string> displayFormatter) { if (displayFormatter == null) { throw new ArgumentNullException("displayFormatter"); } return Configurator.CollectionFormatter.Humanize(collection, displayFormatter); } public static string Humanize<T>(this IEnumerable<T> collection, Func<T, object> displayFormatter) { if (displayFormatter == null) { throw new ArgumentNullException("displayFormatter"); } return Configurator.CollectionFormatter.Humanize(collection, displayFormatter); } public static string Humanize<T>(this IEnumerable<T> collection, string separator) { return Configurator.CollectionFormatter.Humanize(collection, separator); } public static string Humanize<T>(this IEnumerable<T> collection, Func<T, string> displayFormatter, string separator) { if (displayFormatter == null) { throw new ArgumentNullException("displayFormatter"); } return Configurator.CollectionFormatter.Humanize(collection, displayFormatter, separator); } public static string Humanize<T>(this IEnumerable<T> collection, Func<T, object> displayFormatter, string separator) { if (displayFormatter == null) { throw new ArgumentNullException("displayFormatter"); } return Configurator.CollectionFormatter.Humanize(collection, displayFormatter, separator); } } public static class DateHumanizeExtensions { public static string Humanize(this DateTime input, bool? utcDate = null, DateTime? dateToCompareAgainst = null, CultureInfo culture = null) { DateTime dateTime = (dateToCompareAgainst.HasValue ? dateToCompareAgainst.Value : DateTime.UtcNow); bool valueOrDefault = utcDate.GetValueOrDefault(); if (!utcDate.HasValue) { valueOrDefault = input.Kind != DateTimeKind.Local; utcDate = valueOrDefault; } dateTime = (utcDate.Value ? dateTime.ToUniversalTime() : dateTime.ToLocalTime()); return Configurator.DateTimeHumanizeStrategy.Humanize(input, dateTime, culture); } public static string Humanize(this DateTime? input, bool? utcDate = null, DateTime? dateToCompareAgainst = null, CultureInfo culture = null) { if (input.HasValue) { return input.Value.Humanize(utcDate, dateToCompareAgainst, culture); } return Configurator.GetFormatter(culture).DateHumanize_Never(); } public static string Humanize(this DateTimeOffset input, DateTimeOffset? dateToCompareAgainst = null, CultureInfo culture = null) { DateTimeOffset comparisonBase = dateToCompareAgainst ?? DateTimeOffset.UtcNow; return Configurator.DateTimeOffsetHumanizeStrategy.Humanize(input, comparisonBase, culture); } public static string Humanize(this DateTimeOffset? input, DateTimeOffset? dateToCompareAgainst = null, CultureInfo culture = null) { if (input.HasValue) { return input.Value.Humanize(dateToCompareAgainst, culture); } return Configurator.GetFormatter(culture).DateHumanize_Never(); } } public static class DateToOrdinalWordsExtensions { public static string ToOrdinalWords(this DateTime input) { return Configurator.DateToOrdinalWordsConverter.Convert(input); } public static string ToOrdinalWords(this DateTime input, GrammaticalCase grammaticalCase) { return Configurator.DateToOrdinalWordsConverter.Convert(input, grammaticalCase); } } public static class EnumDehumanizeExtensions { public static TTargetEnum DehumanizeTo<TTargetEnum>(this string input) where TTargetEnum : struct, IComparable, IFormattable { return (TTargetEnum)DehumanizeToPrivate(input, typeof(TTargetEnum), OnNoMatch.ThrowsException); } public static Enum DehumanizeTo(this string input, Type targetEnum, OnNoMatch onNoMatch = OnNoMatch.ThrowsException) { return (Enum)DehumanizeToPrivate(input, targetEnum, onNoMatch); } private static object DehumanizeToPrivate(string input, Type targetEnum, OnNoMatch onNoMatch) { Enum? @enum = Enum.GetValues(targetEnum).Cast<Enum>().FirstOrDefault((Enum value) => string.Equals(value.Humanize(), input, StringComparison.OrdinalIgnoreCase)); if (@enum == null && onNoMatch == OnNoMatch.ThrowsException) { throw new NoMatchFoundException("Couldn't find any enum member that matches the string " + input); } return @enum; } } public static class EnumHumanizeExtensions { private const string DisplayAttributeTypeName = "System.ComponentModel.DataAnnotations.DisplayAttribute"; private const string DisplayAttributeGetDescriptionMethodName = "GetDescription"; private const string DisplayAttributeGetNameMethodName = "GetName"; private static readonly Func<PropertyInfo, bool> StringTypedProperty = (PropertyInfo p) => p.PropertyType == typeof(string); public static string Humanize(this Enum input) { Type enumType = input.GetType(); TypeInfo typeInfo = enumType.GetTypeInfo(); if (IsBitFieldEnum(typeInfo) && !Enum.IsDefined(enumType, input)) { return (from e in (from Enum e in Enum.GetValues(enumType) where e.CompareTo(Convert.ChangeType(Enum.ToObject(enumType, 0), enumType)) != 0 select e).Where(input.HasFlag) select e.Humanize()).Humanize(); } string text = input.ToString(); FieldInfo declaredField = typeInfo.GetDeclaredField(text); if (declaredField != null) { string customDescription = GetCustomDescription(declaredField); if (customDescription != null) { return customDescription; } } return text.Humanize(); } private static bool IsBitFieldEnum(TypeInfo typeInfo) { return typeInfo.GetCustomAttribute(typeof(FlagsAttribute)) != null; } private static string GetCustomDescription(MemberInfo memberInfo) { object[] customAttributes = memberInfo.GetCustomAttributes(inherit: true); foreach (object obj in customAttributes) { Type type = obj.GetType(); if (type.FullName == "System.ComponentModel.DataAnnotations.DisplayAttribute") { MethodInfo runtimeMethod = type.GetRuntimeMethod("GetDescription", new Type[0]); if (runtimeMethod != null) { object obj2 = runtimeMethod.Invoke(obj, new object[0]); if (obj2 != null) { return obj2.ToString(); } } MethodInfo runtimeMethod2 = type.GetRuntimeMethod("GetName", new Type[0]); if (runtimeMethod2 != null) { object obj3 = runtimeMethod2.Invoke(obj, new object[0]); if (obj3 != null) { return obj3.ToString(); } } return null; } PropertyInfo propertyInfo = type.GetRuntimeProperties().Where(StringTypedProperty).FirstOrDefault(Configurator.EnumDescriptionPropertyLocator); if (propertyInfo != null) { return propertyInfo.GetValue(obj, null).ToString(); } } return null; } public static string Humanize(this Enum input, LetterCasing casing) { return input.Humanize().ApplyCase(casing); } } public class In { public static class One { public static DateTime Second => DateTime.UtcNow.AddSeconds(1.0); public static DateTime Minute => DateTime.UtcNow.AddMinutes(1.0); public static DateTime Hour => DateTime.UtcNow.AddHours(1.0); public static DateTime Day => DateTime.UtcNow.AddDays(1.0); public static DateTime Week => DateTime.UtcNow.AddDays(7.0); public static DateTime Month => DateTime.UtcNow.AddMonths(1); public static DateTime Year => DateTime.UtcNow.AddYears(1); public static DateTime SecondFrom(DateTime date) { return date.AddSeconds(1.0); } public static DateTime MinuteFrom(DateTime date) { return date.AddMinutes(1.0); } public static DateTime HourFrom(DateTime date) { return date.AddHours(1.0); } public static DateTime DayFrom(DateTime date) { return date.AddDays(1.0); } public static DateTime WeekFrom(DateTime date) { return date.AddDays(7.0); } public static DateTime MonthFrom(DateTime date) { return date.AddMonths(1); } public static DateTime YearFrom(DateTime date) { return date.AddYears(1); } } public static class Two { public static DateTime Seconds => DateTime.UtcNow.AddSeconds(2.0); public static DateTime Minutes => DateTime.UtcNow.AddMinutes(2.0); public static DateTime Hours => DateTime.UtcNow.AddHours(2.0); public static DateTime Days => DateTime.UtcNow.AddDays(2.0); public static DateTime Weeks => DateTime.UtcNow.AddDays(14.0); public static DateTime Months => DateTime.UtcNow.AddMonths(2); public static DateTime Years => DateTime.UtcNow.AddYears(2); public static DateTime SecondsFrom(DateTime date) { return date.AddSeconds(2.0); } public static DateTime MinutesFrom(DateTime date) { return date.AddMinutes(2.0); } public static DateTime HoursFrom(DateTime date) { return date.AddHours(2.0); } public static DateTime DaysFrom(DateTime date) { return date.AddDays(2.0); } public static DateTime WeeksFrom(DateTime date) { return date.AddDays(14.0); } public static DateTime MonthsFrom(DateTime date) { return date.AddMonths(2); } public static DateTime YearsFrom(DateTime date) { return date.AddYears(2); } } public static class Three { public static DateTime Seconds => DateTime.UtcNow.AddSeconds(3.0); public static DateTime Minutes => DateTime.UtcNow.AddMinutes(3.0); public static DateTime Hours => DateTime.UtcNow.AddHours(3.0); public static DateTime Days => DateTime.UtcNow.AddDays(3.0); public static DateTime Weeks => DateTime.UtcNow.AddDays(21.0); public static DateTime Months => DateTime.UtcNow.AddMonths(3); public static DateTime Years => DateTime.UtcNow.AddYears(3); public static DateTime SecondsFrom(DateTime date) { return date.AddSeconds(3.0); } public static DateTime MinutesFrom(DateTime date) { return date.AddMinutes(3.0); } public static DateTime HoursFrom(DateTime date) { return date.AddHours(3.0); } public static DateTime DaysFrom(DateTime date) { return date.AddDays(3.0); } public static DateTime WeeksFrom(DateTime date) { return date.AddDays(21.0); } public static DateTime MonthsFrom(DateTime date) { return date.AddMonths(3); } public static DateTime YearsFrom(DateTime date) { return date.AddYears(3); } } public static class Four { public static DateTime Seconds => DateTime.UtcNow.AddSeconds(4.0); public static DateTime Minutes => DateTime.UtcNow.AddMinutes(4.0); public static DateTime Hours => DateTime.UtcNow.AddHours(4.0); public static DateTime Days => DateTime.UtcNow.AddDays(4.0); public static DateTime Weeks => DateTime.UtcNow.AddDays(28.0); public static DateTime Months => DateTime.UtcNow.AddMonths(4); public static DateTime Years => DateTime.UtcNow.AddYears(4); public static DateTime SecondsFrom(DateTime date) { return date.AddSeconds(4.0); } public static DateTime MinutesFrom(DateTime date) { return date.AddMinutes(4.0); } public static DateTime HoursFrom(DateTime date) { return date.AddHours(4.0); } public static DateTime DaysFrom(DateTime date) { return date.AddDays(4.0); } public static DateTime WeeksFrom(DateTime date) { return date.AddDays(28.0); } public static DateTime MonthsFrom(DateTime date) { return date.AddMonths(4); } public static DateTime YearsFrom(DateTime date) { return date.AddYears(4); } } public static class Five { public static DateTime Seconds => DateTime.UtcNow.AddSeconds(5.0); public static DateTime Minutes => DateTime.UtcNow.AddMinutes(5.0); public static DateTime Hours => DateTime.UtcNow.AddHours(5.0); public static DateTime Days => DateTime.UtcNow.AddDays(5.0); public static DateTime Weeks => DateTime.UtcNow.AddDays(35.0); public static DateTime Months => DateTime.UtcNow.AddMonths(5); public static DateTime Years => DateTime.UtcNow.AddYears(5); public static DateTime SecondsFrom(DateTime date) { return date.AddSeconds(5.0); } public static DateTime MinutesFrom(DateTime date) { return date.AddMinutes(5.0); } public static DateTime HoursFrom(DateTime date) { return date.AddHours(5.0); } public static DateTime DaysFrom(DateTime date) { return date.AddDays(5.0); } public static DateTime WeeksFrom(DateTime date) { return date.AddDays(35.0); } public static DateTime MonthsFrom(DateTime date) { return date.AddMonths(5); } public static DateTime YearsFrom(DateTime date) { return date.AddYears(5); } } public static class Six { public static DateTime Seconds => DateTime.UtcNow.AddSeconds(6.0); public static DateTime Minutes => DateTime.UtcNow.AddMinutes(6.0); public static DateTime Hours => DateTime.UtcNow.AddHours(6.0); public static DateTime Days => DateTime.UtcNow.AddDays(6.0); public static DateTime Weeks => DateTime.UtcNow.AddDays(42.0); public static DateTime Months => DateTime.UtcNow.AddMonths(6); public static DateTime Years => DateTime.UtcNow.AddYears(6); public static DateTime SecondsFrom(DateTime date) { return date.AddSeconds(6.0); } public static DateTime MinutesFrom(DateTime date) { return date.AddMinutes(6.0); } public static DateTime HoursFrom(DateTime date) { return date.AddHours(6.0); } public static DateTime DaysFrom(DateTime date) { return date.AddDays(6.0); } public static DateTime WeeksFrom(DateTime date) { return date.AddDays(42.0); } public static DateTime MonthsFrom(DateTime date) { return date.AddMonths(6); } public static DateTime YearsFrom(DateTime date) { return date.AddYears(6); } } public static class Seven { public static DateTime Seconds => DateTime.UtcNow.AddSeconds(7.0); public static DateTime Minutes => DateTime.UtcNow.AddMinutes(7.0); public static DateTime Hours => DateTime.UtcNow.AddHours(7.0); public static DateTime Days => DateTime.UtcNow.AddDays(7.0); public static DateTime Weeks => DateTime.UtcNow.AddDays(49.0); public static DateTime Months => DateTime.UtcNow.AddMonths(7); public static DateTime Years => DateTime.UtcNow.AddYears(7); public static DateTime SecondsFrom(DateTime date) { return date.AddSeconds(7.0); } public static DateTime MinutesFrom(DateTime date) { return date.AddMinutes(7.0); } public static DateTime HoursFrom(DateTime date) { return date.AddHours(7.0); } public static DateTime DaysFrom(DateTime date) { return date.AddDays(7.0); } public static DateTime WeeksFrom(DateTime date) { return date.AddDays(49.0); } public static DateTime MonthsFrom(DateTime date) { return date.AddMonths(7); } public static DateTime YearsFrom(DateTime date) { return date.AddYears(7); } } public static class Eight { public static DateTime Seconds => DateTime.UtcNow.AddSeconds(8.0); public static DateTime Minutes => DateTime.UtcNow.AddMinutes(8.0); public static DateTime Hours => DateTime.UtcNow.AddHours(8.0); public static DateTime Days => DateTime.UtcNow.AddDays(8.0); public static DateTime Weeks => DateTime.UtcNow.AddDays(56.0); public static DateTime Months => DateTime.UtcNow.AddMonths(8); public static DateTime Years => DateTime.UtcNow.AddYears(8); public static DateTime SecondsFrom(DateTime date) { return date.AddSeconds(8.0); } public static DateTime MinutesFrom(DateTime date) { return date.AddMinutes(8.0); } public static DateTime HoursFrom(DateTime date) { return date.AddHours(8.0); } public static DateTime DaysFrom(DateTime date) { return date.AddDays(8.0); } public static DateTime WeeksFrom(DateTime date) { return date.AddDays(56.0); } public static DateTime MonthsFrom(DateTime date) { return date.AddMonths(8); } public static DateTime YearsFrom(DateTime date) { return date.AddYears(8); } } public static class Nine { public static DateTime Seconds => DateTime.UtcNow.AddSeconds(9.0); public static DateTime Minutes => DateTime.UtcNow.AddMinutes(9.0); public static DateTime Hours => DateTime.UtcNow.AddHours(9.0); public static DateTime Days => DateTime.UtcNow.AddDays(9.0); public static DateTime Weeks => DateTime.UtcNow.AddDays(63.0); public static DateTime Months => DateTime.UtcNow.AddMonths(9); public static DateTime Years => DateTime.UtcNow.AddYears(9); public static DateTime SecondsFrom(DateTime date) { return date.AddSeconds(9.0); } public static DateTime MinutesFrom(DateTime date) { return date.AddMinutes(9.0); } public static DateTime HoursFrom(DateTime date) { return date.AddHours(9.0); } public static DateTime DaysFrom(DateTime date) { return date.AddDays(9.0); } public static DateTime WeeksFrom(DateTime date) { return date.AddDays(63.0); } public static DateTime MonthsFrom(DateTime date) { return date.AddMonths(9); } public static DateTime YearsFrom(DateTime date) { return date.AddYears(9); } } public static class Ten { public static DateTime Seconds => DateTime.UtcNow.AddSeconds(10.0); public static DateTime Minutes => DateTime.UtcNow.AddMinutes(10.0); public static DateTime Hours => DateTime.UtcNow.AddHours(10.0); public static DateTime Days => DateTime.UtcNow.AddDays(10.0); public static DateTime Weeks => DateTime.UtcNow.AddDays(70.0); public static DateTime Months => DateTime.UtcNow.AddMonths(10); public static DateTime Years => DateTime.UtcNow.AddYears(10); public static DateTime SecondsFrom(DateTime date) { return date.AddSeconds(10.0); } public static DateTime MinutesFrom(DateTime date) { return date.AddMinutes(10.0); } public static DateTime HoursFrom(DateTime date) { return date.AddHours(10.0); } public static DateTime DaysFrom(DateTime date) { return date.AddDays(10.0); } public static DateTime WeeksFrom(DateTime date) { return date.AddDays(70.0); } public static DateTime MonthsFrom(DateTime date) { return date.AddMonths(10); } public static DateTime YearsFrom(DateTime date) { return date.AddYears(10); } } public static DateTime January => new DateTime(DateTime.UtcNow.Year, 1, 1); public static DateTime February => new DateTime(DateTime.UtcNow.Year, 2, 1); public static DateTime March => new DateTime(DateTime.UtcNow.Year, 3, 1); public static DateTime April => new DateTime(DateTime.UtcNow.Year, 4, 1); public static DateTime May => new DateTime(DateTime.UtcNow.Year, 5, 1); public static DateTime June => new DateTime(DateTime.UtcNow.Year, 6, 1); public static DateTime July => new DateTime(DateTime.UtcNow.Year, 7, 1); public static DateTime August => new DateTime(DateTime.UtcNow.Year, 8, 1); public static DateTime September => new DateTime(DateTime.UtcNow.Year, 9, 1); public static DateTime October => new DateTime(DateTime.UtcNow.Year, 10, 1); public static DateTime November => new DateTime(DateTime.UtcNow.Year, 11, 1); public static DateTime December => new DateTime(DateTime.UtcNow.Year, 12, 1); public static DateTime TheYear(int year) { return new DateTime(year, 1, 1); } public static DateTime JanuaryOf(int year) { return new DateTime(year, 1, 1); } public static DateTime FebruaryOf(int year) { return new DateTime(year, 2, 1); } public static DateTime MarchOf(int year) { return new DateTime(year, 3, 1); } public static DateTime AprilOf(int year) { return new DateTime(year, 4, 1); } public static DateTime MayOf(int year) { return new DateTime(year, 5, 1); } public static DateTime JuneOf(int year) { return new DateTime(year, 6, 1); } public static DateTime JulyOf(int year) { return new DateTime(year, 7, 1); } public static DateTime AugustOf(int year) { return new DateTime(year, 8, 1); } public static DateTime SeptemberOf(int year) { return new DateTime(year, 9, 1); } public static DateTime OctoberOf(int year) { return new DateTime(year, 10, 1); } public static DateTime NovemberOf(int year) { return new DateTime(year, 11, 1); } public static DateTime DecemberOf(int year) { return new DateTime(year, 12, 1); } } public class On { public class January { public static DateTime The1st => new DateTime(DateTime.Now.Year, 1, 1); public static DateTime The2nd => new DateTime(DateTime.Now.Year, 1, 2); public static DateTime The3rd => new DateTime(DateTime.Now.Year, 1, 3); public static DateTime The4th => new DateTime(DateTime.Now.Year, 1, 4); public static DateTime The5th => new DateTime(DateTime.Now.Year, 1, 5); public static DateTime The6th => new DateTime(DateTime.Now.Year, 1, 6); public static DateTime The7th => new DateTime(DateTime.Now.Year, 1, 7); public static DateTime The8th => new DateTime(DateTime.Now.Year, 1, 8); public static DateTime The9th => new DateTime(DateTime.Now.Year, 1, 9); public static DateTime The10th => new DateTime(DateTime.Now.Year, 1, 10); public static DateTime The11th => new DateTime(DateTime.Now.Year, 1, 11); public static DateTime The12th => new DateTime(DateTime.Now.Year, 1, 12); public static DateTime The13th => new DateTime(DateTime.Now.Year, 1, 13); public static DateTime The14th => new DateTime(DateTime.Now.Year, 1, 14); public static DateTime The15th => new DateTime(DateTime.Now.Year, 1, 15); public static DateTime The16th => new DateTime(DateTime.Now.Year, 1, 16); public static DateTime The17th => new DateTime(DateTime.Now.Year, 1, 17); public static DateTime The18th => new DateTime(DateTime.Now.Year, 1, 18); public static DateTime The19th => new DateTime(DateTime.Now.Year, 1, 19); public static DateTime The20th => new DateTime(DateTime.Now.Year, 1, 20); public static DateTime The21st => new DateTime(DateTime.Now.Year, 1, 21); public static DateTime The22nd => new DateTime(DateTime.Now.Year, 1, 22); public static DateTime The23rd => new DateTime(DateTime.Now.Year, 1, 23); public static DateTime The24th => new DateTime(DateTime.Now.Year, 1, 24); public static DateTime The25th => new DateTime(DateTime.Now.Year, 1, 25); public static DateTime The26th => new DateTime(DateTime.Now.Year, 1, 26); public static DateTime The27th => new DateTime(DateTime.Now.Year, 1, 27); public static DateTime The28th => new DateTime(DateTime.Now.Year, 1, 28); public static DateTime The29th => new DateTime(DateTime.Now.Year, 1, 29); public static DateTime The30th => new DateTime(DateTime.Now.Year, 1, 30); public static DateTime The31st => new DateTime(DateTime.Now.Year, 1, 31); public static DateTime The(int dayNumber) { return new DateTime(DateTime.Now.Year, 1, dayNumber); } } public class February { public static DateTime The1st => new DateTime(DateTime.Now.Year, 2, 1); public static DateTime The2nd => new DateTime(DateTime.Now.Year, 2, 2); public static DateTime The3rd => new DateTime(DateTime.Now.Year, 2, 3); public static DateTime The4th => new DateTime(DateTime.Now.Year, 2, 4); public static DateTime The5th => new DateTime(DateTime.Now.Year, 2, 5); public static DateTime The6th => new DateTime(DateTime.Now.Year, 2, 6); public static DateTime The7th => new DateTime(DateTime.Now.Year, 2, 7); public static DateTime The8th => new DateTime(DateTime.Now.Year, 2, 8); public static DateTime The9th => new DateTime(DateTime.Now.Year, 2, 9); public static DateTime The10th => new DateTime(DateTime.Now.Year, 2, 10); public static DateTime The11th => new DateTime(DateTime.Now.Year, 2, 11); public static DateTime The12th => new DateTime(DateTime.Now.Year, 2, 12); public static DateTime The13th => new DateTime(DateTime.Now.Year, 2, 13); public static DateTime The14th => new DateTime(DateTime.Now.Year, 2, 14); public static DateTime The15th => new DateTime(DateTime.Now.Year, 2, 15); public static DateTime The16th => new DateTime(DateTime.Now.Year, 2, 16); public static DateTime The17th => new DateTime(DateTime.Now.Year, 2, 17); public static DateTime The18th => new DateTime(DateTime.Now.Year, 2, 18); public static DateTime The19th => new DateTime(DateTime.Now.Year, 2, 19); public static DateTime The20th => new DateTime(DateTime.Now.Year, 2, 20); public static DateTime The21st => new DateTime(DateTime.Now.Year, 2, 21); public static DateTime The22nd => new DateTime(DateTime.Now.Year, 2, 22); public static DateTime The23rd => new DateTime(DateTime.Now.Year, 2, 23); public static DateTime The24th => new DateTime(DateTime.Now.Year, 2, 24); public static DateTime The25th => new DateTime(DateTime.Now.Year, 2, 25); public static DateTime The26th => new DateTime(DateTime.Now.Year, 2, 26); public static DateTime The27th => new DateTime(DateTime.Now.Year, 2, 27); public static DateTime The28th => new DateTime(DateTime.Now.Year, 2, 28); public static DateTime The29th => new DateTime(DateTime.Now.Year, 2, 29); public static DateTime The(int dayNumber) { return new DateTime(DateTime.Now.Year, 2, dayNumber); } } public class March { public static DateTime The1st => new DateTime(DateTime.Now.Year, 3, 1); public static DateTime The2nd => new DateTime(DateTime.Now.Year, 3, 2); public static DateTime The3rd => new DateTime(DateTime.Now.Year, 3, 3); public static DateTime The4th => new DateTime(DateTime.Now.Year, 3, 4); public static DateTime The5th => new DateTime(DateTime.Now.Year, 3, 5); public static DateTime The6th => new DateTime(DateTime.Now.Year, 3, 6); public static DateTime The7th => new DateTime(DateTime.Now.Year, 3, 7); public static DateTime The8th => new DateTime(DateTime.Now.Year, 3, 8); public static DateTime The9th => new DateTime(DateTime.Now.Year, 3, 9); public static DateTime The10th => new DateTime(DateTime.Now.Year, 3, 10); public static DateTime The11th => new DateTime(DateTime.Now.Year, 3, 11); public static DateTime The12th => new DateTime(DateTime.Now.Year, 3, 12); public static DateTime The13th => new DateTime(DateTime.Now.Year, 3, 13); public static DateTime The14th => new DateTime(DateTime.Now.Year, 3, 14); public static DateTime The15th => new DateTime(DateTime.Now.Year, 3, 15); public static DateTime The16th => new DateTime(DateTime.Now.Year, 3, 16); public static DateTime The17th => new DateTime(DateTime.Now.Year, 3, 17); public static DateTime The18th => new DateTime(DateTime.Now.Year, 3, 18); public static DateTime The19th => new DateTime(DateTime.Now.Year, 3, 19); public static DateTime The20th => new DateTime(DateTime.Now.Year, 3, 20); public static DateTime The21st => new DateTime(DateTime.Now.Year, 3, 21); public static DateTime The22nd => new DateTime(DateTime.Now.Year, 3, 22); public static DateTime The23rd => new DateTime(DateTime.Now.Year, 3, 23); public static DateTime The24th => new DateTime(DateTime.Now.Year, 3, 24); public static DateTime The25th => new DateTime(DateTime.Now.Year, 3, 25); public static DateTime The26th => new DateTime(DateTime.Now.Year, 3, 26); public static DateTime The27th => new DateTime(DateTime.Now.Year, 3, 27); public static DateTime The28th => new DateTime(DateTime.Now.Year, 3, 28); public static DateTime The29th => new DateTime(DateTime.Now.Year, 3, 29); public static DateTime The30th => new DateTime(DateTime.Now.Year, 3, 30); public static DateTime The31st => new DateTime(DateTime.Now.Year, 3, 31); public static DateTime The(int dayNumber) { return new DateTime(DateTime.Now.Year, 3, dayNumber); } } public class April { public static DateTime The1st => new DateTime(DateTime.Now.Year, 4, 1); public static DateTime The2nd => new DateTime(DateTime.Now.Year, 4, 2); public static DateTime The3rd => new DateTime(DateTime.Now.Year, 4, 3); public static DateTime The4th => new DateTime(DateTime.Now.Year, 4, 4); public static DateTime The5th => new DateTime(DateTime.Now.Year, 4, 5); public static DateTime The6th => new DateTime(DateTime.Now.Year, 4, 6); public static DateTime The7th => new DateTime(DateTime.Now.Year, 4, 7); public static DateTime The8th => new DateTime(DateTime.Now.Year, 4, 8); public static DateTime The9th => new DateTime(DateTime.Now.Year, 4, 9); public static DateTime The10th => new DateTime(DateTime.Now.Year, 4, 10); public static DateTime The11th => new DateTime(DateTime.Now.Year, 4, 11); public static DateTime The12th => new DateTime(DateTime.Now.Year, 4, 12); public static DateTime The13th => new DateTime(DateTime.Now.Year, 4, 13); public static DateTime The14th => new DateTime(DateTime.Now.Year, 4, 14); public static DateTime The15th => new DateTime(DateTime.Now.Year, 4, 15); public static DateTime The16th => new DateTime(DateTime.Now.Year, 4, 16); public static DateTime The17th => new DateTime(DateTime.Now.Year, 4, 17); public static DateTime The18th => new DateTime(DateTime.Now.Year, 4, 18); public static DateTime The19th => new DateTime(DateTime.Now.Year, 4, 19); public static DateTime The20th => new DateTime(DateTime.Now.Year, 4, 20); public static DateTime The21st => new DateTime(DateTime.Now.Year, 4, 21); public static DateTime The22nd => new DateTime(DateTime.Now.Year, 4, 22); public static DateTime The23rd => new DateTime(DateTime.Now.Year, 4, 23); public static DateTime The24th => new DateTime(DateTime.Now.Year, 4, 24); public static DateTime The25th => new DateTime(DateTime.Now.Year, 4, 25); public static DateTime The26th => new DateTime(DateTime.Now.Year, 4, 26); public static DateTime The27th => new DateTime(DateTime.Now.Year, 4, 27); public static DateTime The28th => new DateTime(DateTime.Now.Year, 4, 28); public static DateTime The29th => new DateTime(DateTime.Now.Year, 4, 29); public static DateTime The30th => new DateTime(DateTime.Now.Year, 4, 30); public static DateTime The(int dayNumber) { return new DateTime(DateTime.Now.Year, 4, dayNumber); } } public class May { public static DateTime The1st => new DateTime(DateTime.Now.Year, 5, 1); public static DateTime The2nd => new DateTime(DateTime.Now.Year, 5, 2); public static DateTime The3rd => new DateTime(DateTime.Now.Year, 5, 3); public static DateTime The4th => new DateTime(DateTime.Now.Year, 5, 4); public static DateTime The5th => new DateTime(DateTime.Now.Year, 5, 5); public static DateTime The6th => new DateTime(DateTime.Now.Year, 5, 6); public static DateTime The7th => new DateTime(DateTime.Now.Year, 5, 7); public static DateTime The8th => new DateTime(DateTime.Now.Year, 5, 8); public static DateTime The9th => new DateTime(DateTime.Now.Year, 5, 9); public static DateTime The10th => new DateTime(DateTime.Now.Year, 5, 10); public static DateTime The11th => new DateTime(DateTime.Now.Year, 5, 11); public static DateTime The12th => new DateTime(DateTime.Now.Year, 5, 12); public static DateTime The13th => new DateTime(DateTime.Now.Year, 5, 13); public static DateTime The14th => new DateTime(DateTime.Now.Year, 5, 14); public static DateTime The15th => new DateTime(DateTime.Now.Year, 5, 15); public static DateTime The16th => new DateTime(DateTime.Now.Year, 5, 16); public static DateTime The17th => new DateTime(DateTime.Now.Year, 5, 17); public static DateTime The18th => new DateTime(DateTime.Now.Year, 5, 18); public static DateTime The19th => new DateTime(DateTime.Now.Year, 5, 19); public static DateTime The20th => new DateTime(DateTime.Now.Year, 5, 20); public static DateTime The21st => new DateTime(DateTime.Now.Year, 5, 21); public static DateTime The22nd => new DateTime(DateTime.Now.Year, 5, 22); public static DateTime The23rd => new DateTime(DateTime.Now.Year, 5, 23); public static DateTime The24th => new DateTime(DateTime.Now.Year, 5, 24); public static DateTime The25th => new DateTime(DateTime.Now.Year, 5, 25); public static DateTime The26th => new DateTime(DateTime.Now.Year, 5, 26); public static DateTime The27th => new DateTime(DateTime.Now.Year, 5, 27); public static DateTime The28th => new DateTime(DateTime.Now.Year, 5, 28); public static DateTime The29th => new DateTime(DateTime.Now.Year, 5, 29); public static DateTime The30th => new DateTime(DateTime.Now.Year, 5, 30); public static DateTime The31st => new DateTime(DateTime.Now.Year, 5, 31); public static DateTime The(int dayNumber) { return new DateTime(DateTime.Now.Year, 5, dayNumber); } } public class June { public static DateTime The1st => new DateTime(DateTime.Now.Year, 6, 1); public static DateTime The2nd => new DateTime(DateTime.Now.Year, 6, 2); public static DateTime The3rd => new DateTime(DateTime.Now.Year, 6, 3); public static DateTime The4th => new DateTime(DateTime.Now.Year, 6, 4); public static DateTime The5th => new DateTime(DateTime.Now.Year, 6, 5); public static DateTime The6th => new DateTime(DateTime.Now.Year, 6, 6); public static DateTime The7th => new DateTime(DateTime.Now.Year, 6, 7); public static DateTime The8th => new DateTime(DateTime.Now.Year, 6, 8); public static DateTime The9th => new DateTime(DateTime.Now.Year, 6, 9); public static DateTime The10th => new DateTime(DateTime.Now.Year, 6, 10); public static DateTime The11th => new DateTime(DateTime.Now.Year, 6, 11); public static DateTime The12th => new DateTime(DateTime.Now.Year, 6, 12); public static DateTime The13th => new DateTime(DateTime.Now.Year, 6, 13); public static DateTime The14th => new DateTime(DateTime.Now.Year, 6, 14); public static DateTime The15th => new DateTime(DateTime.Now.Year, 6, 15); public static DateTime The16th => new DateTime(DateTime.Now.Year, 6, 16); public static DateTime The17th => new DateTime(DateTime.Now.Year, 6, 17); public static DateTime The18th => new DateTime(DateTime.Now.Year, 6, 18); public static DateTime The19th => new DateTime(DateTime.Now.Year, 6, 19); public static DateTime The20th => new DateTime(DateTime.Now.Year, 6, 20); public static DateTime The21st => new DateTime(DateTime.Now.Year, 6, 21); public static DateTime The22nd => new DateTime(DateTime.Now.Year, 6, 22); public static DateTime The23rd => new DateTime(DateTime.Now.Year, 6, 23); public static DateTime The24th => new DateTime(DateTime.Now.Year, 6, 24); public static DateTime The25th => new DateTime(DateTime.Now.Year, 6, 25); public static DateTime The26th => new DateTime(DateTime.Now.Year, 6, 26); public static DateTime The27th => new DateTime(DateTime.Now.Year, 6, 27); public static DateTime The28th => new DateTime(DateTime.Now.Year, 6, 28); public static DateTime The29th => new DateTime(DateTime.Now.Year, 6, 29); public static DateTime The30th => new DateTime(DateTime.Now.Year, 6, 30); public static DateTime The(int dayNumber) { return new DateTime(DateTime.Now.Year, 6, dayNumber); } } public class July { public static DateTime The1st => new DateTime(DateTime.Now.Year, 7, 1); public static DateTime The2nd => new DateTime(DateTime.Now.Year, 7, 2); public static DateTime The3rd => new DateTime(DateTime.Now.Year, 7, 3); public static DateTime The4th => new DateTime(DateTime.Now.Year, 7, 4); public static DateTime The5th => new DateTime(DateTime.Now.Year, 7, 5); public static DateTime The6th => new DateTime(DateTime.Now.Year, 7, 6); public static DateTime The7th => new DateTime(DateTime.Now.Year, 7, 7); public static DateTime The8th => new DateTime(DateTime.Now.Year, 7, 8); public static DateTime The9th => new DateTime(DateTime.Now.Year, 7, 9); public static DateTime The10th => new DateTime(DateTime.Now.Year, 7, 10); public static DateTime The11th => new DateTime(DateTime.Now.Year, 7, 11); public static DateTime The12th => new DateTime(DateTime.Now.Year, 7, 12); public static DateTime The13th => new DateTime(DateTime.Now.Year, 7, 13); public static DateTime The14th => new DateTime(DateTime.Now.Year, 7, 14); public static DateTime The15th => new DateTime(DateTime.Now.Year, 7, 15); public static DateTime The16th => new DateTime(DateTime.Now.Year, 7, 16); public static DateTime The17th => new DateTime(DateTime.Now.Year, 7, 17); public static DateTime The18th => new DateTime(DateTime.Now.Year, 7, 18); public static DateTime The19th => new DateTime(DateTime.Now.Year, 7, 19); public static DateTime The20th => new DateTime(DateTime.Now.Year, 7, 20); public static DateTime The21st => new DateTime(DateTime.Now.Year, 7, 21); public static DateTime The22nd => new DateTime(DateTime.Now.Year, 7, 22); public static DateTime The23rd => new DateTime(DateTime.Now.Year, 7, 23); public static DateTime The24th => new DateTime(DateTime.Now.Year, 7, 24); public static DateTime The25th => new DateTime(DateTime.Now.Year, 7, 25); public static DateTime The26th => new DateTime(DateTime.Now.Year, 7, 26); public static DateTime The27th => new DateTime(DateTime.Now.Year, 7, 27); public static DateTime The28th => new DateTime(DateTime.Now.Year, 7, 28); public static DateTime The29th => new DateTime(DateTime.Now.Year, 7, 29); public static DateTime The30th => new DateTime(DateTime.Now.Year, 7, 30); public static DateTime The31st => new DateTime(DateTime.Now.Year, 7, 31); public static DateTime The(int dayNumber) { return new DateTime(DateTime.Now.Year, 7, dayNumber); } } public class August { public static DateTime The1st => new DateTime(DateTime.Now.Year, 8, 1); public static DateTime The2nd => new DateTime(DateTime.Now.Year, 8, 2); public static DateTime The3rd => new DateTime(DateTime.Now.Year, 8, 3); public static DateTime The4th => new DateTime(DateTime.Now.Year, 8, 4); public static DateTime The5th => new DateTime(DateTime.Now.Year, 8, 5); public static DateTime The6th => new DateTime(DateTime.Now.Year, 8, 6); public static DateTime The7th => new DateTime(DateTime.Now.Year, 8, 7); public static DateTime The8th => new DateTime(DateTime.Now.Year, 8, 8); public static DateTime The9th => new DateTime(DateTime.Now.Year, 8, 9); public static DateTime The10th => new DateTime(DateTime.Now.Year, 8, 10); public static DateTime The11th => new DateTime(DateTime.Now.Year, 8, 11); public static DateTime The12th => new DateTime(DateTime.Now.Year, 8, 12); public static DateTime The13th => new DateTime(DateTime.Now.Year, 8, 13); public static DateTime The14th => new DateTime(DateTime.Now.Year, 8, 14); public static DateTime The15th => new DateTime(DateTime.Now.Year, 8, 15); public static DateTime The16th => new DateTime(DateTime.Now.Year, 8, 16); public static DateTime The17th => new DateTime(DateTime.Now.Year, 8, 17); public static DateTime The18th => new DateTime(DateTime.Now.Year, 8, 18); public static DateTime The19th => new DateTime(DateTime.Now.Year, 8, 19); public static DateTime The20th => new DateTime(DateTime.Now.Year, 8, 20); public static DateTime The21st => new DateTime(DateTime.Now.Year, 8, 21); public static DateTime The22nd => new DateTime(DateTime.Now.Year, 8, 22); public static DateTime The23rd => new DateTime(DateTime.Now.Year, 8, 23); public static DateTime The24th => new DateTime(DateTime.Now.Year, 8, 24); public static DateTime The25th => new DateTime(DateTime.Now.Year, 8, 25); public static DateTime The26th => new DateTime(DateTime.Now.Year, 8, 26); public static DateTime The27th => new DateTime(DateTime.Now.Year, 8, 27); public static DateTime The28th => new DateTime(DateTime.Now.Year, 8, 28); public static DateTime The29th => new DateTime(DateTime.Now.Year, 8, 29); public static DateTime The30th => new DateTime(DateTime.Now.Year, 8, 30); public static DateTime The31st => new DateTime(DateTime.Now.Year, 8, 31); public static DateTime The(int dayNumber) { return new DateTime(DateTime.Now.Year, 8, dayNumber); } } public class September { public static DateTime The1st => new DateTime(DateTime.Now.Year, 9, 1); public static DateTime The2nd => new DateTime(DateTime.Now.Year, 9, 2); public static DateTime The3rd => new DateTime(DateTime.Now.Year, 9, 3); public static DateTime The4th => new DateTime(DateTime.Now.Year, 9, 4); public static DateTime The5th => new DateTime(DateTime.Now.Year, 9, 5); public static DateTime The6th => new DateTime(DateTime.Now.Year, 9, 6); public static DateTime The7th => new DateTime(DateTime.Now.Year, 9, 7); public static DateTime The8th => new DateTime(DateTime.Now.Year, 9, 8); public static DateTime The9th => new DateTime(DateTime.Now.Year, 9, 9); public static DateTime The10th => new DateTime(DateTime.Now.Year, 9, 10); public static DateTime The11th => new DateTime(DateTime.Now.Year, 9, 11); public static DateTime The12th => new DateTime(DateTime.Now.Year, 9, 12); public static DateTime The13th => new DateTime(DateTime.Now.Year, 9, 13); public static DateTime The14th => new DateTime(DateTime.Now.Year, 9, 14); public static DateTime The15th => new DateTime(DateTime.Now.Year, 9, 15); public static DateTime The16th => new DateTime(DateTime.Now.Year, 9, 16); public static DateTime The17th => new DateTime(DateTime.Now.Year, 9, 17); public static DateTime The18th => new DateTime(DateTime.Now.Year, 9, 18); public static DateTime The19th => new DateTime(DateTime.Now.Year, 9, 19); public static DateTime The20th => new DateTime(DateTime.Now.Year, 9, 20); public static DateTime The21st => new DateTime(DateTime.Now.Year, 9, 21); public static DateTime The22nd => new DateTime(DateTime.Now.Year, 9, 22); public static DateTime The23rd => new DateTime(DateTime.Now.Year, 9, 23); public static DateTime The24th => new DateTime(DateTime.Now.Year, 9, 24); public static DateTime The25th => new DateTime(DateTime.Now.Year, 9, 25); public static DateTime The26th => new DateTime(DateTime.Now.Year, 9, 26); public static DateTime The27th => new DateTime(DateTime.Now.Year, 9, 27); public static DateTime The28th => new DateTime(DateTime.Now.Year, 9, 28); public static DateTime The29th => new DateTime(DateTime.Now.Year, 9, 29); public static DateTime The30th => new DateTime(DateTime.Now.Year, 9, 30); public static DateTime The(int dayNumber) { return new DateTime(DateTime.Now.Year, 9, dayNumber); } } public class October { public static DateTime The1st => new DateTime(DateTime.Now.Year, 10, 1); public static DateTime The2nd => new DateTime(DateTime.Now.Year, 10, 2); public static DateTime The3rd => new DateTime(DateTime.Now.Year, 10, 3); public static DateTime The4th => new DateTime(DateTime.Now.Year, 10, 4); public static DateTime The5th => new DateTime(DateTime.Now.Year, 10, 5); public static DateTime The6th => new DateTime(DateTime.Now.Year, 10, 6); public static DateTime The7th => new DateTime(DateTime.Now.Year, 10, 7); public static DateTime The8th => new DateTime(DateTime.Now.Year, 10, 8); public static DateTime The9th => new DateTime(DateTime.Now.Year, 10, 9); public static DateTime The10th => new DateTime(DateTime.Now.Year, 10, 10); public static DateTime The11th => new DateTime(DateTime.Now.Year, 10, 11); public static DateTime The12th => new DateTime(DateTime.Now.Year, 10, 12); public static DateTime The13th => new DateTime(DateTime.Now.Year, 10, 13); public static DateTime The14th => new DateTime(DateTime.Now.Year, 10, 14); public static DateTime The15th => new DateTime(DateTime.Now.Year, 10, 15); public static DateTime The16th => new DateTime(DateTime.Now.Year, 10, 16); public static DateTime The17th => new DateTime(DateTime.Now.Year, 10, 17); public static DateTime The18th => new DateTime(DateTime.Now.Year, 10, 18); public static DateTime The19th => new DateTime(DateTime.Now.Year, 10, 19); public static DateTime The20th => new DateTime(DateTime.Now.Year, 10, 20); public static DateTime The21st => new DateTime(DateTime.Now.Year, 10, 21); public static DateTime The22nd => new DateTime(DateTime.Now.Year, 10, 22); public static DateTime The23rd => new DateTime(DateTime.Now.Year, 10, 23); public static DateTime The24th => new DateTime(DateTime.Now.Year, 10, 24); public static DateTime The25th => new DateTime(DateTime.Now.Year, 10, 25); public static DateTime The26th => new DateTime(DateTime.Now.Year, 10, 26); public static DateTime The27th => new DateTime(DateTime.Now.Year, 10, 27); public static DateTime The28th => new DateTime(DateTime.Now.Year, 10, 28); public static DateTime The29th => new DateTime(DateTime.Now.Year, 10, 29); public static DateTime The30th => new DateTime(DateTime.Now.Year, 10, 30); public static DateTime The31st => new DateTime(DateTime.Now.Year, 10, 31); public static DateTime The(int dayNumber) { return new DateTime(DateTime.Now.Year, 10, dayNumber); } } public class November { public static DateTime The1st => new DateTime(DateTime.Now.Year, 11, 1); public static DateTime The2nd => new DateTime(DateTime.Now.Year, 11, 2); public static DateTime The3rd => new DateTime(DateTime.Now.Year, 11, 3); public static DateTime The4th => new DateTime(DateTime.Now.Year, 11, 4); public static DateTime The5th => new DateTime(DateTime.Now.Year, 11, 5); public static DateTime The6th => new DateTime(DateTime.Now.Year, 11, 6); public static DateTime The7th => new DateTime(DateTime.Now.Year, 11, 7); public static DateTime The8th => new DateTime(DateTime.Now.Year, 11, 8); public static DateTime The9th => new DateTime(DateTime.Now.Year, 11, 9); public static DateTime The10th => new DateTime(DateTime.Now.Year, 11, 10); public static DateTime The11th => new DateTime(DateTime.Now.Year, 11, 11); public static DateTime The12th => new DateTime(DateTime.Now.Year, 11, 12); public static DateTime The13th => new DateTime(DateTime.Now.Year, 11, 13); public static DateTime The14th => new DateTime(DateTime.Now.Year, 11, 14); public static DateTime The15th => new DateTime(DateTime.Now.Year, 11, 15); public static DateTime The16th => new DateTime(DateTime.Now.Year, 11, 16); public static DateTime The17th => new DateTime(DateTime.Now.Year, 11, 17); public static DateTime The18th => new DateTime(DateTime.Now.Year, 11, 18); public static DateTime The19th => new DateTime(DateTime.Now.Year, 11, 19); public static DateTime The20th => new DateTime(DateTime.Now.Year, 11, 20); public static DateTime The21st => new DateTime(DateTime.Now.Year, 11, 21); public static DateTime The22nd => new DateTime(DateTime.Now.Year, 11, 22); public static DateTime The23rd => new DateTime(DateTime.Now.Year, 11, 23); public static DateTime The24th => new DateTime(DateTime.Now.Year, 11, 24); public static DateTime The25th => new DateTime(DateTime.Now.Year, 11, 25); public static DateTime The26th => new DateTime(DateTime.Now.Year, 11, 26); public static DateTime The27th => new DateTime(DateTime.Now.Year, 11, 27); public static DateTime The28th => new DateTime(DateTime.Now.Year, 11, 28); public static DateTime The29th => new DateTime(DateTime.Now.Year, 11, 29); public static DateTime The30th => new DateTime(DateTime.Now.Year, 11, 30); public static DateTime The(int dayNumber) { return new DateTime(DateTime.Now.Year, 11, dayNumber); } } public class December { public static DateTime The1st => new DateTime(DateTime.Now.Year, 12, 1); public static DateTime The2nd => new DateTime(DateTime.Now.Year, 12, 2); public static DateTime The3rd => new DateTime(DateTime.Now.Year, 12, 3); public static DateTime The4th => new DateTime(DateTime.Now.Year, 12, 4); public static DateTime The5th => new DateTime(DateTime.Now.Year, 12, 5); public static DateTime The6th => new DateTime(DateTime.Now.Year, 12, 6); public static DateTime The7th => new DateTime(DateTime.Now.Year, 12, 7); public static DateTime The8th => new DateTime(DateTime.Now.Year, 12, 8); public static DateTime The9th => new DateTime(DateTime.Now.Year, 12, 9); public static DateTime The10th => new DateTime(DateTime.Now.Year, 12, 10); public static DateTime The11th => new DateTime(DateTime.Now.Year, 12, 11); public static DateTime The12th => new DateTime(DateTime.Now.Year, 12, 12); public static DateTime The13th => new DateTime(DateTime.Now.Year, 12, 13); public static DateTime The14th => new DateTime(DateTime.Now.Year, 12, 14); public static DateTime The15th => new DateTime(DateTime.Now.Year, 12, 15); public static DateTime The16th => new DateTime(DateTime.Now.Year, 12, 16); public static DateTime The17th => new DateTime(DateTime.Now.Year, 12, 17); public static DateTime The18th => new DateTime(DateTime.Now.Year, 12, 18); public static DateTime The19th => new DateTime(DateTime.Now.Year, 12, 19); public static DateTime The20th => new DateTime(DateTime.Now.Year, 12, 20); public static DateTime The21st => new DateTime(DateTime.Now.Year, 12, 21); public static DateTime The22nd => new DateTime(DateTime.Now.Year, 12, 22); public static DateTime The23rd => new DateTime(DateTime.Now.Year, 12, 23); public static DateTime The24th => new DateTime(DateTime.Now.Year, 12, 24); public static DateTime The25th => new DateTime(DateTime.Now.Year, 12, 25); public static DateTime The26th => new DateTime(DateTime.Now.Year, 12, 26); public static DateTime The27th => new DateTime(DateTime.Now.Year, 12, 27); public static DateTime The28th => new DateTime(DateTime.Now.Year, 12, 28); public static DateTime The29th => new DateTime(DateTime.Now.Year, 12, 29); public static DateTime The30th => new DateTime(DateTime.Now.Year, 12, 30); public static DateTime The31st => new DateTime(DateTime.Now.Year, 12, 31); public static DateTime The(int dayNumber) { return new DateTime(DateTime.Now.Year, 12, dayNumber); } } } public static class PrepositionsExtensions { public static DateTime At(this DateTime date, int hour, int min = 0, int second = 0, int millisecond = 0) { return new DateTime(date.Year, date.Month, date.Day, hour, min, second, millisecond); } public static DateTime AtMidnight(this DateTime date) { return date.At(0); } public static DateTime AtNoon(this DateTime date) { return date.At(12); } public static DateTime In(this DateTime date, int year) { return new DateTime(year, date.Month, date.Day, date.Hour, date.Minute, date.Second, date.Millisecond); } } public enum GrammaticalCase { Nominative, Genitive, Dative, Accusative, Instrumental, Prepositional } public enum GrammaticalGender { Masculine, Feminine, Neuter } public enum HeadingStyle { Abbreviated, Full } public static class HeadingExtensions { internal static readonly string[] headings = new string[16] { "N", "NNE", "NE", "ENE", "E", "ESE", "SE", "SSE", "S", "SSW", "SW", "WSW", "W", "WNW", "NW", "NNW" }; internal static readonly char[] headingArrows = new char[8] { '↑', '↗', '→', '↘', '↓', '↙', '←', '↖' }; public static string ToHeading(this double heading, HeadingStyle style = HeadingStyle.Abbreviated, CultureInfo culture = null) { int num = (int)(heading / 22.5 + 0.5); string text = headings[num % 16]; if (style == HeadingStyle.Abbreviated) { return Resources.GetResource(text + "_Short", culture); } return Resources.GetResource(text, culture); } public static char ToHeadingArrow(this double heading) { int num = (int)(heading / 45.0 + 0.5); return headingArrows[num % 8]; } public static double FromAbbreviatedHeading(this string heading) { return heading.FromAbbreviatedHeading(null); } public static double FromAbbreviatedHeading(this string heading, CultureInfo culture = null) { if (heading == null) { throw new ArgumentNullException("heading"); } if (culture == null) { culture = CultureInfo.CurrentCulture; } string @string = culture.TextInfo.ToUpper(heading); for (int i = 0; i < headings.Length; i++) { string resource = Resources.GetResource(headings[i] + "_Short", culture); if (culture.CompareInfo.Compare(@string, resource) == 0) { return (double)i * 22.5; } } return -1.0; } public static double FromHeadingArrow(this char heading) { int num = Array.IndexOf(headingArrows, heading); if (num == -1) { return -1.0; } return (double)num * 45.0; } public static double FromHeadingArrow(this string heading) { if (heading == null) { throw new ArgumentNullException("heading"); } if (heading.Length != 1) { return -1.0; } return heading[0].FromHeadingArrow(); } } public static class InflectorExtensions { public static string Pluralize(this string word, bool inputIsKnownToBeSingular = true) { return Vocabularies.Default.Pluralize(word, inputIsKnownToBeSingular); } public static string Singularize(this string word, bool inputIsKnownToBePlural = true, bool skipSimpleWords = false) { return Vocabularies.Default.Singularize(word, inputIsKnownToBePlural, skipSimpleWords); } public static string Titleize(this string input) { return input.Humanize(LetterCasing.Title); } public static string Pascalize(this string input) { return Regex.Replace(input, "(?:^|_| +)(.)", (Match match) => match.Groups[1].Value.ToUpper()); } public static string Camelize(this string input) { string text = input.Pascalize(); if (text.Length <= 0) { return text; } return text.Substring(0, 1).ToLower() + text.Substring(1); } public static string Underscore(this string input) { return Regex.Replace(Regex.Replace(Regex.Replace(input, "([\\p{Lu}]+)([\\p{Lu}][\\p{Ll}])", "$1_$2"), "([\\p{Ll}\\d])([\\p{Lu}])", "$1_$2"), "[-\\s]", "_").ToLower(); } public static string Dasherize(this string underscoredWord) { return underscoredWord.Replace('_', '-'); } public static string Hyphenate(this string underscoredWord) { return underscoredWord.Dasherize(); } public static string Kebaberize(this string input) { return input.Underscore().Dasherize(); } } public enum LetterCasing { Title, AllCaps, LowerCase, Sentence } public static class MetricNumeralExtensions { private struct UnitPrefix { private readonly string _longScaleWord; public string Name { get; } public string ShortScaleWord { get; } public string LongScaleWord => _longScaleWord ?? ShortScaleWord; public UnitPrefix(string name, string shortScaleWord, string longScaleWord = null) { Name = name; ShortScaleWord = shortScaleWord; _longScaleWord = longScaleWord; } } private static readonly double BigLimit; private static readonly double SmallLimit; private static readonly List<char>[] Symbols; private static readonly Dictionary<char, UnitPrefix> UnitPrefixes; static MetricNumeralExtensions() { Symbols = new List<char>[2] { new List<char> { 'k', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y' }, new List<char> { 'm', 'μ', 'n', 'p', 'f', 'a', 'z', 'y' } }; UnitPrefixes = new Dictionary<char, UnitPrefix> { { 'Y', new UnitPrefix("yotta", "septillion", "quadrillion") }, { 'Z', new UnitPrefix("zetta", "sextillion", "trilliard") }, { 'E', new UnitPrefix("exa", "quintillion", "trillion") }, { 'P', new UnitPrefix("peta", "quadrillion", "billiard") }, { 'T', new UnitPrefix("tera", "trillion", "billion") }, { 'G', new UnitPrefix("giga", "billion", "milliard") }, { 'M', new UnitPrefix("mega", "million") }, { 'k', new UnitPrefix("kilo", "thousand") }, { 'm', new UnitPrefix("milli", "thousandth") }, { 'μ', new UnitPrefix("micro", "millionth") }, { 'n', new UnitPrefix("nano", "billionth", "milliardth") }, { 'p', new UnitPrefix("pico", "trillionth", "billionth") }, { 'f', new UnitPrefix("femto", "quadrillionth", "billiardth") }, { 'a', new UnitPrefix("atto", "quintillionth", "trillionth") }, { 'z', new UnitPrefix("zepto", "sextillionth", "trilliardth") }, { 'y', new UnitPrefix("yocto", "septillionth", "quadrillionth") } }; BigLimit = Math.Pow(10.0, 27.0); SmallLimit = Math.Pow(10.0, -27.0); } public static double FromMetric(this string input) { input = CleanRepresentation(input); return BuildNumber(input, input[input.Length - 1]); } [Obsolete("Please use overload with MetricNumeralFormats")] public static string ToMetric(this int input, bool hasSpace, bool useSymbol = true, int? decimals = null) { return ((double)input).ToMetric(hasSpace, useSymbol, decimals); } public static string ToMetric(this int input, MetricNumeralFormats? formats = null, int? decimals = null) { return ((double)input).ToMetric(formats, decimals); } [Obsolete("Please use overload with MetricNumeralFormats")] public static string ToMetric(this double input, bool hasSpace, bool useSymbol = true, int? decimals = null) { MetricNumeralFormats? metricNumeralFormats = null; if (hasSpace) { metricNumeralFormats = MetricNumeralFormats.WithSpace; } if (!useSymbol) { metricNumeralFormats = ((!metricNumeralFormats.HasValue) ? new MetricNumeralFormats?(MetricNumeralFormats.UseName) : (metricNumeralFormats | MetricNumeralFormats.UseName)); } return input.ToMetric(metricNumeralFormats, decimals); } public static string ToMetric(this double input, MetricNumeralFormats? formats = null, int? decimals = null) { if (input.Equals(0.0)) { return input.ToString(); } if (input.IsOutOfRange()) { throw new ArgumentOutOfRangeException("input"); } return BuildRepresentation(input, formats, decimals); } private static string CleanRepresentation(string input) { if (input == null) { throw new ArgumentNullException("input"); } input = input.Trim(); input = ReplaceNameBySymbol(input); if (input.Length == 0 || input.IsInvalidMetricNumeral()) { throw new ArgumentException("Empty or invalid Metric string.", "input"); } return input.Replace(" ", string.Empty); } private static double BuildNumber(string input, char last) { if (!char.IsLetter(last)) { return double.Parse(input); } return BuildMetricNumber(input, last); } private static double BuildMetricNumber(string input, char last) { double num = double.Parse(input.Remove(input.Length - 1)); double num2 = Math.Pow(10.0, Symbols[0].Contains(last) ? getExponent(Symbols[0]) : (0.0 - getExponent(Symbols[1]))); return num * num2; double getExponent(List<char> symbols) { return (symbols.IndexOf(last) + 1) * 3; } } private static string ReplaceNameBySymbol(string input) { return UnitPrefixes.Aggregate(input, (string current, KeyValuePair<char, UnitPrefix> unitPrefix) => current.Replace(unitPrefix.Value.Name, unitPrefix.Key.ToString())); } private static string BuildRepresentation(double input, MetricNumeralFormats? formats, int? decimals) { int exponent = (int)Math.Floor(Math.Log10(Math.Abs(input)) / 3.0); if (!exponent.Equals(0)) { return BuildMetricRepresentation(input, exponent, formats, decimals); } string text = (decimals.HasValue ? Math.Round(input, decimals.Value).ToString() : input.ToString()); if (((uint?)formats & 8u) == 8) { text += " "; } return text; } private static string BuildMetricRepresentation(double input, int exponent, MetricNumeralFormats? formats, int? decimals) { double value = input * Math.Pow(1000.0, -exponent); if (decimals.HasValue) { value = Math.Round(value, decimals.Value); } char symbol = ((Math.Sign(exponent) == 1) ? Symbols[0][exponent - 1] : Symbols[1][-exponent - 1]); return value.ToString("G15") + ((formats.HasValue && formats.Value.HasFlag(MetricNumeralFormats.WithSpace)) ? " " : string.Empty) + GetUnitText(symbol, formats); } private static string GetUnitText(char symbol, MetricNumeralFormats? formats) { if (formats.HasValue && formats.Value.HasFlag(MetricNumeralFormats.UseName)) { return UnitPrefixes[symbol].Name; } if (formats.HasValue && formats.Value.HasFlag(MetricNumeralFormats.UseShortScaleWord)) { return UnitPrefixes[symbol].ShortScaleWord; } if (formats.HasValue && formats.Value.HasFlag(MetricNumeralFormats.UseLongScaleWord)) { return UnitPrefixes[symbol].LongScaleWord; } return symbol.ToString(); } private static bool IsOutOfRange(this double input) { if (Math.Sign(input) != 1 || !outside(SmallLimit, BigLimit)) { if (Math.Sign(input) == -1) { return outside(0.0 - BigLimit, 0.0 - SmallLimit); } return false; } return true; bool outside(double min, double max) { if (max > input) { return !(input > min); } return true; } } private static bool IsInvalidMetricNumeral(this string input) { int num = input.Length - 1; char item = input[num]; double result; return !double.TryParse((Symbols[0].Contains(item) || Symbols[1].Contains(item)) ? input.Remove(num) : input, out result); } } [Flags] public enum MetricNumeralFormats { UseLongScaleWord = 1, UseName = 2, UseShortScaleWord = 4, WithSpace = 8 } public class NoMatchFoundException : Exception { public NoMatchFoundException() { } public NoMatchFoundException(string message) : base(message) { } public NoMatchFoundException(string message, Exception inner) : base(message, inner) { } } public static class NumberToNumberExtensions { [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Tens(this int input) { return input * 10; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static uint Tens(this uint input) { return input * 10; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static long Tens(this long input) { return input * 10; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ulong Tens(this ulong input) { return input * 10; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static double Tens(this double input) { return input * 10.0; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Hundreds(this int input) { return input * 100; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static uint Hundreds(this uint input) { return input * 100; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static long Hundreds(this long input) { return input * 100; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ulong Hundreds(this ulong input) { return input * 100; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static double Hundreds(this double input) { return input * 100.0; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Thousands(this int input) { return input * 1000; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static uint Thousands(this uint input) { return input * 1000; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static long Thousands(this long input) { return input * 1000; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ulong Thousands(this ulong input) { return input * 1000; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static double Thousands(this double input) { return input * 1000.0; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Millions(this int input) { return input * 1000000; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static uint Millions(this uint input) { return input * 1000000; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static long Millions(this long input) { return input * 1000000; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ulong Millions(this ulong input) { return input * 1000000; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static double Millions(this double input) { return input * 1000000.0; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static int Billions(this int input) { return input * 1000000000; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static uint Billions(this uint input) { return input * 1000000000; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static long Billions(this long input) { return input * 1000000000; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static ulong Billions(this ulong input) { return input * 1000000000; } [MethodImpl(MethodImplOptions.AggressiveInlining)] public static double Billions(this double input) { return input * 1000000000.0; } } public static class NumberToTimeSpanExtensions { public static TimeSpan Milliseconds(this byte ms) { return ((double)(int)ms).Milliseconds(); } public static TimeSpan Milliseconds(this sbyte ms) { return ((double)ms).Milliseconds(); } public static TimeSpan Milliseconds(this short ms) { return ((double)ms).Milliseconds(); } public static TimeSpan Milliseconds(this ushort ms) { return ((double)(int)ms).Milliseconds(); } public static TimeSpan Milliseconds(this int ms) { return ((double)ms).Milliseconds(); } public static TimeSpan Milliseconds(this uint ms) { return ((double)ms).Milliseconds(); } public static TimeSpan Milliseconds(this long ms) { return ((double)ms).Milliseconds(); } public static TimeSpan Milliseconds(this ulong ms) { return ((double)ms).Milliseconds(); } public static TimeSpan Milliseconds(this double ms) { return TimeSpan.FromMilliseconds(ms); } public static TimeSpan Seconds(this byte seconds) { return ((double)(int)seconds).Seconds(); } public static TimeSpan Seconds(this sbyte seconds) { return ((double)seconds).Seconds(); } public static TimeSpan Seconds(this short seconds) { return ((double)seconds).Seconds(); } public static TimeSpan Seconds(this ushort seconds) { return ((double)(int)seconds).Seconds(); } public static TimeSpan Seconds(this int seconds) { return ((double)seconds).Seconds(); } public static TimeSpan Seconds(this uint seconds) { return ((double)seconds).Seconds(); } public static TimeSpan Seconds(this long seconds) { return ((double)seconds).Seconds(); } public static TimeSpan Seconds(this ulong seconds) { return ((double)seconds).Seconds(); } public static TimeSpan Seconds(this double seconds) { return TimeSpan.FromSeconds(seconds); } public static TimeSpan Minutes(this byte minutes) { return ((double)(int)minutes).Minutes(); } public static TimeSpan Minutes(this sbyte minutes) { return ((double)minutes).Minutes(); } public static TimeSpan Minutes(this short minutes) { return ((double)minutes).Minutes(); } public static TimeSpan Minutes(this ushort minutes) { return ((double)(int)minutes).Minutes(); } public static TimeSpan Minutes(this int minutes) { return ((double)minutes).Minutes(); } public static TimeSpan Minutes(this uint minutes) { return ((double)minutes).Minutes(); } public static TimeSpan Minutes(this long minutes) { return ((double)minutes).Minutes(); } public static TimeSpan Minutes(this ulong minutes) { return ((double)minutes).Minutes(); } public static TimeSpan Minutes(this double minutes) { return TimeSpan.FromMinutes(minutes); } public static TimeSpan Hours(this byte hours) { return ((double)(int)hours).Hours(); } public static TimeSpan Hours(this sbyte hours) { return ((double)hours).Hours(); } public static TimeSpan Hours(this short hours) { return ((double)hours).Hours(); } public static TimeSpan Hours(this ushort hours) { return ((double)(int)hours).Hours(); } public static TimeSpan Hours(this int hours) { return ((double)hours).Hours(); } public static TimeSpan Hours(this uint hours) { return ((double)hours).Hours(); } public static TimeSpan Hours(this long hours) { return ((double)hours).Hours(); } public static TimeSpan Hours(this ulong hours) { return ((double)hours).Hours(); } public static TimeSpan Hours(this double hours) { return TimeSpan.FromHours(hours); } public static TimeSpan Days(this byte days) { return ((double)(int)days).Days(); } public static TimeSpan Days(this sbyte days) { return ((double)days).Days(); } public static TimeSpan Days(this short days) { return ((double)days).Days(); } public static TimeSpan Days(this ushort days) { return ((double)(int)days).Days(); } public static TimeSpan Days(this int days) { return ((double)days).Days(); } public static TimeSpan Days(this uint days) { return ((double)days).Days(); } public static TimeSpan Days(this long days) { return ((double)days).Days(); } public static TimeSpan Days(this ulong days) { return ((double)days).Days(); } public static TimeSpan Days(this double days) { return TimeSpan.FromDays(days); } public static TimeSpan Weeks(this byte input) { return ((double)(int)input).Weeks(); } public static TimeSpan Weeks(this sbyte input) { return ((double)input).Weeks(); } public static TimeSpan Weeks(this short input) { return ((double)input).Weeks(); } public static TimeSpan Weeks(this ushort input) { return ((double)(int)input).Weeks(); } public static TimeSpan Weeks(this int input) { return ((double)input).Weeks(); } public static TimeSpan Weeks(this uint input) { return ((double)input).Weeks(); } public static TimeSpan Weeks(this long input) { return ((double)input).Weeks(); } public static TimeSpan Weeks(this ulong input) { return ((double)input).Weeks(); } public static TimeSpan Weeks(this double input) { return (7.0 * input).Days(); } } public static class NumberToWordsExtension { public static string ToOrdinalWords(this int number, CultureInfo culture = null) { return Configurator.GetNumberToWordsConverter(culture).ConvertToOrdinal(number); } public static string ToOrdinalWords(this int number, WordForm wordForm, CultureInfo culture = null) { return Configurator.GetNumberToWordsConverter(culture).ConvertToOrdinal(number, wordForm); } public static string ToOrdinalWords(this int number, GrammaticalGender gender, CultureInfo culture = null) { return Configurator.GetNumberToWordsConverter(culture).ConvertToOrdinal(number, gender); } public static string ToOrdinalWords(this int number, GrammaticalGender gender, WordForm wordForm, CultureInfo culture = null) { return Configurator.GetNumberToWordsConverter(culture).ConvertToOrdinal(number, gender, wordForm); } public static string ToTuple(this int number, CultureInfo culture = null) { return Configurator.GetNumberToWordsConverter(culture).ConvertToTuple(number); } public static string ToWords(this int number, CultureInfo culture = null) { return ToWords(number, culture, addAnd: true); } public static string ToWords(this int number, WordForm wordForm, CultureInfo culture = null) { return ToWords(number, wordForm, culture, addAnd: false); } public static string ToWords(this int number, bool addAnd, CultureInfo culture = null) { return ToWords(number, culture, addAnd); } public static string ToWords(this int number, bool addAnd, WordForm wordForm, CultureInfo culture = null) { return ToWords(number, wordForm, culture, addAnd); } public static string ToWords(this int number, GrammaticalGender gender, CultureInfo culture = null) { return ((long)number).ToWords(gender, culture); } public static string ToWords(this int number, WordForm wordForm, GrammaticalGender gender, CultureInfo culture = null) { return ((long)number).ToWords(wordForm, gender, culture); } public static string ToWords(this long number, CultureInfo culture = null, bool addAnd = true) { return Configurator.GetNumberToWordsConverter(culture).Convert(number, addAnd); } public static string ToWords(this long number, WordForm wordForm, CultureInfo culture = null, bool addAnd = false) { return Configurator.GetNumberToWordsConverter(culture).Convert(number, addAnd, wordForm); } public static string ToWords(this long number, GrammaticalGender gender, CultureInfo culture = null) { return Configurator.GetNumberToWordsConverter(culture).Convert(number, gender); } public static string ToWords(this long number, WordForm wordForm, GrammaticalGender gender, CultureInfo culture = null) { return Configurator.GetNumberToWordsConverter(culture).Convert(number, wordForm, gender); } } public enum OnNoMatch { ThrowsException, ReturnsNull } public static class OrdinalizeExtensions { public static string Ordinalize(this string numberString) { return Configurator.Ordinalizer.Convert(int.Parse(numberString), numberString); } public static string Ordinalize(this string numberString, WordForm wordForm) { return Configurator.Ordinalizer.Convert(int.Parse(numberString), numberString, wordForm); } public static string Ordinalize(this string numberString, CultureInfo culture) { return Configurator.Ordinalizers.ResolveForCulture(culture).Convert(int.Parse(numberString, culture), numberString); } public static string Ordinalize(this string numberString, CultureInfo culture, WordForm wordForm) { return Configurator.Ordinalizers.ResolveForCulture(culture).Convert(int.Parse(numberString, culture), numberString, wordForm); } public static string Ordinalize(this string numberString, GrammaticalGender gender) { return Configurator.Ordinalizer.Convert(int.Parse(numberString), numberString, gender); } public static string Ordinalize(this string numberString, GrammaticalGender gender, WordForm wordForm) { return Configurator.Ordinalizer.Convert(int.Parse(numberString), numberString, gender, wordForm); } public static string Ordinalize(this string numberString, GrammaticalGender gender, CultureInfo culture) { return Configurator.Ordinalizers.ResolveForCulture(culture).Convert(int.Parse(numberString, culture), numberString, gender); } public static string Ordinalize(this string numberString, GrammaticalGender gender, CultureInfo culture, WordForm wordForm) { return Configurator.Ordinalizers.ResolveForCulture(culture).Convert(int.Parse(numberString, culture), numberString, gender, wordForm); } public static string Ordinalize(this int number) { return Configurator.Ordinalizer.Convert(number, number.ToString(CultureInfo.InvariantCulture)); } public static string Ordinalize(this int number, WordForm wordForm) { return Configurator.Ordinalizer.Convert(number, number.ToString(CultureInfo.InvariantCulture), wordForm); } public static string Ordinalize(this int number, CultureInfo culture) { return Configurator.Ordinalizers.ResolveForCulture(culture).Convert(number, number.ToString(culture)); } public static string Ordinalize(this int number, CultureInfo culture, WordForm wordForm) { return Configurator.Ordinalizers.ResolveForCulture(culture).Convert(number, number.ToString(culture), wordForm); } public static string Ordinalize(this int number, GrammaticalGender gender) { return Configurator.Ordinalizer.Convert(number, number.ToString(CultureInfo.InvariantCulture), gender); } public static string Ordinalize(this int number, GrammaticalGender gender, WordForm wordForm) { return Configurator.Ordinalizer.Convert(number, number.ToString(CultureInfo.InvariantCulture), gender, wordForm); } public static string Ordinalize(this int number, GrammaticalGender gender, CultureInfo culture) { return Configurator.Ordinalizers.ResolveForCulture(culture).Convert(number, number.ToString(culture), gender); } public static string Ordinalize(this int number, GrammaticalGender gender, CultureInfo culture, WordForm wordForm) { return Configurator.Ordinalizers.ResolveForCulture(culture).Convert(number, number.ToString(culture), gender, wordForm); } } public enum Plurality { Singular, Plural, CouldBeEither } internal static class RegexOptionsUtil { public static RegexOptions Compiled { get; } static RegexOptionsUtil() { Compiled = (Enum.TryParse<RegexOptions>("Compiled", out var result) ? result : RegexOptions.None); } } public static class RomanNumeralExtensions { private const int NumberOfRomanNumeralMaps = 13; private static readonly IDictionary<string, int> RomanNumerals = new Dictionary<string, int>(13) { { "M", 1000 }, { "CM", 900 }, { "D", 500 }, { "CD", 400 }, { "C", 100 }, { "XC", 90 }, { "L", 50 }, { "XL", 40 }, { "X", 10 }, { "IX", 9 }, { "V", 5 }, { "IV", 4 }, { "I", 1 } }; private static readonly Regex ValidRomanNumeral = new Regex("^(?i:(?=[MDCLXVI])((M{0,3})((C[DM])|(D?C{0,3}))?((X[LC])|(L?XX{0,2})|L)?((I[VX])|(V?(II{0,2}))|V)?))$", RegexOptionsUtil.Compiled); public static int FromRoman(this string input) { if (input == null) { throw new ArgumentNullException("input"); } input = input.Trim().ToUpperInvariant(); int length = input.Length; if (length == 0 || IsInvalidRomanNumeral(input)) { throw new ArgumentException("Empty or invalid Roman numeral string.", "input"); } int num = 0; int num2 = length; while (num2 > 0) { int num3 = RomanNumerals[input[--num2].ToString()]; if (num2 > 0) { int num4 = RomanNumerals[input[num2 - 1].ToString()]; if (num4 < num3) { num3 -= num4; num2--; } } num += num3; } return num; } public static string ToRoman(this int input) { if (input < 1 || input > 3999) { throw new ArgumentOutOfRangeException(); } StringBuilder stringBuilder = new StringBuilder(15); foreach (KeyValuePair<string, int> romanNumeral in RomanNumerals) { while (input / romanNumeral.Value > 0) { stringBuilder.Append(romanNumeral.Key); input -= romanNumeral.Value; } } return stringBuilder.ToString(); } private static bool IsInvalidRomanNumeral(string input) { return !ValidRomanNumeral.IsMatch(input); } } public static class StringDehumanizeExtensions { public static string Dehumanize(this string input) { IEnumerable<string> values = from word in input.Split(new char[1] { ' ' }) select word.Humanize().Pascalize(); return string.Join("", values).Replace(" ", ""); } } public static class StringExtensions { public static string FormatWith(this string format, params object[] args) { return string.Format(format, args); } public static string FormatWith(this string format, IFormatProvider provider, params object[] args) { return string.Format(provider, format, args); } } public static class StringHumanizeExtensions { private static readonly Regex PascalCaseWordPartsRegex; private static readonly Regex FreestandingSpacingCharRegex; static StringHumanizeExtensions() { PascalCaseWordPartsRegex = new Regex("[\\p{Lu}]?[\\p{Ll}]+|[0-9]+[\\p{Ll}]*|[\\p{Lu}]+(?=[\\p{Lu}][\\p{Ll}]|[0-9]|\\b)|[\\p{Lo}]+", RegexOptions.ExplicitCapture | RegexOptions.IgnorePatternWhitespace | RegexOptionsUtil.Compiled); FreestandingSpacingCharRegex = new Regex("\\s[-_]|[-_]\\s", RegexOptionsUtil.Compiled); } private static string FromUnderscoreDashSeparatedWords(string input) { return string.Join(" ", input.Split('_', '-')); } private static string FromPascalCase(string input) { string text = string.Join(" ", from Match match in PascalCaseWordPartsRegex.Matches(input) select (!match.Value.ToCharArray().All(char.IsUpper) || (match.Value.Length <= 1 && (match.Index <= 0 || input[match.Index - 1] != ' ') && !(match.Value == "I"))) ? match.Value.ToLower() : match.Value); if (text.Replace(" ", "").ToCharArray().All((char c) => char.IsUpper(c)) && text.Contains(" ")) { text = text.ToLower(); } if (text.Length <= 0) { return text; } return char.ToUpper(text[0]) + text.Substring(1, text.Length - 1); } public static string Humanize(this string input) { if (input.ToCharArray().All(char.IsUpper)) { return input; } if (FreestandingSpacingCharRegex.IsMatch(input)) { return FromPascalCase(FromUnderscoreDashSeparatedWords(input)); } if (input.Contains("_") || input.Contains("-")) { return FromUnderscoreDashSeparatedWords(input); } return FromPascalCase(input); } public static string Humanize(this string input, LetterCasing casing) { return input.Humanize().ApplyCase(casing); } } public static class TimeSpanHumanizeExtensions { private const int _daysInAWeek = 7; private const double _daysInAYear = 365.2425; private const double _daysInAMonth = 30.436875; public static string Humanize(this TimeSpan timeSpan, int precision = 1, CultureInfo culture = null, TimeUnit maxUnit = TimeUnit.Week, TimeUnit minUnit = TimeUnit.Millisecond, string collectionSeparator = ", ", bool toWords = false) { return timeSpan.Humanize(precision, countEmptyUnits: false, culture, maxUnit, minUnit, collectionSeparator, toWords); } public static string Humanize(this TimeSpan timeSpan, int precision, bool countEmptyUnits, CultureInfo culture = null, TimeUnit maxUnit = TimeUnit.Week, TimeUnit minUnit = TimeUnit.Millisecond, string collectionSeparator = ", ", bool toWords = false) { return ConcatenateTimeSpanParts(SetPrecisionOfTimeSpan(CreateTheTimePartsWithUpperAndLowerLimits(timeSpan, culture, maxUnit, minUnit, toWords), precision, countEmptyUnits), culture, collectionSeparator); } private static IEnumerable<string> CreateTheTimePartsWithUpperAndLowerLimits(TimeSpan timespan, CultureInfo culture, TimeUnit maxUnit, TimeUnit minUnit, bool toWords = false) { IFormatter formatter = Configurator.GetFormatter(culture); bool flag = false; IEnumerable<TimeUnit> enumTypesForTimeUnit = GetEnumTypesForTimeUnit(); List<string> list = new List<string>(); foreach (TimeUnit item in enumTypesForTimeUnit) { string timeUnitPart = GetTimeUnitPart(item, timespan, maxUnit, minUnit, formatter, toWords); if (timeUnitPart != null || flag) { flag = true; list.Add(timeUnitPart); } } if (IsContainingOnlyNullValue(list)) { list = CreateTimePartsWithNoTimeValue(toWords ? formatter.TimeSpanHumanize_Zero() : formatter.TimeSpanHumanize(minUnit, 0, toWords)); } return list; } private static IEnumerable<TimeUnit> GetEnumTypesForTimeUnit() { return ((IEnumerable<TimeUnit>)Enum.GetValues(typeof(TimeUnit))).Reverse(); } private static string GetTimeUnitPart(TimeUnit timeUnitToGet, TimeSpan timespan, TimeUnit maximumTimeUnit, TimeUnit minimumTimeUnit, IFormatter cultureFormatter, bool toWords = false) { if (timeUnitToGet <= maximumTimeUnit && timeUnitToGet >= minimumTimeUnit) { int timeUnitNumericalValue = GetTimeUnitNumericalValue(timeUnitToGet, timespan, maximumTimeUnit); return BuildFormatTimePart(cultureFormatter, timeUnitToGet, timeUnitNumericalValue, toWords); } return null; } private static int GetTimeUnitNumericalValue(TimeUnit timeUnitToGet, TimeSpan timespan, TimeUnit maximumTimeUnit) { bool isTimeUnitToGetTheMaximumTimeUnit = timeUnitToGet == maximumTimeUnit; return timeUnitToGet switch { TimeUnit.Millisecond => GetNormalCaseTimeAsInteger(timespan.Milliseconds, timespan.TotalMilliseconds, isTimeUnitToGetTheMaximumTimeUnit), TimeUnit.Second => GetNormalCaseTimeAsInteger(timespan.Seconds, timespan.TotalSeconds, isTimeUnitToGetTheMaximumTimeUnit), TimeUnit.Minute => GetNormalCaseTimeAsInteger(timespan.Minutes, timespan.TotalMinutes, isTimeUnitToGetTheMaximumTimeUnit), TimeUnit.Hour => GetNormalCaseTimeAsInteger(timespan.Hours, timespan.TotalHours, isTimeUnitToGetTheMaximumTimeUnit), TimeUnit.Day => GetSpecialCaseDaysAsInteger(timespan, maximumTimeUnit), TimeUnit.Week => GetSpecialCaseWeeksAsInteger(timespan, isTimeUnitToGetTheMaximumTimeUnit), TimeUnit.Month => GetSpecialCaseMonthAsInteger(timespan, isTimeUnitToGetTheMaximumTimeUnit), TimeUnit.Year => GetSpecialCaseYearAsInteger(timespan), _ => 0, }; } private static int GetSpecialCaseMonthAsInteger(TimeSpan timespan, bool isTimeUnitToGetTheMaximumTimeUnit) { if (isTimeUnitToGetTheMaximumTimeUnit) { return (int)((double)timespan.Days / 30.436875); } return (int)((double)timespan.Days % 365.2425 / 30.436875); } private static int GetSpecialCaseYearAsInteger(TimeSpan timespan) { return (int)((double)timespan.Days / 365.2425); } private static int GetSpecialCaseWeeksAsInteger(TimeSpan timespan, bool isTimeUnitToGetTheMaximumTimeUnit) { if (isTimeUnitToGetTheMaximumTimeUnit || (double)timespan.Days < 30.436875) { return timespan.Days / 7; } return 0; } private static int GetSpecialCaseDaysAsInteger(TimeSpan timespan, TimeUnit maximumTimeUnit) { if (maximumTimeUnit == TimeUnit.Day) { return timespan.Days; } if ((double)timespan.Days < 30.436875 || maximumTimeUnit == TimeUnit.Week) { return timespan.Days % 7; } return (int)((double)timespan.Days % 30.436875); } private static int GetNormalCaseTimeAsInteger(int timeNumberOfUnits, double totalTimeNumberOfUnits, bool isTimeUnitToGetTheMaximumTimeUnit) { if (isTimeUnitToGetTheMaximumTimeUnit) { try { return (int)totalTimeNumberOfUnits; } catch { return 0; } } return timeNumberOfUnits; } private static string BuildFormatTimePart(IFormatter cultureFormatter, TimeUnit timeUnitType, int amountOfTimeUnits, bool toWords = false) { if (amountOfTimeUnits == 0) { return null; } return cultureFormatter.TimeSpanHumanize(timeUnitType, Math.Abs(amountOfTimeUnits), toWords); } private static List<string> CreateTimePartsWithNoTimeValue(string noTimeValue) { return new List<string> { noTimeValue }; } private static bool IsContainingOnlyNullValue(IEnumerable<string> timeParts) { return timeParts.Count((string x) => x != null) == 0; } private static IEnumerable<string> SetPrecisionOfTimeSpan(IEnumerable<string> timeParts, int precision, bool countEmptyUnits) { if (!countEmptyUnits) { timeParts = timeParts.Where((string x) => x != null); } timeParts = timeParts.Take(precision); if (countEmptyUnits) { timeParts = timeParts.Where((string x) => x != null); } return timeParts; } private static string ConcatenateTimeSpanParts(IEnumerable<string> timeSpanParts, CultureInfo culture, string collectionSeparator) { if (collectionSeparator == null) { return Configurator.CollectionFormatters.ResolveForCulture(culture).Humanize(timeSpanParts); } return string.Join(collectionSeparator, timeSpanParts); } } public static class TimeUnitToSymbolExtensions { public static string ToSymbol(this TimeUnit unit, CultureInfo culture = null) { return Configurator.GetFormatter(culture).TimeUnitHumanize(unit); } } public enum ShowQuantityAs { None, Numeric, Words } public static class ToQuantityExtensions { public static string ToQuantity(this string input, int quantity, ShowQuantityAs showQuantityAs = ShowQuantityAs.Numeric) { return input.ToQuantity(quantity, showQuantityAs, null, null); } public static string ToQuantity(this string input, int quantity, string format, IFormatProvider formatProvider = null) { return input.ToQuantity(quantity, ShowQuantityAs.Numeric, format, formatProvider); } public static string ToQuantity(this string input, long quantity, ShowQuantityAs showQuantityAs = ShowQuantityAs.Numeric) { return input.ToQuantity(quantity, showQuantityAs, null, null); } public static string ToQuantity(this string input, long qu
plugins/ULTRAKIT.Data.dll
Decompiled 8 months agousing System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using UnityEngine; using UnityEngine.AddressableAssets; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ULTRAKIT.Data")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("HP Inc.")] [assembly: AssemblyProduct("ULTRAKIT.Data")] [assembly: AssemblyCopyright("Copyright © HP Inc. 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("cef77a9b-383b-4080-aece-6b92dc5bf990")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace ULTRAKIT.Data; public class Glow : MonoBehaviour { public Color glowColor; public float glowIntensity; } public class Arm : ScriptableObject { public string id; public string Name; public GameObject Prefab; public Sprite Icon; public bool Unlocked = true; [HideInInspector] public string modName; } public class AssetBundleData : ScriptableObject { } public class HatRegistry : ScriptableObject { public string hatID; public Hat[] hats; [HideInInspector] public Dictionary<EnemyType, Hat> hatDict; } public class Hat : ScriptableObject { public GameObject obj; public Vector3 position_offset; public Vector3 rotation_offset; public Vector3 scale_offset; public EnemyType enemyType; } public class UKSpawnable : ScriptableObject { public SpawnableObjectDataType type; public string identifier; public GameObject prefab; public Sprite icon; } public class Weapon : ScriptableObject { public string id; public string[] Names; [HideInInspector] public GameObject[] All_Variants; public GameObject[] Variants; public GameObject[] AltVariants; public Sprite[] Icons; public bool Unlocked = true; [HideInInspector] public int[] equipOrder; [HideInInspector] public int[] equipStatus; [HideInInspector] public string modName; } public class ReplacementWeapon : ScriptableObject { public GameObject Prefab; public WeaponType WeaponType; [Range(0f, 2f)] public int Variant; public bool Alt; [HideInInspector] public string modName; } public enum WeaponType { Revolver, Shotgun, Nailgun, Railcannon, RocketLauncher } public class UKAsset : AssetReference { private Object _asset; public override Object Asset => _asset; public UKAsset(Object asset) { _asset = asset; } }
plugins/ULTRAKIT.dll
Decompiled 8 months agousing System; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using GameConsole; using ULTRAKIT.Core.Cheats; using ULTRAKIT.Core.Commands; using ULTRAKIT.Extensions; using ULTRAKIT.Extensions.Data; using ULTRAKIT.Loader; using ULTRAKIT.Loader.Loaders; using ULTRAKIT.Properties; using UnityEngine; using UnityEngine.SceneManagement; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ULTRAKIT")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("HP Inc.")] [assembly: AssemblyProduct("ULTRAKIT")] [assembly: AssemblyCopyright("Copyright © HP Inc. 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("da42fe3a-4e5b-4191-bdc2-cc62c2d04f63")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace ULTRAKIT.Properties { [GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")] [DebuggerNonUserCode] [CompilerGenerated] internal class Resources { private static ResourceManager resourceMan; private static CultureInfo resourceCulture; [EditorBrowsable(EditorBrowsableState.Advanced)] internal static ResourceManager ResourceManager { get { if (resourceMan == null) { ResourceManager resourceManager = new ResourceManager("ULTRAKIT.Properties.Resources", typeof(Resources).Assembly); resourceMan = resourceManager; } return resourceMan; } } [EditorBrowsable(EditorBrowsableState.Advanced)] internal static CultureInfo Culture { get { return resourceCulture; } set { resourceCulture = value; } } internal static byte[] cameye_jpg { get { object @object = ResourceManager.GetObject("cameye_jpg", resourceCulture); return (byte[])@object; } } internal static byte[] d_drone_jpg { get { object @object = ResourceManager.GetObject("d_drone_jpg", resourceCulture); return (byte[])@object; } } internal static byte[] fpeye_jpg { get { object @object = ResourceManager.GetObject("fpeye_jpg", resourceCulture); return (byte[])@object; } } internal static byte[] fpface_jpg { get { object @object = ResourceManager.GetObject("fpface_jpg", resourceCulture); return (byte[])@object; } } internal static byte[] levi_jpg { get { object @object = ResourceManager.GetObject("levi_jpg", resourceCulture); return (byte[])@object; } } internal static byte[] minos_jpg { get { object @object = ResourceManager.GetObject("minos_jpg", resourceCulture); return (byte[])@object; } } internal static string rlocation_1 => ResourceManager.GetString("rlocation_1", resourceCulture); internal static byte[] ultrakit_tophat { get { object @object = ResourceManager.GetObject("ultrakit_tophat", resourceCulture); return (byte[])@object; } } internal static byte[] wicked_jpg { get { object @object = ResourceManager.GetObject("wicked_jpg", resourceCulture); return (byte[])@object; } } internal Resources() { } } } namespace ULTRAKIT.Core { internal class Initializer { public static void Init() { SetSpawnerSprites(); ((MonoBehaviour)Plugin.plugin).StartCoroutine(InitializeComponents()); } public static IEnumerator InitializeComponents() { while ((Object)(object)MonoSingleton<AssetHelper>.Instance == (Object)null) { yield return (object)new WaitForSeconds(0.5f); } Initializer.Initialize(Resources.rlocation_1); Initializer.Initialize(); LoadCommands(); LoadHats(); SceneManager.sceneLoaded += OnSceneLoaded; SceneManager.sceneUnloaded += OnSceneUnloaded; yield return null; } private unsafe static void OnSceneLoaded(Scene scene, LoadSceneMode mode) { LoadCheats(); Plugin.Invoke(new Action(MonoSingleton<GunSetter>.Instance, (nint)(delegate*<GunSetter, void>)(&GunSetterExtension.RefreshWeapons)), 0.05f); } private static void OnSceneUnloaded(Scene scene) { if (!HatLoader.Persistent) { Registries.hat_activeHats.Clear(); HatLoader.SetSeasonals(); } } private static void SetSpawnerSprites() { Sprite value = GraphicsUtilities.CreateSprite(Resources.fpeye_jpg, 128, 128); Sprite value2 = GraphicsUtilities.CreateSprite(Resources.fpface_jpg, 128, 128); Sprite value3 = GraphicsUtilities.CreateSprite(Resources.levi_jpg, 128, 128); Sprite value4 = GraphicsUtilities.CreateSprite(Resources.minos_jpg, 128, 128); Sprite value5 = GraphicsUtilities.CreateSprite(Resources.wicked_jpg, 128, 128); Sprite value6 = GraphicsUtilities.CreateSprite(Resources.d_drone_jpg, 128, 128); Sprite value7 = GraphicsUtilities.CreateSprite(Resources.cameye_jpg, 128, 128); Registries.spawn_sprites.Add("DroneFlesh", value); Registries.spawn_sprites.Add("DroneSkull Variant", value2); Registries.spawn_sprites.Add("MinosBoss", value4); Registries.spawn_sprites.Add("Wicked", value5); Registries.spawn_sprites.Add("Leviathan", value3); Registries.spawn_sprites.Add("Drone Variant", value6); Registries.spawn_sprites.Add("DroneFleshCamera Variant", value7); } private static void LoadHats() { AssetBundle val = AssetBundle.LoadFromMemory(Resources.ultrakit_tophat); HatLoader.LoadHats(val); } private static void LoadCheats() { if (Object.op_Implicit((Object)(object)MonoSingleton<CheatsManager>.Instance)) { MonoSingleton<CheatsManager>.Instance.RegisterCheat((ICheat)(object)new Refresher(), "ULTRAKIT"); MonoSingleton<CheatsManager>.Instance.RegisterCheat((ICheat)(object)new ActivateHats(), "ULTRAKIT"); } } private static void LoadCommands() { MonoSingleton<Console>.Instance.RegisterCommand((ICommand)(object)new AltSetter()); } } [BepInPlugin("ULTRAKIT.core_module", "ULTRAKIT Reloaded", "2.3.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public static Plugin plugin; public static bool isUMM; public static bool isWaffle; private void Awake() { ConfigData.config = ((BaseUnityPlugin)this).Config; ConfigData.LoadConfig(); plugin = this; Registries.Invoke = Invoke; foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos) { if (pluginInfo.Value.Metadata.GUID == "UMM") { isUMM = true; Initializer.isUMMInstalled = true; } if (pluginInfo.Value.Metadata.GUID == "waffle.ultrakill.extraalts") { isWaffle = true; Initializer.isWaffle = true; } } Initializer.Init(); } private static void OnApplicationQuit() { SaveData.Save(); PlayerPrefs.SetInt("CurSlo", 1); } public static void Invoke(Action func, float delay) { ((MonoBehaviour)plugin).StartCoroutine(Delay()); IEnumerator Delay() { yield return (object)new WaitForSeconds(delay); func(); } } } } namespace ULTRAKIT.Core.Commands { public class AltSetter : ICommand { private string[] weaponNames = new string[15] { "rev0", "rev1", "rev2", "sho0", "sho1", "sho2", "nai0", "nai1", "nai2", "rai0", "rai1", "rai2", "rock0", "rock1", "rock2" }; public string Name => "Set Weapon Alt"; public string Description => "Sets a weapon to either normal or alternate variants."; public string Command => "setalt"; public void Execute(Console con, string[] args) { if (args.Length < 2) { con.PrintLine("Usage: setalt <weapon> <equipStatus>"); return; } if (!weaponNames.Contains(args[0])) { con.PrintLine("Invalid weapon name. Valid names are:"); string[] array = weaponNames; foreach (string text in array) { con.PrintLine(text); } return; } int num = Convert.ToInt32(args[1]); if (num != 0 && num != 1 && num != 2) { con.PrintLine("Invalid weapon state. Valids states are: [0, 1, 2]"); return; } if (!MonoSingleton<PrefsManager>.Instance.prefMap.ContainsKey("weapon." + args[0])) { MonoSingleton<PrefsManager>.Instance.prefMap.Add("weapon." + args[0], num); } MonoSingleton<PrefsManager>.Instance.prefMap["weapon." + args[0]] = num; GunSetterExtension.RefreshWeapons(MonoSingleton<GunSetter>.Instance); } } } namespace ULTRAKIT.Core.Cheats { public class ActivateHats : ICheat { public string LongName => "Toggle Top Hats"; public string Identifier => "ULTRAKIT.toggle_hats"; public string ButtonEnabledOverride => "Hats Enabled"; public string ButtonDisabledOverride => "Hats Disabled"; public bool DefaultState => false; public bool IsActive => false; public string Icon => "warning"; public StatePersistenceMode PersistenceMode => (StatePersistenceMode)1; public void Enable() { HatLoader.SetAllActive("ultrakit.tophat", true); } public void Disable() { HatLoader.SetAllActive("ultrakit.tophat", false); } public void Update() { } } public class Refresher : ICheat { public string LongName => "Refresh Weapons"; public string Identifier => "ULTRAKIT.refresh_weapons"; public string ButtonEnabledOverride => "Refreshing"; public string ButtonDisabledOverride => "Refresh"; public bool DefaultState => false; public bool IsActive => false; public string Icon => "warning"; public StatePersistenceMode PersistenceMode => (StatePersistenceMode)0; public void Enable() { GunSetterExtension.RefreshWeapons(MonoSingleton<GunSetter>.Instance); Disable(); } public void Disable() { } public void Update() { } } }
plugins/ULTRAKIT.Editor.dll
Decompiled 8 months agousing System; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using ULTRAKIT.Data; using UnityEditor; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ULTRAKIT.Editor")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("HP Inc.")] [assembly: AssemblyProduct("ULTRAKIT.Editor")] [assembly: AssemblyCopyright("Copyright © HP Inc. 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("98797264-a4e1-45e2-ac4a-95bab64cba34")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace ULTRAKIT.EditorScripts; [CustomEditor(typeof(AssetBundleData))] public class AssetBundleEditor : Editor { private static string outputPath = ""; public override void OnInspectorGUI() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) Object target = ((Editor)this).target; AssetBundleData val = (AssetBundleData)(object)((target is AssetBundleData) ? target : null); string assetPath = AssetDatabase.GetAssetPath(((Object)val).GetInstanceID()); EditorGUILayout.LabelField("EXPORT", EditorStyles.boldLabel, Array.Empty<GUILayoutOption>()); EditorGUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); outputPath = EditorGUILayout.TextField(outputPath, Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Browse", Array.Empty<GUILayoutOption>())) { outputPath = EditorUtility.SaveFilePanel("Export AssetBundle", "Assets", "modAssets", "assetBundle"); } EditorGUILayout.EndHorizontal(); if (!GUILayout.Button("Export AssetBundle", Array.Empty<GUILayoutOption>())) { return; } if (outputPath == null || outputPath.Length == 0) { EditorUtility.DisplayDialog("Invalid Path", "Please choose a valid output directory", "OK"); return; } string implicitAssetBundleName = AssetDatabase.GetImplicitAssetBundleName(assetPath); if (!BuildAssetBundleByName(implicitAssetBundleName, outputPath)) { Debug.LogError((object)"AssetBundle export failed"); } } public static bool BuildAssetBundleByName(string name, string outputPath) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) if (File.Exists(outputPath) && !EditorUtility.DisplayDialog("Replace File", "File '" + Path.GetFileName(outputPath) + "' already exists. Would you like to replace it?", "Yes", "No")) { return false; } string text = "Assets/_tempexport"; if (Directory.Exists(text)) { Directory.Delete(text, recursive: true); } Directory.CreateDirectory(text); AssetBundleBuild val = default(AssetBundleBuild); val.assetBundleName = name; val.assetNames = AssetDatabase.GetAssetPathsFromAssetBundle(name); BuildPipeline.BuildAssetBundles(text, (AssetBundleBuild[])(object)new AssetBundleBuild[1] { val }, (BuildAssetBundleOptions)0, (BuildTarget)5); try { File.Copy(text + "/" + name, outputPath, overwrite: true); } catch (ArgumentException) { Debug.LogError((object)"AssetBundle has no name. Did you forget to assign one to the folder in the editor?"); return false; } Directory.Delete(text, recursive: true); if (outputPath.Contains("Assets/")) { AssetDatabase.Refresh(); } Debug.Log((object)("AssetBundle export successful at " + outputPath)); return true; } } public class SOMenuInjector { [MenuItem("Assets/ULTRAKIT/Exporter")] public static void NewAssetBundleData() { CreateObject<AssetBundleData>("Exporter"); } [MenuItem("Assets/ULTRAKIT/New Weapon")] public static void NewWeapon() { CreateObject<Weapon>("New_Weapon"); } [MenuItem("Assets/ULTRAKIT/New Vanilla Weapon")] public static void NewReplacementWeapon() { CreateObject<ReplacementWeapon>("New_Vanilla_Weapon"); } [MenuItem("Assets/ULTRAKIT/New Hat")] public static void NewHat() { CreateObject<Hat>("New_Hat"); } [MenuItem("Assets/ULTRAKIT/New Hat Registry")] public static void NewHatRegistry() { CreateObject<HatRegistry>("New_Hat_Registry"); } [MenuItem("Assets/ULTRAKIT/New Spawnable")] public static void NewSpawnable() { CreateObject<UKSpawnable>("New_Spawnable"); } private static void CreateObject<T>(string name) where T : ScriptableObject { T val = ScriptableObject.CreateInstance<T>(); string assetPath = AssetDatabase.GetAssetPath(Selection.activeObject); string text = AssetDatabase.GenerateUniqueAssetPath(assetPath + "\\" + name + ".asset"); AssetDatabase.CreateAsset((Object)(object)val, text); AssetDatabase.Refresh(); Selection.activeObject = (Object)(object)val; } }
plugins/ULTRAKIT.Extensions.dll
Decompiled 8 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx.Configuration; using HarmonyLib; using Humanizer; using Newtonsoft.Json; using ULTRAKIT.Data; using ULTRAKIT.Extensions.Classes; using ULTRAKIT.Extensions.Interfaces; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Events; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ULTRAKIT.Extensions")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("HP Inc.")] [assembly: AssemblyProduct("ULTRAKIT.Extensions")] [assembly: AssemblyCopyright("Copyright © HP Inc. 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("456a436c-031e-495d-9c2e-350694b6e3c9")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace ULTRAKIT.Extensions { public static class Events { public static CheatStateChangedEvent CheatStateChanged { get; set; } public static EnemySpawnedEvent EnemySpawned { get; set; } public static EnemyDiedEvent EnemyDied { get; set; } public static UnityEvent ArenaActivated { get; set; } public static UnityEvent ArenaCompleted { get; set; } } [Serializable] public class CheatStateChangedEvent : UnityEvent<string> { } [Serializable] public class EnemySpawnedEvent : UnityEvent<EnemyIdentifier> { } [Serializable] public class EnemyDiedEvent : UnityEvent<EnemyIdentifier> { } public static class AssetLoader { public static Dictionary<string, string> ShortToFullAssets = new Dictionary<string, string>(); internal static void Init(string unparsedAssetData) { string[] source = unparsedAssetData.Split(new string[1] { "=================================" }, StringSplitOptions.None); source = (from s in source.Skip(1) select s.Split(new char[1] { '\n' })[1]).ToArray(); source = source.Select((string s) => s.Substring(6)).ToArray(); string[] array = source; foreach (string text in array) { string key = text.Split(new char[1] { '/' }).Last(); if (!ShortToFullAssets.ContainsKey(key)) { ShortToFullAssets.Add(key, text); } } } public static T[] GetAll<T>(IEnumerable<object> allAssets) { return (T[])allAssets.Where((object k) => k is T).ToArray().Cast<T>(); } public static T AssetFind<T>(string name) where T : Object { Object val = LoadAsset(name); if (val == (Object)null) { UKLogger.LogError("Failed to load asset " + name); return default(T); } T val2 = (T)(object)((val is T) ? val : null); if (val2 == null) { UKLogger.LogError($"Asset {name} is not a(n) {typeof(T)}"); return default(T); } return val2; } internal static Object LoadAsset(string name) { //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) if (ShortToFullAssets.ContainsKey(name)) { name = ShortToFullAssets[name]; } Object val = Addressables.LoadAssetAsync<Object>((object)name).WaitForCompletion(); if (val == (Object)null) { UKLogger.LogWarning("Asset " + name + " not found"); } return val; } } public static class ComponentExt { public static IEnumerable<T> GetComponentsInArray<T>(this Component[] source) where T : Component { List<T> list = new List<T>(); T item = default(T); foreach (Component val in source) { if (val.TryGetComponent<T>(ref item)) { list.Add(item); } } return list; } public static IEnumerable<T> GetAllComponentsInArray<T>(this Component[] source, bool searchInactive) where T : Component { List<T> list = new List<T>(); foreach (Component val in source) { T[] componentsInChildren = val.GetComponentsInChildren<T>(searchInactive); if (componentsInChildren.Length != 0) { list.AddRange(componentsInChildren); } } return list; } public static IEnumerable<Transform> ListChildren(this Component parent) { List<Transform> list = new List<Transform>(); list.AddRange(parent.GetComponentsInChildren<Transform>(true)); list.Remove(parent.transform); return list; } public static Transform FindInChildren(this Component parent, string name) { Transform[] componentsInChildren = parent.GetComponentsInChildren<Transform>(); foreach (Transform val in componentsInChildren) { if (((Object)val).name == name) { return val; } } UKLogger.LogWarning("Could not find child " + name); return null; } } public static class EnumerableExt { public static int FindIndexOf<T>(this IEnumerable<T> source, T obj) { int result = 0; for (int i = 0; i < source.Count(); i++) { if (source.ElementAt(i).Equals(obj)) { result = i; break; } } return result; } public static int[] FindIdexesOf<T>(this IEnumerable<T> source, T obj) { List<int> list = new List<int>(); for (int i = 0; i < source.Count(); i++) { if (source.ElementAt(i).Equals(obj)) { list.Add(i); } } return list?.ToArray() ?? new int[0]; } public static void RemoveRange<T>(this List<T> list, IEnumerable<T> range) { foreach (T item in range) { list.Remove(item); } } public static void ReplaceOrAddTo<T>(this List<T> list, T item, int index) { while (index >= list.Count) { list.Add(default(T)); } list[index] = item; } } public static class GraphicsUtilities { public static Sprite CreateSprite(byte[] bytes, int width, int height) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_0020: 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) Texture2D val = new Texture2D(width, height); ImageConversion.LoadImage(val, bytes); return Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2((float)(width / 2), (float)(height / 2))); } public static void RenderObject<T>(this T obj, LayerMask layer) where T : Component { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = ((Component)obj).GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { ((Component)val).gameObject.layer = LayerMask.op_Implicit(layer); Glow component = ((Component)val).gameObject.GetComponent<Glow>(); if (Object.op_Implicit((Object)(object)component)) { val.material.shader = Shader.Find("psx/railgun"); val.material.SetFloat("_EmissivePosition", 5f); val.material.SetFloat("_EmissiveStrength", component.glowIntensity); val.material.SetColor("_EmissiveColor", component.glowColor); } else { val.material.shader = Shader.Find(((Object)val.material.shader).name); } } } public static string BonePath(int start, int end) { string text = string.Empty; for (int i = start; i <= end; i++) { text = text + "Bone" + ((i < 100) ? ("0" + i) : i.ToString()); text += "/"; } return text.Substring(0, text.Length - 1); } } public class Initializer { public static void Initialize(string assetFileData) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown CreateEvents(); AssetLoader.Init(assetFileData); Harmony val = new Harmony("ULTRAKIT.Extensions"); val.PatchAll(); } private static void CreateEvents() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown Events.CheatStateChanged = new CheatStateChangedEvent(); Events.EnemySpawned = new EnemySpawnedEvent(); Events.EnemyDied = new EnemyDiedEvent(); Events.ArenaActivated = new UnityEvent(); Events.ArenaCompleted = new UnityEvent(); } } public static class UKLogger { private static int counter; public static void Log(object obj) { string name = Assembly.GetCallingAssembly().GetName().Name; Debug.Log((object)$"[{name}] {obj}"); } public static void LogWarning(object obj) { string name = Assembly.GetCallingAssembly().GetName().Name; Debug.LogWarning((object)$"[{name}] {obj}"); } public static void LogError(object obj) { string name = Assembly.GetCallingAssembly().GetName().Name; Debug.LogError((object)$"[{name}] {obj}"); } public static void LogCounter() { string name = Assembly.GetCallingAssembly().GetName().Name; Debug.LogError((object)$"[{name}] {counter}"); counter++; } } public static class GunSetterExtension { public static void RefreshWeapons(this GunSetter gs) { try { int currentSlot = gs.gunc.currentSlot; int currentVariation = gs.gunc.currentVariation; gs.ResetWeapons(false); gs.gunc.currentSlot = currentSlot; gs.gunc.currentVariation = currentVariation; gs.gunc.YesWeapon(); } catch { } } } public static class CheatsManagerExtension { public static void PrintCheatIDs(this CheatsManager manager) { foreach (KeyValuePair<string, ICheat> item in manager.GetFieldValue<Dictionary<string, ICheat>>("idToCheat", isPrivate: true)) { Debug.Log((object)item.Key); } } public static bool SetCheatState(this CheatsManager manager, string id, bool enabled) { Dictionary<string, ICheat> fieldValue = manager.GetFieldValue<Dictionary<string, ICheat>>("idToCheat", isPrivate: true); if (fieldValue.ContainsKey(id)) { manager.WrappedSetState(fieldValue[id], enabled); manager.UpdateCheatState(fieldValue[id]); return true; } Debug.LogWarning((object)("Could not find cheat with id: '" + id + "'")); return false; } } public static class ReflectionExt { public static void SetFieldValue(this object obj, string name, object value, bool isPrivate = false) { if (isPrivate) { obj.GetType().GetField(name, BindingFlags.Instance | BindingFlags.NonPublic).SetValue(obj, value); } else { obj.GetType().GetField(name).SetValue(obj, value); } } public static T GetFieldValue<T>(this object obj, string name, bool isPrivate = false) { if (isPrivate) { return (T)obj.GetType().GetField(name, BindingFlags.Instance | BindingFlags.NonPublic).GetValue(obj); } return (T)obj.GetType().GetField(name).GetValue(obj); } public static void SetPropertyValue(this object obj, string name, object value, bool isPrivate = false) { if (isPrivate) { obj.GetType().GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic).SetValue(obj, value); } else { obj.GetType().GetProperty(name).SetValue(obj, value); } } public static T GetPropertyValue<T>(this object obj, string name, bool isPrivate = false) { if (isPrivate) { return (T)obj.GetType().GetProperty(name, BindingFlags.Instance | BindingFlags.NonPublic).GetValue(obj); } return (T)obj.GetType().GetProperty(name).GetValue(obj); } public static FieldInfo[] GetFieldInfos(this object obj) { List<FieldInfo> list = new List<FieldInfo>(); Type type = obj.GetType(); list.AddRange(type.GetFields()); list.AddRange(type.GetFields(BindingFlags.Instance | BindingFlags.NonPublic)); return list.ToArray(); } public static PropertyInfo[] GetPropertyInfos(this object obj) { List<PropertyInfo> list = new List<PropertyInfo>(); Type type = obj.GetType(); list.AddRange(type.GetProperties()); list.AddRange(type.GetProperties(BindingFlags.Instance | BindingFlags.NonPublic)); return list.ToArray(); } public static Type GetInternalType(string name) { Type type = typeof(GunControl).Assembly.GetType(name); if (type == null) { UKLogger.LogWarning("Could not find type " + name); } return type ?? null; } } } namespace ULTRAKIT.Extensions.Managers { public class BuffsManager : MonoBehaviour { public Dictionary<string, IBuff> buffs = new Dictionary<string, IBuff>(); public EnemyIdentifier eid; public void LoadBuffs(IBuff[] buffsToLoad) { foreach (IBuff buff in buffsToLoad) { buff.eid = eid; buffs.Add(buff.id, buff); } } public void SetBuffState(string id, bool active) { if (buffs.ContainsKey(id)) { if (active && !buffs[id].IsActive) { buffs[id].Enable(); } else if (!active && buffs[id].IsActive) { buffs[id].Disable(); } } } private void Update() { foreach (KeyValuePair<string, IBuff> buff in buffs) { if (buff.Value.IsActive) { buff.Value.Update(); } } } } public class HatsManager : MonoBehaviour { public Dictionary<string, GameObject> hats; private SeasonalHats sh; private void Awake() { if ((Object)(object)sh == (Object)null) { sh = ((Component)this).GetComponent<SeasonalHats>(); } hats = new Dictionary<string, GameObject>(); hats.Add("christmas", sh.GetFieldValue<GameObject>("christmas", isPrivate: true)); hats.Add("halloween", sh.GetFieldValue<GameObject>("halloween", isPrivate: true)); hats.Add("easter", sh.GetFieldValue<GameObject>("easter", isPrivate: true)); } public void LoadHat(HatRegistry registry) { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Invalid comparison between Unknown and I4 //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0172: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) Hat val = ScriptableObject.CreateInstance<Hat>(); try { Transform val2 = ((Component)this).transform; while ((Object)(object)((Component)val2).GetComponent<EnemyIdentifier>() == (Object)null && ((Component)val2).tag != "Player") { val2 = val2.parent; } if (((Component)val2).tag == "Player") { val = registry.hatDict[(EnemyType)8]; } else { EnemyType enemyType = ((Component)val2).GetComponentInChildren<EnemyIdentifier>().enemyType; val = registry.hatDict[enemyType]; if ((int)enemyType == 1 && ((Object)val2).name.Contains("Mandalore")) { val = registry.hatDict[(EnemyType)25]; } } if (((Object)((Component)this).transform.parent).name.Contains("Cancerous Rodent")) { val = registry.hatDict[(EnemyType)23]; } if (((Object)((Component)this).transform.parent).name.Contains("Very Cancerous Rodent")) { val = registry.hatDict[(EnemyType)24]; } } catch { return; } GameObject val3 = Object.Instantiate<GameObject>(val.obj, ((Component)this).gameObject.transform); val3.transform.localPosition = val.obj.transform.position + val.position_offset; val3.transform.localRotation = val.obj.transform.rotation * Quaternion.Euler(val.rotation_offset); val3.transform.localScale = val.obj.transform.localScale + val.scale_offset; val3.transform.RenderObject<Transform>(LayerMask.op_Implicit(LayerMask.NameToLayer("Limb"))); val3.SetActive(false); hats.Add(registry.hatID, val3); } public void SetHatActive(string hatID, bool active) { if (hats.ContainsKey(hatID)) { hats[hatID].SetActive(active); } } } } namespace ULTRAKIT.Extensions.Patches { [HarmonyPatch(typeof(ActivateArena))] public class ActivateArenaPatch { public static UnityEvent ArenaActivated { get { return Events.ArenaActivated; } set { Events.ArenaActivated = value; } } [HarmonyPatch("Activate")] [HarmonyPostfix] private static void ActivatePostfix() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown if (ArenaActivated == null) { ArenaActivated = new UnityEvent(); } ArenaActivated.Invoke(); } } [HarmonyPatch(typeof(ActivateNextWave))] public class ActivateNextWavePatch { public static UnityEvent ArenaCompleted { get { return Events.ArenaCompleted; } set { Events.ArenaCompleted = value; } } [HarmonyPatch("EndWaves")] [HarmonyPostfix] private static void EndWavesPostfix() { ArenaCompleted.Invoke(); } } [HarmonyPatch(typeof(ActivateNextWaveHP))] public class ActivateNextWaveHPPatch { public static UnityEvent ArenaCompleted { get { return Events.ArenaCompleted; } set { Events.ArenaCompleted = value; } } [HarmonyPatch("EndWaves")] [HarmonyPostfix] private static void EndWavesPostfix() { ArenaCompleted.Invoke(); } } [HarmonyPatch(typeof(CheatsManager))] public class CheatsManagerPatch { public static CheatStateChangedEvent CheatStateChanged { get { return Events.CheatStateChanged; } set { Events.CheatStateChanged = value; } } [HarmonyPatch("WrappedSetState")] [HarmonyPostfix] public static void Postfix(CheatsManager __instance, ICheat targetCheat) { ((UnityEvent<string>)CheatStateChanged).Invoke(targetCheat.Identifier); } } [HarmonyPatch(typeof(EnemyTracker))] public class EnemyTrackerPatch { public static EnemySpawnedEvent EnemySpawned { get { return Events.EnemySpawned; } set { Events.EnemySpawned = value; } } [HarmonyPatch("AddEnemy")] [HarmonyPostfix] private static void AddEnemyPostfix(EnemyTracker __instance, EnemyIdentifier eid) { ((UnityEvent<EnemyIdentifier>)EnemySpawned).Invoke(eid); } } [HarmonyPatch(typeof(EnemyIdentifier))] public class EnemyIdentifierPatch { public static EnemyDiedEvent EnemyDied { get { return Events.EnemyDied; } set { Events.EnemyDied = value; } } [HarmonyPatch("Death")] [HarmonyPostfix] private static void DeathPostfix(EnemyIdentifier __instance) { ((UnityEvent<EnemyIdentifier>)EnemyDied).Invoke(__instance); } } } namespace ULTRAKIT.Extensions.Classes { public class CustomHealthbarPos : MonoBehaviour { public float size = 0.1f; public Vector3 offset; public GameObject enemy; public GameObject barObj; public Camera playerCam; private void OnEnable() { //IL_000c: 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) barObj.transform.localScale = Vector3.one * size; playerCam = ((Component)MonoSingleton<CameraController>.Instance).GetComponent<Camera>(); } private void Update() { //IL_003a: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)enemy == (Object)null) { ((Behaviour)this).enabled = false; barObj.SetActive(false); return; } Vector3 val = enemy.transform.position + offset; Vector3 val2 = val - ((Component)playerCam).transform.position; Vector3 normalized = ((Vector3)(ref val2)).normalized; Vector3 val3 = playerCam.WorldToViewportPoint(val); bool active = Vector3.Dot(normalized, ((Component)playerCam).transform.forward) > 0f; barObj.SetActive(active); barObj.transform.position = new Vector3(val3.x * (float)Screen.width, val3.y * (float)Screen.height); } catch { } } } public class RenderFixer : MonoBehaviour { public string LayerName; public void Start() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) this.RenderObject<RenderFixer>(LayerMask.op_Implicit(LayerMask.NameToLayer(LayerName))); } } [Serializable] public class SettingChangedEvent : UnityEvent<UKSetting> { } [Serializable] public class UKSetting { [JsonProperty("OnValueChanged")] public SettingChangedEvent OnValueChanged = new SettingChangedEvent(); [JsonProperty("Section")] public string Section { get; internal set; } [JsonProperty("Heading")] public string Heading { get; internal set; } [JsonProperty("Name")] public string Name { get; internal set; } [JsonProperty("ID")] public string ID { get; internal set; } } public class UKCheckbox : UKSetting { [JsonProperty("ValueCheck")] public bool Value { get; internal set; } public UKCheckbox(string section, string heading, string name, string id, bool defaultValue) { base.Section = section; base.Heading = heading; base.Name = name; base.ID = id; Value = defaultValue; } public bool GetValue() { return Value; } public void SetValue(bool value) { Value = value; ((UnityEvent<UKSetting>)OnValueChanged).Invoke((UKSetting)this); } } public class UKPicker : UKSetting { [JsonProperty("ValuePick")] public int Value { get; internal set; } [JsonProperty("Options")] public string[] Options { get; internal set; } public UKPicker(string section, string heading, string name, string id, string[] options, int startingIndex) { base.Section = section; base.Heading = heading; base.Name = name; base.ID = id; Options = options; Value = startingIndex; } public int GetValue() { return Value; } public void SetValue(int value) { Value = value; ((UnityEvent<UKSetting>)OnValueChanged).Invoke((UKSetting)this); } } public class UKSlider : UKSetting { [JsonProperty("ValueSlide")] public float Value { get; internal set; } [JsonProperty("Range")] public Tuple<float, float> Range { get; internal set; } public UKSlider(string section, string heading, string name, string id, float min, float max, float defaultValue) { base.Section = section; base.Heading = heading; base.Name = name; base.ID = id; Range = new Tuple<float, float>(min, max); Value = defaultValue; } public float GetValue() { return Value; } public void SetValue(float value) { Value = value; ((UnityEvent<UKSetting>)OnValueChanged).Invoke((UKSetting)this); } } public class UKKeySetting : UKSetting { public KeyCode Key { get; internal set; } public BindingInfo Binding { get; internal set; } public UKKeySetting(string heading, string name, KeyCode defaultKey) { //IL_003c: 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_004f: Expected O, but got Unknown //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown //IL_0070: 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) base.Section = "Controls"; base.Heading = heading; base.Name = name; base.ID = "keybind." + StringDehumanizeExtensions.Dehumanize(name); Key = defaultKey; InputAction action = new InputAction(name, (InputActionType)1, (string)null, (string)null, (string)null, (string)null); BindingInfo val = new BindingInfo(); val.Action = action; val.Name = StringDehumanizeExtensions.Dehumanize(name); val.Offset = 0; val.DefaultKey = defaultKey; Binding = val; } public KeyCode GetValue() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) return Key; } public void SetValue(KeyCode key) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) Key = key; ((UnityEvent<UKSetting>)OnValueChanged).Invoke((UKSetting)this); } } public class Buff : IBuff { private bool active; public Action EnableScript; public Action DisableScript; public Action UpdateScript; public bool IsActive => active; public string id { get; set; } public EnemyIdentifier eid { get; set; } public void Enable() { active = true; EnableScript(); } public void Disable() { active = false; DisableScript(); } public void Update() { UpdateScript(); } } public class Cheat : ICheat { private static Cheat _lastInstance; private bool active; public Action EnableScript; public Action DisableScript; public Action UpdateScript; public static Cheat Instance => _lastInstance; public string LongName { get; set; } public string Identifier { get; set; } public string ButtonEnabledOverride { get; set; } public string ButtonDisabledOverride { get; set; } public string Icon => "warning"; public bool IsActive => active; public bool DefaultState { get; set; } public StatePersistenceMode PersistenceMode { get; set; } public void Enable() { active = true; _lastInstance = this; EnableScript(); } public void Disable() { active = false; DisableScript(); } public void Update() { UpdateScript(); } } } namespace ULTRAKIT.Extensions.Interfaces { public interface IBuff { string id { get; } EnemyIdentifier eid { get; set; } bool IsActive { get; } void Enable(); void Disable(); void Update(); } } namespace ULTRAKIT.Extensions.Data { public static class ConfigData { public static ConfigFile config; public static void LoadConfig() { } } public static class SaveData { private const string folderName = "data"; private static string dataFilePath = GetDataPath("save.ultradata"); private static PersistentData _data; public static PersistentData data { get { if (_data == null) { Load(); } return _data; } set { if (value != null && value != _data) { _data = value; Save(); } } } public static string GetDataPath(params string[] subpath) { string location = Assembly.GetExecutingAssembly().Location; location = Path.GetDirectoryName(location); string text = Path.Combine(location, "data"); if (subpath.Length != 0) { string path = Path.Combine(subpath); text = Path.Combine(text, path); } return text; } public static bool Internal_SetValue<TKey, TValue>(Dictionary<TKey, TValue> dict, TKey key, TValue value) { if (dict.ContainsKey(key)) { dict[key] = value; Save(); return true; } dict.Add(key, value); Save(); return false; } private static bool Internal_SetPrivateValue<TKey, TValue>(Dictionary<string, Dictionary<TKey, TValue>> dict, TKey key, TValue value, string assemblyName) { if (dict.ContainsKey(assemblyName)) { return Internal_SetValue(dict[assemblyName], key, value); } dict.Add(assemblyName, new Dictionary<TKey, TValue>()); Internal_SetValue(dict[assemblyName], key, value); return false; } public static void Save() { if (!Directory.Exists(GetDataPath())) { Directory.CreateDirectory(GetDataPath()); } string contents = JsonConvert.SerializeObject((object)_data); File.WriteAllText(dataFilePath, contents); UKLogger.Log("Saved persistent data"); } public static void Load() { UKLogger.Log("Loading persistent data..."); if (!File.Exists(dataFilePath)) { _data = PersistentData.Default; Save(); return; } string text; using (StreamReader streamReader = new StreamReader(dataFilePath)) { text = streamReader.ReadToEnd(); } _data = JsonConvert.DeserializeObject<PersistentData>(text); } public static bool SetPersistent(string key, object value, bool global) { if (global) { if (value is string) { Internal_SetValue(data.g_string_data, key, (string)value); return true; } if (value is int) { Internal_SetValue(data.g_int_data, key, (int)value); return true; } if (value is float) { Internal_SetValue(data.g_float_data, key, (float)value); return true; } if (value is bool) { Internal_SetValue(data.g_bool_data, key, (bool)value); return true; } if (value is string[]) { Internal_SetValue(data.g_string_data_array, key, (string[])value); return true; } if (value is int[]) { Internal_SetValue(data.g_int_data_array, key, (int[])value); return true; } if (value is float[]) { Internal_SetValue(data.g_float_data_array, key, (float[])value); return true; } if (value is bool[]) { Internal_SetValue(data.g_bool_data_array, key, (bool[])value); return true; } return false; } string name = Assembly.GetCallingAssembly().GetName().Name; if (value is string) { Internal_SetPrivateValue(data.p_string_data, key, (string)value, name); return true; } if (value is int) { Internal_SetPrivateValue(data.p_int_data, key, (int)value, name); return true; } if (value is float) { Internal_SetPrivateValue(data.p_float_data, key, (float)value, name); return true; } if (value is bool) { Internal_SetPrivateValue(data.p_bool_data, key, (bool)value, name); return true; } if (value is string[]) { Internal_SetPrivateValue(data.p_string_data_array, key, (string[])value, name); return true; } if (value is int[]) { Internal_SetPrivateValue(data.p_int_data_array, key, (int[])value, name); return true; } if (value is float[]) { Internal_SetPrivateValue(data.p_float_data_array, key, (float[])value, name); return true; } if (value is bool[]) { Internal_SetPrivateValue(data.p_bool_data_array, key, (bool[])value, name); return true; } return false; } public static bool GetPersistent<T>(string key, bool global, out object value) { Type typeFromHandle = typeof(T); if (global) { if (typeFromHandle.IsEquivalentTo(typeof(string))) { string value2; bool result = data.g_string_data.TryGetValue(key, out value2); value = value2; return result; } if (typeFromHandle.IsEquivalentTo(typeof(int))) { int value3; bool result2 = data.g_int_data.TryGetValue(key, out value3); value = value3; return result2; } if (typeFromHandle.IsEquivalentTo(typeof(float))) { float value4; bool result3 = data.g_float_data.TryGetValue(key, out value4); value = value4; return result3; } if (typeFromHandle.IsEquivalentTo(typeof(bool))) { bool value5; bool result4 = data.g_bool_data.TryGetValue(key, out value5); value = value5; return result4; } if (typeFromHandle.IsEquivalentTo(typeof(string[]))) { string[] value6; bool result5 = data.g_string_data_array.TryGetValue(key, out value6); value = value6; return result5; } if (typeFromHandle.IsEquivalentTo(typeof(int[]))) { int[] value7; bool result6 = data.g_int_data_array.TryGetValue(key, out value7); value = value7; return result6; } if (typeFromHandle.IsEquivalentTo(typeof(float[]))) { float[] value8; bool result7 = data.g_float_data_array.TryGetValue(key, out value8); value = value8; return result7; } if (typeFromHandle.IsEquivalentTo(typeof(bool[]))) { bool[] value9; bool result8 = data.g_bool_data_array.TryGetValue(key, out value9); value = value9; return result8; } value = default(T); return false; } string name = Assembly.GetCallingAssembly().GetName().Name; if (typeFromHandle.IsEquivalentTo(typeof(string))) { bool result9 = false; string value10 = null; if (data.p_string_data.TryGetValue(name, out var value11)) { result9 = value11.TryGetValue(key, out value10); } value = value10; return result9; } if (typeFromHandle.IsEquivalentTo(typeof(int))) { bool result10 = false; int value12 = 0; if (data.p_int_data.TryGetValue(name, out var value13)) { result10 = value13.TryGetValue(key, out value12); } value = value12; return result10; } if (typeFromHandle.IsEquivalentTo(typeof(float))) { bool result11 = false; float value14 = 0f; if (data.p_float_data.TryGetValue(name, out var value15)) { result11 = value15.TryGetValue(key, out value14); } value = value14; return result11; } if (typeFromHandle.IsEquivalentTo(typeof(bool))) { bool result12 = false; bool value16 = false; if (data.p_bool_data.TryGetValue(name, out var value17)) { result12 = value17.TryGetValue(key, out value16); } value = value16; return result12; } if (typeFromHandle.IsEquivalentTo(typeof(string[]))) { bool result13 = false; string[] value18 = null; if (data.p_string_data_array.TryGetValue(name, out var value19)) { result13 = value19.TryGetValue(key, out value18); } value = value18; return result13; } if (typeFromHandle.IsEquivalentTo(typeof(int[]))) { bool result14 = false; int[] value20 = null; if (data.p_int_data_array.TryGetValue(name, out var value21)) { result14 = value21.TryGetValue(key, out value20); } value = value20; return result14; } if (typeFromHandle.IsEquivalentTo(typeof(float[]))) { bool result15 = false; float[] value22 = null; if (data.p_float_data_array.TryGetValue(name, out var value23)) { result15 = value23.TryGetValue(key, out value22); } value = value22; return result15; } if (typeFromHandle.IsEquivalentTo(typeof(bool[]))) { bool result16 = false; bool[] value24 = null; if (data.p_bool_data_array.TryGetValue(name, out var value25)) { result16 = value25.TryGetValue(key, out value24); } value = value24; return result16; } value = default(T); return false; } } [Serializable] public class PersistentData { public Dictionary<string, int[]> weapon_order; public Dictionary<string, int[]> weapon_status; public Dictionary<string, bool> weapon_unlock; public Dictionary<string, UKCheckbox> settings_check; public Dictionary<string, UKSlider> settings_slide; public Dictionary<string, UKPicker> settings_pick; public Dictionary<string, string> g_string_data; public Dictionary<string, int> g_int_data; public Dictionary<string, float> g_float_data; public Dictionary<string, bool> g_bool_data; public Dictionary<string, string[]> g_string_data_array; public Dictionary<string, int[]> g_int_data_array; public Dictionary<string, float[]> g_float_data_array; public Dictionary<string, bool[]> g_bool_data_array; public Dictionary<string, Dictionary<string, string>> p_string_data; public Dictionary<string, Dictionary<string, int>> p_int_data; public Dictionary<string, Dictionary<string, float>> p_float_data; public Dictionary<string, Dictionary<string, bool>> p_bool_data; public Dictionary<string, Dictionary<string, string[]>> p_string_data_array; public Dictionary<string, Dictionary<string, int[]>> p_int_data_array; public Dictionary<string, Dictionary<string, float[]>> p_float_data_array; public Dictionary<string, Dictionary<string, bool[]>> p_bool_data_array; internal static readonly PersistentData Default = new PersistentData { weapon_order = new Dictionary<string, int[]>(), weapon_status = new Dictionary<string, int[]>(), weapon_unlock = new Dictionary<string, bool>(), settings_check = new Dictionary<string, UKCheckbox>(), settings_slide = new Dictionary<string, UKSlider>(), settings_pick = new Dictionary<string, UKPicker>(), g_string_data = new Dictionary<string, string>(), g_int_data = new Dictionary<string, int>(), g_float_data = new Dictionary<string, float>(), g_bool_data = new Dictionary<string, bool>(), g_string_data_array = new Dictionary<string, string[]>(), g_int_data_array = new Dictionary<string, int[]>(), g_float_data_array = new Dictionary<string, float[]>(), g_bool_data_array = new Dictionary<string, bool[]>(), p_string_data = new Dictionary<string, Dictionary<string, string>>(), p_int_data = new Dictionary<string, Dictionary<string, int>>(), p_float_data = new Dictionary<string, Dictionary<string, float>>(), p_bool_data = new Dictionary<string, Dictionary<string, bool>>(), p_string_data_array = new Dictionary<string, Dictionary<string, string[]>>(), p_int_data_array = new Dictionary<string, Dictionary<string, int[]>>(), p_float_data_array = new Dictionary<string, Dictionary<string, float[]>>(), p_bool_data_array = new Dictionary<string, Dictionary<string, bool[]>>() }; } }
plugins/ULTRAKIT.Loader.dll
Decompiled 8 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using HarmonyLib; using Humanizer; using Sandbox; using TMPro; using ULTRAKIT.Data; using ULTRAKIT.Extensions; using ULTRAKIT.Extensions.Classes; using ULTRAKIT.Extensions.Data; using ULTRAKIT.Extensions.Interfaces; using ULTRAKIT.Extensions.Managers; using ULTRAKIT.Loader.Injectors; using ULTRAKIT.Loader.Loaders; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("ULTRAKIT.Loader")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("HP Inc.")] [assembly: AssemblyProduct("ULTRAKIT.Loader")] [assembly: AssemblyCopyright("Copyright © HP Inc. 2022")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("919834fc-81ec-4f1a-9fd1-aa4272eeaf19")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace ULTRAKIT.Loader { public class Initializer { public static bool isUMMInstalled; public static bool isWaffle; public static void Initialize() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown Harmony val = new Harmony("ULTRAKIT.Loader"); val.PatchAll(); HatLoader.Init(); UltrakitInputManager.UpdateKeyBinds(); } } public static class Registries { public static Action<Action, float> Invoke; public static Dictionary<string, List<Weapon>> weap_registry = new Dictionary<string, List<Weapon>>(); public static List<Weapon> weap_allWeapons = new List<Weapon>(); public static Dictionary<Tuple<WeaponType, int>, ReplacementWeapon> weap_replacements = new Dictionary<Tuple<WeaponType, int>, ReplacementWeapon>(); public static List<HatRegistry> hat_registries = new List<HatRegistry>(); public static List<string> hat_activeHats = new List<string>(); public static List<IBuff> buff_buffRegistry = new List<IBuff>(); public static List<UKSpawnable> spawn_spawnables = new List<UKSpawnable>(); public static SpawnableObjectsDatabase spawn_spawnablesDatabase = ScriptableObject.CreateInstance<SpawnableObjectsDatabase>(); public static SpawnableObject[] spawn_tools = (SpawnableObject[])(object)new SpawnableObject[0]; public static SpawnableObject[] spawn_enemies = (SpawnableObject[])(object)new SpawnableObject[0]; public static SpawnableObject[] spawn_objects = (SpawnableObject[])(object)new SpawnableObject[0]; public static Dictionary<string, Sprite> spawn_sprites = new Dictionary<string, Sprite>(); public static SortedList<string, UKSetting> options_registry = new SortedList<string, UKSetting>(); public static Dictionary<string, GameObject> options_menus = new Dictionary<string, GameObject>(); public static Dictionary<string, GameObject> options_buttons = new Dictionary<string, GameObject>(); public static List<string> options_menusToAdd = new List<string>(); public static Dictionary<string, UKKeySetting> key_registry = new Dictionary<string, UKKeySetting>(); public static Dictionary<string, InputActionState> key_states = new Dictionary<string, InputActionState>(); private static int counter = 0; public static void RegisterSetting(UKSetting setting) { options_registry.Add($"{setting.Section}{setting.Heading}{counter}", setting); counter++; } } public static class UltrakitInputManager { public static InputActionState Slot7; public static InputActionState Slot8; public static InputActionState Slot9; public static InputActionState Slot10; public static InputActionState Slot11; public static InputActionState Slot12; public static InputActionState Slot13; public static InputActionState Slot14; public static InputActionState Slot15; public static InputActionState Slot16; public static InputActionState Slot17; public static InputActionState Slot18; public static InputActionState Slot19; public static InputActionState Slot20; public static void UpdateKeyBinds() { int num = Registries.weap_allWeapons.Count + 6; if ((Object)(object)MonoSingleton<GunControl>.Instance != (Object)null) { num = MonoSingleton<GunControl>.Instance.slots.Count; } if (num > 6) { OptionsLoader.SetKeyBind("ULTRAKIT Reloaded", "Slot 7", (KeyCode)55); OptionsLoader.GetKeyBind("Slot 7", out Slot7); } if (num > 7) { OptionsLoader.SetKeyBind("ULTRAKIT Reloaded", "Slot 8", (KeyCode)56); OptionsLoader.GetKeyBind("Slot 8", out Slot8); } if (num > 8) { OptionsLoader.SetKeyBind("ULTRAKIT Reloaded", "Slot 9", (KeyCode)57); OptionsLoader.GetKeyBind("Slot 9", out Slot9); } if (num > 9) { OptionsLoader.SetKeyBind("ULTRAKIT Reloaded", "Slot 10", (KeyCode)48); OptionsLoader.GetKeyBind("Slot 10", out Slot10); } if (num > 10) { OptionsLoader.SetKeyBind("ULTRAKIT Reloaded", "Slot 11", (KeyCode)256); OptionsLoader.GetKeyBind("Slot 11", out Slot11); } if (num > 11) { OptionsLoader.SetKeyBind("ULTRAKIT Reloaded", "Slot 12", (KeyCode)257); OptionsLoader.GetKeyBind("Slot 12", out Slot12); } if (num > 12) { OptionsLoader.SetKeyBind("ULTRAKIT Reloaded", "Slot 13", (KeyCode)258); OptionsLoader.GetKeyBind("Slot 13", out Slot13); } if (num > 13) { OptionsLoader.SetKeyBind("ULTRAKIT Reloaded", "Slot 14", (KeyCode)259); OptionsLoader.GetKeyBind("Slot 14", out Slot14); } if (num > 14) { OptionsLoader.SetKeyBind("ULTRAKIT Reloaded", "Slot 15", (KeyCode)260); OptionsLoader.GetKeyBind("Slot 15", out Slot15); } if (num > 15) { OptionsLoader.SetKeyBind("ULTRAKIT Reloaded", "Slot 16", (KeyCode)261); OptionsLoader.GetKeyBind("Slot 16", out Slot16); } if (num > 16) { OptionsLoader.SetKeyBind("ULTRAKIT Reloaded", "Slot 17", (KeyCode)262); OptionsLoader.GetKeyBind("Slot 17", out Slot17); } if (num > 17) { OptionsLoader.SetKeyBind("ULTRAKIT Reloaded", "Slot 18", (KeyCode)263); OptionsLoader.GetKeyBind("Slot 18", out Slot18); } if (num > 18) { OptionsLoader.SetKeyBind("ULTRAKIT Reloaded", "Slot 19", (KeyCode)264); OptionsLoader.GetKeyBind("Slot 19", out Slot19); } if (num > 19) { OptionsLoader.SetKeyBind("ULTRAKIT Reloaded", "Slot 20", (KeyCode)265); OptionsLoader.GetKeyBind("Slot 20", out Slot20); } } } } namespace ULTRAKIT.Loader.Patches { [HarmonyPatch(typeof(MinosBoss))] public static class MinosPatch { private static float minosHeight = 600f; private static float minosOffset = 200f; [HarmonyPatch("Start")] [HarmonyPrefix] public static void StartPrefix(MinosBoss __instance) { //IL_0015: 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_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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) CustomHealthbarPos componentInChildren = ((Component)__instance).GetComponentInChildren<CustomHealthbarPos>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { componentInChildren.offset = Vector3.up * minosHeight * 1.5f; componentInChildren.size = 0.25f; } if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponentInChildren<SandboxEnemy>())) { Transform transform = ((Component)MonoSingleton<NewMovement>.Instance).transform; ((Component)__instance).transform.position = transform.position + Vector3.down * minosHeight; Transform transform2 = ((Component)__instance).transform; transform2.position += transform.forward * minosOffset; Transform transform3 = ((Component)__instance).transform; Vector3 val = transform.position - ((Component)__instance).transform.position; transform3.forward = Vector3.ProjectOnPlane(((Vector3)(ref val)).normalized, Vector3.up); } } } [HarmonyPatch(typeof(LeviathanHead))] public static class LeviathanPatch { private static float leviHeight = 50f; [HarmonyPatch("Start")] [HarmonyPrefix] public static void StartPrefix(LeviathanHead __instance) { //IL_0065: 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_0029: 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) CustomHealthbarPos componentInChildren = ((Component)((Component)__instance).transform.parent).GetComponentInChildren<CustomHealthbarPos>(true); if (Object.op_Implicit((Object)(object)componentInChildren)) { componentInChildren.offset = Vector3.up * leviHeight * 1.5f; componentInChildren.size = 0.25f; } SkinnedMeshRenderer component = ((Component)((Component)__instance).transform.Find("Leviathan_SplineHook_Basic/ArmR")).GetComponent<SkinnedMeshRenderer>(); ((Renderer)component).material.color = Color.white; ((Renderer)component).material.mainTexture = ((Renderer)component).material.mainTexture; } } [HarmonyPatch(typeof(SpawnMenu))] public static class SpawnMenuPatch { [HarmonyPatch("Awake")] [HarmonyPrefix] public static void AwakePrefix(SpawnMenu __instance, SpawnableObjectsDatabase ___objects) { if (!SpawnablesLoader.init) { SpawnablesInjector.Init(); Registries.spawn_spawnablesDatabase.enemies = ___objects.enemies; Registries.spawn_spawnablesDatabase.objects = ___objects.objects; Registries.spawn_spawnablesDatabase.sandboxTools = ___objects.sandboxTools; SpawnablesLoader.init = true; } SpawnablesLoader.InjectSpawnables(__instance); ___objects.sandboxTools = Registries.spawn_tools; ___objects.enemies = Registries.spawn_enemies; ___objects.objects = Registries.spawn_objects; } } [HarmonyPatch(typeof(LeviathanTail))] public static class LeviathanTailPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] public static void AwakePostfix(LeviathanTail __instance) { //IL_001d: Unknown result type (might be due to invalid IL or missing references) SkinnedMeshRenderer component = ((Component)((Component)__instance).transform.Find("Leviathan_SplineHook_Basic/ArmR")).GetComponent<SkinnedMeshRenderer>(); ((Renderer)component).material.color = Color.white; ((Renderer)component).material.mainTexture = ((Renderer)component).material.mainTexture; } } [HarmonyPatch(typeof(ComplexSplasher))] public static class LeviathanTeasePatch { [HarmonyPatch("Awake")] [HarmonyPostfix] public static void AwakePostfix(ComplexSplasher __instance) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Component)__instance).transform.Find("Leviathan_SplineHook_Basic/ArmR"); if (!((Object)(object)val == (Object)null)) { SkinnedMeshRenderer component = ((Component)val).GetComponent<SkinnedMeshRenderer>(); ((Renderer)component).material.color = Color.white; ((Renderer)component).material.mainTexture = ((Renderer)component).material.mainTexture; } } } [HarmonyPatch(typeof(ObjectActivator))] public static class LeviathanTeasePatch2 { [HarmonyPatch("Start")] [HarmonyPostfix] public static void StartPostfix(ObjectActivator __instance) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Component)__instance).transform.Find("Leviathan_HeadFix/Leviathan"); if (!((Object)(object)val == (Object)null)) { SkinnedMeshRenderer component = ((Component)val).GetComponent<SkinnedMeshRenderer>(); ((Renderer)component).material.color = Color.white; ((Renderer)component).material.mainTexture = ((Renderer)component).material.mainTexture; } } } [HarmonyPatch(typeof(Wicked))] public static class WickedPatch { [HarmonyPatch("GetHit")] [HarmonyPrefix] public static bool GetHitPrefix(Wicked __instance) { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0035: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance.patrolPoints[0] == (Object)null) { AudioSource component = __instance.hitSound.GetComponent<AudioSource>(); GameObject val = new GameObject(); val.transform.position = ((Component)__instance).transform.position; AudioSource val2 = val.AddComponent<AudioSource>(); val2.playOnAwake = false; val2.clip = component.clip; val2.volume = component.volume; val2.pitch = component.pitch; val2.spatialBlend = component.spatialBlend; val2.Play(); Object.Destroy((Object)(object)val, val2.clip.length); Object.Destroy((Object)(object)((Component)__instance).gameObject); return false; } return true; } } } namespace ULTRAKIT.Loader.Loaders { public static class ArmLoader { } public static class BuffLoader { private static List<IBuff> buffRegistry => Registries.buff_buffRegistry; public static void RegisterBuff(IBuff buff) { UKLogger.Log((object)$"Loading buff {buff.id} into {Registries.buff_buffRegistry}"); buffRegistry.Add(buff); } } public static class HatLoader { public static List<HatsManager> managerInstances; public static bool Persistent; private static List<HatRegistry> registries => Registries.hat_registries; private static List<string> activeHats => Registries.hat_activeHats; internal static void Init() { SceneManager.sceneUnloaded += ClearInstances; if (managerInstances == null) { managerInstances = new List<HatsManager>(); } SetSeasonals(); } public static void LoadHats(AssetBundle bundle) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) Hat[] array = bundle.LoadAllAssets<Hat>(); HatRegistry[] array2 = bundle.LoadAllAssets<HatRegistry>(); HatRegistry[] array3 = array2; foreach (HatRegistry val in array3) { val.hatDict = new Dictionary<EnemyType, Hat>(); Hat[] hats = val.hats; foreach (Hat val2 in hats) { val.hatDict.Add(val2.enemyType, val2); } } registries.AddRange(array2); UKLogger.Log((object)("Loaded hats from " + ((Object)bundle).name)); } public static void SetAllActive(string hatID, bool active) { List<HatsManager> list = new List<HatsManager>(); foreach (HatsManager managerInstance in managerInstances) { if ((Object)(object)managerInstance == (Object)null) { list.Add(managerInstance); } else if (((Behaviour)managerInstance).isActiveAndEnabled) { managerInstance.SetHatActive(hatID, active); } } if (active && !activeHats.Contains(hatID)) { activeHats.Add(hatID); } if (!active && activeHats.Contains(hatID)) { activeHats.Remove(hatID); } EnumerableExt.RemoveRange<HatsManager>(managerInstances, (IEnumerable<HatsManager>)list); } private static void ClearInstances(Scene scene) { managerInstances.Clear(); } private static DateTime GetEaster(int year) { int num = year % 19; int num2 = year / 100; int num3 = (num2 - num2 / 4 - (8 * num2 + 13) / 25 + 19 * num + 15) % 30; int num4 = num3 - num3 / 28 * (1 - num3 / 28 * (29 / (num3 + 1)) * ((21 - num) / 11)); int num5 = num4 - (year + year / 4 + num4 + 2 - num2 + num2 / 4) % 7; int num6 = 3 + (num5 + 40) / 44; int day = num5 + 28 - 31 * (num6 / 4); return new DateTime(year, num6, day); } public static void SetSeasonals() { DateTime now = DateTime.Now; switch (now.Month) { case 12: if (now.Day >= 22 && now.Day <= 28) { activeHats.Add("christmas"); } return; case 10: if (now.Day >= 25 && now.Day <= 31) { activeHats.Add("halloween"); } return; } DateTime easter = GetEaster(now.Year); if (now.DayOfYear >= easter.DayOfYear - 2 && now.DayOfYear <= easter.DayOfYear) { activeHats.Add("easter"); } } } public static class OptionsLoader { public static UKCheckbox RegisterCheckbox(string section, string heading, string name, string id, bool defaultValue, bool overwrite = false) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown string text = "checkbox." + StringDehumanizeExtensions.Dehumanize(id); UKCheckbox val; if (!overwrite && SaveData.data.settings_check.ContainsKey(text)) { val = SaveData.data.settings_check[text]; Registries.RegisterSetting((UKSetting)(object)val); return val; } val = new UKCheckbox(section, heading, name, id, defaultValue); Registries.RegisterSetting((UKSetting)(object)val); SaveData.Internal_SetValue<string, UKCheckbox>(SaveData.data.settings_check, text, val); return val; } public static UKSlider RegisterSlider(string section, string heading, string name, string id, float min, float max, float defaultValue, bool overwrite = false) { //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown string text = "slider." + StringDehumanizeExtensions.Dehumanize(id); UKSlider val; if (!overwrite && SaveData.data.settings_slide.ContainsKey(text)) { val = SaveData.data.settings_slide[text]; Registries.RegisterSetting((UKSetting)(object)val); return val; } val = new UKSlider(section, heading, name, id, min, max, defaultValue); Registries.RegisterSetting((UKSetting)(object)val); SaveData.Internal_SetValue<string, UKSlider>(SaveData.data.settings_slide, text, val); return val; } public static UKPicker RegisterPicker(string section, string heading, string name, string id, string[] options, int defaultIndex, bool overwrite = false) { //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown string text = "picker." + StringDehumanizeExtensions.Dehumanize(id); UKPicker val; if (!overwrite && SaveData.data.settings_pick.ContainsKey(text)) { val = SaveData.data.settings_pick[text]; Registries.RegisterSetting((UKSetting)(object)val); return val; } val = new UKPicker(section, heading, name, id, options, defaultIndex); Registries.RegisterSetting((UKSetting)(object)val); SaveData.Internal_SetValue<string, UKPicker>(SaveData.data.settings_pick, text, val); return val; } public static bool GetCheckbox(string id, out UKCheckbox checkbox) { id = "checkbox." + StringDehumanizeExtensions.Dehumanize(id); if (SaveData.data.settings_check.TryGetValue(id, out checkbox)) { return true; } checkbox = null; return false; } public static bool GetSlider(string id, out UKSlider slider) { id = "slider." + StringDehumanizeExtensions.Dehumanize(id); if (SaveData.data.settings_slide.TryGetValue(id, out slider)) { return true; } slider = null; return false; } public static bool GetPicker(string id, out UKPicker picker) { id = "picker." + StringDehumanizeExtensions.Dehumanize(id); if (SaveData.data.settings_pick.TryGetValue(id, out picker)) { return true; } picker = null; return false; } public static UKKeySetting SetKeyBind(string heading, string name, KeyCode defaultKey) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown string key = "keybind." + StringDehumanizeExtensions.Dehumanize(name); if (Registries.key_registry.ContainsKey(key)) { return Registries.key_registry[key]; } UKKeySetting val = new UKKeySetting(heading, name, defaultKey); Registries.key_registry.Add(((UKSetting)val).ID, val); Registries.RegisterSetting((UKSetting)(object)val); return val; } public static bool GetKeyBind(string name, out InputActionState actionState) { string key = "keybind." + StringDehumanizeExtensions.Dehumanize(name); if (Registries.key_states.ContainsKey(key)) { actionState = Registries.key_states[key]; return true; } actionState = null; return false; } public static void CreateMenu(string name) { } public static (GameObject button, GameObject menu) GetMenu(string name) { string key = StringDehumanizeExtensions.Dehumanize(name); GameObject item = Registries.options_buttons[key] ?? null; GameObject item2 = Registries.options_menus[key] ?? null; return (item, item2); } } public static class SpawnablesLoader { public static bool init; private static List<UKSpawnable> spawnables => Registries.spawn_spawnables; private static SpawnableObjectsDatabase spawnablesDatabase => Registries.spawn_spawnablesDatabase; public static void LoadSpawnables(AssetBundle bundle) { UKSpawnable[] array = bundle.LoadAllAssets<UKSpawnable>(); UKSpawnable[] array2 = array; foreach (UKSpawnable val in array2) { val.prefab.AddComponent<RenderFixer>().LayerName = "Outdoors"; if (!spawnables.Contains(val)) { spawnables.Add(val); } } } public static void UnloadSpawnables(AssetBundle bundle) { UKSpawnable[] array = bundle.LoadAllAssets<UKSpawnable>(); UKSpawnable[] array2 = array; foreach (UKSpawnable item in array2) { if (spawnables.Contains(item)) { spawnables.Remove(item); } } } public static void InjectSpawnables(SpawnMenu spawnMenu) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_009e: 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_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected I4, but got Unknown //IL_00eb: 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_00c5: Unknown result type (might be due to invalid IL or missing references) List<SpawnableObject> list = new List<SpawnableObject>(); List<SpawnableObject> list2 = new List<SpawnableObject>(); List<SpawnableObject> list3 = new List<SpawnableObject>(); foreach (UKSpawnable spawn_spawnable in Registries.spawn_spawnables) { SpawnableObject val = ScriptableObject.CreateInstance<SpawnableObject>(); val.identifier = spawn_spawnable.identifier; val.spawnableObjectType = spawn_spawnable.type; val.objectName = spawn_spawnable.identifier; val.type = "UKSpawnable"; val.enemyType = (EnemyType)18; val.gameObject = spawn_spawnable.prefab; val.preview = new GameObject(); val.gridIcon = spawn_spawnable.icon; SpawnableObjectDataType type = spawn_spawnable.type; SpawnableObjectDataType val2 = type; switch ((int)val2) { case 3: val.spawnableType = (SpawnableType)2; list.Add(val); break; case 1: val.spawnableType = (SpawnableType)0; list2.Add(val); break; case 0: val.spawnableType = (SpawnableType)0; list3.Add(val); break; } } list2.AddRange(SpawnablesInjector._enemies); Registries.spawn_tools = spawnablesDatabase.sandboxTools.Concat(list).ToArray(); Registries.spawn_enemies = spawnablesDatabase.enemies.Concat(list2).ToArray(); Registries.spawn_objects = spawnablesDatabase.objects.Concat(list3).ToArray(); } } public static class WeaponLoader { private static Dictionary<string, List<Weapon>> registry => Registries.weap_registry; private static List<Weapon> allWeapons => Registries.weap_allWeapons; private static Dictionary<Tuple<WeaponType, int>, ReplacementWeapon> replacements => Registries.weap_replacements; public static Weapon[] LoadWeapons(AssetBundle bundle) { string name = ((Object)bundle).name; registry.Add(name, new List<Weapon>()); Weapon[] array = bundle.LoadAllAssets<Weapon>(); Weapon[] array2 = array; foreach (Weapon val in array2) { val.modName = name; if (!SaveData.data.weapon_order.TryGetValue(val.modName + "." + val.id, out var value)) { value = new int[3] { 0, 1, 2 }; } if (!SaveData.data.weapon_status.TryGetValue(val.modName + "." + val.id, out var value2)) { value2 = new int[3] { 1, 1, 1 }; } if (!SaveData.data.weapon_unlock.TryGetValue(val.modName + "." + val.id, out var value3)) { value3 = val.Unlocked; } val.equipOrder = value; val.equipStatus = value2; val.Unlocked = value3; List<GameObject> list = new List<GameObject>(); list.AddRange(val.Variants); list.AddRange(val.AltVariants); val.All_Variants = list.ToArray(); } registry[name].AddRange(array); allWeapons.AddRange(array); UKLogger.Log((object)("Loaded weapons from " + name)); UltrakitInputManager.UpdateKeyBinds(); return array; } public static void LoadReplacements(AssetBundle bundle) { //IL_0026: 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) string name = ((Object)bundle).name; ReplacementWeapon[] array = bundle.LoadAllAssets<ReplacementWeapon>(); ReplacementWeapon[] array2 = array; foreach (ReplacementWeapon val in array2) { val.modName = name; Tuple<WeaponType, int> key = new Tuple<WeaponType, int>(val.WeaponType, val.Variant); if (replacements.ContainsKey(key)) { UKLogger.LogWarning((object)$"{{{name}}} Failed to load weapon: {val.WeaponType} variant {val.Variant} replacement already loaded."); } else { replacements.Add(key, val); } } } public static void UnloadWeapons(string bundleName) { List<Tuple<WeaponType, int>> list = new List<Tuple<WeaponType, int>>(); foreach (KeyValuePair<Tuple<WeaponType, int>, ReplacementWeapon> replacement in replacements) { if (replacement.Value.modName == bundleName) { list.Add(replacement.Key); } } foreach (Tuple<WeaponType, int> item in list) { replacements.Remove(item); } foreach (Weapon item2 in registry[bundleName]) { allWeapons.Remove(item2); } registry.Remove(bundleName); AssetBundle[] array = (from b in AssetBundle.GetAllLoadedAssetBundles() where ((Object)b).name == bundleName select b).ToArray(); AssetBundle[] array2 = array; foreach (AssetBundle val in array2) { val.Unload(true); } UltrakitInputManager.UpdateKeyBinds(); } public static Weapon idToWeapon(string bundleName, string weaponId) { List<Weapon> list = new List<Weapon>(); try { list = registry[bundleName]; } catch (ArgumentOutOfRangeException) { UKLogger.LogWarning((object)("No bundle of name " + bundleName + " found.")); return null; } foreach (Weapon item in list) { if (item.id == weaponId) { return item; } } UKLogger.LogWarning((object)("No weapon " + weaponId + " found.")); return null; } public static bool SetWeaponUnlock(string bundleName, string weaponId, bool state) { Weapon val = idToWeapon(bundleName, weaponId); if ((Object)(object)val == (Object)null) { UKLogger.LogWarning((object)"Weapon not found"); return false; } val.Unlocked = state; SaveData.Internal_SetValue<string, bool>(SaveData.data.weapon_unlock, val.modName + "." + val.id, state); GunSetterExtension.RefreshWeapons(MonoSingleton<GunSetter>.Instance); return true; } public static bool SetWeaponUnlock(Weapon weapon, bool state) { if ((Object)(object)weapon == (Object)null) { UKLogger.LogWarning((object)"Weapon not found"); return false; } weapon.Unlocked = state; SaveData.Internal_SetValue<string, bool>(SaveData.data.weapon_unlock, weapon.modName + "." + weapon.id, state); GunSetterExtension.RefreshWeapons(MonoSingleton<GunSetter>.Instance); return true; } } } namespace ULTRAKIT.Loader.Injectors { [HarmonyPatch(typeof(InputManager))] public class KeybindsInjector { [HarmonyPatch("OnEnable")] [HarmonyPostfix] private static void OnEnablePostfix(InputManager __instance) { SetKeys(__instance); } public static void SetKeys(InputManager instance) { //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) instance.legacyBindings = CollectionExtensions.AddRangeToArray<BindingInfo>(instance.legacyBindings, (from n in Registries.key_registry select n.Value.Binding into s where !instance.legacyBindings.Contains(s) select s).ToArray()); Registries.key_states = ((IEnumerable<KeyValuePair<string, UKKeySetting>>)Registries.key_registry).ToDictionary((Func<KeyValuePair<string, UKKeySetting>, string>)((KeyValuePair<string, UKKeySetting> item) => item.Key), (Func<KeyValuePair<string, UKKeySetting>, InputActionState>)((KeyValuePair<string, UKKeySetting> item) => new InputActionState(item.Value.Binding.Action))); foreach (UKKeySetting value in Registries.key_registry.Values) { if (!MonoSingleton<PrefsManager>.Instance.HasKey(value.Binding.PrefName)) { MonoSingleton<PrefsManager>.instance.prefMap.Add(value.Binding.PrefName, value.Binding.DefaultKey); } BindingSyntax val = InputActionSetupExtensions.AddBinding(value.Binding.Action, default(InputBinding)); ((BindingSyntax)(ref val)).WithGroup("Keyboard"); value.Binding.Action.Enable(); } instance.UpgradeBindings(); } } [HarmonyPatch(typeof(ControlsOptions))] public class ControlsOptionsPatch { public static UKKeySetting currentKey; [HarmonyPatch("OnActionChanged")] [HarmonyPostfix] private static void OnGUIPostix() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) if (currentKey != null) { currentKey.SetValue(MonoSingleton<InputManager>.instance.Inputs[currentKey.Binding.PrefName]); } } } public static class ArmInjector { } [HarmonyPatch(typeof(EnemyIdentifier))] public static class EnemyIdentifierPatch { [HarmonyPatch("Start")] [HarmonyPostfix] private static void StartPatch(EnemyIdentifier __instance) { BuffsManager val = ((Component)__instance).gameObject.AddComponent<BuffsManager>(); val.eid = __instance; val.LoadBuffs(Registries.buff_buffRegistry.ToArray()); } } [HarmonyPatch(typeof(SeasonalHats))] public static class SeasonalHatsPatch { [HarmonyPatch("Start")] [HarmonyPrefix] private static void StartPrefix(SeasonalHats __instance) { HatsManager val = ((Component)__instance).gameObject.AddComponent<HatsManager>(); foreach (HatRegistry hat_registry in Registries.hat_registries) { val.LoadHat(hat_registry); } HatLoader.managerInstances.Add(val); ClearSeasonal(val); foreach (string hat_activeHat in Registries.hat_activeHats) { val.SetHatActive(hat_activeHat, true); } } private static void ClearSeasonal(HatsManager manager) { manager.SetHatActive("christmas", false); manager.SetHatActive("halloween", false); manager.SetHatActive("easter", false); } } [HarmonyPatch(typeof(VariationInfo))] public static class VariationInfoInjections { [HarmonyPatch("ChangeEquipment")] [HarmonyPrefix] public static bool ChangeEquipmentPrefix(VariationInfo __instance) { return ((Behaviour)__instance).enabled; } } [HarmonyPatch(typeof(ShopGearChecker))] public static class ShopInjector { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Func<TextMeshProUGUI, bool> <>9__12_0; public static Func<TextMeshProUGUI, bool> <>9__13_4; public static Func<TextMeshProUGUI, bool> <>9__13_5; public static UnityAction <>9__14_0; internal bool <CreatePanels>b__12_0(TextMeshProUGUI k) { return ((Object)((TMP_Text)k).transform.parent).name == "Order"; } internal bool <CreateVariantOption>b__13_4(TextMeshProUGUI k) { return ((Object)((TMP_Text)k).transform.parent).name == "Order"; } internal bool <CreateVariantOption>b__13_5(TextMeshProUGUI k) { return ((Object)((TMP_Text)k).transform.parent).name == "Order"; } internal void <CreatePageButton>b__14_0() { page++; UpdatePage(); } } private static GameObject buttonTemplate; private static GameObject panelTemplate; private static GameObject variantTemplate; private static int buttonHeight = 30; private static int variantHeight = 80; private static Dictionary<Weapon, GameObject> panels; private static List<List<GameObject>> pages; private static int page; private static GameObject pageButton; [HarmonyPatch("OnEnable")] [HarmonyPostfix] public static void TurnOnPostFix(ShopGearChecker __instance) { if (!Object.op_Implicit((Object)(object)pageButton)) { page = 0; buttonTemplate = ((Component)((Component)__instance).GetComponentInChildren<ShopButton>(true)).gameObject; variantTemplate = ((Component)((Component)__instance).GetComponentInChildren<VariationInfo>(true)).gameObject; panelTemplate = ((Component)variantTemplate.transform.parent).gameObject; panels = CreatePanels(((Component)__instance).gameObject); pages = CreatePages(((Component)__instance).gameObject); pageButton = CreatePageButton(); } UpdatePage(); } private static List<List<GameObject>> CreatePages(GameObject parent) { List<List<GameObject>> list = new List<List<GameObject>>(); list.Add(new List<GameObject>()); ShopButton[] componentsInChildren = parent.gameObject.GetComponentsInChildren<ShopButton>(); foreach (ShopButton val in componentsInChildren) { foreach (GameObject value in panels.Values) { val.toDeactivate = CollectionExtensions.AddItem<GameObject>((IEnumerable<GameObject>)val.toDeactivate, value).ToArray(); } list[0].Add(((Component)val).gameObject); } List<Weapon> weap_allWeapons = Registries.weap_allWeapons; int num = 1; int num2 = 0; list.Add(new List<GameObject>()); foreach (Weapon item in weap_allWeapons) { if (item.Unlocked) { list[num].Add(CreateWeaponButton(parent, item, num2)); num2++; if (num2 > 5) { list.Add(new List<GameObject>()); num++; num2 = 0; } } } return list; } private static GameObject CreateWeaponButton(GameObject parent, Weapon weap, int i) { //IL_0045: 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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(buttonTemplate, parent.transform); int num = 80 - buttonHeight * i; RectTransform component = val.GetComponent<RectTransform>(); component.offsetMax = new Vector2(-100f, (float)num); component.offsetMin = new Vector2(-260f, (float)(num - buttonHeight)); ((Transform)component).SetAsFirstSibling(); ((TMP_Text)val.GetComponentInChildren<TextMeshProUGUI>()).text = weap.Names[0].ToUpper(); val.GetComponent<ShopButton>().deactivated = true; ((UnityEvent)val.GetComponent<Button>().onClick).AddListener((UnityAction)delegate { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown foreach (KeyValuePair<Weapon, GameObject> panel in panels) { panel.Value.SetActive((Object)(object)panels[weap] == (Object)(object)panel.Value); } foreach (Transform item in parent.transform) { Transform val2 = item; if (!((Object)(object)val2 == (Object)(object)parent.transform) && (Object)(object)((Component)val2).GetComponentInChildren<VariationInfo>(true) != (Object)null) { ((Component)val2).gameObject.SetActive((Object)(object)panels[weap] == (Object)(object)((Component)val2).gameObject); } } }); val.AddComponent<HudOpenEffect>(); return val; } private static Dictionary<Weapon, GameObject> CreatePanels(GameObject parent) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown Dictionary<Weapon, GameObject> dictionary = new Dictionary<Weapon, GameObject>(); List<Weapon> weap_allWeapons = Registries.weap_allWeapons; foreach (Weapon item in weap_allWeapons) { GameObject val = Object.Instantiate<GameObject>(panelTemplate, parent.transform); foreach (Transform item2 in val.transform) { Transform val2 = item2; Object.Destroy((Object)(object)((Component)val2).gameObject); } for (int i = 0; i < item.Variants.Length; i++) { CreateVariantOption(val, item, i); } TextMeshProUGUI[] array = (from k in val.GetComponentsInChildren<TextMeshProUGUI>(true) where ((Object)((TMP_Text)k).transform.parent).name == "Order" select k).ToArray(); for (int j = 0; j < item.Variants.Length; j++) { ((TMP_Text)array[j]).text = (item.equipOrder[j] + 1).ToString(); } dictionary.Add(item, val); } return dictionary; } private static GameObject CreateVariantOption(GameObject panel, Weapon weapon, int i) { //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Expected O, but got Unknown //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Expected O, but got Unknown //IL_01d2: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Expected O, but got Unknown //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Expected O, but got Unknown //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Expected O, but got Unknown //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) GameObject val = Object.Instantiate<GameObject>(variantTemplate, panel.transform); VariationInfo info = val.GetComponent<VariationInfo>(); ((Behaviour)info).enabled = false; ColorBlindGet componentInChildren = ((Component)info).GetComponentInChildren<ColorBlindGet>(); ((Component)componentInChildren).GetComponent<Image>().sprite = weapon.Icons[i]; componentInChildren.variationNumber = i; ((TMP_Text)((Component)((Component)info).transform.Find("Text")).GetComponent<TextMeshProUGUI>()).text = weapon.Names[i]; ((Component)((Component)info).transform.Find("Text (1)")).gameObject.SetActive(false); Transform val2 = ((Component)info).transform.Find("EquipmentStuffs"); Button component = ((Component)val2.Find("PreviousButton")).GetComponent<Button>(); Button component2 = ((Component)val2.Find("NextButton")).GetComponent<Button>(); Transform val3 = val2.Find("Order"); ((Behaviour)((Component)val3).GetComponent<WeaponOrderController>()).enabled = false; GameObject gameObject = ((Component)val3.Find("UpButton")).gameObject; GameObject gameObject2 = ((Component)val3.Find("DownButton")).gameObject; Image component3 = ((Component)val3.Find("Image")).GetComponent<Image>(); Image img = ((Component)((Component)info.equipButton).transform.GetChild(0)).GetComponent<Image>(); img.sprite = info.equipSprites[weapon.equipStatus[i]]; UnityAction val4 = (UnityAction)delegate { int num4 = ((weapon.AltVariants.Length > i && (Object)(object)weapon.AltVariants[i] != (Object)null) ? 1 : 0); weapon.equipStatus[i] = (int)Mathf.Repeat((float)(weapon.equipStatus[i] - 1), (float)(2 + num4)); GunSetterPatch.equippedDict[weapon.All_Variants[i]] = weapon.equipStatus[i] == 1; if (num4 == 1) { GunSetterPatch.equippedDict[weapon.All_Variants[i + weapon.Variants.Length]] = weapon.equipStatus[i] == 2; } img.sprite = info.equipSprites[weapon.equipStatus[i]]; MonoSingleton<GunSetter>.Instance.ResetWeapons(false); }; UnityAction val5 = (UnityAction)delegate { int num3 = ((weapon.AltVariants.Length > i && (Object)(object)weapon.AltVariants[i] != (Object)null) ? 1 : 0); weapon.equipStatus[i] = (int)Mathf.Repeat((float)(weapon.equipStatus[i] + 1), (float)(2 + num3)); GunSetterPatch.equippedDict[weapon.All_Variants[i]] = weapon.equipStatus[i] == 1; if (num3 == 1) { GunSetterPatch.equippedDict[weapon.All_Variants[i + weapon.Variants.Length]] = weapon.equipStatus[i] == 2; } img.sprite = info.equipSprites[weapon.equipStatus[i]]; MonoSingleton<GunSetter>.Instance.ResetWeapons(false); }; UnityAction val6 = (UnityAction)delegate { TextMeshProUGUI[] array2 = (from k in ((Component)((Component)info).transform.parent).GetComponentsInChildren<TextMeshProUGUI>() where ((Object)((TMP_Text)k).transform.parent).name == "Order" select k).ToArray(); int num2 = (int)Mathf.Repeat((float)(weapon.equipOrder[i] + 1), (float)weapon.Variants.Length); weapon.equipOrder[EnumerableExt.FindIndexOf<int>((IEnumerable<int>)weapon.equipOrder, num2)] = weapon.equipOrder[i]; weapon.equipOrder[i] = num2; for (int l = 0; l < weapon.Variants.Length; l++) { ((TMP_Text)array2[l]).text = (weapon.equipOrder[l] + 1).ToString(); } MonoSingleton<GunSetter>.Instance.ResetWeapons(false); }; UnityAction val7 = (UnityAction)delegate { TextMeshProUGUI[] array = (from k in ((Component)((Component)info).transform.parent).GetComponentsInChildren<TextMeshProUGUI>() where ((Object)((TMP_Text)k).transform.parent).name == "Order" select k).ToArray(); int num = (int)Mathf.Repeat((float)(weapon.equipOrder[i] - 1), (float)weapon.Variants.Length); weapon.equipOrder[EnumerableExt.FindIndexOf<int>((IEnumerable<int>)weapon.equipOrder, num)] = weapon.equipOrder[i]; weapon.equipOrder[i] = num; for (int j = 0; j < weapon.Variants.Length; j++) { ((TMP_Text)array[j]).text = (weapon.equipOrder[j] + 1).ToString(); } MonoSingleton<GunSetter>.Instance.ResetWeapons(false); }; UnityEvent val8 = new UnityEvent(); UnityEvent val9 = new UnityEvent(); val8.AddListener(val6); val9.AddListener(val7); Type internalType = ReflectionExt.GetInternalType("ControllerPointer"); Component component4 = gameObject.GetComponent(internalType); FieldInfo field = ((object)component4).GetType().GetField("onPressed", BindingFlags.Instance | BindingFlags.NonPublic); field.SetValue(component4, val8); Component component5 = gameObject2.GetComponent(internalType); FieldInfo field2 = ((object)component5).GetType().GetField("onPressed", BindingFlags.Instance | BindingFlags.NonPublic); field2.SetValue(component5, val9); ((UnityEvent)component.onClick).AddListener(val4); ((UnityEvent)component2.onClick).AddListener(val5); component3.sprite = weapon.Icons[i]; ((Graphic)component3).color = new Color(MonoSingleton<ColorBlindSettings>.Instance.variationColors[i].r, MonoSingleton<ColorBlindSettings>.Instance.variationColors[i].g, MonoSingleton<ColorBlindSettings>.Instance.variationColors[i].b, ((Graphic)component3).color.a); ((Component)val3).gameObject.SetActive(true); val.GetComponent<RectTransform>().offsetMax = new Vector2(0f, (float)(160 - i * variantHeight)); val.GetComponent<RectTransform>().offsetMin = new Vector2(-360f, (float)(80 - i * variantHeight)); return val; } private static GameObject CreatePageButton() { //IL_004b: 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_00d3: 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_00de: Expected O, but got Unknown GameObject val = Object.Instantiate<GameObject>(buttonTemplate, buttonTemplate.transform.parent); int num = -10 - buttonHeight * 4; RectTransform component = val.GetComponent<RectTransform>(); component.offsetMax = new Vector2(-100f, (float)(-130 + (Initializer.isWaffle ? (buttonHeight * 2) : 0))); component.offsetMin = new Vector2(-260f, (float)(-160 + (Initializer.isWaffle ? (buttonHeight * 2) : 0))); ((Transform)component).SetAsFirstSibling(); ((TMP_Text)val.GetComponentInChildren<TextMeshProUGUI>()).text = $"PAGE {page + 1}"; val.GetComponent<ShopButton>().deactivated = true; ButtonClickedEvent onClick = val.GetComponent<Button>().onClick; object obj = <>c.<>9__14_0; if (obj == null) { UnityAction val2 = delegate { page++; UpdatePage(); }; <>c.<>9__14_0 = val2; obj = (object)val2; } ((UnityEvent)onClick).AddListener((UnityAction)obj); val.AddComponent<HudOpenEffect>(); return val; } private static void UpdatePage() { page = (int)Mathf.Repeat((float)page, (float)pages.Count); ((TMP_Text)pageButton.GetComponentInChildren<TextMeshProUGUI>(true)).text = $"PAGE {page + 1}"; int num = 0; foreach (List<GameObject> page in pages) { foreach (GameObject item in page) { if ((Object)(object)item != (Object)null) { item.SetActive(ShopInjector.page == num); } } num++; } } } public static class SpawnablesInjector { public static List<SpawnableObject> _enemies = new List<SpawnableObject>(); private static Dictionary<string, EnemyType> SpawnList = new Dictionary<string, EnemyType> { { "DroneFlesh", (EnemyType)1 }, { "DroneSkull Variant", (EnemyType)1 }, { "MinosBoss", (EnemyType)11 }, { "Wicked", (EnemyType)10 }, { "Drone Variant", (EnemyType)1 }, { "DroneFleshCamera Variant", (EnemyType)1 } }; public static void Init() { //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) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown PrepLeviathan(); foreach (KeyValuePair<string, EnemyType> spawn in SpawnList) { SpawnableObject val = ScriptableObject.CreateInstance<SpawnableObject>(); val.identifier = spawn.Key; val.spawnableObjectType = (SpawnableObjectDataType)1; val.objectName = spawn.Key; val.type = "Enemy"; val.enemyType = spawn.Value; val.spawnableType = (SpawnableType)0; val.gameObject = GrabEnemy(spawn.Key + ".prefab"); val.preview = new GameObject(); val.gridIcon = Registries.spawn_sprites[spawn.Key]; _enemies.Add(val); } } private static void PrepLeviathan() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Expected O, but got Unknown //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Expected O, but got Unknown //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_0359: Unknown result type (might be due to invalid IL or missing references) //IL_0361: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Leviathan"); val.SetActive(false); GameObject val2 = Object.Instantiate<GameObject>(AssetLoader.AssetFind<GameObject>("LeviathanHead.prefab"), val.transform); GameObject val3 = Object.Instantiate<GameObject>(AssetLoader.AssetFind<GameObject>("LeviathanTail Variant.prefab"), val.transform); GameObject val4 = Object.Instantiate<GameObject>(AssetLoader.AssetFind<GameObject>("SplashBig.prefab"), val.transform); LeviathanController val5 = val.AddComponent<LeviathanController>(); EnemyIdentifier val6 = val.AddComponent<EnemyIdentifier>(); Statue val7 = val.AddComponent<Statue>(); SphereCollider val8 = val.AddComponent<SphereCollider>(); Rigidbody val9 = val.AddComponent<Rigidbody>(); BossIdentifier val10 = val.AddComponent<BossIdentifier>(); BossHealthBar val11 = val.AddComponent<BossHealthBar>(); val5.head = val2.GetComponent<LeviathanHead>(); val5.tail = val3.GetComponent<LeviathanTail>(); val5.bigSplash = AssetLoader.AssetFind<GameObject>("SplashBig.prefab"); val5.headWeakPoint = val2.transform.Find("Leviathan_SplineHook_Basic/Armature/Bone043/Bone001/Heart"); val5.tailWeakPoint = val3.transform.Find("Leviathan_SplineHook_Basic/Armature/" + GraphicsUtilities.BonePath(43, 86)); val5.headPartsParent = val2.transform.Find("Leviathan_SplineHook_Basic/Armature/Bone043/Bone044"); val5.tailPartsParent = val3.transform.Find("Leviathan_SplineHook_Basic/Armature/Bone043/Bone044"); val5.phaseChangeHealth = 100f; val6.overrideFullName = "Leviathan"; val6.bigEnemy = true; val6.damageBuffModifier = 1.5f; val6.enemyClass = (EnemyClass)2; val6.enemyType = (EnemyType)27; val6.health = 200f; val6.healthBuffModifier = 1.5f; val6.speedBuffModifier = 1.5f; val6.unbounceable = true; val6.weakPoint = ((Component)val2.transform.Find("Leviathan_SplineHook_Basic/Armature/Bone043/Bone001/Heart")).gameObject; val7.affectedByGravity = true; val7.bigBlood = true; val7.extraDamageMultiplier = 3f; val7.extraDamageZones = new List<GameObject> { ((Component)val2.transform.Find("Leviathan_SplineHook_Basic/Armature/Bone043/Bone001/Heart")).gameObject }; val7.health = 200f; val7.specialDeath = true; val11.bossName = "LEVIATHAN"; HealthLayer val12 = new HealthLayer(); HealthLayer val13 = new HealthLayer(); val12.health = 100f; val13.health = 100f; val11.healthLayers = (HealthLayer[])(object)new HealthLayer[2] { val12, val13 }; val9.isKinematic = true; val5.head.shootPoint = val2.transform.Find("Leviathan_SplineHook_Basic/Armature/Bone043/Bone001/ShootPoint"); val5.head.projectileSpreadAmount = 5f; val5.head.tracker = val2.transform.Find("Leviathan_SplineHook_Basic/Armature/Bone043/Bone001"); val5.head.tailBone = val2.transform.Find("Leviathan_SplineHook_Basic/Armature/" + GraphicsUtilities.BonePath(43, 56)); val5.head.lookAtPlayer = true; val5.head.biteSwingCheck = ((Component)val2.transform.Find("Leviathan_SplineHook_Basic/Armature/Bone043/Bone001/SwingCheck")).GetComponent<SwingCheck2>(); val5.head.warningFlash = AssetLoader.AssetFind<GameObject>("V2FlashUnparriable.prefab"); ((Component)val5).gameObject.tag = "Enemy"; Object.DontDestroyOnLoad((Object)(object)val); SpawnableObject val14 = ScriptableObject.CreateInstance<SpawnableObject>(); val14.identifier = "leviathan"; val14.spawnableObjectType = (SpawnableObjectDataType)1; val14.objectName = "leviathan"; val14.type = "Enemy"; val14.enemyType = (EnemyType)27; val14.spawnableType = (SpawnableType)0; val14.gameObject = val; val14.preview = AssetLoader.AssetFind<GameObject>("Leviathan Preview Variant.prefab"); val14.gridIcon = Registries.spawn_sprites["Leviathan"]; SetHealthBar(val, "Leviathan"); _enemies.Add(val14); } public static GameObject GrabEnemy(string enemy) { GameObject val = AssetLoader.AssetFind<GameObject>(enemy); if ((Object)(object)val != (Object)null) { SetHealthBar(val, enemy); return val; } UKLogger.LogWarning((object)("Could not find enemy " + enemy)); return null; } public static void SetHealthBar(GameObject obj, string enemy) { BossHealthBar componentInChildren = obj.GetComponentInChildren<BossHealthBar>(); if ((Object)(object)componentInChildren == (Object)null && (enemy == "MinosBoss" || enemy == "Leviathan")) { componentInChildren = ((Component)obj.GetComponentInChildren<EnemyIdentifier>(true)).gameObject.AddComponent<BossHealthBar>(); componentInChildren.bossName = ""; } } } [HarmonyPatch(typeof(GunSetter))] public class GunSetterPatch { public static List<List<GameObject>> modSlots = new List<List<GameObject>>(); public static Dictionary<GameObject, bool> equippedDict = new Dictionary<GameObject, bool>(); private static void SetPref(string weapon, bool alt) { if (!MonoSingleton<PrefsManager>.Instance.prefMap.ContainsKey("weapon." + weapon)) { MonoSingleton<PrefsManager>.Instance.prefMap.Add("weapon." + weapon, 1); } if (!GameProgressSaverPatch.loadedWeapons.Contains(weapon)) { GameProgressSaverPatch.loadedWeapons.Add(weapon); } string item = weapon.Remove(weapon.Length - 1) + "alt"; if (alt && !GameProgressSaverPatch.loadedWeapons.Contains(item)) { GameProgressSaverPatch.loadedWeapons.Add(item); } } [HarmonyPatch("Start")] [HarmonyPrefix] private static void StartPrefix(GunSetter __instance) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Expected I4, but got Unknown foreach (ReplacementWeapon value in Registries.weap_replacements.Values) { int num = (value.Alt ? 1 : 0); value.Prefab.SetActive(false); value.Prefab.AddComponent<RenderFixer>().LayerName = "AlwaysOnTop"; WeaponType weaponType = value.WeaponType; WeaponType val = weaponType; switch ((int)val) { case 0: switch (value.Variant) { case 0: { List<GameObject> list15 = ((IEnumerable<AssetReference>)__instance.revolverPierce).Select((Func<AssetReference, GameObject>)((AssetReference k) => (GameObject)k.Asset)).ToList(); EnumerableExt.ReplaceOrAddTo<GameObject>(list15, value.Prefab, num); AssetReference[] rocketRed = (AssetReference[])(object)((IEnumerable<GameObject>)list15).Select((Func<GameObject, UKAsset>)((GameObject k) => new UKAsset((Object)(object)k))).ToArray(); __instance.revolverPierce = rocketRed; SetPref("rev0", value.Alt); break; } case 1: { List<GameObject> list14 = ((IEnumerable<AssetReference>)__instance.revolverRicochet).Select((Func<AssetReference, GameObject>)((AssetReference k) => (GameObject)k.Asset)).ToList(); EnumerableExt.ReplaceOrAddTo<GameObject>(list14, value.Prefab, num); AssetReference[] rocketRed = (AssetReference[])(object)((IEnumerable<GameObject>)list14).Select((Func<GameObject, UKAsset>)((GameObject k) => new UKAsset((Object)(object)k))).ToArray(); __instance.revolverRicochet = rocketRed; SetPref("rev2", value.Alt); break; } case 2: { List<GameObject> list13 = ((IEnumerable<AssetReference>)__instance.revolverTwirl).Select((Func<AssetReference, GameObject>)((AssetReference k) => (GameObject)k.Asset)).ToList(); EnumerableExt.ReplaceOrAddTo<GameObject>(list13, value.Prefab, num); AssetReference[] rocketRed = (AssetReference[])(object)((IEnumerable<GameObject>)list13).Select((Func<GameObject, UKAsset>)((GameObject k) => new UKAsset((Object)(object)k))).ToArray(); __instance.revolverTwirl = rocketRed; SetPref("rev1", value.Alt); break; } } break; case 1: switch (value.Variant) { case 0: { List<GameObject> list12 = ((IEnumerable<AssetReference>)__instance.shotgunGrenade).Select((Func<AssetReference, GameObject>)((AssetReference k) => (GameObject)k.Asset)).ToList(); EnumerableExt.ReplaceOrAddTo<GameObject>(list12, value.Prefab, num); AssetReference[] rocketRed = (AssetReference[])(object)((IEnumerable<GameObject>)list12).Select((Func<GameObject, UKAsset>)((GameObject k) => new UKAsset((Object)(object)k))).ToArray(); __instance.shotgunGrenade = rocketRed; SetPref("sho0", value.Alt); break; } case 1: { List<GameObject> list11 = ((IEnumerable<AssetReference>)__instance.shotgunPump).Select((Func<AssetReference, GameObject>)((AssetReference k) => (GameObject)k.Asset)).ToList(); EnumerableExt.ReplaceOrAddTo<GameObject>(list11, value.Prefab, num); AssetReference[] rocketRed = (AssetReference[])(object)((IEnumerable<GameObject>)list11).Select((Func<GameObject, UKAsset>)((GameObject k) => new UKAsset((Object)(object)k))).ToArray(); __instance.shotgunPump = rocketRed; SetPref("sho1", value.Alt); break; } case 2: { List<GameObject> list10 = ((IEnumerable<AssetReference>)__instance.shotgunRed).Select((Func<AssetReference, GameObject>)((AssetReference k) => (GameObject)k.Asset)).ToList(); EnumerableExt.ReplaceOrAddTo<GameObject>(list10, value.Prefab, num); AssetReference[] rocketRed = (AssetReference[])(object)((IEnumerable<GameObject>)list10).Select((Func<GameObject, UKAsset>)((GameObject k) => new UKAsset((Object)(object)k))).ToArray(); __instance.shotgunRed = rocketRed; SetPref("sho2", value.Alt); break; } } break; case 2: switch (value.Variant) { case 0: { List<GameObject> list9 = ((IEnumerable<AssetReference>)__instance.nailMagnet).Select((Func<AssetReference, GameObject>)((AssetReference k) => (GameObject)k.Asset)).ToList(); EnumerableExt.ReplaceOrAddTo<GameObject>(list9, value.Prefab, num); AssetReference[] rocketRed = (AssetReference[])(object)((IEnumerable<GameObject>)list9).Select((Func<GameObject, UKAsset>)((GameObject k) => new UKAsset((Object)(object)k))).ToArray(); __instance.nailMagnet = rocketRed; SetPref("nai0", value.Alt); break; } case 1: { List<GameObject> list8 = ((IEnumerable<AssetReference>)__instance.nailOverheat).Select((Func<AssetReference, GameObject>)((AssetReference k) => (GameObject)k.Asset)).ToList(); EnumerableExt.ReplaceOrAddTo<GameObject>(list8, value.Prefab, num); AssetReference[] rocketRed = (AssetReference[])(object)((IEnumerable<GameObject>)list8).Select((Func<GameObject, UKAsset>)((GameObject k) => new UKAsset((Object)(object)k))).ToArray(); __instance.nailOverheat = rocketRed; SetPref("nai1", value.Alt); break; } case 2: { List<GameObject> list7 = ((IEnumerable<AssetReference>)__instance.nailRed).Select((Func<AssetReference, GameObject>)((AssetReference k) => (GameObject)k.Asset)).ToList(); EnumerableExt.ReplaceOrAddTo<GameObject>(list7, value.Prefab, num); AssetReference[] rocketRed = (AssetReference[])(object)((IEnumerable<GameObject>)list7).Select((Func<GameObject, UKAsset>)((GameObject k) => new UKAsset((Object)(object)k))).ToArray(); __instance.nailRed = rocketRed; SetPref("nai2", value.Alt); break; } } break; case 3: switch (value.Variant) { case 0: { List<GameObject> list6 = ((IEnumerable<AssetReference>)__instance.railCannon).Select((Func<AssetReference, GameObject>)((AssetReference k) => (GameObject)k.Asset)).ToList(); EnumerableExt.ReplaceOrAddTo<GameObject>(list6, value.Prefab, num); AssetReference[] rocketRed = (AssetReference[])(object)((IEnumerable<GameObject>)list6).Select((Func<GameObject, UKAsset>)((GameObject k) => new UKAsset((Object)(object)k))).ToArray(); __instance.railCannon = rocketRed; SetPref("rai0", value.Alt); break; } case 1: { List<GameObject> list5 = ((IEnumerable<AssetReference>)__instance.railHarpoon).Select((Func<AssetReference, GameObject>)((AssetReference k) => (GameObject)k.Asset)).ToList(); EnumerableExt.ReplaceOrAddTo<GameObject>(list5, value.Prefab, num); AssetReference[] rocketRed = (AssetReference[])(object)((IEnumerable<GameObject>)list5).Select((Func<GameObject, UKAsset>)((GameObject k) => new UKAsset((Object)(object)k))).ToArray(); __instance.railHarpoon = rocketRed; SetPref("rai1", value.Alt); break; } case 2: { List<GameObject> list4 = ((IEnumerable<AssetReference>)__instance.railMalicious).Select((Func<AssetReference, GameObject>)((AssetReference k) => (GameObject)k.Asset)).ToList(); EnumerableExt.ReplaceOrAddTo<GameObject>(list4, value.Prefab, num); AssetReference[] rocketRed = (AssetReference[])(object)((IEnumerable<GameObject>)list4).Select((Func<GameObject, UKAsset>)((GameObject k) => new UKAsset((Object)(object)k))).ToArray(); __instance.railMalicious = rocketRed; SetPref("rai2", value.Alt); break; } } break; case 4: switch (value.Variant) { case 0: { List<GameObject> list3 = ((IEnumerable<AssetReference>)__instance.rocketBlue).Select((Func<AssetReference, GameObject>)((AssetReference k) => (GameObject)k.Asset)).ToList(); EnumerableExt.ReplaceOrAddTo<GameObject>(list3, value.Prefab, num); AssetReference[] rocketRed = (AssetReference[])(object)((IEnumerable<GameObject>)list3).Select((Func<GameObject, UKAsset>)((GameObject k) => new UKAsset((Object)(object)k))).ToArray(); __instance.rocketBlue = rocketRed; SetPref("rock0", value.Alt); break; } case 1: { List<GameObject> list2 = ((IEnumerable<AssetReference>)__instance.rocketGreen).Select((Func<AssetReference, GameObject>)((AssetReference k) => (GameObject)k.Asset)).ToList(); EnumerableExt.ReplaceOrAddTo<GameObject>(list2, value.Prefab, num); AssetReference[] rocketRed = (AssetReference[])(object)((IEnumerable<GameObject>)list2).Select((Func<GameObject, UKAsset>)((GameObject k) => new UKAsset((Object)(object)k))).ToArray(); __instance.rocketGreen = rocketRed; SetPref("rock1", value.Alt); break; } case 2: { List<GameObject> list = ((IEnumerable<AssetReference>)__instance.rocketRed).Select((Func<AssetReference, GameObject>)((AssetReference k) => (GameObject)k.Asset)).ToList(); EnumerableExt.ReplaceOrAddTo<GameObject>(list, value.Prefab, num); AssetReference[] rocketRed = (AssetReference[])(object)((IEnumerable<GameObject>)list).Select((Func<GameObject, UKAsset>)((GameObject k) => new UKAsset((Object)(object)k))).ToArray(); __instance.rocketRed = rocketRed; SetPref("rock2", value.Alt); break; } } break; } } } [HarmonyPatch("ResetWeapons")] [HarmonyPostfix] private static void ResetWeaponsPostfix(GunSetter __instance) { //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) foreach (List<GameObject> modSlot in modSlots) { foreach (GameObject item in modSlot) { if (Object.op_Implicit((Object)(object)item)) { Object.Destroy((Object)(object)item); } } if ((__instance.gunc?.slots?.Contains(modSlot)).GetValueOrDefault()) { __instance.gunc.slots.Remove(modSlot); } } modSlots.Clear(); foreach (KeyValuePair<string, List<Weapon>> item2 in Registries.weap_registry) { foreach (Weapon item3 in item2.Value) { if (!item3.Unlocked) { continue; } List<GameObject> list = new List<GameObject>(); SaveData.Internal_SetValue<string, int[]>(SaveData.data.weapon_order, item3.modName + "." + item3.id, item3.equipOrder); SaveData.Internal_SetValue<string, int[]>(SaveData.data.weapon_status, item3.modName + "." + item3.id, item3.equipStatus); for (int i = 0; i < item3.All_Variants.Length; i++) { GameObject key = item3.All_Variants[i]; if (!equippedDict.ContainsKey(key)) { int num = (int)Mathf.Repeat((float)i, (float)item3.Variants.Length); bool value = (i < item3.Variants.Length && item3.equipStatus[num] == 1) || (i >= item3.Variants.Length && item3.equipStatus[num] == 2); equippedDict.Add(key, value); } } for (int j = 0; j < item3.Variants.Length; j++) { int num2 = EnumerableExt.FindIndexOf<int>((IEnumerable<int>)item3.equipOrder, j); GameObject val = ((item3.equipStatus[num2] == 2) ? item3.AltVariants[num2] : item3.Variants[num2]); if (equippedDict[val]) { GameObject val2 = Object.Instantiate<GameObject>(val, ((Component)__instance).transform); val2.SetActive(false); GraphicsUtilities.RenderObject<Transform>(val2.transform, LayerMask.op_Implicit(LayerMask.NameToLayer("AlwaysOnTop"))); WeaponIcon val3 = val2.AddComponent<WeaponIcon>(); val3.weaponDescriptor = ScriptableObject.CreateInstance<WeaponDescriptor>(); val3.weaponDescriptor.icon = item3.Icons[j]; val3.weaponDescriptor.glowIcon = item3.Icons[j]; val3.weaponDescriptor.variationColor = (WeaponVariant)j; val3.variationColoredRenderers = (Renderer[])(((object)(from k in val2.GetComponentsInChildren<Renderer>() where ((Object)k.material).name.Contains(".var") select k).ToArray()) ?? ((object)new Renderer[0])); val3.variationColoredImages = (Image[])(object)new Image[0]; MonoSingleton<StyleHUD>.Instance.weaponFreshness.Add(val2, 10f); list.Add(val2); __instance.gunc.allWeapons.Add(val2); } } __instance.gunc.slots.Add(list); modSlots.Add(list); } } UltrakitInputManager.UpdateKeyBinds(); } } [HarmonyPatch(typeof(GunControl))] internal class GunControlPatch { [HarmonyPatch("Start")] [HarmonyPrefix] private static void StartPrefix(GunControl __instance) { if (PlayerPrefs.GetInt("CurSlo", 1) > __instance.slots.Count) { PlayerPrefs.SetInt("CurSlo", 1); } } [HarmonyPatch("Update")] [HarmonyPostfix] private static void UpdatePostfix(GunControl __instance) { InputActionState slot = UltrakitInputManager.Slot7; if (slot != null && slot.WasPerformedThisFrame && __instance.slots.Count >= 7) { List<GameObject> list = __instance.slots[6]; if ((list != null && list.Count > 0) || __instance.currentSlot != 7) { List<GameObject> list2 = __instance.slots[6]; if (list2 != null && list2.Count > 0 && (Object)(object)__instance.slots[6][0] != (Object)null) { __instance.SwitchWeapon(7, __instance.slots[6], false, false, false); } } } InputActionState slot2 = UltrakitInputManager.Slot8; if (slot2 != null && slot2.WasPerformedThisFrame && __instance.slots.Count >= 8) { List<GameObject> list3 = __instance.slots[7]; if ((list3 != null && list3.Count > 0) || __instance.currentSlot != 8) { List<GameObject> list4 = __instance.slots[7]; if (list4 != null && list4.Count > 0 && (Object)(object)__instance.slots[7][0] != (Object)null) { __instance.SwitchWeapon(8, __instance.slots[7], false, false, false); } } } InputActionState slot3 = UltrakitInputManager.Slot9; if (slot3 != null && slot3.WasPerformedThisFrame && __instance.slots.Count >= 9) { List<GameObject> list5 = __instance.slots[8]; if ((list5 != null && list5.Count > 0) || __instance.currentSlot != 9) { List<GameObject> list6 = __instance.slots[8]; if (list6 != null && list6.Count > 0 && (Object)(object)__instance.slots[8][0] != (Object)null) { __instance.SwitchWeapon(9, __instance.slots[8], false, false, false); } } } InputActionState slot4 = UltrakitInputManager.Slot10; if (slot4 != null && slot4.WasPerformedThisFrame && __instance.slots.Count >= 10) { List<GameObject> list7 = __instance.slots[9]; if ((list7 != null && list7.Count > 0) || __instance.currentSlot != 10) { List<GameObject> list8 = __instance.slots[9]; if (list8 != null && list8.Count > 0 && (Object)(object)__instance.slots[9][0] != (Object)null) { __instance.SwitchWeapon(10, __instance.slots[9], false, false, false); } } } InputActionState slot5 = UltrakitInputManager.Slot11; if (slot5 != null && slot5.WasPerformedThisFrame && __instance.slots.Count >= 11) { List<GameObject> list9 = __instance.slots[10]; if ((list9 != null && list9.Count > 0) || __instance.currentSlot != 11) { List<GameObject> list10 = __instance.slots[10]; if (list10 != null && list10.Count > 0 && (Object)(object)__instance.slots[10][0] != (Object)null) { __instance.SwitchWeapon(11, __instance.slots[10], false, false, false); } } } InputActionState slot6 = UltrakitInputManager.Slot12; if (slot6 != null && slot6.WasPerformedThisFrame && __instance.slots.Count >= 12) { List<GameObject> list11 = __instance.slots[11]; if ((list11 != null && list11.Count > 0) || __instance.currentSlot != 12) { List<GameObject> list12 = __instance.slots[11]; if (list12 != null && list12.Count > 0 && (Object)(object)__instance.slots[11][0] != (Object)null) { __instance.SwitchWeapon(12, __instance.slots[11], false, false, false); } } } InputActionState slot7 = UltrakitInputManager.Slot13; if (slot7 != null && slot7.WasPerformedThisFrame && __instance.slots.Count >= 13) { List<GameObject> list13 = __instance.slots[12]; if ((list13 != null && list13.Count > 0) || __instance.currentSlot != 13) { List<GameObject> list14 = __instance.slots[12]; if (list14 != null && list14.Count > 0 && (Object)(object)__instance.slots[12][0] != (Object)null) { __instance.SwitchWeapon(13, __instance.slots[12], false, false, false); } } } InputActionState slot8 = UltrakitInputManager.Slot14; if (slot8 != null && slot8.WasPerformedThisFrame && __instance.slots.Count >= 14) { List<GameObject> list15 = __instance.slots[13]; if ((list15 != null && list15.Count > 0) || __instance.currentSlot != 14) { List<GameObject> list16 = __instance.slots[13]; if (list16 != null && list16.Count > 0 && (Object)(object)__instance.slots[13][0] != (Object)null) { __instance.SwitchWeapon(14, __instance.slots[13], false, false, false); } } } InputActionState slot9 = UltrakitInputManager.Slot15; if (slot9 != null && slot9.WasPerformedThisFrame && __instance.slots.Count >= 15) { List<GameObject> list17 = __instance.slots[14]; if ((list17 != null && list17.Count > 0) || __instance.currentSlot != 15) { List<GameObject> list18 = __instance.slots[14]; if (list18 != null && list18.Count > 0 && (Object)(object)__instance.slots[14][0] != (Object)null) { __instance.SwitchWeapon(15, __instance.slots[14], false, false, false); } } } InputActionState slot10 = UltrakitInputManager.Slot16; if (slot10 != null && slot10.WasPerformedThisFrame && __instance.slots.Count >= 16) { List<GameObject> list19 = __instance.slots[15]; if ((list19 != null && list19.Count > 0) || __instance.currentSlot != 16) { List<GameObject> list20 = __instance.slots[15]; if (list20 != null && list20.Count > 0 && (Object)(object)__instance.slots[15][0] != (Object)null) { __instance.SwitchWeapon(16, __instance.slots[15], false, false, false); } } } InputActionState slot11 = UltrakitInputManager.Slot17; if (slot11 != null && slot11.WasPerformedThisFrame && __instance.slots.Count >= 17) { List<GameObject> list21 = __instance.slots[16]; if ((list21 != null && list21.Count > 0) || __instance.currentSlot != 17) { List<GameObject> list22 = __instance.slots[16]; if (list22 != null && list22.Count > 0 && (Object)(object)__instance.slots[16][0] != (Object)null) { __instance.SwitchWeapon(17, __instance.slots[16], false, false, false); } } } InputActionState slot12 = UltrakitInputManager.Slot18; if (slot12 != null && slot12.WasPerformedThisFrame && __instance.slots.Count >= 18) { List<GameObject> list23 = __instance.slots[17]; if ((list23 != null && list23.Count > 0) || __instance.currentSlot != 18) { List<GameObject> list24 = __instance.slots[17]; if (list24 != null && list24.Count > 0 && (Object)(object)__instance.slots[17][0] != (Object)null) { __instance.SwitchWeapon(18, __instance.slots[17], false, false, false); } } } InputActionState slot13 = UltrakitInputManager.Slot19; if (slot13 != null && slot13.WasPerformedThisFrame && __instance.slots.Count >= 19) { List<GameObject> list25 = __instance.slots[18]; if ((list25 != null && list25.Count > 0) || __instance.currentSlot != 19) { List<GameObject> list26 = __instance.slots[18]; if (list26 != null && list26.Count > 0 && (Object)(object)__instance.slots[18][0] != (Object)null) { __instance.SwitchWeapon(19, __instance.slots[18], false, false, false); } } } InputActionState slot14 = UltrakitInputManager.Slot20; if (slot14 == null || !slot14.WasPerformedThisFrame || __instance.slots.Count < 20) { return; } List<GameObject> list27 = __instance.slots[19]; if ((list27 != null && list27.Count > 0) || __instance.currentSlot != 20) { List<GameObject> list28 = __instance.slots[19]; if (list28 != null && list28.Count > 0 && (Object)(object)__instance.slots[19][0] != (Object)null) { __instance.SwitchWeapon(20, __instance.slots[19], false, false, false); } } } } [HarmonyPatch(typeof(GameProgressSaver))] public class GameProgressSaverPatch { public static List<string> loadedWeapons = new List<string>(); [HarmonyPatch("CheckGear")] [HarmonyPostfix] private static void ChechGearPostfix(ref object __result, string gear) { if (loadedWeapons.Contains(gear)) { __result = 1; } } } [HarmonyPatch(typeof(StyleHUD))] public class StyleHUDPatch { [HarmonyPatch("Start")] [HarmonyPrefix] private static void StartPrefix(StyleHUD __instance) { __instance.weaponFreshness = new Dictionary<GameObject, float>(); } } }