using System; using System.CodeDom.Compiler; using System.Collections; using System.Collections.Generic; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Dawn; using Dawn.Interfaces; using Dawn.Internal; using Dawn.Utils; using DunGen; using DunGen.Graph; using DunGenPlus; using EasyTextEffects; using EasyTextEffects.Effects; using GameNetcodeStuff; using GoodItemScan; using HarmonyLib; using IL; using IL.GameNetcodeStuff; using InjectionLibrary.Attributes; using LethalConfig.AutoConfig; using LethalConfig.ConfigItems; using LethalLevelLoader; using LethalLib.Modules; using LethalQuantities.Objects; using LethalQuantities.Patches; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using MrovLib.Events; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using On; using On.BepInEx.Configuration; using On.DunGen; using On.GameNetcodeStuff; using On.TMPro; using On.Unity.Netcode; using PathfindingLib.API.SmartPathfinding; using Steamworks; using Steamworks.Data; using TMPro; using TerminalFormatter.Nodes; using Unity.Netcode; using Unity.Netcode.Components; using UnityEngine; using UnityEngine.AI; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.InputSystem.Utilities; using UnityEngine.Pool; using UnityEngine.Rendering; using UnityEngine.Rendering.HighDefinition; using UnityEngine.SceneManagement; using UnityEngine.Serialization; using UnityEngine.UI; using UnityEngine.Video; using WeatherRegistry; using com.github.teamxiaolan.dawnlib.NetcodePatcher; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: RequiresInjections] [assembly: InternalsVisibleTo("com.github.teamxiaolan.dawnlib.dusk")] [assembly: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("DunGen")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")] [assembly: IgnoresAccessChecksTo("DunGenPlus")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("GoodItemScan")] [assembly: IgnoresAccessChecksTo("LethalConfig")] [assembly: IgnoresAccessChecksTo("LethalLevelLoader")] [assembly: IgnoresAccessChecksTo("LethalLib")] [assembly: IgnoresAccessChecksTo("LethalQuantities")] [assembly: IgnoresAccessChecksTo("MMHOOK_Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("MMHOOK_BepInEx")] [assembly: IgnoresAccessChecksTo("MMHOOK_BepInEx.Preloader")] [assembly: IgnoresAccessChecksTo("MMHOOK_DunGen")] [assembly: IgnoresAccessChecksTo("MMHOOK_Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("MMHOOK_Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("MMHOOK_UnityEngine.CoreModule")] [assembly: IgnoresAccessChecksTo("MrovLib")] [assembly: IgnoresAccessChecksTo("StarlancerAI")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")] [assembly: IgnoresAccessChecksTo("Unity.XR.Management")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")] [assembly: IgnoresAccessChecksTo("WeatherRegistry")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("XuXiaolan,loaforc")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("A modern API for Lethal Company content and all sizes of mods.")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+75bd30d5352a35f1657d9c13965f4155c465bcd3")] [assembly: AssemblyProduct("DawnLib")] [assembly: AssemblyTitle("com.github.teamxiaolan.dawnlib")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] [CompilerGenerated] internal sealed class <>z__ReadOnlyArray : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { int ICollection.Count => _items.Length; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection.Count => _items.Length; T IReadOnlyList.this[int index] => _items[index]; int ICollection.Count => _items.Length; bool ICollection.IsReadOnly => true; T IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyArray(T[] items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(T item) { return ((ICollection)_items).Contains(item); } void ICollection.CopyTo(T[] array, int arrayIndex) { ((ICollection)_items).CopyTo(array, arrayIndex); } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { return ((IList)_items).IndexOf(item); } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } } namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class ExtensionMarkerAttribute : Attribute { private readonly string k__BackingField; public string Name => k__BackingField; public ExtensionMarkerAttribute(string name) { k__BackingField = name; } } } public sealed class Vector3Converter : JsonConverter { public override void WriteJson(JsonWriter writer, Vector3 value, JsonSerializer serializer) { //IL_0012: 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_0040: Unknown result type (might be due to invalid IL or missing references) writer.WriteStartObject(); writer.WritePropertyName("x"); writer.WriteValue(value.x); writer.WritePropertyName("y"); writer.WriteValue(value.y); writer.WritePropertyName("z"); writer.WriteValue(value.z); writer.WriteEndObject(); } public override Vector3 ReadJson(JsonReader reader, Type objectType, Vector3 existingValue, bool hasExistingValue, JsonSerializer serializer) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Invalid comparison between Unknown and I4 //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Invalid comparison between Unknown and I4 float num = 0f; float num2 = 0f; float num3 = 0f; if ((int)reader.TokenType != 1) { throw new JsonSerializationException("Expected StartObject for Vector3"); } while (reader.Read() && (int)reader.TokenType != 13) { if ((int)reader.TokenType == 4) { string text = (string)reader.Value; reader.Read(); switch (text) { case "x": num = Convert.ToSingle(reader.Value); break; case "y": num2 = Convert.ToSingle(reader.Value); break; case "z": num3 = Convert.ToSingle(reader.Value); break; } } } return new Vector3(num, num2, num3); } } public class DawnDeadBodyNamespacedKeyContainer : MonoBehaviour { [field: SerializeField] public NamespacedKey Value { get; internal set; } public DawnDeadBodyInfo GetDawnDeadBodynfo() { return LethalContent.DeadBodies[Value.AsTyped()]; } } public class DawnMapObjectNamespacedKeyContainer : MonoBehaviour { [field: SerializeField] public NamespacedKey Value { get; internal set; } public DawnMapObjectInfo GetDawnMapObjectInfo() { return LethalContent.MapObjects[Value.AsTyped()]; } } public class DawnStoryLogNamespacedKeyContainer : MonoBehaviour { [field: SerializeField] public NamespacedKey Value { get; internal set; } } namespace Dawn { public abstract class BaseInfoBuilder { internal abstract void SoloAddTags(IEnumerable newTags); } public abstract class BaseInfoBuilder : BaseInfoBuilder where TInfo : INamespaced where TBuilder : BaseInfoBuilder { protected HashSet tags = new HashSet(); protected IDataContainer? customData; protected NamespacedKey key { get; private set; } protected T value { get; private set; } internal BaseInfoBuilder(NamespacedKey key, T value) { this.key = key; this.value = value; } public TBuilder AddTag(NamespacedKey tag) { tags.Add(tag); return (TBuilder)this; } public TBuilder AddTags(IEnumerable newTags) { foreach (NamespacedKey newTag in newTags) { AddTag(newTag); } return (TBuilder)this; } internal override void SoloAddTags(IEnumerable newTags) { AddTags(newTags); } public TBuilder SetCustomData(IDataContainer container) { customData = container ?? throw new ArgumentNullException("container"); return (TBuilder)this; } public TBuilder EditCustomData(Action callback) { if (customData == null) { customData = new DataContainer(); } callback(customData); return (TBuilder)this; } internal abstract TInfo Build(); } [JsonObject(/*Could not decode attribute arguments.*/)] public class DataContainer : IDataContainer { private class NoOpDisposable : IDisposable { public void Dispose() { } } [JsonProperty] protected Dictionary dictionary = new Dictionary(); public IEnumerable Keys => dictionary.Keys; public int Count => dictionary.Count; public bool Has(NamespacedKey key) { return dictionary.ContainsKey(key); } public bool TryGet(NamespacedKey key, [NotNullWhen(true)] out T? value) { if (dictionary.TryGetValue(key, out object value2)) { JToken val = (JToken)((value2 is JToken) ? value2 : null); if (val != null) { value = val.ToObject(); return true; } if (value2 is T val2) { value = val2; return true; } if (typeof(T) == typeof(int) && value2 is long num) { value = (T)(object)(int)num; return true; } if (typeof(T) == typeof(long) && value2 is int num2) { value = (T)(object)(long)num2; return true; } throw new InvalidCastException($"type of '{key}' is {value2.GetType().Name} which can not be {typeof(T).Name}"); } value = default(T); return false; } public T GetOrSetDefault(NamespacedKey key, T defaultValue) { if (TryGet(key, out T value)) { return value; } Set(key, defaultValue); return defaultValue; } public T GetOrCreateDefault(NamespacedKey key) where T : new() { if (TryGet(key, out T value)) { return value; } value = new T(); Set(key, value); return value; } public virtual void Set(NamespacedKey key, T value) { if (value == null) { throw new ArgumentNullException("value"); } dictionary[key] = value; } public virtual void Remove(NamespacedKey key) { dictionary.Remove(key); } public virtual void Clear() { dictionary.Clear(); } public virtual void MarkDirty() { } public virtual IDisposable CreateEditContext() { return new NoOpDisposable(); } public bool Has(NamespacedKey key) { if (dictionary.ContainsKey(key)) { return dictionary[key] is T; } return false; } } public class FrozenEmptyDataContainer : IDataContainer { public static FrozenEmptyDataContainer Instance { get; private set; } = new FrozenEmptyDataContainer(); public IEnumerable Keys { get; } = Array.Empty(); public int Count => 0; private FrozenEmptyDataContainer() { } public bool TryGet(NamespacedKey key, [NotNullWhen(true)] out T? value) { value = default(T); return false; } public T GetOrSetDefault(NamespacedKey key, T defaultValue) { throw new RegistryFrozenException(); } public T GetOrCreateDefault(NamespacedKey key) where T : new() { throw new RegistryFrozenException(); } public void Set(NamespacedKey key, T value) { throw new RegistryFrozenException(); } public void Remove(NamespacedKey key) { throw new RegistryFrozenException(); } public void Clear() { throw new RegistryFrozenException(); } public void MarkDirty() { throw new RegistryFrozenException(); } public IDisposable CreateEditContext() { throw new RegistryFrozenException(); } public bool Has(NamespacedKey key) { throw new NotImplementedException(); } } public interface IDataContainer { IEnumerable Keys { get; } int Count { get; } bool Has(NamespacedKey key); bool TryGet(NamespacedKey key, [NotNullWhen(true)] out T? value); T GetOrSetDefault(NamespacedKey key, T defaultValue); T GetOrCreateDefault(NamespacedKey key) where T : new(); void Set(NamespacedKey key, T value); void Remove(NamespacedKey key); void Clear(); void MarkDirty(); IDisposable CreateEditContext(); } public interface INamespaced { NamespacedKey Key { get; } } public interface INamespaced : INamespaced where T : INamespaced { NamespacedKey TypedKey { get; } } public class JSONTagDefinition { public string Tag; public string[] Values; } public class NamespacedKeyConverter : JsonConverter { public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { if (value is NamespacedKey namespacedKey) { writer.WriteValue(namespacedKey.ToString()); } else { writer.WriteNull(); } } public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_009f: Unknown result type (might be due to invalid IL or missing references) if ((int)reader.TokenType == 11) { return null; } string text = reader.Value?.ToString(); if (text == null) { return null; } NamespacedKey namespacedKey = NamespacedKey.ForceParse(text); if (objectType == typeof(NamespacedKey)) { return namespacedKey; } if (objectType.IsGenericType && objectType.GetGenericTypeDefinition() == typeof(NamespacedKey<>)) { MethodInfo method = typeof(NamespacedKey).GetMethod("AsTyped"); MethodInfo methodInfo = method.MakeGenericMethod(objectType.GetGenericArguments()[0]); return methodInfo.Invoke(namespacedKey, null); } throw new JsonSerializationException($"Cannot deserialize {objectType}"); } public override bool CanConvert(Type objectType) { if (objectType == typeof(NamespacedKey)) { return true; } if (objectType.IsGenericType && objectType.GetGenericTypeDefinition() == typeof(NamespacedKey<>)) { return true; } return false; } } public class NamespacedKeyDictionaryConverter : JsonConverter { public override bool CanConvert(Type objectType) { if (objectType.IsGenericType && objectType.GetGenericTypeDefinition() == typeof(Dictionary<, >)) { return objectType.GetGenericArguments()[0] == typeof(NamespacedKey); } return false; } public override void WriteJson(JsonWriter writer, object? value, JsonSerializer serializer) { writer.WriteStartObject(); IDictionary dictionary = (IDictionary)value; List list = new List(); foreach (object key in dictionary.Keys) { list.Add(key); } foreach (object item in list) { NamespacedKey namespacedKey = (NamespacedKey)item; object obj = dictionary[item]; writer.WritePropertyName(namespacedKey.ToString()); serializer.Serialize(writer, obj); } writer.WriteEndObject(); } public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) { Type type = objectType.GetGenericArguments()[1]; Type type2 = typeof(Dictionary<, >).MakeGenericType(typeof(NamespacedKey), type); IDictionary dictionary = (IDictionary)Activator.CreateInstance(type2); JObject val = JObject.Load(reader); foreach (JProperty item in val.Properties()) { NamespacedKey key = NamespacedKey.ForceParse(item.Name); object value = item.Value.ToObject(type, serializer); dictionary[key] = value; } return dictionary; } } public interface IAdditionalResolvableKeys { IEnumerable AdditionalResolvableKeys(); } [Serializable] public class NamespacedKey : INetworkSerializable { private static readonly Regex NamespacedKeyRegex = new Regex("[?!.\\n\\t\"`\\[\\]'-]"); private static readonly Dictionary NumberWords = new Dictionary { { '0', "Zero" }, { '1', "One" }, { '2', "Two" }, { '3', "Three" }, { '4', "Four" }, { '5', "Five" }, { '6', "Six" }, { '7', "Seven" }, { '8', "Eight" }, { '9', "Nine" } }; public const char Separator = ':'; public const string VanillaNamespace = "lethal_company"; [SerializeField] private string _namespace; [SerializeField] private string _key; public string Namespace => _namespace; public string Key => _key; public ulong NetworkID => ComputeStableHash64(ToString()); internal static string NormalizeStringForNamespacedKey(string input, bool CSharpName) { if (string.IsNullOrWhiteSpace(input)) { return string.Empty; } string text = NamespacedKeyRegex.Replace(input, string.Empty); StringBuilder stringBuilder = new StringBuilder(text.Length); bool flag = false; string text2 = text; foreach (char c in text2) { if (flag || (!char.IsDigit(c) && c != ' ')) { flag = true; stringBuilder.Append(c); } } StringBuilder stringBuilder2 = new StringBuilder(stringBuilder.Length); string text3 = stringBuilder.ToString(); foreach (char c2 in text3) { if (NumberWords.TryGetValue(c2, out string value)) { stringBuilder2.Append(value); } else { stringBuilder2.Append(c2); } } string text4 = stringBuilder2.ToString(); if (CSharpName) { text4 = text4.Replace(" ", string.Empty); text4 = text4.Replace("_", string.Empty); return text4.ToCapitalized(); } return text4.ToLowerInvariant().Replace(" ", "_"); } protected NamespacedKey(string @namespace, string key) { _namespace = NormalizeStringForNamespacedKey(@namespace, CSharpName: false); _key = NormalizeStringForNamespacedKey(key, CSharpName: false); } [EditorBrowsable(EditorBrowsableState.Never)] public NamespacedKey() { } public static NamespacedKey From(string @namespace, string key) { return new NamespacedKey(@namespace, key); } public static NamespacedKey Vanilla(string key) { return From("lethal_company", key); } public static NamespacedKey Parse(string input) { if (string.IsNullOrWhiteSpace(input)) { throw new ArgumentException("Input cannot be null or empty.", "input"); } string[] array = input.Split(':'); if (array.Length != 2 || string.IsNullOrWhiteSpace(array[0]) || string.IsNullOrWhiteSpace(array[1])) { throw new FormatException($"Invalid namespaced key '{input}'. Expected 'namespace{':'}key'."); } return From(array[0], array[1]); } public static bool TryParse(string input, [NotNullWhen(true)] out NamespacedKey? result) { result = null; if (string.IsNullOrWhiteSpace(input)) { return false; } string[] array = input.Split(':'); if (array.Length != 2 || string.IsNullOrWhiteSpace(array[0]) || string.IsNullOrWhiteSpace(array[1])) { return false; } result = From(array[0], array[1]); return true; } public static NamespacedKey ForceParse(string input) { if (string.IsNullOrWhiteSpace(input)) { throw new ArgumentException("Input cannot be null or empty.", "input"); } string[] array = input.Split(':'); if (array.Length == 2) { return From(array[0], array[1]); } string input2 = array[0]; string key = NormalizeStringForNamespacedKey(input2, CSharpName: false); return From("lethal_company", key); } public override string ToString() { return $"{Namespace}{':'}{Key}"; } public void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter { serializer.SerializeValue(ref _namespace, false); serializer.SerializeValue(ref _key, false); } public static bool operator ==(NamespacedKey? left, NamespacedKey? right) { if ((object)left == right) { return true; } if ((object)left == null || (object)right == null) { return false; } return left.Equals(right); } public static bool operator !=(NamespacedKey? left, NamespacedKey? right) { return !(left == right); } public override bool Equals(object? obj) { if (obj == null) { return false; } if (this == obj) { return true; } if (!(obj is NamespacedKey namespacedKey)) { return false; } if (Namespace == namespacedKey.Namespace) { return Key == namespacedKey.Key; } return false; } private static ulong ComputeStableHash64(string value) { ulong num = 14695981039346656037uL; byte[] bytes = Encoding.UTF8.GetBytes(value); byte[] array = bytes; foreach (byte b in array) { num ^= b; num *= 1099511628211L; } return num; } public override int GetHashCode() { return HashCode.Combine(Namespace, Key); } public NamespacedKey AsTyped() where T : INamespaced { return NamespacedKey.From(Namespace, Key); } public bool IsVanilla() { return Namespace == "lethal_company"; } public bool IsModded() { return !IsVanilla(); } } [Serializable] public class NamespacedKey : NamespacedKey where T : INamespaced { protected NamespacedKey(string @namespace, string key) : base(@namespace, key) { } [EditorBrowsable(EditorBrowsableState.Never)] public NamespacedKey() { } public new static NamespacedKey From(string @namespace, string key) { return new NamespacedKey(@namespace, key); } public new static NamespacedKey Vanilla(string key) { return From("lethal_company", key); } public new static NamespacedKey Parse(string input) { if (string.IsNullOrWhiteSpace(input)) { throw new ArgumentException("Input cannot be null or empty.", "input"); } string[] array = input.Split(':'); if (array.Length != 2 || string.IsNullOrWhiteSpace(array[0]) || string.IsNullOrWhiteSpace(array[1])) { throw new FormatException($"Invalid namespaced key '{input}'. Expected 'namespace{':'}key'."); } return From(array[0], array[1]); } } public class NamespacedKeyResolver : IDisposable { public enum MatchType { ExactKey, CompactKey, Fuzzy } private readonly List _keys = new List(); private readonly Dictionary _fullLookup = new Dictionary(StringComparer.OrdinalIgnoreCase); private readonly Dictionary> _keyLookup = new Dictionary>(StringComparer.OrdinalIgnoreCase); private readonly Dictionary> _compactKeyLookup = new Dictionary>(StringComparer.OrdinalIgnoreCase); private readonly Dictionary _cache = new Dictionary(StringComparer.OrdinalIgnoreCase); private readonly bool _allowFuzzyMatching; public NamespacedKeyResolver(IEnumerable keys, bool allowFuzzyMatching = true) { _allowFuzzyMatching = allowFuzzyMatching; foreach (NamespacedKey key in keys) { AddKey(key); } } public List Resolve(IEnumerable inputs) { List list = new List(); foreach (string input in inputs) { if (TryResolve(input, out NamespacedKey key)) { list.Add(key); } } return list; } public bool TryResolve(string input, [NotNullWhen(true)] out NamespacedKey? key) { key = null; if (string.IsNullOrWhiteSpace(input)) { return false; } string text = input.Trim(); if (_cache.TryGetValue(text, out key)) { return key != null; } key = ResolveInternal(text); _cache[text] = key; if (key == null) { Debuggers.NamespacedKeys?.Log("Could not resolve NamespacedKey input '" + input + "'."); return false; } return true; } private NamespacedKey? ResolveInternal(string input) { if (TryResolveFullKey(input, out NamespacedKey key)) { return key; } string text = NamespacedKey.NormalizeStringForNamespacedKey(input, CSharpName: false); string text2 = Compact(text); if (_keyLookup.TryGetValue(text, out List value)) { return PickBestMatch(input, value, MatchType.ExactKey); } if (_compactKeyLookup.TryGetValue(text2, out List value2)) { return PickBestMatch(input, value2, MatchType.CompactKey); } if (_allowFuzzyMatching) { return TryResolveFuzzy(input, text, text2); } return null; } private bool TryResolveFullKey(string input, out NamespacedKey? key) { key = null; if (!input.Contains(':')) { return false; } if (!NamespacedKey.TryParse(input, out NamespacedKey parsed)) { return false; } if (_fullLookup.TryGetValue(parsed.ToString(), out NamespacedKey value)) { key = value; return true; } if (!_allowFuzzyMatching) { return false; } List keys = _keys.Where((NamespacedKey x) => x.Namespace == parsed.Namespace).ToList(); NamespacedKey bestFuzzyMatch = GetBestFuzzyMatch(parsed.Key, keys); if (bestFuzzyMatch == null) { return false; } DawnPlugin.Logger.LogError((object)($"Fuzzy NamespacedKey match used. Input '{input}' resolved to '{bestFuzzyMatch}'. \n" + $"This should be changed to the exact key '{bestFuzzyMatch}'.")); key = bestFuzzyMatch; return true; } private NamespacedKey? TryResolveFuzzy(string rawInput, string normalizedInput, string compactInput) { NamespacedKey bestFuzzyMatch = GetBestFuzzyMatch(normalizedInput, compactInput, _keys); if (bestFuzzyMatch == null) { return null; } DawnPlugin.Logger.LogError((object)($"Fuzzy NamespacedKey match used. Input '{rawInput}' resolved to '{bestFuzzyMatch}'.\n" + $"This should be changed to the exact name '{bestFuzzyMatch.Key}' or full key '{bestFuzzyMatch}'.")); return bestFuzzyMatch; } private NamespacedKey? GetBestFuzzyMatch(string normalizedInput, List keys) { return GetBestFuzzyMatch(normalizedInput, Compact(normalizedInput), keys); } private NamespacedKey? GetBestFuzzyMatch(string normalizedInput, string compactInput, List keys) { int num = int.MaxValue; List list = new List(); foreach (NamespacedKey key2 in keys) { string key = key2.Key; string b = Compact(key); int num2 = Math.Min(LevenshteinDistance(normalizedInput, key), LevenshteinDistance(compactInput, b)); int maxDistance = GetMaxDistance(normalizedInput, key); if (num2 <= maxDistance) { if (num2 < num) { num = num2; list.Clear(); list.Add(key2); } else if (num2 == num) { list.Add(key2); } } } if (list.Count == 0) { return null; } return PickBestMatch(normalizedInput, list, MatchType.Fuzzy); } private NamespacedKey PickBestMatch(string input, List matches, MatchType matchType) { if (matches.Count == 1) { return matches[0]; } NamespacedKey namespacedKey = matches[0]; Debuggers.NamespacedKeys?.Log(BuildMultipleMatchWarning(input, namespacedKey, matches, matchType)); return namespacedKey; } private void AddKey(NamespacedKey key) { _keys.Add(key); _fullLookup[key.ToString()] = key; AddToLookup(_keyLookup, key.Key, key); AddToLookup(_compactKeyLookup, Compact(key.Key), key); } private static void AddToLookup(Dictionary> lookup, string lookupKey, NamespacedKey key) { if (!lookup.TryGetValue(lookupKey, out List value)) { value = (lookup[lookupKey] = new List()); } value.Add(key); } private static string BuildMultipleMatchWarning(string input, NamespacedKey selected, List matches, MatchType matchType) { return $"NamespacedKey input '{input}' matched multiple keys using {matchType} matching.\n" + string.Format("Using '{0}'. Other matches: {1}", selected, string.Join(", ", matches.Where((NamespacedKey x) => !x.Equals(selected)))); } private static string Compact(string value) { return value.Replace("_", string.Empty).Replace(" ", string.Empty).Replace("-", string.Empty) .ToLowerInvariant(); } private static int GetMaxDistance(string a, string b) { int num = Math.Max(a.Length, b.Length); if (num <= 5) { return 1; } if (num <= 12) { return 2; } return 3; } private static int LevenshteinDistance(string a, string b) { int[,] array = new int[a.Length + 1, b.Length + 1]; for (int i = 0; i <= a.Length; i++) { array[i, 0] = i; } for (int j = 0; j <= b.Length; j++) { array[0, j] = j; } for (int k = 1; k <= a.Length; k++) { for (int l = 1; l <= b.Length; l++) { int num = ((a[k - 1] != b[l - 1]) ? 1 : 0); array[k, l] = Math.Min(Math.Min(array[k - 1, l] + 1, array[k, l - 1] + 1), array[k - 1, l - 1] + num); } } return array[a.Length, b.Length]; } public void Dispose() { _keys.Clear(); _fullLookup.Clear(); _keyLookup.Clear(); _compactKeyLookup.Clear(); _cache.Clear(); } } public class NamespacedKeyResolver : IDisposable where T : INamespaced { private readonly NamespacedKeyResolver _resolver; public NamespacedKeyResolver(IEnumerable values, bool allowFuzzyMatching = true) { _resolver = new NamespacedKeyResolver(CollectResolvableKeys(values), allowFuzzyMatching); } private static IEnumerable CollectResolvableKeys(IEnumerable values) { HashSet seen = new HashSet(); foreach (T value in values) { if (seen.Add(value.Key)) { yield return value.Key; } if (value is ITaggable taggable) { foreach (NamespacedKey item in taggable.AllTags()) { if (!(item == null) && seen.Add(item)) { yield return item; } } } if (!(value is IAdditionalResolvableKeys additionalResolvableKeys)) { continue; } foreach (NamespacedKey item2 in additionalResolvableKeys.AdditionalResolvableKeys()) { if (!(item2 == null) && seen.Add(item2)) { yield return item2; } } } } public List> Resolve(IEnumerable inputs) { List> list = new List>(); foreach (string input in inputs) { if (TryResolve(input, out NamespacedKey key)) { list.Add(key); } } return list; } public bool TryResolve(string input, [NotNullWhen(true)] out NamespacedKey? key) { key = null; if (!_resolver.TryResolve(input, out NamespacedKey key2)) { return false; } key = key2.AsTyped(); return true; } public void Dispose() { _resolver.Dispose(); } } public static class NamespacedKeyResolverWeightExtensions { public static List> ResolveWeights(this NamespacedKeyResolver resolver, IEnumerable weights) where T : INamespaced { List> list = new List>(); foreach (UnresolvedNamespacedWeight weight in weights) { ResolvedNamespacedWeight? resolvedNamespacedWeight = resolver.ResolveWeight(weight); if (!resolvedNamespacedWeight.HasValue) { Debuggers.Weights?.Log("Could not resolve weight key input '" + weight.KeyInput + "'."); } else { list.Add(resolvedNamespacedWeight.Value); } } return list; } public static ResolvedNamespacedWeight? ResolveWeight(this NamespacedKeyResolver resolver, UnresolvedNamespacedWeight weight) where T : INamespaced { if (!resolver.TryResolve(weight.KeyInput, out NamespacedKey key)) { return null; } return new ResolvedNamespacedWeight(key, weight.Operation, weight.Value); } } public readonly struct ResolvedNamespacedWeight : IOperationWithValue where T : INamespaced { public NamespacedKey Key { get; } public MathOperation Operation { get; } public float Value { get; } public ResolvedNamespacedWeight(NamespacedKey key, MathOperation operation, float value) { Key = key; Operation = operation; Value = value; } } [Serializable] public readonly struct UnresolvedNamespacedWeight : IOperationWithValue { public string KeyInput { get; } public MathOperation Operation { get; } public float Value { get; } public UnresolvedNamespacedWeight(string keyInput, MathOperation operation, float value) { KeyInput = keyInput; Operation = operation; Value = value; } public override string ToString() { string arg = Operation switch { MathOperation.Additive => "+", MathOperation.Subtractive => "-", MathOperation.Multiplicative => "*", MathOperation.Divisive => "/", _ => "+", }; return $"{KeyInput}={arg}{Value}"; } public static List ConvertManyFromString(string input) { if (string.IsNullOrWhiteSpace(input)) { return new List(); } string[] array = input.Split(',', StringSplitOptions.RemoveEmptyEntries); List list = new List(array.Length); string[] array2 = array; foreach (string text in array2) { list.Add(ConvertFromString(text.Trim())); } return list; } public static UnresolvedNamespacedWeight ConvertFromString(string input) { string[] array = input.Split('=', StringSplitOptions.RemoveEmptyEntries); string keyInput = array[0].Trim(); MathOperation operation = MathOperation.Additive; float result = 0f; if (array.Length > 1 && !string.IsNullOrWhiteSpace(array[1])) { string text = array[1].Trim(); operation = text[0] switch { '+' => MathOperation.Additive, '-' => MathOperation.Subtractive, '*' => MathOperation.Multiplicative, '/' => MathOperation.Divisive, _ => MathOperation.Additive, }; if (!float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out result) && (text.Length <= 1 || !float.TryParse(text.Substring(1), NumberStyles.Float, CultureInfo.InvariantCulture, out result))) { DawnPlugin.Logger.LogWarning((object)("Invalid weight value in config input: " + input)); result = 0f; } } return new UnresolvedNamespacedWeight(keyInput, operation, Mathf.Abs(result)); } } public class PersistentDataContainer : DataContainer { public class EditContext : IDisposable { private PersistentDataContainer _container; private bool _prevAutoSave; public EditContext(PersistentDataContainer container) { _container = container; _prevAutoSave = _container.AutoSave; _container.AutoSave = false; } public void Dispose() { _container.AutoSave = _prevAutoSave; _container.MarkDirty(); } } private string _filePath; private readonly SemaphoreSlim _saveLock = new SemaphoreSlim(1, 1); public bool AutoSave { get; private set; } = true; internal static List HasCorruptedData { get; private set; } = new List(); public string FileName => Path.GetFileName(_filePath); public PersistentDataContainer(string filePath) { Debuggers.PersistentDataContainer?.Log("new PersistentDataContainer: " + Path.GetFileName(filePath)); _filePath = filePath; if (!File.Exists(filePath)) { return; } Debuggers.PersistentDataContainer?.Log("loading existing file"); try { dictionary = JsonConvert.DeserializeObject>(File.ReadAllText(_filePath), DawnLib.JSONSettings); } catch (Exception arg) { DawnPlugin.Logger.LogFatal((object)$"Exception when loading from persistent data container ({Path.GetFileName(_filePath)}):\n{arg}"); HasCorruptedData.Add(this); return; } if (dictionary == null) { DawnPlugin.Logger.LogFatal((object)("Failure when loading from persistent data container (" + Path.GetFileName(_filePath) + "), file likely corrupted, please delete.")); HasCorruptedData.Add(this); return; } foreach (object value in dictionary.Values) { if (value is ChildPersistentDataContainer childPersistentDataContainer) { Debuggers.PersistentDataContainer?.Log(string.Format("updated parent for a loaded persistent data container. count = {0}: {1}", childPersistentDataContainer.Count, string.Join(", ", childPersistentDataContainer.Keys.Select((NamespacedKey it) => it.ToString())))); childPersistentDataContainer.Internal_SetParent(this); } } Debuggers.PersistentDataContainer?.Log($"loaded {dictionary.Count} entries."); } public override void Set(NamespacedKey key, T value) { if (value is IDataContainer && !(value is ChildPersistentDataContainer)) { throw new NotSupportedException($"{key} is a {value.GetType().Name}, which is not supported by persistent data container. Only ChildPersistentDataContainer is supported."); } if (value is ChildPersistentDataContainer childPersistentDataContainer && childPersistentDataContainer.Parent != this) { throw new NotSupportedException($"{key} is a child persistent data container being added to '{FileName}' when it belongs to '{childPersistentDataContainer.Parent.FileName}'."); } base.Set(key, value); if (AutoSave) { Task.Run((Func)SaveAsync); } } public override void Clear() { base.Clear(); if (AutoSave) { MarkDirty(); } } public override void Remove(NamespacedKey key) { base.Remove(key); if (AutoSave) { MarkDirty(); } } [Obsolete("Use CreateEditContext()")] public IDisposable LargeEdit() { return CreateEditContext(); } public override IDisposable CreateEditContext() { return new EditContext(this); } public override void MarkDirty() { Task.Run((Func)SaveAsync); } private async Task SaveAsync() { Debuggers.PersistentDataContainer?.Log("saving (" + Path.GetFileName(_filePath) + ")"); await _saveLock.WaitAsync().ConfigureAwait(continueOnCapturedContext: false); try { await using FileStream stream = new FileStream(_filePath, FileMode.Create, FileAccess.Write, FileShare.None, 4096, useAsync: true); await using StreamWriter writer = new StreamWriter(stream, Encoding.UTF8); string value = JsonConvert.SerializeObject((object)dictionary, DawnLib.JSONSettings); await writer.WriteAsync(value).ConfigureAwait(continueOnCapturedContext: false); await writer.FlushAsync().ConfigureAwait(continueOnCapturedContext: false); await stream.FlushAsync().ConfigureAwait(continueOnCapturedContext: false); Debuggers.PersistentDataContainer?.Log("saved (" + Path.GetFileName(_filePath) + ")"); } catch (Exception arg) { DawnPlugin.Logger.LogError((object)$"Error happened while trying to save PersistentDataContainer ({Path.GetFileName(_filePath)}):\n{arg}"); } finally { _saveLock.Release(); } } internal void DeleteFile() { File.Delete(_filePath); } } public class ChildPersistentDataContainer : DataContainer { public PersistentDataContainer Parent { get; private set; } internal ChildPersistentDataContainer() { } public ChildPersistentDataContainer(PersistentDataContainer parent) { Parent = parent; } public override void MarkDirty() { if (Parent.AutoSave) { Parent.MarkDirty(); } } public override IDisposable CreateEditContext() { return Parent.CreateEditContext(); } internal void Internal_SetParent(PersistentDataContainer parent) { Parent = parent; } } public abstract class DawnBaseInfo : INamespaced, INamespaced, ITaggable, IRegistryEvents where T : DawnBaseInfo { private HashSet _tags; private IDataContainer? _customData; public IDataContainer CustomData { get { if (_customData == null) { _customData = new DataContainer(); } return _customData; } } public NamespacedKey Key => TypedKey; public NamespacedKey TypedKey { get; } protected DawnBaseInfo(NamespacedKey key, HashSet tags, IDataContainer? customData) { TypedKey = key; _tags = tags; _customData = customData; } public bool HasTag(NamespacedKey tag) { return _tags.Contains(tag); } public IEnumerable AllTags() { return _tags; } internal void Internal_AddTag(NamespacedKey tag) { Debuggers.Tags?.Log($"Internal_AddTag: {tag} !!!"); _tags.Add(tag); } public void OnFrozen() { if (_customData == null) { _customData = FrozenEmptyDataContainer.Instance; } } public bool ShouldSkipIgnoreOverride() { if (!Key.IsVanilla() && !HasTag(DawnLibTags.IsExternal)) { return HasTag(Tags.Unimplemented); } return true; } public bool ShouldSkipRespectOverride() { if (ShouldSkipIgnoreOverride()) { return !HasTag(DawnLibTags.LunarConfig); } return false; } } public class DawnInfoContainer : MonoBehaviour where T : DawnBaseInfo { public T Value { get; internal set; } } public static class DawnLib { public const string PLUGIN_GUID = "com.github.teamxiaolan.dawnlib"; internal static readonly JsonSerializerSettings JSONSettings = new JsonSerializerSettings { ReferenceLoopHandling = (ReferenceLoopHandling)1, PreserveReferencesHandling = (PreserveReferencesHandling)0, TypeNameHandling = (TypeNameHandling)3, Formatting = (Formatting)1, Converters = new List(3) { (JsonConverter)(object)new NamespacedKeyConverter(), (JsonConverter)(object)new NamespacedKeyDictionaryConverter(), (JsonConverter)(object)new Vector3Converter() } }; private static PersistentDataContainer? _profileContainer; public static DawnWeightSystem Weights { get; } = new DawnWeightSystem(); public static PersistentDataContainer? GetCurrentSave() { return NetworkSingleton.Instance?.SaveContainer; } public static PersistentDataContainer? GetCurrentContract() { return NetworkSingleton.Instance?.ContractContainer; } public static PersistentDataContainer GetCurrentInstallSave() { if (_profileContainer == null) { _profileContainer = new PersistentDataContainer(Path.Combine(Paths.BepInExRootPath, "DawnLib.dawndata")); } return _profileContainer; } public static void RegisterNetworkPrefab(GameObject prefab) { if (!Object.op_Implicit((Object)(object)prefab)) { throw new ArgumentNullException("prefab"); } MiscFixesPatch.networkPrefabsToAdd.Add(prefab); } public static void RegisterNetworkScene(string scenePath) { DawnNetworkSceneManager.AddScenePath(scenePath); } public static void FixMixerGroups(GameObject prefab) { if (!Object.op_Implicit((Object)(object)prefab)) { throw new ArgumentNullException("prefab"); } MiscFixesPatch.soundPrefabsToFix.Add(prefab); } public static void FixDoorwaySockets(GameObject tilePrefab) { if (!Object.op_Implicit((Object)(object)tilePrefab)) { throw new ArgumentNullException("tilePrefab"); } MiscFixesPatch.tilesToFixSockets.Add(tilePrefab); } public static DawnTerminalCommandInfo DefineTerminalCommand(NamespacedKey key, TerminalCommandBasicInformation commandBasicInformation, Action callback) { TerminalCommandInfoBuilder terminalCommandInfoBuilder = new TerminalCommandInfoBuilder(key, commandBasicInformation); callback(terminalCommandInfoBuilder); DawnTerminalCommandInfo dawnTerminalCommandInfo = terminalCommandInfoBuilder.Build(); LethalContent.TerminalCommands.Register(dawnTerminalCommandInfo); return dawnTerminalCommandInfo; } public static DawnDeadBodyInfo DefineDeadBodyInfo(NamespacedKey key, GameObject deadBodyPrefab, Action callback) { DeadBodyInfoBuilder deadBodyInfoBuilder = new DeadBodyInfoBuilder(key, deadBodyPrefab); callback(deadBodyInfoBuilder); DawnDeadBodyInfo dawnDeadBodyInfo = deadBodyInfoBuilder.Build(); DawnStoryLogNamespacedKeyContainer dawnStoryLogNamespacedKeyContainer = deadBodyPrefab.AddComponent(); dawnStoryLogNamespacedKeyContainer.Value = dawnDeadBodyInfo.Key; DeadBodyInfo deadBody = default(DeadBodyInfo); if (dawnDeadBodyInfo.DeadBodyPrefab.TryGetComponent(ref deadBody)) { DeadBodyInfoExtensions.set_DawnInfo(deadBody, dawnDeadBodyInfo); } LethalContent.DeadBodies.Register(dawnDeadBodyInfo); return dawnDeadBodyInfo; } public static DawnRoundLoadingStepInfo DefineRoundLoadingStep(NamespacedKey key, Func loadingContextCallback, Action callback) { RoundLoadingStepInfoBuilder roundLoadingStepInfoBuilder = new RoundLoadingStepInfoBuilder(key, loadingContextCallback); callback(roundLoadingStepInfoBuilder); DawnRoundLoadingStepInfo dawnRoundLoadingStepInfo = roundLoadingStepInfoBuilder.Build(); LethalContent.RoundLoadingSteps.Register(dawnRoundLoadingStepInfo); return dawnRoundLoadingStepInfo; } public static DawnSurfaceInfo DefineSurface(NamespacedKey key, FootstepSurface surface, Action callback) { SurfaceInfoBuilder surfaceInfoBuilder = new SurfaceInfoBuilder(key, surface); callback(surfaceInfoBuilder); DawnSurfaceInfo dawnSurfaceInfo = surfaceInfoBuilder.Build(); FootstepSurfaceExtensions.set_DawnInfo(surface, dawnSurfaceInfo); LethalContent.Surfaces.Register(dawnSurfaceInfo); return dawnSurfaceInfo; } public static DawnStoryLogInfo DefineStoryLog(NamespacedKey key, GameObject storyLogGameObject, Action callback) { StoryLogInfoBuilder storyLogInfoBuilder = new StoryLogInfoBuilder(key, storyLogGameObject); callback(storyLogInfoBuilder); DawnStoryLogInfo dawnStoryLogInfo = storyLogInfoBuilder.Build(); DawnStoryLogNamespacedKeyContainer dawnStoryLogNamespacedKeyContainer = storyLogGameObject.AddComponent(); dawnStoryLogNamespacedKeyContainer.Value = dawnStoryLogInfo.Key; LethalContent.StoryLogs.Register(dawnStoryLogInfo); return dawnStoryLogInfo; } public static DawnDungeonInfo DefineDungeon(NamespacedKey key, string flowName, Action callback) { DungeonFlow val = ScriptableObject.CreateInstance(); ((Object)val).name = flowName; DungeonFlowInfoBuilder dungeonFlowInfoBuilder = new DungeonFlowInfoBuilder(key, val); callback(dungeonFlowInfoBuilder); DawnDungeonInfo dawnDungeonInfo = dungeonFlowInfoBuilder.Build(); DungeonFlowExtensions.set_DawnInfo(val, dawnDungeonInfo); LethalContent.Dungeons.Register(dawnDungeonInfo); return dawnDungeonInfo; } public static DawnTileSetInfo DefineTileSet(NamespacedKey key, TileSet tileSet, Action callback) { TilesetInfoBuilder tilesetInfoBuilder = new TilesetInfoBuilder(key, tileSet); callback(tilesetInfoBuilder); DawnTileSetInfo dawnTileSetInfo = tilesetInfoBuilder.Build(); TileSetExtensions.set_DawnInfo(tileSet, dawnTileSetInfo); LethalContent.TileSets.Register(dawnTileSetInfo); return dawnTileSetInfo; } public static DawnMapObjectInfo DefineMapObject(NamespacedKey key, GameObject mapObject, Action callback) { MapObjectInfoBuilder mapObjectInfoBuilder = new MapObjectInfoBuilder(key, mapObject); callback(mapObjectInfoBuilder); DawnMapObjectInfo dawnMapObjectInfo = mapObjectInfoBuilder.Build(); IIndoorMapHazard val = default(IIndoorMapHazard); if (!mapObject.TryGetComponent(ref val)) { DawnMapObjectNamespacedKeyContainer dawnMapObjectNamespacedKeyContainer = mapObject.AddComponent(); dawnMapObjectNamespacedKeyContainer.Value = dawnMapObjectInfo.Key; } if (dawnMapObjectInfo.InsideInfo != null) { IndoorMapHazardTypeExtensions.set_DawnInfo(dawnMapObjectInfo.InsideInfo.IndoorMapHazardType, dawnMapObjectInfo); } if (dawnMapObjectInfo.OutsideInfo != null) { SpawnableOutsideObjectExtensions.set_DawnInfo(dawnMapObjectInfo.OutsideInfo.SpawnableOutsideObject, dawnMapObjectInfo); } LethalContent.MapObjects.Register(dawnMapObjectInfo); return dawnMapObjectInfo; } public static DawnUnlockableItemInfo DefineUnlockable(NamespacedKey key, UnlockableItem unlockableItem, Action callback) { UnlockableInfoBuilder unlockableInfoBuilder = new UnlockableInfoBuilder(key, unlockableItem); callback(unlockableInfoBuilder); DawnUnlockableItemInfo dawnUnlockableItemInfo = unlockableInfoBuilder.Build(); UnlockableItemExtensions.set_DawnInfo(unlockableItem, dawnUnlockableItemInfo); LethalContent.Unlockables.Register(dawnUnlockableItemInfo); return dawnUnlockableItemInfo; } public static DawnItemInfo DefineItem(NamespacedKey key, Item item, Action callback) { ItemInfoBuilder itemInfoBuilder = new ItemInfoBuilder(key, item); callback(itemInfoBuilder); DawnItemInfo dawnItemInfo = itemInfoBuilder.Build(); ItemExtensions.set_DawnInfo(item, dawnItemInfo); LethalContent.Items.Register(dawnItemInfo); return dawnItemInfo; } public static DawnEnemyInfo DefineEnemy(NamespacedKey key, EnemyType enemy, Action callback) { EnemyInfoBuilder enemyInfoBuilder = new EnemyInfoBuilder(key, enemy); callback(enemyInfoBuilder); DawnEnemyInfo dawnEnemyInfo = enemyInfoBuilder.Build(); EnemyTypeExtensions.set_DawnInfo(enemy, dawnEnemyInfo); LethalContent.Enemies.Register(dawnEnemyInfo); return dawnEnemyInfo; } public static DawnMoonInfo DefineMoon(NamespacedKey key, SelectableLevel level, Action callback) { MoonInfoBuilder moonInfoBuilder = new MoonInfoBuilder(key, level); callback(moonInfoBuilder); DawnMoonInfo dawnMoonInfo = moonInfoBuilder.Build(); SelectableLevelExtensions.set_DawnInfo(level, dawnMoonInfo); LethalContent.Moons.Register(dawnMoonInfo); return dawnMoonInfo; } public static DawnWeatherEffectInfo DefineWeatherEffect(NamespacedKey key, WeatherEffect weather, Action callback) { WeatherEffectInfoBuilder weatherEffectInfoBuilder = new WeatherEffectInfoBuilder(key, weather); callback(weatherEffectInfoBuilder); DawnWeatherEffectInfo dawnWeatherEffectInfo = weatherEffectInfoBuilder.Build(); WeatherEffectExtensions.set_DawnInfo(weather, dawnWeatherEffectInfo); LethalContent.Weathers.Register(dawnWeatherEffectInfo); return dawnWeatherEffectInfo; } public static void ApplyTag(JSONTagDefinition definition) { NamespacedKey namespacedKey = NamespacedKey.Parse(definition.Tag); ListenToRegistry(LethalContent.Moons, namespacedKey); ListenToRegistry(LethalContent.MapObjects, namespacedKey); ListenToRegistry(LethalContent.Enemies, namespacedKey); ListenToRegistry(LethalContent.Items, namespacedKey); ListenToRegistry(LethalContent.Weathers, namespacedKey); ListenToRegistry(LethalContent.Dungeons, namespacedKey); ListenToRegistry(LethalContent.Unlockables, namespacedKey); Debuggers.Tags?.Log($"Scheduled applying tag: {namespacedKey}"); void ListenToRegistry(TaggedRegistry registry, NamespacedKey tag) where T : notnull, DawnBaseInfo { registry.OnFreezeWithContext += delegate { string[] values = definition.Values; foreach (string input in values) { if (registry.TryGetValue(NamespacedKey.Parse(input), out T value)) { value.Internal_AddTag(tag); } } }; } } public static void ApplyAllTagsInFolder(string path) { string[] files = Directory.GetFiles(path, "*.tag.json", SearchOption.AllDirectories); foreach (string path2 in files) { JSONTagDefinition definition = JsonConvert.DeserializeObject(File.ReadAllText(path2)); ApplyTag(definition); } } } public class DawnNamespacedKeyContainer : MonoBehaviour where T : NamespacedKey { public T Value { get; internal set; } } internal static class DeadBodyRegistrationHandler { [CompilerGenerated] private static class <>O { public static hook_Awake <0>__CollectVanillaDeadBodies; } internal static void Init() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__CollectVanillaDeadBodies; if (obj == null) { hook_Awake val = CollectVanillaDeadBodies; <>O.<0>__CollectVanillaDeadBodies = val; obj = (object)val; } StartOfRound.Awake += (hook_Awake)obj; } private static void CollectVanillaDeadBodies(orig_Awake orig, StartOfRound self) { if (LethalContent.DeadBodies.IsFrozen) { orig.Invoke(self); return; } DeadBodyInfo deadBody = default(DeadBodyInfo); foreach (var item3 in self.playerRagdolls.WithIndex()) { int item = item3.index; GameObject item2 = item3.value; string text = NamespacedKey.NormalizeStringForNamespacedKey(((Object)item2).name, CSharpName: true); NamespacedKey namespacedKey = DeadBodyKeys.GetByReflection(text); if (namespacedKey == null) { namespacedKey = NamespacedKey.From("unknown_modded", text); } DawnDeadBodyInfo dawnDeadBodyInfo = new DawnDeadBodyInfo(namespacedKey, new HashSet(), item2, null) { Index = item }; DawnDeadBodyNamespacedKeyContainer dawnDeadBodyNamespacedKeyContainer = item2.AddComponent(); dawnDeadBodyNamespacedKeyContainer.Value = dawnDeadBodyInfo.Key; if (item2.TryGetComponent(ref deadBody)) { DeadBodyInfoExtensions.set_DawnInfo(deadBody, dawnDeadBodyInfo); } LethalContent.DeadBodies.Register(dawnDeadBodyInfo); } foreach (DawnDeadBodyInfo value in LethalContent.DeadBodies.Values) { if (!value.ShouldSkipIgnoreOverride()) { int count = self.playerRagdolls.Count; self.playerRagdolls.Add(value.DeadBodyPrefab); value.Index = count; } } LethalContent.DeadBodies.Freeze(); orig.Invoke(self); } } public sealed class DawnDeadBodyInfo : DawnBaseInfo { public GameObject DeadBodyPrefab { get; } public int Index { get; internal set; } internal DawnDeadBodyInfo(NamespacedKey key, HashSet tags, GameObject deadBodyPrefab, IDataContainer? customData) : base(key, tags, customData) { DeadBodyPrefab = deadBodyPrefab; } } public class DeadBodyInfoBuilder : BaseInfoBuilder { public DeadBodyInfoBuilder(NamespacedKey key, GameObject value) : base(key, value) { } internal override DawnDeadBodyInfo Build() { return new DawnDeadBodyInfo(base.key, tags, base.value, customData); } } public static class DeadBodyInfoExtensions { [SpecialName] public sealed class $A470D541580C35A9FF28AD8B9B478A06 { [SpecialName] public static class $CFBEF7FC135F73CAEF4B193506E3AC03 { } [ExtensionMarker("$CFBEF7FC135F73CAEF4B193506E3AC03")] public DawnDeadBodyInfo DawnInfo { [ExtensionMarker("$CFBEF7FC135F73CAEF4B193506E3AC03")] get { throw new NotSupportedException(); } [ExtensionMarker("$CFBEF7FC135F73CAEF4B193506E3AC03")] set { throw new NotSupportedException(); } } [ExtensionMarker("$CFBEF7FC135F73CAEF4B193506E3AC03")] private DawnDeadBodyInfo GetDawnInfoCore() { throw new NotSupportedException(); } [ExtensionMarker("$CFBEF7FC135F73CAEF4B193506E3AC03")] private void SetDawnInfoCore(DawnDeadBodyInfo dawnBodyInfo) { throw new NotSupportedException(); } } public static DawnDeadBodyInfo get_DawnInfo(DeadBodyInfo deadBody) { return deadBody.GetDawnInfoCore(); } public static void set_DawnInfo(DeadBodyInfo deadBody, DawnDeadBodyInfo value) { deadBody.SetDawnInfoCore(value); } private static DawnDeadBodyInfo GetDawnInfoCore(this DeadBodyInfo deadBody) { return ((IDeadBodyInfoDawnObject)deadBody).DawnInfo; } private static void SetDawnInfoCore(this DeadBodyInfo deadBody, DawnDeadBodyInfo dawnBodyInfo) { ((IDeadBodyInfoDawnObject)deadBody).DawnInfo = dawnBodyInfo; } } public static class PlayerControllerBExtensions { [SpecialName] public sealed class $45B62F97DAFB2E69FE261FE1356619DD { [SpecialName] public static class $C7EFA495105B6AEA9D4C0BF5D9482B99 { } [ExtensionMarker("$C7EFA495105B6AEA9D4C0BF5D9482B99")] public void KillPlayer(Vector3 bodyVelocity, bool spawnBody, CauseOfDeath causeOfDeath, NamespacedKey deathAnimationKey, Vector3 positionOffset, bool setOverrideDropItems) { throw new NotSupportedException(); } } public static void KillPlayer(this PlayerControllerB playerControllerB, Vector3 bodyVelocity, bool spawnBody, CauseOfDeath causeOfDeath, NamespacedKey deathAnimationKey, Vector3 positionOffset, bool setOverrideDropItems) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (LethalContent.DeadBodies.TryGetValue(deathAnimationKey, out DawnDeadBodyInfo value)) { playerControllerB.KillPlayer(bodyVelocity, spawnBody, causeOfDeath, value.Index, positionOffset, setOverrideDropItems); } } public static bool TryGetCurrentDawnSurface(this PlayerControllerB player, [NotNullWhen(true)] out DawnSurface? dawnSurface) { dawnSurface = (DawnSurface)((ICurrentDawnSurface)player).CurrentDawnSurface; return (Object)(object)dawnSurface != (Object)null; } public static void SetCurrentDawnSurface(this PlayerControllerB player, DawnSurface? dawnSurface) { ((ICurrentDawnSurface)player).CurrentDawnSurface = dawnSurface; } } internal static class DungeonRegistrationHandler { [CompilerGenerated] private static class <>O { public static hook_Awake <0>__RegisterDawnDungeons; public static Action, RandomMapObject> <1>__FixRandomMapObjects; public static hook_SetPlanetsWeather <2>__UpdateAllDungeonWeights; public static hook_EndOfGame <3>__UnloadDungeonBundleForAllPlayers; public static hook_Awake <4>__DeleteLLLTranspilerAndEnsureDelayedDungeon; public static hook_Awake <5>__RemoveHotloadingIfDebugDunGenPlus; public static Manipulator <6>__MakeExtraScrapGenerationMoreModular; public static hook_TeleportPlayer <7>__HandleStingerAudio; public static Manipulator <8>__DelayDungeonGeneration; public static Func <9>__LoadDungeonBundle; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Action> <>9__0_0; public static Action> <>9__0_1; public static hook_GenerateNewFloor <>9__0_2; public static Action> <>9__0_3; public static hook_Start <>9__0_4; public static hook_Generate <>9__0_5; public static Func <>9__2_0; public static Func <>9__2_1; public static Func <>9__2_2; public static Func <>9__2_3; public static Func <>9__2_4; public static Func <>9__2_5; public static Func <>9__2_6; public static Func <>9__2_7; public static Func <>9__9_0; public static Func <>9__9_1; public static Func <>9__9_2; public static Func <>9__11_0; public static Func <>9__12_0; public static Func <>9__12_1; public static Func <>9__15_0; public static Func <>9__17_0; internal void b__0_0(NamespacedKeyResolver _) { AddDawnDungeonsToMoons(); } internal void b__0_1(NamespacedKeyResolver _) { CollectNonDawnDungeons(); } internal void b__0_2(orig_GenerateNewFloor orig, RoundManager self) { UpdateDungeonWeightOnLevel(self.currentLevel); orig.Invoke(self); } internal void b__0_3(NamespacedKeyResolver _) { CleanDawnDungeonReferences(); } internal void b__0_4(orig_Start orig, RuntimeDungeon self) { self.GenerateOnStart = false; orig.Invoke(self); } internal void b__0_5(orig_Generate orig, RuntimeDungeon self) { AdjustFireExits(self.Generator.DungeonFlow); TryInjectTileSets(self.Generator.DungeonFlow); orig.Invoke(self); } internal bool b__2_0(Instruction instr) { return ILPatternMatchingExt.MatchLdarg(instr, 0); } internal bool b__2_1(Instruction instr) { return ILPatternMatchingExt.MatchLdfld(instr, "currentDungeonType"); } internal bool b__2_2(Instruction instr) { return ILPatternMatchingExt.MatchLdcI4(instr, 4); } internal bool b__2_3(Instruction instr) { ILLabel val = default(ILLabel); return ILPatternMatchingExt.MatchBneUn(instr, ref val); } internal bool b__2_4(Instruction instr) { return ILPatternMatchingExt.MatchLdloc(instr, 1); } internal bool b__2_5(Instruction instr) { return ILPatternMatchingExt.MatchLdcI4(instr, 6); } internal bool b__2_6(Instruction instr) { return ILPatternMatchingExt.MatchAdd(instr); } internal bool b__2_7(Instruction instr) { return ILPatternMatchingExt.MatchStloc(instr, 1); } internal bool b__9_0(Instruction i) { return ILPatternMatchingExt.MatchLdarg(i, 0); } internal bool b__9_1(Instruction i) { return ILPatternMatchingExt.MatchLdfld(i, "dungeonGenerator"); } internal bool b__9_2(Instruction i) { return ILPatternMatchingExt.MatchCallvirt(i, "Generate"); } internal bool b__11_0() { return NetworkSingleton.Instance.allPlayersDone; } internal bool b__12_0(EntranceTeleport e) { return e.entranceId != 0; } internal bool b__12_1(GlobalPropSettings p) { return p.ID == 1231; } internal DungeonFlow b__15_0(IndoorMapType t) { return t.dungeonFlow; } internal bool b__17_0() { return true; } } private static bool _alreadyPatched = false; private static readonly Dictionary _internalToHumanDungeonNames = new Dictionary { { "LevelOne", "Facility" }, { "LevelTwo", "Mansion" }, { "LevelThree", "Mineshaft" } }; internal static void Init() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //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_013b: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown //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_019f: Expected O, but got Unknown //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Expected O, but got Unknown //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Expected O, but got Unknown //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Expected O, but got Unknown DetourContext val = new DetourContext(int.MaxValue); try { object obj = <>O.<0>__RegisterDawnDungeons; if (obj == null) { hook_Awake val2 = RegisterDawnDungeons; <>O.<0>__RegisterDawnDungeons = val2; obj = (object)val2; } StartOfRound.Awake += (hook_Awake)obj; } finally { ((IDisposable)val)?.Dispose(); } DetourContext val3 = new DetourContext(200); try { DawnPlugin.Hooks.Add(new Hook((MethodBase)AccessTools.DeclaredMethod(typeof(RandomMapObject), "Awake", (Type[])null, (Type[])null), (Delegate)new Action, RandomMapObject>(FixRandomMapObjects))); } finally { ((IDisposable)val3)?.Dispose(); } LethalContent.Moons.OnFreezeWithContext += delegate { AddDawnDungeonsToMoons(); }; LethalContent.Moons.OnFreezeWithContext += delegate { CollectNonDawnDungeons(); }; object obj2 = <>O.<2>__UpdateAllDungeonWeights; if (obj2 == null) { hook_SetPlanetsWeather val4 = UpdateAllDungeonWeights; <>O.<2>__UpdateAllDungeonWeights = val4; obj2 = (object)val4; } StartOfRound.SetPlanetsWeather += (hook_SetPlanetsWeather)obj2; object obj3 = <>O.<3>__UnloadDungeonBundleForAllPlayers; if (obj3 == null) { hook_EndOfGame val5 = UnloadDungeonBundleForAllPlayers; <>O.<3>__UnloadDungeonBundleForAllPlayers = val5; obj3 = (object)val5; } StartOfRound.EndOfGame += (hook_EndOfGame)obj3; object obj4 = <>O.<4>__DeleteLLLTranspilerAndEnsureDelayedDungeon; if (obj4 == null) { hook_Awake val6 = DeleteLLLTranspilerAndEnsureDelayedDungeon; <>O.<4>__DeleteLLLTranspilerAndEnsureDelayedDungeon = val6; obj4 = (object)val6; } MenuManager.Awake += (hook_Awake)obj4; object obj5 = <>O.<5>__RemoveHotloadingIfDebugDunGenPlus; if (obj5 == null) { hook_Awake val7 = RemoveHotloadingIfDebugDunGenPlus; <>O.<5>__RemoveHotloadingIfDebugDunGenPlus = val7; obj5 = (object)val7; } MenuManager.Awake += (hook_Awake)obj5; object obj6 = <>O.<6>__MakeExtraScrapGenerationMoreModular; if (obj6 == null) { Manipulator val8 = MakeExtraScrapGenerationMoreModular; <>O.<6>__MakeExtraScrapGenerationMoreModular = val8; obj6 = (object)val8; } RoundManager.SpawnScrapInLevel += (Manipulator)obj6; object obj7 = <>c.<>9__0_2; if (obj7 == null) { hook_GenerateNewFloor val9 = delegate(orig_GenerateNewFloor orig, RoundManager self) { UpdateDungeonWeightOnLevel(self.currentLevel); orig.Invoke(self); }; <>c.<>9__0_2 = val9; obj7 = (object)val9; } RoundManager.GenerateNewFloor += (hook_GenerateNewFloor)obj7; LethalContent.Dungeons.BeforeFreezeWithContext += delegate { CleanDawnDungeonReferences(); }; object obj8 = <>O.<7>__HandleStingerAudio; if (obj8 == null) { hook_TeleportPlayer val10 = HandleStingerAudio; <>O.<7>__HandleStingerAudio = val10; obj8 = (object)val10; } EntranceTeleport.TeleportPlayer += (hook_TeleportPlayer)obj8; object obj9 = <>c.<>9__0_4; if (obj9 == null) { hook_Start val11 = delegate(orig_Start orig, RuntimeDungeon self) { self.GenerateOnStart = false; orig.Invoke(self); }; <>c.<>9__0_4 = val11; obj9 = (object)val11; } RuntimeDungeon.Start += (hook_Start)obj9; object obj10 = <>c.<>9__0_5; if (obj10 == null) { hook_Generate val12 = delegate(orig_Generate orig, RuntimeDungeon self) { AdjustFireExits(self.Generator.DungeonFlow); TryInjectTileSets(self.Generator.DungeonFlow); orig.Invoke(self); }; <>c.<>9__0_5 = val12; obj10 = (object)val12; } RuntimeDungeon.Generate += (hook_Generate)obj10; } private static void RemoveHotloadingIfDebugDunGenPlus(orig_Awake orig, MenuManager self) { if ((Object)(object)self.versionNumberText == (Object)null) { orig.Invoke(self); return; } if (DungeonGenerationPlusCompat.Enabled && DungeonGenerationPlusCompat.IsDebugOn() && !DungeonGenerationPlusCompat.RemovedHotloading) { DungeonGenerationPlusCompat.RemovedHotloading = true; foreach (DawnDungeonInfo value in LethalContent.Dungeons.Values) { if (!value.ShouldSkipIgnoreOverride()) { AssetBundle val = AssetBundle.LoadFromFile(value.AssetBundlePath); DungeonFlow val2 = val.LoadAsset(((Object)value.DungeonFlow).name ?? ""); if ((Object)(object)val2 == (Object)null) { DawnPlugin.Logger.LogError((object)("Bundle: " + Path.GetFileName(value.AssetBundlePath) + " does not contain DungeonFlow: " + ((Object)value.DungeonFlow).name + ".")); return; } DawnDungeonNetworker.TryApplyLoadedDungeonFlow(val2, val); } } } orig.Invoke(self); } private static void MakeExtraScrapGenerationMoreModular(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel val2 = default(ILLabel); if (!val.TryGotoNext((MoveType)0, new Func[8] { (Instruction instr) => ILPatternMatchingExt.MatchLdarg(instr, 0), (Instruction instr) => ILPatternMatchingExt.MatchLdfld(instr, "currentDungeonType"), (Instruction instr) => ILPatternMatchingExt.MatchLdcI4(instr, 4), (Instruction instr) => ILPatternMatchingExt.MatchBneUn(instr, ref val2), (Instruction instr) => ILPatternMatchingExt.MatchLdloc(instr, 1), (Instruction instr) => ILPatternMatchingExt.MatchLdcI4(instr, 6), (Instruction instr) => ILPatternMatchingExt.MatchAdd(instr), (Instruction instr) => ILPatternMatchingExt.MatchStloc(instr, 1) })) { DawnPlugin.Logger.LogWarning((object)"Failed to find IL for RoundManager.SpawnScrapInLevel (MakeExtraScrapGenerationMoreModular)."); return; } val.RemoveRange(8); val.Emit(OpCodes.Ldloc_1); val.Emit(OpCodes.Call, (MethodBase)AccessTools.DeclaredMethod(typeof(DungeonRegistrationHandler), "GetExtraScrapForCurrentlyLoadedInterior", (Type[])null, (Type[])null)); val.Emit(OpCodes.Add); val.Emit(OpCodes.Stloc_1); } private static int GetExtraScrapForCurrentlyLoadedInterior() { return RoundManagerRefs.GetCurrentDungeonInfo()?.ExtraScrapGeneration ?? 0; } private static void HandleStingerAudio(orig_TeleportPlayer orig, EntranceTeleport self) { if (!self.checkedForFirstTime) { self.checkedForFirstTime = true; if (!self.isEntranceToBuilding) { orig.Invoke(self); return; } DawnDungeonInfo currentDungeonInfo = RoundManagerRefs.GetCurrentDungeonInfo(); if (currentDungeonInfo == null || (Object)(object)currentDungeonInfo.StingerDetail.FirstTimeAudio == (Object)null) { orig.Invoke(self); return; } if (!currentDungeonInfo.StingerDetail.AllowStingerToPlay.Provide()) { orig.Invoke(self); return; } if (!currentDungeonInfo.CustomData.TryGet(DawnKeys.StingerPlayed, out var value)) { DawnPlugin.Logger.LogError((object)$"Failed to get {DawnKeys.StingerPlayed} from dungeon: {currentDungeonInfo.Key}."); orig.Invoke(self); return; } if (value && !currentDungeonInfo.StingerDetail.PlaysMoreThanOnce) { orig.Invoke(self); return; } float num = Random.Range(0f, 100f); if (num > currentDungeonInfo.StingerDetail.PlayChance) { orig.Invoke(self); return; } Debuggers.Dungeons?.Log($"Playing dungeon stinger for dungeon {currentDungeonInfo.Key}, alreadyPlayed: {value} (Chance Roll: {num} <= {currentDungeonInfo.StingerDetail.PlayChance})"); currentDungeonInfo.CustomData.Set(DawnKeys.StingerPlayed, value: true); ((MonoBehaviour)self).StartCoroutine(self.playMusicOnDelay()); } orig.Invoke(self); } private static void FixRandomMapObjects(Action orig, RandomMapObject self) { foreach (DawnMapObjectInfo value in LethalContent.MapObjects.Values) { for (int i = 0; i < self.spawnablePrefabs.Count; i++) { if (!((Object)(object)self.spawnablePrefabs[i] == (Object)null)) { GameObject mapObjectPrefab = value.GetMapObjectPrefab(); if (!((Object)(object)mapObjectPrefab == (Object)null) && ((Object)self.spawnablePrefabs[i]).name.Equals(((Object)mapObjectPrefab).name, StringComparison.OrdinalIgnoreCase)) { self.spawnablePrefabs[i] = mapObjectPrefab; break; } } } } orig.Invoke(self); } private static void DeleteLLLTranspilerAndEnsureDelayedDungeon(orig_Awake orig, MenuManager self) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown orig.Invoke(self); if (!_alreadyPatched) { if (LethalLevelLoaderCompat.Enabled) { DawnPlugin.Logger.LogDebug((object)"Removing LethalLevelLoader dungeon generation transpiler."); LethalLevelLoaderCompat.TryRemoveLLLDungeonTranspiler(); LethalLevelLoaderCompat.ScrewWithLLLDynamicDungeonRarity(); } object obj = <>O.<8>__DelayDungeonGeneration; if (obj == null) { Manipulator val = DelayDungeonGeneration; <>O.<8>__DelayDungeonGeneration = val; obj = (object)val; } RoundManager.GenerateNewFloor += (Manipulator)obj; _alreadyPatched = true; } } private static void CleanDawnDungeonReferences() { foreach (DawnDungeonInfo value in LethalContent.Dungeons.Values) { if (!value.ShouldSkipIgnoreOverride()) { List list = value.DungeonFlow.GetUsedArchetypes().Distinct().ToList(); List list2 = value.DungeonFlow.GetUsedTileSets().Distinct().ToList(); value.DungeonFlow.Nodes.Clear(); value.DungeonFlow.Lines.Clear(); for (int num = list.Count - 1; num >= 0; num--) { Object.Destroy((Object)(object)list[num]); } for (int num2 = list2.Count - 1; num2 >= 0; num2--) { Object.Destroy((Object)(object)list2[num2]); } } } } private static void DelayDungeonGeneration(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)0, new Func[3] { (Instruction i) => ILPatternMatchingExt.MatchLdarg(i, 0), (Instruction i) => ILPatternMatchingExt.MatchLdfld(i, "dungeonGenerator"), (Instruction i) => ILPatternMatchingExt.MatchCallvirt(i, "Generate") })) { val.RemoveRange(3); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)LoadDungeonBundle); MethodInfo method = typeof(MonoBehaviour).GetMethod("StartCoroutine", new Type[1] { typeof(IEnumerator) }); val.Emit(OpCodes.Callvirt, (MethodBase)method); val.Emit(OpCodes.Pop); } else { DawnPlugin.Logger.LogError((object)"Failed to apply DawnLib dungeon generation delay patch!"); DawnPlugin.Logger.LogError((object)"IL code:"); DawnPlugin.Logger.LogError((object)((object)il).ToString()); } } private static IEnumerator UnloadDungeonBundleForAllPlayers(orig_EndOfGame orig, StartOfRound self, int bodiesInsured, int connectedPlayersOnServer, int scrapCollected) { if (!DungeonGenerationPlusCompat.Enabled || !DungeonGenerationPlusCompat.IsDebugOn()) { if ((Object)(object)NetworkSingleton.Instance != (Object)null) { IEnumerator unloadIEnumerator = NetworkSingleton.Instance.UnloadExisting(); while (unloadIEnumerator.MoveNext()) { yield return unloadIEnumerator.Current; } NetworkSingleton.Instance.PlayerSetBundleStateRpc(GameNetworkManager.Instance.localPlayerController, DawnMoonNetworker.BundleState.Done); } else if (!DawnConfig.VanillaCompatibility.Value) { DawnPlugin.Logger.LogError((object)"DawnDungeonNetworker is null, but VanillaCompatibility is false! This is a bug!"); } } IEnumerator origIEnumerator = orig.Invoke(self, bodiesInsured, connectedPlayersOnServer, scrapCollected); while (origIEnumerator.MoveNext()) { yield return origIEnumerator.Current; } } private static IEnumerator LoadDungeonBundle() { DawnDungeonInfo dungeonInfo = DungeonFlowExtensions.get_DawnInfo(RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow); if (!DungeonGenerationPlusCompat.Enabled || !DungeonGenerationPlusCompat.IsDebugOn()) { if (!dungeonInfo.ShouldSkipIgnoreOverride() && NetworkSingleton.IsNotNull) { NetworkSingleton.Instance.QueueDungeonBundleLoading(dungeonInfo.Key); IEnumerator waitForLoad = (IEnumerator)new WaitUntil((Func)(() => NetworkSingleton.Instance.allPlayersDone)); while (waitForLoad.MoveNext()) { yield return waitForLoad.Current; } } yield return (object)new WaitForSeconds(0.1f); } if (LethalLevelLoaderCompat.Enabled && dungeonInfo.ShouldSkipRespectOverride()) { LethalLevelLoaderCompat.LetLLLHandleGeneration(); yield break; } BoundedRange boundedRange = dungeonInfo.DungeonClampRange; if (dungeonInfo.DungeonClampRange.Min == 0f && dungeonInfo.DungeonClampRange.Max == 0f) { boundedRange = new BoundedRange(0f, 999f); } RoundManager.Instance.dungeonGenerator.Generator.LengthMultiplier = Mathf.Clamp(RoundManager.Instance.dungeonGenerator.Generator.LengthMultiplier, boundedRange.Min, boundedRange.Max); RoundManager.Instance.dungeonGenerator.Generate(); } private static void AdjustFireExits(DungeonFlow dungeonFlow) { //IL_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Expected O, but got Unknown GameObject val = GameObject.FindGameObjectWithTag("OutsideLevelNavMesh"); EntranceTeleport[] array = (from e in Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)1) where e.entranceId != 0 select e).ToArray(); for (int num = 0; num < array.Length; num++) { EntranceTeleport val2 = array[num]; val2.entranceId = num + 1; } foreach (GlobalPropSettings item in dungeonFlow.GlobalProps.Where((GlobalPropSettings p) => p.ID == 1231)) { item.Count = new IntRange(array.Length, array.Length); } } private static void UpdateAllDungeonWeights(orig_SetPlanetsWeather orig, StartOfRound self, int connectedPlayersOnServer) { orig.Invoke(self, connectedPlayersOnServer); UpdateDungeonWeightOnLevel(self.currentLevel); } internal static void UpdateDungeonWeightOnLevel(SelectableLevel level) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) if (!LethalContent.Weathers.IsFrozen || !LethalContent.Dungeons.IsFrozen || (Object)(object)StartOfRound.Instance == (Object)null || (WeatherRegistryCompat.Enabled && !WeatherRegistryCompat.IsWeatherManagerReady())) { return; } IntWithRarity[] dungeonFlowTypes = level.dungeonFlowTypes; foreach (IntWithRarity val in dungeonFlowTypes) { DawnDungeonInfo dawnDungeonInfo = DungeonFlowExtensions.get_DawnInfo(RoundManagerRefs.Instance.dungeonFlowTypes[val.id].dungeonFlow); if (!dawnDungeonInfo.ShouldSkipRespectOverride()) { int rarity = dawnDungeonInfo.GetRarity(SelectableLevelExtensions.get_DawnInfo(level), LevelWeatherTypeExtensions.get_DawnInfo(level.currentWeather)); val.rarity = rarity; } } } private static void AddDawnDungeonsToMoons() { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown foreach (DawnMoonInfo value in LethalContent.Moons.Values) { List list = value.Level.dungeonFlowTypes.ToList(); foreach (DawnDungeonInfo value2 in LethalContent.Dungeons.Values) { if (!value2.ShouldSkipIgnoreOverride()) { int num = Array.IndexOf(RoundManagerRefs.Instance.dungeonFlowTypes.Select((IndoorMapType t) => t.dungeonFlow).ToArray(), value2.DungeonFlow); IntWithRarity item = new IntWithRarity(num, 0, (LevelAmbienceLibrary)null); list.Add(item); } } value.Level.dungeonFlowTypes = list.ToArray(); } } private static void RegisterDawnDungeons(orig_Awake orig, StartOfRound self) { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown List list = RoundManagerRefs.Instance.dungeonFlowTypes.ToList(); foreach (DawnDungeonInfo value in LethalContent.Dungeons.Values) { if (!value.ShouldSkipIgnoreOverride()) { IndoorMapType item = new IndoorMapType(value.DungeonFlow, value.MapTileSize, value.StingerDetail.FirstTimeAudio); list.Add(item); } } RoundManagerRefs.Instance.dungeonFlowTypes = list.ToArray(); orig.Invoke(self); } private static void CollectNonDawnDungeons() { IndoorMapType[] dungeonFlowTypes = RoundManagerRefs.Instance.dungeonFlowTypes; foreach (IndoorMapType val in dungeonFlowTypes) { if (val == null || (Object)(object)val.dungeonFlow == (Object)null || DungeonFlowExtensions.get_DawnInfo(val.dungeonFlow) != null) { continue; } string name = FormatFlowName(val.dungeonFlow); NamespacedKey namespacedKey = DungeonKeys.GetByReflection(name); BoundedRange dungeonClampRange = new BoundedRange(0f, 999f); if (namespacedKey == null && LethalLevelLoaderCompat.Enabled && LethalLevelLoaderCompat.TryGetExtendedDungeonModName(val.dungeonFlow, out string modName)) { namespacedKey = NamespacedKey.From(modName, ((Object)val.dungeonFlow).name); dungeonClampRange = LethalLevelLoaderCompat.GetDungeonClamp(val.dungeonFlow); } else if (namespacedKey == null) { namespacedKey = NamespacedKey.From("unknown_modded", ((Object)val.dungeonFlow).name); } if (LethalContent.Dungeons.ContainsKey(namespacedKey)) { Debuggers.Dungeons?.Log($"LethalContent.Dungeons already contains {namespacedKey}"); DungeonFlowExtensions.set_DawnInfo(val.dungeonFlow, LethalContent.Dungeons[namespacedKey]); continue; } HashSet tags = new HashSet { DawnLibTags.IsExternal }; CollectLLLTags(val.dungeonFlow, tags); WeightProfile weightProfile = new WeightProfile(DawnWeightChannels.DungeonRarity.Policy); weightProfile.AddSource(new DungeonListBaseRaritySource(val.dungeonFlow)); PersistentDataContainer persistentDataContainer = new PersistentDataContainer(Path.Combine(PersistentDataHandler.RootPath, "dungeon_" + namespacedKey.Namespace + "_" + namespacedKey.Key)); if (!persistentDataContainer.Has(DawnKeys.StingerPlayed)) { persistentDataContainer.Set(DawnKeys.StingerPlayed, value: false); } DawnStingerDetail stingerDetail = new DawnStingerDetail(val.firstTimeAudio, playsMoreThanOnce: false, 100f, new FuncProvider(() => true)); int extraScrapGeneration = 0; if (namespacedKey == DungeonKeys.MineshaftFlow) { extraScrapGeneration = 6; } DawnDungeonInfo value = new DawnDungeonInfo(namespacedKey, tags, val.dungeonFlow, new DawnWeightedValue(DawnWeightChannels.DungeonRarity, weightProfile), val.MapTileSize, stingerDetail, string.Empty, dungeonClampRange, extraScrapGeneration, persistentDataContainer); DungeonFlowExtensions.set_DawnInfo(val.dungeonFlow, value); LethalContent.Dungeons.Register(value); } CollectArchetypesAndTileSets(); LethalContent.Dungeons.Freeze(); } private static void CollectArchetypesAndTileSets() { foreach (DawnDungeonInfo value in LethalContent.Dungeons.Values) { DungeonArchetype[] usedArchetypes = value.DungeonFlow.GetUsedArchetypes(); foreach (DungeonArchetype val in usedArchetypes) { Debuggers.Dungeons?.Log("dungeonArchetype.name: " + ((Object)val).name); NamespacedKey namespacedKey; if (value.Key.IsVanilla()) { string text = FormatArchetypeName(val); namespacedKey = DungeonArchetypeKeys.GetByReflection(text); if (namespacedKey == null) { DawnPlugin.Logger.LogWarning((object)$"archetype: '{((Object)val).name}' (part of {value.Key}) is vanilla, but DawnLib couldn't get a corresponding NamespacedKey, archetype has formatted name: {text}!"); continue; } } else { namespacedKey = NamespacedKey.From(value.Key.Namespace, ((Object)val).name); } if (LethalContent.Archetypes.ContainsKey(namespacedKey)) { Debuggers.Dungeons?.Log($"LethalContent.Archetypes already contains {namespacedKey}"); DungeonArchetypeExtensions.set_DawnInfo(val, LethalContent.Archetypes[namespacedKey]); continue; } HashSet hashSet = new HashSet(); if (value.HasTag(DawnLibTags.IsExternal)) { hashSet.Add(DawnLibTags.IsExternal); } DawnArchetypeInfo dawnArchetypeInfo = new DawnArchetypeInfo(namespacedKey, hashSet, val, null); DungeonArchetypeExtensions.set_DawnInfo(val, dawnArchetypeInfo); dawnArchetypeInfo.ParentInfo = value; LethalContent.Archetypes.Register(dawnArchetypeInfo); List tileSets = val.TileSets; List branchCapTileSets = val.BranchCapTileSets; List list = new List(tileSets.Count + branchCapTileSets.Count); list.AddRange(tileSets); list.AddRange(branchCapTileSets); List list2 = list; foreach (TileSet item in list2) { TryRegisterTileSet(value, item, dawnArchetypeInfo); } } TileSet[] usedTileSets = value.DungeonFlow.GetUsedTileSets(); foreach (TileSet tileSet in usedTileSets) { TryRegisterTileSet(value, tileSet, null); } } LethalContent.Archetypes.Freeze(); LethalContent.TileSets.Freeze(); } private static void TryRegisterTileSet(DawnDungeonInfo dungeonInfo, TileSet tileSet, DawnArchetypeInfo? archetypeInfo) { if (TileSetExtensions.get_DawnInfo(tileSet) != null) { return; } Debuggers.Dungeons?.Log("tileSet.name: " + ((Object)tileSet).name); NamespacedKey namespacedKey; if (dungeonInfo.Key.IsVanilla()) { string text = FormatTileSetName(tileSet); namespacedKey = DungeonTileSetKeys.GetByReflection(text); if (namespacedKey == null) { string text2 = archetypeInfo?.TypedKey.ToString() ?? "no archetype"; DawnPlugin.Logger.LogWarning((object)("tileset: '" + ((Object)tileSet).name + "' (part of " + text2 + ") is vanilla, but DawnLib couldn't get a corresponding NamespacedKey, tileset has formatted name: " + text + "!")); return; } } else { namespacedKey = NamespacedKey.From(dungeonInfo.Key.Namespace, ((Object)tileSet).name); } if (LethalContent.TileSets.ContainsKey(namespacedKey)) { Debuggers.Dungeons?.Log($"LethalContent.TileSets already contains {namespacedKey}"); TileSetExtensions.set_DawnInfo(tileSet, LethalContent.TileSets[namespacedKey]); return; } HashSet hashSet = new HashSet(); if (dungeonInfo.HasTag(DawnLibTags.IsExternal)) { hashSet.Add(DawnLibTags.IsExternal); } DawnTileSetInfo dawnTileSetInfo = new DawnTileSetInfo(namespacedKey, hashSet, ConstantPredicate.True, tileSet, archetypeInfo?.DungeonArchetype.BranchCapTileSets.Contains(tileSet) ?? false, archetypeInfo?.DungeonArchetype.TileSets.Contains(tileSet) ?? false, null); archetypeInfo?.AddTileSet(dawnTileSetInfo); TileSetExtensions.set_DawnInfo(tileSet, dawnTileSetInfo); LethalContent.TileSets.Register(dawnTileSetInfo); } private static string FormatTileSetName(TileSet tileSet) { string input = NamespacedKey.NormalizeStringForNamespacedKey(((Object)tileSet).name, CSharpName: true); return ReplaceInternalLevelNames(input).Replace("Tiles", string.Empty); } private static string FormatArchetypeName(DungeonArchetype dungeonArchetype) { string input = NamespacedKey.NormalizeStringForNamespacedKey(((Object)dungeonArchetype).name, CSharpName: true); return ReplaceInternalLevelNames(input).Replace("Archetype", string.Empty); } private static string FormatFlowName(DungeonFlow dungeonFlow) { string input = NamespacedKey.NormalizeStringForNamespacedKey(((Object)dungeonFlow).name, CSharpName: true); return ReplaceInternalLevelNames(input); } private static string ReplaceInternalLevelNames(string input) { string text = input; foreach (KeyValuePair internalToHumanDungeonName in _internalToHumanDungeonNames) { internalToHumanDungeonName.Deconstruct(out var key, out var value); string oldValue = key; string newValue = value; text = text.Replace(oldValue, newValue); } return text; } private static void CollectLLLTags(DungeonFlow dungeonFlow, HashSet tags) { if (LethalLevelLoaderCompat.Enabled && LethalLevelLoaderCompat.TryGetAllTagsWithModNames(dungeonFlow, out List<(string, string)> allTagsWithModNames)) { tags.AddToList(allTagsWithModNames, Debuggers.Dungeons, ((Object)dungeonFlow).name); } } private static void TryInjectTileSets(DungeonFlow dungeonFlow) { DungeonArchetype[] usedArchetypes = dungeonFlow.GetUsedArchetypes(); foreach (DungeonArchetype val in usedArchetypes) { if ((Object)(object)val == (Object)null) { Debuggers.Dungeons?.Log("Archetype is null in dungeonflow: " + ((Object)dungeonFlow).name); continue; } Debuggers.Dungeons?.Log("Injecting tile sets for " + ((Object)val).name); foreach (DawnTileSetInfo tileSet in DungeonArchetypeExtensions.get_DawnInfo(val).TileSets) { if ((Object)(object)tileSet.TileSet == (Object)null) { Debuggers.Dungeons?.Log("TileSet is null in archetype: " + ((Object)val).name); } else { if (tileSet.ShouldSkipIgnoreOverride()) { continue; } val.BranchCapTileSets.Remove(tileSet.TileSet); val.TileSets.Remove(tileSet.TileSet); if (tileSet.InjectionPredicate.Evaluate()) { if (tileSet.IsBranchCap) { val.BranchCapTileSets.Add(tileSet.TileSet); } if (tileSet.IsRegular) { val.TileSets.Add(tileSet.TileSet); } Debuggers.Dungeons?.Log("Added " + ((Object)tileSet.TileSet).name + " to " + ((Object)val).name); } } } } } } public sealed class DawnArchetypeInfo : DawnBaseInfo { private List _tileSets = new List(); public DungeonArchetype DungeonArchetype { get; internal set; } public IReadOnlyList TileSets => _tileSets.AsReadOnly(); public DawnDungeonInfo ParentInfo { get; internal set; } internal DawnArchetypeInfo(NamespacedKey key, HashSet tags, DungeonArchetype archetype, IDataContainer? customData) : base(key, tags, customData) { DungeonArchetype = archetype; } public void AddTileSet(DawnTileSetInfo info) { if (LethalContent.Dungeons.IsFrozen) { throw new RegistryFrozenException(); } _tileSets.Add(info); } } public sealed class DawnDungeonInfo : DawnBaseInfo { public const int FireExitGlobalPropID = 1231; public DawnWeightedValue Rarity { get; } public DungeonFlow DungeonFlow { get; } public string AssetBundlePath { get; } public float MapTileSize { get; private set; } public DawnStingerDetail StingerDetail { get; private set; } public BoundedRange DungeonClampRange { get; private set; } public int ExtraScrapGeneration { get; private set; } public HashSet SpawnSyncedObjects => CollectAllSpawnSyncedObjects(); internal DawnDungeonInfo(NamespacedKey key, HashSet tags, DungeonFlow dungeonFlow, DawnWeightedValue rarity, float mapTileSize, DawnStingerDetail stingerDetail, string assetBundlePath, BoundedRange dungeonClampRange, int extraScrapGeneration, IDataContainer? customData) : base(key, tags, customData) { DungeonFlow = dungeonFlow; Rarity = rarity; MapTileSize = mapTileSize; StingerDetail = stingerDetail; AssetBundlePath = assetBundlePath; DungeonClampRange = dungeonClampRange; ExtraScrapGeneration = extraScrapGeneration; } public int GetRarity(DawnMoonInfo? moonInfo = null, DawnWeatherEffectInfo? weatherEffectInfo = null) { return Rarity.GetValue(new WeightQuery { Subject = this, Moon = moonInfo, Weather = weatherEffectInfo, Channel = DawnWeightChannels.ScrapRarity.Key }); } private HashSet CollectAllSpawnSyncedObjects() { HashSet hashSet = new HashSet(); TileSet[] usedTileSets = DungeonFlow.GetUsedTileSets(); foreach (TileSet val in usedTileSets) { if (TileSetExtensions.get_DawnInfo(val) == null) { DawnPlugin.Logger.LogWarning((object)("TileSet has no DawnInfo: " + ((Object)val).name + ", falling back to manual method.")); hashSet.UnionWith(DawnTileSetInfo.GrabAllSpawnSyncedObjects(val)); } else { hashSet.UnionWith(TileSetExtensions.get_DawnInfo(val).SpawnSyncedObjects); } } return hashSet; } } public class DawnStingerDetail(AudioClip? firstTimeAudio, bool playsMoreThanOnce, float playChance, FuncProvider allowStingerToPlay) { public AudioClip? FirstTimeAudio { get; private set; } = firstTimeAudio; public bool PlaysMoreThanOnce { get; private set; } = playsMoreThanOnce; public float PlayChance { get; private set; } = playChance; public FuncProvider AllowStingerToPlay { get; private set; } = allowStingerToPlay; } public sealed class DawnTileSetInfo : DawnBaseInfo { internal List sockets = new List(); internal List doorways = new List(); internal List spawnSyncedObjects = new List(); internal List tiles = new List(); public TileSet? TileSet { get; internal set; } public bool IsBranchCap { get; } public bool IsRegular { get; } public IPredicate InjectionPredicate { get; } public IReadOnlyList Tiles => tiles.AsReadOnly(); public IReadOnlyList Doorways => doorways.AsReadOnly(); public IReadOnlyList SpawnSyncedObjects => spawnSyncedObjects.AsReadOnly(); public IReadOnlyList Sockets => sockets.AsReadOnly(); internal DawnTileSetInfo(NamespacedKey key, HashSet tags, IPredicate injectionRule, TileSet tileSet, bool isBranchCap, bool isRegular, IDataContainer? customData) : base(key, tags, customData) { TileSet = tileSet; IsBranchCap = isBranchCap; IsRegular = isRegular; InjectionPredicate = injectionRule; if (ShouldSkipIgnoreOverride()) { SetupDetails(); RegisterSpawnSyncedObjects(); } } internal void RegisterSpawnSyncedObjects() { if ((Object)(object)TileSet == (Object)null) { DawnPlugin.Logger.LogWarning((object)$"Trying to register spawnSyncedObjects for likely-dawnlib tileSet: {base.TypedKey} that isn't loaded"); return; } NetworkObject val = default(NetworkObject); foreach (SpawnSyncedObject spawnSyncedObject in SpawnSyncedObjects) { if ((Object)(object)spawnSyncedObject.spawnPrefab == (Object)null) { DawnPlugin.Logger.LogWarning((object)("SpawnSyncedObject.spawnPrefab is null in tileSet: " + ((Object)TileSet).name)); } else if (spawnSyncedObject.spawnPrefab.TryGetComponent(ref val)) { DawnLib.RegisterNetworkPrefab(spawnSyncedObject.spawnPrefab); } } } internal void SetupDetails() { tiles.Clear(); doorways.Clear(); spawnSyncedObjects.Clear(); sockets.Clear(); if ((Object)(object)TileSet == (Object)null) { DawnPlugin.Logger.LogWarning((object)$"Trying to setup details for likely-dawnlib tileSet: {base.TypedKey} that isn't loaded"); return; } foreach (GameObjectChance weight in TileSet.TileWeights.Weights) { if ((Object)(object)weight.Value == (Object)null) { DawnPlugin.Logger.LogWarning((object)("GameObject is null in tileSet: " + ((Object)TileSet).name)); continue; } Tile[] componentsInChildren = weight.Value.GetComponentsInChildren(); foreach (Tile val in componentsInChildren) { if ((Object)(object)val == (Object)null) { DawnPlugin.Logger.LogWarning((object)("Tile is null in tileSet: " + ((Object)TileSet).name)); } else if (!tiles.Contains(val)) { tiles.Add(val); DawnLib.FixDoorwaySockets(weight.Value); } } } foreach (Tile tile in Tiles) { Doorway[] componentsInChildren2 = ((Component)tile).gameObject.GetComponentsInChildren(); foreach (Doorway val2 in componentsInChildren2) { if (!Doorways.Contains(val2)) { doorways.Add(val2); } if (!Sockets.Contains(val2.socket)) { if ((Object)(object)val2.socket == (Object)null) { DawnPlugin.Logger.LogWarning((object)("TileSet: " + ((Object)TileSet).name + " has a null socket in doorway: " + ((Object)val2).name + " from Tile: " + ((Object)tile).name)); continue; } sockets.Add(val2.socket); } foreach (GameObjectWeight connectorPrefabWeight in val2.ConnectorPrefabWeights) { SpawnSyncedObject[] componentsInChildren3 = connectorPrefabWeight.GameObject.GetComponentsInChildren(); foreach (SpawnSyncedObject val3 in componentsInChildren3) { if (!SpawnSyncedObjects.Contains(val3)) { spawnSyncedObjects.Add(val3); } } } foreach (GameObjectWeight blockerPrefabWeight in val2.BlockerPrefabWeights) { SpawnSyncedObject[] componentsInChildren4 = blockerPrefabWeight.GameObject.GetComponentsInChildren(); foreach (SpawnSyncedObject val4 in componentsInChildren4) { if (!SpawnSyncedObjects.Contains(val4)) { spawnSyncedObjects.Add(val4); } } } } SpawnSyncedObject[] componentsInChildren5 = ((Component)tile).gameObject.GetComponentsInChildren(); foreach (SpawnSyncedObject val5 in componentsInChildren5) { if (!SpawnSyncedObjects.Contains(val5)) { spawnSyncedObjects.Add(val5); } } } } internal static List GrabAllSpawnSyncedObjects(TileSet tileSet) { List list = new List(); foreach (GameObjectChance weight in tileSet.TileWeights.Weights) { if ((Object)(object)weight.Value == (Object)null) { DawnPlugin.Logger.LogWarning((object)("GameObject is null in tileSet: " + ((Object)tileSet).name)); continue; } Tile[] componentsInChildren = weight.Value.GetComponentsInChildren(); foreach (Tile val in componentsInChildren) { if ((Object)(object)val == (Object)null) { DawnPlugin.Logger.LogWarning((object)("Tile is null in tileSet: " + ((Object)tileSet).name)); } else if (!list.Contains(val)) { list.Add(val); DawnLib.FixDoorwaySockets(weight.Value); } } } List list2 = new List(); foreach (Tile item4 in list) { Doorway[] componentsInChildren2 = ((Component)item4).gameObject.GetComponentsInChildren(); foreach (Doorway val2 in componentsInChildren2) { foreach (GameObjectWeight connectorPrefabWeight in val2.ConnectorPrefabWeights) { SpawnSyncedObject[] componentsInChildren3 = connectorPrefabWeight.GameObject.GetComponentsInChildren(); foreach (SpawnSyncedObject item in componentsInChildren3) { if (!list2.Contains(item)) { list2.Add(item); } } } foreach (GameObjectWeight blockerPrefabWeight in val2.BlockerPrefabWeights) { SpawnSyncedObject[] componentsInChildren4 = blockerPrefabWeight.GameObject.GetComponentsInChildren(); foreach (SpawnSyncedObject item2 in componentsInChildren4) { if (!list2.Contains(item2)) { list2.Add(item2); } } } } SpawnSyncedObject[] componentsInChildren5 = ((Component)item4).gameObject.GetComponentsInChildren(); foreach (SpawnSyncedObject item3 in componentsInChildren5) { if (!list2.Contains(item3)) { list2.Add(item3); } } } return list2; } } public static class DungeonArchetypeExtensions { [SpecialName] public sealed class $67CCFAA6B12051CFD0C42BBC3AD369C8 { [SpecialName] public static class $2B1AB4F0CE02B6706978646102AF3E55 { } [ExtensionMarker("$2B1AB4F0CE02B6706978646102AF3E55")] public DawnArchetypeInfo DawnInfo { [ExtensionMarker("$2B1AB4F0CE02B6706978646102AF3E55")] get { throw new NotSupportedException(); } [ExtensionMarker("$2B1AB4F0CE02B6706978646102AF3E55")] set { throw new NotSupportedException(); } } [ExtensionMarker("$2B1AB4F0CE02B6706978646102AF3E55")] [Obsolete("Use DungeonArchetype.DawnInfo instead")] public DawnArchetypeInfo GetDawnInfo() { throw new NotSupportedException(); } [ExtensionMarker("$2B1AB4F0CE02B6706978646102AF3E55")] [Obsolete("Use DungeonArchetype.DawnInfo instead")] public void SetDawnInfo(DawnArchetypeInfo archetypeInfo) { throw new NotSupportedException(); } [ExtensionMarker("$2B1AB4F0CE02B6706978646102AF3E55")] [Obsolete] public bool HasDawnInfo() { throw new NotSupportedException(); } [ExtensionMarker("$2B1AB4F0CE02B6706978646102AF3E55")] private DawnArchetypeInfo GetDawnInfoCore() { throw new NotSupportedException(); } [ExtensionMarker("$2B1AB4F0CE02B6706978646102AF3E55")] private void SetDawnInfoCore(DawnArchetypeInfo archetypeInfo) { throw new NotSupportedException(); } } public static DawnArchetypeInfo get_DawnInfo(DungeonArchetype archetype) { return archetype.GetDawnInfoCore(); } public static void set_DawnInfo(DungeonArchetype archetype, DawnArchetypeInfo value) { archetype.SetDawnInfoCore(value); } [Obsolete("Use DungeonArchetype.DawnInfo instead")] public static DawnArchetypeInfo GetDawnInfo(this DungeonArchetype archetype) { return archetype.GetDawnInfoCore(); } [Obsolete("Use DungeonArchetype.DawnInfo instead")] public static void SetDawnInfo(this DungeonArchetype archetype, DawnArchetypeInfo archetypeInfo) { archetype.SetDawnInfoCore(archetypeInfo); } [Obsolete] public static bool HasDawnInfo(this DungeonArchetype archetype) { return get_DawnInfo(archetype) != null; } private static DawnArchetypeInfo GetDawnInfoCore(this DungeonArchetype archetype) { return ((IDunGenArchetypeDawnObject)archetype).DawnInfo; } private static void SetDawnInfoCore(this DungeonArchetype archetype, DawnArchetypeInfo archetypeInfo) { ((IDunGenArchetypeDawnObject)archetype).DawnInfo = archetypeInfo; } } public static class DungeonFlowExtensions { [SpecialName] public sealed class $CD10C215F7ED837D53099BBFF929B4C2 { [SpecialName] public static class $CE90CADF2EAE73A1D49C15E17C3E15C2 { } [ExtensionMarker("$CE90CADF2EAE73A1D49C15E17C3E15C2")] public DawnDungeonInfo DawnInfo { [ExtensionMarker("$CE90CADF2EAE73A1D49C15E17C3E15C2")] get { throw new NotSupportedException(); } [ExtensionMarker("$CE90CADF2EAE73A1D49C15E17C3E15C2")] set { throw new NotSupportedException(); } } [ExtensionMarker("$CE90CADF2EAE73A1D49C15E17C3E15C2")] [Obsolete("Use DungeonFlow.DawnInfo instead")] public DawnDungeonInfo GetDawnInfo() { throw new NotSupportedException(); } [ExtensionMarker("$CE90CADF2EAE73A1D49C15E17C3E15C2")] [Obsolete("Use DungeonFlow.DawnInfo instead")] public void SetDawnInfo(DawnDungeonInfo dungeonFlowInfo) { throw new NotSupportedException(); } [ExtensionMarker("$CE90CADF2EAE73A1D49C15E17C3E15C2")] [Obsolete] public bool HasDawnInfo() { throw new NotSupportedException(); } [ExtensionMarker("$CE90CADF2EAE73A1D49C15E17C3E15C2")] private DawnDungeonInfo GetDawnInfoCore() { throw new NotSupportedException(); } [ExtensionMarker("$CE90CADF2EAE73A1D49C15E17C3E15C2")] private void SetDawnInfoCore(DawnDungeonInfo dungeonFlowInfo) { throw new NotSupportedException(); } } public static DawnDungeonInfo get_DawnInfo(DungeonFlow dungeonFlow) { return dungeonFlow.GetDawnInfoCore(); } public static void set_DawnInfo(DungeonFlow dungeonFlow, DawnDungeonInfo value) { dungeonFlow.SetDawnInfoCore(value); } [Obsolete("Use DungeonFlow.DawnInfo instead")] public static DawnDungeonInfo GetDawnInfo(this DungeonFlow dungeonFlow) { return dungeonFlow.GetDawnInfoCore(); } [Obsolete("Use DungeonFlow.DawnInfo instead")] public static void SetDawnInfo(this DungeonFlow dungeonFlow, DawnDungeonInfo dungeonFlowInfo) { dungeonFlow.SetDawnInfoCore(dungeonFlowInfo); } [Obsolete] public static bool HasDawnInfo(this DungeonFlow dungeonFlow) { return get_DawnInfo(dungeonFlow) != null; } private static DawnDungeonInfo GetDawnInfoCore(this DungeonFlow dungeonFlow) { return ((IDunGenFlowDawnObject)dungeonFlow).DawnInfo; } private static void SetDawnInfoCore(this DungeonFlow dungeonFlow, DawnDungeonInfo dungeonFlowInfo) { ((IDunGenFlowDawnObject)dungeonFlow).DawnInfo = dungeonFlowInfo; } } public class DungeonFlowInfoBuilder : BaseInfoBuilder { private float _mapTileSize; private AudioClip? _firstTimeAudio; private DawnWeightedValue _weights; private string _assetBundlePath = string.Empty; private BoundedRange _dungeonRangeClamp = new BoundedRange(0f, 999f); private bool _stingerPlaysMoreThanOnce; private float _stingerPlayChance = 100f; private FuncProvider _allowStingerToPlay = new FuncProvider(() => true); private int _extraScrapGeneration; internal DungeonFlowInfoBuilder(NamespacedKey key, DungeonFlow value) : base(key, value) { } public DungeonFlowInfoBuilder SetArchetypeTileSetMapping(string archetypeName, IEnumerable tileSetNames) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown GraphLine val = new GraphLine(base.value); base.value.Lines.Add(val); TileSet[] array = base.value.GetUsedTileSets() ?? Array.Empty(); Dictionary dictionary = new Dictionary(StringComparer.Ordinal); TileSet[] array2 = array; foreach (TileSet val2 in array2) { if (!dictionary.ContainsKey(((Object)val2).name)) { dictionary.Add(((Object)val2).name, val2); } } List list = new List(); foreach (string tileSetName in tileSetNames) { string name = tileSetName.Trim(); if (!dictionary.TryGetValue(name, out var val3)) { val3 = ScriptableObject.CreateInstance(); ((Object)val3).name = name; dictionary.Add(name, val3); } if (!list.Contains(val3)) { list.Add(val3); } } DungeonArchetype val4 = null; DungeonArchetype[] usedArchetypes = base.value.GetUsedArchetypes(); if (usedArchetypes != null) { DungeonArchetype[] array3 = usedArchetypes; foreach (DungeonArchetype val5 in array3) { if (!((Object)(object)val5 == (Object)null) && string.Equals(((Object)val5).name, archetypeName, StringComparison.Ordinal)) { val4 = val5; break; } } } if ((Object)(object)val4 == (Object)null) { val4 = ScriptableObject.CreateInstance(); ((Object)val4).name = archetypeName; } if (val4.TileSets == null) { val4.TileSets = new List(); } else { val4.TileSets.Clear(); } val4.TileSets.AddRange(list); if (val.DungeonArchetypes == null) { val.DungeonArchetypes = new List(); } else { val.DungeonArchetypes.Clear(); } val.DungeonArchetypes.Add(val4); return this; } public DungeonFlowInfoBuilder SetMapTileSize(float mapTileSize) { _mapTileSize = mapTileSize; return this; } public DungeonFlowInfoBuilder SetExtraScrapGeneration(int extraScrapGeneration) { _extraScrapGeneration = extraScrapGeneration; return this; } public DungeonFlowInfoBuilder SetAssetBundlePath(string assetBundlePath) { _assetBundlePath = assetBundlePath; return this; } public DungeonFlowInfoBuilder SetFirstTimeAudio(AudioClip firstTimeAudio) { _firstTimeAudio = firstTimeAudio; return this; } public DungeonFlowInfoBuilder OverrideStingerPlaysMoreThanOnce(bool stingerPlaysMoreThanOnce) { _stingerPlaysMoreThanOnce = stingerPlaysMoreThanOnce; return this; } public DungeonFlowInfoBuilder OverrideStingerPlayChance(float stingerPlayChance) { _stingerPlayChance = stingerPlayChance; return this; } public DungeonFlowInfoBuilder SetWeights(Action> callback) { WeightProfile weightProfile = new WeightProfile(DawnWeightChannels.DungeonRarity.Policy); callback(weightProfile); _weights = new DawnWeightedValue(DawnWeightChannels.DungeonRarity, weightProfile); return this; } public DungeonFlowInfoBuilder SetDungeonRangeClamp(BoundedRange dungeonRangeClamp) { _dungeonRangeClamp = dungeonRangeClamp; return this; } public DungeonFlowInfoBuilder OverrideAllowStingerToPlay(FuncProvider allowStingerToPlay) { _allowStingerToPlay = allowStingerToPlay; return this; } internal override DawnDungeonInfo Build() { if (_weights == null) { DawnPlugin.Logger.LogWarning((object)$"DungeonFlow '{base.key}' didn't set weights. If you intend to have no weights (doing something special), call .SetWeights(() => {{}})"); _weights = new DawnWeightedValue(DawnWeightChannels.DungeonRarity); } DawnStingerDetail stingerDetail = new DawnStingerDetail(_firstTimeAudio, _stingerPlaysMoreThanOnce, _stingerPlayChance, _allowStingerToPlay); return new DawnDungeonInfo(base.key, new HashSet(), base.value, _weights, _mapTileSize, stingerDetail, _assetBundlePath, _dungeonRangeClamp, _extraScrapGeneration, customData); } } public static class TileSetExtensions { [SpecialName] public sealed class $A8F1454060797533BAD0A36B837942F0 { [SpecialName] public static class $8FA9543C8C10656A7834235AE3532871 { } [ExtensionMarker("$8FA9543C8C10656A7834235AE3532871")] public DawnTileSetInfo DawnInfo { [ExtensionMarker("$8FA9543C8C10656A7834235AE3532871")] get { throw new NotSupportedException(); } [ExtensionMarker("$8FA9543C8C10656A7834235AE3532871")] set { throw new NotSupportedException(); } } [ExtensionMarker("$8FA9543C8C10656A7834235AE3532871")] [Obsolete("Use TileSet.DawnInfo instead")] public DawnTileSetInfo GetDawnInfo() { throw new NotSupportedException(); } [ExtensionMarker("$8FA9543C8C10656A7834235AE3532871")] [Obsolete("Use TileSet.DawnInfo instead")] public void SetDawnInfo(DawnTileSetInfo tileSetInfo) { throw new NotSupportedException(); } [ExtensionMarker("$8FA9543C8C10656A7834235AE3532871")] [Obsolete] public bool HasDawnInfo() { throw new NotSupportedException(); } [ExtensionMarker("$8FA9543C8C10656A7834235AE3532871")] private DawnTileSetInfo GetDawnInfoCore() { throw new NotSupportedException(); } [ExtensionMarker("$8FA9543C8C10656A7834235AE3532871")] private void SetDawnInfoCore(DawnTileSetInfo tileSetInfo) { throw new NotSupportedException(); } } public static DawnTileSetInfo get_DawnInfo(TileSet tileSet) { return tileSet.GetDawnInfoCore(); } public static void set_DawnInfo(TileSet tileSet, DawnTileSetInfo value) { tileSet.SetDawnInfoCore(value); } [Obsolete("Use TileSet.DawnInfo instead")] public static DawnTileSetInfo GetDawnInfo(this TileSet tileSet) { return tileSet.GetDawnInfoCore(); } [Obsolete("Use TileSet.DawnInfo instead")] public static void SetDawnInfo(this TileSet tileSet, DawnTileSetInfo tileSetInfo) { tileSet.SetDawnInfoCore(tileSetInfo); } [Obsolete] public static bool HasDawnInfo(this TileSet tileSet) { return get_DawnInfo(tileSet) != null; } private static DawnTileSetInfo GetDawnInfoCore(this TileSet tileSet) { return ((IDunGenTileSetDawnObject)tileSet).DawnInfo; } private static void SetDawnInfoCore(this TileSet tileSet, DawnTileSetInfo tileSetInfo) { ((IDunGenTileSetDawnObject)tileSet).DawnInfo = tileSetInfo; } } public class TilesetInfoBuilder : BaseInfoBuilder { private bool _branchCap; private bool _regular = true; private IPredicate? _predicate; internal TilesetInfoBuilder(NamespacedKey key, TileSet value) : base(key, value) { } public TilesetInfoBuilder SetIsBranchCap(bool value) { _branchCap = value; return this; } public TilesetInfoBuilder SetIsRegular(bool value) { _regular = value; return this; } public TilesetInfoBuilder SetInjectionPredicate(IPredicate predicate) { _predicate = predicate; return this; } internal override DawnTileSetInfo Build() { if (_predicate == null) { _predicate = ConstantPredicate.True; } return new DawnTileSetInfo(base.key, new HashSet(), _predicate, base.value, _branchCap, _regular, customData); } } internal static class EnemyRegistrationHandler { [CompilerGenerated] private static class <>O { public static hook_RefreshEnemiesList <0>__UpdateEnemyWeights; public static hook_AssignRandomEnemyToVent <1>__CheckIfEnemyCanSpawn; public static hook_SetPlanetsWeather <2>__UpdateEnemyWeights; public static hook_Start <3>__EnsureCorrectEnemyVariables; public static hook_Start <4>__AddEnemiesToDebugList; public static Manipulator <5>__StopDawnEnemyResetting; public static hook_Awake <6>__AddBestiaryNodes; public static hook_Start <7>__CollectAllEnemyTypes; public static hook_Start <8>__GrabModdedBestiaryNodes; public static Func <9>__DawnLibHandledEnemy; } private static List _networkPrefabEnemyTypes = new List(); internal static void Init() { //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Expected O, but got Unknown //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Expected O, but got Unknown //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_013b: Expected O, but got Unknown //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Expected O, but got Unknown //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Expected O, but got Unknown //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Expected O, but got Unknown //IL_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Expected O, but got Unknown //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Expected O, but got Unknown //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Expected O, but got Unknown //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Expected O, but got Unknown //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Expected O, but got Unknown LethalContent.Enemies.AddAutoTaggers(new SimpleAutoTagger(Tags.Killable, (DawnEnemyInfo info) => info.EnemyType.canDie), new SimpleAutoTagger(Tags.Small, (DawnEnemyInfo info) => (int)info.EnemyType.EnemySize == 0), new SimpleAutoTagger(Tags.Medium, (DawnEnemyInfo info) => (int)info.EnemyType.EnemySize == 2), new SimpleAutoTagger(Tags.Large, (DawnEnemyInfo info) => (int)info.EnemyType.EnemySize == 1)); object obj = <>O.<0>__UpdateEnemyWeights; if (obj == null) { hook_RefreshEnemiesList val = UpdateEnemyWeights; <>O.<0>__UpdateEnemyWeights = val; obj = (object)val; } RoundManager.RefreshEnemiesList += (hook_RefreshEnemiesList)obj; object obj2 = <>O.<1>__CheckIfEnemyCanSpawn; if (obj2 == null) { hook_AssignRandomEnemyToVent val2 = CheckIfEnemyCanSpawn; <>O.<1>__CheckIfEnemyCanSpawn = val2; obj2 = (object)val2; } RoundManager.AssignRandomEnemyToVent += (hook_AssignRandomEnemyToVent)obj2; object obj3 = <>O.<2>__UpdateEnemyWeights; if (obj3 == null) { hook_SetPlanetsWeather val3 = UpdateEnemyWeights; <>O.<2>__UpdateEnemyWeights = val3; obj3 = (object)val3; } StartOfRound.SetPlanetsWeather += (hook_SetPlanetsWeather)obj3; object obj4 = <>O.<3>__EnsureCorrectEnemyVariables; if (obj4 == null) { hook_Start val4 = EnsureCorrectEnemyVariables; <>O.<3>__EnsureCorrectEnemyVariables = val4; obj4 = (object)val4; } EnemyAI.Start += (hook_Start)obj4; object obj5 = <>O.<4>__AddEnemiesToDebugList; if (obj5 == null) { hook_Start val5 = AddEnemiesToDebugList; <>O.<4>__AddEnemiesToDebugList = val5; obj5 = (object)val5; } QuickMenuManager.Start += (hook_Start)obj5; object obj6 = <>O.<5>__StopDawnEnemyResetting; if (obj6 == null) { Manipulator val6 = StopDawnEnemyResetting; <>O.<5>__StopDawnEnemyResetting = val6; obj6 = (object)val6; } RoundManager.SpawnRandomDaytimeEnemy += (Manipulator)obj6; object obj7 = <>O.<5>__StopDawnEnemyResetting; if (obj7 == null) { Manipulator val7 = StopDawnEnemyResetting; <>O.<5>__StopDawnEnemyResetting = val7; obj7 = (object)val7; } RoundManager.AssignRandomEnemyToVent += (Manipulator)obj7; object obj8 = <>O.<5>__StopDawnEnemyResetting; if (obj8 == null) { Manipulator val8 = StopDawnEnemyResetting; <>O.<5>__StopDawnEnemyResetting = val8; obj8 = (object)val8; } RoundManager.SpawnRandomOutsideEnemy += (Manipulator)obj8; object obj9 = <>O.<5>__StopDawnEnemyResetting; if (obj9 == null) { Manipulator val9 = StopDawnEnemyResetting; <>O.<5>__StopDawnEnemyResetting = val9; obj9 = (object)val9; } RoundManager.SpawnRandomWeedEnemy += (Manipulator)obj9; object obj10 = <>O.<5>__StopDawnEnemyResetting; if (obj10 == null) { Manipulator val10 = StopDawnEnemyResetting; <>O.<5>__StopDawnEnemyResetting = val10; obj10 = (object)val10; } RoundManager.PredictAllOutsideEnemies += (Manipulator)obj10; DetourContext val11 = new DetourContext(int.MaxValue); try { object obj11 = <>O.<6>__AddBestiaryNodes; if (obj11 == null) { hook_Awake val12 = AddBestiaryNodes; <>O.<6>__AddBestiaryNodes = val12; obj11 = (object)val12; } Terminal.Awake += (hook_Awake)obj11; object obj12 = <>O.<7>__CollectAllEnemyTypes; if (obj12 == null) { hook_Start val13 = CollectAllEnemyTypes; <>O.<7>__CollectAllEnemyTypes = val13; obj12 = (object)val13; } GameNetworkManager.Start += (hook_Start)obj12; object obj13 = <>O.<8>__GrabModdedBestiaryNodes; if (obj13 == null) { hook_Start val14 = GrabModdedBestiaryNodes; <>O.<8>__GrabModdedBestiaryNodes = val14; obj13 = (object)val14; } Terminal.Start += (hook_Start)obj13; } finally { ((IDisposable)val11)?.Dispose(); } LethalContent.Moons.OnFreezeWithContext += delegate { RegisterEnemies(); }; LethalContent.Enemies.OnFreezeWithContext += delegate { RedoEnemiesDebugMenu(); }; LethalContent.Enemies.OnFreezeWithContext += delegate { FixDawnEnemyReferences(); }; } private static void GrabModdedBestiaryNodes(orig_Start orig, Terminal self) { orig.Invoke(self); foreach (DawnEnemyInfo value in LethalContent.Enemies.Values) { ScanNodeProperties componentInChildren = value.EnemyType.enemyPrefab.GetComponentInChildren(); if (!((Object)(object)componentInChildren != (Object)null)) { continue; } int creatureScanID = componentInChildren.creatureScanID; CompatibleNoun[] compatibleNouns = TerminalRefs.InfoKeyword.compatibleNouns; foreach (CompatibleNoun val in compatibleNouns) { if (val.result.creatureFileID == creatureScanID) { value.BestiaryNode = val.result; value.NameKeyword = val.noun; break; } } } } private static void StopDawnEnemyResetting(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int firstEnemyTypeLoc = -1; ILLabel firstSkip = null; if (!val.TryGotoNext((MoveType)2, new Func[2] { (Instruction c) => ILPatternMatchingExt.MatchLdfld(c, "enemyType"), (Instruction c) => ILPatternMatchingExt.MatchStloc(c, ref firstEnemyTypeLoc) })) { DawnPlugin.Logger.LogError((object)("Failed to apply " + ((MemberReference)il.Method).Name + " patch (0)!")); return; } if (!val.TryGotoNext((MoveType)2, new Func[1] { (Instruction c) => ILPatternMatchingExt.MatchBrfalse(c, ref firstSkip) })) { DawnPlugin.Logger.LogError((object)("Failed to apply " + ((MemberReference)il.Method).Name + " patch (1)!")); return; } val.Emit(OpCodes.Ldloc, firstEnemyTypeLoc); val.EmitDelegate>((Func)DawnLibHandledEnemy); val.Emit(OpCodes.Brfalse_S, (object)firstSkip); if (!((MemberReference)il.Method).Name.Contains("PredictAllOutsideEnemies") && !((MemberReference)il.Method).Name.Contains("SpawnRandomWeedEnemy")) { int secondEnemyTypeLoc = -1; ILLabel secondSkip = null; FieldReference val2 = default(FieldReference); if (!val.TryGotoNext((MoveType)2, new Func[5] { (Instruction c) => ILPatternMatchingExt.MatchLdfld(c, "enemyType"), (Instruction c) => ILPatternMatchingExt.MatchStloc(c, ref secondEnemyTypeLoc), (Instruction c) => ILPatternMatchingExt.MatchLdarg(c, 0), (Instruction c) => ILPatternMatchingExt.MatchLdfld(c, ref val2), (Instruction c) => ILPatternMatchingExt.MatchBrfalse(c, ref secondSkip) })) { DawnPlugin.Logger.LogError((object)("Failed to apply " + ((MemberReference)il.Method).Name + " patch (2)!")); return; } val.Emit(OpCodes.Ldloc, secondEnemyTypeLoc); val.EmitDelegate>((Func)DawnLibHandledEnemy); val.Emit(OpCodes.Brfalse_S, (object)secondSkip); } } private static bool DawnLibHandledEnemy(EnemyType enemyType) { return EnemyTypeExtensions.get_DawnInfo(enemyType)?.ShouldSkipRespectOverride() ?? true; } private static void FixDawnEnemyReferences() { CadaverGrowthAI component = LethalContent.Enemies[EnemyKeys.CadaverGrowths].EnemyType.enemyPrefab.GetComponent(); GameObject faceSporesPrefab = component.faceSporesPrefab; GameObject cadaverSporesParticle = component.CadaverSporesParticle; CadaverGrowthAI val = default(CadaverGrowthAI); foreach (DawnEnemyInfo value in LethalContent.Enemies.Values) { if (!value.ShouldSkipIgnoreOverride() && value.EnemyType.enemyPrefab.TryGetComponent(ref val)) { val.faceSporesPrefab = faceSporesPrefab; val.CadaverSporesParticle = cadaverSporesParticle; } } } private static bool CheckIfEnemyCanSpawn(orig_AssignRandomEnemyToVent orig, RoundManager self, EnemyVent vent, float spawnTime) { if (self.enemyRushIndex == -1) { return orig.Invoke(self, vent, spawnTime); } List list = new List(); foreach (EnemyType item in self.currentLevel.Enemies.Select((SpawnableEnemyWithRarity def) => def.enemyType)) { if (EnemyTypeExtensions.get_DawnInfo(item) != null) { DawnEnemyInfo dawnEnemyInfo = EnemyTypeExtensions.get_DawnInfo(item); if (!dawnEnemyInfo.ShouldSkipRespectOverride() && !dawnEnemyInfo.EnemyType.spawningDisabled && dawnEnemyInfo.Inside.GetRarity() <= 0) { item.spawningDisabled = true; list.Add(item); } } } orig.Invoke(self, vent, spawnTime); foreach (EnemyType item2 in list) { item2.spawningDisabled = false; } return true; } private static void RedoEnemiesDebugMenu() { QuickMenuManagerRefs.Instance.Debug_SetEnemyDropdownOptions(); } private static void CollectAllEnemyTypes(orig_Start orig, GameNetworkManager self) { orig.Invoke(self); EnemyAI val = default(EnemyAI); foreach (NetworkPrefab prefab in NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs) { if (prefab.Prefab.TryGetComponent(ref val) && !((Object)(object)val.enemyType == (Object)null) && !_networkPrefabEnemyTypes.Contains(val.enemyType)) { _networkPrefabEnemyTypes.Add(val.enemyType); } } } private static void AddBestiaryNodes(orig_Awake orig, Terminal self) { foreach (DawnEnemyInfo value in LethalContent.Enemies.Values) { if (!value.ShouldSkipIgnoreOverride() && !((Object)(object)value.BestiaryNode == (Object)null) && !((Object)(object)value.NameKeyword == (Object)null)) { AddScanNodeToBestiaryEvent(value.EnemyType.enemyPrefab, value.BestiaryNode, value.NameKeyword); } } orig.Invoke(self); } private static void AddScanNodeToBestiaryEvent(GameObject gameObjectWithScanNodes, TerminalNode bestiaryNode, TerminalKeyword nameKeyword) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown List list = TerminalRefs.Instance.terminalNodes.allKeywords.ToList(); List list2 = TerminalRefs.InfoKeyword.compatibleNouns.ToList(); bestiaryNode.creatureFileID = TerminalRefs.Instance.enemyFiles.Count; TerminalRefs.Instance.enemyFiles.Add(bestiaryNode); ScanNodeProperties[] componentsInChildren = gameObjectWithScanNodes.GetComponentsInChildren(); ScanNodeProperties[] array = componentsInChildren; foreach (ScanNodeProperties val in array) { val.creatureScanID = bestiaryNode.creatureFileID; } if (!list.Contains(nameKeyword)) { nameKeyword.defaultVerb = TerminalRefs.InfoKeyword; list.Add(nameKeyword); list2.Add(new CompatibleNoun(nameKeyword, bestiaryNode)); TerminalRefs.InfoKeyword.compatibleNouns = list2.ToArray(); TerminalRefs.Instance.terminalNodes.allKeywords = list.ToArray(); } } private static void AddEnemiesToDebugList(orig_Start orig, QuickMenuManager self) { //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown SelectableLevel level = LethalContent.Moons[MoonKeys.Test].Level; foreach (DawnEnemyInfo enemyInfo in LethalContent.Enemies.Values) { if (!enemyInfo.ShouldSkipIgnoreOverride()) { SpawnableEnemyWithRarity item = new SpawnableEnemyWithRarity(enemyInfo.EnemyType, 0); if (level.Enemies.All((SpawnableEnemyWithRarity enemy) => (Object)(object)enemy.enemyType != (Object)(object)enemyInfo.EnemyType)) { Debuggers.Enemies?.Log($"Adding {enemyInfo.EnemyType} to test level {((Object)level).name} inside."); level.Enemies.Add(item); } if (level.OutsideEnemies.All((SpawnableEnemyWithRarity enemy) => (Object)(object)enemy.enemyType != (Object)(object)enemyInfo.EnemyType)) { Debuggers.Enemies?.Log($"Adding {enemyInfo.EnemyType} to test level {((Object)level).name} outside."); level.OutsideEnemies.Add(item); } if (level.DaytimeEnemies.All((SpawnableEnemyWithRarity enemy) => (Object)(object)enemy.enemyType != (Object)(object)enemyInfo.EnemyType)) { Debuggers.Enemies?.Log($"Adding {enemyInfo.EnemyType} to test level {((Object)level).name} daytime."); level.DaytimeEnemies.Add(item); } if (level.OutsideEnemies.All((SpawnableEnemyWithRarity enemy) => (Object)(object)enemy.enemyType != (Object)(object)enemyInfo.EnemyType)) { Debuggers.Enemies?.Log($"Adding {enemyInfo.EnemyType} to test level {((Object)level).name} outside (but it is a weed!)."); level.OutsideEnemies.Add(item); } } } orig.Invoke(self); } private static void EnsureCorrectEnemyVariables(orig_Start orig, EnemyAI self) { //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) if (EnemyTypeExtensions.get_DawnInfo(self.enemyType) == null) { DawnPlugin.Logger.LogError((object)("Enemy with names " + ((Object)self.enemyType).name + " and " + self.enemyType.enemyName + " has no DawnEnemyInfo, this means this enemy is not properly registered.")); orig.Invoke(self); return; } DawnEnemyInfo dawnEnemyInfo = EnemyTypeExtensions.get_DawnInfo(self.enemyType); if (dawnEnemyInfo.ShouldSkipRespectOverride() || StarlancerAIFixCompat.Enabled) { orig.Invoke(self); return; } GameObject[] insideAINodes = RoundManager.Instance.insideAINodes; GameObject[] outsideAINodes = RoundManager.Instance.outsideAINodes; float num = float.MaxValue; bool flag = true; if (insideAINodes != null) { GameObject[] array = insideAINodes; foreach (GameObject val in array) { if (!((Object)(object)val == (Object)null)) { float num2 = Vector3.Distance(val.transform.position, ((Component)self).transform.position); if (!(num2 >= num)) { num = num2; } } } } if (outsideAINodes != null) { GameObject[] array2 = outsideAINodes; foreach (GameObject val2 in array2) { if (!((Object)(object)val2 == (Object)null)) { float num3 = Vector3.Distance(val2.transform.position, ((Component)self).transform.position); if (num3 < num) { num = num3; flag = false; break; } } } } bool isOutsideEnemy = self.enemyType.isOutsideEnemy; if (flag) { self.enemyType.isOutsideEnemy = false; } else { self.enemyType.isOutsideEnemy = true; } orig.Invoke(self); if (isOutsideEnemy != self.enemyType.isOutsideEnemy) { self.enemyType.isOutsideEnemy = isOutsideEnemy; } } private static void UpdateEnemyWeights(orig_RefreshEnemiesList orig, RoundManager self) { UpdateEnemyWeightsOnLevel(self.currentLevel); orig.Invoke(self); } private static void UpdateEnemyWeights(orig_SetPlanetsWeather orig, StartOfRound self, int connectedPlayersOnServer) { orig.Invoke(self, connectedPlayersOnServer); UpdateEnemyWeightsOnLevel(self.currentLevel); } internal static void UpdateEnemyWeightsOnLevel(SelectableLevel level) { //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_017d: 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_0162: Expected O, but got Unknown //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Expected O, but got Unknown //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Expected O, but got Unknown if (!LethalContent.Weathers.IsFrozen || !LethalContent.Enemies.IsFrozen || (Object)(object)StartOfRound.Instance == (Object)null || (WeatherRegistryCompat.Enabled && !WeatherRegistryCompat.IsWeatherManagerReady())) { return; } DawnDungeonInfo currentDungeonInfo = RoundManagerRefs.GetCurrentDungeonInfo(); DawnMoonInfo moonInfo = SelectableLevelExtensions.get_DawnInfo(level); foreach (DawnEnemyInfo enemyInfo in LethalContent.Enemies.Values) { if (!enemyInfo.ShouldSkipRespectOverride()) { Debuggers.Enemies?.Log($"Updating weights for {enemyInfo.EnemyType} on level {level.PlanetName}"); Debuggers.Enemies?.Log("Updating Outside weights"); SpawnableEnemyWithRarity val = ((IEnumerable)level.OutsideEnemies).FirstOrDefault((Func)((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)enemyInfo.EnemyType)); if (val == null) { val = new SpawnableEnemyWithRarity(enemyInfo.EnemyType, 0); level.OutsideEnemies.Add(val); } int rarity = enemyInfo.Outside.GetRarity(moonInfo, currentDungeonInfo, LevelWeatherTypeExtensions.get_DawnInfo(level.currentWeather)); val.rarity = rarity; Debuggers.Enemies?.Log("Updating Inside weights"); SpawnableEnemyWithRarity val2 = ((IEnumerable)level.Enemies).FirstOrDefault((Func)((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)enemyInfo.EnemyType)); if (val2 == null) { val2 = new SpawnableEnemyWithRarity(enemyInfo.EnemyType, 0); level.Enemies.Add(val2); } int rarity2 = enemyInfo.Inside.GetRarity(moonInfo, currentDungeonInfo, LevelWeatherTypeExtensions.get_DawnInfo(level.currentWeather)); val2.rarity = rarity2; Debuggers.Enemies?.Log("Updating Daytime weights"); SpawnableEnemyWithRarity val3 = ((IEnumerable)level.DaytimeEnemies).FirstOrDefault((Func)((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)enemyInfo.EnemyType)); if (val3 == null) { val3 = new SpawnableEnemyWithRarity(enemyInfo.EnemyType, 0); level.DaytimeEnemies.Add(val3); } int rarity3 = enemyInfo.Daytime.GetRarity(moonInfo, currentDungeonInfo, LevelWeatherTypeExtensions.get_DawnInfo(level.currentWeather)); val3.rarity = rarity3; Debuggers.Enemies?.Log("Updating Weed weights"); SpawnableEnemyWithRarity val4 = ((IEnumerable)SelectableLevelExtensions.get_WeedEnemies(level)).FirstOrDefault((Func)((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)enemyInfo.EnemyType)); if (val4 == null) { Debuggers.Enemies?.Log($"Adding weed spawnable {enemyInfo.EnemyType} to the moon"); val4 = new SpawnableEnemyWithRarity(enemyInfo.EnemyType, 0); SelectableLevelExtensions.get_WeedEnemies(level).Add(val4); } int rarity4 = enemyInfo.Weed.GetRarity(moonInfo, currentDungeonInfo, LevelWeatherTypeExtensions.get_DawnInfo(level.currentWeather)); val4.rarity = rarity4; } } RoundManagerRefs.Instance.WeedEnemies.RemoveAll((SpawnableEnemyWithRarity x) => !EnemyTypeExtensions.get_DawnInfo(x.enemyType).ShouldSkipRespectOverride()); foreach (SpawnableEnemyWithRarity item in SelectableLevelExtensions.get_WeedEnemies(level).ToList()) { if (!((Object)(object)item.enemyType == (Object)null) && !EnemyTypeExtensions.get_DawnInfo(item.enemyType).ShouldSkipRespectOverride()) { RoundManagerRefs.Instance.WeedEnemies.Add(item); } } } private static void RegisterEnemies() { TerminalKeyword infoKeyword = TerminalRefs.InfoKeyword; foreach (EnemyType networkPrefabEnemyType in _networkPrefabEnemyTypes) { if ((Object)(object)networkPrefabEnemyType == (Object)null || (Object)(object)networkPrefabEnemyType.enemyPrefab == (Object)null || EnemyTypeExtensions.get_DawnInfo(networkPrefabEnemyType) != null) { continue; } string name = NamespacedKey.NormalizeStringForNamespacedKey(networkPrefabEnemyType.enemyName, CSharpName: true); NamespacedKey namespacedKey = EnemyKeys.GetByReflection(name); string modName2; if (namespacedKey == null && LethalLibCompat.Enabled && LethalLibCompat.TryGetEnemyTypeFromLethalLib(networkPrefabEnemyType, out string modName)) { namespacedKey = NamespacedKey.From(modName, networkPrefabEnemyType.enemyName); } else if (namespacedKey == null && LethalLevelLoaderCompat.Enabled && LethalLevelLoaderCompat.TryGetExtendedEnemyTypeModName(networkPrefabEnemyType, out modName2)) { namespacedKey = NamespacedKey.From(modName2, networkPrefabEnemyType.enemyName); } else if (namespacedKey == null) { namespacedKey = NamespacedKey.From("unknown_lib", networkPrefabEnemyType.enemyName); } if (LethalContent.Enemies.ContainsKey(namespacedKey)) { DawnPlugin.Logger.LogWarning((object)("Enemy " + networkPrefabEnemyType.enemyName + " is already registered by the same creator to LethalContent. This is likely to cause issues.")); EnemyTypeExtensions.set_DawnInfo(networkPrefabEnemyType, LethalContent.Enemies[namespacedKey]); continue; } if (!Object.op_Implicit((Object)(object)networkPrefabEnemyType.enemyPrefab)) { DawnPlugin.Logger.LogWarning((object)(networkPrefabEnemyType.enemyName + " (" + ((Object)networkPrefabEnemyType).name + ") didn't have a spawn prefab?")); continue; } DawnEnemyLocationInfo dawnEnemyLocationInfo = null; DawnEnemyLocationInfo dawnEnemyLocationInfo2 = null; DawnEnemyLocationInfo dawnEnemyLocationInfo3 = null; DawnEnemyLocationInfo dawnEnemyLocationInfo4 = null; WeightProfile weightProfile = new WeightProfile(DawnWeightChannels.EnemyRarity.Policy); weightProfile.AddSource(new EnemyListBaseRaritySource(networkPrefabEnemyType, (SelectableLevel val) => RoundManagerRefs.Instance.WeedEnemies)); DawnWeightedValue rarity = new DawnWeightedValue(DawnWeightChannels.EnemyRarity, weightProfile); dawnEnemyLocationInfo4 = new DawnEnemyLocationInfo(rarity); WeightProfile weightProfile2 = new WeightProfile(DawnWeightChannels.EnemyRarity.Policy); weightProfile2.AddSource(new EnemyListBaseRaritySource(networkPrefabEnemyType, (SelectableLevel val) => val.Enemies)); DawnWeightedValue rarity2 = new DawnWeightedValue(DawnWeightChannels.EnemyRarity, weightProfile2); dawnEnemyLocationInfo = new DawnEnemyLocationInfo(rarity2); WeightProfile weightProfile3 = new WeightProfile(DawnWeightChannels.EnemyRarity.Policy); weightProfile3.AddSource(new EnemyListBaseRaritySource(networkPrefabEnemyType, (SelectableLevel val) => val.OutsideEnemies)); DawnWeightedValue rarity3 = new DawnWeightedValue(DawnWeightChannels.EnemyRarity, weightProfile3); dawnEnemyLocationInfo2 = new DawnEnemyLocationInfo(rarity3); WeightProfile weightProfile4 = new WeightProfile(DawnWeightChannels.EnemyRarity.Policy); weightProfile4.AddSource(new EnemyListBaseRaritySource(networkPrefabEnemyType, (SelectableLevel val) => val.DaytimeEnemies)); DawnWeightedValue rarity4 = new DawnWeightedValue(DawnWeightChannels.EnemyRarity, weightProfile4); dawnEnemyLocationInfo3 = new DawnEnemyLocationInfo(rarity4); HashSet tags = new HashSet { DawnLibTags.IsExternal }; CollectLLLTags(networkPrefabEnemyType, tags); TerminalNode bestiaryNode = null; TerminalKeyword nameKeyword = null; DawnEnemyInfo value = new DawnEnemyInfo(namespacedKey, tags, networkPrefabEnemyType, dawnEnemyLocationInfo2, dawnEnemyLocationInfo, dawnEnemyLocationInfo3, dawnEnemyLocationInfo4, bestiaryNode, nameKeyword, null); EnemyTypeExtensions.set_DawnInfo(networkPrefabEnemyType, value); LethalContent.Enemies.Register(value); } foreach (DawnMoonInfo value2 in LethalContent.Moons.Values) { SelectableLevel level = value2.Level; foreach (DawnEnemyInfo value3 in LethalContent.Enemies.Values) { if (!value3.ShouldSkipRespectOverride()) { TryAddToEnemyList(value3, level.OutsideEnemies); TryAddToEnemyList(value3, level.DaytimeEnemies); TryAddToEnemyList(value3, level.Enemies); TryAddToEnemyList(value3, SelectableLevelExtensions.get_WeedEnemies(level)); } } } LethalContent.Enemies.Freeze(); } private static void CollectLLLTags(EnemyType enemyType, HashSet tags) { if (LethalLevelLoaderCompat.Enabled && LethalLevelLoaderCompat.TryGetAllTagsWithModNames(enemyType, out List<(string, string)> allTagsWithModNames)) { tags.AddToList(allTagsWithModNames, Debuggers.Enemies, ((Object)enemyType).name); } } private static void TryAddToEnemyList(DawnEnemyInfo enemyInfo, List list) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown foreach (SpawnableEnemyWithRarity item2 in list) { if ((Object)(object)item2.enemyType == (Object)(object)enemyInfo.EnemyType) { return; } } SpawnableEnemyWithRarity item = new SpawnableEnemyWithRarity(enemyInfo.EnemyType, 0); list.Add(item); } } public sealed class DawnEnemyInfo : DawnBaseInfo { public EnemyType EnemyType { get; } public DawnEnemyLocationInfo Outside { get; private set; } public DawnEnemyLocationInfo Inside { get; private set; } public DawnEnemyLocationInfo Daytime { get; private set; } public DawnEnemyLocationInfo Weed { get; private set; } public TerminalNode? BestiaryNode { get; internal set; } public TerminalKeyword? NameKeyword { get; internal set; } internal DawnEnemyInfo(NamespacedKey key, HashSet tags, EnemyType enemyType, DawnEnemyLocationInfo outside, DawnEnemyLocationInfo inside, DawnEnemyLocationInfo daytime, DawnEnemyLocationInfo weed, TerminalNode? bestiaryNode, TerminalKeyword? nameKeyword, IDataContainer? customData) : base(key, tags, customData) { EnemyType = enemyType; Outside = outside; Outside.ParentInfo = this; Inside = inside; Inside.ParentInfo = this; Daytime = daytime; Daytime.ParentInfo = this; Weed = weed; Weed.ParentInfo = this; BestiaryNode = bestiaryNode; NameKeyword = nameKeyword; } public IEnumerable GetAllSpawned(bool strongerCheck = false) where T : EnemyAI { foreach (EnemyAI spawnedEnemy in RoundManager.Instance.SpawnedEnemies) { if ((Object)(object)spawnedEnemy.enemyType == (Object)(object)EnemyType || (strongerCheck && spawnedEnemy.enemyType.enemyName.Equals(EnemyType.enemyName, StringComparison.OrdinalIgnoreCase))) { yield return (T)(object)spawnedEnemy; } } } } public sealed class DawnEnemyLocationInfo { public DawnEnemyInfo ParentInfo { get; internal set; } public DawnWeightedValue Rarity { get; } internal DawnEnemyLocationInfo(DawnWeightedValue rarity) { Rarity = rarity; } public int GetRarity(DawnMoonInfo? moonInfo = null, DawnDungeonInfo? dungeonInfo = null, DawnWeatherEffectInfo? weatherEffectInfo = null) { return Rarity.GetValue(new WeightQuery { Owner = ParentInfo, Subject = this, Moon = moonInfo, Dungeon = dungeonInfo, Weather = weatherEffectInfo, Channel = DawnWeightChannels.EnemyRarity.Key }); } } public class EnemyInfoBuilder : BaseInfoBuilder { public class EnemyLocationBuilder { private DawnWeightedValue? _weights; private EnemyInfoBuilder _parent; public EnemyLocationBuilder SetWeights(Action> callback) { WeightProfile weightProfile = new WeightProfile(DawnWeightChannels.EnemyRarity.Policy); callback(weightProfile); _weights = new DawnWeightedValue(DawnWeightChannels.EnemyRarity, weightProfile); return this; } internal EnemyLocationBuilder(EnemyInfoBuilder parent) { _parent = parent; } internal DawnEnemyLocationInfo Build() { if (_weights == null) { DawnPlugin.Logger.LogWarning((object)$"Enemy '{_parent.key}' didn't set weights. If you intend to have no weights (doing something special), call .SetWeights(() => {{}})"); _weights = new DawnWeightedValue(DawnWeightChannels.EnemyRarity); } return new DawnEnemyLocationInfo(_weights); } } private DawnEnemyLocationInfo? _inside; private DawnEnemyLocationInfo? _outside; private DawnEnemyLocationInfo? _daytime; private DawnEnemyLocationInfo? _weed; private TerminalNode? _bestiaryNode; private TerminalKeyword? _nameKeyword; internal EnemyInfoBuilder(NamespacedKey key, EnemyType enemyType) : base(key, enemyType) { } public EnemyInfoBuilder DefineOutside(Action callback) { EnemyLocationBuilder enemyLocationBuilder = new EnemyLocationBuilder(this); callback(enemyLocationBuilder); _outside = enemyLocationBuilder.Build(); return this; } public EnemyInfoBuilder DefineInside(Action callback) { EnemyLocationBuilder enemyLocationBuilder = new EnemyLocationBuilder(this); callback(enemyLocationBuilder); _inside = enemyLocationBuilder.Build(); return this; } public EnemyInfoBuilder DefineDaytime(Action callback) { EnemyLocationBuilder enemyLocationBuilder = new EnemyLocationBuilder(this); callback(enemyLocationBuilder); _daytime = enemyLocationBuilder.Build(); return this; } public EnemyInfoBuilder DefineWeed(Action callback) { EnemyLocationBuilder enemyLocationBuilder = new EnemyLocationBuilder(this); callback(enemyLocationBuilder); _weed = enemyLocationBuilder.Build(); return this; } public EnemyInfoBuilder CreateBestiaryNode(string bestiaryNodeText) { _bestiaryNode = new TerminalNodeBuilder(base.value.enemyName + "BestiaryNode").SetDisplayText(bestiaryNodeText).SetCreatureName(base.value.enemyName).SetClearPreviousText(clearPreviousText: true) .SetMaxCharactersToType(35) .Build(); return this; } public EnemyInfoBuilder SetBestiaryVideo(VideoClip videoClip) { if ((Object)(object)_bestiaryNode == (Object)null) { throw new InvalidOperationException("Must first call CreateBestiaryNode before setting video."); } _bestiaryNode.displayVideo = videoClip; return this; } public EnemyInfoBuilder CreateNameKeyword(string wordOverride) { if (string.IsNullOrWhiteSpace(wordOverride)) { wordOverride = base.value.enemyName.ToLowerInvariant(); } _nameKeyword = new TerminalKeywordBuilder(base.value.enemyName + "NameKeyword", wordOverride, ITerminalKeyword.DawnKeywordType.Bestiary).Build(); return this; } internal override DawnEnemyInfo Build() { if (_outside == null) { _outside = new DawnEnemyLocationInfo(new DawnWeightedValue(DawnWeightChannels.EnemyRarity)); } if (_inside == null) { _inside = new DawnEnemyLocationInfo(new DawnWeightedValue(DawnWeightChannels.EnemyRarity)); } if (_daytime == null) { _daytime = new DawnEnemyLocationInfo(new DawnWeightedValue(DawnWeightChannels.EnemyRarity)); } if (_weed == null) { _weed = new DawnEnemyLocationInfo(new DawnWeightedValue(DawnWeightChannels.EnemyRarity)); } return new DawnEnemyInfo(base.key, tags, base.value, _outside, _inside, _daytime, _weed, _bestiaryNode, _nameKeyword, customData); } } public static class EnemyTypeExtensions { [SpecialName] public sealed class $9983E67FC52B66B02F6BDD805E334468 { [SpecialName] public static class $DAE9DE91A06FE81BAA4DCCD86008E937 { } [ExtensionMarker("$DAE9DE91A06FE81BAA4DCCD86008E937")] public DawnEnemyInfo DawnInfo { [ExtensionMarker("$DAE9DE91A06FE81BAA4DCCD86008E937")] get { throw new NotSupportedException(); } [ExtensionMarker("$DAE9DE91A06FE81BAA4DCCD86008E937")] set { throw new NotSupportedException(); } } [ExtensionMarker("$DAE9DE91A06FE81BAA4DCCD86008E937")] [Obsolete("Use EnemyType.DawnInfo instead")] public DawnEnemyInfo GetDawnInfo() { throw new NotSupportedException(); } [ExtensionMarker("$DAE9DE91A06FE81BAA4DCCD86008E937")] [Obsolete("Use EnemyType.DawnInfo instead")] public void SetDawnInfo(DawnEnemyInfo enemyTypeInfo) { throw new NotSupportedException(); } [ExtensionMarker("$DAE9DE91A06FE81BAA4DCCD86008E937")] [Obsolete] public bool HasDawnInfo() { throw new NotSupportedException(); } [ExtensionMarker("$DAE9DE91A06FE81BAA4DCCD86008E937")] private DawnEnemyInfo GetDawnInfoCore() { throw new NotSupportedException(); } [ExtensionMarker("$DAE9DE91A06FE81BAA4DCCD86008E937")] private void SetDawnInfoCore(DawnEnemyInfo enemyTypeInfo) { throw new NotSupportedException(); } } public static DawnEnemyInfo get_DawnInfo(EnemyType enemyType) { return enemyType.GetDawnInfoCore(); } public static void set_DawnInfo(EnemyType enemyType, DawnEnemyInfo value) { enemyType.SetDawnInfoCore(value); } [Obsolete("Use EnemyType.DawnInfo instead")] public static DawnEnemyInfo GetDawnInfo(this EnemyType enemyType) { return enemyType.GetDawnInfoCore(); } [Obsolete("Use EnemyType.DawnInfo instead")] public static void SetDawnInfo(this EnemyType enemyType, DawnEnemyInfo enemyTypeInfo) { enemyType.SetDawnInfoCore(enemyTypeInfo); } [Obsolete] public static bool HasDawnInfo(this EnemyType enemyType) { return get_DawnInfo(enemyType) != null; } private static DawnEnemyInfo GetDawnInfoCore(this EnemyType enemyType) { return ((IEnemyTypeDawnObject)enemyType).DawnInfo; } private static void SetDawnInfoCore(this EnemyType enemyType, DawnEnemyInfo enemyTypeInfo) { ((IEnemyTypeDawnObject)enemyType).DawnInfo = enemyTypeInfo; } } public class BundleException : Exception { public AssetBundle Bundle { get; } public BundleException(AssetBundle bundle, string message) { Bundle = bundle; base..ctor(message); } } public class MalformedAnimationCurveConfigException(string pair) : Exception() { public string Pair { get; } = pair; public void LogNicely(ManualLogSource? logger) { if (logger != null) { string[] array = (from s in Pair.Split(',') select s.Trim()).ToArray(); logger.LogError((object)("Invalid key,value pair format: '" + Pair + "'! More details:")); logger.LogError((object)$" Found '{array.Length}' parts"); if (array.Length != 2) { logger.LogError((object)" FAIL -> Should have only 2 parts!"); return; } LogNicelyFloatParse(logger, "first", array[0]); LogNicelyFloatParse(logger, "second", array[1]); } } private void LogNicelyFloatParse(ManualLogSource logger, string context, string value) { logger.LogError((object)(" Attempting to parse " + context + " value: '" + value + "'")); if (float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { logger.LogError((object)$" Parsed {context} value! Parsed Value is {result}"); } else { logger.LogError((object)$" FAIL -> Couldn't parse {context} value! Parsed Value is {result}"); } } } public interface IPredicate { bool Evaluate(); } public class ConstantPredicate : IPredicate { public static readonly ConstantPredicate True = new ConstantPredicate(value: true); public static readonly ConstantPredicate False = new ConstantPredicate(value: false); private bool _value; private ConstantPredicate(bool value) { _value = value; } public bool Evaluate() { return _value; } } public interface IProvider { T Provide(); } public class SimpleProvider(T value) : IProvider { public T Provide() { return P; } } public class ConfigEntryProvider(ConfigEntry configEntry) : IProvider { public T Provide() { return P.Value; } } public class FuncProvider(Func function) : IProvider { public T Provide() { return P(); } } internal static class ItemRegistrationHandler { [CompilerGenerated] private static class <>O { public static hook_Awake <0>__RegisterScrapItems; public static hook_Awake <1>__RegisterShopItemsToTerminal; public static hook_SpawnScrapInLevel <2>__UpdateItemWeights; public static hook_SetPlanetsWeather <3>__UpdateItemWeights; } internal static void Init() { //IL_02a5: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Expected O, but got Unknown //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Expected O, but got Unknown //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Expected O, but got Unknown //IL_02fc: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Expected O, but got Unknown //IL_0312: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Expected O, but got Unknown //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Expected O, but got Unknown LethalContent.Items.AddAutoTaggers(new AutoNonInteractableTagger(), new SimpleAutoTagger(Tags.Conductive, (DawnItemInfo itemInfo) => itemInfo.Item.isConductiveMetal), new SimpleAutoTagger(Tags.Noisy, (DawnItemInfo itemInfo) => (Object)(object)itemInfo.Item.spawnPrefab.GetComponent() != (Object)null), new SimpleAutoTagger(Tags.Interactable, (DawnItemInfo itemInfo) => !itemInfo.HasTag(Tags.NonInteractable) && !itemInfo.HasTag(Tags.Noisy)), new SimpleAutoTagger(Tags.Paid, (DawnItemInfo itemInfo) => itemInfo.ShopInfo != null), new SimpleAutoTagger(Tags.Scrap, (DawnItemInfo itemInfo) => itemInfo.ScrapInfo != null), new SimpleAutoTagger(Tags.Chargeable, (DawnItemInfo itemInfo) => itemInfo.Item.requiresBattery), new SimpleAutoTagger(Tags.TwoHanded, (DawnItemInfo itemInfo) => itemInfo.Item.twoHanded), new SimpleAutoTagger(Tags.OneHanded, (DawnItemInfo itemInfo) => !itemInfo.Item.twoHanded), new SimpleAutoTagger(Tags.Weapon, (DawnItemInfo itemInfo) => itemInfo.Item.isDefensiveWeapon), new AutoItemGroupTagger(Tags.GeneralItemClassGroup, "GeneralItemClass"), new AutoItemGroupTagger(Tags.SmallItemsGroup, "SmallItems"), new AutoItemGroupTagger(Tags.TabletopItemsGroup, "TabletopItems"), new AutoItemGroupTagger(Tags.TestItemGroup, "TestItem"), new AutoValueTagger(Tags.LowValue, new BoundedRange(0f, 100f)), new AutoValueTagger(Tags.MediumValue, new BoundedRange(100f, 200f)), new AutoValueTagger(Tags.HighValue, new BoundedRange(200f, 2.1474836E+09f)), new AutoWeightTagger(Tags.LightWeight, new BoundedRange(0f, 1.2f)), new AutoWeightTagger(Tags.MediumWeight, new BoundedRange(1.2f, 1.4f)), new AutoWeightTagger(Tags.HeavyWeight, new BoundedRange(1.4f, 2.1474836E+09f))); DetourContext val = new DetourContext(2147483638); try { object obj = <>O.<0>__RegisterScrapItems; if (obj == null) { hook_Awake val2 = RegisterScrapItems; <>O.<0>__RegisterScrapItems = val2; obj = (object)val2; } StartOfRound.Awake += (hook_Awake)obj; object obj2 = <>O.<1>__RegisterShopItemsToTerminal; if (obj2 == null) { hook_Awake val3 = RegisterShopItemsToTerminal; <>O.<1>__RegisterShopItemsToTerminal = val3; obj2 = (object)val3; } Terminal.Awake += (hook_Awake)obj2; } finally { ((IDisposable)val)?.Dispose(); } DetourContext val4 = new DetourContext(int.MinValue); try { object obj3 = <>O.<2>__UpdateItemWeights; if (obj3 == null) { hook_SpawnScrapInLevel val5 = UpdateItemWeights; <>O.<2>__UpdateItemWeights = val5; obj3 = (object)val5; } RoundManager.SpawnScrapInLevel += (hook_SpawnScrapInLevel)obj3; } finally { ((IDisposable)val4)?.Dispose(); } object obj4 = <>O.<3>__UpdateItemWeights; if (obj4 == null) { hook_SetPlanetsWeather val6 = UpdateItemWeights; <>O.<3>__UpdateItemWeights = val6; obj4 = (object)val6; } StartOfRound.SetPlanetsWeather += (hook_SetPlanetsWeather)obj4; LethalContent.Moons.OnFreezeWithContext += delegate { FreezeItemContent(); }; LethalContent.Items.OnFreezeWithContext += delegate { RedoItemsDebugMenu(); }; } private static void RegisterScrapItems(orig_Awake orig, StartOfRound self) { if (LethalContent.Items.IsFrozen) { orig.Invoke(self); return; } foreach (DawnItemInfo value in LethalContent.Items.Values) { if (!value.ShouldSkipIgnoreOverride() && !self.allItemsList.itemsList.Contains(value.Item)) { self.allItemsList.itemsList.Add(value.Item); } } orig.Invoke(self); } private static void RedoItemsDebugMenu() { QuickMenuManagerRefs.Instance.Debug_SetAllItemsDropdownOptions(); } internal static void UpdateAllShopItemPrices() { foreach (DawnItemInfo value in LethalContent.Items.Values) { DawnShopItemInfo shopInfo = value.ShopInfo; if (shopInfo != null && !value.ShouldSkipRespectOverride()) { UpdateShopItemPrices(shopInfo); } } } private static void UpdateShopItemPrices(DawnShopItemInfo shopInfo) { int num = shopInfo.DawnPurchaseInfo.Cost.Provide(); shopInfo.ParentInfo.Item.creditsWorth = num; shopInfo.ReceiptNode.itemCost = num; shopInfo.RequestNode.itemCost = num; } private static void UpdateItemWeights(orig_SpawnScrapInLevel orig, RoundManager self) { UpdateItemWeightsOnLevel(self.currentLevel); List list = new List(); SpawnableItemWithRarity[] array = self.currentLevel.spawnableScrap.ToArray(); foreach (SpawnableItemWithRarity val in array) { if (val.rarity <= 0) { list.Add(val); self.currentLevel.spawnableScrap.Remove(val); } } orig.Invoke(self); foreach (SpawnableItemWithRarity item in list) { self.currentLevel.spawnableScrap.Add(item); } } private static void UpdateItemWeights(orig_SetPlanetsWeather orig, StartOfRound self, int connectedPlayersOnServer) { orig.Invoke(self, connectedPlayersOnServer); UpdateItemWeightsOnLevel(self.currentLevel); } internal static void UpdateItemWeightsOnLevel(SelectableLevel level) { //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown if (!LethalContent.Weathers.IsFrozen || !LethalContent.Items.IsFrozen || (Object)(object)StartOfRound.Instance == (Object)null || (WeatherRegistryCompat.Enabled && !WeatherRegistryCompat.IsWeatherManagerReady())) { return; } foreach (DawnItemInfo itemInfo in LethalContent.Items.Values) { DawnScrapItemInfo scrapInfo = itemInfo.ScrapInfo; if (scrapInfo != null && !itemInfo.ShouldSkipRespectOverride()) { Debuggers.Items?.Log("Updating " + itemInfo.Item.itemName + "'s weights on level " + level.PlanetName + "."); SpawnableItemWithRarity val = ((IEnumerable)level.spawnableScrap).FirstOrDefault((Func)((SpawnableItemWithRarity x) => (Object)(object)x.spawnableItem == (Object)(object)itemInfo.Item)); if (val == null) { val = new SpawnableItemWithRarity(itemInfo.Item, 0); level.spawnableScrap.Add(val); } int rarity = scrapInfo.GetRarity(SelectableLevelExtensions.get_DawnInfo(level), RoundManagerRefs.GetCurrentDungeonInfo(), LevelWeatherTypeExtensions.get_DawnInfo(level.currentWeather)); val.rarity = rarity; } } } private static void FreezeItemContent() { //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Expected O, but got Unknown Dictionary dictionary = new Dictionary(); foreach (DawnMoonInfo value4 in LethalContent.Moons.Values) { SelectableLevel level = value4.Level; Dictionary dictionary2 = new Dictionary(); for (int num = level.spawnableScrap.Count - 1; num >= 0; num--) { SpawnableItemWithRarity val = level.spawnableScrap[num]; if (dictionary2.ContainsKey(val.spawnableItem)) { DawnPlugin.Logger.LogWarning((object)("Duplicate item found in level " + level.PlanetName + " with name " + ((Object)val.spawnableItem).name + ", adding weight to previous entry to avoid issues.")); level.spawnableScrap.Remove(val); SpawnableItemWithRarity obj = dictionary2[val.spawnableItem]; obj.rarity += val.rarity; } else { dictionary2[val.spawnableItem] = val; } } } Terminal instance = TerminalRefs.Instance; TerminalKeyword buyKeyword = TerminalRefs.BuyKeyword; TerminalKeyword infoKeyword = TerminalRefs.InfoKeyword; List list = buyKeyword.compatibleNouns.ToList(); List list2 = infoKeyword.compatibleNouns.ToList(); List list3 = instance.terminalNodes.allKeywords.ToList(); int i; for (i = 0; i < instance.buyableItemsList.Length; i++) { Item val2 = instance.buyableItemsList[i]; TerminalNode val3 = null; TerminalNode requestNode = null; TerminalNode val4 = null; string text = val2.itemName.ToLowerInvariant(); requestNode = (from noun in TerminalRefs.BuyKeyword.compatibleNouns where noun.result.buyItemIndex == i select noun.result).FirstOrDefault(); if ((Object)(object)requestNode == (Object)null) { DawnPlugin.Logger.LogWarning((object)("No request Node found for " + val2.itemName + " despite it being a buyable item, this is likely the result of an item being removed from the shop items list by LethalLib, i.e. Night Vision Goggles from MoreShipUpgrades")); continue; } val4 = requestNode.terminalOptions[0].result; TerminalKeyword val5 = (from noun in TerminalRefs.BuyKeyword.compatibleNouns where (Object)(object)noun.result == (Object)(object)requestNode select noun.noun).FirstOrDefault(); if ((Object)(object)val5 == (Object)null) { DawnPlugin.Logger.LogWarning((object)("No buy Keyword found for " + val2.itemName + " despite it being a buyable item, this is likely the result of an item being removed from the shop items list by LethalLib, i.e. Night Vision Goggles from MoreShipUpgrades")); continue; } CompatibleNoun[] compatibleNouns = infoKeyword.compatibleNouns; foreach (CompatibleNoun val6 in compatibleNouns) { if ((Object)(object)val6.noun == (Object)(object)val5) { val3 = val6.result; break; } } if ((Object)(object)val3 == (Object)null) { val3 = new TerminalNodeBuilder(text + "InfoNode").SetDisplayText("[No information about this object was found.]\n\n").SetClearPreviousText(clearPreviousText: true).SetMaxCharactersToType(25) .Build(); CompatibleNoun item = new CompatibleNoun(val5, val3); List list4 = infoKeyword.compatibleNouns.ToList(); list4.Add(item); infoKeyword.compatibleNouns = list4.ToArray(); } CompatibleNoun[] compatibleNouns2 = buyKeyword.compatibleNouns; foreach (CompatibleNoun val7 in compatibleNouns2) { if ((Object)(object)val7.noun == (Object)(object)val5) { requestNode = val7.result; break; } } DawnPurchaseInfo dawnPurchaseInfo = new DawnPurchaseInfo(new SimpleProvider(val2.creditsWorth), ITerminalPurchasePredicate.AlwaysSuccess()); DawnShopItemInfo value = new DawnShopItemInfo(dawnPurchaseInfo, val3, requestNode, val4); dictionary[((Object)val2).name] = value; } foreach (Item items in StartOfRound.Instance.allItemsList.itemsList) { if (ItemExtensions.get_DawnInfo(items) != null) { continue; } string name = NamespacedKey.NormalizeStringForNamespacedKey(items.itemName, CSharpName: true); NamespacedKey namespacedKey = ItemKeys.GetByReflection(name); string modName2; if (namespacedKey == null && LethalLibCompat.Enabled && LethalLibCompat.TryGetItemFromLethalLib(items, out string modName)) { namespacedKey = NamespacedKey.From(modName, items.itemName); } else if (namespacedKey == null && LethalLevelLoaderCompat.Enabled && LethalLevelLoaderCompat.TryGetExtendedItemModName(items, out modName2)) { namespacedKey = NamespacedKey.From(modName2, items.itemName); } else if (namespacedKey == null) { namespacedKey = NamespacedKey.From("unknown_lib", items.itemName); } if (LethalContent.Items.ContainsKey(namespacedKey)) { DawnPlugin.Logger.LogWarning((object)("Item " + items.itemName + " is already registered by the same creator to LethalContent. This is likely to cause issues.")); ItemExtensions.set_DawnInfo(items, LethalContent.Items[namespacedKey]); continue; } WeightProfile weightProfile = new WeightProfile(DawnWeightChannels.ScrapRarity.Policy); weightProfile.AddSource(new ItemListBaseRaritySource(items)); DawnScrapItemInfo scrapItemInfo = new DawnScrapItemInfo(new DawnWeightedValue(DawnWeightChannels.ScrapRarity, weightProfile)); dictionary.TryGetValue(((Object)items).name, out var value2); if (!Object.op_Implicit((Object)(object)items.spawnPrefab)) { DawnPlugin.Logger.LogWarning((object)(items.itemName + " (" + ((Object)items).name + ") didn't have a spawn prefab?")); continue; } Debuggers.Items?.Log($"Registering {items.itemName} ({((Object)items).name}) with range of values: {(double)items.minValue * 0.4} and {(double)items.maxValue * 0.4}"); HashSet tags = new HashSet { DawnLibTags.IsExternal }; CollectLLLTags(items, tags); DawnItemInfo value3 = new DawnItemInfo(namespacedKey, tags, items, scrapItemInfo, value2, null); ItemExtensions.set_DawnInfo(items, value3); LethalContent.Items.Register(value3); } RegisterScrapItemsToAllLevels(); LethalContent.Items.Freeze(); } private static void RegisterScrapItemsToAllLevels() { //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown foreach (DawnItemInfo value in LethalContent.Items.Values) { DawnScrapItemInfo scrapInfo = value.ScrapInfo; if (scrapInfo == null || value.ShouldSkipRespectOverride()) { continue; } foreach (DawnMoonInfo value2 in LethalContent.Moons.Values) { SelectableLevel level = value2.Level; bool flag = false; foreach (SpawnableItemWithRarity item2 in level.spawnableScrap) { if ((Object)(object)item2.spawnableItem == (Object)(object)value.Item) { flag = true; break; } } if (!flag) { SpawnableItemWithRarity item = new SpawnableItemWithRarity(value.Item, 0); level.spawnableScrap.Add(item); } } } } private static void RegisterShopItemsToTerminal(orig_Awake orig, Terminal self) { orig.Invoke(self); foreach (DawnItemInfo value in LethalContent.Items.Values) { TryRegisterItemIntoShop(value.Item); } } private static void TryRegisterItemIntoShop(Item item) { //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Expected O, but got Unknown //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Expected O, but got Unknown //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Expected O, but got Unknown //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01e2: Expected O, but got Unknown DawnItemInfo dawnItemInfo = ItemExtensions.get_DawnInfo(item); if (dawnItemInfo == null) { DawnPlugin.Logger.LogWarning((object)("Item: " + item.itemName + " does not have a dawn info, this means they cannot be registered to the terminal as a shop item")); return; } _ = TerminalRefs.Instance; TerminalKeyword buyKeyword = TerminalRefs.BuyKeyword; TerminalKeyword infoKeyword = TerminalRefs.InfoKeyword; TerminalKeyword confirmPurchaseKeyword = TerminalRefs.ConfirmPurchaseKeyword; TerminalKeyword denyKeyword = TerminalRefs.DenyKeyword; TerminalNode cancelPurchaseNode = TerminalRefs.CancelPurchaseNode; DawnShopItemInfo shopInfo = dawnItemInfo.ShopInfo; if (shopInfo == null || dawnItemInfo.ShouldSkipRespectOverride() || TerminalRefs.Instance.buyableItemsList.Contains(item)) { return; } List list = TerminalRefs.Instance.buyableItemsList.ToList(); string text = dawnItemInfo.Item.itemName.ToLowerInvariant(); list.Add(dawnItemInfo.Item); TerminalKeyword[] allKeywords = TerminalRefs.Instance.terminalNodes.allKeywords; foreach (TerminalKeyword val in allKeywords) { if (((Object)val).name == text) { TerminalRefs.Instance.buyableItemsList = list.ToArray(); return; } } List list2 = buyKeyword.compatibleNouns.ToList(); List list3 = infoKeyword.compatibleNouns.ToList(); List list4 = TerminalRefs.Instance.terminalNodes.allKeywords.ToList(); TerminalKeyword val2 = new TerminalKeywordBuilder(text, text, ITerminalKeyword.DawnKeywordType.Store).SetIsVerb(isVerb: false).SetDefaultVerb(buyKeyword).SetAccessTerminalObjects(accessTerminalObjects: false) .Build(); list4.Add(val2); TerminalNode receiptNode = shopInfo.ReceiptNode; TerminalNode requestNode = shopInfo.RequestNode; UpdateShopItemPrices(shopInfo); receiptNode.buyItemIndex = list.Count - 1; requestNode.buyItemIndex = list.Count - 1; requestNode.isConfirmationNode = true; requestNode.overrideOptions = true; requestNode.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2] { new CompatibleNoun(confirmPurchaseKeyword, receiptNode), new CompatibleNoun(denyKeyword, cancelPurchaseNode) }; list2.Add(new CompatibleNoun(val2, requestNode)); list3.Add(new CompatibleNoun(val2, shopInfo.InfoNode)); TerminalRefs.Instance.buyableItemsList = list.ToArray(); infoKeyword.compatibleNouns = list3.ToArray(); buyKeyword.compatibleNouns = list2.ToArray(); TerminalRefs.Instance.terminalNodes.allKeywords = list4.ToArray(); } private static void CollectLLLTags(Item item, HashSet tags) { if (LethalLevelLoaderCompat.Enabled && LethalLevelLoaderCompat.TryGetAllTagsWithModNames(item, out List<(string, string)> allTagsWithModNames)) { tags.AddToList(allTagsWithModNames, Debuggers.Items, ((Object)item).name); } } } public class AutoItemGroupTagger(NamespacedKey tag, string itemGroupName) : IAutoTagger { public NamespacedKey Tag => tag; public bool ShouldApply(DawnItemInfo info) { if (info.Item.spawnPositionTypes == null) { return false; } foreach (ItemGroup spawnPositionType in info.Item.spawnPositionTypes) { if ((Object)(object)spawnPositionType == (Object)null) { DawnPlugin.Logger.LogWarning((object)$"Item: {info.Key} has a null ItemGroup, why!?!?"); } else if (((Object)spawnPositionType).name == itemGroupName) { return true; } } return false; } } public class AutoNonInteractableTagger : IAutoTagger { public NamespacedKey Tag => Tags.NonInteractable; public bool ShouldApply(DawnItemInfo info) { GrabbableObject val = default(GrabbableObject); if (info.Item.spawnPrefab.TryGetComponent(ref val)) { return ((object)val).GetType() == typeof(GrabbableObject); } return false; } } public class AutoValueTagger(NamespacedKey tag, BoundedRange range) : IAutoTagger { public NamespacedKey Tag => tag; public bool ShouldApply(DawnItemInfo info) { float value = (float)(info.Item.maxValue + info.Item.minValue) / 2f; return range.IsInRange(value); } } public class AutoWeightTagger(NamespacedKey tag, BoundedRange range) : IAutoTagger { public NamespacedKey Tag => tag; public bool ShouldApply(DawnItemInfo info) { return range.IsInRange(info.Item.weight); } } public sealed class DawnItemInfo : DawnBaseInfo { public Item Item { get; } public DawnScrapItemInfo? ScrapInfo { get; private set; } public DawnShopItemInfo? ShopInfo { get; private set; } internal DawnItemInfo(NamespacedKey key, HashSet tags, Item item, DawnScrapItemInfo? scrapItemInfo, DawnShopItemInfo? shopItemInfo, IDataContainer? customData) : base(key, tags, customData) { Item = item; ScrapInfo = scrapItemInfo; if (ScrapInfo != null) { ScrapInfo.ParentInfo = this; } ShopInfo = shopItemInfo; if (ShopInfo != null) { ShopInfo.ParentInfo = this; } } } public sealed class DawnScrapItemInfo { public DawnItemInfo ParentInfo { get; internal set; } public DawnWeightedValue Rarity { get; } internal DawnScrapItemInfo(DawnWeightedValue rarity) { Rarity = rarity; } public int GetRarity(DawnMoonInfo? moonInfo = null, DawnDungeonInfo? dungeonInfo = null, DawnWeatherEffectInfo? weatherEffectInfo = null) { return Rarity.GetValue(new WeightQuery { Owner = ParentInfo, Subject = this, Moon = moonInfo, Dungeon = dungeonInfo, Weather = weatherEffectInfo, Channel = DawnWeightChannels.ScrapRarity.Key }); } } public sealed class DawnShopItemInfo { public DawnItemInfo ParentInfo { get; internal set; } public TerminalNode? InfoNode { get; private set; } public TerminalNode RequestNode { get; } public TerminalNode ReceiptNode { get; } public DawnPurchaseInfo DawnPurchaseInfo { get; } internal DawnShopItemInfo(DawnPurchaseInfo dawnPurchaseInfo, TerminalNode? infoNode, TerminalNode requestNode, TerminalNode receiptNode) { DawnPurchaseInfo = dawnPurchaseInfo; InfoNode = infoNode; RequestNode = requestNode; ReceiptNode = receiptNode; } public void AddToDropship(bool ignoreMax = false, int count = 1) { Terminal instance = TerminalRefs.Instance; for (int i = 0; i < count; i++) { if (!ignoreMax && instance.orderedItemsFromTerminal.Count > 12) { break; } instance.orderedItemsFromTerminal.Add(RequestNode.buyItemIndex); instance.numberOfItemsInDropship++; } } public int GetSalePercentage() { return TerminalRefs.Instance.itemSalesPercentages[RequestNode.buyItemIndex]; } } public static class ItemExtensions { [SpecialName] public sealed class $C894FCB080B432D105D3B47EDB437ACE { [SpecialName] public static class $2E26C2B2561302AABE531C779AB6DD6E { } [ExtensionMarker("$2E26C2B2561302AABE531C779AB6DD6E")] public DawnItemInfo DawnInfo { [ExtensionMarker("$2E26C2B2561302AABE531C779AB6DD6E")] get { throw new NotSupportedException(); } [ExtensionMarker("$2E26C2B2561302AABE531C779AB6DD6E")] set { throw new NotSupportedException(); } } [ExtensionMarker("$2E26C2B2561302AABE531C779AB6DD6E")] [Obsolete("Use Item.DawnInfo instead")] public DawnItemInfo GetDawnInfo() { throw new NotSupportedException(); } [ExtensionMarker("$2E26C2B2561302AABE531C779AB6DD6E")] [Obsolete("Use Item.DawnInfo instead")] public void SetDawnInfo(DawnItemInfo itemInfo) { throw new NotSupportedException(); } [ExtensionMarker("$2E26C2B2561302AABE531C779AB6DD6E")] [Obsolete] public bool HasDawnInfo() { throw new NotSupportedException(); } [ExtensionMarker("$2E26C2B2561302AABE531C779AB6DD6E")] private DawnItemInfo GetDawnInfoCore() { throw new NotSupportedException(); } [ExtensionMarker("$2E26C2B2561302AABE531C779AB6DD6E")] private void SetDawnInfoCore(DawnItemInfo itemInfo) { throw new NotSupportedException(); } } public static DawnItemInfo get_DawnInfo(Item item) { return item.GetDawnInfoCore(); } public static void set_DawnInfo(Item item, DawnItemInfo value) { item.SetDawnInfoCore(value); } [Obsolete("Use Item.DawnInfo instead")] public static DawnItemInfo GetDawnInfo(this Item item) { return item.GetDawnInfoCore(); } [Obsolete("Use Item.DawnInfo instead")] public static void SetDawnInfo(this Item item, DawnItemInfo itemInfo) { item.SetDawnInfoCore(itemInfo); } [Obsolete] public static bool HasDawnInfo(this Item item) { return get_DawnInfo(item) != null; } private static DawnItemInfo GetDawnInfoCore(this Item item) { return ((IItemDawnObject)item).DawnInfo; } private static void SetDawnInfoCore(this Item item, DawnItemInfo itemInfo) { ((IItemDawnObject)item).DawnInfo = itemInfo; } } public class ItemInfoBuilder : BaseInfoBuilder { public class ScrapBuilder { private ItemInfoBuilder _parentBuilder; private DawnWeightedValue? _weights; internal ScrapBuilder(ItemInfoBuilder parent) { _parentBuilder = parent; } public ScrapBuilder SetWeights(Action> callback) { WeightProfile weightProfile = new WeightProfile(DawnWeightChannels.ScrapRarity.Policy); callback(weightProfile); _weights = new DawnWeightedValue(DawnWeightChannels.ScrapRarity, weightProfile); return this; } internal DawnScrapItemInfo Build() { if (_weights == null) { DawnPlugin.Logger.LogWarning((object)("Scrap item '" + _parentBuilder.value.itemName + "' didn't set weights. If you intend to have no weights (doing something special), call .SetWeights(() => {})")); _weights = new DawnWeightedValue(DawnWeightChannels.ScrapRarity); } return new DawnScrapItemInfo(_weights); } } public class ShopBuilder { private ItemInfoBuilder _parentBuilder; private TerminalNode? _infoNode; private TerminalNode? _requestNode; private TerminalNode? _receiptNode; private IProvider? _costOverride; private ITerminalPurchasePredicate? _purchasePredicate; internal ShopBuilder(ItemInfoBuilder parent) { _parentBuilder = parent; } public ShopBuilder OverrideCost(int cost) { return OverrideCost(new SimpleProvider(cost)); } public ShopBuilder OverrideCost(IProvider cost) { _costOverride = cost; return this; } public ShopBuilder SetPurchasePredicate(ITerminalPurchasePredicate predicate) { _purchasePredicate = predicate; return this; } public ShopBuilder OverrideInfoNode(TerminalNode infoNode) { _infoNode = infoNode; return this; } public ShopBuilder OverrideRequestNode(TerminalNode requestNode) { _requestNode = requestNode; return this; } public ShopBuilder OverrideReceiptNode(TerminalNode receiptNode) { _receiptNode = receiptNode; return this; } internal DawnShopItemInfo Build() { if ((Object)(object)_receiptNode == (Object)null) { _receiptNode = new TerminalNodeBuilder(_parentBuilder.value.itemName + "ReceiptNode").SetDisplayText("Ordered [variableAmount] " + _parentBuilder.value.itemName + ". Your new balance is [playerCredits].\n\nOur contractors enjoy fast, free shipping while on the job! Any purchased items will arrive hourly at your approximate location.\r\n\r\n").SetClearPreviousText(clearPreviousText: true).SetMaxCharactersToType(15) .SetPlaySyncedClip(0) .Build(); } if ((Object)(object)_requestNode == (Object)null) { _requestNode = new TerminalNodeBuilder(_parentBuilder.value.itemName + "RequestNode").SetDisplayText("You have requested to order " + _parentBuilder.value.itemName + ". Amount: [variableAmount].\nTotal cost of items: [totalCost].\n\nPlease CONFIRM or DENY.\r\n\r\n").SetClearPreviousText(clearPreviousText: true).SetMaxCharactersToType(35) .Build(); } if ((Object)(object)_infoNode == (Object)null) { _infoNode = new TerminalNodeBuilder(_parentBuilder.value.itemName + "InfoNode").SetDisplayText("[No information about this object was found.]\n\n").SetClearPreviousText(clearPreviousText: true).SetMaxCharactersToType(25) .Build(); } if (_purchasePredicate == null) { _purchasePredicate = ITerminalPurchasePredicate.AlwaysSuccess(); } if (_costOverride == null) { _costOverride = new SimpleProvider(_parentBuilder.value.creditsWorth); } return new DawnShopItemInfo(new DawnPurchaseInfo(_costOverride, _purchasePredicate), _infoNode, _requestNode, _receiptNode); } } private DawnScrapItemInfo? _scrapInfo; private DawnShopItemInfo? _shopInfo; internal ItemInfoBuilder(NamespacedKey key, Item item) : base(key, item) { } public ItemInfoBuilder DefineShop(Action callback) { ShopBuilder shopBuilder = new ShopBuilder(this); callback(shopBuilder); _shopInfo = shopBuilder.Build(); return this; } public ItemInfoBuilder DefineScrap(Action callback) { ScrapBuilder scrapBuilder = new ScrapBuilder(this); callback(scrapBuilder); _scrapInfo = scrapBuilder.Build(); return this; } internal override DawnItemInfo Build() { return new DawnItemInfo(base.key, tags, base.value, _scrapInfo, _shopInfo, customData); } } public static class LethalContent { public static TaggedRegistry Items = new TaggedRegistry(); public static TaggedRegistry Enemies = new TaggedRegistry(); public static TaggedRegistry MapObjects = new TaggedRegistry(); public static TaggedRegistry Moons = new TaggedRegistry(); public static Registry TileSets = new Registry(); public static TaggedRegistry Dungeons = new TaggedRegistry(); public static TaggedRegistry Unlockables = new TaggedRegistry(); public static TaggedRegistry Weathers = new TaggedRegistry(); public static Registry Archetypes = new Registry(); public static Registry StoryLogs = new Registry(); public static Registry Surfaces = new Registry(); public static Registry TerminalCommands = new Registry(); public static Registry RoundLoadingSteps = new Registry(); public static Registry DeadBodies = new Registry(); } public static class DawnLibTags { public static readonly NamespacedKey IsExternal = NamespacedKey.From("dawn_lib", "is_external"); public static readonly NamespacedKey LunarConfig = NamespacedKey.From("dawn_lib", "lunar_config"); public static readonly NamespacedKey HasBuyingPercent = NamespacedKey.From("dawn_lib", "has_buying_percent"); } internal static class MapObjectRegistrationHandler { [CompilerGenerated] private static class <>O { public static Action, RandomMapObject> <0>__AddPrefabsToRandomMapObjects; public static hook_SpawnOutsideHazards <1>__SpawnOutsideMapObjects; public static Manipulator <2>__RegenerateNavMeshTranspiler; public static hook_SetPlanetsWeather <3>__UpdateMapObjectSpawnWeights; public static hook_SpawnMapObjects <4>__UpdateMapObjectSpawnWeights; } private static int _spawnedObjects; internal static void Init() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //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_005b: Expected O, but got Unknown //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown DawnPlugin.Hooks.Add(new Hook((MethodBase)AccessTools.DeclaredMethod(typeof(RandomMapObject), "Awake", (Type[])null, (Type[])null), (Delegate)new Action, RandomMapObject>(AddPrefabsToRandomMapObjects))); object obj = <>O.<1>__SpawnOutsideMapObjects; if (obj == null) { hook_SpawnOutsideHazards val = SpawnOutsideMapObjects; <>O.<1>__SpawnOutsideMapObjects = val; obj = (object)val; } RoundManager.SpawnOutsideHazards += (hook_SpawnOutsideHazards)obj; object obj2 = <>O.<2>__RegenerateNavMeshTranspiler; if (obj2 == null) { Manipulator val2 = RegenerateNavMeshTranspiler; <>O.<2>__RegenerateNavMeshTranspiler = val2; obj2 = (object)val2; } RoundManager.SpawnOutsideHazards += (Manipulator)obj2; object obj3 = <>O.<3>__UpdateMapObjectSpawnWeights; if (obj3 == null) { hook_SetPlanetsWeather val3 = UpdateMapObjectSpawnWeights; <>O.<3>__UpdateMapObjectSpawnWeights = val3; obj3 = (object)val3; } StartOfRound.SetPlanetsWeather += (hook_SetPlanetsWeather)obj3; object obj4 = <>O.<4>__UpdateMapObjectSpawnWeights; if (obj4 == null) { hook_SpawnMapObjects val4 = UpdateMapObjectSpawnWeights; <>O.<4>__UpdateMapObjectSpawnWeights = val4; obj4 = (object)val4; } RoundManager.SpawnMapObjects += (hook_SpawnMapObjects)obj4; LethalContent.Moons.OnFreezeWithContext += delegate { RegisterMapObjects(); }; LethalContent.MapObjects.OnFreezeWithContext += delegate { FixMapObjectBlanksOnDawnMoons(); }; } private static void AddPrefabsToRandomMapObjects(Action orig, RandomMapObject self) { foreach (DawnMapObjectInfo value in LethalContent.MapObjects.Values) { if (value.InsideInfo != null && !value.ShouldSkipRespectOverride() && value.HasNetworkObject) { if ((Object)(object)value.InsideInfo.IndoorMapHazardType.prefabToSpawn == (Object)null) { DawnPlugin.Logger.LogWarning((object)$"MapObject Inside prefab is null for {value.Key}"); } else { self.spawnablePrefabs.Add(value.InsideInfo.IndoorMapHazardType.prefabToSpawn); } } } orig.Invoke(self); } private static void FixMapObjectBlanksOnDawnMoons() { List list = new List(); foreach (DawnMoonInfo value in LethalContent.Moons.Values) { if (value.ShouldSkipIgnoreOverride()) { continue; } IndoorMapHazard[] indoorMapHazards = value.Level.indoorMapHazards; foreach (IndoorMapHazard val in indoorMapHazards) { if ((Object)(object)val.hazardType == (Object)null) { continue; } foreach (DawnMapObjectInfo value2 in LethalContent.MapObjects.Values) { if (value2.InsideInfo != null && ((Object)value2.InsideInfo.IndoorMapHazardType).name == ((Object)val.hazardType).name) { list.Add((ScriptableObject)(object)val.hazardType); val.hazardType = value2.InsideInfo.IndoorMapHazardType; break; } } } SpawnableOutsideObjectWithRarity[] spawnableOutsideObjects = value.Level.spawnableOutsideObjects; foreach (SpawnableOutsideObjectWithRarity val2 in spawnableOutsideObjects) { if ((Object)(object)val2.spawnableObject == (Object)null) { continue; } foreach (DawnMapObjectInfo value3 in LethalContent.MapObjects.Values) { if (value3.OutsideInfo != null && ((Object)value3.OutsideInfo.SpawnableOutsideObject).name == ((Object)val2.spawnableObject).name) { list.Add((ScriptableObject)(object)val2.spawnableObject); val2.spawnableObject = value3.OutsideInfo.SpawnableOutsideObject; break; } } } } for (int num = list.Count - 1; num >= 0; num--) { Object.Destroy((Object)(object)list[num]); } } private static void RegenerateNavMeshTranspiler(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); int num = default(int); ILLabel val2 = default(ILLabel); if (!val.TryGotoNext(new Func[3] { (Instruction i) => ILPatternMatchingExt.MatchLdloc(i, ref num), (Instruction i) => ILPatternMatchingExt.MatchLdcI4(i, 0), (Instruction i) => ILPatternMatchingExt.MatchBgt(i, ref val2) })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply RoundManager.SpawnOutsideHazards patch (1)!"); return; } if (!val.TryGotoNext(new Func[1] { (Instruction i) => ILPatternMatchingExt.MatchLdstr(i, "OutsideLevelNavMesh") })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply RoundManager.SpawnOutsideHazards patch (2)!"); return; } val.GotoPrev((MoveType)0, new Func[3] { (Instruction i) => ILPatternMatchingExt.MatchLdloc(i, ref num), (Instruction i) => ILPatternMatchingExt.MatchLdcI4(i, 0), (Instruction i) => ILPatternMatchingExt.MatchBgt(i, ref val2) }); int index = val.Index; val.Index = index + 1; val.EmitDelegate>((Func)((int spawned) => spawned + _spawnedObjects)); } private static void FreezeMapObjectContents() { HashSet hashSet = new HashSet(); HashSet hashSet2 = new HashSet(); foreach (DawnMoonInfo value4 in LethalContent.Moons.Values) { SelectableLevel level = value4.Level; IndoorMapHazard[] indoorMapHazards = level.indoorMapHazards; foreach (IndoorMapHazard val in indoorMapHazards) { IndoorMapHazardType hazardType = val.hazardType; if (!((Object)(object)hazardType == (Object)null) && !((Object)(object)hazardType.prefabToSpawn == (Object)null) && IndoorMapHazardTypeExtensions.get_DawnInfo(hazardType) == null) { hashSet.Add(hazardType); } } SpawnableOutsideObjectWithRarity[] spawnableOutsideObjects = level.spawnableOutsideObjects; foreach (SpawnableOutsideObjectWithRarity val2 in spawnableOutsideObjects) { SpawnableOutsideObject spawnableObject = val2.spawnableObject; if (!((Object)(object)spawnableObject == (Object)null) && !((Object)(object)spawnableObject.prefabToSpawn == (Object)null) && SpawnableOutsideObjectExtensions.get_DawnInfo(spawnableObject) == null) { hashSet2.Add(spawnableObject); } } } Dictionary dictionary = hashSet.ToDictionary((IndoorMapHazardType x) => x.prefabToSpawn); Dictionary dictionary2 = hashSet2.ToDictionary((SpawnableOutsideObject x) => x.prefabToSpawn); List list = hashSet.Select((IndoorMapHazardType x) => x.prefabToSpawn).Concat(hashSet2.Select((SpawnableOutsideObject x) => x.prefabToSpawn)).Distinct() .ToList(); foreach (GameObject item in list) { string name = NamespacedKey.NormalizeStringForNamespacedKey(((Object)item).name, CSharpName: true); NamespacedKey namespacedKey = MapObjectKeys.GetByReflection(name); string modName2; if (namespacedKey == null && LethalLibCompat.Enabled && LethalLibCompat.TryGetMapObjectFromLethalLib(item, out string modName)) { namespacedKey = NamespacedKey.From(modName, ((Object)item).name); } else if (namespacedKey == null && LethalLevelLoaderCompat.Enabled && LethalLevelLoaderCompat.TryGetExtendedMapObjectModName(item, out modName2)) { namespacedKey = NamespacedKey.From(modName2, ((Object)item).name); } else if (namespacedKey == null) { namespacedKey = NamespacedKey.From("unknown_lib", ((Object)item).name); } DawnInsideMapObjectInfo dawnInsideMapObjectInfo = null; DawnOutsideMapObjectInfo dawnOutsideMapObjectInfo = null; if (dictionary.TryGetValue(item, out var value)) { WeightProfile weightProfile = new WeightProfile(DawnWeightChannels.MapObjectSpawnCurve.Policy); weightProfile.AddSource(new IndoorMapHazardBaseCurveSource(value)); DawnWeightedValue rarity = new DawnWeightedValue(DawnWeightChannels.MapObjectSpawnCurve, weightProfile); dawnInsideMapObjectInfo = new DawnInsideMapObjectInfo(value, rarity); } if (dictionary2.TryGetValue(item, out var value2)) { WeightProfile weightProfile2 = new WeightProfile(DawnWeightChannels.MapObjectSpawnCurve.Policy); weightProfile2.AddSource(new OutsideMapObjectBaseCurveSource(value2)); DawnWeightedValue rarity2 = new DawnWeightedValue(DawnWeightChannels.MapObjectSpawnCurve, weightProfile2); dawnOutsideMapObjectInfo = new DawnOutsideMapObjectInfo(value2, rarity2, alignWithTerrain: false, 0); } DawnMapObjectInfo dawnMapObjectInfo = new DawnMapObjectInfo(namespacedKey, new HashSet { DawnLibTags.IsExternal }, dawnInsideMapObjectInfo, dawnOutsideMapObjectInfo, null); DawnMapObjectNamespacedKeyContainer dawnMapObjectNamespacedKeyContainer = item.AddComponent(); dawnMapObjectNamespacedKeyContainer.Value = namespacedKey; if ((Object)(object)value != (Object)null) { IndoorMapHazardTypeExtensions.set_DawnInfo(value, dawnMapObjectInfo); } if ((Object)(object)value2 != (Object)null) { SpawnableOutsideObjectExtensions.set_DawnInfo(value2, dawnMapObjectInfo); } if (LethalContent.MapObjects.TryGetValue(dawnMapObjectInfo.TypedKey, out DawnMapObjectInfo value3)) { if (dawnInsideMapObjectInfo != null) { IndoorMapHazardTypeExtensions.set_DawnInfo(dawnInsideMapObjectInfo.IndoorMapHazardType, value3); } if (dawnOutsideMapObjectInfo != null) { SpawnableOutsideObjectExtensions.set_DawnInfo(dawnOutsideMapObjectInfo.SpawnableOutsideObject, value3); } } else { LethalContent.MapObjects.Register(dawnMapObjectInfo); } } LethalContent.MapObjects.Freeze(); } private static void UpdateMapObjectSpawnWeights(orig_SpawnMapObjects orig, RoundManager self) { UpdateIndoorMapHazardSpawnWeightsOnLevel(self.currentLevel); orig.Invoke(self); } private static void SpawnOutsideMapObjects(orig_SpawnOutsideHazards orig, RoundManager self) { UpdateOutsideMapObjectSpawnWeightsOnLevel(self.currentLevel); Random everyoneRandom = new Random(StartOfRound.Instance.randomMapSeed + 69); Random serverOnlyRandom = new Random(StartOfRound.Instance.randomMapSeed + 6969); List<(DawnOutsideMapObjectInfo, Vector3)> occupiedPositions = new List<(DawnOutsideMapObjectInfo, Vector3)>(); EntranceTeleport[] entranceTeleports = Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)1); Transform[] shipSpawnPathPoints = RoundManager.Instance.shipSpawnPathPoints; GameObject[] spawnDenialPoints = GameObject.FindGameObjectsWithTag("SpawnDenialPoint"); GameObject itemShipLandingNode = GameObject.FindGameObjectWithTag("ItemShipLandingNode"); foreach (DawnMapObjectInfo value in LethalContent.MapObjects.Values) { DawnOutsideMapObjectInfo outsideInfo = value.OutsideInfo; if (outsideInfo != null && !value.ShouldSkipRespectOverride()) { if (outsideInfo.ParentInfo == null) { DawnPlugin.Logger.LogError((object)("Failed to get outside parent info for " + ((Object)outsideInfo.SpawnableOutsideObject.prefabToSpawn).name)); } else { HandleSpawningOutsideObjects(outsideInfo, occupiedPositions, everyoneRandom, serverOnlyRandom, entranceTeleports, shipSpawnPathPoints, spawnDenialPoints, itemShipLandingNode); } } } orig.Invoke(self); _spawnedObjects = 0; } private static void HandleSpawningOutsideObjects(DawnOutsideMapObjectInfo outsideInfo, List<(DawnOutsideMapObjectInfo outsideMapObjectInfo, Vector3 position)> occupiedPositions, Random everyoneRandom, Random serverOnlyRandom, EntranceTeleport[] entranceTeleports, Transform[] shipSpawnPathPoints, GameObject[] spawnDenialPoints, GameObject itemShipLandingNode) { //IL_062e: Unknown result type (might be due to invalid IL or missing references) //IL_063b: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_0201: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0676: Unknown result type (might be due to invalid IL or missing references) //IL_031d: Unknown result type (might be due to invalid IL or missing references) //IL_0327: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0334: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_0438: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04a8: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0469: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) //IL_0534: Unknown result type (might be due to invalid IL or missing references) //IL_0539: Unknown result type (might be due to invalid IL or missing references) //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Unknown result type (might be due to invalid IL or missing references) //IL_0590: Unknown result type (might be due to invalid IL or missing references) //IL_0595: Unknown result type (might be due to invalid IL or missing references) if (RoundManager.Instance.outsideAINodes.Length <= outsideInfo.MinimumAINodeSpawnRequirement) { return; } SelectableLevel currentLevel = RoundManager.Instance.currentLevel; DawnMapObjectInfo parentInfo = outsideInfo.ParentInfo; GameObject prefabToSpawn = outsideInfo.SpawnableOutsideObject.prefabToSpawn; AnimationCurve val = outsideInfo.GetRarity() ?? AnimationCurve.Constant(0f, 1f, 0f); int num2; if (parentInfo.HasNetworkObject) { if (!NetworkManager.Singleton.IsServer) { return; } float num = val.Evaluate(serverOnlyRandom.NextFloat(0f, 1f)) + 0.5f; Debuggers.MapObjects?.Log($"number generated for host only: {num}"); num2 = Mathf.FloorToInt(num); } else { float num3 = val.Evaluate(everyoneRandom.NextFloat(0f, 1f)) + 0.5f; Debuggers.MapObjects?.Log("number generated for everyone: " + num3); num2 = Mathf.FloorToInt(num3); } Debuggers.MapObjects?.Log($"Spawning {num2} of {((Object)prefabToSpawn).name} for level {currentLevel}"); float num4 = outsideInfo.SpawnableOutsideObject.objectWidth; int num5 = 0; int num6 = num2; RaycastHit val3 = default(RaycastHit); DawnSurface dawnSurface = default(DawnSurface); DawnSpawnDenialPoint dawnSpawnDenialPoint = default(DawnSpawnDenialPoint); while (num2 > 0 && num5 < 10 * num6) { Debuggers.MapObjects?.Log($"Attempt number: {num5} with {num2} left to spawn with initial number: {num6}."); num5++; Random random = (parentInfo.HasNetworkObject ? serverOnlyRandom : everyoneRandom); GameObject val2 = RoundManager.Instance.outsideAINodes[random.Next(0, RoundManager.Instance.outsideAINodes.Length)]; if ((Object)(object)val2 == (Object)null) { DawnPlugin.Logger.LogWarning((object)("Failed to get a valid outside AI node to spawn map object at level: " + currentLevel.sceneName + ".")); continue; } Vector3 position = val2.transform.position; position = RoundManager.Instance.GetRandomNavMeshPositionInBoxPredictable(position, 10f, default(NavMeshHit), random, -1, 1f) + Vector3.up * 2f; if (!Physics.Raycast(position, Vector3.down, ref val3, 100f, StartOfRound.Instance.collidersAndRoomMaskAndDefault, (QueryTriggerInteraction)1) || !Object.op_Implicit((Object)(object)((RaycastHit)(ref val3)).collider)) { continue; } string[] spawnableFloorTags = outsideInfo.SpawnableOutsideObject.spawnableFloorTags; if (spawnableFloorTags != null && spawnableFloorTags.Length != 0) { bool flag = false; Transform transform = ((Component)((RaycastHit)(ref val3)).collider).transform; int footstepIndex = -1; if (((Component)transform).TryGetComponent(ref dawnSurface) && (dawnSurface.SurfaceIndex > -1 || dawnSurface.TerrainIndices.Count > 0)) { dawnSurface.TryGetFootstepIndex(((RaycastHit)(ref val3)).point, checkStandingOnTerrain: false, out footstepIndex); } for (int i = 0; i < spawnableFloorTags.Length; i++) { if (footstepIndex != -1) { DawnSurfaceInfo dawnSurfaceInfo = FootstepSurfaceExtensions.get_DawnInfo(StartOfRound.Instance.footstepSurfaces[footstepIndex]); if (dawnSurfaceInfo.Surface.surfaceTag.Equals(spawnableFloorTags[i], StringComparison.OrdinalIgnoreCase)) { flag = true; break; } } else if (((Component)transform).CompareTag(spawnableFloorTags[i])) { flag = true; break; } } if (!flag) { continue; } } Vector3 val4 = RoundManager.Instance.PositionEdgeCheck(((RaycastHit)(ref val3)).point, num4, -1, default(Vector3)); if (val4 == Vector3.zero) { continue; } bool flag2 = false; if (shipSpawnPathPoints != null) { for (int j = 0; j < shipSpawnPathPoints.Length; j++) { if (Vector3.Distance(((Component)shipSpawnPathPoints[j]).transform.position, val4) < num4 + 6f) { flag2 = true; break; } } } foreach (EntranceTeleport val5 in entranceTeleports) { if (Vector3.Distance(((Component)val5).transform.position, val4) < num4 + 6f) { flag2 = true; break; } } if (flag2) { continue; } for (int l = 0; l < spawnDenialPoints.Length; l++) { float num7 = 6f; if (spawnDenialPoints[l].TryGetComponent(ref dawnSpawnDenialPoint)) { num7 = dawnSpawnDenialPoint.SpawnDenialPointOutsideHazardDistanceBlocker; } if (Vector3.Distance(spawnDenialPoints[l].transform.position, val4) < num4 + num7) { flag2 = true; break; } } if (flag2 || ((Object)(object)itemShipLandingNode != (Object)null && Vector3.Distance(itemShipLandingNode.transform.position, val4) < num4 + 4f)) { continue; } if (num4 > 4f) { for (int m = 0; m < occupiedPositions.Count; m++) { if (Vector3.Distance(val4, occupiedPositions[m].position) < num4) { flag2 = true; break; } } if (flag2) { continue; } } num2--; occupiedPositions.Add((outsideInfo, val4)); GameObject val6 = Object.Instantiate(prefabToSpawn, val4, Quaternion.identity, RoundManager.Instance.mapPropsContainer.transform); Debuggers.MapObjects?.Log($"Spawning {((Object)val6).name} at {val4}"); if (outsideInfo.AlignWithTerrain) { val6.transform.up = ((RaycastHit)(ref val3)).normal; } Vector3 eulerAngles = val6.transform.eulerAngles; if (outsideInfo.SpawnableOutsideObject.spawnFacingAwayFromWall) { float y = RoundManager.Instance.YRotationThatFacesTheFarthestFromPosition(val4 + Vector3.up * 0.2f, 25f, 6); eulerAngles.y = y; } else { int num8 = random.Next(0, 360); eulerAngles.y = num8; } val6.transform.eulerAngles = eulerAngles; Transform transform2 = val6.transform; transform2.localEulerAngles += outsideInfo.SpawnableOutsideObject.rotationOffset; _spawnedObjects++; if (parentInfo.HasNetworkObject) { val6.GetComponent().Spawn(true); } } if (!NetworkManager.Singleton.IsServer) { return; } List list = GameObject.FindGameObjectsWithTag("Tree").ToList(); for (int n = 0; n < occupiedPositions.Count; n++) { if (!occupiedPositions[n].outsideMapObjectInfo.SpawnableOutsideObject.destroyTrees) { continue; } for (int num9 = list.Count - 1; num9 >= 0; num9--) { float num10 = Vector3.Distance(list[num9].transform.position, occupiedPositions[n].position); if (num10 < (float)occupiedPositions[n].outsideMapObjectInfo.SpawnableOutsideObject.objectWidth) { RoundManager.Instance.DestroyTreeAtPosition(list[num9].transform.position, 5f); list.RemoveAt(num9); } } } } private static void UpdateMapObjectSpawnWeights(orig_SetPlanetsWeather orig, StartOfRound self, int connectedPlayersOnServer) { orig.Invoke(self, connectedPlayersOnServer); UpdateIndoorMapHazardSpawnWeightsOnLevel(self.currentLevel); UpdateOutsideMapObjectSpawnWeightsOnLevel(self.currentLevel); } internal static void UpdateIndoorMapHazardSpawnWeightsOnLevel(SelectableLevel level) { //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown if (!LethalContent.Weathers.IsFrozen || !LethalContent.MapObjects.IsFrozen || (Object)(object)StartOfRound.Instance == (Object)null || (WeatherRegistryCompat.Enabled && !WeatherRegistryCompat.IsWeatherManagerReady())) { return; } foreach (DawnMapObjectInfo value in LethalContent.MapObjects.Values) { DawnInsideMapObjectInfo insideInfo = value.InsideInfo; if (insideInfo != null && !value.ShouldSkipRespectOverride()) { Debuggers.MapObjects?.Log("Updating weights for " + ((Object)insideInfo.IndoorMapHazardType.prefabToSpawn).name + " on level " + level.PlanetName); IndoorMapHazard val = ((IEnumerable)level.indoorMapHazards).FirstOrDefault((Func)((IndoorMapHazard mapObject) => (Object)(object)mapObject.hazardType == (Object)(object)insideInfo.IndoorMapHazardType)); if (val == null) { val = new IndoorMapHazard { hazardType = insideInfo.IndoorMapHazardType, numberToSpawn = AnimationCurve.Constant(0f, 1f, 0f) }; List list = level.indoorMapHazards.ToList(); list.Add(val); level.indoorMapHazards = list.ToArray(); } val.numberToSpawn = insideInfo.GetRarity(SelectableLevelExtensions.get_DawnInfo(level), RoundManagerRefs.GetCurrentDungeonInfo(), LevelWeatherTypeExtensions.get_DawnInfo(level.currentWeather)) ?? AnimationCurve.Constant(0f, 1f, 0f); } } } internal static void UpdateOutsideMapObjectSpawnWeightsOnLevel(SelectableLevel level) { if (!LethalContent.Weathers.IsFrozen || !LethalContent.MapObjects.IsFrozen || (Object)(object)StartOfRound.Instance == (Object)null || (WeatherRegistryCompat.Enabled && !WeatherRegistryCompat.IsWeatherManagerReady())) { return; } foreach (DawnMapObjectInfo value in LethalContent.MapObjects.Values) { DawnOutsideMapObjectInfo outsideInfo = value.OutsideInfo; if (outsideInfo != null && !value.ShouldSkipRespectOverride()) { Debuggers.MapObjects?.Log("Updating weights for " + ((Object)outsideInfo.SpawnableOutsideObject.prefabToSpawn).name + " on level " + level.PlanetName); SpawnableOutsideObjectWithRarity val = ((IEnumerable)level.spawnableOutsideObjects).FirstOrDefault((Func)((SpawnableOutsideObjectWithRarity mapObject) => (Object)(object)mapObject.spawnableObject.prefabToSpawn == (Object)(object)outsideInfo.SpawnableOutsideObject.prefabToSpawn)); if (val != null) { List list = level.spawnableOutsideObjects.ToList(); list.Remove(val); level.spawnableOutsideObjects = list.ToArray(); } } } } private static void RegisterMapObjects() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown foreach (DawnMoonInfo value in LethalContent.Moons.Values) { List list = value.Level.indoorMapHazards.ToList(); foreach (DawnMapObjectInfo value2 in LethalContent.MapObjects.Values) { if (value2.InsideInfo != null && !value2.ShouldSkipRespectOverride()) { IndoorMapHazard item = new IndoorMapHazard { hazardType = value2.InsideInfo.IndoorMapHazardType, numberToSpawn = AnimationCurve.Constant(0f, 1f, 0f) }; list.Add(item); } } value.Level.indoorMapHazards = list.ToArray(); } FreezeMapObjectContents(); } } public sealed class DawnInsideMapObjectInfo { public DawnMapObjectInfo ParentInfo { get; internal set; } public IndoorMapHazardType IndoorMapHazardType { get; set; } public DawnWeightedValue Rarity { get; private set; } internal DawnInsideMapObjectInfo(IndoorMapHazardType indoorMapHazardType, DawnWeightedValue rarity) { IndoorMapHazardType = indoorMapHazardType; Rarity = rarity; } public AnimationCurve? GetRarity(DawnMoonInfo? moonInfo = null, DawnDungeonInfo? dungeonInfo = null, DawnWeatherEffectInfo? weatherEffectInfo = null) { return Rarity.GetValue(new WeightQuery { Owner = ParentInfo, Subject = this, Moon = moonInfo, Dungeon = dungeonInfo, Weather = weatherEffectInfo, Channel = DawnWeightChannels.MapObjectSpawnCurve.Key }); } } public sealed class DawnMapObjectInfo : DawnBaseInfo { public DawnInsideMapObjectInfo? InsideInfo { get; private set; } public DawnOutsideMapObjectInfo? OutsideInfo { get; private set; } public bool HasNetworkObject { get; } internal DawnMapObjectInfo(NamespacedKey key, HashSet tags, DawnInsideMapObjectInfo? insideInfo, DawnOutsideMapObjectInfo? outsideInfo, IDataContainer? customData) : base(key, tags, customData) { InsideInfo = insideInfo; if (InsideInfo != null) { InsideInfo.ParentInfo = this; HasNetworkObject = (Object)(object)InsideInfo.IndoorMapHazardType.prefabToSpawn.GetComponent() != (Object)null; } OutsideInfo = outsideInfo; if (OutsideInfo != null) { OutsideInfo.ParentInfo = this; HasNetworkObject = (Object)(object)OutsideInfo.SpawnableOutsideObject.prefabToSpawn.GetComponent() != (Object)null; } } public GameObject? GetMapObjectPrefab() { if (InsideInfo != null) { return InsideInfo.IndoorMapHazardType.prefabToSpawn; } if (OutsideInfo != null) { return OutsideInfo.SpawnableOutsideObject.prefabToSpawn; } return null; } } public sealed class DawnOutsideMapObjectInfo { public DawnMapObjectInfo ParentInfo { get; internal set; } public SpawnableOutsideObject SpawnableOutsideObject { get; private set; } public DawnWeightedValue Rarity { get; private set; } public bool AlignWithTerrain { get; private set; } public int MinimumAINodeSpawnRequirement { get; private set; } internal DawnOutsideMapObjectInfo(SpawnableOutsideObject spawnableOutsideObject, DawnWeightedValue rarity, bool alignWithTerrain, int minimumAINodeSpawnRequirement) { SpawnableOutsideObject = spawnableOutsideObject; Rarity = rarity; AlignWithTerrain = alignWithTerrain; MinimumAINodeSpawnRequirement = minimumAINodeSpawnRequirement; } public AnimationCurve? GetRarity(DawnMoonInfo? moonInfo = null, DawnDungeonInfo? dungeonInfo = null, DawnWeatherEffectInfo? weatherEffectInfo = null) { return Rarity.GetValue(new WeightQuery { Owner = ParentInfo, Subject = this, Moon = moonInfo, Dungeon = dungeonInfo, Weather = weatherEffectInfo, Channel = DawnWeightChannels.MapObjectSpawnCurve.Key }); } } public static class IndoorMapHazardTypeExtensions { [SpecialName] public sealed class $28AE2023EB9C917AEE81875983FFE354 { [SpecialName] public static class $CDFE9AFD6E159EFA9B171CC3C22CFFD7 { } [ExtensionMarker("$CDFE9AFD6E159EFA9B171CC3C22CFFD7")] public DawnMapObjectInfo DawnInfo { [ExtensionMarker("$CDFE9AFD6E159EFA9B171CC3C22CFFD7")] get { throw new NotSupportedException(); } [ExtensionMarker("$CDFE9AFD6E159EFA9B171CC3C22CFFD7")] set { throw new NotSupportedException(); } } [ExtensionMarker("$CDFE9AFD6E159EFA9B171CC3C22CFFD7")] [Obsolete("Use IndoorMapHazardType.DawnInfo instead")] public DawnMapObjectInfo GetDawnInfo() { throw new NotSupportedException(); } [ExtensionMarker("$CDFE9AFD6E159EFA9B171CC3C22CFFD7")] [Obsolete("Use IndoorMapHazardType.DawnInfo instead")] public void SetDawnInfo(DawnMapObjectInfo mapObjectInfoInfo) { throw new NotSupportedException(); } [ExtensionMarker("$CDFE9AFD6E159EFA9B171CC3C22CFFD7")] [Obsolete] public bool HasDawnInfo() { throw new NotSupportedException(); } [ExtensionMarker("$CDFE9AFD6E159EFA9B171CC3C22CFFD7")] private DawnMapObjectInfo GetDawnInfoCore() { throw new NotSupportedException(); } [ExtensionMarker("$CDFE9AFD6E159EFA9B171CC3C22CFFD7")] private void SetDawnInfoCore(DawnMapObjectInfo indoorMapHazardTypeInfo) { throw new NotSupportedException(); } } public static DawnMapObjectInfo get_DawnInfo(IndoorMapHazardType indoorMapHazardType) { return indoorMapHazardType.GetDawnInfoCore(); } public static void set_DawnInfo(IndoorMapHazardType indoorMapHazardType, DawnMapObjectInfo value) { indoorMapHazardType.SetDawnInfoCore(value); } [Obsolete("Use IndoorMapHazardType.DawnInfo instead")] public static DawnMapObjectInfo GetDawnInfo(this IndoorMapHazardType indoorMapHazardType) { return indoorMapHazardType.GetDawnInfoCore(); } [Obsolete("Use IndoorMapHazardType.DawnInfo instead")] public static void SetDawnInfo(this IndoorMapHazardType indoorMapHazardType, DawnMapObjectInfo mapObjectInfoInfo) { indoorMapHazardType.SetDawnInfoCore(mapObjectInfoInfo); } [Obsolete] public static bool HasDawnInfo(this IndoorMapHazardType indoorMapHazardType) { return get_DawnInfo(indoorMapHazardType) != null; } private static DawnMapObjectInfo GetDawnInfoCore(this IndoorMapHazardType indoorMapHazardType) { return ((IIndoorMapHazardTypeDawnObject)indoorMapHazardType).DawnInfo; } private static void SetDawnInfoCore(this IndoorMapHazardType indoorMapHazardType, DawnMapObjectInfo indoorMapHazardTypeInfo) { ((IIndoorMapHazardTypeDawnObject)indoorMapHazardType).DawnInfo = indoorMapHazardTypeInfo; } } [Serializable] public class InsideMapObjectSettings { public bool spawnFacingAwayFromWall; public bool spawnFacingWall; public bool spawnWithBackToWall; public bool spawnWithBackFlushAgainstWall; public bool requireDistanceBetweenSpawns; public bool disallowSpawningNearEntrances; public bool allowInMineshaft; } public class MapObjectInfoBuilder : BaseInfoBuilder { public class InsideBuilder { private MapObjectInfoBuilder _parentBuilder; private bool _spawnFacingAwayFromWall; private bool _spawnFacingWall; private bool _spawnWithBackToWall; private bool _spawnWithBackFlushAgainstWall; private bool _requireDistanceBetweenSpawns; private bool _disallowSpawningNearEntrances; private bool _allowInMineshaft; private DawnWeightedValue? _weights; internal InsideBuilder(MapObjectInfoBuilder parent) { _parentBuilder = parent; } public InsideBuilder OverrideSpawnFacingAwayFromWall(bool spawnFacingAwayFromWall) { _spawnFacingAwayFromWall = spawnFacingAwayFromWall; return this; } public InsideBuilder OverrideSpawnFacingWall(bool spawnFacingWall) { _spawnFacingWall = spawnFacingWall; return this; } public InsideBuilder OverrideSpawnWithBackToWall(bool spawnWWithBackToWall) { _spawnWithBackToWall = spawnWWithBackToWall; return this; } public InsideBuilder OverrideSpawnWithBackFlushAgainstWall(bool spawnWithBackFlushAgainstWall) { _spawnWithBackFlushAgainstWall = spawnWithBackFlushAgainstWall; return this; } public InsideBuilder OverrideRequireDistanceBetweenSpawns(bool requireDistanceBetweenSpawns) { _requireDistanceBetweenSpawns = requireDistanceBetweenSpawns; return this; } public InsideBuilder OverrideDisallowSpawningNearEntrances(bool disallowSpawningNearEntrances) { _disallowSpawningNearEntrances = disallowSpawningNearEntrances; return this; } public InsideBuilder OverrideAllowInMineshaft(bool allowInMineshaft) { _allowInMineshaft = allowInMineshaft; return this; } public InsideBuilder SetWeights(Action> callback) { WeightProfile weightProfile = new WeightProfile(DawnWeightChannels.MapObjectSpawnCurve.Policy); callback(weightProfile); _weights = new DawnWeightedValue(DawnWeightChannels.MapObjectSpawnCurve, weightProfile); return this; } internal DawnInsideMapObjectInfo Build() { if (_weights == null) { DawnPlugin.Logger.LogWarning((object)$"MapObject: '{_parentBuilder.key}' didn't set inside weights. If you intend to have no weights (doing something special), call .SetWeights(() => {{}})"); _weights = new DawnWeightedValue(DawnWeightChannels.MapObjectSpawnCurve); } IndoorMapHazardType val = ScriptableObject.CreateInstance(); ((Object)val).name = _parentBuilder.key.Key; val.prefabToSpawn = _parentBuilder.value; val.spawnFacingAwayFromWall = _spawnFacingAwayFromWall; val.spawnFacingWall = _spawnFacingWall; val.spawnWithBackToWall = _spawnWithBackToWall; val.spawnWithBackFlushAgainstWall = _spawnWithBackFlushAgainstWall; val.requireDistanceBetweenSpawns = _requireDistanceBetweenSpawns; val.disallowSpawningNearEntrances = _disallowSpawningNearEntrances; val.allowInMineshaft = _allowInMineshaft; return new DawnInsideMapObjectInfo(val, _weights); } } public class OutsideBuilder { private MapObjectInfoBuilder _parentBuilder; private bool _alignWithTerrain; private bool _destroyTrees; private bool _spawnFacingAwayFromWall; private int _objectWidth = 6; private int _minimumNodeSpawnRequirement; private Vector3 _rotationOffset = Vector3.zero; private string[] _spawnableFloorTags = Array.Empty(); private DawnWeightedValue? _weights; internal OutsideBuilder(MapObjectInfoBuilder parent) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) _parentBuilder = parent; } public OutsideBuilder OverrideAlignWithTerrain(bool alignWithTerrain) { _alignWithTerrain = alignWithTerrain; return this; } public OutsideBuilder OverrideSpawnFacingAwayFromWall(bool spawnFacingAwayFromWall) { _spawnFacingAwayFromWall = spawnFacingAwayFromWall; return this; } public OutsideBuilder OverrideMinimumNodeSpawnRequirement(int minimumAINodeRequirement) { _minimumNodeSpawnRequirement = minimumAINodeRequirement; return this; } public OutsideBuilder OverrideRotationOffset(Vector3 rotationOffset) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) _rotationOffset = rotationOffset; return this; } public OutsideBuilder OverrideSpawnableFloorTags(string[] spawnableFloorTags) { _spawnableFloorTags = spawnableFloorTags; return this; } public OutsideBuilder OverrideObjectWidth(int objectWidth) { _objectWidth = objectWidth; return this; } public OutsideBuilder OverrideDestroyTrees(bool destroyTrees) { _destroyTrees = destroyTrees; return this; } public OutsideBuilder SetWeights(Action> callback) { WeightProfile weightProfile = new WeightProfile(DawnWeightChannels.MapObjectSpawnCurve.Policy); callback(weightProfile); _weights = new DawnWeightedValue(DawnWeightChannels.MapObjectSpawnCurve, weightProfile); return this; } internal DawnOutsideMapObjectInfo Build() { //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) if (_weights == null) { DawnPlugin.Logger.LogWarning((object)$"MapObject: '{_parentBuilder.key}' didn't set inside weights. If you intend to have no weights (doing something special), call .SetWeights(() => {{}})"); _weights = new DawnWeightedValue(DawnWeightChannels.MapObjectSpawnCurve); } SpawnableOutsideObject val = ScriptableObject.CreateInstance(); ((Object)val).name = _parentBuilder.key.Key; val.prefabToSpawn = _parentBuilder.value; val.spawnFacingAwayFromWall = _spawnFacingAwayFromWall; val.rotationOffset = _rotationOffset; val.destroyTrees = _destroyTrees; val.spawnableFloorTags = _spawnableFloorTags; val.objectWidth = _objectWidth; return new DawnOutsideMapObjectInfo(val, _weights, _alignWithTerrain, _minimumNodeSpawnRequirement); } } private DawnInsideMapObjectInfo? _insideInfo; private DawnOutsideMapObjectInfo? _outsideInfo; internal MapObjectInfoBuilder(NamespacedKey key, GameObject mapObject) : base(key, mapObject) { } public MapObjectInfoBuilder DefineInside(Action callback) { InsideBuilder insideBuilder = new InsideBuilder(this); callback(insideBuilder); _insideInfo = insideBuilder.Build(); return this; } public MapObjectInfoBuilder DefineOutside(Action callback) { OutsideBuilder outsideBuilder = new OutsideBuilder(this); callback(outsideBuilder); _outsideInfo = outsideBuilder.Build(); return this; } internal override DawnMapObjectInfo Build() { return new DawnMapObjectInfo(base.key, tags, _insideInfo, _outsideInfo, customData); } } [Serializable] public class OutsideMapObjectSettings { [FormerlySerializedAs("SpawnFacingAwayFromWall")] public bool spawnFacingAwayFromWall; [FormerlySerializedAs("ObjectWidth")] public int objectWidth = 6; public bool destroyTrees; [FormerlySerializedAs("RotationOffset")] public Vector3 rotationOffset = Vector3.zero; [FormerlySerializedAs("SpawnableFloorTags")] public string[] spawnableFloorTags = Array.Empty(); [FormerlySerializedAs("MinimumAINodeSpawnRequirement")] public int minimumAINodeSpawnRequirement; [FormerlySerializedAs("AlignWithTerrain")] public bool alignWithTerrain; } public static class SpawnableOutsideObjectExtensions { [SpecialName] public sealed class $1C90043EDF2BB902C11F41597ADC9751 { [SpecialName] public static class $AF85B84DA6979A463BC1CEBE91D23CAF { } [ExtensionMarker("$AF85B84DA6979A463BC1CEBE91D23CAF")] public DawnMapObjectInfo DawnInfo { [ExtensionMarker("$AF85B84DA6979A463BC1CEBE91D23CAF")] get { throw new NotSupportedException(); } [ExtensionMarker("$AF85B84DA6979A463BC1CEBE91D23CAF")] set { throw new NotSupportedException(); } } [ExtensionMarker("$AF85B84DA6979A463BC1CEBE91D23CAF")] [Obsolete("Use SpawnableOutsideObject.DawnInfo instead")] public DawnMapObjectInfo GetDawnInfo() { throw new NotSupportedException(); } [ExtensionMarker("$AF85B84DA6979A463BC1CEBE91D23CAF")] [Obsolete("Use SpawnableOutsideObject.DawnInfo instead")] public void SetDawnInfo(DawnMapObjectInfo mapObjectInfo) { throw new NotSupportedException(); } [ExtensionMarker("$AF85B84DA6979A463BC1CEBE91D23CAF")] [Obsolete] public bool HasDawnInfo() { throw new NotSupportedException(); } [ExtensionMarker("$AF85B84DA6979A463BC1CEBE91D23CAF")] private DawnMapObjectInfo GetDawnInfoCore() { throw new NotSupportedException(); } [ExtensionMarker("$AF85B84DA6979A463BC1CEBE91D23CAF")] private void SetDawnInfoCore(DawnMapObjectInfo spawnableOutsideObjectInfo) { throw new NotSupportedException(); } } public static DawnMapObjectInfo get_DawnInfo(SpawnableOutsideObject spawnableOutsideObject) { return spawnableOutsideObject.GetDawnInfoCore(); } public static void set_DawnInfo(SpawnableOutsideObject spawnableOutsideObject, DawnMapObjectInfo value) { spawnableOutsideObject.SetDawnInfoCore(value); } [Obsolete("Use SpawnableOutsideObject.DawnInfo instead")] public static DawnMapObjectInfo GetDawnInfo(this SpawnableOutsideObject spawnableOutsideObject) { return spawnableOutsideObject.GetDawnInfoCore(); } [Obsolete("Use SpawnableOutsideObject.DawnInfo instead")] public static void SetDawnInfo(this SpawnableOutsideObject spawnableOutsideObject, DawnMapObjectInfo mapObjectInfo) { spawnableOutsideObject.SetDawnInfoCore(mapObjectInfo); } [Obsolete] public static bool HasDawnInfo(this SpawnableOutsideObject spawnableOutsideObject) { return get_DawnInfo(spawnableOutsideObject) != null; } private static DawnMapObjectInfo GetDawnInfoCore(this SpawnableOutsideObject spawnableOutsideObject) { return ((ISpawnableOutsideObjectDawnObject)spawnableOutsideObject).DawnInfo; } private static void SetDawnInfoCore(this SpawnableOutsideObject spawnableOutsideObject, DawnMapObjectInfo spawnableOutsideObjectInfo) { ((ISpawnableOutsideObjectDawnObject)spawnableOutsideObject).DawnInfo = spawnableOutsideObjectInfo; } } [HarmonyPatch] internal static class MoonRegistrationHandler { [CompilerGenerated] private static class <>O { public static hook_Awake <0>__CollectTestLevel; public static hook_Awake <1>__CollectLevels; public static hook_Awake <2>__SpawnRouteProgressUI; public static hook_Awake <3>__RegisterDawnLevels; public static hook_ChangeLevel <4>__StartOfRoundOnChangeLevel; public static hook_OnClientConnect <5>__StartOfRoundOnClientConnect; public static hook_OnClientDisconnect <6>__StartOfRoundOnClientDisconnect; public static hook_TravelToLevelEffects <7>__DelayTravelEffects; public static hook_TextPostProcess <8>__DynamicMoonCatalogue; public static Manipulator <9>__ReplaceStaticOutsideEnemyProbabilityRange; public static Manipulator <10>__MultiplyGlobalTimeMultiplierToDaySpeedMultiplier; public static Manipulator <11>__IgnoreDaySpeedMultiplier; public static Manipulator <12>__AccountForDaytimeDiversity; public static Manipulator <13>__AccountForWeedDiversity; public static hook_RefreshEnemiesList <14>__UpdateNewerDiversity; public static hook_UnloadSceneObjectsEarly <15>__ResetNewerDiversity; public static hook_RefreshEnemiesList <16>__SetCurrentMaxPower; public static Manipulator <17>__ReplaceLevelValueWithRoundManager; public static Manipulator <18>__IntroduceMoreVariablesToSpawning; public static Func <19>__GetWeedEnemySpawnChanceThroughDay; public static Func <20>__GetWeedSpawnProbabilityRange; public static Func <21>__DetermineNumberToSpawn; public static Func <22>__GetCurrentWeedMaxDiversity; public static Func <23>__GetCurrentWeedDiversity; public static Func <24>__EnemyCanSpawnAccountingForDiversity; public static Func <25>__GetCurrentMaxWeedPower; public static Action <26>__IncrementWeedDiversity; public static Func <27>__GetCurrentDaytimeMaxDiversity; public static Func <28>__GetCurrentDaytimeDiversity; public static Action <29>__IncrementDaytimeDiversity; } public static MainGroupAlgorithm MoonGroupAlgorithm = new MainGroupAlgorithm(); internal static GameObject RouteProgressUIPrefab; internal static void Init() { //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Expected O, but got Unknown //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Expected O, but got Unknown //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0355: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Expected O, but got Unknown //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Expected O, but got Unknown //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Expected O, but got Unknown //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_037b: Expected O, but got Unknown //IL_0310: 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) //IL_031b: Expected O, but got Unknown //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Expected O, but got Unknown //IL_0390: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039b: Expected O, but got Unknown //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Expected O, but got Unknown //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected O, but got Unknown //IL_03b0: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Expected O, but got Unknown //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Expected O, but got Unknown //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Expected O, but got Unknown //IL_02c9: Unknown result type (might be due to invalid IL or missing references) //IL_02ce: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Expected O, but got Unknown //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Expected O, but got Unknown //IL_0410: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Expected O, but got Unknown //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0435: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Expected O, but got Unknown LethalContent.Moons.AddAutoTaggers(new SimpleAutoTagger(Tags.Company, (DawnMoonInfo moonInfo) => !moonInfo.Level.spawnEnemiesAndScrap), new SimpleAutoTagger(Tags.SupportsWeather, (DawnMoonInfo moonInfo) => moonInfo.Level.spawnEnemiesAndScrap), new SimpleAutoTagger(Tags.Free, (DawnMoonInfo moonInfo) => (Object)(object)moonInfo.RouteNode != (Object)null && moonInfo.RouteNode.itemCost == 0), new SimpleAutoTagger(Tags.Paid, (DawnMoonInfo moonInfo) => (Object)(object)moonInfo.RouteNode != (Object)null && moonInfo.RouteNode.itemCost > 0), new SimpleAutoTagger(DawnLibTags.HasBuyingPercent, (DawnMoonInfo moonInfo) => moonInfo.GetNumberlessPlanetName() == "Gordion")); DetourContext val = new DetourContext(2147483637); try { object obj = <>O.<0>__CollectTestLevel; if (obj == null) { hook_Awake val2 = CollectTestLevel; <>O.<0>__CollectTestLevel = val2; obj = (object)val2; } StartOfRound.Awake += (hook_Awake)obj; object obj2 = <>O.<1>__CollectLevels; if (obj2 == null) { hook_Awake val3 = CollectLevels; <>O.<1>__CollectLevels = val3; obj2 = (object)val3; } StartOfRound.Awake += (hook_Awake)obj2; if (!DawnConfig.VanillaCompatibility.Value) { object obj3 = <>O.<2>__SpawnRouteProgressUI; if (obj3 == null) { hook_Awake val4 = SpawnRouteProgressUI; <>O.<2>__SpawnRouteProgressUI = val4; obj3 = (object)val4; } StartOfRound.Awake += (hook_Awake)obj3; object obj4 = <>O.<3>__RegisterDawnLevels; if (obj4 == null) { hook_Awake val5 = RegisterDawnLevels; <>O.<3>__RegisterDawnLevels = val5; obj4 = (object)val5; } Terminal.Awake += (hook_Awake)obj4; } } finally { ((IDisposable)val)?.Dispose(); } LethalContent.Moons.OnFreezeWithContext += delegate { FixAmbienceLibraries(); }; LethalContent.Enemies.OnFreezeWithContext += delegate { FixDawnMoonEnemies(); }; LethalContent.Items.OnFreezeWithContext += delegate { FixDawnMoonItems(); }; if (!DawnConfig.VanillaCompatibility.Value) { object obj5 = <>O.<4>__StartOfRoundOnChangeLevel; if (obj5 == null) { hook_ChangeLevel val6 = StartOfRoundOnChangeLevel; <>O.<4>__StartOfRoundOnChangeLevel = val6; obj5 = (object)val6; } StartOfRound.ChangeLevel += (hook_ChangeLevel)obj5; object obj6 = <>O.<5>__StartOfRoundOnClientConnect; if (obj6 == null) { hook_OnClientConnect val7 = StartOfRoundOnClientConnect; <>O.<5>__StartOfRoundOnClientConnect = val7; obj6 = (object)val7; } StartOfRound.OnClientConnect += (hook_OnClientConnect)obj6; object obj7 = <>O.<6>__StartOfRoundOnClientDisconnect; if (obj7 == null) { hook_OnClientDisconnect val8 = StartOfRoundOnClientDisconnect; <>O.<6>__StartOfRoundOnClientDisconnect = val8; obj7 = (object)val8; } StartOfRound.OnClientDisconnect += (hook_OnClientDisconnect)obj7; object obj8 = <>O.<7>__DelayTravelEffects; if (obj8 == null) { hook_TravelToLevelEffects val9 = DelayTravelEffects; <>O.<7>__DelayTravelEffects = val9; obj8 = (object)val9; } StartOfRound.TravelToLevelEffects += (hook_TravelToLevelEffects)obj8; object obj9 = <>O.<8>__DynamicMoonCatalogue; if (obj9 == null) { hook_TextPostProcess val10 = DynamicMoonCatalogue; <>O.<8>__DynamicMoonCatalogue = val10; obj9 = (object)val10; } Terminal.TextPostProcess += (hook_TextPostProcess)obj9; object obj10 = <>O.<9>__ReplaceStaticOutsideEnemyProbabilityRange; if (obj10 == null) { Manipulator val11 = ReplaceStaticOutsideEnemyProbabilityRange; <>O.<9>__ReplaceStaticOutsideEnemyProbabilityRange = val11; obj10 = (object)val11; } RoundManager.PredictAllOutsideEnemies += (Manipulator)obj10; } if (!MoonDaySpeedMultiplierPatcherCompat.Enabled) { object obj11 = <>O.<10>__MultiplyGlobalTimeMultiplierToDaySpeedMultiplier; if (obj11 == null) { Manipulator val12 = MultiplyGlobalTimeMultiplierToDaySpeedMultiplier; <>O.<10>__MultiplyGlobalTimeMultiplierToDaySpeedMultiplier = val12; obj11 = (object)val12; } TimeOfDay.MoveGlobalTime += (Manipulator)obj11; object obj12 = <>O.<11>__IgnoreDaySpeedMultiplier; if (obj12 == null) { Manipulator val13 = IgnoreDaySpeedMultiplier; <>O.<11>__IgnoreDaySpeedMultiplier = val13; obj12 = (object)val13; } TimeOfDay.CalculatePlanetTime += (Manipulator)obj12; object obj13 = <>O.<11>__IgnoreDaySpeedMultiplier; if (obj13 == null) { Manipulator val14 = IgnoreDaySpeedMultiplier; <>O.<11>__IgnoreDaySpeedMultiplier = val14; obj13 = (object)val14; } TimeOfDay.Update += (Manipulator)obj13; } object obj14 = <>O.<12>__AccountForDaytimeDiversity; if (obj14 == null) { Manipulator val15 = AccountForDaytimeDiversity; <>O.<12>__AccountForDaytimeDiversity = val15; obj14 = (object)val15; } RoundManager.SpawnRandomDaytimeEnemy += (Manipulator)obj14; object obj15 = <>O.<13>__AccountForWeedDiversity; if (obj15 == null) { Manipulator val16 = AccountForWeedDiversity; <>O.<13>__AccountForWeedDiversity = val16; obj15 = (object)val16; } RoundManager.SpawnRandomWeedEnemy += (Manipulator)obj15; object obj16 = <>O.<14>__UpdateNewerDiversity; if (obj16 == null) { hook_RefreshEnemiesList val17 = UpdateNewerDiversity; <>O.<14>__UpdateNewerDiversity = val17; obj16 = (object)val17; } RoundManager.RefreshEnemiesList += (hook_RefreshEnemiesList)obj16; object obj17 = <>O.<15>__ResetNewerDiversity; if (obj17 == null) { hook_UnloadSceneObjectsEarly val18 = ResetNewerDiversity; <>O.<15>__ResetNewerDiversity = val18; obj17 = (object)val18; } RoundManager.UnloadSceneObjectsEarly += (hook_UnloadSceneObjectsEarly)obj17; object obj18 = <>O.<16>__SetCurrentMaxPower; if (obj18 == null) { hook_RefreshEnemiesList val19 = SetCurrentMaxPower; <>O.<16>__SetCurrentMaxPower = val19; obj18 = (object)val19; } RoundManager.RefreshEnemiesList += (hook_RefreshEnemiesList)obj18; object obj19 = <>O.<17>__ReplaceLevelValueWithRoundManager; if (obj19 == null) { Manipulator val20 = ReplaceLevelValueWithRoundManager; <>O.<17>__ReplaceLevelValueWithRoundManager = val20; obj19 = (object)val20; } RoundManager.SpawnDaytimeEnemiesOutside += (Manipulator)obj19; object obj20 = <>O.<17>__ReplaceLevelValueWithRoundManager; if (obj20 == null) { Manipulator val21 = ReplaceLevelValueWithRoundManager; <>O.<17>__ReplaceLevelValueWithRoundManager = val21; obj20 = (object)val21; } RoundManager.SpawnRandomDaytimeEnemy += (Manipulator)obj20; object obj21 = <>O.<18>__IntroduceMoreVariablesToSpawning; if (obj21 == null) { Manipulator val22 = IntroduceMoreVariablesToSpawning; <>O.<18>__IntroduceMoreVariablesToSpawning = val22; obj21 = (object)val22; } RoundManager.SpawnWeedEnemies += (Manipulator)obj21; } private static void IntroduceMoreVariablesToSpawning(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (!val.TryGotoNext((MoveType)0, new Func[5] { (Instruction val2) => ILPatternMatchingExt.MatchLdarg(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "WeedEnemySpawnRandom"), (Instruction val2) => ILPatternMatchingExt.MatchLdcI4(val2, 1), (Instruction val2) => ILPatternMatchingExt.MatchLdcI4(val2, 3), (Instruction val2) => ILPatternMatchingExt.MatchCallvirt(val2, "Next") })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply RoundManager.SpawnWeedEnemies patch (1)"); return; } int index = val.Index; val.Index = index + 1; val.RemoveRange(4); val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldfld, typeof(RoundManager).GetField("WeedEnemySpawnRandom")); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)GetWeedEnemySpawnChanceThroughDay); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)GetWeedSpawnProbabilityRange); val.EmitDelegate>((Func)DetermineNumberToSpawn); } private static int DetermineNumberToSpawn(RoundManager roundManager, Random weedEnemySpawnRandom, AnimationCurve weedEnemySpawnChanceThroughDay, float weedSpawnProbabilityRange) { float num = roundManager.timeScript.lengthOfHours * (float)roundManager.currentHour; float num2 = (float)(int)(weedEnemySpawnChanceThroughDay.Evaluate(num / roundManager.timeScript.totalTime) * 100f) / 100f; return weedEnemySpawnRandom.Next(Mathf.RoundToInt(num2 - weedSpawnProbabilityRange), Mathf.RoundToInt(num2 + weedSpawnProbabilityRange)); } private static AnimationCurve GetWeedEnemySpawnChanceThroughDay(RoundManager roundManager) { return SelectableLevelExtensions.get_WeedEnemySpawnChanceThroughDay(roundManager.currentLevel); } private static float GetWeedSpawnProbabilityRange(RoundManager roundManager) { return SelectableLevelExtensions.get_WeedEnemiesProbabilityRange(roundManager.currentLevel); } private static void AccountForWeedDiversity(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_0564: Unknown result type (might be due to invalid IL or missing references) //IL_0707: Unknown result type (might be due to invalid IL or missing references) //IL_0713: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel zeroWeightLabel = null; if (!val.TryGotoNext((MoveType)0, new Func[10] { (Instruction val2) => ILPatternMatchingExt.MatchLdloc(val2, 1), (Instruction val2) => ILPatternMatchingExt.MatchLdcI4(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchStfld(val2, "hasSpawnedAtLeastOne"), (Instruction val2) => ILPatternMatchingExt.MatchLdloc(val2, 1), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "PowerLevel"), (Instruction val2) => ILPatternMatchingExt.MatchLdcR4(val2, 4f), (Instruction val2) => ILPatternMatchingExt.MatchLdarg(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "currentWeedEnemyPower"), (Instruction val2) => ILPatternMatchingExt.MatchSub(val2), (Instruction val2) => ILPatternMatchingExt.MatchBgt(val2, ref zeroWeightLabel) })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply RoundManager.SpawnRandomWeedEnemy patch (1)"); return; } val.Emit(OpCodes.Ldloc, 1); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)GetCurrentWeedMaxDiversity); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)GetCurrentWeedDiversity); val.EmitDelegate>((Func)EnemyCanSpawnAccountingForDiversity); val.Emit(OpCodes.Brfalse_S, (object)zeroWeightLabel); if (!val.TryGotoNext((MoveType)2, new Func[5] { (Instruction val2) => ILPatternMatchingExt.MatchLdloc(val2, 1), (Instruction val2) => ILPatternMatchingExt.MatchLdcI4(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchStfld(val2, "hasSpawnedAtLeastOne"), (Instruction val2) => ILPatternMatchingExt.MatchLdloc(val2, 1), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "PowerLevel") })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply RoundManager.SpawnRandomWeedEnemy patch (2)"); return; } val.Remove(); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)GetCurrentMaxWeedPower); MethodReference val3 = default(MethodReference); if (!val.TryGotoNext((MoveType)0, new Func[7] { (Instruction val2) => ILPatternMatchingExt.MatchLdarg(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "increasedOutsideEnemySpawnRateIndex"), (Instruction val2) => ILPatternMatchingExt.MatchLdloc(val2, 7), (Instruction val2) => ILPatternMatchingExt.MatchBneUn(val2, ref val3), (Instruction val2) => ILPatternMatchingExt.MatchLdcI4(val2, 100), (Instruction val2) => ILPatternMatchingExt.MatchStloc(val2, 8), (Instruction val2) => ILPatternMatchingExt.MatchBr(val2, ref val3) })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply RoundManager.SpawnRandomWeedEnemy patch (3)"); return; } val.MoveAfterLabels(); val.RemoveRange(7); if (!val.TryGotoNext((MoveType)2, new Func[8] { (Instruction val2) => ILPatternMatchingExt.MatchLdarg(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "outsideAINodes"), (Instruction val2) => ILPatternMatchingExt.MatchStloc(val2, 6), (Instruction val2) => ILPatternMatchingExt.MatchLdcI4(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchStloc(val2, 9), (Instruction val2) => ILPatternMatchingExt.MatchBr(val2, ref val3), (Instruction val2) => ILPatternMatchingExt.MatchLdloc(val2, 4), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "PowerLevel") })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply RoundManager.SpawnRandomWeedEnemy patch (4)"); return; } val.Remove(); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)GetCurrentMaxWeedPower); if (!val.TryGotoNext((MoveType)0, new Func[10] { (Instruction val2) => ILPatternMatchingExt.MatchLdloc(val2, 11), (Instruction val2) => ILPatternMatchingExt.MatchCallvirt(val2, ref val3), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "enemyType"), (Instruction val2) => ILPatternMatchingExt.MatchDup(val2), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "numberSpawned"), (Instruction val2) => ILPatternMatchingExt.MatchLdcI4(val2, 1), (Instruction val2) => ILPatternMatchingExt.MatchAdd(val2), (Instruction val2) => ILPatternMatchingExt.MatchStfld(val2, "numberSpawned"), (Instruction val2) => ILPatternMatchingExt.MatchLdloc(val2, 11), (Instruction val2) => ILPatternMatchingExt.MatchCallvirt(val2, ref val3) })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply RoundManager.SpawnRandomWeedEnemy patch (5)"); return; } val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldloc, 4); val.EmitDelegate>((Action)IncrementWeedDiversity); } private static void IncrementWeedDiversity(RoundManager roundManager, EnemyType enemyType) { if (!enemyType.hasSpawnedAtLeastOne) { RoundManagerExtensions.set_CurrentWeedEnemyDiversityLevel(roundManager, RoundManagerExtensions.get_CurrentWeedEnemyDiversityLevel(roundManager) + enemyType.DiversityPowerLevel); } } private static int GetCurrentWeedDiversity(RoundManager roundManager) { return RoundManagerExtensions.get_CurrentWeedEnemyDiversityLevel(roundManager); } private static int GetCurrentWeedMaxDiversity(RoundManager roundManager) { return RoundManagerExtensions.get_CurrentMaxWeedDiversityLevel(roundManager); } private static float GetCurrentMaxWeedPower(RoundManager roundManager) { return RoundManagerExtensions.get_CurrentMaxWeedPower(roundManager); } private static void ReplaceLevelValueWithRoundManager(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); while (val.Index < val.Instrs.Count) { if ((!(val.Next.OpCode != OpCodes.Ldfld) || val.Next.Next == null || !(val.Next.Next.OpCode != OpCodes.Ldfld)) && ILPatternMatchingExt.MatchLdfld(val.Next, "currentLevel") && ILPatternMatchingExt.MatchLdfld(val.Next.Next, "maxDaytimeEnemyPowerCount")) { val.Index += 2; val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)((int _, RoundManager self) => RoundManagerExtensions.get_CurrentMaxDaytimePower(self))); } int index = val.Index; val.Index = index + 1; } } private static void SetCurrentMaxPower(orig_RefreshEnemiesList orig, RoundManager self) { orig.Invoke(self); RoundManagerExtensions.set_CurrentMaxDaytimePower(self, self.currentLevel.maxDaytimeEnemyPowerCount); RoundManagerExtensions.set_CurrentMaxWeedPower(self, SelectableLevelExtensions.get_MaxWeedEnemyPowerCount(self.currentLevel)); } private static void ResetNewerDiversity(orig_UnloadSceneObjectsEarly orig, RoundManager self) { orig.Invoke(self); RoundManagerExtensions.set_CurrentMaxDaytimeDiversityLevel(self, 0); RoundManagerExtensions.set_CurrentDaytimeEnemyDiversityLevel(self, 0); RoundManagerExtensions.set_CurrentMaxWeedDiversityLevel(self, 0); RoundManagerExtensions.set_CurrentWeedEnemyDiversityLevel(self, 0); } private static void UpdateNewerDiversity(orig_RefreshEnemiesList orig, RoundManager self) { RoundManagerExtensions.set_CurrentMaxDaytimeDiversityLevel(self, SelectableLevelExtensions.get_MaxDaytimeDiversityPowerCount(self.currentLevel)); RoundManagerExtensions.set_CurrentMaxWeedDiversityLevel(self, SelectableLevelExtensions.get_MaxWeedDiversityPowerCount(self.currentLevel)); orig.Invoke(self); } private static void AccountForDaytimeDiversity(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel firstSkipLabel = null; MethodReference val3 = default(MethodReference); if (!val.TryGotoNext((MoveType)2, new Func[7] { (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "normalizedTimeInDayToLeave"), (Instruction val2) => ILPatternMatchingExt.MatchCall(val2, "get_Instance"), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "normalizedTimeOfDay"), (Instruction val2) => ILPatternMatchingExt.MatchBlt(val2, ref firstSkipLabel), (Instruction val2) => ILPatternMatchingExt.MatchLdloc(val2, 2), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "spawningDisabled"), (Instruction val2) => ILPatternMatchingExt.MatchBrtrue(val2, ref val3) })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply RoundManager.SpawnRandomDaytimeEnemy patch (1)"); return; } val.Emit(OpCodes.Ldloc, 2); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)GetCurrentDaytimeMaxDiversity); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)GetCurrentDaytimeDiversity); val.EmitDelegate>((Func)EnemyCanSpawnAccountingForDiversity); val.Emit(OpCodes.Brfalse_S, (object)firstSkipLabel); ILLabel zeroWeightLabel = null; if (!val.TryGotoNext((MoveType)0, new Func[9] { (Instruction val2) => ILPatternMatchingExt.MatchLdloc(val2, 2), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "PowerLevel"), (Instruction val2) => ILPatternMatchingExt.MatchLdarg(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "currentLevel"), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "maxDaytimeEnemyPowerCount"), (Instruction val2) => ILPatternMatchingExt.MatchConvR4(val2), (Instruction val2) => ILPatternMatchingExt.MatchLdloc(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchSub(val2), (Instruction val2) => ILPatternMatchingExt.MatchBgt(val2, ref zeroWeightLabel) })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply RoundManager.SpawnRandomDaytimeEnemy patch (2)"); return; } val.Emit(OpCodes.Ldloc, 2); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)GetCurrentDaytimeMaxDiversity); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Func)GetCurrentDaytimeDiversity); val.EmitDelegate>((Func)EnemyCanSpawnAccountingForDiversity); val.Emit(OpCodes.Brfalse_S, (object)zeroWeightLabel); if (!val.TryGotoNext((MoveType)0, new Func[10] { (Instruction val2) => ILPatternMatchingExt.MatchLdloc(val2, 14), (Instruction val2) => ILPatternMatchingExt.MatchCallvirt(val2, ref val3), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "enemyType"), (Instruction val2) => ILPatternMatchingExt.MatchDup(val2), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "numberSpawned"), (Instruction val2) => ILPatternMatchingExt.MatchLdcI4(val2, 1), (Instruction val2) => ILPatternMatchingExt.MatchAdd(val2), (Instruction val2) => ILPatternMatchingExt.MatchStfld(val2, "numberSpawned"), (Instruction val2) => ILPatternMatchingExt.MatchLdloc(val2, 14), (Instruction val2) => ILPatternMatchingExt.MatchCallvirt(val2, ref val3) })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply RoundManager.SpawnRandomDaytimeEnemy patch (3)"); return; } val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldloc, 5); val.EmitDelegate>((Action)IncrementDaytimeDiversity); } private static void IncrementDaytimeDiversity(RoundManager roundManager, EnemyType enemyType) { if (!enemyType.hasSpawnedAtLeastOne) { RoundManagerExtensions.set_CurrentDaytimeEnemyDiversityLevel(roundManager, RoundManagerExtensions.get_CurrentDaytimeEnemyDiversityLevel(roundManager) + enemyType.DiversityPowerLevel); } } private static bool EnemyCanSpawnAccountingForDiversity(EnemyType enemyType, int currentMaxDiversityLevel, int currentEnemyDiversityLevel) { if (enemyType.DiversityPowerLevel > currentMaxDiversityLevel - currentEnemyDiversityLevel) { return enemyType.hasSpawnedAtLeastOne; } return true; } private static int GetCurrentDaytimeDiversity(RoundManager roundManager) { return RoundManagerExtensions.get_CurrentDaytimeEnemyDiversityLevel(roundManager); } private static int GetCurrentDaytimeMaxDiversity(RoundManager roundManager) { return RoundManagerExtensions.get_CurrentMaxDaytimeDiversityLevel(roundManager); } private static void ReplaceStaticOutsideEnemyProbabilityRange(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int num = default(int); if (!val.TryGotoNext((MoveType)2, new Func[3] { (Instruction i) => ILPatternMatchingExt.MatchLdloc(i, ref num), (Instruction i) => ILPatternMatchingExt.MatchLdloc(i, ref num), (Instruction i) => ILPatternMatchingExt.MatchLdcR4(i, 3f) })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply RoundManager.PredictAllOutsideEnemies patch (1)"); return; } val.Emit(OpCodes.Pop); val.Emit(OpCodes.Call, (MethodBase)typeof(MoonRegistrationHandler).GetMethod("GetMoonOutsideEnemyProbabilitySpawnRange", BindingFlags.Static | BindingFlags.NonPublic)); if (!val.TryGotoNext((MoveType)2, new Func[3] { (Instruction val2) => ILPatternMatchingExt.MatchConvI4(val2), (Instruction val2) => ILPatternMatchingExt.MatchLdloc(val2, ref num), (Instruction val2) => ILPatternMatchingExt.MatchLdcR4(val2, 3f) })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply RoundManager.PredictAllOutsideEnemies patch (2)"); return; } val.Emit(OpCodes.Pop); val.Emit(OpCodes.Call, (MethodBase)typeof(MoonRegistrationHandler).GetMethod("GetMoonOutsideEnemyProbabilitySpawnRange", BindingFlags.Static | BindingFlags.NonPublic)); } private static float GetMoonOutsideEnemyProbabilitySpawnRange() { if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.currentLevel == (Object)null || SelectableLevelExtensions.get_DawnInfo(StartOfRound.Instance.currentLevel) == null) { return 3f; } return SelectableLevelExtensions.get_OutsideEnemiesProbabilityRange(StartOfRound.Instance.currentLevel); } private static void MultiplyGlobalTimeMultiplierToDaySpeedMultiplier(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (!val.TryGotoNext((MoveType)2, new Func[2] { (Instruction val2) => ILPatternMatchingExt.MatchLdarg(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "globalTimeSpeedMultiplier") })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply TimeOfDay.MoveGlobalTime patch"); return; } val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldfld, typeof(TimeOfDay).GetField("currentLevel")); val.Emit(OpCodes.Ldfld, typeof(SelectableLevel).GetField("DaySpeedMultiplier")); val.Emit(OpCodes.Mul); } private static void IgnoreDaySpeedMultiplier(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0049: 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) ILCursor val = new ILCursor(il); if (!val.TryGotoNext((MoveType)2, new Func[1] { (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "DaySpeedMultiplier") })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply TimeOfDay.Update patch"); return; } val.Emit(OpCodes.Pop); val.Emit(OpCodes.Ldc_R4, 1f); } private static void SpawnRouteProgressUI(orig_Awake orig, StartOfRound self) { Object.Instantiate(RouteProgressUIPrefab, ((Component)self.radarCanvas).transform); orig.Invoke(self); } private static void FixAmbienceLibraries() { List vanillaLevelAmbienceLibraries = new List(); foreach (DawnMoonInfo value in LethalContent.Moons.Values) { if (value.TypedKey.IsVanilla()) { if ((Object)(object)value.Level.levelAmbienceClips != (Object)null) { vanillaLevelAmbienceLibraries.Add(value.Level.levelAmbienceClips); } vanillaLevelAmbienceLibraries.AddRange(from dungeonFlowType in value.Level.dungeonFlowTypes select dungeonFlowType.overrideLevelAmbience into x where (Object)(object)x != (Object)null select x); } } vanillaLevelAmbienceLibraries = vanillaLevelAmbienceLibraries.Distinct().ToList(); List list = new List(); foreach (DawnMoonInfo value2 in LethalContent.Moons.Values) { if (value2.ShouldSkipIgnoreOverride()) { continue; } foreach (LevelAmbienceLibrary item in vanillaLevelAmbienceLibraries) { if ((Object)(object)value2.Level.levelAmbienceClips != (Object)null && ((Object)value2.Level.levelAmbienceClips).name == ((Object)item).name) { list.Add(value2.Level.levelAmbienceClips); value2.Level.levelAmbienceClips = item; } for (int num = 0; num < value2.Level.dungeonFlowTypes.Length; num++) { LevelAmbienceLibrary overrideLevelAmbience = value2.Level.dungeonFlowTypes[num].overrideLevelAmbience; if (!((Object)(object)overrideLevelAmbience == (Object)null) && !(((Object)overrideLevelAmbience).name != ((Object)item).name)) { list.Add(overrideLevelAmbience); value2.Level.dungeonFlowTypes[num].overrideLevelAmbience = item; } } } } list = list.Where((LevelAmbienceLibrary x) => !vanillaLevelAmbienceLibraries.Contains(x)).Distinct().ToList(); for (int num2 = list.Count - 1; num2 >= 0; num2--) { Object.Destroy((Object)(object)list[num2]); } } private static void RegisterDawnLevels(orig_Awake orig, Terminal self) { //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Expected O, but got Unknown //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Expected O, but got Unknown //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Expected O, but got Unknown List list = StartOfRoundRefs.Instance.levels.ToList(); foreach (DawnMoonInfo value in LethalContent.Moons.Values) { if (!value.ShouldSkipIgnoreOverride()) { value.Level.levelID = list.Count; list.Add(value.Level); UpdateMoonPrice(value); } } StartOfRoundRefs.Instance.levels = list.ToArray(); if (LethalContent.Moons.IsFrozen) { orig.Invoke(self); return; } List list2 = TerminalRefs.Instance.terminalNodes.allKeywords.ToList(); List list3 = TerminalRefs.RouteKeyword.compatibleNouns.ToList(); List list4 = TerminalRefs.Instance.moonsCatalogueList.ToList(); foreach (DawnMoonInfo value2 in LethalContent.Moons.Values) { if (!value2.ShouldSkipIgnoreOverride() && !((Object)(object)value2.ReceiptNode == (Object)null) && !((Object)(object)value2.RouteNode == (Object)null) && !((Object)(object)value2.NameKeyword == (Object)null)) { value2.ReceiptNode.buyRerouteToMoon = value2.Level.levelID; value2.RouteNode.displayPlanetInfo = value2.Level.levelID; list3.Add(new CompatibleNoun(value2.NameKeyword, value2.RouteNode)); list2.Add(value2.NameKeyword); value2.NameKeyword.defaultVerb = TerminalRefs.RouteKeyword; value2.RouteNode.overrideOptions = true; value2.RouteNode.terminalOptions = (CompatibleNoun[])(object)new CompatibleNoun[2] { new CompatibleNoun(TerminalRefs.DenyKeyword, TerminalRefs.CancelRouteNode), new CompatibleNoun(TerminalRefs.ConfirmPurchaseKeyword, value2.ReceiptNode) }; if (!(value2.DawnPurchaseInfo.PurchasePredicate.CanPurchase() is TerminalPurchaseResult.HiddenPurchaseResult)) { list4.Add(value2.Level); } } } TerminalRefs.Instance.moonsCatalogueList = list4.ToArray(); TerminalRefs.RouteKeyword.compatibleNouns = list3.ToArray(); TerminalRefs.Instance.terminalNodes.allKeywords = list2.ToArray(); orig.Invoke(self); } [HarmonyPatch(typeof(StartOfRound), "Start")] [HarmonyPrefix] [HarmonyPriority(-999)] private static void FreezeMoonRegistry() { foreach (DawnMoonInfo value in LethalContent.Moons.Values) { if (value.Level.indoorMapHazards == null) { value.Level.indoorMapHazards = Array.Empty(); } } if (!LethalContent.Moons.IsFrozen) { LethalContent.Moons.Freeze(); } } private static void FixDawnMoonItems() { List list = new List(); foreach (DawnMoonInfo value in LethalContent.Moons.Values) { if (value.ShouldSkipIgnoreOverride()) { continue; } SpawnableItemWithRarity[] array = value.Level.spawnableScrap.ToArray(); foreach (SpawnableItemWithRarity val in array) { if ((Object)(object)val.spawnableItem == (Object)null) { value.Level.spawnableScrap.Remove(val); continue; } bool flag = ItemExtensions.get_DawnInfo(val.spawnableItem) != null; foreach (DawnItemInfo value2 in LethalContent.Items.Values) { if (!flag && ((Object)value2.Item).name == ((Object)val.spawnableItem).name) { list.Add(val.spawnableItem); val.spawnableItem = value2.Item; break; } } } } for (int num = list.Count - 1; num >= 0; num--) { Object.Destroy((Object)(object)list[num]); } } private static void FixDawnMoonEnemies() { List list = new List(); foreach (DawnMoonInfo value in LethalContent.Moons.Values) { if (value.ShouldSkipIgnoreOverride()) { continue; } EnemyType val = value.Level.specialEnemyRarity?.overrideEnemy; foreach (DawnEnemyInfo value2 in LethalContent.Enemies.Values) { EnemyType enemyType = value2.EnemyType; ReplaceAndSetToDestroy(value.Level.Enemies, enemyType, list); ReplaceAndSetToDestroy(value.Level.OutsideEnemies, enemyType, list); ReplaceAndSetToDestroy(value.Level.DaytimeEnemies, enemyType, list); ReplaceAndSetToDestroy(SelectableLevelExtensions.get_WeedEnemies(value.Level), enemyType, list); if ((Object)(object)val != (Object)null && EnemyTypeExtensions.get_DawnInfo(val) == null && ((Object)enemyType).name == ((Object)val).name) { Debuggers.Moons?.Log("replacing fake SO " + ((Object)val).name + " with " + ((Object)enemyType).name); list.Add(val); val = enemyType; } } } for (int num = list.Count - 1; num >= 0; num--) { if (!((Object)(object)list[num] == (Object)null)) { Object.Destroy((Object)(object)list[num]); } } } private static void ReplaceAndSetToDestroy(List spawnableEnemiesWithRarities, EnemyType potentialReplacement, List enemiesToDestroy) { for (int num = spawnableEnemiesWithRarities.Count - 1; num >= 0; num--) { SpawnableEnemyWithRarity val = spawnableEnemiesWithRarities[num]; if ((Object)(object)val.enemyType == (Object)null) { spawnableEnemiesWithRarities.RemoveAt(num); } else if (EnemyTypeExtensions.get_DawnInfo(val.enemyType) == null && ((Object)potentialReplacement).name == ((Object)val.enemyType).name) { Debuggers.Moons?.Log("replacing fake SO " + ((Object)val.enemyType).name + " with " + ((Object)potentialReplacement).name); enemiesToDestroy.Add(val.enemyType); val.enemyType = potentialReplacement; break; } } } private static string DynamicMoonCatalogue(orig_TextPostProcess orig, Terminal self, string modifieddisplaytext, TerminalNode node) { if ((Object)(object)node != (Object)(object)TerminalRefs.MoonCatalogueNode || LethalConstellationsCompat.Enabled) { return orig.Invoke(self, modifieddisplaytext, node); } StringBuilder stringBuilder = new StringBuilder("\n\nWelcome to the exomoons catalogue.\nTo route the autopilot to a moon, use the word ROUTE.\nTo learn about any moon, use INFO.\n____________________________\n"); IEnumerable input = from it in LethalContent.Moons.Values where !it.HasTag(Tags.Unimplemented) orderby it.HasTag(Tags.Vanilla) descending select it; List list = MoonGroupAlgorithm.Group(input); foreach (MoonGroup item in list) { stringBuilder.AppendLine(""); if (!string.IsNullOrWhiteSpace(item.GroupName)) { stringBuilder.AppendLine(item.GroupName); } foreach (DawnMoonInfo moon in item.Moons) { TerminalPurchaseResult result = moon.DawnPurchaseInfo.PurchasePredicate.CanPurchase(); stringBuilder.AppendLine(FormatMoonEntry(moon, result)); } } return orig.Invoke(self, stringBuilder.ToString(), node); } public static string FormatMoonEntry(DawnMoonInfo moonInfo, TerminalPurchaseResult result) { StringBuilder stringBuilder = new StringBuilder(); string text = moonInfo.GetNumberlessPlanetName(); if (result is TerminalPurchaseResult.FailedPurchaseResult failedPurchaseResult) { text = failedPurchaseResult.OverrideName ?? text; } if (text == "Gordion") { text = "The Company building"; } stringBuilder.Append("* " + text + " "); if (moonInfo.HasTag(DawnLibTags.HasBuyingPercent)) { stringBuilder.Append("// Buying at [companyBuyingPercent]."); } else { TryAppendMoonWeather(stringBuilder, moonInfo); } return stringBuilder.ToString(); } public static void TryAppendMoonWeather(StringBuilder builder, DawnMoonInfo moonInfo) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) DawnWeatherEffectInfo currentWeather = moonInfo.GetCurrentWeather(); if (currentWeather != null) { builder.Append($"({moonInfo.Level.currentWeather})"); } } private static IEnumerator DelayTravelEffects(orig_TravelToLevelEffects orig, StartOfRound self) { IEnumerator enumerator = orig.Invoke(self); while (enumerator.MoveNext()) { yield return enumerator.Current; object current = enumerator.Current; WaitForSeconds val = (WaitForSeconds)((current is WaitForSeconds) ? current : null); if (val != null && val.m_Seconds == self.currentLevel.timeToArrive && NetworkSingleton.IsNotNull) { yield return (object)new WaitUntil((Func)(() => NetworkSingleton.Instance.allPlayersDone)); } } self.shipTravelCoroutine = null; } private static void StartOfRoundOnClientDisconnect(orig_OnClientDisconnect orig, StartOfRound self, ulong clientid) { orig.Invoke(self, clientid); if (((NetworkBehaviour)self).IsServer && self.inShipPhase) { NetworkSingleton.Instance?.HostRebroadcastQueue(); } } private static void StartOfRoundOnClientConnect(orig_OnClientConnect orig, StartOfRound self, ulong clientid) { orig.Invoke(self, clientid); if (((NetworkBehaviour)self).IsServer && self.inShipPhase) { NetworkSingleton.Instance?.HostRebroadcastQueue(); } } private static void StartOfRoundOnChangeLevel(orig_ChangeLevel orig, StartOfRound self, int levelid) { orig.Invoke(self, levelid); if (((NetworkBehaviour)self).IsServer) { ((MonoBehaviour)self).StartCoroutine(DoHotloadSceneStuff(self.currentLevel)); } } private static IEnumerator DoHotloadSceneStuff(SelectableLevel level) { yield return (object)new WaitUntil((Func)(() => NetworkSingleton.IsNotNull && Singleton.IsNotNull)); NetworkSingleton.Instance.HostDecide(SelectableLevelExtensions.get_DawnInfo(level)); } private static void CollectLevels(orig_Awake orig, StartOfRound self) { orig.Invoke(self); if (LethalContent.Moons.IsFrozen) { return; } _ = TerminalRefs.Instance; SelectableLevel[] levels = StartOfRound.Instance.levels; foreach (SelectableLevel val in levels) { if (SelectableLevelExtensions.get_DawnInfo(val) != null) { continue; } Debuggers.Moons?.Log($"Registering level: {val.PlanetName} with scrap spawn range of: {val.minScrap} and {val.maxScrap}"); NamespacedKey namespacedKey = MoonKeys.GetByReflection(NamespacedKey.NormalizeStringForNamespacedKey(val.PlanetName, CSharpName: true).RemoveEnd("Level")); if (namespacedKey == null && LethalLevelLoaderCompat.Enabled && LethalLevelLoaderCompat.TryGetExtendedLevelModName(val, out string modName)) { namespacedKey = NamespacedKey.From(modName, val.PlanetName); } else if (namespacedKey == null) { namespacedKey = NamespacedKey.From("unknown_modded", val.PlanetName); } HashSet tags = new HashSet { DawnLibTags.IsExternal }; CollectLLLTags(val, tags); TerminalNode val2 = null; TerminalNode receiptNode = null; TerminalKeyword nameKeyword = null; CompatibleNoun[] compatibleNouns = TerminalRefs.RouteKeyword.compatibleNouns; foreach (CompatibleNoun val3 in compatibleNouns) { if (val3.result.displayPlanetInfo == val.levelID) { val2 = val3.result; if (val2.terminalOptions.Length > 1) { receiptNode = val2.terminalOptions[1].result; } nameKeyword = val3.noun; break; } } ITerminalPurchasePredicate purchasePredicate = ITerminalPurchasePredicate.AlwaysSuccess(); if (LethalLevelLoaderCompat.Enabled && LethalLevelLoaderCompat.ExtendedLevelIsModded(val, out object extendedLevelObject)) { purchasePredicate = new LethalLevelLoaderTerminalPredicate(extendedLevelObject); } else if (LethalLevelLoaderCompat.Enabled && DawnConfig.AllowLLLToOverrideVanillaStatus.Value && namespacedKey.IsVanilla()) { purchasePredicate = new LethalLevelLoaderTerminalPredicate(val); } else if (object.Equals(namespacedKey, MoonKeys.Embrion) || object.Equals(namespacedKey, MoonKeys.Artifice)) { purchasePredicate = new ConstantTerminalPredicate(TerminalPurchaseResult.Hidden().SetFailure(isFailure: false)); } List list = new List(); List> list2 = new List>(); if (namespacedKey.IsVanilla()) { list2.Add(NamespacedKey.Vanilla(val.sceneName)); } else { list2.Add(NamespacedKey.From(namespacedKey.Namespace, val.sceneName)); } foreach (NamespacedKey item in list2) { if (item.IsVanilla()) { list.Add(new VanillaMoonSceneInfo(item, val.sceneName)); } else { list.Add(new VanillaMoonSceneInfo(item, val.sceneName)); } } DawnMoonInfo value = new DawnMoonInfo(namespacedKey, tags, val, 3f, 100, 4, 100, RoundManagerRefs.Instance.WeedEnemies.ToList(), AnimationCurve.Constant(0f, 1f, 2f), 1f, list, val2, receiptNode, nameKeyword, new DawnPurchaseInfo(new SimpleProvider(val2?.itemCost ?? (-1)), purchasePredicate), null); SelectableLevelExtensions.set_DawnInfo(val, value); LethalContent.Moons.Register(value); } } private static void CollectTestLevel(orig_Awake orig, StartOfRound self) { if (LethalContent.Moons.IsFrozen) { orig.Invoke(self); return; } DawnMoonInfo value = new DawnMoonInfo(MoonKeys.Test, new HashSet { DawnLibTags.IsExternal }, self.currentLevel, 3f, 100, 4, 100, RoundManagerRefs.Instance.WeedEnemies.ToList(), AnimationCurve.Constant(0f, 1f, 2f), 1f, new List(), null, null, null, new DawnPurchaseInfo(new SimpleProvider(-1), ITerminalPurchasePredicate.AlwaysHide()), null); SelectableLevelExtensions.set_DawnInfo(self.currentLevel, value); LethalContent.Moons.Register(value); orig.Invoke(self); } private static void CollectLLLTags(SelectableLevel moon, HashSet tags) { if (LethalLevelLoaderCompat.Enabled && LethalLevelLoaderCompat.TryGetAllTagsWithModNames(moon, out List<(string, string)> allTagsWithModNames)) { tags.AddToList(allTagsWithModNames, Debuggers.Moons, ((Object)moon).name); } } internal static void UpdateAllPrices() { foreach (DawnMoonInfo value in LethalContent.Moons.Values) { if (!value.ShouldSkipRespectOverride()) { UpdateMoonPrice(value); } } } private static void UpdateMoonPrice(DawnMoonInfo moonInfo) { int itemCost = moonInfo.DawnPurchaseInfo.Cost.Provide(); if ((Object)(object)moonInfo.RouteNode != (Object)null) { moonInfo.RouteNode.itemCost = itemCost; } if ((Object)(object)moonInfo.ReceiptNode != (Object)null) { moonInfo.ReceiptNode.itemCost = itemCost; } } } public sealed class DawnMoonInfo : DawnBaseInfo { public SelectableLevel Level { get; } public TerminalNode? RouteNode { get; } public TerminalNode? ReceiptNode { get; } public TerminalKeyword? NameKeyword { get; } public float OutsideEnemiesProbabilityRange { get; internal set; } public int MaxDaytimeDiversityPowerCount { get; internal set; } public int MaxWeedEnemyPowerCount { get; internal set; } public int MaxWeedDiversityPowerCount { get; internal set; } public List WeedEnemies { get; } = new List(); public AnimationCurve WeedEnemySpawnChanceThroughDay { get; internal set; } public float WeedEnemiesProbabilityRange { get; internal set; } public List Scenes { get; } = new List(); public DawnPurchaseInfo DawnPurchaseInfo { get; } internal DawnMoonInfo(NamespacedKey key, HashSet tags, SelectableLevel level, float outsideEnemiesProbabilityRange, int maxDaytimeDiversityPowerCount, int maxWeedEnemyPowerCount, int maxWeedDiversityPowerCount, List weedEnemies, AnimationCurve weedEnemySpawnChanceThroughDay, float weedEnemiesProbabilityRange, List scenes, TerminalNode? routeNode, TerminalNode? receiptNode, TerminalKeyword? nameKeyword, DawnPurchaseInfo dawnPurchaseInfo, IDataContainer? customData) : base(key, tags, customData) { Level = level; OutsideEnemiesProbabilityRange = outsideEnemiesProbabilityRange; MaxDaytimeDiversityPowerCount = maxDaytimeDiversityPowerCount; MaxWeedEnemyPowerCount = maxWeedEnemyPowerCount; MaxWeedDiversityPowerCount = maxWeedDiversityPowerCount; WeedEnemies = weedEnemies; WeedEnemySpawnChanceThroughDay = weedEnemySpawnChanceThroughDay; WeedEnemiesProbabilityRange = weedEnemiesProbabilityRange; Scenes.AddRange(scenes); RouteNode = routeNode; ReceiptNode = receiptNode; NameKeyword = nameKeyword; DawnPurchaseInfo = dawnPurchaseInfo; } public DawnWeatherEffectInfo? GetCurrentWeather() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_001c: Unknown result type (might be due to invalid IL or missing references) LevelWeatherType currentWeather = Level.currentWeather; if ((int)currentWeather == -1) { return null; } WeatherEffect weatherEffect = TimeOfDay.Instance.effects[currentWeather]; if (WeatherEffectExtensions.get_DawnInfo(weatherEffect) != null) { return WeatherEffectExtensions.get_DawnInfo(weatherEffect); } return null; } public string GetConfigName() { string text = StripSpecialCharacters(Level.PlanetName); if (!text.EndsWith("Level", ignoreCase: true, CultureInfo.InvariantCulture)) { text += "Level"; } return text.ToLowerInvariant(); } public string GetNumberlessPlanetName() { return StripSpecialCharacters(Level.PlanetName); } public void RouteTo() { int num = Array.IndexOf(StartOfRound.Instance.levels, Level); StartOfRound.Instance.ChangeLevelServerRpc(num, TerminalRefs.Instance.groupCredits); } public void ChangeWeatherTo(LevelWeatherType levelWeatherType) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) if (WeatherRegistryCompat.Enabled) { WeatherRegistryCompat.SetCurrentWeather(Level, levelWeatherType); return; } EveryoneRpcTarget val = new EveryoneRpcTarget(NetworkManager.Singleton); NetworkSingleton.Instance.ChangeWeatherToRpc(base.Key, levelWeatherType, RpcParams.op_Implicit((BaseRpcTarget)(object)val)); ((BaseRpcTarget)val).Dispose(); } public void ChangeWeatherTo(DawnWeatherEffectInfo? weatherEffectInfo) { if (weatherEffectInfo == null) { ChangeWeatherTo((LevelWeatherType)(-1)); } else { ChangeWeatherTo((LevelWeatherType)MiscHelpers.IndexOf((IEnumerable)TimeOfDayRefs.Instance.effects, weatherEffectInfo.WeatherEffect)); } } private static string StripSpecialCharacters(string input) { string text = string.Empty; for (int i = 0; i < input.Length; i++) { char c = input[i]; if (char.IsLetter(c)) { text += c; } } return text; } } public class MoonGroup { public string GroupName = ""; public List Moons = new List(); } public interface IMoonFilterStep { IEnumerable Filter(IEnumerable input); } public interface IMoonOrderingStep { IOrderedEnumerable ApplyInitial(IEnumerable input, bool reverse = false); IOrderedEnumerable ApplyNext(IOrderedEnumerable input, bool reverse = false); } public interface IMoonGroupingAlgorithm { List Group(IEnumerable input); } public class VisibleFilterStep : IMoonFilterStep { public IEnumerable Filter(IEnumerable input) { return input.Where((DawnMoonInfo moon) => !(moon.DawnPurchaseInfo.PurchasePredicate.CanPurchase() is TerminalPurchaseResult.HiddenPurchaseResult)); } } public class TagFilterStep(NamespacedKey tag) : IMoonFilterStep { public IEnumerable Filter(IEnumerable input) { return input.Where((DawnMoonInfo moon) => moon.HasTag(tag)); } } public class FixedGroupSizeGroupingAlgorithm(int groupSize = 3) : IMoonGroupingAlgorithm { public List Group(IEnumerable input) { MoonGroup moonGroup = new MoonGroup(); MoonGroup moonGroup2 = new MoonGroup(); List list = new List(1) { moonGroup2 }; int num = 0; foreach (DawnMoonInfo item in input) { if (item.HasTag(Tags.Company)) { moonGroup.Moons.Add(item); continue; } moonGroup2.Moons.Add(item); if (!(item.DawnPurchaseInfo.PurchasePredicate.CanPurchase() is TerminalPurchaseResult.HiddenPurchaseResult)) { num++; } if (num == groupSize) { moonGroup2 = new MoonGroup(); num = 0; list.Add(moonGroup2); } } list.RemoveAll((MoonGroup group) => group.Moons.Count == 0); if (moonGroup.Moons.Count > 0) { list.Insert(0, moonGroup); } return list; } } public class RankOrderingStep : IMoonOrderingStep { private static readonly string[] RiskIndexes = new string[8] { "F", "E", "D", "C", "B", "A", "S", "UNKNOWN" }; public IOrderedEnumerable ApplyInitial(IEnumerable input, bool reverse = false) { if (!reverse) { return input.OrderBy(GetRiskIndex); } return input.OrderByDescending(GetRiskIndex); } public IOrderedEnumerable ApplyNext(IOrderedEnumerable input, bool reverse = false) { if (!reverse) { return input.ThenBy(GetRiskIndex); } return input.ThenByDescending(GetRiskIndex); } private int GetRiskIndex(DawnMoonInfo moonInfo) { string input = moonInfo.Level.riskLevel ?? "UNKNOWN"; input = input.StripSpecialCharacters(); int num = Array.IndexOf(RiskIndexes, input); if (num < 0) { return RiskIndexes.Length - 1; } return num; } } public class PriceOrderingStep : IMoonOrderingStep { public IOrderedEnumerable ApplyInitial(IEnumerable input, bool reverse = false) { if (!reverse) { return input.OrderBy(GetPrice); } return input.OrderByDescending(GetPrice); } public IOrderedEnumerable ApplyNext(IOrderedEnumerable input, bool reverse = false) { if (!reverse) { return input.ThenBy(GetPrice); } return input.ThenByDescending(GetPrice); } private int GetPrice(DawnMoonInfo moonInfo) { return moonInfo.DawnPurchaseInfo.Cost.Provide(); } } public class IndexBasedOrderingStep : IMoonOrderingStep { public IOrderedEnumerable ApplyInitial(IEnumerable input, bool reverse = false) { if (!reverse) { return input.OrderBy(GetIndex); } return input.OrderByDescending(GetIndex); } public IOrderedEnumerable ApplyNext(IOrderedEnumerable input, bool reverse = false) { if (!reverse) { return input.ThenBy(GetIndex); } return input.ThenByDescending(GetIndex); } private int GetIndex(DawnMoonInfo moonInfo) { return LethalContent.Moons.Values.ToList().IndexOf(moonInfo); } } public class MainGroupAlgorithm { public List FilterSteps = new List(1) { new VisibleFilterStep() }; public List OrderingSteps = new List(3) { new RankOrderingStep(), new PriceOrderingStep(), new IndexBasedOrderingStep() }; public IMoonGroupingAlgorithm GroupingAlgorithm = new FixedGroupSizeGroupingAlgorithm(); public List Group(IEnumerable input, bool reverse = false) { IEnumerable enumerable = input; foreach (IMoonFilterStep filterStep in FilterSteps) { enumerable = filterStep.Filter(enumerable); } IOrderedEnumerable orderedEnumerable = null; for (int i = 0; i < OrderingSteps.Count; i++) { IMoonOrderingStep moonOrderingStep = OrderingSteps[i]; orderedEnumerable = ((i == 0) ? moonOrderingStep.ApplyInitial(enumerable, reverse) : moonOrderingStep.ApplyNext(orderedEnumerable, reverse)); } IEnumerable enumerable2 = orderedEnumerable; IEnumerable input2 = enumerable2 ?? enumerable; return GroupingAlgorithm.Group(input2); } } public class MoonInfoBuilder : BaseInfoBuilder { private TerminalNode? _routeNode; private TerminalNode? _receiptNode; private TerminalKeyword? _nameKeyword; private List _scenes = new List(); private IProvider? _costOverride; private ITerminalPurchasePredicate? _purchasePredicate; private float _outsideEnemiesProbabilityRange = 3f; private int _maxWeedEnemyPowerCount; private int _maxWeedDiversityPowerCount; private int _maxDaytimeDiversityPowerCount; private AnimationCurve _weedEnemySpawnChanceThroughDay = AnimationCurve.Constant(0f, 0f, 1f); private float _weedEnemiesProbabilityRange; private List _weedEnemies = new List(); public MoonInfoBuilder(NamespacedKey key, SelectableLevel value) : base(key, value) { } public MoonInfoBuilder OverrideRouteNode(TerminalNode node) { _routeNode = node; return this; } public MoonInfoBuilder CreateNameKeyword(string wordOverride) { if (string.IsNullOrWhiteSpace(wordOverride)) { wordOverride = base.value.PlanetName.ToLowerInvariant().Replace(' ', '-'); } _nameKeyword = new TerminalKeywordBuilder(base.value.PlanetName + "NameKeyword", wordOverride, ITerminalKeyword.DawnKeywordType.Moons).Build(); _nameKeyword.compatibleNouns = Array.Empty(); return this; } public MoonInfoBuilder AddScene(NamespacedKey sceneKey, AnimationClip shipLandingOverrideAnimation, AnimationClip shipTakeoffOverrideAnimation, DawnWeightedValue weight, string assetBundlePath, string scenePath) { _scenes.Add(new CustomMoonSceneInfo(sceneKey, shipLandingOverrideAnimation, shipTakeoffOverrideAnimation, weight, assetBundlePath, scenePath)); return this; } private static string StripSpecialCharacters(string input) { string text = string.Empty; for (int i = 0; i < input.Length; i++) { char c = input[i]; if (char.IsLetter(c)) { text += c; } } return text; } public MoonInfoBuilder OverrideCost(int cost) { return OverrideCost(new SimpleProvider(cost)); } public MoonInfoBuilder OverrideTimeMultiplier(float multiplier) { base.value.DaySpeedMultiplier = multiplier; return this; } public MoonInfoBuilder OverrideMinMaxScrap(BoundedRange range) { base.value.minScrap = (int)range.Min; base.value.maxScrap = (int)range.Max; return this; } public MoonInfoBuilder OverrideEnemyPowerCount(int maxInsidePowerCount, int maxOutsidePowerCount, int maxDaytimePowerCount, int maxWeedPowerCount) { base.value.maxEnemyPowerCount = maxInsidePowerCount; base.value.maxOutsideEnemyPowerCount = maxOutsidePowerCount; base.value.maxDaytimeEnemyPowerCount = maxDaytimePowerCount; _maxWeedEnemyPowerCount = maxWeedPowerCount; return this; } public MoonInfoBuilder OverrideEnemySpawnCurves(AnimationCurve insideAnimationCurve, AnimationCurve outsideAnimationCurve, AnimationCurve daytimeAnimationCurve, AnimationCurve weedAnimationCurve) { base.value.enemySpawnChanceThroughoutDay = insideAnimationCurve; base.value.outsideEnemySpawnChanceThroughDay = outsideAnimationCurve; base.value.daytimeEnemySpawnChanceThroughDay = daytimeAnimationCurve; _weedEnemySpawnChanceThroughDay = weedAnimationCurve; return this; } public MoonInfoBuilder OverrideEnemySpawnRanges(float insideSpawnRange, float outsideSpawnRange, float daytimeSpawnRange, float weedSpawnRange) { base.value.spawnProbabilityRange = insideSpawnRange; _outsideEnemiesProbabilityRange = outsideSpawnRange; base.value.daytimeEnemiesProbabilityRange = daytimeSpawnRange; _weedEnemiesProbabilityRange = weedSpawnRange; return this; } public MoonInfoBuilder OverrideDiversityPowerCounts(int insideDiversityPowerCount, int outsideDiversityPowerCount, int daytimeDiversityPowerCount, int weedDiversityPowerCount) { base.value.maxInsideDiversityPowerCount = insideDiversityPowerCount; base.value.maxOutsideDiversityPowerCount = outsideDiversityPowerCount; _maxDaytimeDiversityPowerCount = daytimeDiversityPowerCount; _maxWeedDiversityPowerCount = weedDiversityPowerCount; return this; } public MoonInfoBuilder SetWeedEnemies(List weedEnemies) { _weedEnemies = weedEnemies; return this; } public MoonInfoBuilder OverrideCost(IProvider cost) { _costOverride = cost; return this; } public MoonInfoBuilder SetPurchasePredicate(ITerminalPurchasePredicate predicate) { _purchasePredicate = predicate; return this; } internal override DawnMoonInfo Build() { if ((Object)(object)_routeNode == (Object)null) { _routeNode = new TerminalNodeBuilder(base.value.PlanetName + "RouteNode").SetDisplayText("The cost to route to " + base.value.PlanetName + " is [totalCost]. It is \ncurrently [currentPlanetTime] on this moon.\n\nPlease CONFIRM or DENY.\n\n").SetClearPreviousText(clearPreviousText: true).SetOverrideOptions(overrideOptions: true) .SetBuyRerouteToMoon(-2) .SetMaxCharactersToType(25) .Build(); } if ((Object)(object)_receiptNode == (Object)null) { _receiptNode = new TerminalNodeBuilder(base.value.PlanetName + "RecieptNode").SetDisplayText("Routing autopilot to " + base.value.PlanetName + ".\nYour new balance is [playerCredits].\n\nPlease enjoy your flight.\n\n").SetClearPreviousText(clearPreviousText: true).SetMaxCharactersToType(25) .Build(); } if ((Object)(object)_nameKeyword == (Object)null) { CreateNameKeyword(StripSpecialCharacters(base.value.PlanetName).ToLowerInvariant()); } if (_scenes.Count == 0) { DawnPlugin.Logger.LogError((object)$"Moon: '{base.key}' has 0 scenes."); } if (_purchasePredicate == null) { _purchasePredicate = ITerminalPurchasePredicate.AlwaysSuccess(); } if (_costOverride == null) { _costOverride = new SimpleProvider(_routeNode.itemCost); } return new DawnMoonInfo(base.key, tags, base.value, _outsideEnemiesProbabilityRange, _maxDaytimeDiversityPowerCount, _maxWeedEnemyPowerCount, _maxWeedDiversityPowerCount, _weedEnemies, _weedEnemySpawnChanceThroughDay, _weedEnemiesProbabilityRange, _scenes, _routeNode, _receiptNode, _nameKeyword, new DawnPurchaseInfo(_costOverride, _purchasePredicate), customData); } } public interface IMoonSceneInfo : INamespaced, INamespaced { string SceneName { get; } DawnWeightedValue Rarity { get; } int GetRarity(DawnWeatherEffectInfo? weatherEffectInfo = null) { return Rarity.GetValue(new WeightQuery { Subject = this, Weather = weatherEffectInfo, Channel = DawnWeightChannels.ScrapRarity.Key }); } } public class VanillaMoonSceneInfo : IMoonSceneInfo, INamespaced, INamespaced { public string SceneName { get; private set; } public DawnWeightedValue Rarity { get; private set; } = new DawnWeightedValue(DawnWeightChannels.MoonSceneRarity, WeightProfile.Create(DawnWeightChannels.MoonSceneRarity.Policy, delegate(WeightProfile weightProfile) { weightProfile.AddSource(new GlobalBaseIntSource(() => 100)); })); public NamespacedKey Key => TypedKey; public NamespacedKey TypedKey { get; } internal VanillaMoonSceneInfo(NamespacedKey key, string sceneName) { SceneName = sceneName; TypedKey = key; } } public class CustomMoonSceneInfo : IMoonSceneInfo, INamespaced, INamespaced { internal string AssetBundlePath; public string SceneName { get; } public string ScenePath { get; } public DawnWeightedValue Rarity { get; private set; } public AnimationClip? ShipLandingOverrideAnimation { get; private set; } public AnimationClip? ShipTakeoffOverrideAnimation { get; private set; } public NamespacedKey Key => TypedKey; public NamespacedKey TypedKey { get; } internal CustomMoonSceneInfo(NamespacedKey key, AnimationClip? shipLandingOverrideAnimation, AnimationClip? shipTakeoffOverrideAnimation, DawnWeightedValue weight, string assetBundlePath, string scenePath) { AssetBundlePath = assetBundlePath; Rarity = weight; TypedKey = key; ShipLandingOverrideAnimation = shipLandingOverrideAnimation; ShipTakeoffOverrideAnimation = shipTakeoffOverrideAnimation; ScenePath = scenePath; SceneName = DawnNetworkSceneManager.GetSceneNameFromPath(scenePath); DawnLib.RegisterNetworkScene(scenePath); } } public static class RoundManagerExtensions { [SpecialName] public sealed class $32C06E8A3BA7BD5A7888B387479C3848 { [SpecialName] public static class $328ECF8D5DA4384C9E3E0BD0A407FB97 { } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] public int CurrentDaytimeEnemyDiversityLevel { [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] get { throw new NotSupportedException(); } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] set { throw new NotSupportedException(); } } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] public int CurrentMaxDaytimeDiversityLevel { [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] get { throw new NotSupportedException(); } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] set { throw new NotSupportedException(); } } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] public float CurrentMaxDaytimePower { [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] get { throw new NotSupportedException(); } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] set { throw new NotSupportedException(); } } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] public int CurrentWeedEnemyDiversityLevel { [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] get { throw new NotSupportedException(); } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] set { throw new NotSupportedException(); } } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] public int CurrentMaxWeedDiversityLevel { [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] get { throw new NotSupportedException(); } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] set { throw new NotSupportedException(); } } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] public float CurrentMaxWeedPower { [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] get { throw new NotSupportedException(); } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] set { throw new NotSupportedException(); } } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] private int GetCurrentDaytimeDiversityCore() { throw new NotSupportedException(); } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] private void SetCurrentDaytimeDiversityCore(int value) { throw new NotSupportedException(); } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] private int GetCurrentMaxDaytimeDiversityCore() { throw new NotSupportedException(); } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] private void SetCurrentMaxDaytimeDiversityCore(int value) { throw new NotSupportedException(); } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] private float GetCurrentMaxDaytimePowerCore() { throw new NotSupportedException(); } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] private void SetCurrentMaxDaytimePowerCore(float value) { throw new NotSupportedException(); } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] private int GetCurrentWeedDiversityCore() { throw new NotSupportedException(); } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] private void SetCurrentWeedDiversityCore(int value) { throw new NotSupportedException(); } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] private int GetCurrentMaxWeedDiversityCore() { throw new NotSupportedException(); } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] private void SetCurrentMaxWeedDiversityCore(int value) { throw new NotSupportedException(); } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] private float GetCurrentMaxWeedPowerCore() { throw new NotSupportedException(); } [ExtensionMarker("$328ECF8D5DA4384C9E3E0BD0A407FB97")] private void SetCurrentMaxWeedPowerCore(float value) { throw new NotSupportedException(); } } public static int get_CurrentDaytimeEnemyDiversityLevel(RoundManager roundManager) { return roundManager.GetCurrentDaytimeDiversityCore(); } public static void set_CurrentDaytimeEnemyDiversityLevel(RoundManager roundManager, int value) { roundManager.SetCurrentDaytimeDiversityCore(value); } private static int GetCurrentDaytimeDiversityCore(this RoundManager roundManager) { return ((IRoundManagerInjects)roundManager).CurrentDaytimeDiversity; } private static void SetCurrentDaytimeDiversityCore(this RoundManager roundManager, int value) { ((IRoundManagerInjects)roundManager).CurrentDaytimeDiversity = value; } public static int get_CurrentMaxDaytimeDiversityLevel(RoundManager roundManager) { return roundManager.GetCurrentMaxDaytimeDiversityCore(); } public static void set_CurrentMaxDaytimeDiversityLevel(RoundManager roundManager, int value) { roundManager.SetCurrentMaxDaytimeDiversityCore(value); } private static int GetCurrentMaxDaytimeDiversityCore(this RoundManager roundManager) { return ((IRoundManagerInjects)roundManager).CurrentDaytimeMaxDiversity; } private static void SetCurrentMaxDaytimeDiversityCore(this RoundManager roundManager, int value) { ((IRoundManagerInjects)roundManager).CurrentDaytimeMaxDiversity = value; } public static float get_CurrentMaxDaytimePower(RoundManager roundManager) { return roundManager.GetCurrentMaxDaytimePowerCore(); } public static void set_CurrentMaxDaytimePower(RoundManager roundManager, float value) { roundManager.SetCurrentMaxDaytimePowerCore(value); } private static float GetCurrentMaxDaytimePowerCore(this RoundManager roundManager) { return ((IRoundManagerInjects)roundManager).CurrentDaytimeMaxPower; } private static void SetCurrentMaxDaytimePowerCore(this RoundManager roundManager, float value) { ((IRoundManagerInjects)roundManager).CurrentDaytimeMaxPower = value; } public static int get_CurrentWeedEnemyDiversityLevel(RoundManager roundManager) { return roundManager.GetCurrentWeedDiversityCore(); } public static void set_CurrentWeedEnemyDiversityLevel(RoundManager roundManager, int value) { roundManager.SetCurrentWeedDiversityCore(value); } private static int GetCurrentWeedDiversityCore(this RoundManager roundManager) { return ((IRoundManagerInjects)roundManager).CurrentWeedDiversity; } private static void SetCurrentWeedDiversityCore(this RoundManager roundManager, int value) { ((IRoundManagerInjects)roundManager).CurrentWeedDiversity = value; } public static int get_CurrentMaxWeedDiversityLevel(RoundManager roundManager) { return roundManager.GetCurrentMaxWeedDiversityCore(); } public static void set_CurrentMaxWeedDiversityLevel(RoundManager roundManager, int value) { roundManager.SetCurrentMaxWeedDiversityCore(value); } private static int GetCurrentMaxWeedDiversityCore(this RoundManager roundManager) { return ((IRoundManagerInjects)roundManager).CurrentWeedMaxDiversity; } private static void SetCurrentMaxWeedDiversityCore(this RoundManager roundManager, int value) { ((IRoundManagerInjects)roundManager).CurrentWeedMaxDiversity = value; } public static float get_CurrentMaxWeedPower(RoundManager roundManager) { return roundManager.GetCurrentMaxWeedPowerCore(); } public static void set_CurrentMaxWeedPower(RoundManager roundManager, float value) { roundManager.SetCurrentMaxWeedPowerCore(value); } private static float GetCurrentMaxWeedPowerCore(this RoundManager roundManager) { return ((IRoundManagerInjects)roundManager).CurrentWeedMaxPower; } private static void SetCurrentMaxWeedPowerCore(this RoundManager roundManager, float value) { ((IRoundManagerInjects)roundManager).CurrentWeedMaxPower = value; } } public static class SelectableLevelExtensions { [SpecialName] public sealed class $372FCAFD85B1D00EA5340A4887D0870B { [SpecialName] public static class $1773A1B5815907352EB891526A92562C { } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] public DawnMoonInfo DawnInfo { [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] get { throw new NotSupportedException(); } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] set { throw new NotSupportedException(); } } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] public float OutsideEnemiesProbabilityRange { [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] get { throw new NotSupportedException(); } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] set { throw new NotSupportedException(); } } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] public int MaxDaytimeDiversityPowerCount { [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] get { throw new NotSupportedException(); } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] set { throw new NotSupportedException(); } } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] public int MaxWeedEnemyPowerCount { [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] get { throw new NotSupportedException(); } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] set { throw new NotSupportedException(); } } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] public int MaxWeedDiversityPowerCount { [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] get { throw new NotSupportedException(); } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] set { throw new NotSupportedException(); } } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] public List WeedEnemies { [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] get { throw new NotSupportedException(); } } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] public AnimationCurve WeedEnemySpawnChanceThroughDay { [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] get { throw new NotSupportedException(); } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] set { throw new NotSupportedException(); } } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] public float WeedEnemiesProbabilityRange { [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] get { throw new NotSupportedException(); } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] set { throw new NotSupportedException(); } } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] [Obsolete("Use SelectableLevel.DawnInfo instead")] public DawnMoonInfo GetDawnInfo() { throw new NotSupportedException(); } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] [Obsolete("Use SelectableLevel.DawnInfo instead")] public void SetDawnInfo(DawnMoonInfo selectableLevelInfo) { throw new NotSupportedException(); } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] [Obsolete] public bool HasDawnInfo() { throw new NotSupportedException(); } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] private DawnMoonInfo GetDawnInfoCore() { throw new NotSupportedException(); } [ExtensionMarker("$1773A1B5815907352EB891526A92562C")] private void SetDawnInfoCore(DawnMoonInfo selectableLevelInfo) { throw new NotSupportedException(); } } public static DawnMoonInfo get_DawnInfo(SelectableLevel selectableLevel) { return selectableLevel.GetDawnInfoCore(); } public static void set_DawnInfo(SelectableLevel selectableLevel, DawnMoonInfo value) { selectableLevel.SetDawnInfoCore(value); } public static float get_OutsideEnemiesProbabilityRange(SelectableLevel selectableLevel) { return get_DawnInfo(selectableLevel).OutsideEnemiesProbabilityRange; } public static void set_OutsideEnemiesProbabilityRange(SelectableLevel selectableLevel, float value) { get_DawnInfo(selectableLevel).OutsideEnemiesProbabilityRange = value; } public static int get_MaxDaytimeDiversityPowerCount(SelectableLevel selectableLevel) { return get_DawnInfo(selectableLevel).MaxDaytimeDiversityPowerCount; } public static void set_MaxDaytimeDiversityPowerCount(SelectableLevel selectableLevel, int value) { get_DawnInfo(selectableLevel).MaxDaytimeDiversityPowerCount = value; } public static int get_MaxWeedEnemyPowerCount(SelectableLevel selectableLevel) { return get_DawnInfo(selectableLevel).MaxWeedEnemyPowerCount; } public static void set_MaxWeedEnemyPowerCount(SelectableLevel selectableLevel, int value) { get_DawnInfo(selectableLevel).MaxWeedEnemyPowerCount = value; } public static int get_MaxWeedDiversityPowerCount(SelectableLevel selectableLevel) { return get_DawnInfo(selectableLevel).MaxWeedDiversityPowerCount; } public static void set_MaxWeedDiversityPowerCount(SelectableLevel selectableLevel, int value) { get_DawnInfo(selectableLevel).MaxWeedDiversityPowerCount = value; } public static List get_WeedEnemies(SelectableLevel selectableLevel) { return get_DawnInfo(selectableLevel).WeedEnemies; } public static AnimationCurve get_WeedEnemySpawnChanceThroughDay(SelectableLevel selectableLevel) { return get_DawnInfo(selectableLevel).WeedEnemySpawnChanceThroughDay; } public static void set_WeedEnemySpawnChanceThroughDay(SelectableLevel selectableLevel, AnimationCurve value) { get_DawnInfo(selectableLevel).WeedEnemySpawnChanceThroughDay = value; } public static float get_WeedEnemiesProbabilityRange(SelectableLevel selectableLevel) { return get_DawnInfo(selectableLevel).WeedEnemiesProbabilityRange; } public static void set_WeedEnemiesProbabilityRange(SelectableLevel selectableLevel, float value) { get_DawnInfo(selectableLevel).WeedEnemiesProbabilityRange = value; } [Obsolete("Use SelectableLevel.DawnInfo instead")] public static DawnMoonInfo GetDawnInfo(this SelectableLevel selectableLevel) { return selectableLevel.GetDawnInfoCore(); } [Obsolete("Use SelectableLevel.DawnInfo instead")] public static void SetDawnInfo(this SelectableLevel selectableLevel, DawnMoonInfo selectableLevelInfo) { selectableLevel.SetDawnInfoCore(selectableLevelInfo); } [Obsolete] public static bool HasDawnInfo(this SelectableLevel selectableLevel) { return get_DawnInfo(selectableLevel) != null; } private static DawnMoonInfo GetDawnInfoCore(this SelectableLevel selectableLevel) { return ((ISelectableLevelDawnObject)selectableLevel).DawnInfo; } private static void SetDawnInfoCore(this SelectableLevel selectableLevel, DawnMoonInfo selectableLevelInfo) { ((ISelectableLevelDawnObject)selectableLevel).DawnInfo = selectableLevelInfo; } } [InjectInterface(typeof(Terminal))] public interface ITerminal { string DawnLastCommand { get; set; } TerminalKeyword DawnLastNoun { get; set; } TerminalKeyword DawnLastVerb { get; set; } } [InjectInterface(typeof(TerminalKeyword))] public interface ITerminalKeyword { public enum DawnKeywordType { Unset, Core, TerminalObject, Moons, Vehicles, Store, Bestiary, SigurdLog, TerminalEvent, DawnCommand, Other } DawnKeywordType DawnKeywordPriority { get; set; } bool DawnAcceptAdditionalText { get; set; } string DawnKeywordDescription { get; set; } string DawnKeywordCategory { get; set; } } [InjectInterface(typeof(TerminalNode))] public interface ITerminalNode { Func DynamicDisplayText { get; set; } } public class RegistryFrozenException : Exception { public RegistryFrozenException() : base("Registry is frozen") { } } public class Registry : IReadOnlyDictionary, T>, IEnumerable, T>>, IEnumerable, IReadOnlyCollection, T>> where T : INamespaced { protected readonly Dictionary, T> _dictionary = new Dictionary, T>(); public bool IsFrozen { get; private set; } public int Count => _dictionary.Count; public T this[NamespacedKey key] => _dictionary[key]; public IEnumerable> Keys => _dictionary.Keys; public IEnumerable Values => _dictionary.Values; [Obsolete("Use BeforeFreezeWithContext instead")] public event Action BeforeFreeze { add { BeforeFreezeWithContext += delegate { value(); }; } remove { DawnPlugin.Logger.LogError((object)"Registry.BeforeFreeze -= is not supported."); } } public event Action> BeforeFreezeWithContext { add { _beforeFreezeWithContext += delegate(NamespacedKeyResolver resolver) { try { value(resolver); } catch (Exception arg) { DawnPlugin.Logger.LogError((object)$"(BeforeFreezeWithContext) An exception occured in firing an event for a registry:\n{arg}"); } }; } remove { DawnPlugin.Logger.LogError((object)"Registry.BeforeFreezeWithContext -= is not supported."); } } [Obsolete("Use OnFreezeWithContext instead")] public event Action OnFreeze { add { OnFreezeWithContext += delegate { value(); }; } remove { DawnPlugin.Logger.LogError((object)"Registry.OnFreeze -= is not supported."); } } public event Action> OnFreezeWithContext { add { _onFreezeWithContext += delegate(NamespacedKeyResolver resolver) { try { value(resolver); } catch (Exception arg) { DawnPlugin.Logger.LogError((object)$"(OnFreezeWithContext) An exception occured in firing an event for a registry:\n{arg}"); } }; } remove { DawnPlugin.Logger.LogError((object)"Registry.OnFreezeWithContext -= is not supported."); } } private event Action> _onFreezeWithContext = delegate { }; private event Action> _beforeFreezeWithContext = delegate { }; internal virtual void Freeze() { if (IsFrozen) { throw new RegistryFrozenException(); } using (NamespacedKeyResolver obj = new NamespacedKeyResolver(Values)) { this._beforeFreezeWithContext(obj); } IsFrozen = true; foreach (T value in Values) { if (value is IRegistryEvents registryEvents) { registryEvents.OnFrozen(); } } using NamespacedKeyResolver obj2 = new NamespacedKeyResolver(Values); this._onFreezeWithContext(obj2); } internal virtual void Register(T value) { if (IsFrozen) { throw new RegistryFrozenException(); } NamespacedKey typedKey = value.TypedKey; if (ContainsKey(typedKey)) { throw new ArgumentException($"'{typedKey}' has already been added to this registry."); } _dictionary[typedKey] = value; } public IEnumerator, T>> GetEnumerator() { return _dictionary.GetEnumerator(); } IEnumerator IEnumerable.GetEnumerator() { return GetEnumerator(); } public bool ContainsKey(NamespacedKey key) { return _dictionary.ContainsKey(key); } public bool TryGetValue(NamespacedKey key, out T value) { return _dictionary.TryGetValue(key, out value); } public bool TryGetValue(NamespacedKey key, out T value) { return TryGetValue(key.AsTyped(), out value); } } public interface IRegistryEvents { void OnFrozen(); } internal static class RoundLoadingStepRegistrationHandler { private enum VisitState { Visiting, Visited } [CompilerGenerated] private static class <>O { public static Manipulator <0>__StartInjectInteriorLoadingStep; public static Manipulator <1>__FinishInjectInteriorLoadingStep; public static Manipulator <2>__StartInjectSceneLoadingStep; public static Manipulator <3>__FinishInjectSceneLoadingStep; public static Manipulator <4>__WaitUntilScrapAndMapObjectsSpawn; public static Manipulator <5>__RemoveSpawnMapObjectsCall; public static hook_SpawnScrapInLevel <6>__StartInjectScrapLoadingStep; public static hook_SpawnMapObjects <7>__StartInjectMapObjectsLoadingStep; public static Func <8>__WaitAfterScrapAndMapObjectSpawn; public static Action <9>__HandleSceneLoadingStep; public static Action <10>__FinishSceneLoadingStep; public static Action <11>__HandleInteriorLoadingStep; public static Action <12>__FinishInteriorLoadingStep; public static Func <13>__InteriorLoading; public static Func <14>__CurrentLevelSceneLoading; public static Func <15>__ScrapLoading; public static Func <16>__InsideMapObjectLoading; } internal static List orderedRoundLoadingSteps = new List(); private static bool _dungeonCompletionInProgress = true; private static bool _sceneLoadingInProgress = true; internal static bool scrapAndMapObjectsSpawned = false; private static readonly int IsLoadingHash = Animator.StringToHash("IsLoading"); private static TaskCompletionSource _playerLoadedIntoScene = new TaskCompletionSource(); internal static void Init() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_00a9: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Expected O, but got Unknown //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown //IL_0139: 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_0144: Expected O, but got Unknown //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Expected O, but got Unknown RegisterVanillaRoundLoadingSteps(); LethalContent.Moons.OnFreezeWithContext += delegate { SortRoundLoadingSteps(); }; object obj = <>O.<0>__StartInjectInteriorLoadingStep; if (obj == null) { Manipulator val = StartInjectInteriorLoadingStep; <>O.<0>__StartInjectInteriorLoadingStep = val; obj = (object)val; } RoundManager.GenerateNewLevelClientRpc += (Manipulator)obj; object obj2 = <>O.<1>__FinishInjectInteriorLoadingStep; if (obj2 == null) { Manipulator val2 = FinishInjectInteriorLoadingStep; <>O.<1>__FinishInjectInteriorLoadingStep = val2; obj2 = (object)val2; } RoundManager.FinishGeneratingNewLevelClientRpc += (Manipulator)obj2; object obj3 = <>O.<2>__StartInjectSceneLoadingStep; if (obj3 == null) { Manipulator val3 = StartInjectSceneLoadingStep; <>O.<2>__StartInjectSceneLoadingStep = val3; obj3 = (object)val3; } StartOfRound.SceneManager_OnLoad += (Manipulator)obj3; object obj4 = <>O.<3>__FinishInjectSceneLoadingStep; if (obj4 == null) { Manipulator val4 = FinishInjectSceneLoadingStep; <>O.<3>__FinishInjectSceneLoadingStep = val4; obj4 = (object)val4; } StartOfRound.SceneManager_OnLoadComplete1 += (Manipulator)obj4; MethodInfo methodInfo = AccessTools.Method(typeof(RoundManager), "LoadNewLevelWait", new Type[1] { typeof(int) }, (Type[])null); MethodInfo methodInfo2 = AccessTools.EnumeratorMoveNext((MethodBase)methodInfo); List iLHooks = DawnPlugin.ILHooks; object obj5 = <>O.<4>__WaitUntilScrapAndMapObjectsSpawn; if (obj5 == null) { Manipulator val5 = WaitUntilScrapAndMapObjectsSpawn; <>O.<4>__WaitUntilScrapAndMapObjectsSpawn = val5; obj5 = (object)val5; } iLHooks.Add(new ILHook((MethodBase)methodInfo2, (Manipulator)obj5)); object obj6 = <>O.<5>__RemoveSpawnMapObjectsCall; if (obj6 == null) { Manipulator val6 = RemoveSpawnMapObjectsCall; <>O.<5>__RemoveSpawnMapObjectsCall = val6; obj6 = (object)val6; } RoundManager.GeneratedFloorPostProcessing += (Manipulator)obj6; object obj7 = <>O.<6>__StartInjectScrapLoadingStep; if (obj7 == null) { hook_SpawnScrapInLevel val7 = StartInjectScrapLoadingStep; <>O.<6>__StartInjectScrapLoadingStep = val7; obj7 = (object)val7; } RoundManager.SpawnScrapInLevel += (hook_SpawnScrapInLevel)obj7; object obj8 = <>O.<7>__StartInjectMapObjectsLoadingStep; if (obj8 == null) { hook_SpawnMapObjects val8 = StartInjectMapObjectsLoadingStep; <>O.<7>__StartInjectMapObjectsLoadingStep = val8; obj8 = (object)val8; } RoundManager.SpawnMapObjects += (hook_SpawnMapObjects)obj8; } private static void StartInjectScrapLoadingStep(orig_SpawnScrapInLevel orig, RoundManager self) { NetworkSingleton.Instance?.StartScrapLoadingRpc(); orig.Invoke(self); NetworkSingleton.Instance?.FinishScrapLoadingRpc(); } private static void StartInjectMapObjectsLoadingStep(orig_SpawnMapObjects orig, RoundManager self) { NetworkSingleton.Instance?.StartInsideMapObjectsLoadingRpc(); orig.Invoke(self); NetworkSingleton.Instance?.FinishInsideMapObjectsLoadingRpc(); } private static void RemoveSpawnMapObjectsCall(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); val.EmitDelegate((Action)delegate { scrapAndMapObjectsSpawned = false; }); if (!val.TryGotoNext((MoveType)0, new Func[2] { (Instruction val2) => ILPatternMatchingExt.MatchLdarg(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchCall(val2, "SpawnMapObjects") })) { DawnPlugin.Logger.LogError((object)"Couldn't match RoundManager.GeneratedFloorPostProcessing (1) IL."); } else { val.RemoveRange(2); } } private static void WaitUntilScrapAndMapObjectsSpawn(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); ILLabel val3 = default(ILLabel); if (!val.TryGotoNext((MoveType)2, new Func[5] { (Instruction val2) => ILPatternMatchingExt.MatchBrfalse(val2, ref val3), (Instruction val2) => ILPatternMatchingExt.MatchLdloc(val2, 1), (Instruction val2) => ILPatternMatchingExt.MatchCall(val2, "GeneratedFloorPostProcessing"), (Instruction val2) => ILPatternMatchingExt.MatchLdarg(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchLdnull(val2) })) { DawnPlugin.Logger.LogError((object)"Couldn't match RoundManager.LoadNewLevelWait (1) IL."); return; } int index = val.Index; val.Index = index - 1; val.Remove(); val.EmitDelegate>((Func)WaitAfterScrapAndMapObjectSpawn); } private static IEnumerator WaitAfterScrapAndMapObjectSpawn() { yield return (object)new WaitUntil((Func)(() => scrapAndMapObjectsSpawned)); yield return null; } private static void StartInjectSceneLoadingStep(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (!val.TryGotoNext((MoveType)0, new Func[8] { (Instruction val2) => ILPatternMatchingExt.MatchCall(val2, "get_Instance"), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "loadingText"), (Instruction val2) => ILPatternMatchingExt.MatchLdcI4(val2, 1), (Instruction val2) => ILPatternMatchingExt.MatchCallvirt(val2, "set_enabled"), (Instruction val2) => ILPatternMatchingExt.MatchCall(val2, "get_Instance"), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "loadingText"), (Instruction val2) => ILPatternMatchingExt.MatchLdstr(val2, "LOADING WORLD..."), (Instruction val2) => ILPatternMatchingExt.MatchCallvirt(val2, "set_text") })) { DawnPlugin.Logger.LogError((object)"Couldn't match StartOfRound.SceneManager_OnLoad (1) IL."); return; } int index = val.Index; val.Index = index + 1; val.RemoveRange(7); val.EmitDelegate>((Action)HandleSceneLoadingStep); } private static void FinishInjectSceneLoadingStep(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a9: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel val4 = default(ILLabel); if (!val.TryGotoNext((MoveType)2, new Func[16] { (Instruction val3) => ILPatternMatchingExt.MatchLdarg(val3, 0), (Instruction val3) => ILPatternMatchingExt.MatchLdfld(val3, "shipDoorsEnabled"), (Instruction val3) => ILPatternMatchingExt.MatchBrtrue(val3, ref val4), (Instruction val3) => ILPatternMatchingExt.MatchCall(val3, "get_Instance"), (Instruction val3) => ILPatternMatchingExt.MatchLdfld(val3, "loadingText"), (Instruction val3) => ILPatternMatchingExt.MatchLdcI4(val3, 1), (Instruction val3) => ILPatternMatchingExt.MatchCallvirt(val3, "set_enabled"), (Instruction val3) => ILPatternMatchingExt.MatchCall(val3, "get_Instance"), (Instruction val3) => ILPatternMatchingExt.MatchLdfld(val3, "LoadingScreen"), (Instruction val3) => ILPatternMatchingExt.MatchLdstr(val3, "IsLoading"), (Instruction val3) => ILPatternMatchingExt.MatchLdcI4(val3, 1), (Instruction val3) => ILPatternMatchingExt.MatchCallvirt(val3, "SetBool"), (Instruction val3) => ILPatternMatchingExt.MatchCall(val3, "get_Instance"), (Instruction val3) => ILPatternMatchingExt.MatchLdfld(val3, "loadingText"), (Instruction val3) => ILPatternMatchingExt.MatchLdstr(val3, "Waiting for crew..."), (Instruction val3) => ILPatternMatchingExt.MatchCallvirt(val3, "set_text") })) { DawnPlugin.Logger.LogError((object)"Couldn't match StartOfRound.SceneManager_OnLoadComplete1 (1) IL."); return; } FieldInfo fieldInfo = AccessTools.Field(typeof(RoundLoadingStepRegistrationHandler), "_sceneLoadingInProgress"); ILLabel val2 = val.DefineLabel(); val.Emit(OpCodes.Ldsfld, fieldInfo); val.Emit(OpCodes.Brfalse_S, (object)val2); val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldarg_1); val.Emit(OpCodes.Ldarg_2); val.Emit(OpCodes.Ldarg_3); val.EmitDelegate>((Action)FinishSceneLoadingStep); val.Emit(OpCodes.Ret); val.MarkLabel(val2); } private static void HandleSceneLoadingStep(HUDManager hudManager) { DawnRoundLoadingStepInfo dawnRoundLoadingStepInfo = LethalContent.RoundLoadingSteps[RoundLoadingStepKeys.CurrentLevelSceneLoading]; dawnRoundLoadingStepInfo.Callback(new EnteringAtmosphereLoadingContext()); _sceneLoadingInProgress = true; hudManager.LoadingScreen.SetBool(IsLoadingHash, true); ((Behaviour)hudManager.loadingText).enabled = true; } private static async void FinishSceneLoadingStep(StartOfRound startOfRound, ulong clientId, string sceneName, LoadSceneMode loadSceneMode) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) startOfRound.ClientPlayerList.TryGetValue(clientId, out var value); if (value != 0 && ((NetworkBehaviour)startOfRound).IsServer) { return; } _playerLoadedIntoScene.SetResult(null); DawnRoundLoadingStepInfo dawnRoundLoadingStepInfo = LethalContent.RoundLoadingSteps[RoundLoadingStepKeys.CurrentLevelSceneLoading]; List orderedDependants = dawnRoundLoadingStepInfo.GetOrderedDependants(); foreach (DawnRoundLoadingStepInfo item in orderedDependants) { await item.Callback(new EnteringAtmosphereLoadingContext()); } _sceneLoadingInProgress = false; startOfRound.SceneManager_OnLoadComplete1(clientId, sceneName, loadSceneMode); } private static void StartInjectInteriorLoadingStep(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown ILCursor val = new ILCursor(il); if (!val.TryGotoNext((MoveType)0, new Func[12] { (Instruction val2) => ILPatternMatchingExt.MatchCall(val2, "get_Instance"), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "loadingText"), (Instruction val2) => ILPatternMatchingExt.MatchLdstr(val2, "Random seed: {0}"), (Instruction val2) => ILPatternMatchingExt.MatchLdarg(val2, 1), (Instruction val2) => ILPatternMatchingExt.MatchBox(val2, typeof(int)), (Instruction val2) => ILPatternMatchingExt.MatchCall(val2, "Format"), (Instruction val2) => ILPatternMatchingExt.MatchCallvirt(val2, "set_text"), (Instruction val2) => ILPatternMatchingExt.MatchCall(val2, "get_Instance"), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "LoadingScreen"), (Instruction val2) => ILPatternMatchingExt.MatchLdstr(val2, "IsLoading"), (Instruction val2) => ILPatternMatchingExt.MatchLdcI4(val2, 1), (Instruction val2) => ILPatternMatchingExt.MatchCallvirt(val2, "SetBool") })) { DawnPlugin.Logger.LogError((object)"Couldn't match RoundManager.GenerateNewLevelClientRpc (1) IL."); return; } int index = val.Index; val.Index = index + 1; val.RemoveRange(11); val.EmitDelegate>((Action)HandleInteriorLoadingStep); } private static void FinishInjectInteriorLoadingStep(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (!val.TryGotoNext((MoveType)0, new Func[9] { (Instruction val3) => ILPatternMatchingExt.MatchCall(val3, "get_Instance"), (Instruction val3) => ILPatternMatchingExt.MatchLdfld(val3, "loadingText"), (Instruction val3) => ILPatternMatchingExt.MatchLdcI4(val3, 0), (Instruction val3) => ILPatternMatchingExt.MatchCallvirt(val3, "set_enabled"), (Instruction val3) => ILPatternMatchingExt.MatchCall(val3, "get_Instance"), (Instruction val3) => ILPatternMatchingExt.MatchLdfld(val3, "LoadingScreen"), (Instruction val3) => ILPatternMatchingExt.MatchLdstr(val3, "IsLoading"), (Instruction val3) => ILPatternMatchingExt.MatchLdcI4(val3, 0), (Instruction val3) => ILPatternMatchingExt.MatchCallvirt(val3, "SetBool") })) { DawnPlugin.Logger.LogError((object)"Couldn't match RoundManager.FinishGeneratingNewLevelClientRpc (1) IL."); return; } FieldInfo fieldInfo = AccessTools.Field(typeof(RoundLoadingStepRegistrationHandler), "_dungeonCompletionInProgress"); ILLabel val2 = val.DefineLabel(); val.Emit(OpCodes.Ldsfld, fieldInfo); val.Emit(OpCodes.Brfalse_S, (object)val2); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate>((Action)FinishInteriorLoadingStep); val.Emit(OpCodes.Ret); val.MarkLabel(val2); } private static void HandleInteriorLoadingStep(HUDManager hudManager) { DawnRoundLoadingStepInfo dawnRoundLoadingStepInfo = LethalContent.RoundLoadingSteps[RoundLoadingStepKeys.InteriorLoading]; dawnRoundLoadingStepInfo.Callback(new EnteringAtmosphereLoadingContext()); _dungeonCompletionInProgress = true; hudManager.LoadingScreen.SetBool(IsLoadingHash, true); } private static async void FinishInteriorLoadingStep(RoundManager roundManager) { DawnRoundLoadingStepInfo dawnRoundLoadingStepInfo = LethalContent.RoundLoadingSteps[RoundLoadingStepKeys.InteriorLoading]; List orderedDependants = dawnRoundLoadingStepInfo.GetOrderedDependants(); foreach (DawnRoundLoadingStepInfo item in orderedDependants) { await item.Callback(new EnteringAtmosphereLoadingContext()); } _dungeonCompletionInProgress = false; roundManager.FinishGeneratingNewLevelClientRpc(); } private static void RegisterVanillaRoundLoadingSteps() { DawnLib.DefineRoundLoadingStep(RoundLoadingStepKeys.InteriorLoading, InteriorLoading, delegate { }); DawnLib.DefineRoundLoadingStep(RoundLoadingStepKeys.CurrentLevelSceneLoading, CurrentLevelSceneLoading, delegate { }); DawnLib.DefineRoundLoadingStep(RoundLoadingStepKeys.ScrapLoading, ScrapLoading, delegate { }); DawnLib.DefineRoundLoadingStep(RoundLoadingStepKeys.InsideMapObjectLoading, InsideMapObjectLoading, delegate { }); } private static async Task InsideMapObjectLoading(ILoadingContext context) { } private static async Task ScrapLoading(ILoadingContext context) { } private static async Task CurrentLevelSceneLoading(ILoadingContext context) { Color mainTextStartColor = default(Color); ColorUtility.TryParseHtmlString("#3D4A5B", ref mainTextStartColor); Color mainTextEndColor = default(Color); ColorUtility.TryParseHtmlString("#7DB5BE", ref mainTextEndColor); Color secondaryTextColor = default(Color); ColorUtility.TryParseHtmlString("#465A6F8D", ref secondaryTextColor); Color backgroundColor = default(Color); ColorUtility.TryParseHtmlString("#0F171F9F", ref backgroundColor); context.SetMainText("ENTERING THE ATMOSPHERE..."); context.SetMainTextColor(mainTextStartColor, mainTextEndColor); context.SetSecondaryText("LOADING WORLD..."); context.SetSecondaryTextColor(secondaryTextColor); context.SetBackgroundColor(backgroundColor); _playerLoadedIntoScene = new TaskCompletionSource(); await _playerLoadedIntoScene.Task; context.SetMainText("ENTERING THE ATMOSPHERE..."); context.SetMainTextColor(mainTextStartColor, mainTextEndColor); context.SetSecondaryText("Waiting for crew..."); context.SetSecondaryTextColor(secondaryTextColor); context.SetBackgroundColor(backgroundColor); } private static Task InteriorLoading(ILoadingContext context) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) Color startColor = default(Color); ColorUtility.TryParseHtmlString("#3D4A5B", ref startColor); Color endColor = default(Color); ColorUtility.TryParseHtmlString("#7DB5BE", ref endColor); Color secondaryTextColor = default(Color); ColorUtility.TryParseHtmlString("#465A6F8D", ref secondaryTextColor); Color backgroundColor = default(Color); ColorUtility.TryParseHtmlString("#0F171F9F", ref backgroundColor); context.SetMainText("ENTERING THE ATMOSPHERE..."); context.SetMainTextColor(startColor, endColor); context.SetSecondaryText($"Random seed: {StartOfRoundRefs.Instance.randomMapSeed}"); context.SetSecondaryTextColor(secondaryTextColor); context.SetBackgroundColor(backgroundColor); return Task.CompletedTask; } private static void SortRoundLoadingSteps() { Dictionary eligibleByKey = new Dictionary(); foreach (DawnRoundLoadingStepInfo value in LethalContent.RoundLoadingSteps.Values) { if (!eligibleByKey.TryAdd(value.Key, value)) { DawnPlugin.Logger.LogWarning((object)$"Duplicate round loading step key registered: {value.Key}"); } } bool flag; do { flag = false; DawnRoundLoadingStepInfo[] array = eligibleByKey.Values.ToArray(); foreach (DawnRoundLoadingStepInfo dawnRoundLoadingStepInfo in array) { NamespacedKey namespacedKey = dawnRoundLoadingStepInfo.HardDependencies.FirstOrDefault((NamespacedKey dependency) => !eligibleByKey.ContainsKey(dependency)); if (!(namespacedKey == null)) { DawnPlugin.Logger.LogError((object)$"Round loading step {dawnRoundLoadingStepInfo.Key} was removed because hard dependency {namespacedKey} is missing or unavailable."); eligibleByKey.Remove(dawnRoundLoadingStepInfo.Key); flag = true; } } } while (flag); orderedRoundLoadingSteps.Clear(); orderedRoundLoadingSteps.AddRange(SortSteps((IReadOnlyCollection)(object)eligibleByKey.Values.ToArray())); DawnPlugin.Logger.LogInfo((object)$"Finished sorting {orderedRoundLoadingSteps.Count} round loading steps."); foreach (DawnRoundLoadingStepInfo orderedRoundLoadingStep in orderedRoundLoadingSteps) { DawnPlugin.Logger.LogInfo((object)$"Round loading step registered: {orderedRoundLoadingStep.Key}"); } LethalContent.RoundLoadingSteps.Freeze(); } private static List SortSteps(IReadOnlyCollection entries) { Dictionary entriesByKey = entries.ToDictionary((DawnRoundLoadingStepInfo entry) => entry.Key); Dictionary remainingDependencies = new Dictionary(); Dictionary> dictionary = new Dictionary>(); foreach (DawnRoundLoadingStepInfo entry in entries) { remainingDependencies[entry] = 0; dictionary[entry] = new List(); } foreach (DawnRoundLoadingStepInfo entry2 in entries) { foreach (NamespacedKey item in entry2.HardDependencies.Concat(entry2.SoftDependencies)) { if (entriesByKey.TryGetValue(item, out DawnRoundLoadingStepInfo value)) { remainingDependencies[entry2]++; dictionary[value].Add(entry2); } } } Stack stack = new Stack(entries.Where((DawnRoundLoadingStepInfo entry) => remainingDependencies[entry] == 0).Reverse()); List list = new List(); DawnRoundLoadingStepInfo result; while (stack.TryPop(out result)) { list.Add(result); foreach (DawnRoundLoadingStepInfo item2 in dictionary[result].AsEnumerable().Reverse()) { remainingDependencies[item2]--; if (remainingDependencies[item2] == 0) { stack.Push(item2); } } } if (list.Count != entries.Count) { Dictionary> dictionary2 = new Dictionary>(); foreach (DawnRoundLoadingStepInfo entry3 in entries) { if (remainingDependencies[entry3] != 0) { dictionary2[entry3] = (from key in entry3.HardDependencies.Concat(entry3.SoftDependencies) select entriesByKey.GetValueOrDefault(key) into dependency where dependency != null && remainingDependencies[dependency] > 0 select dependency).ToHashSet(); } } LogCircularDependency(dictionary2); } return list; } private static void LogCircularDependency(Dictionary> stepToDependencies) { List list = FindDependencyCycle(stepToDependencies); if (list.Count == 0) { DawnPlugin.Logger.LogError((object)"Could not resolve exact circular dependency chain. Remaining unresolved steps:"); { foreach (KeyValuePair> stepToDependency in stepToDependencies) { stepToDependency.Deconstruct(out var key, out var value); DawnRoundLoadingStepInfo dawnRoundLoadingStepInfo = key; HashSet source = value; string arg = string.Join(", ", source.Select((DawnRoundLoadingStepInfo dependency) => dependency.Key)); DawnPlugin.Logger.LogError((object)$"- {dawnRoundLoadingStepInfo.Key} depends on: {arg}"); } return; } } DawnPlugin.Logger.LogError((object)"Circular dependency chain:"); for (int num = 0; num < list.Count - 1; num++) { DawnRoundLoadingStepInfo dawnRoundLoadingStepInfo2 = list[num]; DawnRoundLoadingStepInfo dawnRoundLoadingStepInfo3 = list[num + 1]; string dependencyType = GetDependencyType(dawnRoundLoadingStepInfo2, dawnRoundLoadingStepInfo3); DawnPlugin.Logger.LogError((object)$"- {dawnRoundLoadingStepInfo2.Key} {dependencyType} depends on {dawnRoundLoadingStepInfo3.Key}"); } } private static List FindDependencyCycle(Dictionary> stepToDependencies) { Dictionary dictionary = new Dictionary(); List stack = new List(); foreach (DawnRoundLoadingStepInfo key in stepToDependencies.Keys) { if (!dictionary.ContainsKey(key) && TryFindDependencyCycle(key, stepToDependencies, dictionary, stack, out List cycle)) { return cycle; } } return new List(); } private static bool TryFindDependencyCycle(DawnRoundLoadingStepInfo entry, Dictionary> stepToDependencies, Dictionary states, List stack, out List cycle) { states[entry] = VisitState.Visiting; stack.Add(entry); foreach (DawnRoundLoadingStepInfo item in stepToDependencies[entry]) { if (!stepToDependencies.ContainsKey(item)) { continue; } if (!states.TryGetValue(item, out var value)) { if (TryFindDependencyCycle(item, stepToDependencies, states, stack, out cycle)) { return true; } } else if (value == VisitState.Visiting) { int count = stack.IndexOf(item); cycle = stack.Skip(count).ToList(); cycle.Add(item); return true; } } stack.RemoveAt(stack.Count - 1); states[entry] = VisitState.Visited; cycle = new List(); return false; } private static string GetDependencyType(DawnRoundLoadingStepInfo entry, DawnRoundLoadingStepInfo dependency) { if (entry.HardDependencies.Contains(dependency.Key)) { return "hard"; } if (entry.SoftDependencies.Contains(dependency.Key)) { return "soft"; } return "unknown"; } } public sealed class DawnRoundLoadingStepInfo : DawnBaseInfo { public Func Callback { get; } public List HardDependencies { get; } public List SoftDependencies { get; } internal DawnRoundLoadingStepInfo(NamespacedKey key, HashSet tags, Func callback, List hardDependencies, List softDependencies, IDataContainer? customData) : base(key, tags, customData) { Callback = callback; HardDependencies = hardDependencies; SoftDependencies = softDependencies; } public List GetOrderedDependants() { List list = new List(); HashSet hashSet = new HashSet { base.Key }; foreach (DawnRoundLoadingStepInfo orderedRoundLoadingStep in RoundLoadingStepRegistrationHandler.orderedRoundLoadingSteps) { if (orderedRoundLoadingStep.HardDependencies.Concat(orderedRoundLoadingStep.SoftDependencies).Any(hashSet.Contains)) { list.Add(orderedRoundLoadingStep); hashSet.Add(orderedRoundLoadingStep.Key); } } return list; } } public class EnteringAtmosphereLoadingContext : ILoadingContext { public void SetBackgroundColor(Color color) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)HUDManagerRefs.Instance == (Object)null)) { ((Graphic)HUDManagerRefs.MainLoadingBackground).color = color; } } public void SetMainText(string text) { if (!((Object)(object)HUDManagerRefs.Instance == (Object)null)) { ((TMP_Text)HUDManagerRefs.MainLoadingText).text = text; } } public void SetMainTextColor(Color startColor, Color endColor) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: 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) if (!((Object)(object)HUDManagerRefs.Instance == (Object)null)) { HUDManagerRefs.MainTextEffectColor.startColor = startColor; HUDManagerRefs.MainTextEffectColor.endColor = endColor; HUDManagerRefs.MainLoadingTextEffect.Refresh(); } } public void SetSecondaryText(string text) { if (!((Object)(object)HUDManagerRefs.Instance == (Object)null)) { ((TMP_Text)HUDManagerRefs.SecondaryLoadingText).text = text; } } public void SetSecondaryTextColor(Color color) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)HUDManagerRefs.Instance == (Object)null)) { ((Graphic)HUDManagerRefs.SecondaryLoadingText).color = color; } } } public interface ILoadingContext { void SetBackgroundColor(Color color); void SetMainText(string text); void SetSecondaryText(string text); void SetMainTextColor(Color startColor, Color endColor); void SetSecondaryTextColor(Color color); } public class RoundLoadingStepInfoBuilder : BaseInfoBuilder, RoundLoadingStepInfoBuilder> { private List _hardDependencies = new List(); private List _softDependencies = new List(); internal RoundLoadingStepInfoBuilder(NamespacedKey key, Func value) : base(key, value) { } public RoundLoadingStepInfoBuilder AddHardDependency(NamespacedKey key) { _hardDependencies.Add(key); return this; } public RoundLoadingStepInfoBuilder AddSoftDependency(NamespacedKey key) { _softDependencies.Add(key); return this; } internal override DawnRoundLoadingStepInfo Build() { return new DawnRoundLoadingStepInfo(base.key, new HashSet(), base.value, _hardDependencies, _softDependencies, customData); } } internal static class StoryLogRegistrationHandler { [CompilerGenerated] private static class <>O { public static hook_Start <0>__CollectAllStoryLogs; public static hook_Start <1>__RegisterStoryLogs; } private static List _networkPrefabStoryLogTypes = new List(); internal static void Init() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //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_0052: Expected O, but got Unknown DetourContext val = new DetourContext(int.MaxValue); try { object obj = <>O.<0>__CollectAllStoryLogs; if (obj == null) { hook_Start val2 = CollectAllStoryLogs; <>O.<0>__CollectAllStoryLogs = val2; obj = (object)val2; } GameNetworkManager.Start += (hook_Start)obj; } finally { ((IDisposable)val)?.Dispose(); } object obj2 = <>O.<1>__RegisterStoryLogs; if (obj2 == null) { hook_Start val3 = RegisterStoryLogs; <>O.<1>__RegisterStoryLogs = val3; obj2 = (object)val3; } Terminal.Start += (hook_Start)obj2; } private static void RegisterStoryLogs(orig_Start orig, Terminal self) { //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown orig.Invoke(self); _ = TerminalRefs.Instance; List list = TerminalRefs.ViewKeyword.compatibleNouns.ToList(); List list2 = TerminalRefs.Instance.terminalNodes.allKeywords.ToList(); foreach (DawnStoryLogInfo value2 in LethalContent.StoryLogs.Values) { if (!value2.ShouldSkipIgnoreOverride()) { self.logEntryFiles.Add(value2.StoryLogTerminalNode); if (!LethalContent.StoryLogs.IsFrozen) { value2.StoryLogTerminalKeyword.defaultVerb = TerminalRefs.ViewKeyword; int num = self.logEntryFiles.Count - 1; value2.StoryLogGameObject.GetComponent().SetStoryLogID(num); value2.StoryLogTerminalNode.storyLogFileID = num; CompatibleNoun item = new CompatibleNoun(value2.StoryLogTerminalKeyword, value2.StoryLogTerminalNode); list.Add(item); list2.Add(value2.StoryLogTerminalKeyword); } } } if (LethalContent.StoryLogs.IsFrozen) { return; } TerminalRefs.Instance.terminalNodes.allKeywords = list2.ToArray(); TerminalRefs.ViewKeyword.compatibleNouns = list.ToArray(); foreach (CompatibleNoun item2 in TerminalRefs.ViewKeyword.compatibleNouns.Where((CompatibleNoun x) => (Object)(object)x.result != (Object)null && x.result.storyLogFileID > -1)) { string name = NamespacedKey.NormalizeStringForNamespacedKey(item2.result.creatureName, CSharpName: true); NamespacedKey namespacedKey = StoryLogKeys.GetByReflection(name); if (namespacedKey == null) { namespacedKey = NamespacedKey.From("unknown_lib", item2.result.creatureName); } if (LethalContent.StoryLogs.ContainsKey(namespacedKey)) { DawnPlugin.Logger.LogWarning((object)("StoryLog " + item2.result.creatureName + " is already registered by the same creator to LethalContent. This is likely to cause issues.")); continue; } GameObject storyLogGameObject = null; foreach (GameObject networkPrefabStoryLogType in _networkPrefabStoryLogTypes) { if (networkPrefabStoryLogType.GetComponent().storyLogID == item2.result.storyLogFileID) { storyLogGameObject = networkPrefabStoryLogType; break; } } DawnStoryLogInfo value = new DawnStoryLogInfo(namespacedKey, new HashSet { DawnLibTags.IsExternal }, storyLogGameObject, item2.result, item2.noun, null); LethalContent.StoryLogs.Register(value); } LethalContent.StoryLogs.Freeze(); } private static void CollectAllStoryLogs(orig_Start orig, GameNetworkManager self) { orig.Invoke(self); StoryLog val = default(StoryLog); foreach (NetworkPrefab prefab in NetworkManager.Singleton.NetworkConfig.Prefabs.Prefabs) { if (prefab.Prefab.TryGetComponent(ref val) && !_networkPrefabStoryLogTypes.Contains(prefab.Prefab)) { _networkPrefabStoryLogTypes.Add(prefab.Prefab); } } } } public sealed class DawnStoryLogInfo : DawnBaseInfo { public GameObject? StoryLogGameObject { get; } public TerminalNode StoryLogTerminalNode { get; } public TerminalKeyword StoryLogTerminalKeyword { get; } internal DawnStoryLogInfo(NamespacedKey key, HashSet tags, GameObject? storyLogGameObject, TerminalNode storyLogTerminalNode, TerminalKeyword storyLogTerminalKeyword, IDataContainer? customData) : base(key, tags, customData) { StoryLogGameObject = storyLogGameObject; StoryLogTerminalNode = storyLogTerminalNode; StoryLogTerminalKeyword = storyLogTerminalKeyword; } } public class StoryLogInfoBuilder : BaseInfoBuilder { private TerminalNode? _storyLogTerminalNode; private string _storyLogTitle; private string _storyLogKeyword; private string _storyLogDescription = "The developer of this story log left this empty!"; public StoryLogInfoBuilder(NamespacedKey key, GameObject value) : base(key, value) { } public StoryLogInfoBuilder OverrideTerminalNode(TerminalNode? terminalNode) { _storyLogTerminalNode = terminalNode; return this; } public StoryLogInfoBuilder SetDescription(string description) { _storyLogDescription = description; return this; } public StoryLogInfoBuilder SetTitle(string title) { _storyLogTitle = title; return this; } public StoryLogInfoBuilder SetKeyword(string keyword) { _storyLogKeyword = keyword.ToLowerInvariant(); return this; } internal override DawnStoryLogInfo Build() { if ((Object)(object)_storyLogTerminalNode == (Object)null) { _storyLogTerminalNode = new TerminalNodeBuilder($"{base.key}TerminalNode").SetClearPreviousText(clearPreviousText: true).SetCreatureName(_storyLogTitle).SetMaxCharactersToType(35) .SetDisplayText(_storyLogDescription) .Build(); } if (string.IsNullOrEmpty(_storyLogKeyword)) { DawnPlugin.Logger.LogWarning((object)$"StoryLog: '{base.key}' didn't set keyword, please call .SetKeyword on the builder."); } TerminalKeyword storyLogTerminalKeyword = new TerminalKeywordBuilder($"{base.key}TerminalKeyword", _storyLogKeyword, ITerminalKeyword.DawnKeywordType.SigurdLog).Build(); return new DawnStoryLogInfo(base.key, tags, base.value, _storyLogTerminalNode, storyLogTerminalKeyword, customData); } } [HarmonyPatch] internal static class SurfaceRegistrationHandler { [CompilerGenerated] private static class <>O { public static hook_Awake <0>__RegisterDawnSurfaces; public static Manipulator <1>__PlayerGetCurrentMaterialStandingOn; public static Manipulator <2>__EditGravityDirection; public static Manipulator <3>__EditFallValueForGravity; public static Manipulator <4>__EditUncappedFallValueForGravity; public static Manipulator <5>__AllowCustomSurfacesInQuicksand; public static Manipulator <6>__AllowEmergingAtCustomSurfaces; public static UnityAction <7>__OnVowOrMarchLoaded; public static UnityAction <8>__TryFixMoonTerrainFootsteps; public static hook_Start <9>__AddCrouchingFootsteps; public static Action, PlayerAnimationEvents> <10>__PlayCrouchFootstepSound; public static Manipulator <11>__ModifyBatchingVainShrouds; public static Manipulator <12>__CollectVainShroudBatches; public static hook_ClearBatchedMeshes <13>__ClearVainShroudBatches; public static Manipulator <14>__AdjustCheckForSnowyFootprints; public static Func <15>__CheckSurfaceForSnowy; public static <>A{00000001} <16>__CollectTransformForBatch; public static Func <17>__DrawMultipleBatches; } private const int MaxBatchSize = 1023; private static Dictionary>> _batchingDict = new Dictionary>>(); private static readonly NamespacedKey VanillaSurface = NamespacedKey.Vanilla("vanilla_surface"); private static readonly List CrouchingAnimationEvents = new List { new AnimationEventData { AnimationEventName = "PlayCrouchFootstepSound", Time = 0.33f }, new AnimationEventData { AnimationEventName = "PlayCrouchFootstepSound", Time = 0.66f } }; private static bool addedCrouchingSteps = false; internal static void Init() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //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_0052: Expected O, but got Unknown //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Expected O, but got Unknown //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Expected O, but got Unknown //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Expected O, but got Unknown //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Expected O, but got Unknown //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Expected O, but got Unknown //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Expected O, but got Unknown //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Expected O, but got Unknown DetourContext val = new DetourContext(int.MaxValue); try { object obj = <>O.<0>__RegisterDawnSurfaces; if (obj == null) { hook_Awake val2 = RegisterDawnSurfaces; <>O.<0>__RegisterDawnSurfaces = val2; obj = (object)val2; } StartOfRound.Awake += (hook_Awake)obj; } finally { ((IDisposable)val)?.Dispose(); } object obj2 = <>O.<1>__PlayerGetCurrentMaterialStandingOn; if (obj2 == null) { Manipulator val3 = PlayerGetCurrentMaterialStandingOn; <>O.<1>__PlayerGetCurrentMaterialStandingOn = val3; obj2 = (object)val3; } PlayerControllerB.GetCurrentMaterialStandingOn += (Manipulator)obj2; object obj3 = <>O.<2>__EditGravityDirection; if (obj3 == null) { Manipulator val4 = EditGravityDirection; <>O.<2>__EditGravityDirection = val4; obj3 = (object)val4; } PlayerControllerB.Update += (Manipulator)obj3; object obj4 = <>O.<3>__EditFallValueForGravity; if (obj4 == null) { Manipulator val5 = EditFallValueForGravity; <>O.<3>__EditFallValueForGravity = val5; obj4 = (object)val5; } PlayerControllerB.Update += (Manipulator)obj4; object obj5 = <>O.<4>__EditUncappedFallValueForGravity; if (obj5 == null) { Manipulator val6 = EditUncappedFallValueForGravity; <>O.<4>__EditUncappedFallValueForGravity = val6; obj5 = (object)val6; } PlayerControllerB.Update += (Manipulator)obj5; PlayerControllerB.PlayFootstepSound += EditFootstepSound(typeof(PlayerControllerB)); MaskedPlayerEnemy.PlayFootstepSound += EditFootstepSound(typeof(MaskedPlayerEnemy)); object obj6 = <>O.<5>__AllowCustomSurfacesInQuicksand; if (obj6 == null) { Manipulator val7 = AllowCustomSurfacesInQuicksand; <>O.<5>__AllowCustomSurfacesInQuicksand = val7; obj6 = (object)val7; } PlayerControllerB.CheckConditionsForSinkingInQuicksand += (Manipulator)obj6; object obj7 = <>O.<6>__AllowEmergingAtCustomSurfaces; if (obj7 == null) { Manipulator val8 = AllowEmergingAtCustomSurfaces; <>O.<6>__AllowEmergingAtCustomSurfaces = val8; obj7 = (object)val8; } SandWormAI.StartEmergeAnimation += (Manipulator)obj7; SceneManager.sceneLoaded += OnVowOrMarchLoaded; SceneManager.sceneLoaded += TryFixMoonTerrainFootsteps; object obj8 = <>O.<9>__AddCrouchingFootsteps; if (obj8 == null) { hook_Start val9 = AddCrouchingFootsteps; <>O.<9>__AddCrouchingFootsteps = val9; obj8 = (object)val9; } PlayerControllerB.Start += (hook_Start)obj8; DawnPlugin.Hooks.Add(new Hook((MethodBase)AccessTools.DeclaredMethod(typeof(PlayerAnimationEvents), "PlayCrouchFootstepSound", (Type[])null, (Type[])null), (Delegate)new Action, PlayerAnimationEvents>(PlayCrouchFootstepSound))); LethalContent.Surfaces.OnFreezeWithContext += delegate { CollectCustomVainShroudBatches(); }; object obj9 = <>O.<11>__ModifyBatchingVainShrouds; if (obj9 == null) { Manipulator val10 = ModifyBatchingVainShrouds; <>O.<11>__ModifyBatchingVainShrouds = val10; obj9 = (object)val10; } BatchAllMeshChildren.RenderBatches += (Manipulator)obj9; object obj10 = <>O.<12>__CollectVainShroudBatches; if (obj10 == null) { Manipulator val11 = CollectVainShroudBatches; <>O.<12>__CollectVainShroudBatches = val11; obj10 = (object)val11; } MoldSpreadManager.GenerateMold += (Manipulator)obj10; object obj11 = <>O.<13>__ClearVainShroudBatches; if (obj11 == null) { hook_ClearBatchedMeshes val12 = ClearVainShroudBatches; <>O.<13>__ClearVainShroudBatches = val12; obj11 = (object)val12; } BatchAllMeshChildren.ClearBatchedMeshes += (hook_ClearBatchedMeshes)obj11; object obj12 = <>O.<14>__AdjustCheckForSnowyFootprints; if (obj12 == null) { Manipulator val13 = AdjustCheckForSnowyFootprints; <>O.<14>__AdjustCheckForSnowyFootprints = val13; obj12 = (object)val13; } PlayerControllerB.LateUpdate += (Manipulator)obj12; object obj13 = <>O.<14>__AdjustCheckForSnowyFootprints; if (obj13 == null) { Manipulator val14 = AdjustCheckForSnowyFootprints; <>O.<14>__AdjustCheckForSnowyFootprints = val14; obj13 = (object)val14; } PlayerControllerB.UpdatePlayerPositionRpc += (Manipulator)obj13; } private static void AdjustCheckForSnowyFootprints(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00f8: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel skipLabel = null; if (!val.TryGotoNext((MoveType)0, new Func[4] { (Instruction val2) => ILPatternMatchingExt.MatchLdarg(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "currentFootstepSurfaceIndex"), (Instruction val2) => ILPatternMatchingExt.MatchLdcI4(val2, 8), (Instruction val2) => ILPatternMatchingExt.MatchBneUn(val2, ref skipLabel) })) { DawnPlugin.Logger.LogError((object)("Couldn't match AdjustCheckForSnowyFootprints IL on method: " + ((MemberReference)il.Method).Name + ".")); return; } int index = val.Index; val.Index = index + 1; val.RemoveRange(3); val.EmitDelegate>((Func)CheckSurfaceForSnowy); val.Emit(OpCodes.Brfalse_S, (object)skipLabel); } private static bool CheckSurfaceForSnowy(PlayerControllerB playerControllerB) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (playerControllerB.TryGetCurrentDawnSurface(out DawnSurface dawnSurface) && dawnSurface.TryGetFootstepIndex(((Component)playerControllerB).transform.position, checkStandingOnTerrain: false, out var footstepIndex, playerControllerB)) { return FootstepSurfaceExtensions.get_DawnInfo(StartOfRoundRefs.Instance.footstepSurfaces[footstepIndex]).SupportsSnowyFootprints; } return playerControllerB.currentFootstepSurfaceIndex == 8; } private static void ClearVainShroudBatches(orig_ClearBatchedMeshes orig, BatchAllMeshChildren self) { orig.Invoke(self); if (!((Object)((Component)self).gameObject).name.StartsWith("Mold")) { return; } foreach (KeyValuePair>> item in _batchingDict) { item.Value.Clear(); } } private static void CollectVainShroudBatches(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_00af: 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_0282: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_0462: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); MethodReference val3 = default(MethodReference); if (!val.TryGotoNext((MoveType)2, new Func[4] { (Instruction val2) => ILPatternMatchingExt.MatchLdarg(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "moldContainer"), (Instruction val2) => ILPatternMatchingExt.MatchCallOrCallvirt(val2, ref val3) && ((MemberReference)val3).Name == "Instantiate", (Instruction val2) => ILPatternMatchingExt.MatchStloc(val2, 1) })) { DawnPlugin.Logger.LogError((object)"Couldn't match BatchAllMeshChildren.BatchChildren (1) IL."); return; } val.Emit(OpCodes.Ldloca, 3); val.Emit(OpCodes.Ldloc_1); val.EmitDelegate<<>A{00000001}>((<>A{00000001})CollectTransformForBatch); if (!val.TryGotoNext((MoveType)2, new Func[11] { (Instruction val2) => ILPatternMatchingExt.MatchLdcR4(val2, 0f), (Instruction val2) => ILPatternMatchingExt.MatchLdcR4(val2, -180f), (Instruction val2) => ILPatternMatchingExt.MatchLdcR4(val2, 180f), (Instruction val2) => ILPatternMatchingExt.MatchCall(val2, ref val3), (Instruction val2) => ILPatternMatchingExt.MatchLdcR4(val2, 0f), (Instruction val2) => ILPatternMatchingExt.MatchNewobj(val2, ref val3), (Instruction val2) => ILPatternMatchingExt.MatchCall(val2, ref val3), (Instruction val2) => ILPatternMatchingExt.MatchLdarg(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "moldContainer"), (Instruction val2) => ILPatternMatchingExt.MatchCall(val2, ref val3), (Instruction val2) => ILPatternMatchingExt.MatchStloc(val2, 1) })) { DawnPlugin.Logger.LogError((object)"Couldn't match BatchAllMeshChildren.BatchChildren (2) IL."); return; } val.Emit(OpCodes.Ldloca, 3); val.Emit(OpCodes.Ldloc_1); val.EmitDelegate<<>A{00000001}>((<>A{00000001})CollectTransformForBatch); if (!val.TryGotoNext((MoveType)2, new Func[11] { (Instruction val2) => ILPatternMatchingExt.MatchLdcR4(val2, 0f), (Instruction val2) => ILPatternMatchingExt.MatchLdcR4(val2, -180f), (Instruction val2) => ILPatternMatchingExt.MatchLdcR4(val2, 180f), (Instruction val2) => ILPatternMatchingExt.MatchCall(val2, ref val3), (Instruction val2) => ILPatternMatchingExt.MatchLdcR4(val2, 0f), (Instruction val2) => ILPatternMatchingExt.MatchNewobj(val2, ref val3), (Instruction val2) => ILPatternMatchingExt.MatchCall(val2, ref val3), (Instruction val2) => ILPatternMatchingExt.MatchLdarg(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "moldContainer"), (Instruction val2) => ILPatternMatchingExt.MatchCall(val2, ref val3), (Instruction val2) => ILPatternMatchingExt.MatchStloc(val2, 1) })) { DawnPlugin.Logger.LogError((object)"Couldn't match BatchAllMeshChildren.BatchChildren (3) IL."); return; } val.Emit(OpCodes.Ldloca, 3); val.Emit(OpCodes.Ldloc_1); val.EmitDelegate<<>A{00000001}>((<>A{00000001})CollectTransformForBatch); } private static void CollectTransformForBatch(ref RaycastHit raycastHit, GameObject vainShroudGameObject) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003c: 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_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) Transform transform = ((RaycastHit)(ref raycastHit)).transform; MeshFilter component = vainShroudGameObject.GetComponent(); if (!((Object)(object)component == (Object)null)) { Matrix4x4 localToWorldMatrix = ((Component)component).transform.localToWorldMatrix; DawnSurface dawnSurface = default(DawnSurface); NamespacedKey key; if (!((Component)transform).TryGetComponent(ref dawnSurface)) { AddMatrixToBatches(VanillaSurface, localToWorldMatrix); } else if (!dawnSurface.TryGetNamespacedKeyAtPosition(((RaycastHit)(ref raycastHit)).point, out key) || key == null || key.Namespace == "lethal_company" || !_batchingDict.ContainsKey(key)) { AddMatrixToBatches(VanillaSurface, localToWorldMatrix); } else { AddMatrixToBatches(key, localToWorldMatrix); } } } private static void AddMatrixToBatches(NamespacedKey surfaceKey, Matrix4x4 matrix) { //IL_0040: 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) if (!_batchingDict.TryGetValue(surfaceKey, out List> value)) { value = new List>(); _batchingDict.Add(surfaceKey, value); } foreach (List item in value) { if (item.Count < 1023) { item.Add(matrix); return; } } value.Add(new List(1) { matrix }); } private static void ModifyBatchingVainShrouds(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); TypeReference val3 = default(TypeReference); if (!val.TryGotoNext((MoveType)0, new Func[6] { (Instruction val2) => ILPatternMatchingExt.MatchLdarg(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "Batches"), (Instruction val2) => ILPatternMatchingExt.MatchCallvirt(val2, ref val3), (Instruction val2) => ILPatternMatchingExt.MatchStloc(val2, 1), (Instruction val2) => ILPatternMatchingExt.MatchBr(val2, ref val3), (Instruction val2) => ILPatternMatchingExt.MatchLdloca(val2, 1) })) { DawnPlugin.Logger.LogError((object)"Couldn't match BatchAllMeshChildren.RenderBatches (1) IL."); return; } int index = val.Index; ILLabel finalRet = null; if (!val.TryGotoNext((MoveType)2, new Func[6] { (Instruction val2) => ILPatternMatchingExt.MatchLeaveS(val2, ref finalRet), (Instruction val2) => ILPatternMatchingExt.MatchLdloca(val2, 1), (Instruction val2) => ILPatternMatchingExt.MatchConstrained(val2, ref val3), (Instruction val2) => ILPatternMatchingExt.MatchCallvirt(val2, "Dispose"), (Instruction val2) => ILPatternMatchingExt.MatchEndfinally(val2), (Instruction val2) => ILPatternMatchingExt.MatchRet(val2) })) { DawnPlugin.Logger.LogError((object)"Couldn't match BatchAllMeshChildren.RenderBatches (2) IL."); return; } val.Index = index; val.MoveAfterLabels(); val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldloc_0); val.EmitDelegate>((Func)DrawMultipleBatches); val.Emit(OpCodes.Brfalse_S, (object)finalRet); } private static bool DrawMultipleBatches(BatchAllMeshChildren self, Camera camera) { if (!((Object)((Component)self).gameObject).name.StartsWith("Mold")) { return true; } foreach (KeyValuePair>> item in _batchingDict) { if (item.Value.Count <= 0) { continue; } Mesh val; Material[] array; if (!LethalContent.Surfaces.TryGetValue(item.Key, out DawnSurfaceInfo value)) { val = self.mesh; array = (Material[])(object)new Material[1] { self.material }; } else { val = value.VainShroudMesh; array = value.VainShroudMaterials; } for (int i = 0; i < val.subMeshCount; i++) { foreach (List item2 in item.Value) { Graphics.DrawMeshInstanced(val, i, array[i], item2, (MaterialPropertyBlock)null, (ShadowCastingMode)1, true, 24, camera); } } } return false; } private static void CollectCustomVainShroudBatches() { _batchingDict.Add(VanillaSurface, new List> { new List() }); foreach (DawnSurfaceInfo value in LethalContent.Surfaces.Values) { if (!value.ShouldSkipIgnoreOverride() && (Object)(object)value.VainShroudPrefab != (Object)null) { _batchingDict.Add(value.Key, new List> { new List() }); } } } private static void PlayCrouchFootstepSound(Action orig, PlayerAnimationEvents self) { PlayerControllerB thisPlayerController = self.thisPlayerController; if (thisPlayerController.isClimbingLadder || thisPlayerController.inSpecialInteractAnimation) { orig.Invoke(self); return; } if ((((NetworkBehaviour)thisPlayerController).IsOwner && thisPlayerController.slipperyFloor > 0.5f) || (!((NetworkBehaviour)thisPlayerController).IsOwner && thisPlayerController.slimeSlipAudioVolumeSync > 0f)) { thisPlayerController.currentFootstepSurfaceIndex = 12; } else { thisPlayerController.GetCurrentMaterialStandingOn(false); } DawnSurfaceInfo dawnSurfaceInfo = FootstepSurfaceExtensions.get_DawnInfo(StartOfRound.Instance.footstepSurfaces[thisPlayerController.currentFootstepSurfaceIndex]); if (dawnSurfaceInfo == null || dawnSurfaceInfo.CrouchClips == null || dawnSurfaceInfo.CrouchClips.Count == 0) { orig.Invoke(self); return; } int num = Random.Range(0, dawnSurfaceInfo.CrouchClips.Count); if (num == thisPlayerController.previousFootstepClip) { num = (num + 1) % dawnSurfaceInfo.CrouchClips.Count; } thisPlayerController.movementAudio.pitch = Random.Range(0.93f, 1.07f); float num2 = 0.3f; num2 *= dawnSurfaceInfo.Volume; thisPlayerController.movementAudio.PlayOneShot(dawnSurfaceInfo.CrouchClips[num], num2); thisPlayerController.previousFootstepClip = num; WalkieTalkie.TransmitOneShotAudio(thisPlayerController.movementAudio, dawnSurfaceInfo.CrouchClips[num], num2); orig.Invoke(self); } private static void AddCrouchingFootsteps(orig_Start orig, PlayerControllerB self) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown orig.Invoke(self); if (addedCrouchingSteps) { return; } addedCrouchingSteps = true; AnimationClip val = null; AnimationClip[] animationClips = self.playerBodyAnimator.runtimeAnimatorController.animationClips; foreach (AnimationClip val2 in animationClips) { if (((Object)val2).name == "CrouchWalk") { val = val2; break; } } foreach (AnimationEventData crouchingAnimationEvent in CrouchingAnimationEvents) { AnimationEvent val3 = new AnimationEvent { functionName = crouchingAnimationEvent.AnimationEventName, time = crouchingAnimationEvent.Time }; val.AddEvent(val3); } } private static Manipulator EditFootstepSound(Type type) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown return (Manipulator)delegate(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); int location = -1; if (!val.TryGotoNext((MoveType)0, new Func[6] { (Instruction val2) => ILPatternMatchingExt.MatchStloc(val2, ref location), (Instruction val2) => ILPatternMatchingExt.MatchLdarg(val2, 0), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, type, "movementAudio"), (Instruction val2) => ILPatternMatchingExt.MatchCall(val2, "get_Instance"), (Instruction val2) => ILPatternMatchingExt.MatchLdfld(val2, "footstepSurfaces"), (Instruction val2) => ILPatternMatchingExt.MatchLdarg(val2, 0) })) { DawnPlugin.Logger.LogWarning((object)("Failed to apply " + type.Name + ".PlayFootstepSound patch (0)!")); } else { val.GotoNext((MoveType)2, new Func[1] { (Instruction val2) => ILPatternMatchingExt.MatchLdarg(val2, 0) }); val.EmitLdfld(type, "currentFootstepSurfaceIndex"); val.Emit(OpCodes.Ldloca, location); val.EmitDelegate<<>A{00000008}>((<>A{00000008})delegate(int currentFootstepSurfaceIndex, ref float volume) { FootstepSurface footstepSurface = StartOfRound.Instance.footstepSurfaces[currentFootstepSurfaceIndex]; DawnSurfaceInfo dawnSurfaceInfo = FootstepSurfaceExtensions.get_DawnInfo(footstepSurface); if (dawnSurfaceInfo != null) { volume *= dawnSurfaceInfo.Volume; } }); val.Emit(OpCodes.Ldarg_0); } }; } private static void AllowEmergingAtCustomSurfaces(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel val3 = default(ILLabel); if (!val.TryGotoNext((MoveType)0, new Func[5] { (Instruction i) => ILPatternMatchingExt.MatchLdloc(i, 2), (Instruction i) => ILPatternMatchingExt.MatchBrfalse(i, ref val3), (Instruction i) => ILPatternMatchingExt.MatchLdloc(i, 5), (Instruction i) => ILPatternMatchingExt.MatchLdcI4(i, 1), (Instruction i) => ILPatternMatchingExt.MatchAdd(i) })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply SandWormAI.StartEmergeAnimation patch (0)!"); return; } ILLabel val2 = val.DefineLabel(); val.MarkLabel(val2); if (!val.TryGotoPrev((MoveType)0, new Func[4] { (Instruction i) => ILPatternMatchingExt.MatchLdcI4(i, 0), (Instruction i) => ILPatternMatchingExt.MatchStloc(i, 2), (Instruction i) => ILPatternMatchingExt.MatchCall(i, "get_activeTerrain"), (Instruction i) => ILPatternMatchingExt.MatchLdnull(i) })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply SandWormAI.StartEmergeAnimation patch (1)!"); return; } val.Emit(OpCodes.Ldloc_1); val.Emit(OpCodes.Ldloca, 2); val.EmitDelegate<<>F{00000008}>((<>F{00000008})delegate(RaycastHit hit, ref bool flag) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) DawnSurface dawnSurface = default(DawnSurface); if (!((Component)((RaycastHit)(ref hit)).collider).TryGetComponent(ref dawnSurface)) { return false; } if (!dawnSurface.TryGetFootstepIndex(((RaycastHit)(ref hit)).point, checkStandingOnTerrain: true, out var footstepIndex) || footstepIndex == -1) { return false; } DawnSurfaceInfo dawnSurfaceInfo = null; foreach (DawnSurfaceInfo value in LethalContent.Surfaces.Values) { if (value.SurfaceIndex == footstepIndex) { dawnSurfaceInfo = value; break; } } if (dawnSurfaceInfo == null) { return false; } if (SelectableLevelExtensions.get_DawnInfo(StartOfRoundRefs.Instance.currentLevel) == LethalContent.Moons[MoonKeys.Embrion] && dawnSurfaceInfo == LethalContent.Surfaces[SurfaceKeys.Rock]) { flag = true; return true; } if (dawnSurfaceInfo.IsNatural) { flag = true; return true; } return true; }); val.Emit(OpCodes.Brtrue_S, (object)val2); } private static void AllowCustomSurfacesInQuicksand(ILContext il) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel branchLabel = null; if (!val.TryGotoNext((MoveType)0, new Func[4] { (Instruction i) => ILPatternMatchingExt.MatchLdarg(i, 0), (Instruction i) => ILPatternMatchingExt.MatchLdfld(i, "currentFootstepSurfaceIndex"), (Instruction i) => ILPatternMatchingExt.MatchLdcI4(i, 1), (Instruction i) => ILPatternMatchingExt.MatchBeq(i, ref branchLabel) })) { DawnPlugin.Logger.LogWarning((object)"Failed to apply PlayerControllerB.CheckConditionsForSinkingInQuicksand patch (0)!"); return; } val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldfld, AccessTools.Field(typeof(PlayerControllerB), "currentFootstepSurfaceIndex")); val.EmitDelegate>((Func)delegate(int currentFootstepSurfaceIndex) { foreach (DawnSurfaceInfo value in LethalContent.Surfaces.Values) { if (!value.ShouldSkipIgnoreOverride() && value.SurfaceIndex == currentFootstepSurfaceIndex) { if (value.QuicksandCompatible) { return true; } return false; } } return false; }); val.Emit(OpCodes.Brtrue_S, (object)branchLabel); } private static void TryFixMoonTerrainFootsteps(Scene arg0, LoadSceneMode arg1) { if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.currentLevel == (Object)null) { return; } if (LethalLevelLoaderCompat.Enabled && Version.Parse("1.6.9") < Chainloader.PluginInfos["imabatby.lethallevelloader"].Metadata.Version) { SceneManager.sceneLoaded -= TryFixMoonTerrainFootsteps; return; } DawnMoonInfo dawnMoonInfo = SelectableLevelExtensions.get_DawnInfo(StartOfRound.Instance.currentLevel); if (dawnMoonInfo == null || dawnMoonInfo.TypedKey.IsVanilla()) { return; } Terrain[] activeTerrains = Terrain.activeTerrains; DawnSurface dawnSurface = default(DawnSurface); foreach (Terrain val in activeTerrains) { TerrainData terrainData = val.terrainData; int num = terrainData.GetAlphamaps(0, 0, terrainData.alphamapWidth, terrainData.alphamapHeight).Length / (terrainData.alphamapWidth * terrainData.alphamapHeight); if (num == 0) { break; } if (((Component)val).CompareTag("Untagged")) { continue; } if (((Component)val).TryGetComponent(ref dawnSurface)) { break; } dawnSurface = ((Component)val).gameObject.AddComponent(); foreach (DawnSurfaceInfo value in LethalContent.Surfaces.Values) { if (value.Surface.surfaceTag.Equals(((Component)val).tag, StringComparison.OrdinalIgnoreCase)) { for (int j = 0; j < num; j++) { dawnSurface.NamespacedKeysForTerrain.Add(value.Key); } } } } } private static void OnVowOrMarchLoaded(Scene arg0, LoadSceneMode arg1) { if (!((Object)(object)StartOfRound.Instance == (Object)null)) { SelectableLevel currentLevel = RoundManager.Instance.currentLevel; if ((Object)(object)currentLevel == (Object)(object)LethalContent.Moons[MoonKeys.March].Level) { GameObject gameObject = ((Component)GameObject.FindGameObjectWithTag("OutsideLevelNavMesh").transform.Find("Map/MarchTerrainNew")).gameObject; DawnSurface dawnSurface = gameObject.AddComponent(); dawnSurface.NamespacedKeysForTerrain.AddRange(new <>z__ReadOnlyArray(new NamespacedKey[3] { SurfaceKeys.Grass, SurfaceKeys.Rock, SurfaceKeys.Gravel })); } else if ((Object)(object)currentLevel == (Object)(object)LethalContent.Moons[MoonKeys.Vow].Level) { GameObject gameObject2 = ((Component)GameObject.FindGameObjectWithTag("OutsideLevelNavMesh").transform.Find("VowTerrain")).gameObject; DawnSurface dawnSurface2 = gameObject2.AddComponent(); dawnSurface2.NamespacedKeysForTerrain.AddRange(new <>z__ReadOnlyArray(new NamespacedKey[3] { SurfaceKeys.Grass, SurfaceKeys.Gravel, SurfaceKeys.Rock })); } } } private static void PlayerGetCurrentMaterialStandingOn(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel val3 = default(ILLabel); if (!val.TryGotoNext((MoveType)2, new Func[5] { (Instruction instr) => ILPatternMatchingExt.MatchCall(instr, (MethodBase)AccessTools.Method(typeof(StartOfRound), "get_Instance", (Type[])null, (Type[])null)), (Instruction instr) => ILPatternMatchingExt.MatchLdfld(instr, AccessTools.Field(typeof(StartOfRound), "walkableSurfacesMask")), (Instruction instr) => ILPatternMatchingExt.MatchLdcI4(instr, 1), (Instruction instr) => ILPatternMatchingExt.MatchCall(instr, (MethodBase)AccessTools.Method(typeof(Physics), "Raycast", new Type[5] { typeof(Ray), typeof(RaycastHit).MakeByRefType(), typeof(float), typeof(int), typeof(QueryTriggerInteraction) }, (Type[])null)), (Instruction instr) => ILPatternMatchingExt.MatchBrfalse(instr, ref val3) })) { DawnPlugin.Logger.LogError((object)"Couldn't match GameNetcodeStuff.PlayerControllerB.GetCurrentMaterialStandingOn IL."); return; } ILLabel val2 = val.DefineLabel(); val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldarg_1); val.Emit(OpCodes.Ldarg_0); val.EmitLdflda("hit"); val.Emit(OpCodes.Ldarg_0); val.EmitLdflda("currentFootstepSurfaceIndex"); val.Emit(OpCodes.Call, (MethodBase)AccessTools.Method(typeof(SurfaceRegistrationHandler), "TryGetAndSetDawnSurfaceIndexPlayer", (Type[])null, (Type[])null)); val.Emit(OpCodes.Brfalse, (object)val2); val.Emit(OpCodes.Ret); val.MarkLabel(val2); } private static void EditUncappedFallValueForGravity(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0115: 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_022e: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (!val.TryGotoNext((MoveType)2, new Func[6] { (Instruction instr) => ILPatternMatchingExt.MatchLdarg(instr, 0), (Instruction instr) => ILPatternMatchingExt.MatchLdarg(instr, 0), (Instruction instr) => ILPatternMatchingExt.MatchLdfld(instr, "fallValueUncapped"), (Instruction instr) => ILPatternMatchingExt.MatchLdcR4(instr, 26f), (Instruction instr) => ILPatternMatchingExt.MatchCall