Decompiled source of DawnLib v0.4.3
BepInEx/plugins/DawnLib/com.github.teamxiaolan.dawnlib.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.CodeDom.Compiler; using System.Collections; 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.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 GameNetcodeStuff; using GoodItemScan; using HarmonyLib; using IL; 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.TMPro; using On.Unity.Netcode; using PathfindingLib.API.SmartPathfinding; using Steamworks; 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.UI; using WeatherRegistry; using com.github.teamxiaolan.dawnlib.NetcodePatcher; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [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("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_Unity.TextMeshPro")] [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("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [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("0.4.3.0")] [assembly: AssemblyInformationalVersion("0.4.3+beec3bd066ed9e9cf3d67aa86121d7c5e60c8b43")] [assembly: AssemblyProduct("DawnLib")] [assembly: AssemblyTitle("com.github.teamxiaolan.dawnlib")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.4.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } public sealed class Vector3Converter : JsonConverter<Vector3> { 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 DawnMapObjectInfoContainer : DawnInfoContainer<DawnMapObjectInfo> { } public class DawnMapObjectNamespacedKeyContainer : MonoBehaviour { [field: SerializeField] public NamespacedKey Value { get; internal set; } } namespace Dawn { public abstract class BaseInfoBuilder { internal abstract void SoloAddTags(IEnumerable<NamespacedKey> newTags); } public abstract class BaseInfoBuilder<TInfo, T, TBuilder> : BaseInfoBuilder where TInfo : INamespaced<TInfo> where TBuilder : BaseInfoBuilder<TInfo, T, TBuilder> { protected HashSet<NamespacedKey> tags = new HashSet<NamespacedKey>(); protected IDataContainer? customData; protected NamespacedKey<TInfo> key { get; private set; } protected T value { get; private set; } internal BaseInfoBuilder(NamespacedKey<TInfo> key, T value) { this.key = key; this.value = value; } public TBuilder AddTag(NamespacedKey tag) { tags.Add(tag); return (TBuilder)this; } public TBuilder AddTags(IEnumerable<NamespacedKey> newTags) { foreach (NamespacedKey newTag in newTags) { AddTag(newTag); } return (TBuilder)this; } internal override void SoloAddTags(IEnumerable<NamespacedKey> newTags) { AddTags(newTags); } public TBuilder EditCustomData(Action<IDataContainer> 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<NamespacedKey, object> dictionary = new Dictionary<NamespacedKey, object>(); public IEnumerable<NamespacedKey> Keys => dictionary.Keys; public int Count => dictionary.Count; public bool Has(NamespacedKey key) { return dictionary.ContainsKey(key); } public bool TryGet<T>(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<T>(); 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<T>(NamespacedKey key, T defaultValue) { if (TryGet<T>(key, out T value)) { return value; } Set(key, defaultValue); return defaultValue; } public T GetOrCreateDefault<T>(NamespacedKey key) where T : new() { if (TryGet<T>(key, out T value)) { return value; } value = new T(); Set(key, value); return value; } public virtual void Set<T>(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 class FrozenEmptyDataContainer : IDataContainer { public static FrozenEmptyDataContainer Instance { get; private set; } = new FrozenEmptyDataContainer(); public IEnumerable<NamespacedKey> Keys { get; } = Array.Empty<NamespacedKey>(); public int Count => 0; private FrozenEmptyDataContainer() { } public bool TryGet<T>(NamespacedKey key, [NotNullWhen(true)] out T? value) { value = default(T); return false; } public T GetOrSetDefault<T>(NamespacedKey key, T defaultValue) { throw new RegistryFrozenException(); } public T GetOrCreateDefault<T>(NamespacedKey key) where T : new() { throw new RegistryFrozenException(); } public void Set<T>(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 interface IDataContainer { IEnumerable<NamespacedKey> Keys { get; } int Count { get; } bool TryGet<T>(NamespacedKey key, [NotNullWhen(true)] out T? value); T GetOrSetDefault<T>(NamespacedKey key, T defaultValue); T GetOrCreateDefault<T>(NamespacedKey key) where T : new(); void Set<T>(NamespacedKey key, T value); void Remove(NamespacedKey key); void Clear(); void MarkDirty(); IDisposable CreateEditContext(); } public interface INamespaced { NamespacedKey Key { get; } } public interface INamespaced<T> : INamespaced where T : INamespaced<T> { NamespacedKey<T> TypedKey { get; } } public class JSONTagDefinition { public string Tag; public string[] Values; } [Serializable] public class NamespacedKey : INetworkSerializable { private static readonly Regex NamespacedKeyRegex = new Regex("[?!.\\n\\t\"`\\[\\]'-]"); private static readonly Dictionary<char, string> NumberWords = new Dictionary<char, string> { { '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; internal static string NormalizeStringForNamespacedKey(string input, bool CSharpName) { if (string.IsNullOrEmpty(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(" ", ""); text4 = text4.Replace("_", ""); return text4.ToCapitalized(); } return text4.ToLowerInvariant().Replace(" ", "_"); } protected NamespacedKey(string @namespace, string key) { _namespace = @namespace; _key = key; } [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) { string[] array = input.Split(':'); return From(array[0], array[1]); } public static bool TryParse(string input, [NotNullWhen(true)] out NamespacedKey? result) { result = null; string[] array = input.Split(':'); if (array.Length != 2) { return false; } result = From(array[0], array[1]); return true; } public static NamespacedKey ForceParse(string input) { string[] array = input.Split(':'); if (array.Length == 1) { array = new string[2] { "lethal_company", array[0] }; } return From(array[0], array[1]); } public override string ToString() { return $"{Namespace}{':'}{Key}"; } public void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter { serializer.SerializeValue(ref _namespace, false); serializer.SerializeValue(ref _key, false); } public override bool Equals(object? obj) { if (obj == null) { return false; } NamespacedKey namespacedKey = (NamespacedKey)obj; if (Namespace == namespacedKey.Namespace) { return Key == namespacedKey.Key; } return false; } public override int GetHashCode() { int num = 13; num = num * 17 + Namespace.GetHashCode(); return num * 17 + Key.GetHashCode(); } public NamespacedKey<T> AsTyped<T>() where T : INamespaced { return NamespacedKey<T>.From(Namespace, Key); } public bool IsVanilla() { return Namespace == "lethal_company"; } public bool IsModded() { return !IsVanilla(); } } [Serializable] public class NamespacedKey<T> : NamespacedKey where T : INamespaced { protected NamespacedKey(string @namespace, string key) : base(@namespace, key) { } [EditorBrowsable(EditorBrowsableState.Never)] public NamespacedKey() { } public new static NamespacedKey<T> From(string @namespace, string key) { return new NamespacedKey<T>(@namespace, key); } public new static NamespacedKey<T> Vanilla(string key) { return From("lethal_company", key); } public new static NamespacedKey<T> Parse(string input) { string[] array = input.Split(':'); return From(array[0], array[1]); } } 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<object> list = new List<object>(); 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 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<PersistentDataContainer> HasCorruptedData { get; private set; } = new List<PersistentDataContainer>(); 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<Dictionary<NamespacedKey, object>>(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; } 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<T>(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 ((object)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<Task?>)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<Task?>)SaveAsync); } private async Task SaveAsync() { Debuggers.PersistentDataContainer?.Log("saving (" + Path.GetFileName(_filePath) + ")"); await _saveLock.WaitAsync().ConfigureAwait(continueOnCapturedContext: false); try { FileStream stream = new FileStream(_filePath, FileMode.Create, FileAccess.Write, FileShare.None, 4096, useAsync: true); try { 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) + ")"); } finally { if (stream != null) { await stream.DisposeAsync(); } } } 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<T> : INamespaced<T>, INamespaced, ITaggable, IRegistryEvents where T : DawnBaseInfo<T> { private HashSet<NamespacedKey> _tags; private IDataContainer? _customData; public IDataContainer CustomData { get { if (_customData == null) { _customData = new DataContainer(); } return _customData; } } public NamespacedKey Key => TypedKey; public NamespacedKey<T> TypedKey { get; } protected DawnBaseInfo(NamespacedKey<T> key, HashSet<NamespacedKey> tags, IDataContainer? customData) { TypedKey = key; _tags = tags; _customData = customData; } public bool HasTag(NamespacedKey tag) { return _tags.Contains(tag); } public IEnumerable<NamespacedKey> 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; } } internal bool ShouldSkipIgnoreOverride() { if (!Key.IsVanilla() && !HasTag(DawnLibTags.IsExternal)) { return HasTag(Tags.Unimplemented); } return true; } internal bool ShouldSkipRespectOverride() { if (ShouldSkipIgnoreOverride()) { return !HasTag(DawnLibTags.LunarConfig); } return false; } } public class DawnInfoContainer<T> : MonoBehaviour where T : DawnBaseInfo<T> { 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<JsonConverter>(3) { (JsonConverter)(object)new NamespacedKeyConverter(), (JsonConverter)(object)new NamespacedKeyDictionaryConverter(), (JsonConverter)(object)new Vector3Converter() } }; private static PersistentDataContainer? _profileContainer; public static PersistentDataContainer? GetCurrentSave() { return NetworkSingleton<DawnNetworker>.Instance?.SaveContainer; } public static PersistentDataContainer? GetCurrentContract() { return NetworkSingleton<DawnNetworker>.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 prefab) { if (!Object.op_Implicit((Object)(object)prefab)) { throw new ArgumentNullException("prefab"); } MiscFixesPatch.tilesToFixSockets.Add(prefab); } public static DawnDungeonInfo DefineDungeon(NamespacedKey<DawnDungeonInfo> key, DungeonFlow dungeonFlow, Action<DungeonFlowInfoBuilder> callback) { DungeonFlowInfoBuilder dungeonFlowInfoBuilder = new DungeonFlowInfoBuilder(key, dungeonFlow); callback(dungeonFlowInfoBuilder); DawnDungeonInfo dawnDungeonInfo = dungeonFlowInfoBuilder.Build(); dungeonFlow.SetDawnInfo(dawnDungeonInfo); LethalContent.Dungeons.Register(dawnDungeonInfo); return dawnDungeonInfo; } public static DawnTileSetInfo DefineTileSet(NamespacedKey<DawnTileSetInfo> key, TileSet tileSet, Action<TilesetInfoBuilder> callback) { TilesetInfoBuilder tilesetInfoBuilder = new TilesetInfoBuilder(key, tileSet); callback(tilesetInfoBuilder); DawnTileSetInfo dawnTileSetInfo = tilesetInfoBuilder.Build(); tileSet.SetDawnInfo(dawnTileSetInfo); LethalContent.TileSets.Register(dawnTileSetInfo); return dawnTileSetInfo; } public static DawnMapObjectInfo DefineMapObject(NamespacedKey<DawnMapObjectInfo> key, GameObject mapObject, Action<MapObjectInfoBuilder> callback) { MapObjectInfoBuilder mapObjectInfoBuilder = new MapObjectInfoBuilder(key, mapObject); callback(mapObjectInfoBuilder); DawnMapObjectInfo dawnMapObjectInfo = mapObjectInfoBuilder.Build(); DawnMapObjectNamespacedKeyContainer dawnMapObjectNamespacedKeyContainer = mapObject.AddComponent<DawnMapObjectNamespacedKeyContainer>(); dawnMapObjectNamespacedKeyContainer.Value = dawnMapObjectInfo.TypedKey; LethalContent.MapObjects.Register(dawnMapObjectInfo); return dawnMapObjectInfo; } public static DawnUnlockableItemInfo DefineUnlockable(NamespacedKey<DawnUnlockableItemInfo> key, UnlockableItem unlockableItem, Action<UnlockableInfoBuilder> callback) { UnlockableInfoBuilder unlockableInfoBuilder = new UnlockableInfoBuilder(key, unlockableItem); callback(unlockableInfoBuilder); DawnUnlockableItemInfo dawnUnlockableItemInfo = unlockableInfoBuilder.Build(); unlockableItem.SetDawnInfo(dawnUnlockableItemInfo); LethalContent.Unlockables.Register(dawnUnlockableItemInfo); return dawnUnlockableItemInfo; } public static DawnItemInfo DefineItem(NamespacedKey<DawnItemInfo> key, Item item, Action<ItemInfoBuilder> callback) { ItemInfoBuilder itemInfoBuilder = new ItemInfoBuilder(key, item); callback(itemInfoBuilder); DawnItemInfo dawnItemInfo = itemInfoBuilder.Build(); item.SetDawnInfo(dawnItemInfo); LethalContent.Items.Register(dawnItemInfo); return dawnItemInfo; } public static DawnEnemyInfo DefineEnemy(NamespacedKey<DawnEnemyInfo> key, EnemyType enemy, Action<EnemyInfoBuilder> callback) { EnemyInfoBuilder enemyInfoBuilder = new EnemyInfoBuilder(key, enemy); callback(enemyInfoBuilder); DawnEnemyInfo dawnEnemyInfo = enemyInfoBuilder.Build(); enemy.SetDawnInfo(dawnEnemyInfo); LethalContent.Enemies.Register(dawnEnemyInfo); return dawnEnemyInfo; } public static DawnMoonInfo DefineMoon(NamespacedKey<DawnMoonInfo> key, SelectableLevel level, Action<MoonInfoBuilder> callback) { MoonInfoBuilder moonInfoBuilder = new MoonInfoBuilder(key, level); callback(moonInfoBuilder); DawnMoonInfo dawnMoonInfo = moonInfoBuilder.Build(); level.SetDawnInfo(dawnMoonInfo); LethalContent.Moons.Register(dawnMoonInfo); return dawnMoonInfo; } public static void ApplyTag(JSONTagDefinition definition) { JSONTagDefinition definition2 = definition; NamespacedKey namespacedKey2 = NamespacedKey.Parse(definition2.Tag); ListenToRegistry<DawnMoonInfo>(LethalContent.Moons, namespacedKey2); ListenToRegistry<DawnMapObjectInfo>(LethalContent.MapObjects, namespacedKey2); ListenToRegistry<DawnEnemyInfo>(LethalContent.Enemies, namespacedKey2); ListenToRegistry<DawnItemInfo>(LethalContent.Items, namespacedKey2); ListenToRegistry<DawnWeatherEffectInfo>(LethalContent.Weathers, namespacedKey2); ListenToRegistry<DawnDungeonInfo>(LethalContent.Dungeons, namespacedKey2); ListenToRegistry<DawnUnlockableItemInfo>(LethalContent.Unlockables, namespacedKey2); Debuggers.Tags?.Log($"Scheduled applying tag: {namespacedKey2}"); void ListenToRegistry<T>(TaggedRegistry<T> registry, NamespacedKey namespacedKey) where T : notnull, DawnBaseInfo<T> { TaggedRegistry<T> registry2 = registry; NamespacedKey namespacedKey3 = namespacedKey; registry2.OnFreeze += delegate { string[] values = definition2.Values; foreach (string input in values) { if (registry2.TryGetValue(NamespacedKey.Parse(input), out var value)) { value.Internal_AddTag(namespacedKey3); } } }; } } public static void ApplyAllTagsInFolder(string path) { string[] files = Directory.GetFiles(path, "*.tag.json", SearchOption.AllDirectories); foreach (string path2 in files) { JSONTagDefinition definition = JsonConvert.DeserializeObject<JSONTagDefinition>(File.ReadAllText(path2)); ApplyTag(definition); } } } public class DawnNamespacedKeyContainer<T> : MonoBehaviour where T : NamespacedKey { public T Value { get; internal set; } } internal static class DungeonRegistrationHandler { [CompilerGenerated] private static class <>O { public static hook_Awake <0>__RegisterDawnDungeons; public static Action <1>__AddDawnDungeonsToMoons; public static Action <2>__CollectNonDawnDungeons; public static hook_SetPlanetsWeather <3>__UpdateAllDungeonWeights; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static hook_Start <>9__0_0; public static hook_Generate <>9__0_1; public static Func<IndoorMapType, DungeonFlow> <>9__3_0; internal void <Init>b__0_0(orig_Start orig, RuntimeDungeon self) { self.GenerateOnStart = false; orig.Invoke(self); } internal void <Init>b__0_1(orig_Generate orig, RuntimeDungeon self) { TryInjectTileSets(self.Generator.DungeonFlow); orig.Invoke(self); } internal DungeonFlow <AddDawnDungeonsToMoons>b__3_0(IndoorMapType t) { return t.dungeonFlow; } } private static readonly Dictionary<string, string> _internalToHumanDungeonNames = new Dictionary<string, string> { { "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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Expected O, but got Unknown //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: 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(); } LethalContent.Moons.OnFreeze += AddDawnDungeonsToMoons; LethalContent.Moons.OnFreeze += CollectNonDawnDungeons; object obj2 = <>O.<3>__UpdateAllDungeonWeights; if (obj2 == null) { hook_SetPlanetsWeather val3 = UpdateAllDungeonWeights; <>O.<3>__UpdateAllDungeonWeights = val3; obj2 = (object)val3; } StartOfRound.SetPlanetsWeather += (hook_SetPlanetsWeather)obj2; object obj3 = <>c.<>9__0_0; if (obj3 == null) { hook_Start val4 = delegate(orig_Start orig, RuntimeDungeon self) { self.GenerateOnStart = false; orig.Invoke(self); }; <>c.<>9__0_0 = val4; obj3 = (object)val4; } RuntimeDungeon.Start += (hook_Start)obj3; object obj4 = <>c.<>9__0_1; if (obj4 == null) { hook_Generate val5 = delegate(orig_Generate orig, RuntimeDungeon self) { TryInjectTileSets(self.Generator.DungeonFlow); orig.Invoke(self); }; <>c.<>9__0_1 = val5; obj4 = (object)val5; } RuntimeDungeon.Generate += (hook_Generate)obj4; } private static void UpdateAllDungeonWeights(orig_SetPlanetsWeather orig, StartOfRound self, int connectedPlayersOnServer) { orig.Invoke(self, connectedPlayersOnServer); UpdateDungeonWeightOnLevel(self.currentLevel); } internal static void UpdateDungeonWeightOnLevel(SelectableLevel level) { 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 dawnInfo = RoundManagerRefs.Instance.dungeonFlowTypes[val.id].dungeonFlow.GetDawnInfo(); if (!dawnInfo.ShouldSkipRespectOverride()) { val.rarity = (dawnInfo.Weights?.GetFor(level.GetDawnInfo())).GetValueOrDefault(); } } } private static void AddDawnDungeonsToMoons() { //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Expected O, but got Unknown foreach (DawnMoonInfo value in LethalContent.Moons.Values) { List<IntWithRarity> list = value.Level.dungeonFlowTypes.ToList(); foreach (DawnDungeonInfo value2 in LethalContent.Dungeons.Values) { if (!value2.ShouldSkipIgnoreOverride()) { int id = Array.IndexOf(RoundManagerRefs.Instance.dungeonFlowTypes.Select((IndoorMapType t) => t.dungeonFlow).ToArray(), value2.DungeonFlow); IntWithRarity item = new IntWithRarity { id = id, rarity = 0 }; list.Add(item); } } value.Level.dungeonFlowTypes = list.ToArray(); } } private static void RegisterDawnDungeons(orig_Awake orig, StartOfRound self) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown List<IndoorMapType> list = RoundManagerRefs.Instance.dungeonFlowTypes.ToList(); foreach (DawnDungeonInfo value in LethalContent.Dungeons.Values) { if (!value.ShouldSkipIgnoreOverride()) { IndoorMapType item = new IndoorMapType { dungeonFlow = value.DungeonFlow, MapTileSize = value.MapTileSize, firstTimeAudio = value.FirstTimeAudio }; list.Add(item); } } RoundManagerRefs.Instance.dungeonFlowTypes = list.ToArray(); orig.Invoke(self); } private static void CollectNonDawnDungeons() { Dictionary<string, WeightTableBuilder<DawnMoonInfo>> dictionary = new Dictionary<string, WeightTableBuilder<DawnMoonInfo>>(); foreach (DawnMoonInfo value3 in LethalContent.Moons.Values) { SelectableLevel level = value3.Level; IntWithRarity[] dungeonFlowTypes = level.dungeonFlowTypes; foreach (IntWithRarity val in dungeonFlowTypes) { DungeonFlow dungeonFlow = RoundManagerRefs.Instance.dungeonFlowTypes[val.id].dungeonFlow; if (!dictionary.TryGetValue(((Object)dungeonFlow).name, out var value)) { value = new WeightTableBuilder<DawnMoonInfo>(); dictionary[((Object)dungeonFlow).name] = value; } Debuggers.Dungeons?.Log($"Grabbing weight {val.rarity} to {((Object)dungeonFlow).name} on level {level.PlanetName}"); value.AddWeight(value3.TypedKey, val.rarity); } } IndoorMapType[] dungeonFlowTypes2 = RoundManagerRefs.Instance.dungeonFlowTypes; foreach (IndoorMapType val2 in dungeonFlowTypes2) { if (val2 == null || (Object)(object)val2.dungeonFlow == (Object)null || val2.dungeonFlow.HasDawnInfo()) { continue; } string name = FormatFlowName(val2.dungeonFlow); NamespacedKey<DawnDungeonInfo> namespacedKey = DungeonKeys.GetByReflection(name); if (namespacedKey == null && LethalLevelLoaderCompat.Enabled && LethalLevelLoaderCompat.TryGetExtendedDungeonModName(val2.dungeonFlow, out string modName)) { namespacedKey = NamespacedKey<DawnDungeonInfo>.From(NamespacedKey.NormalizeStringForNamespacedKey(modName, CSharpName: false), NamespacedKey.NormalizeStringForNamespacedKey(((Object)val2.dungeonFlow).name, CSharpName: false)); } else if (namespacedKey == null) { namespacedKey = NamespacedKey<DawnDungeonInfo>.From("unknown_modded", NamespacedKey.NormalizeStringForNamespacedKey(((Object)val2.dungeonFlow).name, CSharpName: false)); } if (LethalContent.Dungeons.ContainsKey(namespacedKey)) { Debuggers.Dungeons?.Log($"LethalContent.Dungeons already contains {namespacedKey}"); val2.dungeonFlow.SetDawnInfo(LethalContent.Dungeons[namespacedKey]); continue; } HashSet<NamespacedKey> tags = new HashSet<NamespacedKey> { DawnLibTags.IsExternal }; CollectLLLTags(val2.dungeonFlow, tags); dictionary.TryGetValue(((Object)val2.dungeonFlow).name, out var value2); if (value2 == null) { value2 = new WeightTableBuilder<DawnMoonInfo>(); } DawnDungeonInfo dawnDungeonInfo = new DawnDungeonInfo(namespacedKey, tags, val2.dungeonFlow, value2.Build(), val2.MapTileSize, val2.firstTimeAudio, null); val2.dungeonFlow.SetDawnInfo(dawnDungeonInfo); LethalContent.Dungeons.Register(dawnDungeonInfo); } 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<DawnArchetypeInfo> namespacedKey; if (value.Key.IsVanilla()) { string name = FormatArchetypeName(val); namespacedKey = DungeonArchetypeKeys.GetByReflection(name); 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!"); continue; } } else { namespacedKey = NamespacedKey<DawnArchetypeInfo>.From(value.Key.Namespace, NamespacedKey.NormalizeStringForNamespacedKey(((Object)val).name, CSharpName: false)); } if (LethalContent.Archetypes.ContainsKey(namespacedKey)) { Debuggers.Dungeons?.Log($"LethalContent.Archetypes already contains {namespacedKey}"); val.SetDawnInfo(LethalContent.Archetypes[namespacedKey]); continue; } DawnArchetypeInfo dawnArchetypeInfo = new DawnArchetypeInfo(namespacedKey, new HashSet<NamespacedKey> { DawnLibTags.IsExternal }, val, null); val.SetDawnInfo(dawnArchetypeInfo); dawnArchetypeInfo.ParentInfo = value; LethalContent.Archetypes.Register(dawnArchetypeInfo); List<TileSet> tileSets = val.TileSets; List<TileSet> branchCapTileSets = val.BranchCapTileSets; int num = 0; TileSet[] array = (TileSet[])(object)new TileSet[tileSets.Count + branchCapTileSets.Count]; foreach (TileSet item in tileSets) { array[num] = item; num++; } foreach (TileSet item2 in branchCapTileSets) { array[num] = item2; num++; } IEnumerable<TileSet> enumerable = new <>z__ReadOnlyArray<TileSet>(array); foreach (TileSet item3 in enumerable) { Debuggers.Dungeons?.Log("tileSet.name: " + ((Object)item3).name); NamespacedKey<DawnTileSetInfo> namespacedKey2; if (value.Key.IsVanilla()) { string name2 = FormatTileSetName(item3); namespacedKey2 = DungeonTileSetKeys.GetByReflection(name2); if (namespacedKey2 == null) { DawnPlugin.Logger.LogWarning((object)$"tileset: '{((Object)item3).name}' (part of {namespacedKey}) is vanilla, but DawnLib couldn't get a corresponding NamespacedKey!"); continue; } } else { namespacedKey2 = NamespacedKey<DawnTileSetInfo>.From(value.Key.Namespace, NamespacedKey.NormalizeStringForNamespacedKey(((Object)val).name, CSharpName: false)); } if (LethalContent.TileSets.ContainsKey(namespacedKey2)) { Debuggers.Dungeons?.Log($"LethalContent.TileSets already contains {namespacedKey2}"); item3.SetDawnInfo(LethalContent.TileSets[namespacedKey2]); continue; } DawnTileSetInfo dawnTileSetInfo = new DawnTileSetInfo(namespacedKey2, new HashSet<NamespacedKey> { DawnLibTags.IsExternal }, ConstantPredicate.True, item3, val.BranchCapTileSets.Contains(item3), val.TileSets.Contains(item3), null); dawnArchetypeInfo.AddTileSet(dawnTileSetInfo); item3.SetDawnInfo(dawnTileSetInfo); LethalContent.TileSets.Register(dawnTileSetInfo); } } } LethalContent.Archetypes.Freeze(); LethalContent.TileSets.Freeze(); } 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) { foreach (KeyValuePair<string, string> internalToHumanDungeonName in _internalToHumanDungeonNames) { internalToHumanDungeonName.Deconstruct(out var key, out var value); string oldValue = key; string newValue = value; input = input.Replace(oldValue, newValue); } return input; } private static void CollectLLLTags(DungeonFlow dungeonFlow, HashSet<NamespacedKey> tags) { if (LethalLevelLoaderCompat.Enabled && LethalLevelLoaderCompat.TryGetAllTagsWithModNames(dungeonFlow, out List<(string, string)> allTagsWithModNames)) { tags.AddToList(allTagsWithModNames, Debuggers.Dungeons, ((Object)dungeonFlow).name); } } internal static void TryInjectTileSets(DungeonFlow dungeonFlow) { DungeonArchetype[] usedArchetypes = dungeonFlow.GetUsedArchetypes(); foreach (DungeonArchetype val in usedArchetypes) { foreach (DawnTileSetInfo tileSet in val.GetDawnInfo().TileSets) { if (tileSet.ShouldSkipIgnoreOverride()) { continue; } if (val.BranchCapTileSets.Contains(tileSet.TileSet)) { val.BranchCapTileSets.Remove(tileSet.TileSet); } if (val.TileSets.Contains(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); } } } } } } public class DawnArchetypeInfo : DawnBaseInfo<DawnArchetypeInfo> { private List<DawnTileSetInfo> _tileSets = new List<DawnTileSetInfo>(); public DungeonArchetype DungeonArchetype { get; } public IReadOnlyList<DawnTileSetInfo> TileSets => _tileSets.AsReadOnly(); public DawnDungeonInfo ParentInfo { get; internal set; } internal DawnArchetypeInfo(NamespacedKey<DawnArchetypeInfo> key, HashSet<NamespacedKey> 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 class DawnDungeonInfo : DawnBaseInfo<DawnDungeonInfo> { private List<DoorwaySocket> _sockets; public DungeonFlow DungeonFlow { get; } public ProviderTable<int?, DawnMoonInfo>? Weights { get; } public float MapTileSize { get; } public AudioClip? FirstTimeAudio { get; } public IReadOnlyList<DoorwaySocket> Sockets => _sockets.AsReadOnly(); internal DawnDungeonInfo(NamespacedKey<DawnDungeonInfo> key, HashSet<NamespacedKey> tags, DungeonFlow dungeonFlow, ProviderTable<int?, DawnMoonInfo>? weights, float mapTileSize, AudioClip? firstTimeAudio, IDataContainer? customData) : base(key, tags, customData) { DungeonFlow = dungeonFlow; Weights = weights; MapTileSize = mapTileSize; firstTimeAudio = FirstTimeAudio; _sockets = new List<DoorwaySocket>(); foreach (GameObjectChance item in (from it in DungeonFlow.GetUsedTileSets() select it.TileWeights.Weights).SelectMany((List<GameObjectChance> it) => it)) { Doorway[] componentsInChildren = item.Value.GetComponentsInChildren<Doorway>(); Doorway[] array = componentsInChildren; foreach (Doorway val in array) { if (!Sockets.Contains(val.socket)) { _sockets.Add(val.socket); } } } } } public class DawnTileSetInfo : DawnBaseInfo<DawnTileSetInfo> { public TileSet TileSet { get; } public bool IsBranchCap { get; } public bool IsRegular { get; } public IPredicate InjectionPredicate { get; } internal DawnTileSetInfo(NamespacedKey<DawnTileSetInfo> key, HashSet<NamespacedKey> tags, IPredicate injectionRule, TileSet tileSet, bool isBranchCap, bool isRegular, IDataContainer? customData) : base(key, tags, customData) { TileSet = tileSet; IsBranchCap = isBranchCap; IsRegular = isRegular; InjectionPredicate = injectionRule; } } public static class DungeonArchetypeExtensions { public static DawnArchetypeInfo GetDawnInfo(this DungeonArchetype archetype) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return (DawnArchetypeInfo)((IDawnObject)archetype).DawnInfo; } internal static bool HasDawnInfo(this DungeonArchetype archetype) { return archetype.GetDawnInfo() != null; } internal static void SetDawnInfo(this DungeonArchetype archetype, DawnArchetypeInfo archetypeInfo) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) ((IDawnObject)archetype).DawnInfo = archetypeInfo; } } public static class DungeonFlowExtensions { public static DawnDungeonInfo GetDawnInfo(this DungeonFlow dungeonFlow) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return (DawnDungeonInfo)((IDawnObject)dungeonFlow).DawnInfo; } internal static bool HasDawnInfo(this DungeonFlow dungeonFlow) { return dungeonFlow.GetDawnInfo() != null; } internal static void SetDawnInfo(this DungeonFlow dungeonFlow, DawnDungeonInfo dungeonInfo) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) ((IDawnObject)dungeonFlow).DawnInfo = dungeonInfo; } } public class DungeonFlowInfoBuilder : BaseInfoBuilder<DawnDungeonInfo, DungeonFlow, DungeonFlowInfoBuilder> { private float _mapTileSize; private AudioClip? _firstTimeAudio; private ProviderTable<int?, DawnMoonInfo>? _weights; internal DungeonFlowInfoBuilder(NamespacedKey<DawnDungeonInfo> key, DungeonFlow value) : base(key, value) { } public DungeonFlowInfoBuilder SetMapTileSize(float mapTileSize) { _mapTileSize = mapTileSize; return this; } public DungeonFlowInfoBuilder SetFirstTimeAudio(AudioClip firstTimeAudio) { _firstTimeAudio = firstTimeAudio; return this; } public DungeonFlowInfoBuilder SetWeights(Action<WeightTableBuilder<DawnMoonInfo>> callback) { WeightTableBuilder<DawnMoonInfo> weightTableBuilder = new WeightTableBuilder<DawnMoonInfo>(); callback(weightTableBuilder); _weights = weightTableBuilder.Build(); return this; } internal override DawnDungeonInfo Build() { return new DawnDungeonInfo(base.key, new HashSet<NamespacedKey>(), base.value, _weights, _mapTileSize, _firstTimeAudio, customData); } } public static class TileSetExtensions { public static DawnTileSetInfo GetDawnInfo(this TileSet tileSet) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) return (DawnTileSetInfo)((IDawnObject)tileSet).DawnInfo; } internal static bool HasDawnInfo(this TileSet tileSet) { return tileSet.GetDawnInfo() != null; } internal static void SetDawnInfo(this TileSet tileSet, DawnTileSetInfo tileSetInfo) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) ((IDawnObject)tileSet).DawnInfo = tileSetInfo; } } public class TilesetInfoBuilder : BaseInfoBuilder<DawnTileSetInfo, TileSet, TilesetInfoBuilder> { private bool _branchCap; private bool _regular = true; private IPredicate? _predicate; internal TilesetInfoBuilder(NamespacedKey<DawnTileSetInfo> 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<NamespacedKey>(), _predicate, base.value, _branchCap, _regular, customData); } } internal static class EnemyRegistrationHandler { [CompilerGenerated] private static class <>O { public static hook_RefreshEnemiesList <0>__UpdateEnemyWeights; public static hook_SetPlanetsWeather <1>__UpdateEnemyWeights; public static hook_Start <2>__EnsureCorrectEnemyVariables; public static hook_Start <3>__AddEnemiesToDebugList; public static hook_Awake <4>__AddBestiaryNodes; public static hook_Start <5>__CollectAllEnemyTypes; public static Action <6>__RegisterEnemies; public static Action <7>__RedoEnemiesDebugMenu; } private static List<EnemyType> _networkPrefabEnemyTypes = new List<EnemyType>(); 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_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Expected O, but got Unknown LethalContent.Enemies.AddAutoTaggers(new SimpleAutoTagger<DawnEnemyInfo>(Tags.Killable, (DawnEnemyInfo info) => info.EnemyType.canDie), new SimpleAutoTagger<DawnEnemyInfo>(Tags.Small, (DawnEnemyInfo info) => (int)info.EnemyType.EnemySize == 0), new SimpleAutoTagger<DawnEnemyInfo>(Tags.Medium, (DawnEnemyInfo info) => (int)info.EnemyType.EnemySize == 2), new SimpleAutoTagger<DawnEnemyInfo>(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>__UpdateEnemyWeights; if (obj2 == null) { hook_SetPlanetsWeather val2 = UpdateEnemyWeights; <>O.<1>__UpdateEnemyWeights = val2; obj2 = (object)val2; } StartOfRound.SetPlanetsWeather += (hook_SetPlanetsWeather)obj2; object obj3 = <>O.<2>__EnsureCorrectEnemyVariables; if (obj3 == null) { hook_Start val3 = EnsureCorrectEnemyVariables; <>O.<2>__EnsureCorrectEnemyVariables = val3; obj3 = (object)val3; } EnemyAI.Start += (hook_Start)obj3; object obj4 = <>O.<3>__AddEnemiesToDebugList; if (obj4 == null) { hook_Start val4 = AddEnemiesToDebugList; <>O.<3>__AddEnemiesToDebugList = val4; obj4 = (object)val4; } QuickMenuManager.Start += (hook_Start)obj4; DetourContext val5 = new DetourContext(int.MaxValue); try { object obj5 = <>O.<4>__AddBestiaryNodes; if (obj5 == null) { hook_Awake val6 = AddBestiaryNodes; <>O.<4>__AddBestiaryNodes = val6; obj5 = (object)val6; } Terminal.Awake += (hook_Awake)obj5; object obj6 = <>O.<5>__CollectAllEnemyTypes; if (obj6 == null) { hook_Start val7 = CollectAllEnemyTypes; <>O.<5>__CollectAllEnemyTypes = val7; obj6 = (object)val7; } GameNetworkManager.Start += (hook_Start)obj6; } finally { ((IDisposable)val5)?.Dispose(); } LethalContent.Moons.OnFreeze += RegisterEnemies; LethalContent.Enemies.OnFreeze += RedoEnemiesDebugMenu; } 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<EnemyAI>(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.op_Implicit((Object)(object)value.BestiaryNode) && Object.op_Implicit((Object)(object)value.NameKeyword)) { AddScanNodeToBestiaryEvent(value.EnemyType.enemyPrefab, value.BestiaryNode, value.NameKeyword); } } orig.Invoke(self); } private static void AddScanNodeToBestiaryEvent(GameObject gameObjectWithScanNodes, TerminalNode bestiaryNode, TerminalKeyword nameKeyword) { //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown List<TerminalKeyword> list = TerminalRefs.Instance.terminalNodes.allKeywords.ToList(); List<CompatibleNoun> list2 = TerminalRefs.InfoKeyword.compatibleNouns.ToList(); bestiaryNode.creatureFileID = TerminalRefs.Instance.enemyFiles.Count; TerminalRefs.Instance.enemyFiles.Add(bestiaryNode); ScanNodeProperties[] componentsInChildren = gameObjectWithScanNodes.GetComponentsInChildren<ScanNodeProperties>(); 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 { noun = nameKeyword, result = bestiaryNode }); TerminalRefs.InfoKeyword.compatibleNouns = list2.ToArray(); TerminalRefs.Instance.terminalNodes.allKeywords = list.ToArray(); } } private static void AddEnemiesToDebugList(orig_Start orig, QuickMenuManager self) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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 { enemyType = enemyInfo.EnemyType, rarity = 0 }; if (enemyInfo.Inside != null && 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 (enemyInfo.Outside != null && 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 (enemyInfo.Daytime != null && 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); } } } orig.Invoke(self); } private static void EnsureCorrectEnemyVariables(orig_Start orig, EnemyAI self) { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) if (!self.enemyType.HasDawnInfo()) { 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 dawnInfo = self.enemyType.GetDawnInfo(); if (dawnInfo.ShouldSkipRespectOverride() || StarlancerAIFixCompat.Enabled) { orig.Invoke(self); return; } if (dawnInfo.Daytime != null) { self.enemyType.isDaytimeEnemy = true; } GameObject[] insideAINodes = RoundManager.Instance.insideAINodes; GameObject[] outsideAINodes = RoundManager.Instance.outsideAINodes; bool flag = true; float num = float.MaxValue; if (insideAINodes != null) { GameObject[] array = insideAINodes; foreach (GameObject val in array) { 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) { 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_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Expected O, but got Unknown //IL_013b: 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_0151: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: 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_01de: Expected O, but got Unknown if (!LethalContent.Weathers.IsFrozen || !LethalContent.Enemies.IsFrozen || (Object)(object)StartOfRound.Instance == (Object)null || (WeatherRegistryCompat.Enabled && !WeatherRegistryCompat.IsWeatherManagerReady())) { return; } foreach (DawnEnemyInfo enemyInfo in LethalContent.Enemies.Values) { if (enemyInfo.ShouldSkipRespectOverride()) { continue; } Debuggers.Enemies?.Log($"Updating weights for {enemyInfo.EnemyType} on level {level.PlanetName}"); if (enemyInfo.Outside != null) { SpawnableEnemyWithRarity val = ((IEnumerable<SpawnableEnemyWithRarity>)level.OutsideEnemies).FirstOrDefault((Func<SpawnableEnemyWithRarity, bool>)((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)enemyInfo.EnemyType)); if (val == null) { val = new SpawnableEnemyWithRarity { enemyType = enemyInfo.EnemyType, rarity = 0 }; level.OutsideEnemies.Add(val); } val.rarity = enemyInfo.Outside.Weights.GetFor(level.GetDawnInfo()).GetValueOrDefault(); } if (enemyInfo.Inside != null) { SpawnableEnemyWithRarity val2 = ((IEnumerable<SpawnableEnemyWithRarity>)level.Enemies).FirstOrDefault((Func<SpawnableEnemyWithRarity, bool>)((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)enemyInfo.EnemyType)); if (val2 == null) { val2 = new SpawnableEnemyWithRarity { enemyType = enemyInfo.EnemyType, rarity = 0 }; level.Enemies.Add(val2); } int valueOrDefault = enemyInfo.Inside.Weights.GetFor(level.GetDawnInfo()).GetValueOrDefault(); val2.rarity = valueOrDefault; } if (enemyInfo.Daytime != null) { SpawnableEnemyWithRarity val3 = ((IEnumerable<SpawnableEnemyWithRarity>)level.DaytimeEnemies).FirstOrDefault((Func<SpawnableEnemyWithRarity, bool>)((SpawnableEnemyWithRarity x) => (Object)(object)x.enemyType == (Object)(object)enemyInfo.EnemyType)); if (val3 == null) { val3 = new SpawnableEnemyWithRarity { enemyType = enemyInfo.EnemyType, rarity = 0 }; level.DaytimeEnemies.Add(val3); } val3.rarity = enemyInfo.Daytime.Weights.GetFor(level.GetDawnInfo()).GetValueOrDefault(); } } } private static void RegisterEnemies() { Dictionary<string, WeightTableBuilder<DawnMoonInfo>> dictionary = new Dictionary<string, WeightTableBuilder<DawnMoonInfo>>(); Dictionary<string, WeightTableBuilder<DawnMoonInfo>> dictionary2 = new Dictionary<string, WeightTableBuilder<DawnMoonInfo>>(); Dictionary<string, WeightTableBuilder<DawnMoonInfo>> dictionary3 = new Dictionary<string, WeightTableBuilder<DawnMoonInfo>>(); foreach (DawnMoonInfo value4 in LethalContent.Moons.Values) { SelectableLevel level = value4.Level; NamespacedKey<DawnMoonInfo> typedKey = value4.TypedKey; foreach (SpawnableEnemyWithRarity enemy in level.Enemies) { if (!((Object)(object)enemy.enemyType == (Object)null)) { if (!dictionary.TryGetValue(((Object)enemy.enemyType).name, out var value)) { value = new WeightTableBuilder<DawnMoonInfo>(); dictionary[((Object)enemy.enemyType).name] = value; } Debuggers.Enemies?.Log($"Adding inside weight {enemy.rarity} for {enemy.enemyType} on level {level.PlanetName}"); value.AddWeight(typedKey, enemy.rarity); } } foreach (SpawnableEnemyWithRarity outsideEnemy in level.OutsideEnemies) { if (!((Object)(object)outsideEnemy.enemyType == (Object)null)) { if (!dictionary2.TryGetValue(((Object)outsideEnemy.enemyType).name, out var value2)) { value2 = new WeightTableBuilder<DawnMoonInfo>(); dictionary2[((Object)outsideEnemy.enemyType).name] = value2; } Debuggers.Enemies?.Log($"Adding outside weight {outsideEnemy.rarity} for {outsideEnemy.enemyType} on level {level.PlanetName}"); value2.AddWeight(typedKey, outsideEnemy.rarity); } } foreach (SpawnableEnemyWithRarity daytimeEnemy in level.DaytimeEnemies) { if (!((Object)(object)daytimeEnemy.enemyType == (Object)null)) { if (!dictionary3.TryGetValue(((Object)daytimeEnemy.enemyType).name, out var value3)) { value3 = new WeightTableBuilder<DawnMoonInfo>(); dictionary3[((Object)daytimeEnemy.enemyType).name] = value3; } Debuggers.Enemies?.Log($"Adding daytime weight {daytimeEnemy.rarity} for {daytimeEnemy.enemyType} on level {level.PlanetName}"); value3.AddWeight(typedKey, daytimeEnemy.rarity); } } } TerminalKeyword infoKeyword = TerminalRefs.InfoKeyword; foreach (EnemyType networkPrefabEnemyType in _networkPrefabEnemyTypes) { if ((Object)(object)networkPrefabEnemyType == (Object)null || (Object)(object)networkPrefabEnemyType.enemyPrefab == (Object)null || networkPrefabEnemyType.HasDawnInfo()) { continue; } string name = NamespacedKey.NormalizeStringForNamespacedKey(networkPrefabEnemyType.enemyName, CSharpName: true); NamespacedKey<DawnEnemyInfo> namespacedKey = EnemyKeys.GetByReflection(name); string modName2; if (namespacedKey == null && LethalLibCompat.Enabled && LethalLibCompat.TryGetEnemyTypeFromLethalLib(networkPrefabEnemyType, out string modName)) { namespacedKey = NamespacedKey<DawnEnemyInfo>.From(NamespacedKey.NormalizeStringForNamespacedKey(modName, CSharpName: false), NamespacedKey.NormalizeStringForNamespacedKey(networkPrefabEnemyType.enemyName, CSharpName: false)); } else if (namespacedKey == null && LethalLevelLoaderCompat.Enabled && LethalLevelLoaderCompat.TryGetExtendedEnemyTypeModName(networkPrefabEnemyType, out modName2)) { namespacedKey = NamespacedKey<DawnEnemyInfo>.From(NamespacedKey.NormalizeStringForNamespacedKey(modName2, CSharpName: false), NamespacedKey.NormalizeStringForNamespacedKey(networkPrefabEnemyType.enemyName, CSharpName: false)); } else if (namespacedKey == null) { namespacedKey = NamespacedKey<DawnEnemyInfo>.From("unknown_lib", NamespacedKey.NormalizeStringForNamespacedKey(networkPrefabEnemyType.enemyName, CSharpName: false)); } 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.")); networkPrefabEnemyType.SetDawnInfo(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 inside = null; DawnEnemyLocationInfo outside = null; DawnEnemyLocationInfo daytime = null; if (dictionary.ContainsKey(((Object)networkPrefabEnemyType).name)) { inside = new DawnEnemyLocationInfo(dictionary[((Object)networkPrefabEnemyType).name].Build()); } if (dictionary2.ContainsKey(((Object)networkPrefabEnemyType).name)) { outside = new DawnEnemyLocationInfo(dictionary2[((Object)networkPrefabEnemyType).name].Build()); } if (dictionary3.ContainsKey(((Object)networkPrefabEnemyType).name)) { daytime = new DawnEnemyLocationInfo(dictionary3[((Object)networkPrefabEnemyType).name].Build()); } HashSet<NamespacedKey> tags = new HashSet<NamespacedKey> { DawnLibTags.IsExternal }; CollectLLLTags(networkPrefabEnemyType, tags); TerminalNode bestiaryNode = null; TerminalKeyword nameKeyword = null; ScanNodeProperties componentInChildren = networkPrefabEnemyType.enemyPrefab.GetComponentInChildren<ScanNodeProperties>(); if ((Object)(object)componentInChildren != (Object)null) { int creatureScanID = componentInChildren.creatureScanID; CompatibleNoun[] compatibleNouns = infoKeyword.compatibleNouns; foreach (CompatibleNoun val in compatibleNouns) { if (val.result.creatureFileID == creatureScanID) { bestiaryNode = val.result; nameKeyword = val.noun; } } } DawnEnemyInfo dawnEnemyInfo = new DawnEnemyInfo(namespacedKey, tags, networkPrefabEnemyType, outside, inside, daytime, bestiaryNode, nameKeyword, null); networkPrefabEnemyType.SetDawnInfo(dawnEnemyInfo); LethalContent.Enemies.Register(dawnEnemyInfo); } foreach (DawnMoonInfo value5 in LethalContent.Moons.Values) { SelectableLevel level2 = value5.Level; foreach (DawnEnemyInfo value6 in LethalContent.Enemies.Values) { if (!value6.ShouldSkipRespectOverride()) { if (value6.Outside != null) { TryAddToEnemyList(value6, level2.OutsideEnemies); } if (value6.Daytime != null) { TryAddToEnemyList(value6, level2.DaytimeEnemies); } if (value6.Inside != null) { TryAddToEnemyList(value6, level2.Enemies); } } } } LethalContent.Enemies.Freeze(); } private static void CollectLLLTags(EnemyType enemyType, HashSet<NamespacedKey> 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<SpawnableEnemyWithRarity> list) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Expected O, but got Unknown foreach (SpawnableEnemyWithRarity item2 in list) { if ((Object)(object)item2.enemyType == (Object)(object)enemyInfo.EnemyType) { return; } } SpawnableEnemyWithRarity item = new SpawnableEnemyWithRarity { enemyType = enemyInfo.EnemyType, rarity = 0 }; list.Add(item); } } public sealed class DawnEnemyInfo : DawnBaseInfo<DawnEnemyInfo> { [CompilerGenerated] private sealed class <GetAllSpawned>d__19<T> : IEnumerable<T>, IEnumerable, IEnumerator<T>, IEnumerator, IDisposable where T : EnemyAI { private int <>1__state; private T <>2__current; private int <>l__initialThreadId; public DawnEnemyInfo <>4__this; private List<EnemyAI>.Enumerator <>7__wrap1; T? IEnumerator<T>.Current { [DebuggerHidden] get { return <>2__current; } } object? IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <GetAllSpawned>d__19(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = default(List<EnemyAI>.Enumerator); <>1__state = -2; } private bool MoveNext() { try { int num = <>1__state; DawnEnemyInfo dawnEnemyInfo = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = RoundManager.Instance.SpawnedEnemies.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; } while (<>7__wrap1.MoveNext()) { EnemyAI current = <>7__wrap1.Current; if ((Object)(object)current.enemyType == (Object)(object)dawnEnemyInfo.EnemyType) { <>2__current = (T)(object)current; <>1__state = 1; return true; } } <>m__Finally1(); <>7__wrap1 = default(List<EnemyAI>.Enumerator); return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; ((IDisposable)<>7__wrap1).Dispose(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<T> IEnumerable<T>.GetEnumerator() { <GetAllSpawned>d__19<T> result; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; result = this; } else { result = new <GetAllSpawned>d__19<T>(0) { <>4__this = <>4__this }; } return result; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<T>)this).GetEnumerator(); } } public EnemyType EnemyType { get; } public DawnEnemyLocationInfo? Outside { get; } public DawnEnemyLocationInfo? Inside { get; } public DawnEnemyLocationInfo? Daytime { get; } public TerminalNode? BestiaryNode { get; } public TerminalKeyword? NameKeyword { get; } internal DawnEnemyInfo(NamespacedKey<DawnEnemyInfo> key, HashSet<NamespacedKey> tags, EnemyType enemyType, DawnEnemyLocationInfo? outside, DawnEnemyLocationInfo? inside, DawnEnemyLocationInfo? daytime, TerminalNode? bestiaryNode, TerminalKeyword? nameKeyword, IDataContainer? customData) : base(key, tags, customData) { EnemyType = enemyType; Outside = outside; if (Outside != null) { Outside.ParentInfo = this; } Inside = inside; if (Inside != null) { Inside.ParentInfo = this; } Daytime = daytime; if (Daytime != null) { Daytime.ParentInfo = this; } BestiaryNode = bestiaryNode; NameKeyword = nameKeyword; } [IteratorStateMachine(typeof(<GetAllSpawned>d__19<>))] public IEnumerable<T> GetAllSpawned<T>() where T : EnemyAI { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <GetAllSpawned>d__19<T>(-2) { <>4__this = this }; } } public sealed class DawnEnemyLocationInfo { public DawnEnemyInfo ParentInfo { get; internal set; } public ProviderTable<int?, DawnMoonInfo> Weights { get; private set; } internal DawnEnemyLocationInfo(ProviderTable<int?, DawnMoonInfo> weights) { Weights = weights; } } public class EnemyInfoBuilder : BaseInfoBuilder<DawnEnemyInfo, EnemyType, EnemyInfoBuilder> { public class EnemyLocationBuilder { private ProviderTable<int?, DawnMoonInfo>? _weights; private EnemyInfoBuilder _parent; public EnemyLocationBuilder SetWeights(Action<WeightTableBuilder<DawnMoonInfo>> callback) { WeightTableBuilder<DawnMoonInfo> weightTableBuilder = new WeightTableBuilder<DawnMoonInfo>(); callback(weightTableBuilder); _weights = weightTableBuilder.Build(); 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 = ProviderTable<int?, DawnMoonInfo>.Empty(); } return new DawnEnemyLocationInfo(_weights); } } private DawnEnemyLocationInfo? _inside; private DawnEnemyLocationInfo? _outside; private DawnEnemyLocationInfo? _daytime; private TerminalNode? _bestiaryNode; private TerminalKeyword? _nameKeyword; internal EnemyInfoBuilder(NamespacedKey<DawnEnemyInfo> key, EnemyType enemyType) : base(key, enemyType) { } public EnemyInfoBuilder DefineOutside(Action<EnemyLocationBuilder> callback) { EnemyLocationBuilder enemyLocationBuilder = new EnemyLocationBuilder(this); callback(enemyLocationBuilder); _outside = enemyLocationBuilder.Build(); return this; } public EnemyInfoBuilder DefineInside(Action<EnemyLocationBuilder> callback) { EnemyLocationBuilder enemyLocationBuilder = new EnemyLocationBuilder(this); callback(enemyLocationBuilder); _inside = enemyLocationBuilder.Build(); return this; } public EnemyInfoBuilder DefineDaytime(Action<EnemyLocationBuilder> callback) { EnemyLocationBuilder enemyLocationBuilder = new EnemyLocationBuilder(this); callback(enemyLocationBuilder); _daytime = 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 CreateNameKeyword(string wordOverride) { if (string.IsNullOrEmpty(wordOverride)) { wordOverride = base.value.enemyName.ToLowerInvariant().Replace(' ', '-'); } _nameKeyword = new TerminalKeywordBuilder(base.value.enemyName + "NameKeyword").SetWord(wordOverride).Build(); return this; } internal override DawnEnemyInfo Build() { return new DawnEnemyInfo(base.key, tags, base.value, _outside, _inside, _daytime, _bestiaryNode, _nameKeyword, customData); } } public static class EnemyTypeExtensions { public static DawnEnemyInfo GetDawnInfo(this EnemyType enemyType) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return (DawnEnemyInfo)((IDawnObject)enemyType).DawnInfo; } internal static bool HasDawnInfo(this EnemyType enemyType) { return enemyType.GetDawnInfo() != null; } internal static void SetDawnInfo(this EnemyType enemyType, DawnEnemyInfo enemyInfo) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((IDawnObject)enemyType).DawnInfo = enemyInfo; } } public class BundleException : Exception { public AssetBundle Bundle { get; } public BundleException(AssetBundle bundle, string message) { Bundle = bundle; base..ctor(message); } } public class MalformedAnimationCurveConfigException : Exception { public string Pair { get; } public MalformedAnimationCurveConfigException(string pair) { Pair = pair; base..ctor(); } 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<out T> { T Provide(); } public class SimpleProvider<T> : IProvider<T> { [CompilerGenerated] private T <value>P; public SimpleProvider(T value) { <value>P = value; base..ctor(); } public T Provide() { return <value>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; public static Action <4>__FreezeItemContent; public static Action <5>__RedoItemsDebugMenu; } 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<DawnItemInfo>(Tags.Conductive, (DawnItemInfo itemInfo) => itemInfo.Item.isConductiveMetal), new SimpleAutoTagger<DawnItemInfo>(Tags.Noisy, (DawnItemInfo itemInfo) => (Object)(object)itemInfo.Item.spawnPrefab.GetComponent<NoisemakerProp>() != (Object)null), new SimpleAutoTagger<DawnItemInfo>(Tags.Interactable, (DawnItemInfo itemInfo) => !itemInfo.HasTag(Tags.NonInteractable) && !itemInfo.HasTag(Tags.Noisy)), new SimpleAutoTagger<DawnItemInfo>(Tags.Paid, (DawnItemInfo itemInfo) => itemInfo.ShopInfo != null), new SimpleAutoTagger<DawnItemInfo>(Tags.Scrap, (DawnItemInfo itemInfo) => itemInfo.ScrapInfo != null), new SimpleAutoTagger<DawnItemInfo>(Tags.Chargeable, (DawnItemInfo itemInfo) => itemInfo.Item.requiresBattery), new SimpleAutoTagger<DawnItemInfo>(Tags.TwoHanded, (DawnItemInfo itemInfo) => itemInfo.Item.twoHanded), new SimpleAutoTagger<DawnItemInfo>(Tags.OneHanded, (DawnItemInfo itemInfo) => !itemInfo.Item.twoHanded), new SimpleAutoTagger<DawnItemInfo>(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.OnFreeze += FreezeItemContent; LethalContent.Items.OnFreeze += 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<SpawnableItemWithRarity> list = new List<SpawnableItemWithRarity>(); 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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<SpawnableItemWithRarity>)level.spawnableScrap).FirstOrDefault((Func<SpawnableItemWithRarity, bool>)((SpawnableItemWithRarity x) => (Object)(object)x.spawnableItem == (Object)(object)itemInfo.Item)); if (val == null) { val = new SpawnableItemWithRarity { spawnableItem = itemInfo.Item, rarity = 0 }; level.spawnableScrap.Add(val); } val.rarity = scrapInfo.Weights.GetFor(level.GetDawnInfo()).GetValueOrDefault(); } } } private static void FreezeItemContent() { //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03a6: Expected O, but got Unknown Dictionary<string, WeightTableBuilder<DawnMoonInfo>> dictionary = new Dictionary<string, WeightTableBuilder<DawnMoonInfo>>(); Dictionary<string, DawnShopItemInfo> dictionary2 = new Dictionary<string, DawnShopItemInfo>(); foreach (DawnMoonInfo value5 in LethalContent.Moons.Values) { SelectableLevel level = value5.Level; foreach (SpawnableItemWithRarity item2 in level.spawnableScrap) { if (!dictionary.TryGetValue(((Object)item2.spawnableItem).name, out var value)) { value = new WeightTableBuilder<DawnMoonInfo>(); dictionary[((Object)item2.spawnableItem).name] = value; } Debuggers.Items?.Log($"Adding weight {item2.rarity} to {((Object)item2.spawnableItem).name} on level {level.PlanetName}"); value.AddWeight(value5.TypedKey, item2.rarity); } } Terminal instance = TerminalRefs.Instance; TerminalKeyword buyKeyword = TerminalRefs.BuyKeyword; TerminalKeyword infoKeyword = TerminalRefs.InfoKeyword; List<CompatibleNoun> list = buyKeyword.compatibleNouns.ToList(); List<CompatibleNoun> list2 = infoKeyword.compatibleNouns.ToList(); List<TerminalKeyword> list3 = instance.terminalNodes.allKeywords.ToList(); foreach (TerminalKeyword item3 in list3) { item3.word = item3.word.Replace(" ", "-").ToLowerInvariant(); } int i; for (i = 0; i < instance.buyableItemsList.Length; i++) { Item val = instance.buyableItemsList[i]; TerminalNode val2 = null; TerminalNode requestNode = null; TerminalNode val3 = null; string simplifiedItemName = val.itemName.Replace(" ", "-").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 " + val.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; } val3 = requestNode.terminalOptions[0].result; TerminalKeyword val4 = (from noun in TerminalRefs.BuyKeyword.compatibleNouns where (Object)(object)noun.result == (Object)(object)requestNode select noun.noun).FirstOrDefault() ?? ((IEnumerable<TerminalKeyword>)list3).FirstOrDefaul
BepInEx/plugins/DawnLib/com.github.teamxiaolan.dawnlib.dusk.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Dawn; using Dawn.Interfaces; using Dawn.Internal; using Dawn.Utils; using DunGen; using DunGen.Graph; using Dusk.Internal; using Dusk.Utils; using Dusk.Weights; using Dusk.Weights.Transformers; using GameNetcodeStuff; using HarmonyLib; using IL; using IL.GameNetcodeStuff; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using On; using TMPro; using Unity.Netcode; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.Serialization; using UnityEngine.UI; using UnityEngine.VFX; using UnityEngine.Video; using WeatherRegistry; using WeatherRegistry.Modules; using com.github.teamxiaolan.dawnlib.dusk.NetcodePatcher; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("XuXiaolan,loaforc")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Assetloading, content and config management built ontop of DawnLib.")] [assembly: AssemblyFileVersion("0.4.3.0")] [assembly: AssemblyInformationalVersion("0.4.3+beec3bd066ed9e9cf3d67aa86121d7c5e60c8b43")] [assembly: AssemblyProduct("DawnLib.DuskMod")] [assembly: AssemblyTitle("com.github.teamxiaolan.dawnlib.dusk")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.4.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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; } } } namespace Dusk { [Serializable] public class AssetBundleData { [AssetBundleReference] public string assetBundleName; [AssertNotEmpty] public string configName; } public abstract class AssetBundleLoader<TLoader> : IAssetBundleLoader where TLoader : AssetBundleLoader<TLoader> { private readonly bool _hasNonPreloadAudioClips; private List<string> _audioClipNames = new List<string>(); private readonly bool _hasVideoClips; private List<string> _videoClipNames = new List<string>(); private AssetBundle? _bundle; public AssetBundleData AssetBundleData { get; set; } public DuskContentDefinition[] Content { get; } public Dictionary<string, ConfigEntryBase> ConfigEntries => Content.SelectMany((DuskContentDefinition c) => c.generalConfigs).ToDictionary<KeyValuePair<string, ConfigEntryBase>, string, ConfigEntryBase>((KeyValuePair<string, ConfigEntryBase> it) => it.Key, (KeyValuePair<string, ConfigEntryBase> it) => it.Value); protected AssetBundleLoader(DuskMod mod, string filePath) : this(mod.Assembly, filePath) { } internal AssetBundleLoader(Assembly assembly, string filePath) : this(AssetBundleUtils.LoadBundle(assembly, filePath)) { } protected AssetBundleLoader(AssetBundle bundle) { _bundle = bundle; DebugLogSource assetLoading = Debuggers.AssetLoading; if (assetLoading != null) { assetLoading.Log((object)(((Object)bundle).name + " contains these objects: " + string.Join(",", bundle.GetAllAssetNames()))); } Type typeFromHandle = typeof(TLoader); PropertyInfo[] properties = typeFromHandle.GetProperties(); foreach (PropertyInfo propertyInfo in properties) { LoadFromBundleAttribute loadFromBundleAttribute = (LoadFromBundleAttribute)propertyInfo.GetCustomAttribute(typeof(LoadFromBundleAttribute)); if (loadFromBundleAttribute != null) { propertyInfo.SetValue(this, LoadAsset(bundle, loadFromBundleAttribute.BundleFile)); } } Object[] array = bundle.LoadAllAssets(); foreach (Object val in array) { GameObject val2 = (GameObject)(object)((val is GameObject) ? val : null); if (val2 == null) { VideoClip val3 = (VideoClip)(object)((val is VideoClip) ? val : null); if (val3 == null) { AudioClip val4 = (AudioClip)(object)((val is AudioClip) ? val : null); if (val4 != null && !val4.preloadAudioData) { _audioClipNames.Add(((Object)val4).name); _hasNonPreloadAudioClips = true; } } else { _videoClipNames.Add(((Object)val3).name); _hasVideoClips = true; } continue; } DawnLib.FixMixerGroups(val2); DebugLogSource assetLoading2 = Debuggers.AssetLoading; if (assetLoading2 != null) { assetLoading2.Log((object)("Fixed Mixer Groups: " + ((Object)val2).name)); } if (!((Object)(object)val2.GetComponent<NetworkObject>() == (Object)null)) { DawnLib.RegisterNetworkPrefab(val2); DebugLogSource assetLoading3 = Debuggers.AssetLoading; if (assetLoading3 != null) { assetLoading3.Log((object)("Registered Network Prefab: " + ((Object)val2).name)); } } } Content = bundle.LoadAllAssets<DuskContentDefinition>(); List<Type> definitionOrder = new List<Type>(11) { typeof(DuskMoonDefinition), typeof(DuskDungeonDefinition), typeof(DuskWeatherDefinition), typeof(DuskVehicleDefinition), typeof(DuskMapObjectDefinition), typeof(DuskEnemyDefinition), typeof(DuskUnlockableDefinition), typeof(DuskItemDefinition), typeof(DuskEntityReplacementDefinition), typeof(DuskAchievementDefinition), typeof(DuskAdditionalTilesDefinition) }; Content = Content.OrderBy(delegate(DuskContentDefinition it) { Type type = ((object)it).GetType(); int num = definitionOrder.IndexOf(type); return (num < 0) ? int.MaxValue : num; }).ToArray(); } public ConfigEntry<T> GetConfig<T>(string configName) { return (ConfigEntry<T>)(object)ConfigEntries[configName]; } public bool TryGetConfig<T>(string configName, [NotNullWhen(true)] out ConfigEntry<T>? entry) { if (ConfigEntries.TryGetValue(configName, out ConfigEntryBase value)) { entry = (ConfigEntry<T>)(object)value; return true; } if (Debuggers.Dusk != null) { DuskContentDefinition? duskContentDefinition = Content.FirstOrDefault(); if (duskContentDefinition != null) { ManualLogSource? logger = duskContentDefinition.Mod.Logger; if (logger != null) { logger.LogWarning((object)$"TryGetConfig: '{configName}' does not exist on '{Content}', returning false and entry will be null"); } } } entry = null; return false; } internal void TryUnload() { if ((Object)(object)_bundle == (Object)null) { DawnPlugin.Logger.LogError((object)"Tried to unload bundle twice?"); throw new NullReferenceException(); } if (_hasNonPreloadAudioClips) { DawnPlugin.Logger.LogWarning((object)("Bundle: '" + ((Object)_bundle).name + "' is being unloaded but contains atleast one AudioClip that has 'preloadAudioData' to false! This will cause errors when trying to play said AudioClips, unloading stopped.")); foreach (string audioClipName in _audioClipNames) { DebugLogSource assetLoading = Debuggers.AssetLoading; if (assetLoading != null) { assetLoading.Log((object)("AudioClip Name: " + audioClipName)); } } } if (_hasVideoClips) { foreach (string videoClipName in _videoClipNames) { DebugLogSource assetLoading2 = Debuggers.AssetLoading; if (assetLoading2 != null) { assetLoading2.Log((object)("VideoClip Name: " + videoClipName)); } } return; } _bundle.Unload(false); _bundle = null; } private Object LoadAsset(AssetBundle bundle, string path) { Object val = bundle.LoadAsset<Object>(path); if (val == (Object)null) { throw new ArgumentException(path + " is not valid in the assetbundle!"); } return val; } } [AttributeUsage(AttributeTargets.Field)] public class AssetBundleReference : PropertyAttribute { } [CreateAssetMenu(fileName = "New Content Container", menuName = "DawnLib/Content Container", order = -10)] public class ContentContainer : ScriptableObject { public List<AssetBundleData> assetBundles; } public class DefaultBundle : AssetBundleLoader<DefaultBundle> { public DefaultBundle(DuskMod mod, string filePath) : base(mod, filePath) { } internal DefaultBundle(AssetBundle bundle) : base(bundle) { } } public interface IAssetBundleLoader { DuskContentDefinition[] Content { get; } AssetBundleData AssetBundleData { get; set; } } [AttributeUsage(AttributeTargets.Property)] public class LoadFromBundleAttribute : Attribute { public string BundleFile { get; private set; } public LoadFromBundleAttribute(string bundleFile) { BundleFile = bundleFile; base..ctor(); } } [AttributeUsage(AttributeTargets.Field)] public class AssertAssetInCorrectBundle : PropertyAttribute { } [AttributeUsage(AttributeTargets.Field)] public class AssertFieldNotNull : PropertyAttribute { } [AttributeUsage(AttributeTargets.Field)] public class AssertNotEmpty : PropertyAttribute { } [AttributeUsage(AttributeTargets.Class, Inherited = false)] public sealed class ContentOrderAttribute : Attribute { public int Order { get; } public ContentOrderAttribute(int order) { Order = order; base..ctor(); } } [AttributeUsage(AttributeTargets.Field)] public class UnlockedNamespacedKey : PropertyAttribute { } public class AutoDuskModHandler { public static void AutoRegisterMods() { string[] files = Directory.GetFiles(Paths.PluginPath, "*.duskmod", SearchOption.AllDirectories); foreach (string text in files) { AssetBundle val = AssetBundle.LoadFromFile(text); DebugLogSource assetLoading = Debuggers.AssetLoading; if (assetLoading != null) { assetLoading.Log((object)(((Object)val).name + " contains these objects: " + string.Join(",", val.GetAllAssetNames()))); } DuskModInformation[] array = val.LoadAllAssets<DuskModInformation>(); if (array.Length == 0) { DawnPlugin.Logger.LogError((object)(".duskmod bundle: '" + Path.GetFileName(text) + "' does not have a 'Mod Information' file!")); continue; } if (array.Length > 1) { DawnPlugin.Logger.LogError((object)(".duskmod bundle: '" + Path.GetFileName(text) + "' has multiple 'Mod Information' files! Only the first one will be used.")); } DawnPlugin.Logger.LogInfo((object)("AuthorName: " + array[0].AuthorName + ", ModName: " + array[0].ModName + ", Version: " + array[0].Version)); DuskMod.RegisterNoCodeMod(array[0], val, Path.GetDirectoryName(text)); } } } public class DefaultContentHandler : ContentHandler { public DefaultContentHandler(DuskMod mod) : base(mod) { ManualLogSource? logger = mod.Logger; if (logger != null) { logger.LogDebug((object)$"Trying to register bundle: {((Object)mod.Content).name} with {mod.Content.assetBundles.Count} assets."); } foreach (AssetBundleData assetBundle in mod.Content.assetBundles) { if (!IsContentEnabled(assetBundle)) { continue; } if (!mod.TryGetRelativeFile(out string fullPath, "Assets", assetBundle.assetBundleName)) { ManualLogSource? logger2 = mod.Logger; if (logger2 != null) { logger2.LogError((object)("The bundle: " + assetBundle.configName + " is not defined at plugins/" + Path.GetRelativePath(Paths.PluginPath, fullPath) + ".")); } if (mod.TryGetRelativeFile(out string fullPath2, assetBundle.assetBundleName)) { ManualLogSource? logger3 = mod.Logger; if (logger3 != null) { logger3.LogError((object)("The bundle is instead defined at plugins/" + Path.GetRelativePath(Paths.PluginPath, fullPath2) + ". It should be in an Assets/ subfolder.")); } } } else { LoadAllContent(new DefaultBundle(AssetBundle.LoadFromFile(fullPath)) { AssetBundleData = assetBundle }); } } } } [CreateAssetMenu(fileName = "Mod Information", menuName = "DawnLib/Mod Information", order = -10)] public class DuskModInformation : ScriptableObject { [field: SerializeField] public string AuthorName { get; internal set; } [field: SerializeField] public string ModName { get; internal set; } [field: SerializeField] public string Version { get; internal set; } [field: SerializeField] public TextAsset? READMEFile { get; private set; } [field: SerializeField] public TextAsset? ChangelogFile { get; private set; } [field: SerializeField] public string ModDescription { get; internal set; } [Tooltip("Comma separated list of dependencies that this mod depends on apart from the default DawnLib, BepInEx and potentially WeatherRegistry, grab from the thunderstore page.")] [field: SerializeField] public List<string> ExtraDependencies { get; internal set; } = new List<string>(); [field: SerializeField] public string WebsiteUrl { get; internal set; } [field: SerializeField] public Sprite? ModIcon { get; internal set; } public BepInPlugin CreatePluginMetadata() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown return new BepInPlugin(AuthorName + "." + ModName, ModName, Version); } } public class ConfigContext : IDisposable { [CompilerGenerated] private ConfigFile <file>P; [CompilerGenerated] private string <heading>P; public ConfigContext(ConfigFile file, string heading) { <file>P = file; <heading>P = heading; base..ctor(); } public void Dispose() { } public ConfigEntry<T> Bind<T>(string name, string description, T defaultValue = default(T)) { return <file>P.Bind<T>(ConfigManager.CleanStringForConfig(<heading>P), ConfigManager.CleanStringForConfig(name), defaultValue, description); } } public class ConfigManager { [CompilerGenerated] private ConfigFile <file>P; private static readonly Regex ConfigCleanerRegex = new Regex("[\\n\\t\"`\\[\\]']"); public ConfigManager(ConfigFile file) { <file>P = file; base..ctor(); } internal static string CleanStringForConfig(string input) { return ConfigCleanerRegex.Replace(input, string.Empty); } public ConfigContext CreateConfigSection(string header) { return new ConfigContext(<file>P, header); } public ConfigContext CreateConfigSectionForBundleData(AssetBundleData data) { return CreateConfigSection(data.configName + " Options"); } public ConfigEntryBase CreateDynamicConfig(DuskDynamicConfig configDefinition, ConfigContext context) { ConfigContext context2 = context; DuskDynamicConfig configDefinition2 = configDefinition; return (ConfigEntryBase)(configDefinition2.DynamicConfigType switch { DuskDynamicConfigType.String => Bind<string>(configDefinition2.defaultString), DuskDynamicConfigType.Int => Bind<int>(configDefinition2.defaultInt), DuskDynamicConfigType.Bool => Bind<bool>(configDefinition2.defaultBool), DuskDynamicConfigType.Float => Bind<float>(configDefinition2.defaultFloat), DuskDynamicConfigType.BoundedRange => Bind<BoundedRange>(configDefinition2.defaultBoundedRange), DuskDynamicConfigType.AnimationCurve => Bind<AnimationCurve>(configDefinition2.defaultAnimationCurve), _ => throw new ArgumentOutOfRangeException($"DynamicConfigType of '{configDefinition2.DynamicConfigType}' is not yet internally implemented!!"), }); ConfigEntryBase Bind<T>(T defaultValue) { return (ConfigEntryBase)(object)context2.Bind(configDefinition2.settingName, configDefinition2.Description, defaultValue); } } public static Dictionary<string, string> ParseLevelNameWithCurves(string configMoonRarity) { Dictionary<string, string> dictionary = new Dictionary<string, string>(); foreach (string item in from s in configMoonRarity.Split('|', StringSplitOptions.RemoveEmptyEntries) select s.Trim()) { string[] array = (from s in item.Split('-') select s.Trim()).ToArray(); if (array.Length == 2) { string key = array[0].ToLowerInvariant(); dictionary[key] = array[1]; } } return dictionary; } public static AnimationCurve ParseCurve(string keyValuePairs) { return TomlTypeConverter.ConvertToValue<AnimationCurve>(keyValuePairs); } internal static ConfigFile GenerateConfigFile(BepInPlugin plugin) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown return new ConfigFile(Utility.CombinePaths(new string[2] { Paths.ConfigPath, plugin.GUID + ".cfg" }), false, plugin); } } public class DuskContentConfig { public bool Enabled; } [Serializable] public class DuskDynamicConfig { public string settingName; public DuskDynamicConfigType DynamicConfigType; public string defaultString; public int defaultInt; public float defaultFloat; public bool defaultBool; public BoundedRange defaultBoundedRange; public AnimationCurve defaultAnimationCurve; public string Description; } public enum DuskDynamicConfigType { String, Int, Float, Bool, BoundedRange, AnimationCurve } public abstract class ContentHandler { [CompilerGenerated] private DuskMod <mod>P; protected ContentHandler(DuskMod mod) { <mod>P = mod; base..ctor(); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] protected bool IsContentEnabled(string bundleName) { if (!<mod>P.TryGetBundleDataFromName(bundleName, out AssetBundleData data)) { return false; } return IsContentEnabled(data); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] protected bool IsContentEnabled(AssetBundleData assetBundleData) { string configName = assetBundleData.configName; using ConfigContext configContext = <mod>P.ConfigManager.CreateConfigSectionForBundleData(assetBundleData); return configContext.Bind("Enabled", "Whether " + configName + " is enabled.", defaultValue: true).Value; } protected bool TryLoadContentBundle<TAsset>(string assetBundleName, out TAsset? asset, bool forceEnabled = false) where TAsset : AssetBundleLoader<TAsset> { asset = null; if (!<mod>P.TryGetBundleDataFromName(assetBundleName, out AssetBundleData data)) { ManualLogSource? logger = <mod>P.Logger; if (logger != null) { logger.LogWarning((object)("Assetbundle name: " + assetBundleName + " is not implemented yet!")); } return false; } if (!IsContentEnabled(data) && !forceEnabled) { return false; } ConstructorInfo constructor = typeof(TAsset).GetConstructor(new Type[2] { typeof(DuskMod), typeof(string) }); if (constructor == null) { ManualLogSource? logger2 = <mod>P.Logger; if (logger2 != null) { logger2.LogError((object)(typeof(TAsset).Name + " is not properly setup to handle TryLoadContentBundle. It must have a constructor with (DuskMod, string) as arguments!")); } return false; } asset = (TAsset)constructor.Invoke(new object[2] { <mod>P, assetBundleName }); asset.AssetBundleData = data; asset.TryUnload(); return true; } protected void LoadAllContent(IAssetBundleLoader bundle) { DuskContentDefinition[] content = bundle.Content; DuskContentDefinition[] array = content; foreach (DuskContentDefinition duskContentDefinition in array) { duskContentDefinition.AssetBundleData = bundle.AssetBundleData; duskContentDefinition.Register(<mod>P); } } protected void LoadAllContent(params IAssetBundleLoader[] bundles) { foreach (IAssetBundleLoader bundle in bundles) { LoadAllContent(bundle); } } protected bool RegisterContent<TAsset>(string bundleName, out TAsset? asset, bool forceEnabled = false) where TAsset : AssetBundleLoader<TAsset> { if (TryLoadContentBundle<TAsset>(bundleName, out asset, forceEnabled)) { LoadAllContent(asset); return true; } return false; } } public abstract class ContentHandler<T> : ContentHandler where T : ContentHandler<T> { public static T Instance { get; private set; } public ContentHandler(DuskMod mod) : base(mod) { Instance = (T)this; } } public class AchievementConfig { } public class AchievementSaveData { public bool Completed { get; set; } public AchievementSaveData(bool completed) { Completed = completed; base..ctor(); } } [AddComponentMenu("DawnLib/Achievements/Achivement Triggers")] public class AchievementTriggers : MonoBehaviour { [SerializeReference] private DuskAchievementReference _reference; [SerializeField] private UnityEvent _onAchievementCompleted = new UnityEvent(); public void TryCompleteAchievement() { if (_reference.TryResolve(out DuskAchievementDefinition info) && DuskModContent.Achievements.TryTriggerAchievement(info.TypedKey)) { _onAchievementCompleted.Invoke(); } } public void TryIncrementAchievement(float amountToIncrement) { if (_reference.TryResolve(out DuskAchievementDefinition info) && DuskModContent.Achievements.TryIncrementAchievement(info.TypedKey, amountToIncrement)) { _onAchievementCompleted.Invoke(); } } public void TryDiscoverMoreProgressAchievement(string uniqueStringID) { if (_reference.TryResolve(out DuskAchievementDefinition info) && DuskModContent.Achievements.TryDiscoverMoreProgressAchievement(info.TypedKey, uniqueStringID)) { _onAchievementCompleted.Invoke(); } } public void ResetAllAchievementProgress() { if (_reference.TryResolve(out DuskAchievementDefinition info)) { info.ResetProgress(); } } } public class AchievementModUIElement : MonoBehaviour { [SerializeField] private TextMeshProUGUI _modNameText; [SerializeField] private Image _modIcon; [SerializeField] private Button _achievementAccessButton; [SerializeField] private GameObject _achievementUIElementPrefab; internal GameObject _achievementsContainer; internal List<AchievementUIElement> achievementsContainerList = new List<AchievementUIElement>(); internal static List<AchievementModUIElement> achievementModUIElements = new List<AchievementModUIElement>(); private void Awake() { achievementModUIElements.Add(this); } private void OnDestroy() { achievementModUIElements.Remove(this); } internal void SetupModUI(DuskMod mod) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown DuskMod mod2 = mod; ((TMP_Text)_modNameText).text = mod2.ModInformation.ModName; if ((Object)(object)mod2.ModInformation.ModIcon != (Object)null) { _modIcon.sprite = mod2.ModInformation.ModIcon; ((Graphic)_modIcon).color = Color.white; } List<DuskAchievementDefinition> list = (from a in DuskModContent.Achievements.Values.Where((DuskAchievementDefinition a) => a.Mod == mod2).ToList() orderby a.AchievementName descending select a).ToList(); foreach (DuskAchievementDefinition item in list) { DebugLogSource achievements = Debuggers.Achievements; if (achievements != null) { achievements.Log((object)("Adding achievement: " + item.AchievementName)); } GameObject val = Object.Instantiate<GameObject>(_achievementUIElementPrefab, _achievementsContainer.transform); val.SetActive(false); AchievementUIElement component = val.GetComponent<AchievementUIElement>(); component.SetupAchievementUI(item); ((Object)val).name = "DawnLib Achievement UI - " + item.AchievementName + " - " + mod2.Plugin.GUID; achievementsContainerList.Add(component); } ((UnityEvent)_achievementAccessButton.onClick).AddListener(new UnityAction(OnButtonClick)); } public void OnButtonClick() { foreach (AchievementModUIElement modUIElement in Singleton<AchievementUICanvas>.Instance._modUIElements) { if ((Object)(object)modUIElement == (Object)(object)this) { continue; } foreach (AchievementUIElement achievementsContainer in modUIElement.achievementsContainerList) { ((Component)achievementsContainer).gameObject.SetActive(false); } } foreach (AchievementUIElement achievementsContainer2 in achievementsContainerList) { ((Component)achievementsContainer2).gameObject.SetActive(!((Component)achievementsContainer2).gameObject.activeSelf); } } } public class AchievementUICanvas : Singleton<AchievementUICanvas> { [SerializeField] internal GameObject _achievementContents; [SerializeField] private GameObject _modContents; [SerializeField] private Button _backButton; [SerializeField] private GameObject _background; [SerializeField] private GameObject _achievementModUIElementPrefab; internal Button _achievementsButton; private GameObject _mainButtons; internal MenuManager _menuManager; internal List<AchievementModUIElement> _modUIElements = new List<AchievementModUIElement>(); private void Start() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Expected O, but got Unknown //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown _mainButtons = _menuManager.menuButtons; ((UnityEvent)_backButton.onClick).AddListener(new UnityAction(BackButtonOnClick)); ((UnityEvent)_backButton.onClick).AddListener(new UnityAction(_menuManager.PlayCancelSFX)); AddAllAchievementsToContents(); } private void AddAllAchievementsToContents() { foreach (DuskMod duskMod in DuskMod.AllMods) { if (DuskModContent.Achievements.Values.Where((DuskAchievementDefinition a) => a.Mod == duskMod).Count() > 0) { GameObject val = Object.Instantiate<GameObject>(_achievementModUIElementPrefab, _modContents.transform); AchievementModUIElement component = val.GetComponent<AchievementModUIElement>(); component._achievementsContainer = _achievementContents; _modUIElements.Add(component); component.SetupModUI(duskMod); } } } public void BackButtonOnClick() { _menuManager.EnableUIPanel(_mainButtons); ((Selectable)_achievementsButton).Select(); _background.SetActive(false); } public void AchievementsButtonOnClick() { _mainButtons.SetActive(false); _background.SetActive(true); ((Selectable)_backButton).Select(); } } public class AchievementUIElement : MonoBehaviour { [SerializeField] [FormerlySerializedAs("_achievementNameTMP")] internal TextMeshProUGUI achievementNameTMP; [SerializeField] [FormerlySerializedAs("_achievementDescriptionTMP")] internal TextMeshProUGUI achievementDescriptionTMP; [SerializeField] [FormerlySerializedAs("_achievementProgressGO")] internal GameObject achievementProgressGO; [SerializeField] [FormerlySerializedAs("_achievementHiddenButton")] internal Button achievementHiddenButton; [SerializeField] [FormerlySerializedAs("_achievementIcon")] internal Image achievementIcon; [SerializeField] [FormerlySerializedAs("_unfinishedAchievementColor")] internal Color unfinishedAchievementColor = new Color(0.5f, 0.5f, 0.5f); [SerializeField] [FormerlySerializedAs("_backgroundImage")] internal Image backgroundImage; [SerializeField] [FormerlySerializedAs("_progressBar")] internal Image progressBar; [SerializeField] internal AudioSource audioSource; [SerializeField] [FormerlySerializedAs("_eventTrigger")] internal EventTrigger? eventTrigger; internal DuskAchievementDefinition achievementDefinition; public void SetupAchievementUI(DuskAchievementDefinition definition) { achievementDefinition = definition; DuskAchievementHandler.UpdateUIElement(this, definition); } public void ResetAchievementProgress() { achievementDefinition.ResetProgress(); } } public class AchievementUIGetCanvas : Singleton<AchievementUIGetCanvas> { [CompilerGenerated] private sealed class <ShowNextAchievement>d__7 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public AchievementUIGetCanvas <>4__this; private GameObject <achievementElement>5__2; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <ShowNextAchievement>d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <achievementElement>5__2 = null; <>1__state = -2; } private bool MoveNext() { //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Expected O, but got Unknown //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Expected O, but got Unknown int num = <>1__state; AchievementUIGetCanvas achievementUIGetCanvas = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; break; case 1: <>1__state = -1; <achievementElement>5__2.GetComponent<Animator>().SetTrigger(SlideOut); <>2__current = (object)new WaitForSeconds(3f); <>1__state = 2; return true; case 2: <>1__state = -1; Object.Destroy((Object)(object)<achievementElement>5__2); <achievementElement>5__2 = null; break; } if (achievementUIGetCanvas.achievementQueue.Count > 0) { DuskAchievementDefinition duskAchievementDefinition = achievementUIGetCanvas.achievementQueue.Dequeue(); <achievementElement>5__2 = Object.Instantiate<GameObject>(achievementUIGetCanvas._achievementGetUIElementPrefab, achievementUIGetCanvas.achievementContent.transform); AchievementUIElement component = <achievementElement>5__2.GetComponent<AchievementUIElement>(); component.SetupAchievementUI(duskAchievementDefinition); if ((Object)(object)duskAchievementDefinition.FinishAchievementAudioClip != (Object)null) { component.audioSource.clip = duskAchievementDefinition.FinishAchievementAudioClip; } component.audioSource.Play(); <>2__current = (object)new WaitForSeconds(duskAchievementDefinition.PopupTime); <>1__state = 1; return true; } return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static readonly int SlideOut = Animator.StringToHash("SlideOut"); [SerializeField] private GameObject _achievementGetUIElementPrefab; [SerializeField] private GameObject achievementContent; private Queue<DuskAchievementDefinition> achievementQueue = new Queue<DuskAchievementDefinition>(); private void Start() { DuskAchievementHandler.OnAchievementUnlocked = (Action<DuskAchievementDefinition>)Delegate.Combine(DuskAchievementHandler.OnAchievementUnlocked, new Action<DuskAchievementDefinition>(QueuePopup)); } private void OnDestroy() { DuskAchievementHandler.OnAchievementUnlocked = (Action<DuskAchievementDefinition>)Delegate.Remove(DuskAchievementHandler.OnAchievementUnlocked, new Action<DuskAchievementDefinition>(QueuePopup)); } internal void QueuePopup(DuskAchievementDefinition achievement) { achievementQueue.Enqueue(achievement); if (achievementContent.transform.childCount == 0) { ((MonoBehaviour)this).StartCoroutine(ShowNextAchievement()); } } [IteratorStateMachine(typeof(<ShowNextAchievement>d__7))] private IEnumerator ShowNextAchievement() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <ShowNextAchievement>d__7(0) { <>4__this = this }; } } public abstract class DuskAchievementDefinition : DuskContentDefinition, INamespaced<DuskAchievementDefinition>, INamespaced { [SerializeField] private NamespacedKey<DuskAchievementDefinition> _typedKey; [field: SerializeField] public Sprite? AchievementIcon { get; private set; } [field: Space(10f)] [field: SerializeField] public string AchievementName { get; private set; } [field: SerializeField] public string AchievementDescription { get; private set; } [field: SerializeField] public TMP_ColorGradient? FinishedAchievementNameColorGradientPreset { get; private set; } [field: SerializeField] public TMP_ColorGradient? FinishedAchievementDescColorGradientPreset { get; private set; } [field: SerializeField] public Sprite? FinishedAchievementBackgroundIcon { get; private set; } [field: SerializeField] public AudioClip? FinishAchievementAudioClip { get; private set; } [field: Space(10f)] [field: SerializeField] public string AchievementRequirement { get; private set; } [field: SerializeField] public bool IsHidden { get; private set; } [field: SerializeField] public bool CanBeUnhidden { get; private set; } [field: SerializeField] public float PopupTime { get; private set; } = 5f; public bool Completed { get; protected set; } public NamespacedKey<DuskAchievementDefinition> TypedKey => _typedKey; public override NamespacedKey Key { get { return (NamespacedKey)(object)TypedKey; } protected set { _typedKey = value.AsTyped<DuskAchievementDefinition>(); } } protected override string EntityNameReference => AchievementName; protected virtual AchievementSaveData GetSaveData() { return new AchievementSaveData(Completed); } protected virtual void LoadSaveData(AchievementSaveData saveData) { Completed = saveData.Completed; } public void LoadAchievementState(IDataContainer dataContainer) { LoadSaveData(dataContainer.GetOrSetDefault<AchievementSaveData>(Key, GetSaveData())); DebugLogSource achievements = Debuggers.Achievements; if (achievements != null) { achievements.Log((object)$"Loaded Achievement: {AchievementName} with value: {Completed}"); } } public void SaveAchievementState(IDataContainer dataContainer) { dataContainer.Set<AchievementSaveData>(Key, GetSaveData()); DebugLogSource achievements = Debuggers.Achievements; if (achievements != null) { achievements.Log((object)$"Saving Achievement: {AchievementName} with value: {Completed}"); } } protected bool TryCompleteAchievement() { if (Completed) { return false; } Completed = true; DuskAchievementHandler.OnAchievementUnlocked(this); return Completed; } internal bool TryCompleteFromServer() { return TryCompleteAchievement(); } public virtual void ResetProgress() { Completed = false; DuskAchievementHandler.SaveAll(); DuskAchievementHandler.LoadAll(); foreach (AchievementModUIElement achievementModUIElement in AchievementModUIElement.achievementModUIElements) { foreach (AchievementUIElement achievementsContainer in achievementModUIElement.achievementsContainerList) { DuskAchievementHandler.UpdateUIElement(achievementsContainer, achievementsContainer.achievementDefinition); } } } public override void Register(DuskMod mod) { base.Register(mod); DuskModContent.Achievements.Register(this); } public virtual bool IsActive() { return true; } } public static class DuskAchievementExtensions { public static bool TryTriggerAchievement(this Registry<DuskAchievementDefinition> registry, NamespacedKey<DuskAchievementDefinition> achievementKey) { DuskAchievementDefinition duskAchievementDefinition = default(DuskAchievementDefinition); if (registry.TryGetValue(achievementKey, ref duskAchievementDefinition) && duskAchievementDefinition is DuskInstantAchievement duskInstantAchievement) { return duskInstantAchievement.TriggerAchievement(); } return false; } public static bool TryIncrementAchievement(this Registry<DuskAchievementDefinition> registry, NamespacedKey<DuskAchievementDefinition> achievementKey, float amount) { DuskAchievementDefinition duskAchievementDefinition = default(DuskAchievementDefinition); if (registry.TryGetValue(achievementKey, ref duskAchievementDefinition) && duskAchievementDefinition is DuskStatAchievement duskStatAchievement) { return duskStatAchievement.IncrementProgress(amount); } return false; } public static bool TryDiscoverMoreProgressAchievement(this Registry<DuskAchievementDefinition> registry, NamespacedKey<DuskAchievementDefinition> achievementKey, IEnumerable<string> uniqueStringIDs) { DuskAchievementDefinition duskAchievementDefinition = default(DuskAchievementDefinition); if (registry.TryGetValue(achievementKey, ref duskAchievementDefinition) && duskAchievementDefinition is DuskDiscoveryAchievement duskDiscoveryAchievement) { return duskDiscoveryAchievement.TryDiscoverMoreProgress(uniqueStringIDs); } return false; } public static bool TryDiscoverMoreProgressAchievement(this Registry<DuskAchievementDefinition> registry, NamespacedKey<DuskAchievementDefinition> achievementKey, string uniqueStringID) { DuskAchievementDefinition duskAchievementDefinition = default(DuskAchievementDefinition); if (registry.TryGetValue(achievementKey, ref duskAchievementDefinition) && duskAchievementDefinition is DuskDiscoveryAchievement duskDiscoveryAchievement) { return duskDiscoveryAchievement.TryDiscoverMoreProgress(uniqueStringID); } return false; } public static void ResetAchievementProgress(this Registry<DuskAchievementDefinition> registry, NamespacedKey<DuskAchievementDefinition> achievementKey) { DuskAchievementDefinition duskAchievementDefinition = default(DuskAchievementDefinition); if (registry.TryGetValue(achievementKey, ref duskAchievementDefinition)) { duskAchievementDefinition.ResetProgress(); } } } internal static class DuskAchievementHandler { public static Action<DuskAchievementDefinition> OnAchievementUnlocked = delegate { }; internal static void LoadAll() { using (((DataContainer)DuskPlugin.PersistentData).CreateEditContext()) { foreach (DuskAchievementDefinition value in DuskModContent.Achievements.Values) { value.LoadAchievementState((IDataContainer)(object)DuskPlugin.PersistentData); } } } internal static void SaveAll() { using (((DataContainer)DuskPlugin.PersistentData).CreateEditContext()) { foreach (DuskAchievementDefinition value in DuskModContent.Achievements.Values) { value.SaveAchievementState((IDataContainer)(object)DuskPlugin.PersistentData); } } } internal static void UpdateUIElement(AchievementUIElement achievementUIElement, DuskAchievementDefinition achievementDefinition) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_015c: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)achievementUIElement.achievementNameTMP).text = achievementDefinition.AchievementName; ((TMP_Text)achievementUIElement.achievementDescriptionTMP).text = achievementDefinition.AchievementDescription; achievementUIElement.achievementIcon.sprite = achievementDefinition.AchievementIcon; ((Selectable)achievementUIElement.achievementHiddenButton).interactable = false; if ((Object)(object)achievementUIElement.eventTrigger != (Object)null) { ((Behaviour)achievementUIElement.eventTrigger).enabled = false; } if (achievementDefinition.CanBeUnhidden) { ((Selectable)achievementUIElement.achievementHiddenButton).interactable = true; if ((Object)(object)achievementUIElement.eventTrigger != (Object)null) { ((Behaviour)achievementUIElement.eventTrigger).enabled = true; } } if (!achievementDefinition.IsHidden || achievementDefinition.Completed) { if ((Object)(object)achievementUIElement.eventTrigger != (Object)null) { ((Behaviour)achievementUIElement.eventTrigger).enabled = true; } ((Selectable)achievementUIElement.achievementHiddenButton).interactable = true; ((UnityEvent)achievementUIElement.achievementHiddenButton.onClick).Invoke(); } if (!achievementDefinition.Completed) { ((Graphic)achievementUIElement.achievementNameTMP).color = achievementUIElement.unfinishedAchievementColor; ((Graphic)achievementUIElement.achievementDescriptionTMP).color = achievementUIElement.unfinishedAchievementColor; achievementUIElement.backgroundImage.sprite = null; ((Graphic)achievementUIElement.backgroundImage).color = Color32.op_Implicit(new Color32((byte)0, (byte)0, (byte)0, (byte)107)); ((TMP_Text)achievementUIElement.achievementNameTMP).colorGradientPreset = null; ((TMP_Text)achievementUIElement.achievementDescriptionTMP).colorGradientPreset = null; } else { if ((Object)(object)achievementDefinition.FinishedAchievementBackgroundIcon != (Object)null) { achievementUIElement.backgroundImage.sprite = achievementDefinition.FinishedAchievementBackgroundIcon; ((Graphic)achievementUIElement.backgroundImage).color = Color.white; } ((TMP_Text)achievementUIElement.achievementNameTMP).colorGradientPreset = achievementDefinition.FinishedAchievementNameColorGradientPreset; ((TMP_Text)achievementUIElement.achievementDescriptionTMP).colorGradientPreset = achievementDefinition.FinishedAchievementDescColorGradientPreset; } IProgress val = (IProgress)(object)((achievementDefinition is IProgress) ? achievementDefinition : null); if (val != null) { DebugLogSource achievements = Debuggers.Achievements; if (achievements != null) { achievements.Log((object)$"Setting up progress achievement: {achievementDefinition.AchievementName} with percentage: {IProgressExtensions.Percentage(val)}"); } achievementUIElement.progressBar.fillAmount = IProgressExtensions.Percentage(val); ((TMP_Text)((Component)achievementUIElement.progressBar).GetComponentInChildren<TextMeshProUGUI>()).text = $"{val.CurrentProgress}/{val.MaxProgress}"; } else { achievementUIElement.achievementProgressGO.SetActive(false); } } } [Serializable] public class DuskAchievementReference : DuskContentReference<DuskAchievementDefinition, DuskAchievementDefinition> { public DuskAchievementReference() { } public DuskAchievementReference(NamespacedKey<DuskAchievementDefinition> key) : base(key) { } public override bool TryResolve(out DuskAchievementDefinition info) { return DuskModContent.Achievements.TryGetValue(base.TypedKey, ref info); } public override DuskAchievementDefinition Resolve() { return DuskModContent.Achievements[base.TypedKey]; } } [CreateAssetMenu(fileName = "New Discovery Achievement Definition", menuName = "DawnLib/Definitions/Achievements/Discovery Definition")] public class DuskDiscoveryAchievement : DuskAchievementDefinition, IProgress { public class DiscoverySaveData : AchievementSaveData { public List<string> CurrentlyCollectedUniqueStringIDs { get; } public DiscoverySaveData(bool completed, List<string> currentlyCollectedUniqueStringIDs) { CurrentlyCollectedUniqueStringIDs = currentlyCollectedUniqueStringIDs; base..ctor(completed); } } [Tooltip("Unique string ID for each discovery to account for progress.")] [field: SerializeField] public List<string> UniqueStringIDs { get; private set; } public List<string> CurrentlyCollectedUniqueStringIDs { get; private set; } = new List<string>(); public float MaxProgress => UniqueStringIDs.Count; public float CurrentProgress => CurrentlyCollectedUniqueStringIDs.Count; protected override AchievementSaveData GetSaveData() { return new DiscoverySaveData(base.Completed, CurrentlyCollectedUniqueStringIDs); } protected override void LoadSaveData(AchievementSaveData saveData) { base.LoadSaveData(saveData); CurrentlyCollectedUniqueStringIDs = ((DiscoverySaveData)saveData).CurrentlyCollectedUniqueStringIDs; } public override void ResetProgress() { CurrentlyCollectedUniqueStringIDs.Clear(); base.ResetProgress(); } public bool TryDiscoverMoreProgress(string UniqueID) { if (CurrentlyCollectedUniqueStringIDs.Contains(UniqueID)) { return false; } if (!UniqueStringIDs.Contains(UniqueID)) { return false; } CurrentlyCollectedUniqueStringIDs.Add(UniqueID); if (CurrentProgress >= MaxProgress) { CurrentlyCollectedUniqueStringIDs = UniqueStringIDs; return TryCompleteAchievement(); } return false; } public bool TryDiscoverMoreProgress(IEnumerable<string> UniqueID) { foreach (string item in UniqueID) { if (TryDiscoverMoreProgress(item)) { return true; } } return false; } public void UndiscoverProgress(string UniqueID) { if (UniqueStringIDs.Contains(UniqueID)) { CurrentlyCollectedUniqueStringIDs.Remove(UniqueID); } } public void UndiscoverProgress(IEnumerable<string> UniqueID) { foreach (string item in UniqueID) { UndiscoverProgress(item); } } } [CreateAssetMenu(fileName = "New Instant Achievement Definition", menuName = "DawnLib/Definitions/Achievements/Instant Definition")] public class DuskInstantAchievement : DuskAchievementDefinition { [field: SerializeField] public bool SyncedCompletion { get; private set; } public bool TriggerAchievement() { if (SyncedCompletion) { NetworkSingleton<DuskNetworker>.Instance?.TriggerAchievementServerRpc(Key); } return TryCompleteAchievement(); } } [CreateAssetMenu(fileName = "New Parent Achievement Definition", menuName = "DawnLib/Definitions/Achievements/Parent Definition")] public class DuskParentAchievement : DuskAchievementDefinition, IProgress { [field: SerializeReference] [field: FormerlySerializedAs("ChildrenAchievementNames")] public List<DuskAchievementReference> ChildrenAchievementReferences { get; private set; } = new List<DuskAchievementReference>(); public float MaxProgress => ChildrenAchievementReferences.Count; public float CurrentProgress => CountCompleted(); public override void Register(DuskMod mod) { DuskMod mod2 = mod; base.Register(mod2); DuskAchievementHandler.OnAchievementUnlocked = (Action<DuskAchievementDefinition>)Delegate.Combine(DuskAchievementHandler.OnAchievementUnlocked, (Action<DuskAchievementDefinition>)delegate(DuskAchievementDefinition definition) { if (definition.Mod == mod2 && CountCompleted() >= ChildrenAchievementReferences.Count) { TryCompleteAchievement(); } }); } private int CountCompleted() { int num = 0; foreach (DuskAchievementDefinition value in DuskModContent.Achievements.Values) { if (!value.Completed) { continue; } foreach (DuskAchievementReference childrenAchievementReference in ChildrenAchievementReferences) { if (childrenAchievementReference.TryResolve(out DuskAchievementDefinition info) && info.AchievementName == value.AchievementName) { num++; break; } } } return num; } public override bool IsActive() { int num = 0; foreach (DuskAchievementReference childrenAchievementReference in ChildrenAchievementReferences) { if (childrenAchievementReference.TryResolve(out DuskAchievementDefinition info) && info.IsActive()) { num++; } } return num == ChildrenAchievementReferences.Count; } } [CreateAssetMenu(fileName = "New Stat Achievement Definition", menuName = "DawnLib/Definitions/Achievements/Stat Definition")] public class DuskStatAchievement : DuskAchievementDefinition, IProgress { public class StatSaveData : AchievementSaveData { public float CurrentProgress { get; } public StatSaveData(bool completed, float currentProgress) { CurrentProgress = currentProgress; base..ctor(completed); } } [field: SerializeField] public float MaxProgress { get; private set; } public float CurrentProgress { get; private set; } protected override AchievementSaveData GetSaveData() { return new StatSaveData(base.Completed, CurrentProgress); } protected override void LoadSaveData(AchievementSaveData saveData) { base.LoadSaveData(saveData); CurrentProgress = ((StatSaveData)saveData).CurrentProgress; } public override void ResetProgress() { CurrentProgress = 0f; base.ResetProgress(); } public bool IncrementProgress(float amount) { CurrentProgress = Mathf.Max(0f, CurrentProgress + amount); if (CurrentProgress >= MaxProgress) { CurrentProgress = MaxProgress; return TryCompleteAchievement(); } return false; } public void DecrementProgress(float amount) { CurrentProgress -= Mathf.Max(0f, amount); if (CurrentProgress <= 0f) { CurrentProgress = 0f; } } } public class AdditionalTilesConfig { } public class DungeonConfig { } [CreateAssetMenu(fileName = "New Additional Tiles Definition", menuName = "DawnLib/Definitions/Additional Tiles Definition")] public class DuskAdditionalTilesDefinition : DuskContentDefinition<DawnTileSetInfo> { [Flags] public enum BranchCapSetting { Regular = 1, BranchCap = 2 } [SerializeField] public List<NamespacedKey<DawnArchetypeInfo>> archetypeKeys = new List<NamespacedKey<DawnArchetypeInfo>>(); [field: SerializeField] public TileSet TilesToAdd { get; private set; } [field: SerializeField] public BranchCapSetting BranchCap { get; private set; } [field: SerializeField] public DuskPredicate Predicate { get; private set; } public AdditionalTilesConfig Config { get; private set; } protected override string EntityNameReference { get { TileSet tilesToAdd = TilesToAdd; return ((tilesToAdd != null) ? ((Object)tilesToAdd).name : null) ?? string.Empty; } } public override void Register(DuskMod mod) { base.Register(mod); foreach (GameObjectChance weight in TilesToAdd.TileWeights.Weights) { DawnLib.FixDoorwaySockets(weight.Value); } DawnTileSetInfo tileSetInfo = DawnLib.DefineTileSet(base.TypedKey, TilesToAdd, (Action<TilesetInfoBuilder>)delegate(TilesetInfoBuilder builder) { ApplyTagsTo((BaseInfoBuilder)(object)builder); builder.SetIsRegular(BranchCap.HasFlag(BranchCapSetting.Regular)); builder.SetIsBranchCap(BranchCap.HasFlag(BranchCapSetting.BranchCap)); if (Object.op_Implicit((Object)(object)Predicate)) { builder.SetInjectionPredicate((IPredicate)(object)Predicate); } }); LethalContent.Archetypes.BeforeFreeze += delegate { DawnArchetypeInfo val = default(DawnArchetypeInfo); foreach (NamespacedKey<DawnArchetypeInfo> archetypeKey in archetypeKeys) { if (LethalContent.Archetypes.TryGetValue(archetypeKey, ref val)) { val.AddTileSet(tileSetInfo); } } }; } } [Serializable] public class DuskAdditionalTilesReference : DuskContentReference<DuskAdditionalTilesDefinition, DawnTileSetInfo> { public DuskAdditionalTilesReference() { } public DuskAdditionalTilesReference(NamespacedKey<DawnTileSetInfo> key) : base(key) { } public override bool TryResolve(out DawnTileSetInfo info) { return LethalContent.TileSets.TryGetValue(base.TypedKey, ref info); } public override DawnTileSetInfo Resolve() { return LethalContent.TileSets[base.TypedKey]; } } [CreateAssetMenu(fileName = "New Dungeon Definition", menuName = "DawnLib/Definitions/Dungeon Definition")] public class DuskDungeonDefinition : DuskContentDefinition<DawnDungeonInfo> { [field: SerializeField] public DungeonFlow DungeonFlow { get; private set; } [field: SerializeField] public AudioClip? StingerAudio { get; private set; } [field: Space(10f)] [field: Header("Config | Weights")] [field: SerializeField] public string MoonSpawnWeights { get; private set; } [field: Header("Config | Misc")] [field: SerializeField] public float MapTileSize { get; private set; } [field: SerializeField] public bool StingerPlaysMoreThanOnce { get; private set; } [field: SerializeField] public float StingerPlayChance { get; private set; } public DungeonConfig Config { get; private set; } protected override string EntityNameReference { get { DungeonFlow dungeonFlow = DungeonFlow; return ((dungeonFlow != null) ? ((Object)dungeonFlow).name : null) ?? string.Empty; } } public override void Register(DuskMod mod) { base.Register(mod); SpawnWeightsPreset spawnWeightsPreset = new SpawnWeightsPreset(); spawnWeightsPreset.SetupSpawnWeightsPreset(MoonSpawnWeights, string.Empty, string.Empty); DawnLib.DefineDungeon(base.TypedKey, DungeonFlow, (Action<DungeonFlowInfoBuilder>)delegate(DungeonFlowInfoBuilder builder) { builder.SetMapTileSize(MapTileSize); builder.SetFirstTimeAudio(StingerAudio); builder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo>>)delegate(WeightTableBuilder<DawnMoonInfo> weightBuilder) { weightBuilder.SetGlobalWeight((IWeighted)(object)spawnWeightsPreset); }); ApplyTagsTo((BaseInfoBuilder)(object)builder); }); } } [Serializable] public class DuskDungeonReference : DuskContentReference<DuskDungeonDefinition, DawnDungeonInfo> { public DuskDungeonReference() { } public DuskDungeonReference(NamespacedKey<DawnDungeonInfo> key) : base(key) { } public override bool TryResolve(out DawnDungeonInfo info) { return ((Registry<DawnDungeonInfo>)(object)LethalContent.Dungeons).TryGetValue(base.TypedKey, ref info); } public override DawnDungeonInfo Resolve() { return ((Registry<DawnDungeonInfo>)(object)LethalContent.Dungeons)[base.TypedKey]; } } public abstract class DuskContentDefinition : ScriptableObject { [FormerlySerializedAs("ConfigEntries")] [SerializeField] private List<DuskDynamicConfig> _configEntries = new List<DuskDynamicConfig>(); [SerializeField] [UnlockedNamespacedKey] internal List<NamespacedKey> _tags = new List<NamespacedKey>(); internal readonly Dictionary<string, ConfigEntryBase> generalConfigs = new Dictionary<string, ConfigEntryBase>(); internal AssetBundleData AssetBundleData; public abstract NamespacedKey Key { get; protected set; } public DuskMod Mod { get; private set; } protected abstract string EntityNameReference { get; } public virtual void Register(DuskMod mod) { if (AssetBundleData == null) { ManualLogSource? logger = mod.Logger; if (logger != null) { logger.LogError((object)("BUG! Tried to register " + ((Object)this).name + " without setting AssetBundleData?")); } return; } Mod = mod; using ConfigContext context = mod.ConfigManager.CreateConfigSectionForBundleData(AssetBundleData); foreach (DuskDynamicConfig configEntry in _configEntries) { generalConfigs[ConfigManager.CleanStringForConfig(configEntry.settingName)] = mod.ConfigManager.CreateDynamicConfig(configEntry, context); } } public string GetDefaultKey() { return NamespacedKey.NormalizeStringForNamespacedKey(EntityNameReference, false); } protected void ApplyTagsTo(BaseInfoBuilder builder) { builder.SoloAddTags((IEnumerable<NamespacedKey>)_tags); } } public abstract class DuskContentDefinition<TInfo> : DuskContentDefinition where TInfo : INamespaced<TInfo> { public NamespacedKey<TInfo> TypedKey => Key.AsTyped<TInfo>(); public override NamespacedKey Key { get; protected set; } } [Serializable] public abstract class DuskContentReference : INetworkSerializable { [SerializeField] internal string assetGUID; public abstract Type Type { get; } public abstract Type DefinitionType { get; } public abstract NamespacedKey Key { get; protected set; } public abstract void NetworkSerialize<T>(BufferSerializer<T> serializer) where T : IReaderWriter; } [Serializable] public abstract class DuskContentReference<TDef, TInfo> : DuskContentReference where TDef : DuskContentDefinition where TInfo : INamespaced<TInfo> { public NamespacedKey<TInfo> TypedKey => Key.AsTyped<TInfo>(); public override NamespacedKey Key { get; protected set; } public override Type Type => typeof(TInfo); public override Type DefinitionType => typeof(TDef); public DuskContentReference() { Key = (NamespacedKey)(object)NamespacedKey<?>.From("", ""); } protected DuskContentReference(NamespacedKey<TInfo> key) { Key = (NamespacedKey)(object)key; } public unsafe override void NetworkSerialize<T>(BufferSerializer<T> serializer) { NamespacedKey key = Key; ((BufferSerializer<NamespacedKey>*)(&serializer))->SerializeNetworkSerializable<NamespacedKey>(ref key); Key = key; } public abstract bool TryResolve(out TInfo info); public abstract TInfo Resolve(); } [Flags] public enum SpawnTable { Inside = 1, Outside = 2, Daytime = 4 } [CreateAssetMenu(fileName = "New Enemy Definition", menuName = "DawnLib/Definitions/Enemy Definition")] public class DuskEnemyDefinition : DuskContentDefinition<DawnEnemyInfo> { [field: FormerlySerializedAs("enemyType")] [field: SerializeField] public EnemyType EnemyType { get; private set; } [field: SerializeField] public SpawnTable SpawnTable { get; private set; } [field: Header("Optional | Bestiary")] [field: TextArea(2, 20)] [field: SerializeField] public string BestiaryNodeText { get; private set; } = string.Empty; [field: SerializeField] public string BestiaryWordOverride { get; private set; } = string.Empty; [field: Space(10f)] [field: Header("Configs | Spawn Weights | Format: <Namespace>:<Key>=<Operation><Value>, i.e. magic_wesleys_mod:trite=+20")] [field: TextArea(1, 10)] [field: SerializeField] public string MoonSpawnWeights { get; private set; } = "Vanilla=+0, Custom=+0, Valley=+0, Canyon=+0, Tundra=+0, Marsh=+0, Military=+0, Rocky=+0,Amythest=+0, Experimentation=+0, Assurance=+0, Vow=+0, Offense=+0, March=+0, Adamance=+0, Rend=+0, Dine=+0, Titan=+0, Artifice=+0, Embrion=+0"; [field: TextArea(1, 10)] [field: SerializeField] public string InteriorSpawnWeights { get; private set; } = "Facility=+0, Mansion=+0, Mineshaft=+0"; [field: TextArea(1, 10)] [field: SerializeField] public string WeatherSpawnWeights { get; private set; } = "None=*1, DustClouds=*1, Rainy=*1, Stormy=*1, Foggy=*1, Flooded=*1, Eclipsed=*1"; [field: SerializeField] public bool GenerateSpawnWeightsConfig { get; private set; } = true; public SpawnWeightsPreset SpawnWeights { get; private set; } = new SpawnWeightsPreset(); public EnemyConfig Config { get; private set; } protected override string EntityNameReference => EnemyType?.enemyName ?? string.Empty; public override void Register(DuskMod mod) { base.Register(mod); using ConfigContext section = mod.ConfigManager.CreateConfigSectionForBundleData(AssetBundleData); Config = CreateEnemyConfig(section); EnemyType enemyType = EnemyType; enemyType.MaxCount = Config.MaxSpawnCount.Value; enemyType.PowerLevel = Config.PowerLevel.Value; SpawnWeights.SetupSpawnWeightsPreset(Config.MoonSpawnWeights?.Value ?? MoonSpawnWeights, Config.InteriorSpawnWeights?.Value ?? InteriorSpawnWeights, Config.WeatherSpawnWeights?.Value ?? WeatherSpawnWeights); DawnLib.DefineEnemy(base.TypedKey, EnemyType, (Action<EnemyInfoBuilder>)delegate(EnemyInfoBuilder builder) { if (SpawnTable.HasFlag(SpawnTable.Daytime)) { builder.DefineDaytime((Action<EnemyLocationBuilder>)delegate(EnemyLocationBuilder daytimeBuilder) { daytimeBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo>>)delegate(WeightTableBuilder<DawnMoonInfo> weightBuilder) { weightBuilder.SetGlobalWeight((IWeighted)(object)SpawnWeights); }); }); } if (SpawnTable.HasFlag(SpawnTable.Outside)) { builder.DefineOutside((Action<EnemyLocationBuilder>)delegate(EnemyLocationBuilder outsideBuilder) { outsideBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo>>)delegate(WeightTableBuilder<DawnMoonInfo> weightBuilder) { weightBuilder.SetGlobalWeight((IWeighted)(object)SpawnWeights); }); }); } if (SpawnTable.HasFlag(SpawnTable.Inside)) { builder.DefineInside((Action<EnemyLocationBuilder>)delegate(EnemyLocationBuilder insideBuilder) { insideBuilder.SetWeights((Action<WeightTableBuilder<DawnMoonInfo>>)delegate(WeightTableBuilder<DawnMoonInfo> weightBuilder) { weightBuilder.SetGlobalWeight((IWeighted)(object)SpawnWeights); }); }); } if (!string.IsNullOrEmpty(BestiaryNodeText)) { builder.CreateBestiaryNode(BestiaryNodeText); builder.CreateNameKeyword(BestiaryWordOverride); } ApplyTagsTo((BaseInfoBuilder)(object)builder); }); } public EnemyConfig CreateEnemyConfig(ConfigContext section) { return new EnemyConfig { MoonSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Moon Weights", "Preset moon weights for " + EntityNameReference + ".", MoonSpawnWeights) : null), InteriorSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Interior Weights", "Preset interior weights for " + EntityNameReference + ".", InteriorSpawnWeights) : null), WeatherSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Weather Weights", "Preset weather weights for " + EntityNameReference + ".", WeatherSpawnWeights) : null), PowerLevel = section.Bind(EntityNameReference + " | Power Level", "Power level for " + EntityNameReference + ".", EnemyType.PowerLevel), MaxSpawnCount = section.Bind(EntityNameReference + " | Max Spawn Count", "Max spawn count for " + EntityNameReference + ".", EnemyType.MaxCount) }; } } [Serializable] public class DuskEnemyReference : DuskContentReference<DuskEnemyDefinition, DawnEnemyInfo> { public DuskEnemyReference() { } public DuskEnemyReference(NamespacedKey<DawnEnemyInfo> key) : base(key) { } public override bool TryResolve(out DawnEnemyInfo info) { return ((Registry<DawnEnemyInfo>)(object)LethalContent.Enemies).TryGetValue(base.TypedKey, ref info); } public override DawnEnemyInfo Resolve() { return ((Registry<DawnEnemyInfo>)(object)LethalContent.Enemies)[base.TypedKey]; } } public class EnemyConfig { public ConfigEntry<int> MaxSpawnCount; public ConfigEntry<float> PowerLevel; public ConfigEntry<string>? MoonSpawnWeights; public ConfigEntry<string>? InteriorSpawnWeights; public ConfigEntry<string>? WeatherSpawnWeights; } [CreateAssetMenu(fileName = "New AnimationClip Replacement", menuName = "Entity Replacements/Actions/AnimationClip Replacement")] public class AnimationClipReplacement : Hierarchy { [CompilerGenerated] private sealed class <Apply>d__12 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public AnimationClipReplacement <>4__this; public Transform rootTransform; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Apply>d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Expected O, but got Unknown int num = <>1__state; AnimationClipReplacement animationClipReplacement = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: { <>1__state = -1; Animator val = ((!string.IsNullOrEmpty(animationClipReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(animationClipReplacement.HierarchyPath)).GetComponent<Animator>() : ((Component)rootTransform).GetComponent<Animator>()); AnimatorOverrideController val2 = new AnimatorOverrideController(val.runtimeAnimatorController); foreach (AnimationEventAddition potentialAnimationEvent in animationClipReplacement.PotentialAnimationEvents) { AnimationEvent val3 = new AnimationEvent { functionName = potentialAnimationEvent.AnimationEventName, time = potentialAnimationEvent.Time, stringParameter = potentialAnimationEvent.StringParameter, intParameter = potentialAnimationEvent.IntParameter, floatParameter = potentialAnimationEvent.FloatParameter, objectReferenceParameter = potentialAnimationEvent.ObjectParameter }; animationClipReplacement.NewAnimationClip.AddEvent(val3); } val2[animationClipReplacement.OriginalClipName] = animationClipReplacement.NewAnimationClip; val.runtimeAnimatorController = (RuntimeAnimatorController)(object)val2; return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [field: SerializeField] public string OriginalClipName { get; private set; } [field: SerializeField] public AnimationClip NewAnimationClip { get; private set; } [field: SerializeField] public List<AnimationEventAddition> PotentialAnimationEvents { get; private set; } = new List<AnimationEventAddition>(); [IteratorStateMachine(typeof(<Apply>d__12))] public override IEnumerator Apply(Transform rootTransform) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Apply>d__12(0) { <>4__this = this, rootTransform = rootTransform }; } } [Serializable] public class AnimationEventAddition { [field: SerializeField] public string AnimationEventName { get; private set; } [field: SerializeField] public float Time { get; private set; } [field: Header("Optional | Parameters")] [field: SerializeField] public string StringParameter { get; private set; } = string.Empty; [field: SerializeField] public int IntParameter { get; private set; } [field: SerializeField] public float FloatParameter { get; private set; } [field: SerializeField] public bool BoolParameter { get; private set; } [field: SerializeField] public Object? ObjectParameter { get; private set; } } [CreateAssetMenu(fileName = "New GameObject Editor Action", menuName = "Entity Replacements/Actions/GameObject Editor Action")] public class GameObjectEditorAction : Hierarchy { [CompilerGenerated] private sealed class <Apply>d__16 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GameObjectEditorAction <>4__this; public Transform rootTransform; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Apply>d__16(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; GameObjectEditorAction gameObjectEditorAction = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: { <>1__state = -1; GameObject val = ((!string.IsNullOrEmpty(gameObjectEditorAction.HierarchyPath)) ? ((Component)rootTransform.Find(gameObjectEditorAction.HierarchyPath)).gameObject : ((Component)rootTransform).gameObject); if (gameObjectEditorAction.DeleteGameObject) { NetworkObject val2 = default(NetworkObject); if (val.TryGetComponent<NetworkObject>(ref val2) && NetworkManager.Singleton.IsServer) { val2.Despawn(true); } if ((Object)(object)val2 == (Object)null) { Object.Destroy((Object)(object)val); } return false; } if (gameObjectEditorAction.DisableGameObject) { val.SetActive(false); } Transform transform = val.transform; transform.localPosition += gameObjectEditorAction.PositionOffset; Transform transform2 = val.transform; transform2.localRotation *= Quaternion.Euler(gameObjectEditorAction.RotationOffset); return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [field: SerializeField] public bool DeleteGameObject { get; private set; } [field: SerializeField] public bool DisableGameObject { get; private set; } [field: SerializeField] public Vector3 PositionOffset { get; private set; } [field: SerializeField] public Vector3 RotationOffset { get; private set; } [IteratorStateMachine(typeof(<Apply>d__16))] public override IEnumerator Apply(Transform rootTransform) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Apply>d__16(0) { <>4__this = this, rootTransform = rootTransform }; } } public abstract class Hierarchy : ScriptableObject { [field: SerializeField] public string HierarchyPath { get; private set; } public abstract IEnumerator Apply(Transform rootTransform); } [CreateAssetMenu(fileName = "New ParticleSystem Replacement", menuName = "Entity Replacements/Actions/ParticleSystem Replacement")] public class ParticleSystemReplacement : Hierarchy { [CompilerGenerated] private sealed class <Apply>d__4 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ParticleSystemReplacement <>4__this; public Transform rootTransform; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Apply>d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; ParticleSystemReplacement particleSystemReplacement = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: { <>1__state = -1; GameObject val = ((!string.IsNullOrEmpty(particleSystemReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(particleSystemReplacement.HierarchyPath)).gameObject : ((Component)rootTransform).gameObject); GameObject val2 = Object.Instantiate<GameObject>(((Component)particleSystemReplacement.NewParticleSystem).gameObject, val.transform.parent); ((Object)val2).name = ((Object)val).name; Object.Destroy((Object)(object)val); return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [field: SerializeField] public ParticleSystem NewParticleSystem { get; private set; } [IteratorStateMachine(typeof(<Apply>d__4))] public override IEnumerator Apply(Transform rootTransform) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Apply>d__4(0) { <>4__this = this, rootTransform = rootTransform }; } } [CreateAssetMenu(fileName = "New Skinned Mesh Replacement", menuName = "Entity Replacements/Actions/SkinnedMesh Replacement")] public class SkinnedMeshReplacement : Hierarchy { [CompilerGenerated] private sealed class <Apply>d__4 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public SkinnedMeshReplacement <>4__this; public Transform rootTransform; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Apply>d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; SkinnedMeshReplacement skinnedMeshReplacement = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; skinnedMeshReplacement.ReplaceSkinnedMeshRenderer((!string.IsNullOrEmpty(skinnedMeshReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(skinnedMeshReplacement.HierarchyPath)).GetComponent<SkinnedMeshRenderer>() : ((Component)rootTransform).GetComponent<SkinnedMeshRenderer>()); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [field: SerializeField] public SkinnedMeshRenderer ReplacementRenderer { get; private set; } [IteratorStateMachine(typeof(<Apply>d__4))] public override IEnumerator Apply(Transform rootTransform) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Apply>d__4(0) { <>4__this = this, rootTransform = rootTransform }; } private void ReplaceSkinnedMeshRenderer(SkinnedMeshRenderer targetSkinned) { Material[] sharedMaterials = ((Renderer)targetSkinned).sharedMaterials; Transform rootBone = targetSkinned.rootBone; Dictionary<string, Transform> dictionary = BuildBoneLookup(rootBone); Transform[] bones = ReplacementRenderer.bones; Transform[] array = (Transform[])(object)new Transform[bones.Length]; for (int i = 0; i < bones.Length; i++) { string text = (Object.op_Implicit((Object)(object)bones[i]) ? ((Object)bones[i]).name : null); if (string.IsNullOrEmpty(text) || !dictionary.TryGetValue(text, out var value)) { DuskPlugin.Logger.LogWarning((object)("TransferSMR: Could not map bone '" + text + "' with replacement: " + ((Object)ReplacementRenderer).name + ". Using root fallback.")); value = rootBone; } array[i] = value; } Transform value2 = (Object.op_Implicit((Object)(object)targetSkinned.rootBone) ? targetSkinned.rootBone : rootBone); if (Object.op_Implicit((Object)(object)ReplacementRenderer.rootBone)) { dictionary.TryGetValue(((Object)ReplacementRenderer.rootBone).name, out value2); } Mesh val = (targetSkinned.sharedMesh = ReplacementRenderer.sharedMesh); targetSkinned.bones = array; targetSkinned.rootBone = value2; MaterialsReplacement.CopyOrResizeMaterials((Renderer)(object)targetSkinned, sharedMaterials, (!Object.op_Implicit((Object)(object)val)) ? 1 : val.subMeshCount); } private static Dictionary<string, Transform> BuildBoneLookup(Transform root) { Dictionary<string, Transform> dictionary = new Dictionary<string, Transform>(); if (!Object.op_Implicit((Object)(object)root)) { return dictionary; } Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (!dictionary.ContainsKey(((Object)val).name)) { dictionary.Add(((Object)val).name, val); } } return dictionary; } } [CreateAssetMenu(fileName = "New Mesh Replacement", menuName = "Entity Replacements/Actions/Mesh Replacement")] public class MeshReplacement : Hierarchy { [CompilerGenerated] private sealed class <Apply>d__4 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MeshReplacement <>4__this; public Transform rootTransform; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Apply>d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; MeshReplacement meshReplacement = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; meshReplacement.ReplaceMeshRenderer((!string.IsNullOrEmpty(meshReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(meshReplacement.HierarchyPath)).GetComponent<MeshRenderer>() : ((Component)rootTransform).GetComponent<MeshRenderer>(), (!string.IsNullOrEmpty(meshReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(meshReplacement.HierarchyPath)).GetComponent<MeshFilter>() : ((Component)rootTransform).GetComponent<MeshFilter>()); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [field: SerializeField] public Mesh ReplacementMesh { get; private set; } [IteratorStateMachine(typeof(<Apply>d__4))] public override IEnumerator Apply(Transform rootTransform) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Apply>d__4(0) { <>4__this = this, rootTransform = rootTransform }; } private void ReplaceMeshRenderer(MeshRenderer targetMeshRenderer, MeshFilter targetMeshFilter) { targetMeshFilter.sharedMesh = ReplacementMesh; MaterialsReplacement.CopyOrResizeMaterials((Renderer)(object)targetMeshRenderer, ((Renderer)targetMeshRenderer).sharedMaterials, ReplacementMesh.subMeshCount); } } [CreateAssetMenu(fileName = "New Material Replacement", menuName = "Entity Replacements/Actions/Material Replacement")] public class MaterialsReplacement : Hierarchy { [CompilerGenerated] private sealed class <Apply>d__4 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MaterialsReplacement <>4__this; public Transform rootTransform; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Apply>d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; MaterialsReplacement materialsReplacement = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; materialsReplacement.ReplaceMaterials((!string.IsNullOrEmpty(materialsReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(materialsReplacement.HierarchyPath)).GetComponent<Renderer>() : ((Component)rootTransform).GetComponent<Renderer>()); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [field: SerializeField] public List<MaterialWithIndex> ReplacementMaterials { get; private set; } = new List<MaterialWithIndex>(); [IteratorStateMachine(typeof(<Apply>d__4))] public override IEnumerator Apply(Transform rootTransform) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Apply>d__4(0) { <>4__this = this, rootTransform = rootTransform }; } private void ReplaceMaterials(Renderer targetRenderer) { Material[] sharedMaterials = targetRenderer.sharedMaterials; foreach (MaterialWithIndex replacementMaterial in ReplacementMaterials) { if (replacementMaterial != null && replacementMaterial.Index >= 0 && replacementMaterial.Index < sharedMaterials.Length) { sharedMaterials[replacementMaterial.Index] = replacementMaterial.Material; } } targetRenderer.sharedMaterials = sharedMaterials; } internal static void CopyOrResizeMaterials(Renderer target, Material[] sourceMaterials, int requiredCount) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown if (sourceMaterials != null && sourceMaterials.Length == requiredCount) { target.sharedMaterials = sourceMaterials; return; } Material[] array = (Material[])(object)new Material[Mathf.Max(1, requiredCount)]; Material[] sharedMaterials = target.sharedMaterials; for (int i = 0; i < array.Length; i++) { if (sourceMaterials != null && i < sourceMaterials.Length && (Object)(object)sourceMaterials[i] != (Object)null) { array[i] = sourceMaterials[i]; } else if (sourceMaterials != null && sourceMaterials.Length != 0 && (Object)(object)sourceMaterials[0] != (Object)null) { array[i] = sourceMaterials[0]; } else if (sharedMaterials != null && sharedMaterials.Length != 0 && (Object)(object)sharedMaterials[0] != (Object)null) { array[i] = sharedMaterials[0]; } else { array[i] = new Material(Shader.Find("HDRP/Lit")); } } target.sharedMaterials = array; int num = ((sourceMaterials != null) ? sourceMaterials.Length : 0); DuskPlugin.Logger.LogWarning((object)$"TransferRenderer: Material count mismatch (got {num}, need {requiredCount}). Resized with fallback materials."); } } [CreateAssetMenu(fileName = "New MaterialProperties Replacement", menuName = "Entity Replacements/Actions/MaterialProperties Replacement")] public class TextureReplacement : Hierarchy { [CompilerGenerated] private sealed class <Apply>d__4 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public TextureReplacement <>4__this; public Transform rootTransform; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Apply>d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; TextureReplacement textureReplacement = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: <>1__state = -1; textureReplacement.ReplaceMaterials((!string.IsNullOrEmpty(textureReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(textureReplacement.HierarchyPath)).GetComponent<Renderer>() : ((Component)rootTransform).GetComponent<Renderer>()); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [field: SerializeField] public List<MaterialPropertiesWithIndex> ReplacementMaterialProperties { get; private set; } = new List<MaterialPropertiesWithIndex>(); [IteratorStateMachine(typeof(<Apply>d__4))] public override IEnumerator Apply(Transform rootTransform) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Apply>d__4(0) { <>4__this = this, rootTransform = rootTransform }; } private void ReplaceMaterials(Renderer targetRenderer) { //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) Material[] materials = targetRenderer.materials; foreach (MaterialPropertiesWithIndex replacementMaterialProperty in ReplacementMaterialProperties) { if (replacementMaterialProperty != null && replacementMaterialProperty.Index >= 0 && replacementMaterialProperty.Index < materials.Length) { if ((Object)(object)replacementMaterialProperty.BaseMap != (Object)null && materials[replacementMaterialProperty.Index].HasTexture("_MainTex")) { materials[replacementMaterialProperty.Index].mainTexture = (Texture)(object)replacementMaterialProperty.BaseMap; } if ((Object)(object)replacementMaterialProperty.MaskMap != (Object)null && materials[replacementMaterialProperty.Index].HasTexture("_MaskMap")) { materials[replacementMaterialProperty.Index].SetTexture("_MaskMap", (Texture)(object)replacementMaterialProperty.MaskMap); } if ((Object)(object)replacementMaterialProperty.NormalMap != (Object)null && materials[replacementMaterialProperty.Index].HasTexture("_NormalMap")) { materials[replacementMaterialProperty.Index].SetTexture("_NormalMap", (Texture)(object)replacementMaterialProperty.NormalMap); } if (replacementMaterialProperty.GradientColor != Color.black && materials[replacementMaterialProperty.Index].HasColor("_Gradient_Color")) { materials[replacementMaterialProperty.Index].SetColor("_Gradient_Color", replacementMaterialProperty.GradientColor); } } } targetRenderer.materials = materials; } } [Serializable] public class MaterialPropertiesWithIndex { [field: SerializeField] public Texture2D? BaseMap { get; private set; } [field: SerializeField] public Texture2D? MaskMap { get; private set; } [field: SerializeField] public Texture2D? NormalMap { get; private set; } [field: Tooltip("I think only hydrogere would make use of this?")] [field: SerializeField] public Color GradientColor { get; private set; } = Color.black; [field: SerializeField] public int Index { get; private set; } } [CreateAssetMenu(fileName = "New ScanNodeProperties Replacement", menuName = "Entity Replacements/Actions/ScanNodeProperties Replacement")] public class ScanNodePropertiesReplacement : Hierarchy { [CompilerGenerated] private sealed class <Apply>d__24 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public ScanNodePropertiesReplacement <>4__this; public Transform rootTransform; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Apply>d__24(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; ScanNodePropertiesReplacement scanNodePropertiesReplacement = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: { <>1__state = -1; ScanNodeProperties val = ((!string.IsNullOrEmpty(scanNodePropertiesReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(scanNodePropertiesReplacement.HierarchyPath)).GetComponent<ScanNodeProperties>() : ((Component)rootTransform).GetComponent<ScanNodeProperties>()); if (scanNodePropertiesReplacement.MaxRange > -1) { val.maxRange = scanNodePropertiesReplacement.MaxRange; } if (scanNodePropertiesReplacement.MinRange > -1) { val.minRange = scanNodePropertiesReplacement.MinRange; } if (scanNodePropertiesReplacement.NodeType > -1) { val.nodeType = scanNodePropertiesReplacement.NodeType; } val.requiresLineOfSight = scanNodePropertiesReplacement.RequiresLineOfSight; if (scanNodePropertiesReplacement.HeaderText != "Leave as such if not replacing") { val.headerText = scanNodePropertiesReplacement.HeaderText; } if (scanNodePropertiesReplacement.SubText != "Leave as such if not replacing") { val.subText = scanNodePropertiesReplacement.SubText; } return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [field: Tooltip("Leave empty if not replacing")] [field: SerializeField] public int MaxRange { get; private set; } = -1; [field: Tooltip("Leave at -1 if not replacing")] [field: SerializeField] public int MinRange { get; private set; } = -1; [field: SerializeField] public bool RequiresLineOfSight { get; private set; } = true; [field: Space(5f)] [field: SerializeField] public string HeaderText { get; private set; } = "Leave as such if not replacing"; [field: SerializeField] public string SubText { get; private set; } = "Leave as such if not replacing"; [field: Space(3f)] [field: Tooltip("0 = Blue | 1 = Red | 2 = Green")] [field: SerializeField] public int NodeType { get; private set; } = -1; [IteratorStateMachine(typeof(<Apply>d__24))] public override IEnumerator Apply(Transform rootTransform) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Apply>d__24(0) { <>4__this = this, rootTransform = rootTransform }; } } [CreateAssetMenu(fileName = "New VisualEffectAsset Replacement", menuName = "Entity Replacements/Actions/VisualEffectAsset Replacement")] public class VisualEffectReplacement : Hierarchy { [CompilerGenerated] private sealed class <Apply>d__4 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public VisualEffectReplacement <>4__this; public Transform rootTransform; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Apply>d__4(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { int num = <>1__state; VisualEffectReplacement visualEffectReplacement = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = null; <>1__state = 1; return true; case 1: { <>1__state = -1; VisualEffect val = ((!string.IsNullOrEmpty(visualEffectReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(visualEffectReplacement.HierarchyPath)).GetComponent<VisualEffect>() : ((Component)rootTransform).GetComponent<VisualEffect>()); val.visualEffectAsset = visualEffectReplacement.VisualEffectAssetReplacement; return false; } } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [field: SerializeField] public VisualEffectAsset VisualEffectAssetReplacement { get; private set; } [IteratorStateMachine(typeof(<Apply>d__4))] public override IEnumerator Apply(Transform rootTransform) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Apply>d__4(0) { <>4__this = this, rootTransform = rootTransform }; } } [CreateAssetMenu(fileName = "New Wait Action", menuName = "Entity Replacements/Actions/Wait Action")] public class WaitAction : Hierarchy { [CompilerGenerated] private sealed class <Apply>d__8 : IEnumerator<object>, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public WaitAction <>4__this; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <Apply>d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Expected O, but got Unknown int num = <>1__state; WaitAction waitAction = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(waitAction.WaitTime); <>1__state = 1; return true; case 1: <>1__state = -1; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [field: SerializeField] public float WaitTime { get; private set; } [field: HideInInspector] public new string HierarchyPath { get; private set; } [IteratorStateMachine(typeof(<Apply>d__8))] public override IEnumerator Apply(Transform rootTransform) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <Apply>d__8(0) { <>4__this = this }; } } public abstract class DuskEntityReplacementDefinition : DuskContentDefinition, INamespaced<DuskEntityReplacementDefinition>, INamespaced { [SerializeField] [InspectorName("Namespace")] [UnlockedNamespacedKey] private NamespacedKey<DuskEntityReplacementDefinition> _typedKey; internal bool IsDefault; [field: SerializeField] [field: InspectorName("Entity to be Replaced")] [field: UnlockedNamespacedKey] [field: Space(5f)] public NamespacedKey EntityToReplaceKey { get; private set; } [field: SerializeField] public DatePredicate? DatePredicate { get; private set; } [field: Space(10f)] [field: SerializeField] public List<Hierarchy> Replacements { get; private set; } = new List<Hierarchy>(); [field: Tooltip("This is where you'd add gameobjects, main use case is adding meshes or cosmetics to entities.")] [field: SerializeField] public List<GameObjectWithPath> GameObjectAddons { get; private set; } = new List<GameObjectWithPath>(); public NamespacedKey<DuskEntityReplacementDefinition> TypedKey => _typedKey; public override NamespacedKey Key { get { return (NamespacedKey)(object)TypedKey; } protected set { _typedKey = value.AsTyped<DuskEntityReplacementDefinition>(); } } [field: Header("Configs | Spawn Weights | Format: <Namespace>:<Key>=<Operation><Value>, i.e. magic_wesleys_mod:trite=+20")] [field: TextArea(1, 10)] [field: SerializeField] public string MoonSpawnWeights { get; private set; } = "Vanilla=+0, Custom=+0, Valley=+0, Canyon=+0, Tundra=+0, Marsh=+0, Military=+0, Rocky=+0,Amythest=+0, Experimentation=+0, Assurance=+0, Vow=+0, Offense=+0, March=+0, Adamance=+0, Rend=+0, Dine=+0, Titan=+0, Artifice=+0, Embrion=+0"; [field: TextArea(1, 10)] [field: SerializeField] public string InteriorSpawnWeights { get; private set; } = "Facility=+0, Mansion=+0, Mineshaft=+0"; [field: TextArea(1, 10)] [field: SerializeField] public string WeatherSpawnWeights { get; private set; } = "None=*1, DustClouds=*1, Rainy=*1, Stormy=*1, Foggy=*1, Flooded=*1, Eclipsed=*1"; [field: SerializeField] public bool GenerateSpawnWeightsConfig { get; private set; } = true; [field: Header("Configs | Misc")] [field: SerializeField] public bool GenerateDisableDateConfig { get; private set; } = true; public SpawnWeightsPreset SpawnWeights { get; private set; } = new SpawnWeightsPreset(); public ProviderTable<int?, DawnMoonInfo> Weights { get; private set; } public EntityReplacementConfig Config { get; private set; } protected override string EntityNameReference => ((NamespacedKey)TypedKey).Key; public override void Register(DuskMod mod) { if (IsDefault) { Weights = new WeightTableBuilder<DawnMoonInfo>().SetGlobalWeight(100).Build(); return; } base.Register(mod); using ConfigContext section = mod.ConfigManager.CreateConfigSectionForBundleData(AssetBundleData); Config = CreateEntityReplacementConfig(section); SpawnWeights.SetupSpawnWeightsPreset(MoonSpawnWeights, InteriorSpawnWeights, WeatherSpawnWeights); Weights = new WeightTableBuilder<DawnMoonInfo>().SetGlobalWeight((IWeighted)(object)SpawnWeights).Build(); bool flag = Config.DisableDateCheck?.Value ?? false; if (Object.op_Implicit((Object)(object)DatePredicate) && !fla
BepInEx/plugins/DawnLib/com.github.teamxiaolan.dawnlib.compatibility.dll
Decompiled 3 days agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using Microsoft.CodeAnalysis; using UnityEngine; using loaforcsSoundAPI; using loaforcsSoundAPI.SoundPacks.Data.Conditions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("XuXiaolan,loaforc")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.4.3.0")] [assembly: AssemblyInformationalVersion("0.4.3+beec3bd066ed9e9cf3d67aa86121d7c5e60c8b43")] [assembly: AssemblyProduct("DawnLib.Compatibility")] [assembly: AssemblyTitle("com.github.teamxiaolan.dawnlib.compatibility")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.4.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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; } } } namespace Dawn.Compatibility { [BepInPlugin("com.github.teamxiaolan.dawnlib.compatibility", "DawnLib.Compatibility", "0.4.3")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class DawnCompatibilityPlugin : BaseUnityPlugin { internal static ManualLogSource Logger { get; private set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; if (SoundAPICompat.Enabled) { SoundAPICompat.Init(); } Logger.LogInfo((object)"com.github.teamxiaolan.dawnlib.compatibility v0.4.3 has loaded!"); } } internal class DawnTaggableCondition : Condition { [CompilerGenerated] private Func<ITaggable?> <generator>P; private NamespacedKey? _key; public string Value { get; private set; } public DawnTaggableCondition(Func<ITaggable?> generator) { <generator>P = generator; ((Condition)this)..ctor(); } public override bool Evaluate(IContext context) { if (_key == null) { _key = NamespacedKey.ForceParse(Value); } ITaggable val = <generator>P(); if (val != null) { return val.HasTag(_key); } return false; } } internal static class SoundAPICompat { public static bool Enabled => Chainloader.PluginInfos.ContainsKey("me.loaforc.soundapi"); [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] internal static void Init() { SoundAPI.RegisterCondition("DawnLib:moon:has_tag", (Func<Condition>)(() => (Condition)(object)new DawnTaggableCondition(() => (ITaggable?)(object)((!Object.op_Implicit((Object)(object)StartOfRound.Instance)) ? null : SelectableLevelExtensions.GetDawnInfo(StartOfRound.Instance.currentLevel))))); SoundAPI.RegisterCondition("DawnLib:dungeon:has_tag", (Func<Condition>)(() => (Condition)(object)new DawnTaggableCondition(delegate { if (!Object.op_Implicit((Object)(object)RoundManager.Instance)) { return null; } return (ITaggable?)(object)((!Object.op_Implicit((Object)(object)RoundManager.Instance.dungeonGenerator)) ? null : DungeonFlowExtensions.GetDawnInfo(RoundManager.Instance.dungeonGenerator.Generator.DungeonFlow)); }))); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.github.teamxiaolan.dawnlib.compatibility"; public const string PLUGIN_NAME = "DawnLib.Compatibility"; public const string PLUGIN_VERSION = "0.4.3"; } }
BepInEx/patchers/com.github.teamxiaolan.dawnlib.preloader.dll
Decompiled 3 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Collections.Generic; using MonoMod.Utils; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("XuXiaolan,loaforc")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.4.3.0")] [assembly: AssemblyInformationalVersion("0.4.3+beec3bd066ed9e9cf3d67aa86121d7c5e60c8b43")] [assembly: AssemblyProduct("DawnLibPreloader")] [assembly: AssemblyTitle("DawnLibPreloader")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.4.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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; } } } namespace Dawn { internal static class MyPluginInfo { public const string PLUGIN_GUID = "com.github.teamxiaolan.dawnlib.preloader"; public const string PLUGIN_NAME = "DawnLibPreloader"; public const string PLUGIN_VERSION = "0.4.3"; } } namespace Dawn.Preloader { internal static class CecilHelpers { private static class Interfaces { internal static bool ImplementProperties(in TypeDefinition type, TypeDefinition @interface, in HashSet<IMemberDefinition> blacklist, out List<PropertyDefinition> properties, Action<bool, string>? logCallback = null) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) properties = new List<PropertyDefinition>(); Enumerator<PropertyDefinition> enumerator = @interface.Properties.GetEnumerator(); try { while (enumerator.MoveNext()) { PropertyDefinition current = enumerator.Current; if (ImplementProperty(in type, current, in blacklist, out PropertyDefinition implementation, logCallback)) { properties.Add(implementation); } } } finally { ((IDisposable)enumerator).Dispose(); } return true; } internal static bool ImplementEvents(in TypeDefinition type, TypeDefinition @interface, in HashSet<IMemberDefinition> blacklist, out List<EventDefinition> events, Action<bool, string>? logCallback = null) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) events = new List<EventDefinition>(); Enumerator<EventDefinition> enumerator = @interface.Events.GetEnumerator(); try { while (enumerator.MoveNext()) { EventDefinition current = enumerator.Current; if (ImplementEvent(in type, current, in blacklist, out EventDefinition implementation, logCallback)) { events.Add(implementation); } } } finally { ((IDisposable)enumerator).Dispose(); } return true; } internal static bool ImplementMethods(in TypeDefinition type, TypeDefinition @interface, in HashSet<IMemberDefinition> blacklist, out List<MethodDefinition> methods, Action<bool, string>? logCallback = null) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) methods = new List<MethodDefinition>(); Enumerator<MethodDefinition> enumerator = @interface.Methods.GetEnumerator(); try { while (enumerator.MoveNext()) { MethodDefinition current = enumerator.Current; if (ImplementMethod(in type, current, in blacklist, out MethodDefinition implementation, logCallback)) { methods.Add(implementation); } } } finally { ((IDisposable)enumerator).Dispose(); } return true; } private static bool ImplementProperty(in TypeDefinition type, PropertyDefinition property, in HashSet<IMemberDefinition> blacklist, [NotNullWhen(true)] out PropertyDefinition? implementation, Action<bool, string>? logCallback = null) { //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Expected O, but got Unknown //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: 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_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Expected O, but got Unknown //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Expected O, but got Unknown //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) PropertyDefinition property2 = property; Action<bool, string> logCallback2 = logCallback; implementation = property2; FieldDefinition backingField = null; bool hasImplementation = false; if (!blacklist.Add((IMemberDefinition)(object)property2)) { return true; } logCallback2?.Invoke(arg1: false, "Adding Property '" + ((MemberReference)property2).Name + "' to " + ((MemberReference)type).FullName + "'"); MethodDefinition getMethod = property2.GetMethod; if (getMethod != null && getMethod.IsAbstract && blacklist.Add((IMemberDefinition)(object)property2.GetMethod)) { if (!Init(in type, out implementation)) { return false; } logCallback2?.Invoke(arg1: false, "Adding getter of '" + ((MemberReference)property2).Name + "' to " + ((MemberReference)type).FullName + "'"); if (Extensions.FindMethod(type, "get_" + ((MemberReference)property2).Name, true) != null) { logCallback2?.Invoke(arg1: true, "Method 'get_" + ((MemberReference)property2).Name + "' is already defined in '" + ((MemberReference)type).FullName + "'"); return false; } MethodDefinition val = new MethodDefinition("get_" + ((MemberReference)property2).Name, (MethodAttributes)2534, ((PropertyReference)property2).PropertyType); ILProcessor iLProcessor = val.Body.GetILProcessor(); iLProcessor.Emit(OpCodes.Ldarg_0); iLProcessor.Emit(OpCodes.Ldfld, (FieldReference)(object)backingField); iLProcessor.Emit(OpCodes.Ret); type.Methods.Add(val); implementation.GetMethod = val; } getMethod = property2.SetMethod; if (getMethod != null && getMethod.IsAbstract && blacklist.Add((IMemberDefinition)(object)property2.SetMethod)) { if (!hasImplementation && !Init(in type, out implementation)) { return false; } logCallback2?.Invoke(arg1: false, "Adding setter of '" + ((MemberReference)property2).Name + "' to " + ((MemberReference)type).FullName + "'"); if (Extensions.FindMethod(type, "set_" + ((MemberReference)property2).Name, true) != null) { logCallback2?.Invoke(arg1: true, "Method 'set_" + ((MemberReference)property2).Name + "' is already defined in '" + ((MemberReference)type).FullName + "'"); return false; } MethodDefinition val2 = new MethodDefinition("set_" + ((MemberReference)property2).Name, (MethodAttributes)2534, ((MemberReference)type).Module.TypeSystem.Void); ((MethodReference)val2).Parameters.Add(new ParameterDefinition("value", (ParameterAttributes)0, ((PropertyReference)property2).PropertyType)); ILProcessor iLProcessor2 = val2.Body.GetILProcessor(); iLProcessor2.Emit(OpCodes.Ldarg_0); iLProcessor2.Emit(OpCodes.Ldarg_1); iLProcessor2.Emit(OpCodes.Stfld, (FieldReference)(object)backingField); iLProcessor2.Emit(OpCodes.Ret); type.Methods.Add(val2); implementation.SetMethod = val2; } if (!hasImplementation) { return true; } type.Fields.Add(backingField); type.Properties.Add(implementation); return true; bool Init(in TypeDefinition type, [NotNullWhen(true)] out PropertyDefinition? implementation) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Expected O, but got Unknown implementation = null; if (Extensions.FindField(type, "<" + ((MemberReference)property2).Name + ">k__BackingField") != null) { logCallback2?.Invoke(arg1: true, "Field '<" + ((MemberReference)property2).Name + ">k__BackingField' already exists in " + ((MemberReference)type).FullName); return false; } backingField = new FieldDefinition("<" + ((MemberReference)property2).Name + ">k__BackingField", (FieldAttributes)1, ((PropertyReference)property2).PropertyType); if (Extensions.FindProperty(type, ((MemberReference)property2).Name) != null) { logCallback2?.Invoke(arg1: true, "Property '" + ((MemberReference)property2).Name + "' already exists in " + ((MemberReference)type).FullName); return false; } implementation = new PropertyDefinition(((MemberReference)property2).Name, (PropertyAttributes)0, ((PropertyReference)property2).PropertyType); hasImplementation = true; return true; } } private static bool ImplementEvent(in TypeDefinition type, EventDefinition @event, in HashSet<IMemberDefinition> blacklist, [NotNullWhen(true)] out EventDefinition? implementation, Action<bool, string>? logCallback = null) { //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Expected O, but got Unknown //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Expected O, but got Unknown //IL_01e2: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Expected O, but got Unknown //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Expected O, but got Unknown //IL_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_0608: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Expected O, but got Unknown //IL_061f: Unknown result type (might be due to invalid IL or missing references) //IL_0624: Unknown result type (might be due to invalid IL or missing references) //IL_0641: Unknown result type (might be due to invalid IL or missing references) //IL_064d: Unknown result type (might be due to invalid IL or missing references) //IL_0657: Expected O, but got Unknown //IL_0680: Unknown result type (might be due to invalid IL or missing references) //IL_068c: Unknown result type (might be due to invalid IL or missing references) //IL_06a3: Unknown result type (might be due to invalid IL or missing references) //IL_06c9: Unknown result type (might be due to invalid IL or missing references) //IL_071a: Unknown result type (might be due to invalid IL or missing references) EventDefinition event2 = @event; Action<bool, string> logCallback2 = logCallback; implementation = event2; FieldDefinition backingField = null; bool hasImplementation = false; if (!blacklist.Add((IMemberDefinition)(object)event2)) { return true; } logCallback2?.Invoke(arg1: false, "Adding Event '" + ((MemberReference)event2).Name + "' to " + ((MemberReference)type).FullName + "'"); MethodDefinition addMethod = event2.AddMethod; if (addMethod != null && addMethod.IsAbstract && blacklist.Add((IMemberDefinition)(object)event2.AddMethod)) { if (!Init(in type, out implementation)) { return false; } logCallback2?.Invoke(arg1: false, "Adding registration of '" + ((MemberReference)event2).Name + "' to " + ((MemberReference)type).FullName + "'"); if (Extensions.FindMethod(type, "add_" + ((MemberReference)event2).Name, true) != null) { logCallback2?.Invoke(arg1: true, "Method 'add_" + ((MemberReference)event2).Name + "' is already defined in '" + ((MemberReference)type).FullName + "'"); return false; } MethodDefinition val = new MethodDefinition("add_" + ((MemberReference)event2).Name, (MethodAttributes)2534, ((MemberReference)type).Module.TypeSystem.Void); ((MethodReference)val).Parameters.Add(new ParameterDefinition("value", (ParameterAttributes)0, ((EventReference)event2).EventType)); ILProcessor iLProcessor = val.Body.GetILProcessor(); iLProcessor.Emit(OpCodes.Ldarg_0); iLProcessor.Emit(OpCodes.Ldarg_0); iLProcessor.Emit(OpCodes.Ldfld, (FieldReference)(object)backingField); iLProcessor.Emit(OpCodes.Ldarg_1); iLProcessor.Emit(OpCodes.Call, ((MemberReference)type).Module.ImportReference((MethodBase)typeof(Delegate).GetMethod("Combine", new Type[2] { typeof(Delegate), typeof(Delegate) }))); iLProcessor.Emit(OpCodes.Castclass, ((EventReference)event2).EventType); iLProcessor.Emit(OpCodes.Stfld, (FieldReference)(object)backingField); iLProcessor.Emit(OpCodes.Ret); type.Methods.Add(val); implementation.AddMethod = val; } addMethod = event2.RemoveMethod; if (addMethod != null && addMethod.IsAbstract && blacklist.Add((IMemberDefinition)(object)event2.RemoveMethod)) { if (!hasImplementation && !Init(in type, out implementation)) { return false; } logCallback2?.Invoke(arg1: false, "Adding de-registration of '" + ((MemberReference)event2).Name + "' to " + ((MemberReference)type).FullName + "'"); if (Extensions.FindMethod(type, "remove_" + ((MemberReference)event2).Name, true) != null) { logCallback2?.Invoke(arg1: true, "Method 'remove_" + ((MemberReference)event2).Name + "' is already defined in '" + ((MemberReference)type).FullName + "'"); return false; } MethodDefinition val2 = new MethodDefinition("remove_" + ((MemberReference)event2).Name, (MethodAttributes)2534, ((MemberReference)type).Module.TypeSystem.Void); ((MethodReference)val2).Parameters.Add(new ParameterDefinition("value", (ParameterAttributes)0, ((EventReference)event2).EventType)); ILProcessor iLProcessor2 = val2.Body.GetILProcessor(); iLProcessor2.Emit(OpCodes.Ldarg_0); iLProcessor2.Emit(OpCodes.Ldarg_0); iLProcessor2.Emit(OpCodes.Ldfld, (FieldReference)(object)backingField); iLProcessor2.Emit(OpCodes.Ldarg_1); iLProcessor2.Emit(OpCodes.Call, ((MemberReference)type).Module.ImportReference((MethodBase)typeof(Delegate).GetMethod("Remove", new Type[2] { typeof(Delegate), typeof(Delegate) }))); iLProcessor2.Emit(OpCodes.Castclass, ((EventReference)event2).EventType); iLProcessor2.Emit(OpCodes.Stfld, (FieldReference)(object)backingField); iLProcessor2.Emit(OpCodes.Ret); type.Methods.Add(val2); implementation.RemoveMethod = val2; } addMethod = event2.InvokeMethod; if (addMethod != null && addMethod.IsAbstract && blacklist.Add((IMemberDefinition)(object)event2.InvokeMethod)) { if (!hasImplementation && !Init(in type, out implementation)) { return false; } logCallback2?.Invoke(arg1: false, "Adding invocation of '" + ((MemberReference)event2).Name + "' to " + ((MemberReference)type).FullName + "'"); if (Extensions.FindMethod(type, "raise_" + ((MemberReference)event2).Name, true) != null) { logCallback2?.Invoke(arg1: true, "Method 'raise_" + ((MemberReference)event2).Name + "' is already defined in '" + ((MemberReference)type).FullName + "'"); return false; } MethodDefinition val3 = new MethodDefinition("raise_" + ((MemberReference)event2).Name, (MethodAttributes)2534, ((MemberReference)type).Module.TypeSystem.Void); Enumerator<ParameterDefinition> enumerator = ((MethodReference)event2.InvokeMethod).Parameters.GetEnumerator(); try { while (enumerator.MoveNext()) { ParameterDefinition current = enumerator.Current; ((MethodReference)val3).Parameters.Add(new ParameterDefinition(((ParameterReference)current).Name, current.Attributes, ((ParameterReference)current).ParameterType)); } } finally { ((IDisposable)enumerator).Dispose(); } ILProcessor iLProcessor3 = val3.Body.GetILProcessor(); iLProcessor3.Emit(OpCodes.Ldarg_0); iLProcessor3.Emit(OpCodes.Ldfld, (FieldReference)(object)backingField); for (int i = 0; i < ((MethodReference)val3).Parameters.Count; i++) { iLProcessor3.Emit(OpCodes.Ldarg, i + 1); } iLProcessor3.Emit(OpCodes.Callvirt, ((MemberReference)type).Module.ImportReference((MethodReference)(object)((IEnumerable<MethodDefinition>)((EventReference)event2).EventType.Resolve().Methods).First((MethodDefinition m) => ((MemberReference)m).Name == "Invoke"))); iLProcessor3.Emit(OpCodes.Ret); type.Methods.Add(val3); implementation.InvokeMethod = val3; } if (!hasImplementation) { return true; } type.Fields.Add(backingField); type.Events.Add(implementation); return true; bool Init(in TypeDefinition type, [NotNullWhen(true)] out EventDefinition? implementation) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Expected O, but got Unknown implementation = null; if (Extensions.FindField(type, ((MemberReference)event2).Name) != null) { logCallback2?.Invoke(arg1: true, "Field '" + ((MemberReference)event2).Name + "' already exists in " + ((MemberReference)type).FullName); return false; } backingField = new FieldDefinition(((MemberReference)event2).Name, (FieldAttributes)1, ((EventReference)event2).EventType); if (Extensions.FindEvent(type, ((MemberReference)event2).Name) != null) { logCallback2?.Invoke(arg1: true, "Event '" + ((MemberReference)event2).Name + "' already exists in " + ((MemberReference)type).FullName); return false; } implementation = new EventDefinition(((MemberReference)event2).Name, (EventAttributes)0, ((EventReference)event2).EventType); hasImplementation = true; return true; } } private static bool ImplementMethod(in TypeDefinition type, MethodDefinition method, in HashSet<IMemberDefinition> blacklist, out MethodDefinition implementation, Action<bool, string>? logCallback = null) { //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown //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_00ee: 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_0103: Expected O, but got Unknown //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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) implementation = method; if (!blacklist.Add((IMemberDefinition)(object)method)) { return true; } logCallback?.Invoke(arg1: false, "Adding Method '" + ((MemberReference)method).Name + "' to " + ((MemberReference)type).FullName + "'"); if (!method.IsAbstract) { implementation = method; return true; } if (Extensions.FindMethod(type, ((MemberReference)method).Name, true) != null) { logCallback?.Invoke(arg1: true, "Method '" + ((MemberReference)method).Name + "' is already defined in '" + ((MemberReference)type).FullName + "'"); return false; } implementation = new MethodDefinition(((MemberReference)method).Name, (MethodAttributes)358, ((MethodReference)method).ReturnType); Enumerator<ParameterDefinition> enumerator = ((MethodReference)method).Parameters.GetEnumerator(); try { while (enumerator.MoveNext()) { ParameterDefinition current = enumerator.Current; ((MethodReference)implementation).Parameters.Add(new ParameterDefinition(((ParameterReference)current).Name, current.Attributes, ((ParameterReference)current).ParameterType)); } } finally { ((IDisposable)enumerator).Dispose(); } ILProcessor iLProcessor = implementation.Body.GetILProcessor(); if (((MemberReference)((MethodReference)method).ReturnType).FullName != "System.Void") { ConstructorInfo constructor = typeof(NotImplementedException).GetConstructor(new Type[1] { typeof(string) }); MethodReference val = ((MemberReference)type).Module.ImportReference((MethodBase)constructor); iLProcessor.Emit(OpCodes.Ldstr, "This is a Stub"); iLProcessor.Emit(OpCodes.Newobj, val); iLProcessor.Emit(OpCodes.Throw); } else { iLProcessor.Emit(OpCodes.Ret); } type.Methods.Add(implementation); return true; } } public static T GetAttributeInstance<T>(this CustomAttribute ceciAttribute) where T : Attribute { Type typeFromHandle = typeof(T); object[] args = ((IEnumerable<CustomAttributeArgument>)ceciAttribute.ConstructorArguments).Select((CustomAttributeArgument ca) => ((CustomAttributeArgument)(ref ca)).Value).ToArray(); return (T)Activator.CreateInstance(typeFromHandle, args); } internal static bool AddRaise(this TypeDefinition self, string eventName, Action<bool, string>? logCallback = null) { //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: 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: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown //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) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: 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_0218: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) string text = "call_" + eventName; logCallback?.Invoke(arg1: false, "Adding caller for event '" + eventName + "' to " + ((MemberReference)self).FullName); EventDefinition val = Extensions.FindEvent(self, eventName); if (val == null) { logCallback?.Invoke(arg1: true, "Event '" + eventName + "' does not exists in " + ((MemberReference)self).FullName); return false; } FieldDefinition val2 = Extensions.FindField(self, eventName); if (val2 == null) { logCallback?.Invoke(arg1: true, "Field '" + eventName + "' does not exists in " + ((MemberReference)self).FullName); return false; } if (Extensions.FindMethod(self, text, true) != null) { logCallback?.Invoke(arg1: true, "Method '" + text + "' already exists in " + ((MemberReference)self).FullName); return false; } MethodDefinition val3 = Extensions.FindMethod(((FieldReference)val2).FieldType.Resolve(), "Invoke", true); MethodReference val4 = ((MemberReference)self).Module.ImportReference((MethodReference)(object)val3); bool flag = false; MethodAttributes val5 = (MethodAttributes)0; if ((val2.Attributes & 0x10) != 0) { val5 = (MethodAttributes)(val5 | 0x10); flag = true; } if ((val2.Attributes & 1) != 0) { val5 = (MethodAttributes)(val5 | 1); } MethodDefinition val6 = new MethodDefinition(text, val5, ((FieldReference)val2).FieldType); self.Methods.Add(val6); Extensions.AddRange<ParameterDefinition>(((MethodReference)val6).Parameters, (IEnumerable<ParameterDefinition>)val4.Parameters); Collection<Instruction> instructions = val6.Body.Instructions; Instruction val7 = Instruction.Create(OpCodes.Pop); Instruction val8 = Instruction.Create(OpCodes.Ret); Extensions.AddRange<Instruction>(instructions, (IEnumerable<Instruction>)new <>z__ReadOnlyArray<Instruction>((Instruction[])(object)new Instruction[6] { Instruction.Create(flag ? OpCodes.Nop : OpCodes.Ldarg_0), Instruction.Create(flag ? OpCodes.Ldsfld : OpCodes.Ldfld, (FieldReference)(object)val2), Instruction.Create(OpCodes.Dup), Instruction.Create(OpCodes.Ldnull), Instruction.Create(OpCodes.Cgt_Un), Instruction.Create(OpCodes.Brfalse, val7) })); Enumerator<ParameterDefinition> enumerator = ((MethodReference)val6).Parameters.GetEnumerator(); try { while (enumerator.MoveNext()) { ParameterDefinition current = enumerator.Current; instructions.Add(Instruction.Create(OpCodes.Ldarg, current)); } } finally { ((IDisposable)enumerator).Dispose(); } instructions.Add(Instruction.Create(OpCodes.Callvirt, val4)); instructions.Add(Instruction.Create(OpCodes.Br, val8)); Extensions.AddRange<Instruction>(instructions, (IEnumerable<Instruction>)new <>z__ReadOnlyArray<Instruction>((Instruction[])(object)new Instruction[2] { val7, val8 })); return true; } internal static bool ImplementInterface(this TypeDefinition self, Type @interface, Action<bool, string>? logCallback = null) { if (!@interface.IsInterface) { logCallback?.Invoke(arg1: true, "Type '" + @interface.FullName + "' is not an interface!"); return false; } return self.ImplementInterface(((MemberReference)self).Module.ImportReference(@interface), logCallback); } internal static bool ImplementInterface(this TypeDefinition self, TypeReference @interface, Action<bool, string>? logCallback = null) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown TypeDefinition val = @interface.Resolve(); if (!val.IsInterface) { logCallback?.Invoke(arg1: true, "Type '" + ((MemberReference)@interface).FullName + "' is not an interface!"); return false; } logCallback?.Invoke(arg1: false, "Adding '" + ((MemberReference)@interface).FullName + "' to " + ((MemberReference)self).FullName + "'"); TypeReference val2 = ((MemberReference)self).Module.ImportReference(@interface); HashSet<IMemberDefinition> blacklist = new HashSet<IMemberDefinition>(); if (!Interfaces.ImplementProperties(in self, val, in blacklist, out List<PropertyDefinition> _, logCallback)) { return false; } if (!Interfaces.ImplementEvents(in self, val, in blacklist, out List<EventDefinition> _, logCallback)) { return false; } if (!Interfaces.ImplementMethods(in self, val, in blacklist, out List<MethodDefinition> _, logCallback)) { return false; } self.Interfaces.Add(new InterfaceImplementation(val2)); return true; } } internal class DawnLibPreloader { private static readonly Dictionary<string, Dictionary<string, List<TypeDefinition>>> Interfaces = new Dictionary<string, Dictionary<string, List<TypeDefinition>>>(); internal static ManualLogSource Log { get; } = Logger.CreateLogSource("DawnLib.Preloader"); public static IEnumerable<string> TargetDLLs { get; } = new string[1] { "Assembly-CSharp.dll" }; public static void Patch(AssemblyDefinition assembly) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) if (!Interfaces.TryGetValue(((AssemblyNameReference)assembly.Name).Name, out Dictionary<string, List<TypeDefinition>> value)) { return; } Log.LogWarning((object)("Patching " + ((AssemblyNameReference)assembly.Name).Name)); Enumerator<TypeDefinition> enumerator = assembly.MainModule.Types.GetEnumerator(); try { while (enumerator.MoveNext()) { TypeDefinition current = enumerator.Current; if (!value.TryGetValue(((MemberReference)current).Name, out var value2)) { continue; } foreach (TypeDefinition item in value2) { if (!current.ImplementInterface((TypeReference)(object)item, logHandler)) { break; } } } } finally { ((IDisposable)enumerator).Dispose(); } static void logHandler(bool fail, string message) { if (fail) { Log.LogWarning((object)message); } else { Log.LogDebug((object)message); } } } public static void Initialize() { //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) Log.LogInfo((object)"DawnLibPreloaderPrepatcher Started"); string text = Directory.EnumerateDirectories(Paths.PluginPath).FirstOrDefault((string d) => d.Contains("DawnLib")); if (text == null) { Log.LogFatal((object)("Could not find plugins path! DawnLib not found at path: " + Paths.PluginPath)); return; } string text2 = Path.Combine(text, "DawnLib", "com.github.teamxiaolan.dawnlib.interfaces.dll"); if (!File.Exists(text2)) { Log.LogFatal((object)"Could not find Interfaces dll!"); return; } AssemblyDefinition val = AssemblyDefinition.ReadAssembly(text2); string attributeName = typeof(InjectInterfaceAttribute).FullName; Enumerator<TypeDefinition> enumerator = val.MainModule.Types.GetEnumerator(); try { while (enumerator.MoveNext()) { TypeDefinition current = enumerator.Current; if (!current.IsInterface) { continue; } IEnumerable<CustomAttribute> enumerable = ((IEnumerable<CustomAttribute>)current.CustomAttributes).Where((CustomAttribute at) => ((MemberReference)at.AttributeType).FullName == attributeName); foreach (CustomAttribute item in enumerable) { InjectInterfaceAttribute attributeInstance = item.GetAttributeInstance<InjectInterfaceAttribute>(); if (!Interfaces.TryGetValue(attributeInstance.AssemblyName, out Dictionary<string, List<TypeDefinition>> value)) { value = (Interfaces[attributeInstance.AssemblyName] = new Dictionary<string, List<TypeDefinition>>()); } if (!value.TryGetValue(attributeInstance.TypeName, out var value2)) { value2 = (value[attributeInstance.TypeName] = new List<TypeDefinition>()); } value2.Add(current); } } } finally { ((IDisposable)enumerator).Dispose(); } } public static void Finish() { Log.LogInfo((object)"Prepatcher Finished"); } } [AttributeUsage(AttributeTargets.Interface, AllowMultiple = true)] public sealed class InjectInterfaceAttribute : Attribute { [CompilerGenerated] private string <typeName>P; [CompilerGenerated] private string <assemblyName>P; public string AssemblyName => <assemblyName>P; public string TypeName => <typeName>P; public InjectInterfaceAttribute(string typeName, string assemblyName = "Assembly-CSharp") { <typeName>P = typeName; <assemblyName>P = assemblyName; base..ctor(); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } } [CompilerGenerated] internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { 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<T>.Count => _items.Length; T IReadOnlyList<T>.this[int index] => _items[index]; int ICollection<T>.Count => _items.Length; bool ICollection<T>.IsReadOnly => true; T IList<T>.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<T> IEnumerable<T>.GetEnumerator() { return ((IEnumerable<T>)_items).GetEnumerator(); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return ((ICollection<T>)_items).Contains(item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { ((ICollection<T>)_items).CopyTo(array, arrayIndex); } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { return ((IList<T>)_items).IndexOf(item); } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } }
BepInEx/plugins/DawnLib/com.github.teamxiaolan.dawnlib.interfaces.dll
Decompiled 3 days agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using Dawn.Preloader; using Microsoft.CodeAnalysis; using Newtonsoft.Json.Linq; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [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("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [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("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: AssemblyCompany("XuXiaolan,loaforc")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.4.3.0")] [assembly: AssemblyInformationalVersion("0.4.3+beec3bd066ed9e9cf3d67aa86121d7c5e60c8b43")] [assembly: AssemblyProduct("DawnLibInterfaces")] [assembly: AssemblyTitle("DawnLibInterfaces")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.4.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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; } } } namespace Dawn { internal static class MyPluginInfo { public const string PLUGIN_GUID = "com.github.teamxiaolan.dawnlib.interfaces"; public const string PLUGIN_NAME = "DawnLibInterfaces"; public const string PLUGIN_VERSION = "0.4.3"; } } namespace Dawn.Interfaces { [InjectInterface("EnemyAINestSpawnObject", "Assembly-CSharp")] [InjectInterface("RandomMapObject", "Assembly-CSharp")] [InjectInterface("PlaceableShipObject", "Assembly-CSharp")] internal interface IAwakeMethod { void Awake(); } [InjectInterface("EnemyAI", "Assembly-CSharp")] [InjectInterface("GrabbableObject", "Assembly-CSharp")] [InjectInterface("EnemyAINestSpawnObject", "Assembly-CSharp")] public interface ICurrentEntityReplacement { object? CurrentEntityReplacement { get; set; } } [InjectInterface("SelectableLevel", "Assembly-CSharp")] [InjectInterface("WeatherEffect", "Assembly-CSharp")] [InjectInterface("EnemyType", "Assembly-CSharp")] [InjectInterface("Item", "Assembly-CSharp")] [InjectInterface("UnlockableItem", "Assembly-CSharp")] [InjectInterface("TileSet", "Assembly-CSharp")] [InjectInterface("DungeonArchetype", "Assembly-CSharp")] [InjectInterface("DungeonFlow", "Assembly-CSharp")] [InjectInterface("BuyableVehicle", "Assembly-CSharp")] public interface IDawnObject { object DawnInfo { get; set; } } [InjectInterface("GrabbableObject", "Assembly-CSharp")] public interface IDawnSaveData { JToken GetDawnDataToSave() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return JToken.op_Implicit(((GrabbableObject)this).GetItemDataToSave()); } void LoadDawnSaveData(JToken saveData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) if ((int)saveData.Type == 6) { ((GrabbableObject)this).LoadItemSaveData((int)saveData); } } } [InjectInterface("ScanNodeProperties", "Assembly-CSharp")] public interface IDawnScanNode { object RectTransformInfo { get; set; } } [InjectInterface("PlaceableShipObject", "Assembly-CSharp")] internal interface IOnDestroyMethod { void OnDestroy(); } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }