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.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using Dawn; using Dawn.Interfaces; using Dawn.Internal; using Dawn.Utils; using DunGen; using DunGen.Graph; using Dusk; using Dusk.Internal; using Dusk.Utils; using Dusk.Weights; using GameNetcodeStuff; using HarmonyLib; using IL; using IL.GameNetcodeStuff; using LethalConfig; using LethalConfig.AutoConfig; using LethalConfig.ConfigItems; using LethalConfig.Mods; 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: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("ClientNetworkTransform")] [assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")] [assembly: IgnoresAccessChecksTo("DissonanceVoip")] [assembly: IgnoresAccessChecksTo("DunGen")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.ASPP")] [assembly: IgnoresAccessChecksTo("DunGen.Integration.UnityNav")] [assembly: IgnoresAccessChecksTo("EasyTextEffects")] [assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")] [assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")] [assembly: IgnoresAccessChecksTo("LethalConfig")] [assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")] [assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")] [assembly: IgnoresAccessChecksTo("Unity.Burst")] [assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")] [assembly: IgnoresAccessChecksTo("Unity.Collections")] [assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem")] [assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")] [assembly: IgnoresAccessChecksTo("Unity.Jobs")] [assembly: IgnoresAccessChecksTo("Unity.Mathematics")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")] [assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")] [assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")] [assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")] [assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Components")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")] [assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")] [assembly: IgnoresAccessChecksTo("Unity.Services.QoS")] [assembly: IgnoresAccessChecksTo("Unity.Services.Relay")] [assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")] [assembly: IgnoresAccessChecksTo("Unity.Timeline")] [assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")] [assembly: IgnoresAccessChecksTo("Unity.XR.CoreUtils")] [assembly: IgnoresAccessChecksTo("Unity.XR.Management")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.ConformanceAutomation")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MetaQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.MockRuntime")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.OculusQuestSupport")] [assembly: IgnoresAccessChecksTo("Unity.XR.OpenXR.Features.RuntimeDebugger")] [assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")] [assembly: IgnoresAccessChecksTo("UnityEngine.SpatialTracking")] [assembly: IgnoresAccessChecksTo("UnityEngine.UI")] [assembly: IgnoresAccessChecksTo("UnityEngine.XR.LegacyInputHelpers")] [assembly: IgnoresAccessChecksTo("WeatherRegistry")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("XuXiaolan,loaforc")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Assetloading, content and config management built ontop of DawnLib.")] [assembly: AssemblyFileVersion("0.9.21.0")] [assembly: AssemblyInformationalVersion("0.9.21+78d07c774d74f29674974668e8e7aca2a1029d4a")] [assembly: AssemblyProduct("DawnLib.DuskMod")] [assembly: AssemblyTitle("com.github.teamxiaolan.dawnlib.dusk")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.9.21.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] [module: NetcodePatchedAssembly] [CompilerGenerated] internal sealed class <>z__ReadOnlySingleElementList : IEnumerable, ICollection, IList, IEnumerable, IReadOnlyCollection, IReadOnlyList, ICollection, IList { private sealed class Enumerator : IDisposable, IEnumerator, IEnumerator { object IEnumerator.Current => _item; T IEnumerator.Current => _item; public Enumerator(T item) { _item = item; } bool IEnumerator.MoveNext() { if (!_moveNextCalled) { return _moveNextCalled = true; } return false; } void IEnumerator.Reset() { _moveNextCalled = false; } void IDisposable.Dispose() { } } int ICollection.Count => 1; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection.Count => 1; T IReadOnlyList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } } int ICollection.Count => 1; bool ICollection.IsReadOnly => true; T IList.this[int index] { get { if (index != 0) { throw new IndexOutOfRangeException(); } return _item; } set { throw new NotSupportedException(); } } public <>z__ReadOnlySingleElementList(T item) { _item = item; } IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(_item); } void ICollection.CopyTo(Array array, int index) { array.SetValue(_item, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return EqualityComparer.Default.Equals(_item, (T)value); } int IList.IndexOf(object value) { if (!EqualityComparer.Default.Equals(_item, (T)value)) { return -1; } return 0; } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator IEnumerable.GetEnumerator() { return new Enumerator(_item); } void ICollection.Add(T item) { throw new NotSupportedException(); } void ICollection.Clear() { throw new NotSupportedException(); } bool ICollection.Contains(T item) { return EqualityComparer.Default.Equals(_item, item); } void ICollection.CopyTo(T[] array, int arrayIndex) { array[arrayIndex] = _item; } bool ICollection.Remove(T item) { throw new NotSupportedException(); } int IList.IndexOf(T item) { if (!EqualityComparer.Default.Equals(_item, item)) { return -1; } return 0; } void IList.Insert(int index, T item) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } } 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 { internal static class DuskLethalConfigCompat { internal const string VERSION = "1.4.6"; public static bool Enabled { get { //IL_0016: Unknown result type (might be due to invalid IL or missing references) if (Chainloader.PluginInfos.ContainsKey("ainavt.lc.lethalconfig")) { return CompatibilityBoolExtensions.ShouldRunCompatibility(DawnConfig.LethalConfigCompatibility.Value, "1.4.6", Chainloader.PluginInfos["ainavt.lc.lethalconfig"].Metadata.Version); } return false; } } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void CreateLethalConfigMod(DuskMod duskMod) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown ModInfo val = new ModInfo { Name = duskMod.ModInformation.ModName, Guid = "com.local." + duskMod.ModInformation.ModName + "." + duskMod.ModInformation.AuthorName, Version = duskMod.ModInformation.Version, Description = duskMod.ModInformation.ModDescription, Icon = duskMod.ModInformation.ModIcon }; Mod val2 = new Mod(val); LethalConfigManager.Mods.Add(val.Guid, val2); foreach (ConfigEntryBase configEntry in duskMod.ConfigEntries) { DebugLogSource lethalConfig = Debuggers.LethalConfig; if (lethalConfig != null) { lethalConfig.Log((object)$"No-Code DuskMod | Generating config item for {configEntry.Definition.Section}.{configEntry.Definition.Key} with type {configEntry.SettingType} and value {configEntry.BoxedValue}"); } BaseConfigItem val3 = AutoConfigGenerator.GenerateConfigForEntry(configEntry); if (val3 != null) { val3.IsAutoGenerated = true; val3.Owner = val2; val2.ConfigItems.Add(val3); } } } } } namespace Dusk { [Serializable] public class AssetBundleData { [AssetBundleReference] public string assetBundleName; public bool enabledByDefault = true; [AssertNotEmpty] public string configName; } public abstract class AssetBundleLoader : IAssetBundleLoader where TLoader : AssetBundleLoader { private readonly bool _hasNonPreloadAudioClips; private List _audioClipNames = new List(); private readonly bool _hasVideoClips; private List _videoClipNames = new List(); private AssetBundle? _bundle; public AssetBundleData AssetBundleData { get; set; } public DuskContentDefinition[] Content { get; } public Dictionary ConfigEntries => Content.SelectMany((DuskContentDefinition c) => c.generalConfigs).ToDictionary, string, ConfigEntryBase>((KeyValuePair it) => it.Key, (KeyValuePair 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() == (Object)null)) { DawnLib.RegisterNetworkPrefab(val2); DebugLogSource assetLoading3 = Debuggers.AssetLoading; if (assetLoading3 != null) { assetLoading3.Log((object)("Registered Network Prefab: " + ((Object)val2).name)); } } } Content = bundle.LoadAllAssets(); List definitionOrder = new List(14) { typeof(DuskMoonDefinition), typeof(DuskDungeonDefinition), typeof(DuskWeatherDefinition), typeof(DuskVehicleDefinition), typeof(DuskMapObjectDefinition), typeof(DuskEnemyDefinition), typeof(DuskUnlockableDefinition), typeof(DuskItemDefinition), typeof(DuskTerminalCommandDefinition), typeof(DuskEntityReplacementDefinition), typeof(DuskStoryLogDefinition), typeof(DuskAchievementDefinition), typeof(DuskSurfaceDefinition), 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 GetConfig(string configName) { return (ConfigEntry)(object)ConfigEntries[configName]; } public bool TryGetConfig(string configName, [NotNullWhen(true)] out ConfigEntry? entry) { if (ConfigEntries.TryGetValue(configName, out ConfigEntryBase value)) { entry = (ConfigEntry)(object)value; return true; } 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(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 assetBundles; } public class DefaultBundle : AssetBundleLoader { 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, AllowMultiple = false, Inherited = true)] public sealed class DefaultKeySourceAttribute : PropertyAttribute { public string MemberName { get; } public bool Normalize { get; } public DefaultKeySourceAttribute(string memberName, bool normalize = true) { MemberName = memberName; Normalize = normalize; ((PropertyAttribute)this)..ctor(); } } [AttributeUsage(AttributeTargets.Field)] public class DontDrawIfEmpty : PropertyAttribute { public string? GroupId { get; } public string? Header { get; } public DontDrawIfEmpty(string? groupId = null, string? header = null) { GroupId = groupId; Header = header; ((PropertyAttribute)this)..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(); 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 { DefaultBundle bundle = new DefaultBundle(AssetBundle.LoadFromFile(fullPath)) { AssetBundleData = assetBundle }; LoadAllContent(bundle); } } } } [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 ExtraDependencies { get; internal set; } = new List(); [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 P; [CompilerGenerated] private string P; public ConfigContext(ConfigFile file, string heading) { P = file; P = heading; base..ctor(); } public void Dispose() { } public ConfigEntry Bind(string name, string description, T defaultValue) { return ConfigFileExtensions.CleanedBind(P, P, name, defaultValue, description); } } public class ConfigManager { public ConfigFile File { get; } public ConfigManager(ConfigFile file) { File = file; base..ctor(); } public ConfigContext CreateConfigSection(string header) { return new ConfigContext(File, header); } public ConfigContext CreateConfigSectionForBundleData(AssetBundleData data) { return CreateConfigSection(data.configName + " Options"); } public ConfigEntryBase CreateDynamicConfig(bool userAllowedToEdit, DuskDynamicConfig configDefinition, ConfigContext context) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) ConfigContext context2 = context; DuskDynamicConfig configDefinition2 = configDefinition; return (ConfigEntryBase)(configDefinition2.DynamicConfigType switch { DuskDynamicConfigType.String => Bind(configDefinition2.defaultString), DuskDynamicConfigType.Int => Bind(configDefinition2.defaultInt), DuskDynamicConfigType.Bool => Bind(configDefinition2.defaultBool), DuskDynamicConfigType.Float => Bind(configDefinition2.defaultFloat), DuskDynamicConfigType.BoundedRange => Bind(configDefinition2.defaultBoundedRange), DuskDynamicConfigType.AnimationCurve => Bind(configDefinition2.defaultAnimationCurve), DuskDynamicConfigType.Vector3 => Bind(configDefinition2.defaultVector3), DuskDynamicConfigType.Color => Bind(configDefinition2.defaultColor), _ => throw new ArgumentOutOfRangeException($"DynamicConfigType of '{configDefinition2.DynamicConfigType}' is not yet internally implemented!!"), }); ConfigEntryBase Bind(T defaultValue) { ConfigEntry val = context2.Bind(configDefinition2.settingName, configDefinition2.Description, defaultValue); if (!userAllowedToEdit) { DuskBaseConfig.AssignValueIfNotNull(val, defaultValue); } return (ConfigEntryBase)(object)val; } } public static Dictionary ParseNamespacedKeyWithCurves(string configString) { Dictionary dictionary = new Dictionary(); foreach (string item in from s in configString.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(keyValuePairs); } public static string ParseString(AnimationCurve animationCurve) { return TomlTypeConverter.ConvertToString((object)animationCurve, typeof(AnimationCurve)); } 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 static ConfigEntryBase? FindEntry(ConfigFile file, string section, string key) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Expected O, but got Unknown ConfigDefinition definition = new ConfigDefinition(section, key); ICollection values = ((IDictionary)file).Values; return ((IEnumerable)values).FirstOrDefault((Func)((ConfigEntryBase x) => x.Definition == definition)); } } public static class ConfigReaderTypeUtility { private static readonly Dictionary SettingTypeToDynamicType = new Dictionary { { typeof(string), DuskDynamicConfigType.String }, { typeof(int), DuskDynamicConfigType.Int }, { typeof(float), DuskDynamicConfigType.Float }, { typeof(bool), DuskDynamicConfigType.Bool }, { typeof(BoundedRange), DuskDynamicConfigType.BoundedRange }, { typeof(Vector3), DuskDynamicConfigType.Vector3 }, { typeof(Color), DuskDynamicConfigType.Color }, { typeof(AnimationCurve), DuskDynamicConfigType.AnimationCurve } }; private static readonly Dictionary DynamicTypeToEventFieldName = new Dictionary { { DuskDynamicConfigType.String, "onString" }, { DuskDynamicConfigType.Int, "onInt" }, { DuskDynamicConfigType.Float, "onFloat" }, { DuskDynamicConfigType.Bool, "onBool" }, { DuskDynamicConfigType.BoundedRange, "onBoundedRange" }, { DuskDynamicConfigType.Vector3, "onVector3" }, { DuskDynamicConfigType.Color, "onColor" }, { DuskDynamicConfigType.AnimationCurve, "onAnimationCurve" } }; public static DuskDynamicConfigType? ConvertSettingTypeToDynamicType(Type settingType) { if (SettingTypeToDynamicType.TryGetValue(settingType, out var value)) { return value; } return null; } public static string GetEventFieldName(DuskDynamicConfigType configType) { if (DynamicTypeToEventFieldName.TryGetValue(configType, out string value)) { return value; } throw new ArgumentOutOfRangeException("configType", configType, null); } } public class ConfigReader : MonoBehaviour { [Header("Config Target")] [SerializeField] private string pluginGuid = ""; [SerializeField] private string section = ""; [SerializeField] private string key = ""; [SerializeField] private DuskDynamicConfigType expectedType; [Header("Invoke")] [SerializeField] private bool invokeOnStart = true; [Header("Events")] [SerializeField] private UnityEvent onUnsupportedType; [SerializeField] private UnityEvent onEntryNotFound; [SerializeField] private UnityEvent onTypeMismatch; [SerializeField] private StringEvent onString; [SerializeField] private FloatEvent onFloat; [SerializeField] private IntEvent onInt; [SerializeField] private BoolEvent onBool; [SerializeField] private BoundedRangeEvent onBoundedRange; [SerializeField] private Vector3Event onVector3; [SerializeField] private ColorEvent onColor; [SerializeField] private AnimationCurveEvent onAnimationCurve; private ConfigEntryBase? _matchedEntry; public DuskDynamicConfigType ExpectedType => expectedType; public ConfigEntryBase? MatchedEntry => _matchedEntry; private void Start() { ResolveEntry(); if (invokeOnStart) { InvokeMatchedEvent(); } } public void ResolveEntry() { _matchedEntry = TryFindConfigEntry(pluginGuid, section, key); if (_matchedEntry == null) { DuskPlugin.Logger.LogWarning((object)("ConfigReader could not find config entry: plugin='" + pluginGuid + "', section='" + section + "', key='" + key + "'")); return; } DebugLogSource configs = Debuggers.Configs; if (configs != null) { configs.Log((object)$"Matched config entry: plugin='{pluginGuid}', section='{_matchedEntry.Definition.Section}', key='{_matchedEntry.Definition.Key}', type='{_matchedEntry.SettingType}', value='{_matchedEntry.BoxedValue}'"); } } public void InvokeMatchedEvent() { if (_matchedEntry == null) { ResolveEntry(); } if (_matchedEntry == null) { UnityEvent obj = onEntryNotFound; if (obj != null) { obj.Invoke(); } return; } DuskDynamicConfigType? duskDynamicConfigType = ConfigReaderTypeUtility.ConvertSettingTypeToDynamicType(_matchedEntry.SettingType); if (!duskDynamicConfigType.HasValue) { DuskPlugin.Logger.LogWarning((object)("Unsupported config type on ConfigReader: " + _matchedEntry.SettingType.FullName)); UnityEvent obj2 = onUnsupportedType; if (obj2 != null) { obj2.Invoke(); } } else if (duskDynamicConfigType.Value != expectedType) { DuskPlugin.Logger.LogWarning((object)$"ConfigReader type mismatch for '{pluginGuid}:{section}:{key}'. Expected '{expectedType}', but config entry was '{duskDynamicConfigType.Value}'."); UnityEvent obj3 = onTypeMismatch; if (obj3 != null) { obj3.Invoke(); } } else { InvokeExpectedTypeEvent(_matchedEntry.BoxedValue); } } private void InvokeExpectedTypeEvent(object value) { //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) switch (expectedType) { case DuskDynamicConfigType.String: ((UnityEvent)(object)onString)?.Invoke((string)value); return; case DuskDynamicConfigType.Int: ((UnityEvent)(object)onInt)?.Invoke((int)value); return; case DuskDynamicConfigType.Float: ((UnityEvent)(object)onFloat)?.Invoke(Convert.ToSingle(value, CultureInfo.InvariantCulture)); return; case DuskDynamicConfigType.Bool: ((UnityEvent)(object)onBool)?.Invoke((bool)value); return; case DuskDynamicConfigType.BoundedRange: ((UnityEvent)(object)onBoundedRange)?.Invoke((BoundedRange)value); return; case DuskDynamicConfigType.Vector3: ((UnityEvent)(object)onVector3)?.Invoke((Vector3)value); return; case DuskDynamicConfigType.Color: ((UnityEvent)(object)onColor)?.Invoke((Color)value); return; case DuskDynamicConfigType.AnimationCurve: ((UnityEvent)(object)onAnimationCurve)?.Invoke((AnimationCurve)value); return; } DuskPlugin.Logger.LogWarning((object)$"Unhandled expected config type: {expectedType}"); UnityEvent obj = onUnsupportedType; if (obj != null) { obj.Invoke(); } } private static ConfigEntryBase? TryFindConfigEntry(string pluginGuid, string section, string key) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown if (string.IsNullOrWhiteSpace(pluginGuid) || string.IsNullOrWhiteSpace(section) || string.IsNullOrWhiteSpace(key)) { return null; } if (!Chainloader.PluginInfos.TryGetValue(pluginGuid, out var value)) { return null; } DebugLogSource configs = Debuggers.Configs; if (configs != null) { configs.Log((object)("ConfigReader: pluginGuid=" + pluginGuid + ", section=" + section + ", key=" + key)); } ConfigFile config = value.Instance.Config; ConfigDefinition val = new ConfigDefinition(section, key); ICollection values = ((IDictionary)config).Values; foreach (ConfigEntryBase item in values) { ConfigDefinition definition = item.Definition; DebugLogSource configs2 = Debuggers.Configs; if (configs2 != null) { configs2.Log((object)("Existing definition: Section: " + definition.Section + " | Key: " + definition.Key)); } if (definition == val) { return item; } } return null; } } public abstract class DuskBaseConfig { public ConfigEntry AllowEditingConfig; internal abstract List _configEntries { get; } public DuskBaseConfig(ConfigContext section, string EntityNameReference) { bool defaultValue = true; string input = default(string); if (!((DataContainer)DawnPlugin.PersistentData).TryGet(DawnKeys.LastVersion, ref input) || Version.Parse(input) >= Version.Parse("0.7.8")) { defaultValue = false; } AllowEditingConfig = section.Bind(EntityNameReference + " | Allow Editing Config", "Whether you're allowed to edit the config entries for " + EntityNameReference + ".", defaultValue); } public bool UserAllowedToEdit() { return AllowEditingConfig.Value; } internal static void AssignValueIfNotNull(ConfigEntry? configEntry, T value) { if (configEntry != null) { configEntry.Value = value; } } public List ConfigEntries() { List list = new List(1) { (ConfigEntryBase)(object)AllowEditingConfig }; foreach (ConfigEntryBase configEntry in _configEntries) { if (configEntry != null) { list.Add(configEntry); } } return list; } } [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 Vector3 defaultVector3; public Color defaultColor; public string Description; } public enum DuskDynamicConfigType { String, Int, Float, Bool, BoundedRange, AnimationCurve, Vector3, Color } [Serializable] public class IntComparison { [SerializeField] public int Value; [SerializeField] public ComparisonOperation ComparisonOperation; } [Serializable] public class IntComparisonConfigWeight : IOperationWithValue { [SerializeField] public IntComparison IntComparison; [SerializeField] public MathOperation MathOperation; [SerializeField] [Range(-9999f, 9999f)] public float Weight; private static Regex _splitRegex = new Regex("\\s+"); public MathOperation Operation => MathOperation; public float Value => Weight; public static string ConvertToString(IntComparisonConfigWeight input) { string text = input.IntComparison.ComparisonOperation switch { ComparisonOperation.Equal => "==", ComparisonOperation.NotEqual => "!=", ComparisonOperation.Greater => ">", ComparisonOperation.Less => "<", ComparisonOperation.GreaterOrEqual => ">=", ComparisonOperation.LessOrEqual => "<=", _ => "==", }; string text2 = input.MathOperation switch { MathOperation.Additive => "+", MathOperation.Subtractive => "-", MathOperation.Multiplicative => "*", MathOperation.Divisive => "/", _ => "+", }; return $"{text}{input.IntComparison.Value}={text2}{input.Weight}"; } public static string ConvertManyToString(List input) { string text = string.Empty; foreach (IntComparisonConfigWeight item in input) { text = text + ConvertToString(item) + ","; } return StringExtensions.RemoveEnd(text, ","); } public static IntComparisonConfigWeight ConvertFromString(string input) { DebugLogSource weights = Debuggers.Weights; if (weights != null) { weights.Log((object)("Converting IntComparisonConfigWeight from string: " + input)); } if (string.IsNullOrWhiteSpace(input)) { DuskPlugin.Logger.LogWarning((object)"Input string was null or empty."); return new IntComparisonConfigWeight(); } Match match = Regex.Match(input.Trim(), "^(==|!=|<=|>=|<|>)(-?\\d+)=([\\+\\-\\*/])(-?\\d*\\.?\\d+)$"); if (!match.Success) { DuskPlugin.Logger.LogWarning((object)("Invalid IntComparisonConfigWeight format: " + input)); return new IntComparisonConfigWeight(); } string value = match.Groups[1].Value; string value2 = match.Groups[2].Value; string value3 = match.Groups[3].Value; string value4 = match.Groups[4].Value; ComparisonOperation comparisonOperation = value switch { "==" => ComparisonOperation.Equal, "!=" => ComparisonOperation.NotEqual, "<" => ComparisonOperation.Less, ">" => ComparisonOperation.Greater, "<=" => ComparisonOperation.Less, ">=" => ComparisonOperation.Greater, _ => ComparisonOperation.Equal, }; if (!int.TryParse(value2, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result)) { DuskPlugin.Logger.LogWarning((object)("Invalid comparison value in input: " + input)); return new IntComparisonConfigWeight(); } MathOperation mathOperation = value3[0] switch { '+' => MathOperation.Additive, '-' => MathOperation.Subtractive, '*' => MathOperation.Multiplicative, '/' => MathOperation.Divisive, _ => MathOperation.Additive, }; if (!float.TryParse(value4, NumberStyles.Float, CultureInfo.InvariantCulture, out var result2)) { DuskPlugin.Logger.LogWarning((object)("Invalid weight value in input: " + input)); result2 = 0f; } IntComparisonConfigWeight intComparisonConfigWeight = new IntComparisonConfigWeight { IntComparison = new IntComparison { Value = result, ComparisonOperation = comparisonOperation }, MathOperation = mathOperation, Weight = Mathf.Abs(result2) }; DebugLogSource weights2 = Debuggers.Weights; if (weights2 != null) { weights2.Log((object)("Converted IntComparisonConfigWeight: " + ConvertToString(intComparisonConfigWeight))); } return intComparisonConfigWeight; } public static List ConvertManyFromStringList(List input) { List list = new List(input.Count); foreach (string item in input) { list.Add(ConvertFromString(item.Trim().ToLowerInvariant().Replace(" ", "_"))); } return list; } public static List ConvertManyFromString(string input) { if (string.IsNullOrWhiteSpace(input)) { return new List(); } string[] array = input.Split(',', StringSplitOptions.RemoveEmptyEntries); List list = new List(array.Length); string[] array2 = array; foreach (string text in array2) { string input2 = _splitRegex.Replace(text.Trim().ToLowerInvariant(), "_"); list.Add(ConvertFromString(input2)); } return list; } } public abstract class ContentHandler { [CompilerGenerated] private DuskMod P; protected ContentHandler(DuskMod mod) { P = mod; base..ctor(); } [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] protected bool IsContentEnabled(string bundleName) { if (!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 = P.ConfigManager.CreateConfigSectionForBundleData(assetBundleData); ConfigEntry val = configContext.Bind("Enabled", "Whether " + configName + " is enabled.", assetBundleData.enabledByDefault); P._configEntries.Add((ConfigEntryBase)(object)val); return val.Value; } protected bool TryLoadContentBundle(string assetBundleName, out TAsset? asset, bool forceEnabled = false) where TAsset : AssetBundleLoader { asset = null; if (!P.TryGetBundleDataFromName(assetBundleName, out AssetBundleData data)) { ManualLogSource? logger = 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 = 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] { 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(P); duskContentDefinition.RegisterPost(P); duskContentDefinition.RegisterConfigs(P); } } protected void LoadAllContent(params IAssetBundleLoader[] bundles) { foreach (IAssetBundleLoader bundle in bundles) { LoadAllContent(bundle); } } protected bool RegisterContent(string bundleName, out TAsset? asset, bool forceEnabled = false) where TAsset : AssetBundleLoader { if (TryLoadContentBundle(bundleName, out asset, forceEnabled)) { LoadAllContent(asset); return true; } return false; } } public abstract class ContentHandler : ContentHandler where T : ContentHandler { public static T Instance { get; private set; } public ContentHandler(DuskMod mod) : base(mod) { Instance = (T)this; } } 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() { DebugLogSource achievements = Debuggers.Achievements; if (achievements != null) { achievements.Log((object)$"Trying to complete achievement: {_reference.TypedKey}"); } if (_reference.TryResolve(out DuskAchievementDefinition info) && DuskModContent.Achievements.TryTriggerAchievement(info.TypedKey)) { _onAchievementCompleted.Invoke(); } } public void TryIncrementAchievement(float amountToIncrement) { DebugLogSource achievements = Debuggers.Achievements; if (achievements != null) { achievements.Log((object)$"Trying to increment achievement: {_reference.TypedKey} by {amountToIncrement}"); } if (_reference.TryResolve(out DuskAchievementDefinition info) && DuskModContent.Achievements.TryIncrementAchievement(info.TypedKey, amountToIncrement)) { _onAchievementCompleted.Invoke(); } } public void TryDiscoverMoreProgressAchievement(string uniqueStringID) { DebugLogSource achievements = Debuggers.Achievements; if (achievements != null) { achievements.Log((object)$"Trying to discover more progress for achievement: {_reference.TypedKey} with unique string id: {uniqueStringID}"); } if (_reference.TryResolve(out DuskAchievementDefinition info) && DuskModContent.Achievements.TryDiscoverMoreProgressAchievement(info.TypedKey, uniqueStringID)) { _onAchievementCompleted.Invoke(); } } public void TryDiscoverMoreProgressAchievement(List uniqueStringIDs) { DebugLogSource achievements = Debuggers.Achievements; if (achievements != null) { achievements.Log((object)string.Format("Trying to discover more progress for achievement: {0} with unique string ids: {1}", _reference.TypedKey, string.Join(", ", uniqueStringIDs))); } if (_reference.TryResolve(out DuskAchievementDefinition info) && DuskModContent.Achievements.TryDiscoverMoreProgressAchievement(info.TypedKey, uniqueStringIDs)) { _onAchievementCompleted.Invoke(); } } public void ResetAllAchievementProgress() { DebugLogSource achievements = Debuggers.Achievements; if (achievements != null) { achievements.Log((object)$"Trying to reset all progress for achievement: {_reference.TypedKey}"); } if (_reference.TryResolve(out DuskAchievementDefinition info)) { info.ResetProgress(); } } public void SoftResetAllAchievementProgress() { DebugLogSource achievements = Debuggers.Achievements; if (achievements != null) { achievements.Log((object)$"Trying to soft reset all progress for achievement: {_reference.TypedKey}"); } if (_reference.TryResolve(out DuskAchievementDefinition info)) { info.SoftResetProgress(); } } } 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 achievementsContainerList = new List(); internal static List achievementModUIElements = new List(); 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 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(_achievementUIElementPrefab, _achievementsContainer.transform); val.SetActive(false); AchievementUIElement component = val.GetComponent(); 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.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 { [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 _modUIElements = new List(); 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(_achievementModUIElementPrefab, _modContents.transform); AchievementModUIElement component = val.GetComponent(); 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 { [CompilerGenerated] private sealed class d__7 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public AchievementUIGetCanvas <>4__this; private GameObject 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 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; 5__2.GetComponent().SetTrigger(SlideOut); <>2__current = (object)new WaitForSeconds(3f); <>1__state = 2; return true; case 2: <>1__state = -1; Object.Destroy((Object)(object)5__2); 5__2 = null; break; } if (achievementUIGetCanvas.achievementQueue.Count > 0) { DuskAchievementDefinition duskAchievementDefinition = achievementUIGetCanvas.achievementQueue.Dequeue(); 5__2 = Object.Instantiate(achievementUIGetCanvas._achievementGetUIElementPrefab, achievementUIGetCanvas.achievementContent.transform); AchievementUIElement component = 5__2.GetComponent(); 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 achievementQueue = new Queue(); private void Start() { DuskAchievementHandler.OnAchievementUnlocked = (Action)Delegate.Combine(DuskAchievementHandler.OnAchievementUnlocked, new Action(QueuePopup)); } protected override void OnDestroy() { DuskAchievementHandler.OnAchievementUnlocked = (Action)Delegate.Remove(DuskAchievementHandler.OnAchievementUnlocked, new Action(QueuePopup)); base.OnDestroy(); } internal void QueuePopup(DuskAchievementDefinition achievement) { achievementQueue.Enqueue(achievement); if (achievementContent.transform.childCount == 0) { ((MonoBehaviour)this).StartCoroutine(ShowNextAchievement()); } } [IteratorStateMachine(typeof(d__7))] private IEnumerator ShowNextAchievement() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__7(0) { <>4__this = this }; } } public abstract class DuskAchievementDefinition : DuskContentDefinition, INamespaced, INamespaced { [SerializeField] private NamespacedKey _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 TypedKey => _typedKey; public override NamespacedKey Key { get { return (NamespacedKey)(object)TypedKey; } protected set { _typedKey = value.AsTyped(); } } 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(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(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?.Invoke(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 void SoftResetProgress() { if (!Completed) { ResetProgress(); } } 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 registry, NamespacedKey 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 registry, NamespacedKey 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 registry, NamespacedKey achievementKey, IEnumerable 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 registry, NamespacedKey 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 ResetAchievement(this Registry registry, NamespacedKey achievementKey) { DuskAchievementDefinition duskAchievementDefinition = default(DuskAchievementDefinition); if (registry.TryGetValue(achievementKey, ref duskAchievementDefinition)) { duskAchievementDefinition.ResetProgress(); } } public static void SoftResetAchievement(this Registry registry, NamespacedKey achievementKey) { DuskAchievementDefinition duskAchievementDefinition = default(DuskAchievementDefinition); if (registry.TryGetValue(achievementKey, ref duskAchievementDefinition)) { duskAchievementDefinition.ResetProgress(); } } } internal static class DuskAchievementHandler { public static Action? OnAchievementUnlocked; 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()).text = $"{val.CurrentProgress}/{val.MaxProgress}"; } else { achievementUIElement.achievementProgressGO.SetActive(false); } } } [Serializable] public class DuskAchievementReference : DuskContentReference { public DuskAchievementReference() { } public DuskAchievementReference(NamespacedKey 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 CurrentlyCollectedUniqueStringIDs { get; } public DiscoverySaveData(bool completed, List currentlyCollectedUniqueStringIDs) { CurrentlyCollectedUniqueStringIDs = currentlyCollectedUniqueStringIDs; base..ctor(completed); } } [Tooltip("Unique string ID for each discovery to account for progress.")] [field: SerializeField] public List UniqueStringIDs { get; private set; } public List CurrentlyCollectedUniqueStringIDs { get; private set; } = new List(); 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 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 UniqueID) { foreach (string item in UniqueID) { UndiscoverProgress(item); } } public override void TryNetworkRegisterAssets() { } } [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.Instance?.TriggerAchievementServerRpc(Key); } return TryCompleteAchievement(); } public override void TryNetworkRegisterAssets() { } } [CreateAssetMenu(fileName = "New Parent Achievement Definition", menuName = "DawnLib/Definitions/Achievements/Parent Definition")] public class DuskParentAchievement : DuskAchievementDefinition, IProgress { [field: SerializeReference] [field: FormerlySerializedAs("ChildrenAchievementNames")] public List ChildrenAchievementReferences { get; private set; } = new List(); public float MaxProgress => ChildrenAchievementReferences.Count; public float CurrentProgress => CountCompleted(); public override void Register(DuskMod mod) { DuskMod mod2 = mod; base.Register(mod2); DuskAchievementHandler.OnAchievementUnlocked = (Action)Delegate.Combine(DuskAchievementHandler.OnAchievementUnlocked, (Action)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; } public override void TryNetworkRegisterAssets() { } } [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 override void TryNetworkRegisterAssets() { } } public class DungeonConfig : DuskBaseConfig { public ConfigEntry? MoonSpawnWeights; public ConfigEntry? WeatherSpawnWeights; public ConfigEntry? RouteSpawnWeights; public ConfigEntry? DungeonRangeClamp; public ConfigEntry? ExtraScrapGeneration; internal override List _configEntries => new List(5) { (ConfigEntryBase)(object)MoonSpawnWeights, (ConfigEntryBase)(object)WeatherSpawnWeights, (ConfigEntryBase)(object)RouteSpawnWeights, (ConfigEntryBase)(object)DungeonRangeClamp, (ConfigEntryBase)(object)ExtraScrapGeneration }; public DungeonConfig(ConfigContext section, string EntityNameReference) : base(section, EntityNameReference) { } } [CreateAssetMenu(fileName = "New Additional Tiles Definition", menuName = "DawnLib/Definitions/Additional Tiles Definition")] public class DuskAdditionalTilesDefinition : DuskContentDefinition { [Flags] public enum BranchCapSetting { Regular = 1, BranchCap = 2 } [SerializeField] [UnlockedNamespacedKey] public List> archetypeKeys = new List>(); [field: SerializeField] public TileSet TilesToAdd { get; private set; } [field: SerializeField] public BranchCapSetting BranchCap { get; private set; } = BranchCapSetting.Regular | BranchCapSetting.BranchCap; [field: SerializeField] public DuskPredicate Predicate { 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)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 archetypeKey in archetypeKeys) { if (LethalContent.Archetypes.TryGetValue(archetypeKey, ref val)) { val.AddTileSet(tileSetInfo); } } }; } public override void TryNetworkRegisterAssets() { NetworkObject val = default(NetworkObject); foreach (GameObject item in TilesToAdd.TileWeights.Weights.Select((GameObjectChance x) => x.Value)) { if (item.TryGetComponent(ref val)) { DawnLib.RegisterNetworkPrefab(item); } } } } [Serializable] public class DuskAdditionalTilesReference : DuskContentReference { public DuskAdditionalTilesReference() { } public DuskAdditionalTilesReference(NamespacedKey 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 { [field: SerializeField] public DungeonFlowReference DungeonFlowReference { get; private set; } [field: SerializeField] public AudioClip? StingerAudio { get; private set; } [field: Space(5f)] [field: Header("Configs | Spawn Weights")] [field: SerializeField] public List MoonSpawnWeightsConfig { get; private set; } = new List(); [field: SerializeField] public List WeatherSpawnWeightsConfig { get; private set; } = new List(); [field: SerializeField] public List RouteSpawnWeightsConfig { get; private set; } = new List(); [field: Space(2f)] [field: SerializeField] public int ExtraScrapGeneration { get; private set; } [field: Header("Configs | Generation")] [field: SerializeField] public bool GenerateSpawnWeightsConfig { get; private set; } = true; [field: SerializeField] public bool GenerateExtraScrapConfig { get; private set; } = true; [field: SerializeField] public bool GenerateClampConfig { get; private set; } = true; [field: Header("Configs | Misc")] [field: SerializeField] public BoundedRange DungeonRangeClamp { get; private set; } = new BoundedRange(0f, 999f); [field: SerializeField] public float MapTileSize { get; private set; } = 1f; [field: SerializeField] public bool StingerPlaysMoreThanOnce { get; private set; } [field: SerializeField] [field: Range(0f, 100f)] public float StingerPlayChance { get; private set; } [Obsolete] [field: DontDrawIfEmpty("obsolete", "Obsolete")] [field: SerializeField] public string MoonSpawnWeights { get; private set; } [Obsolete] [field: SerializeField] [field: DontDrawIfEmpty("obsolete", "Obsolete")] public string WeatherSpawnWeights { get; private set; } internal string MoonSpawnWeightsCompat => MoonSpawnWeights; internal string WeatherSpawnWeightsCompat => WeatherSpawnWeights; public SpawnWeightsPreset SpawnWeights { get; private set; } = new SpawnWeightsPreset(); public DungeonConfig Config { get; private set; } protected override string EntityNameReference => DungeonFlowReference?.FlowAssetName ?? string.Empty; public override void Register(DuskMod mod) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected O, but got Unknown DuskMod mod2 = mod; base.Register(mod2); if (DungeonRangeClamp.Min == 0f && DungeonRangeClamp.Max == 0f) { DungeonRangeClamp = new BoundedRange(0f, 999f); } using ConfigContext section = mod2.ConfigManager.CreateConfigSectionForBundleData(AssetBundleData); Config = CreateDungeonConfig(section); base.BaseConfig = Config; List moonConfig = NamespacedConfigWeight.ConvertManyFromString(MoonSpawnWeightsCompat); if (MoonSpawnWeightsConfig.Count > 0) { moonConfig = MoonSpawnWeightsConfig; } if (Config.MoonSpawnWeights != null) { moonConfig = NamespacedConfigWeight.ConvertManyFromString(Config.MoonSpawnWeights.Value); } List weatherConfig = NamespacedConfigWeight.ConvertManyFromString(WeatherSpawnWeightsCompat); if (WeatherSpawnWeightsConfig.Count > 0) { weatherConfig = WeatherSpawnWeightsConfig; } if (Config.WeatherSpawnWeights != null) { weatherConfig = NamespacedConfigWeight.ConvertManyFromString(Config.WeatherSpawnWeights.Value); } List routePriceConfig = IntComparisonConfigWeight.ConvertManyFromString(string.Empty); if (RouteSpawnWeightsConfig.Count > 0) { routePriceConfig = RouteSpawnWeightsConfig; } if (Config.RouteSpawnWeights != null) { routePriceConfig = IntComparisonConfigWeight.ConvertManyFromString(Config.RouteSpawnWeights.Value); } SpawnWeights.SetupSpawnWeightsPreset(moonConfig, new List(), weatherConfig); SpawnWeights.AddRule(new RoutePriceRule(new RoutePriceWeightTransformer(routePriceConfig))); DawnLib.DefineDungeon(base.TypedKey, DungeonFlowReference.FlowAssetName, (Action)delegate(DungeonFlowInfoBuilder builder) { DungeonFlowReference.ArchetypeTileSetMapping[] archetypeTileSets = DungeonFlowReference.ArchetypeTileSets; foreach (DungeonFlowReference.ArchetypeTileSetMapping archetypeTileSetMapping in archetypeTileSets) { builder.SetArchetypeTileSetMapping(archetypeTileSetMapping.ArchetypeName, (IEnumerable)archetypeTileSetMapping.TileSetNames); } builder.SetAssetBundlePath(mod2.GetRelativePath("Assets", DungeonFlowReference.BundleName)); builder.SetMapTileSize(MapTileSize); if ((Object)(object)StingerAudio != (Object)null) { builder.SetFirstTimeAudio(StingerAudio); } builder.OverrideStingerPlaysMoreThanOnce(StingerPlaysMoreThanOnce); builder.OverrideStingerPlayChance(StingerPlayChance); builder.SetDungeonRangeClamp(DungeonRangeClamp); builder.SetExtraScrapGeneration(ExtraScrapGeneration); builder.SetWeights((Action>)delegate(WeightTableBuilder weightBuilder) { weightBuilder.SetGlobalWeight((IWeighted)(object)SpawnWeights); }); ApplyTagsTo((BaseInfoBuilder)(object)builder); }); } public DungeonConfig CreateDungeonConfig(ConfigContext section) { DungeonConfig dungeonConfig = new DungeonConfig(section, EntityNameReference) { MoonSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Moon Weights", "Preset moon weights for " + EntityNameReference + ".", (MoonSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(MoonSpawnWeightsConfig) : MoonSpawnWeightsCompat) : null), WeatherSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Weather Weights", "Preset weather weights for " + EntityNameReference + ".", (WeatherSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(WeatherSpawnWeightsConfig) : WeatherSpawnWeightsCompat) : null), RouteSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Route Weights", "Preset route weights for " + EntityNameReference + ".", IntComparisonConfigWeight.ConvertManyToString(RouteSpawnWeightsConfig)) : null), ExtraScrapGeneration = (GenerateExtraScrapConfig ? section.Bind(EntityNameReference + " | Extra Scrap Generation", "Extra scrap generation for " + EntityNameReference + ".", ExtraScrapGeneration) : null), DungeonRangeClamp = (GenerateClampConfig ? section.Bind(EntityNameReference + " | Dungeon Range Clamp", "Dungeon range clamp for " + EntityNameReference + ".", DungeonRangeClamp) : null) }; if (!dungeonConfig.UserAllowedToEdit()) { DuskBaseConfig.AssignValueIfNotNull(dungeonConfig.MoonSpawnWeights, (MoonSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(MoonSpawnWeightsConfig) : MoonSpawnWeightsCompat); DuskBaseConfig.AssignValueIfNotNull(dungeonConfig.WeatherSpawnWeights, (WeatherSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(WeatherSpawnWeightsConfig) : WeatherSpawnWeightsCompat); DuskBaseConfig.AssignValueIfNotNull(dungeonConfig.RouteSpawnWeights, IntComparisonConfigWeight.ConvertManyToString(RouteSpawnWeightsConfig)); DuskBaseConfig.AssignValueIfNotNull(dungeonConfig.ExtraScrapGeneration, ExtraScrapGeneration); DuskBaseConfig.AssignValueIfNotNull(dungeonConfig.DungeonRangeClamp, DungeonRangeClamp); } return dungeonConfig; } public override void TryNetworkRegisterAssets() { } } [Serializable] public class DuskDungeonReference : DuskContentReference { public DuskDungeonReference() { } public DuskDungeonReference(NamespacedKey key) : base(key) { } public override bool TryResolve(out DawnDungeonInfo info) { return ((Registry)(object)LethalContent.Dungeons).TryGetValue(base.TypedKey, ref info); } public override DawnDungeonInfo Resolve() { return ((Registry)(object)LethalContent.Dungeons)[base.TypedKey]; } } public abstract class DuskContentDefinition : ScriptableObject { [FormerlySerializedAs("ConfigEntries")] [SerializeField] private List _configEntries = new List(); [SerializeField] [UnlockedNamespacedKey] internal List _tags = new List(); internal readonly Dictionary generalConfigs = new Dictionary(); internal AssetBundleData AssetBundleData; public abstract NamespacedKey Key { get; protected set; } public DuskBaseConfig? BaseConfig { get; 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?")); } } else { Mod = mod; TryNetworkRegisterAssets(); } } public virtual void RegisterPost(DuskMod mod) { using ConfigContext context = mod.ConfigManager.CreateConfigSectionForBundleData(AssetBundleData); foreach (DuskDynamicConfig configEntry in _configEntries) { ConfigEntryBase value = mod.ConfigManager.CreateDynamicConfig(BaseConfig?.UserAllowedToEdit() ?? true, configEntry, context); generalConfigs[StringExtensions.CleanStringForConfig(configEntry.settingName)] = value; } } public void RegisterConfigs(DuskMod mod) { foreach (KeyValuePair generalConfig in generalConfigs) { mod._configEntries.Add(generalConfig.Value); } if (BaseConfig != null) { mod._configEntries.AddRange(BaseConfig.ConfigEntries()); } } public abstract void TryNetworkRegisterAssets(); public string GetDefaultKey() { return NamespacedKey.NormalizeStringForNamespacedKey(EntityNameReference, false); } protected void ApplyTagsTo(BaseInfoBuilder builder) { builder.SoloAddTags((IEnumerable)_tags); } } public abstract class DuskContentDefinition : DuskContentDefinition where TInfo : INamespaced { public NamespacedKey TypedKey => Key.AsTyped(); 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(BufferSerializer serializer) where T : IReaderWriter; } [Serializable] public abstract class DuskContentReference : DuskContentReference where TDef : DuskContentDefinition where TInfo : INamespaced { public NamespacedKey TypedKey => Key.AsTyped(); 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 key) { Key = (NamespacedKey)(object)key; } public unsafe override void NetworkSerialize(BufferSerializer serializer) { NamespacedKey key = Key; ((BufferSerializer*)(&serializer))->SerializeNetworkSerializable(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 { [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: :=, i.e. magic_wesleys_mod:trite=+20")] [field: SerializeField] public List MoonSpawnWeightsConfig { get; private set; } = new List(); [field: SerializeField] public List InteriorSpawnWeightsConfig { get; private set; } = new List(); [field: SerializeField] public List WeatherSpawnWeightsConfig { get; private set; } = new List(); [field: SerializeField] public List RouteSpawnWeightsConfig { get; private set; } = new List(); [field: SerializeField] public bool GenerateSpawnWeightsConfig { get; private set; } = true; [field: SerializeField] public bool GeneratePowerLevelConfig { get; private set; } = true; [field: SerializeField] public bool GenerateMaxSpawnCountConfig { get; private set; } = true; [Obsolete] [field: SerializeField] [field: DontDrawIfEmpty("obsolete", "Obsolete")] public string MoonSpawnWeights { get; private set; } [Obsolete] [field: SerializeField] [field: DontDrawIfEmpty("obsolete", "Obsolete")] public string InteriorSpawnWeights { get; private set; } [Obsolete] [field: SerializeField] [field: DontDrawIfEmpty("obsolete", "Obsolete")] public string WeatherSpawnWeights { get; private set; } internal string MoonSpawnWeightsCompat => MoonSpawnWeights; internal string InteriorSpawnWeightsCompat => InteriorSpawnWeights; internal string WeatherSpawnWeightsCompat => WeatherSpawnWeights; 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); base.BaseConfig = Config; if (GeneratePowerLevelConfig) { ConfigEntry powerLevel = Config.PowerLevel; if (powerLevel != null) { EnemyType.PowerLevel = powerLevel.Value; } } if (GenerateMaxSpawnCountConfig) { ConfigEntry maxSpawnCount = Config.MaxSpawnCount; if (maxSpawnCount != null) { EnemyType.MaxCount = maxSpawnCount.Value; } } List moonConfig = NamespacedConfigWeight.ConvertManyFromString(MoonSpawnWeightsCompat); if (MoonSpawnWeightsConfig.Count > 0) { moonConfig = MoonSpawnWeightsConfig; } if (Config.MoonSpawnWeights != null) { moonConfig = NamespacedConfigWeight.ConvertManyFromString(Config.MoonSpawnWeights.Value); } List interiorConfig = NamespacedConfigWeight.ConvertManyFromString(InteriorSpawnWeightsCompat); if (InteriorSpawnWeightsConfig.Count > 0) { interiorConfig = InteriorSpawnWeightsConfig; } if (Config.InteriorSpawnWeights != null) { interiorConfig = NamespacedConfigWeight.ConvertManyFromString(Config.InteriorSpawnWeights.Value); } List weatherConfig = NamespacedConfigWeight.ConvertManyFromString(WeatherSpawnWeightsCompat); if (WeatherSpawnWeightsConfig.Count > 0) { weatherConfig = WeatherSpawnWeightsConfig; } if (Config.WeatherSpawnWeights != null) { weatherConfig = NamespacedConfigWeight.ConvertManyFromString(Config.WeatherSpawnWeights.Value); } List routePriceConfig = IntComparisonConfigWeight.ConvertManyFromString(string.Empty); if (RouteSpawnWeightsConfig.Count > 0) { routePriceConfig = RouteSpawnWeightsConfig; } if (Config.RouteSpawnWeights != null) { routePriceConfig = IntComparisonConfigWeight.ConvertManyFromString(Config.RouteSpawnWeights.Value); } SpawnWeights.SetupSpawnWeightsPreset(moonConfig, interiorConfig, weatherConfig); SpawnWeights.AddRule(new RoutePriceRule(new RoutePriceWeightTransformer(routePriceConfig))); DawnLib.DefineEnemy(base.TypedKey, EnemyType, (Action)delegate(EnemyInfoBuilder builder) { if (SpawnTable.HasFlag(SpawnTable.Daytime)) { builder.DefineDaytime((Action)delegate(EnemyLocationBuilder daytimeBuilder) { daytimeBuilder.SetWeights((Action>)delegate(WeightTableBuilder weightBuilder) { weightBuilder.SetGlobalWeight((IWeighted)(object)SpawnWeights); }); }); } if (SpawnTable.HasFlag(SpawnTable.Outside)) { builder.DefineOutside((Action)delegate(EnemyLocationBuilder outsideBuilder) { outsideBuilder.SetWeights((Action>)delegate(WeightTableBuilder weightBuilder) { weightBuilder.SetGlobalWeight((IWeighted)(object)SpawnWeights); }); }); } if (SpawnTable.HasFlag(SpawnTable.Inside)) { builder.DefineInside((Action)delegate(EnemyLocationBuilder insideBuilder) { insideBuilder.SetWeights((Action>)delegate(WeightTableBuilder weightBuilder) { weightBuilder.SetGlobalWeight((IWeighted)(object)SpawnWeights); }); }); } if (!string.IsNullOrWhiteSpace(BestiaryNodeText)) { builder.CreateBestiaryNode(BestiaryNodeText); builder.CreateNameKeyword(BestiaryWordOverride); } ApplyTagsTo((BaseInfoBuilder)(object)builder); }); } public EnemyConfig CreateEnemyConfig(ConfigContext section) { EnemyConfig enemyConfig = new EnemyConfig(section, EntityNameReference) { MoonSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Moon Weights", "Preset moon weights for " + EntityNameReference + ".", (MoonSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(MoonSpawnWeightsConfig) : MoonSpawnWeightsCompat) : null), InteriorSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Interior Weights", "Preset interior weights for " + EntityNameReference + ".", (InteriorSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(InteriorSpawnWeightsConfig) : InteriorSpawnWeightsCompat) : null), WeatherSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Weather Weights", "Preset weather weights for " + EntityNameReference + ".", (WeatherSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(WeatherSpawnWeightsConfig) : WeatherSpawnWeightsCompat) : null), RouteSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Route Weights", "Preset route weights for " + EntityNameReference + ".", IntComparisonConfigWeight.ConvertManyToString(RouteSpawnWeightsConfig)) : null), PowerLevel = (GeneratePowerLevelConfig ? section.Bind(EntityNameReference + " | Power Level", "Power level for " + EntityNameReference + ".", EnemyType.PowerLevel) : null), MaxSpawnCount = (GenerateMaxSpawnCountConfig ? section.Bind(EntityNameReference + " | Max Spawn Count", "Max spawn count for " + EntityNameReference + ".", EnemyType.MaxCount) : null) }; if (!enemyConfig.UserAllowedToEdit()) { DuskBaseConfig.AssignValueIfNotNull(enemyConfig.MoonSpawnWeights, (MoonSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(MoonSpawnWeightsConfig) : MoonSpawnWeightsCompat); DuskBaseConfig.AssignValueIfNotNull(enemyConfig.InteriorSpawnWeights, (InteriorSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(InteriorSpawnWeightsConfig) : InteriorSpawnWeightsCompat); DuskBaseConfig.AssignValueIfNotNull(enemyConfig.WeatherSpawnWeights, (WeatherSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(WeatherSpawnWeightsConfig) : WeatherSpawnWeightsCompat); DuskBaseConfig.AssignValueIfNotNull(enemyConfig.RouteSpawnWeights, IntComparisonConfigWeight.ConvertManyToString(RouteSpawnWeightsConfig)); DuskBaseConfig.AssignValueIfNotNull(enemyConfig.PowerLevel, EnemyType.PowerLevel); DuskBaseConfig.AssignValueIfNotNull(enemyConfig.MaxSpawnCount, EnemyType.MaxCount); } return enemyConfig; } public override void TryNetworkRegisterAssets() { NetworkObject val = default(NetworkObject); if (EnemyType.enemyPrefab.TryGetComponent(ref val)) { DawnLib.RegisterNetworkPrefab(EnemyType.enemyPrefab); } } } [Serializable] public class DuskEnemyReference : DuskContentReference { public DuskEnemyReference() { } public DuskEnemyReference(NamespacedKey key) : base(key) { } public override bool TryResolve(out DawnEnemyInfo info) { return ((Registry)(object)LethalContent.Enemies).TryGetValue(base.TypedKey, ref info); } public override DawnEnemyInfo Resolve() { return ((Registry)(object)LethalContent.Enemies)[base.TypedKey]; } } public class EnemyConfig : DuskBaseConfig { public ConfigEntry? MoonSpawnWeights; public ConfigEntry? InteriorSpawnWeights; public ConfigEntry? WeatherSpawnWeights; public ConfigEntry? RouteSpawnWeights; public ConfigEntry? PowerLevel; public ConfigEntry? MaxSpawnCount; internal override List _configEntries => new List(6) { (ConfigEntryBase)(object)MoonSpawnWeights, (ConfigEntryBase)(object)InteriorSpawnWeights, (ConfigEntryBase)(object)WeatherSpawnWeights, (ConfigEntryBase)(object)RouteSpawnWeights, (ConfigEntryBase)(object)PowerLevel, (ConfigEntryBase)(object)MaxSpawnCount }; public EnemyConfig(ConfigContext section, string EntityNameReference) : base(section, EntityNameReference) { } } [CreateAssetMenu(fileName = "New AnimationClip Replacement", menuName = "Entity Replacements/Actions/AnimationClip Replacement")] public class AnimationClipReplacement : Hierarchy { [CompilerGenerated] private sealed class d__12 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public bool immediate; public AnimationClipReplacement <>4__this; public Transform rootTransform; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__12(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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_00e7: Expected O, but got Unknown int num = <>1__state; AnimationClipReplacement animationClipReplacement = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; if (!immediate) { <>2__current = null; <>1__state = 1; return true; } break; case 1: <>1__state = -1; break; } Animator val = ((!string.IsNullOrWhiteSpace(animationClipReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(animationClipReplacement.HierarchyPath)).GetComponent() : ((Component)rootTransform).GetComponent()); AnimatorOverrideController val2 = new AnimatorOverrideController(val.runtimeAnimatorController); foreach (AnimationEventData 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 PotentialAnimationEvents { get; private set; } = new List(); [IteratorStateMachine(typeof(d__12))] public override IEnumerator Apply(Transform rootTransform, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__12(0) { <>4__this = this, rootTransform = rootTransform, immediate = immediate }; } } [CreateAssetMenu(fileName = "New GameObject Editor Action", menuName = "Entity Replacements/Actions/GameObject Editor Action")] public class GameObjectEditorAction : Hierarchy { [CompilerGenerated] private sealed class d__16 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public bool immediate; public GameObjectEditorAction <>4__this; public Transform rootTransform; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__16(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: 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; if (!immediate) { <>2__current = null; <>1__state = 1; return true; } break; case 1: <>1__state = -1; break; } GameObject val = ((!string.IsNullOrWhiteSpace(gameObjectEditorAction.HierarchyPath)) ? ((Component)rootTransform.Find(gameObjectEditorAction.HierarchyPath)).gameObject : ((Component)rootTransform).gameObject); if (gameObjectEditorAction.DeleteGameObject) { NetworkObject val2 = default(NetworkObject); if (val.TryGetComponent(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(d__16))] public override IEnumerator Apply(Transform rootTransform, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__16(0) { <>4__this = this, rootTransform = rootTransform, immediate = immediate }; } } public abstract class Hierarchy : ScriptableObject { [field: SerializeField] public string HierarchyPath { get; private set; } public abstract IEnumerator Apply(Transform rootTransform, bool immediate); } [CreateAssetMenu(fileName = "New ParticleSystem Replacement", menuName = "Entity Replacements/Actions/ParticleSystem Replacement")] public class ParticleSystemReplacement : Hierarchy { [CompilerGenerated] private sealed class d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public bool immediate; public ParticleSystemReplacement <>4__this; public Transform rootTransform; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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; if (!immediate) { <>2__current = null; <>1__state = 1; return true; } break; case 1: <>1__state = -1; break; } GameObject val = ((!string.IsNullOrWhiteSpace(particleSystemReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(particleSystemReplacement.HierarchyPath)).gameObject : ((Component)rootTransform).gameObject); GameObject val2 = Object.Instantiate(((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(d__4))] public override IEnumerator Apply(Transform rootTransform, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { <>4__this = this, rootTransform = rootTransform, immediate = immediate }; } } [CreateAssetMenu(fileName = "New Skinned Mesh Replacement", menuName = "Entity Replacements/Actions/SkinnedMesh Replacement")] public class SkinnedMeshReplacement : Hierarchy { [CompilerGenerated] private sealed class d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public bool immediate; public SkinnedMeshReplacement <>4__this; public Transform rootTransform; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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; if (!immediate) { <>2__current = null; <>1__state = 1; return true; } break; case 1: <>1__state = -1; break; } skinnedMeshReplacement.ReplaceSkinnedMeshRenderer((!string.IsNullOrWhiteSpace(skinnedMeshReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(skinnedMeshReplacement.HierarchyPath)).GetComponent() : ((Component)rootTransform).GetComponent()); 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(d__4))] public override IEnumerator Apply(Transform rootTransform, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { <>4__this = this, rootTransform = rootTransform, immediate = immediate }; } private void ReplaceSkinnedMeshRenderer(SkinnedMeshRenderer targetSkinned) { Material[] sharedMaterials = ((Renderer)targetSkinned).sharedMaterials; Transform rootBone = targetSkinned.rootBone; Dictionary 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.IsNullOrWhiteSpace(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 BuildBoneLookup(Transform root) { Dictionary dictionary = new Dictionary(); if (!Object.op_Implicit((Object)(object)root)) { return dictionary; } Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren(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 d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public bool immediate; public MeshReplacement <>4__this; public Transform rootTransform; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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; if (!immediate) { <>2__current = null; <>1__state = 1; return true; } break; case 1: <>1__state = -1; break; } meshReplacement.ReplaceMeshRenderer((!string.IsNullOrWhiteSpace(meshReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(meshReplacement.HierarchyPath)).GetComponent() : ((Component)rootTransform).GetComponent(), (!string.IsNullOrWhiteSpace(meshReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(meshReplacement.HierarchyPath)).GetComponent() : ((Component)rootTransform).GetComponent()); 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(d__4))] public override IEnumerator Apply(Transform rootTransform, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { <>4__this = this, rootTransform = rootTransform, immediate = immediate }; } 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 d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public bool immediate; public MaterialsReplacement <>4__this; public Transform rootTransform; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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; if (!immediate) { <>2__current = null; <>1__state = 1; return true; } break; case 1: <>1__state = -1; break; } materialsReplacement.ReplaceMaterials((!string.IsNullOrWhiteSpace(materialsReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(materialsReplacement.HierarchyPath)).GetComponent() : ((Component)rootTransform).GetComponent()); 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 ReplacementMaterials { get; private set; } = new List(); [IteratorStateMachine(typeof(d__4))] public override IEnumerator Apply(Transform rootTransform, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { <>4__this = this, rootTransform = rootTransform, immediate = immediate }; } 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 d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public bool immediate; public TextureReplacement <>4__this; public Transform rootTransform; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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; if (!immediate) { <>2__current = null; <>1__state = 1; return true; } break; case 1: <>1__state = -1; break; } textureReplacement.ReplaceMaterials((!string.IsNullOrWhiteSpace(textureReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(textureReplacement.HierarchyPath)).GetComponent() : ((Component)rootTransform).GetComponent()); 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 ReplacementMaterialProperties { get; private set; } = new List(); [IteratorStateMachine(typeof(d__4))] public override IEnumerator Apply(Transform rootTransform, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { <>4__this = this, rootTransform = rootTransform, immediate = immediate }; } 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 d__24 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public bool immediate; public ScanNodePropertiesReplacement <>4__this; public Transform rootTransform; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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; if (!immediate) { <>2__current = null; <>1__state = 1; return true; } break; case 1: <>1__state = -1; break; } ScanNodeProperties val = ((!string.IsNullOrWhiteSpace(scanNodePropertiesReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(scanNodePropertiesReplacement.HierarchyPath)).GetComponent() : ((Component)rootTransform).GetComponent()); 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(d__24))] public override IEnumerator Apply(Transform rootTransform, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__24(0) { <>4__this = this, rootTransform = rootTransform, immediate = immediate }; } } [CreateAssetMenu(fileName = "New VisualEffectAsset Replacement", menuName = "Entity Replacements/Actions/VisualEffectAsset Replacement")] public class VisualEffectReplacement : Hierarchy { [CompilerGenerated] private sealed class d__4 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public bool immediate; public VisualEffectReplacement <>4__this; public Transform rootTransform; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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; if (!immediate) { <>2__current = null; <>1__state = 1; return true; } break; case 1: <>1__state = -1; break; } VisualEffect val = ((!string.IsNullOrWhiteSpace(visualEffectReplacement.HierarchyPath)) ? ((Component)rootTransform.Find(visualEffectReplacement.HierarchyPath)).GetComponent() : ((Component)rootTransform).GetComponent()); 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(d__4))] public override IEnumerator Apply(Transform rootTransform, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(0) { <>4__this = this, rootTransform = rootTransform, immediate = immediate }; } } [CreateAssetMenu(fileName = "New Wait Action", menuName = "Entity Replacements/Actions/Wait Action")] public class WaitAction : Hierarchy { [CompilerGenerated] private sealed class d__8 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public bool immediate; public WaitAction <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__8(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown int num = <>1__state; WaitAction waitAction = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; if (!immediate) { <>2__current = (object)new WaitForSeconds(waitAction.WaitTime); <>1__state = 1; return true; } break; case 1: <>1__state = -1; break; } 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(d__8))] public override IEnumerator Apply(Transform rootTransform, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__8(0) { <>4__this = this, immediate = immediate }; } } public abstract class DuskEntityReplacementDefinition : DuskContentDefinition, INamespaced, INamespaced { [SerializeField] [InspectorName("Namespace")] [DefaultKeySource("GetDefaultKey", false)] private NamespacedKey _typedKey; internal bool IsDefault; [field: SerializeField] public string SkinName { get; private set; } [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 Replacements { get; private set; } = new List(); [field: Tooltip("This is where you'd add gameobjects, main use case is adding meshes or cosmetics to entities.")] [field: SerializeField] public List GameObjectAddons { get; private set; } = new List(); public NamespacedKey TypedKey => _typedKey; public override NamespacedKey Key { get { return (NamespacedKey)(object)TypedKey; } protected set { _typedKey = value.AsTyped(); } } [field: Header("Configs | Spawn Weights | Format: :=, i.e. magic_wesleys_mod:trite=+20")] [field: SerializeField] public List MoonSpawnWeightsConfig { get; private set; } = new List(); [field: SerializeField] public List InteriorSpawnWeightsConfig { get; private set; } = new List(); [field: SerializeField] public List WeatherSpawnWeightsConfig { get; private set; } = new List(); [field: SerializeField] public List RouteSpawnWeightsConfig { get; private set; } = new List(); [field: SerializeField] public bool GenerateSpawnWeightsConfig { get; private set; } = true; [field: Header("Configs | Misc")] [field: SerializeField] public bool GenerateDisableDateConfig { get; private set; } = true; [Obsolete] [field: SerializeField] [field: DontDrawIfEmpty("obsolete", "Obsolete")] public string MoonSpawnWeights { get; private set; } [Obsolete] [field: SerializeField] [field: DontDrawIfEmpty("obsolete", "Obsolete")] public string InteriorSpawnWeights { get; private set; } [Obsolete] [field: SerializeField] [field: DontDrawIfEmpty("obsolete", "Obsolete")] public string WeatherSpawnWeights { get; private set; } internal string MoonSpawnWeightsCompat => MoonSpawnWeights; internal string InteriorSpawnWeightsCompat => InteriorSpawnWeights; internal string WeatherSpawnWeightsCompat => WeatherSpawnWeights; public SpawnWeightsPreset SpawnWeights { get; private set; } = new SpawnWeightsPreset(); public ProviderTable Weights { get; private set; } public EntityReplacementConfig Config { get; private set; } protected override string EntityNameReference => SkinName; public override void TryNetworkRegisterAssets() { NetworkObject val = default(NetworkObject); foreach (GameObject item in GameObjectAddons.Select((GameObjectWithPath x) => x.GameObjectToCreate)) { if (item.TryGetComponent(ref val)) { DawnLib.RegisterNetworkPrefab(item); } } } internal void RegisterAsDefault() { IsDefault = true; Weights = new WeightTableBuilder().SetGlobalWeight(100).Build(); } public override void Register(DuskMod mod) { if (IsDefault) { RegisterAsDefault(); return; } base.Register(mod); using ConfigContext section = mod.ConfigManager.CreateConfigSectionForBundleData(AssetBundleData); Config = CreateEntityReplacementConfig(section); base.BaseConfig = Config; List moonConfig = NamespacedConfigWeight.ConvertManyFromString(MoonSpawnWeightsCompat); if (MoonSpawnWeightsConfig.Count > 0) { moonConfig = MoonSpawnWeightsConfig; } if (Config.MoonSpawnWeights != null) { moonConfig = NamespacedConfigWeight.ConvertManyFromString(Config.MoonSpawnWeights.Value); } List interiorConfig = NamespacedConfigWeight.ConvertManyFromString(InteriorSpawnWeightsCompat); if (InteriorSpawnWeightsConfig.Count > 0) { interiorConfig = InteriorSpawnWeightsConfig; } if (Config.InteriorSpawnWeights != null) { interiorConfig = NamespacedConfigWeight.ConvertManyFromString(Config.InteriorSpawnWeights.Value); } List weatherConfig = NamespacedConfigWeight.ConvertManyFromString(WeatherSpawnWeightsCompat); if (WeatherSpawnWeightsConfig.Count > 0) { weatherConfig = WeatherSpawnWeightsConfig; } if (Config.WeatherSpawnWeights != null) { weatherConfig = NamespacedConfigWeight.ConvertManyFromString(Config.WeatherSpawnWeights.Value); } List routePriceConfig = IntComparisonConfigWeight.ConvertManyFromString(string.Empty); if (RouteSpawnWeightsConfig.Count > 0) { routePriceConfig = RouteSpawnWeightsConfig; } if (Config.RouteSpawnWeights != null) { routePriceConfig = IntComparisonConfigWeight.ConvertManyFromString(Config.RouteSpawnWeights.Value); } SpawnWeights.SetupSpawnWeightsPreset(moonConfig, interiorConfig, weatherConfig); SpawnWeights.AddRule(new RoutePriceRule(new RoutePriceWeightTransformer(routePriceConfig))); Weights = new WeightTableBuilder().SetGlobalWeight((IWeighted)(object)SpawnWeights).Build(); if ((Object)(object)DatePredicate != (Object)null) { DatePredicate = Object.Instantiate(DatePredicate); } bool flag = Config.DisableDateCheck?.Value ?? false; if ((Object)(object)DatePredicate != (Object)null && !flag) { DatePredicate.Register(Key); } DuskModContent.EntityReplacements.Register(this); } public EntityReplacementConfig CreateEntityReplacementConfig(ConfigContext section) { EntityReplacementConfig entityReplacementConfig = new EntityReplacementConfig(section, EntityNameReference) { MoonSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Moon Weights", "Preset moon weights for " + EntityNameReference + ".", (MoonSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(MoonSpawnWeightsConfig) : MoonSpawnWeightsCompat) : null), InteriorSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Interior Weights", "Preset interior weights for " + EntityNameReference + ".", (InteriorSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(InteriorSpawnWeightsConfig) : InteriorSpawnWeightsCompat) : null), WeatherSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Weather Weights", "Preset weather weights for " + EntityNameReference + ".", (WeatherSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(WeatherSpawnWeightsConfig) : WeatherSpawnWeightsCompat) : null), RouteSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Route Weights", "Preset route weights for " + EntityNameReference + ".", IntComparisonConfigWeight.ConvertManyToString(RouteSpawnWeightsConfig)) : null), DisableDateCheck = ((GenerateDisableDateConfig && Object.op_Implicit((Object)(object)DatePredicate)) ? section.Bind(EntityNameReference + " | Disable Date Check", "Whether " + EntityNameReference + " should have it's date check disabled.", defaultValue: false) : null) }; if (!entityReplacementConfig.UserAllowedToEdit()) { DuskBaseConfig.AssignValueIfNotNull(entityReplacementConfig.MoonSpawnWeights, (MoonSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(MoonSpawnWeightsConfig) : MoonSpawnWeightsCompat); DuskBaseConfig.AssignValueIfNotNull(entityReplacementConfig.InteriorSpawnWeights, (InteriorSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(InteriorSpawnWeightsConfig) : InteriorSpawnWeightsCompat); DuskBaseConfig.AssignValueIfNotNull(entityReplacementConfig.WeatherSpawnWeights, (WeatherSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(WeatherSpawnWeightsConfig) : WeatherSpawnWeightsCompat); DuskBaseConfig.AssignValueIfNotNull(entityReplacementConfig.RouteSpawnWeights, IntComparisonConfigWeight.ConvertManyToString(RouteSpawnWeightsConfig)); DuskBaseConfig.AssignValueIfNotNull(entityReplacementConfig.DisableDateCheck, value: false); } return entityReplacementConfig; } } public abstract class DuskEntityReplacementDefinition : DuskEntityReplacementDefinition where TAI : class { [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public DuskEntityReplacementDefinition <>4__this; public bool immediate; public Transform transform; private List.Enumerator <>7__wrap1; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = default(List.Enumerator); <>1__state = -2; } private bool MoveNext() { //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) try { int num = <>1__state; DuskEntityReplacementDefinition duskEntityReplacementDefinition = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = duskEntityReplacementDefinition.Replacements.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; } while (<>7__wrap1.MoveNext()) { Hierarchy current = <>7__wrap1.Current; if (immediate) { ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(current.Apply(transform, immediate)); continue; } <>2__current = ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(current.Apply(transform, immediate)); <>1__state = 1; return true; } <>m__Finally1(); <>7__wrap1 = default(List.Enumerator); NetworkObject val2 = default(NetworkObject); foreach (GameObjectWithPath gameObjectAddon in duskEntityReplacementDefinition.GameObjectAddons) { GameObject val = ((!string.IsNullOrWhiteSpace(gameObjectAddon.PathToGameObject)) ? ((Component)transform.Find(gameObjectAddon.PathToGameObject)).gameObject : ((Component)transform).gameObject); if (!gameObjectAddon.GameObjectToCreate.TryGetComponent(ref val2) || NetworkManager.Singleton.IsServer) { GameObject val3 = Object.Instantiate(gameObjectAddon.GameObjectToCreate, val.transform); val3.transform.SetLocalPositionAndRotation(gameObjectAddon.PositionOffset, Quaternion.Euler(gameObjectAddon.RotationOffset)); if (!((Object)(object)val2 == (Object)null)) { val2.AutoObjectParentSync = false; val2.Spawn(false); } } } 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(); } } public abstract IEnumerator Apply(TAI ai, bool immediate = false); [IteratorStateMachine(typeof(DuskEntityReplacementDefinition<>.d__1))] public IEnumerator ApplyReplacementAndAddons(Transform transform, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { <>4__this = this, transform = transform, immediate = immediate }; } } public class DuskEnemyReplacementDefinition : DuskEntityReplacementDefinition { [CompilerGenerated] private sealed class d__20 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object? IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object? IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__20(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>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(); } } [CompilerGenerated] private sealed class d__21 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public EnemyAINestSpawnObject nest; public DuskEnemyReplacementDefinition <>4__this; public bool immediate; private List.Enumerator <>7__wrap1; object? IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object? IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__21(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 1) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = default(List.Enumerator); <>1__state = -2; } private bool MoveNext() { try { int num = <>1__state; DuskEnemyReplacementDefinition duskEnemyReplacementDefinition = <>4__this; switch (num) { default: return false; case 0: { <>1__state = -1; EnemyType enemyType = nest.enemyType; if (enemyType.useMinEnemyThresholdForNest) { return false; } <>7__wrap1 = duskEnemyReplacementDefinition.NestRendererReplacements.GetEnumerator(); <>1__state = -3; break; } case 1: <>1__state = -3; break; } while (<>7__wrap1.MoveNext()) { Hierarchy current = <>7__wrap1.Current; if (immediate) { ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(current.Apply(((Component)nest).transform, immediate)); continue; } <>2__current = ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(current.Apply(((Component)nest).transform, immediate)); <>1__state = 1; return true; } <>m__Finally1(); <>7__wrap1 = default(List.Enumerator); nest.SetNestReplacement(duskEnemyReplacementDefinition); 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(); } } [field: Header("Nest")] [field: SerializeField] public List NestRendererReplacements { get; private set; } = new List(); [field: Header("EnemyType Audio")] [field: SerializeField] public AudioClip? HitBodySFX { get; private set; } [field: SerializeField] public AudioClip? HitEnemyVoiceSFX { get; private set; } [field: SerializeField] public AudioClip? StunSFX { get; private set; } [field: SerializeField] public AudioClip[] AudioClips { get; private set; } = Array.Empty(); [IteratorStateMachine(typeof(d__20))] public override IEnumerator Apply(EnemyAI ai, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__20(0); } [IteratorStateMachine(typeof(d__21))] public virtual IEnumerator ApplyNest(EnemyAINestSpawnObject nest, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__21(0) { <>4__this = this, nest = nest, immediate = immediate }; } } public abstract class DuskEnemyReplacementDefinition : DuskEnemyReplacementDefinition where T : EnemyAI { [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public EnemyAI enemyAI; public DuskEnemyReplacementDefinition <>4__this; public bool immediate; private Transform 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; DuskEnemyReplacementDefinition duskEnemyReplacementDefinition = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; enemyAI.SetEnemyReplacement(duskEnemyReplacementDefinition); 5__2 = ((Component)enemyAI).transform; if (immediate) { ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(((DuskEnemyReplacementDefinition)duskEnemyReplacementDefinition).Apply(enemyAI, immediate)); goto IL_009f; } <>2__current = ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(((DuskEnemyReplacementDefinition)duskEnemyReplacementDefinition).Apply(enemyAI, immediate)); <>1__state = 1; return true; case 1: <>1__state = -1; goto IL_009f; case 2: { <>1__state = -1; if ((Object)(object)enemyAI == (Object)null) { return false; } duskEnemyReplacementDefinition.ApplyTyped((T)(object)enemyAI); return false; } IL_009f: <>2__current = ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(duskEnemyReplacementDefinition.ApplyReplacementAndAddons(5__2, immediate)); <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } protected abstract void ApplyTyped(T enemyAI); [IteratorStateMachine(typeof(DuskEnemyReplacementDefinition<>.d__1))] public override IEnumerator Apply(EnemyAI enemyAI, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { <>4__this = this, enemyAI = enemyAI, immediate = immediate }; } } public static class EnemyAIExtensions { public static bool TryGetEnemyReplacement(this EnemyAI enemyAI, [NotNullWhen(true)] out DuskEnemyReplacementDefinition? replacement) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) replacement = ((ICurrentEntityReplacement)enemyAI).CurrentEntityReplacement as DuskEnemyReplacementDefinition; return (Object)(object)replacement != (Object)null; } [Obsolete("Use TryGetEnemyReplacement")] public static DuskEnemyReplacementDefinition? GetEnemyReplacement(this EnemyAI enemyAI) { enemyAI.TryGetEnemyReplacement(out DuskEnemyReplacementDefinition replacement); return replacement; } internal static void SetEnemyReplacement(this EnemyAI enemyAI, DuskEnemyReplacementDefinition enemyReplacementDefinition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((ICurrentEntityReplacement)enemyAI).CurrentEntityReplacement = enemyReplacementDefinition; } } public static class EnemyAINestSpawnObjectExtensions { public static DuskEnemyReplacementDefinition? GetNestReplacement(this EnemyAINestSpawnObject nest) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) return (DuskEnemyReplacementDefinition)((ICurrentEntityReplacement)nest).CurrentEntityReplacement; } internal static bool HasNestReplacement(this EnemyAINestSpawnObject nest) { return (Object)(object)nest.GetNestReplacement() != (Object)null; } internal static void SetNestReplacement(this EnemyAINestSpawnObject nestSpawnObject, DuskEnemyReplacementDefinition enemyReplacementDefinition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((ICurrentEntityReplacement)nestSpawnObject).CurrentEntityReplacement = enemyReplacementDefinition; } } public class EntityReplacementConfig : DuskBaseConfig { public ConfigEntry? MoonSpawnWeights; public ConfigEntry? InteriorSpawnWeights; public ConfigEntry? WeatherSpawnWeights; public ConfigEntry? RouteSpawnWeights; public ConfigEntry? DisableDateCheck; internal override List _configEntries => new List(5) { (ConfigEntryBase)(object)MoonSpawnWeights, (ConfigEntryBase)(object)InteriorSpawnWeights, (ConfigEntryBase)(object)WeatherSpawnWeights, (ConfigEntryBase)(object)RouteSpawnWeights, (ConfigEntryBase)(object)DisableDateCheck }; public EntityReplacementConfig(ConfigContext section, string EntityNameReference) : base(section, EntityNameReference) { } } public static class EntityReplacementsExtensions { public static bool TryGetReplacementByNetworkId(this Registry entityReplacementRegistry, ulong networkID, [NotNullWhen(true)] out DuskEntityReplacementDefinition? entityReplacement) { entityReplacement = null; foreach (DuskEntityReplacementDefinition value in entityReplacementRegistry.Values) { if (value.Key.NetworkID == networkID) { entityReplacement = value; return true; } } return false; } } public class DuskItemReplacementDefinition : DuskEntityReplacementDefinition { [CompilerGenerated] private sealed class d__40 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object? IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object? IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__40(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>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 bool IsConductiveMetal { get; private set; } [field: SerializeField] public AudioClip? GrabSFX { get; private set; } [field: SerializeField] public AudioClip? DropSFX { get; private set; } [field: SerializeField] public AudioClip? PocketSFX { get; private set; } [field: SerializeField] public AudioClip? ThrowSFX { get; private set; } [field: SerializeField] public float VerticalOffset { get; private set; } [field: SerializeField] public int FloorYOffset { get; private set; } [field: SerializeField] public Vector3 RestingRotation { get; private set; } = new Vector3(0f, 0f, 90f); [field: SerializeField] public Vector3 RotationOffset { get; private set; } [field: SerializeField] public Vector3 PositionOffset { get; private set; } [IteratorStateMachine(typeof(d__40))] public override IEnumerator Apply(GrabbableObject ai, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__40(0); } } public abstract class DuskItemReplacementDefinition : DuskItemReplacementDefinition where T : GrabbableObject { [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public GrabbableObject grabbableObject; public DuskItemReplacementDefinition <>4__this; public bool immediate; private Transform 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; DuskItemReplacementDefinition duskItemReplacementDefinition = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; 5__2 = ((Component)grabbableObject).transform; grabbableObject.SetGrabbableObjectReplacement(duskItemReplacementDefinition); if (immediate) { ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(((DuskItemReplacementDefinition)duskItemReplacementDefinition).Apply(grabbableObject, immediate)); goto IL_009f; } <>2__current = ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(((DuskItemReplacementDefinition)duskItemReplacementDefinition).Apply(grabbableObject, immediate)); <>1__state = 1; return true; case 1: <>1__state = -1; goto IL_009f; case 2: { <>1__state = -1; if ((Object)(object)grabbableObject == (Object)null) { return false; } duskItemReplacementDefinition.ApplyTyped((T)(object)grabbableObject); return false; } IL_009f: <>2__current = ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(duskItemReplacementDefinition.ApplyReplacementAndAddons(5__2, immediate)); <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } protected abstract void ApplyTyped(T grabbableObject); [IteratorStateMachine(typeof(DuskItemReplacementDefinition<>.d__1))] public override IEnumerator Apply(GrabbableObject grabbableObject, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { <>4__this = this, grabbableObject = grabbableObject, immediate = immediate }; } } public static class GrabbableObjectExtensions { public static bool TryGetGrabbableObjectReplacement(this GrabbableObject grabbableObject, [NotNullWhen(true)] out DuskItemReplacementDefinition? output) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) output = ((ICurrentEntityReplacement)grabbableObject).CurrentEntityReplacement as DuskItemReplacementDefinition; return (Object)(object)output != (Object)null; } [Obsolete("Use TryGetGrabbableObjectReplacement")] public static DuskItemReplacementDefinition? GetGrabbableObjectReplacement(this GrabbableObject grabbableObject) { grabbableObject.TryGetGrabbableObjectReplacement(out DuskItemReplacementDefinition output); return output; } internal static void SetGrabbableObjectReplacement(this GrabbableObject grabbableObject, DuskItemReplacementDefinition itemReplacementDefinition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((ICurrentEntityReplacement)grabbableObject).CurrentEntityReplacement = itemReplacementDefinition; } } public class DuskMapObject : MonoBehaviour, ICurrentEntityReplacement { public object? CurrentEntityReplacement { get; set; } public DuskMapObjectReplacementDefinition? GetMapObjectReplacement() { return (DuskMapObjectReplacementDefinition)CurrentEntityReplacement; } internal bool HasMapObjectReplacement() { return (Object)(object)GetMapObjectReplacement() != (Object)null; } internal void SetMapObjectReplacement(DuskMapObjectReplacementDefinition mapObjectReplacementDefinition) { CurrentEntityReplacement = mapObjectReplacementDefinition; } public void Start() { //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) DawnMapObjectNamespacedKeyContainer component = ((Component)this).GetComponent(); if ((Object)(object)component == (Object)null) { DuskPlugin.Logger.LogWarning((object)("DuskMapObject: " + ((Object)((Component)this).gameObject).name + " doesn't have a DawnMapObjectNamespacedKeyContainer component, this means that you cannot replace this map object.")); } else if (component.Value == null) { DuskPlugin.Logger.LogWarning((object)("Failed to replace MapObject entity for '" + ((Object)((Component)component).gameObject).name + "', it doesn't have a dawn info! (there may be other problems)")); } else { List collection = default(List); if (!((DawnBaseInfo)(object)((Registry)(object)LethalContent.MapObjects)[component.Value.AsTyped()]).CustomData.TryGet>(DuskKeys.EntityReplacements, ref collection) || HasMapObjectReplacement()) { return; } List list = new List(collection); for (int num = list.Count - 1; num >= 0; num--) { DuskMapObjectReplacementDefinition duskMapObjectReplacementDefinition = list[num]; if (!((Object)(object)duskMapObjectReplacementDefinition.DatePredicate == (Object)null) && !duskMapObjectReplacementDefinition.DatePredicate.Evaluate()) { list.RemoveAt(num); } } DawnMoonInfo dawnInfo = SelectableLevelExtensions.GetDawnInfo(RoundManager.Instance.currentLevel); RuntimeDungeon dungeonGenerator = RoundManager.Instance.dungeonGenerator; object obj; if (dungeonGenerator == null) { obj = null; } else { DungeonGenerator generator = dungeonGenerator.Generator; if (generator == null) { obj = null; } else { DungeonFlow dungeonFlow = generator.DungeonFlow; obj = ((dungeonFlow != null) ? DungeonFlowExtensions.GetDawnInfo(dungeonFlow) : null); } } WeatherEffect currentWeatherEffect = TimeOfDayRefs.GetCurrentWeatherEffect(dawnInfo.Level); SpawnWeightContext val = new SpawnWeightContext(dawnInfo, (DawnDungeonInfo)obj, (currentWeatherEffect != null) ? WeatherEffectExtensions.GetDawnInfo(currentWeatherEffect) : null); SpawnWeightContext ctx = ((SpawnWeightContext)(ref val)).WithExtra(SpawnWeightExtraKeys.RoutingPriceKey, dawnInfo.DawnPurchaseInfo.Cost.Provide()); int? num2 = list.Sum((DuskMapObjectReplacementDefinition it) => ProviderTableSpawnWeightExtensions.GetFor(it.Weights, ref ctx)); if (!num2.HasValue) { return; } if (EntityReplacementRegistrationPatch.mapObjectReplacementRandom == null) { EntityReplacementRegistrationPatch.mapObjectReplacementRandom = new Random(StartOfRound.Instance.randomMapSeed + 234780); } int num3 = EntityReplacementRegistrationPatch.mapObjectReplacementRandom.Next(0, MathfExtensions.Clamp0(num2.Value)); foreach (DuskMapObjectReplacementDefinition item in list) { num3 -= MathfExtensions.Clamp0(ProviderTableSpawnWeightExtensions.GetFor(item.Weights, ref ctx).GetValueOrDefault()); if (num3 <= 0) { if (!item.IsDefault) { ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(item.Apply(this)); } break; } } } } public void OnDestroy() { } } public class DuskMapObjectReplacementDefinition : DuskEntityReplacementDefinition { [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>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(); } } [IteratorStateMachine(typeof(d__0))] public override IEnumerator Apply(DuskMapObject ai, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0); } } public abstract class DuskMapObjectReplacementDefinition : DuskMapObjectReplacementDefinition where T : DuskMapObject { [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public DuskMapObject dawnMapObject; public DuskMapObjectReplacementDefinition <>4__this; public bool immediate; private Transform 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; DuskMapObjectReplacementDefinition duskMapObjectReplacementDefinition = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; 5__2 = ((Component)dawnMapObject).transform; dawnMapObject.SetMapObjectReplacement(duskMapObjectReplacementDefinition); if (immediate) { ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(((DuskMapObjectReplacementDefinition)duskMapObjectReplacementDefinition).Apply(dawnMapObject, immediate)); goto IL_009f; } <>2__current = ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(((DuskMapObjectReplacementDefinition)duskMapObjectReplacementDefinition).Apply(dawnMapObject, immediate)); <>1__state = 1; return true; case 1: <>1__state = -1; goto IL_009f; case 2: { <>1__state = -1; if ((Object)(object)dawnMapObject == (Object)null) { return false; } duskMapObjectReplacementDefinition.ApplyTyped((T)dawnMapObject); return false; } IL_009f: <>2__current = ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(duskMapObjectReplacementDefinition.ApplyReplacementAndAddons(5__2, immediate)); <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } protected abstract void ApplyTyped(T dawnMapObject); [IteratorStateMachine(typeof(DuskMapObjectReplacementDefinition<>.d__1))] public override IEnumerator Apply(DuskMapObject dawnMapObject, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { <>4__this = this, dawnMapObject = dawnMapObject, immediate = immediate }; } } public struct SkinSyncEntry : INetworkSerializable { public NetworkObjectReference GrabbableRef; public ulong NetworkID; public SkinSyncEntry(NetworkObjectReference grabbableRef, ulong networkID) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) GrabbableRef = grabbableRef; NetworkID = networkID; } public unsafe void NetworkSerialize(BufferSerializer serializer) where T : IReaderWriter { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) ((BufferSerializer*)(&serializer))->SerializeValue(ref GrabbableRef, default(ForNetworkSerializable)); ((BufferSerializer*)(&serializer))->SerializeValue(ref NetworkID, default(ForPrimitives)); } } public class DuskUnlockable : MonoBehaviour, ICurrentEntityReplacement, IDawnSaveData { public object? CurrentEntityReplacement { get; set; } public AutoParentToShip AutoParentToShip { get; private set; } public PlaceableShipObject PlaceableShipObject { get; private set; } public DuskUnlockableReplacementDefinition? GetUnlockableReplacement() { return (DuskUnlockableReplacementDefinition)CurrentEntityReplacement; } internal bool HasUnlockableReplacement() { return (Object)(object)GetUnlockableReplacement() != (Object)null; } internal void SetUnlockableReplacement(DuskUnlockableReplacementDefinition unlockableReplacementDefinition) { CurrentEntityReplacement = unlockableReplacementDefinition; } public void Awake() { AutoParentToShip = ((Component)this).GetComponentInChildren(); PlaceableShipObject = ((Component)this).GetComponentInChildren(); } public void Start() { //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) DebugLogSource unlockables = Debuggers.Unlockables; if (unlockables != null) { unlockables.Log((object)(((Object)((Component)this).gameObject).name + " dusk unlockable starting...")); } if ((Object)(object)PlaceableShipObject == (Object)null) { return; } UnlockableItem val = StartOfRoundRefs.Instance.unlockablesList.unlockables[PlaceableShipObject.unlockableID]; List collection = default(List); if (!val.spawnPrefab && (Object)(object)val.prefabObject == (Object)null) { DuskPlugin.Logger.LogWarning((object)("Unlockable: " + val.unlockableName + " doesn't have a prefab nor does it spawn as one, this means that you cannot replace this unlockable.")); } else if (!UnlockableItemExtensions.HasDawnInfo(val)) { DuskPlugin.Logger.LogWarning((object)("Failed to replace unlockable entity for '" + val.unlockableName + "', it doesn't have a dawn info! (there may be other problems)")); } else if (!((DawnBaseInfo)(object)UnlockableItemExtensions.GetDawnInfo(val)).CustomData.TryGet>(DuskKeys.EntityReplacements, ref collection)) { DebugLogSource unlockables2 = Debuggers.Unlockables; if (unlockables2 != null) { unlockables2.Log((object)("Unlockable " + val.unlockableName + " has no replacements!")); } } else { if (HasUnlockableReplacement()) { return; } List list = new List(collection); for (int num = list.Count - 1; num >= 0; num--) { DuskUnlockableReplacementDefinition duskUnlockableReplacementDefinition = list[num]; if (!((Object)(object)duskUnlockableReplacementDefinition.DatePredicate == (Object)null) && !duskUnlockableReplacementDefinition.DatePredicate.Evaluate()) { list.RemoveAt(num); } } DawnMoonInfo dawnInfo = SelectableLevelExtensions.GetDawnInfo(RoundManager.Instance.currentLevel); SpawnWeightContext ctx = new SpawnWeightContext(dawnInfo, (DawnDungeonInfo)null, (DawnWeatherEffectInfo)null); int? num2 = list.Sum((DuskUnlockableReplacementDefinition it) => ProviderTableSpawnWeightExtensions.GetFor(it.Weights, ref ctx)); if (!num2.HasValue) { return; } if (EntityReplacementRegistrationPatch.unlockableReplacementRandom == null) { EntityReplacementRegistrationPatch.unlockableReplacementRandom = new Random(StartOfRoundRefs.Instance.randomMapSeed + 234780); } int num3 = EntityReplacementRegistrationPatch.unlockableReplacementRandom.Next(0, MathfExtensions.Clamp0(num2.Value)); foreach (DuskUnlockableReplacementDefinition item in list) { num3 -= MathfExtensions.Clamp0(ProviderTableSpawnWeightExtensions.GetFor(item.Weights, ref ctx).GetValueOrDefault()); if (num3 <= 0) { if (!item.IsDefault) { ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(item.Apply(this)); } break; } } } } public void OnDestroy() { } public virtual JToken GetDawnDataToSave() { return JToken.FromObject((object)0); } public virtual void LoadDawnSaveData(JToken saveData) { } } public class DuskUnlockableReplacementDefinition : DuskEntityReplacementDefinition { [CompilerGenerated] private sealed class d__0 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__0(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { if (<>1__state != 0) { return false; } <>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(); } } [IteratorStateMachine(typeof(d__0))] public override IEnumerator Apply(DuskUnlockable ai, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__0(0); } } public abstract class DuskUnlockableReplacementDefinition : DuskUnlockableReplacementDefinition where T : DuskUnlockable { [CompilerGenerated] private sealed class d__1 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public DuskUnlockable dawnUnlockable; public DuskUnlockableReplacementDefinition <>4__this; public bool immediate; private Transform 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { 5__2 = null; <>1__state = -2; } private bool MoveNext() { int num = <>1__state; DuskUnlockableReplacementDefinition duskUnlockableReplacementDefinition = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; 5__2 = ((Component)dawnUnlockable).transform; dawnUnlockable.SetUnlockableReplacement(duskUnlockableReplacementDefinition); if (immediate) { ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(((DuskUnlockableReplacementDefinition)duskUnlockableReplacementDefinition).Apply(dawnUnlockable, immediate)); goto IL_009f; } <>2__current = ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(((DuskUnlockableReplacementDefinition)duskUnlockableReplacementDefinition).Apply(dawnUnlockable, immediate)); <>1__state = 1; return true; case 1: <>1__state = -1; goto IL_009f; case 2: { <>1__state = -1; if ((Object)(object)dawnUnlockable == (Object)null) { return false; } duskUnlockableReplacementDefinition.ApplyTyped((T)dawnUnlockable); return false; } IL_009f: <>2__current = ((MonoBehaviour)StartOfRoundRefs.Instance).StartCoroutine(duskUnlockableReplacementDefinition.ApplyReplacementAndAddons(5__2, immediate)); <>1__state = 2; return true; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } protected abstract void ApplyTyped(T dawnUnlockable); [IteratorStateMachine(typeof(DuskUnlockableReplacementDefinition<>.d__1))] public override IEnumerator Apply(DuskUnlockable dawnUnlockable, bool immediate = false) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(0) { <>4__this = this, dawnUnlockable = dawnUnlockable, immediate = immediate }; } } [Serializable] public class GameObjectWithPath { [field: SerializeField] public string PathToGameObject { get; private set; } = string.Empty; [field: SerializeField] public GameObject GameObjectToCreate { get; private set; } [field: SerializeField] public Vector3 PositionOffset { get; private set; } = Vector3.zero; [field: SerializeField] public Vector3 RotationOffset { get; private set; } = Vector3.zero; } [Serializable] public class MaterialWithIndex { [field: SerializeField] public Material Material { get; private set; } [field: SerializeField] public int Index { get; private set; } } [CreateAssetMenu(fileName = "New Item Definition", menuName = "DawnLib/Definitions/Item Definition")] public class DuskItemDefinition : DuskContentDefinition { [field: FormerlySerializedAs("item")] [field: SerializeField] public Item Item { get; private set; } [field: SerializeField] public ShopItemPreset ShopItemPreset { get; private set; } = new ShopItemPreset(); [field: SerializeField] public DuskTerminalPredicate? TerminalPredicate { get; private set; } [field: SerializeField] public DuskPricingStrategy? PricingStrategy { get; private set; } [field: Space(10f)] [field: Header("Configs | Spawn Weights | Format: :=, i.e. magic_wesleys_mod:trite=+20")] [field: SerializeField] public List MoonSpawnWeightsConfig { get; private set; } = new List(); [field: SerializeField] public List InteriorSpawnWeightsConfig { get; private set; } = new List(); [field: SerializeField] public List WeatherSpawnWeightsConfig { get; private set; } = new List(); [field: SerializeField] public List RouteSpawnWeightsConfig { get; private set; } = new List(); [field: SerializeField] public bool GenerateSpawnWeightsConfig { get; private set; } = true; [field: Header("Configs | Scrap")] [field: SerializeField] public bool IsScrap { get; private set; } [field: SerializeField] public bool GenerateScrapConfig { get; private set; } [field: Header("Configs | Shop")] [field: SerializeField] public bool IsShopItem { get; private set; } [field: SerializeField] public bool GenerateShopItemConfig { get; private set; } [field: SerializeField] public int Cost { get; private set; } [field: Header("Configs | Misc")] [field: SerializeField] public bool GenerateDisableUnlockConfig { get; private set; } = true; [field: SerializeField] public bool GenerateDisablePricingStrategyConfig { get; private set; } = true; [Obsolete] [field: SerializeField] [field: DontDrawIfEmpty("obsolete", "Obsolete")] public string MoonSpawnWeights { get; private set; } [Obsolete] [field: SerializeField] [field: DontDrawIfEmpty("obsolete", "Obsolete")] public string InteriorSpawnWeights { get; private set; } [Obsolete] [field: SerializeField] [field: DontDrawIfEmpty("obsolete", "Obsolete")] public string WeatherSpawnWeights { get; private set; } internal string MoonSpawnWeightsCompat => MoonSpawnWeights; internal string InteriorSpawnWeightsCompat => InteriorSpawnWeights; internal string WeatherSpawnWeightsCompat => WeatherSpawnWeights; public SpawnWeightsPreset SpawnWeights { get; private set; } = new SpawnWeightsPreset(); public ItemConfig Config { get; private set; } protected override string EntityNameReference => Item?.itemName ?? string.Empty; public override void Register(DuskMod mod) { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown base.Register(mod); BoundedRange val = new BoundedRange((float)Item.minValue * 0.4f, (float)Item.maxValue * 0.4f); using ConfigContext section = mod.ConfigManager.CreateConfigSectionForBundleData(AssetBundleData); Config = CreateItemConfig(section); base.BaseConfig = Config; if (Config.Worth != null) { BoundedRange value = Config.Worth.Value; if (value.Min == -1f || value.Max == -1f) { ManualLogSource? logger = mod.Logger; if (logger != null) { logger.LogInfo((object)("Migrating scrap value of " + Item.itemName + " from -1,-1.")); } Config.Worth.Value = val; } else { val = value; } } Item.minValue = (int)(val.Min / 0.4f); Item.maxValue = (int)(val.Max / 0.4f); List moonConfig = NamespacedConfigWeight.ConvertManyFromString(MoonSpawnWeightsCompat); if (MoonSpawnWeightsConfig.Count > 0) { moonConfig = MoonSpawnWeightsConfig; } if (Config.MoonSpawnWeights != null) { moonConfig = NamespacedConfigWeight.ConvertManyFromString(Config.MoonSpawnWeights.Value); } List interiorConfig = NamespacedConfigWeight.ConvertManyFromString(InteriorSpawnWeightsCompat); if (InteriorSpawnWeightsConfig.Count > 0) { interiorConfig = InteriorSpawnWeightsConfig; } if (Config.InteriorSpawnWeights != null) { interiorConfig = NamespacedConfigWeight.ConvertManyFromString(Config.InteriorSpawnWeights.Value); } List weatherConfig = NamespacedConfigWeight.ConvertManyFromString(WeatherSpawnWeightsCompat); if (WeatherSpawnWeightsConfig.Count > 0) { weatherConfig = WeatherSpawnWeightsConfig; } if (Config.WeatherSpawnWeights != null) { weatherConfig = NamespacedConfigWeight.ConvertManyFromString(Config.WeatherSpawnWeights.Value); } List routePriceConfig = IntComparisonConfigWeight.ConvertManyFromString(string.Empty); if (RouteSpawnWeightsConfig.Count > 0) { routePriceConfig = RouteSpawnWeightsConfig; } if (Config.RouteSpawnWeights != null) { routePriceConfig = IntComparisonConfigWeight.ConvertManyFromString(Config.RouteSpawnWeights.Value); } SpawnWeights.SetupSpawnWeightsPreset(moonConfig, interiorConfig, weatherConfig); SpawnWeights.AddRule(new RoutePriceRule(new RoutePriceWeightTransformer(routePriceConfig))); DawnLib.DefineItem(base.TypedKey, Item, (Action)delegate(ItemInfoBuilder builder) { if (Config.IsScrapItem?.Value ?? IsScrap) { builder.DefineScrap((Action)delegate(ScrapBuilder scrapBuilder) { scrapBuilder.SetWeights((Action>)delegate(WeightTableBuilder weightBuilder) { weightBuilder.SetGlobalWeight((IWeighted)(object)SpawnWeights); }); }); } if (Config.IsShopItem?.Value ?? IsShopItem) { builder.DefineShop((Action)delegate(ShopBuilder shopItemBuilder) { shopItemBuilder.OverrideRequestNode(ShopItemPreset.OrderRequestNode); shopItemBuilder.OverrideReceiptNode(ShopItemPreset.OrderReceiptNode); shopItemBuilder.OverrideInfoNode(ShopItemPreset.ItemInfoNode); ConfigEntry? disableUnlockRequirements = Config.DisableUnlockRequirements; if ((disableUnlockRequirements == null || !disableUnlockRequirements.Value) && (Object)(object)TerminalPredicate != (Object)null) { TerminalPredicate.Register((NamespacedKey)(object)base.TypedKey); shopItemBuilder.SetPurchasePredicate((ITerminalPurchasePredicate)(object)TerminalPredicate); } bool flag = Config.DisablePricingStrategy?.Value ?? false; if ((Object)(object)PricingStrategy != (Object)null && !flag) { PricingStrategy.Register(Key); shopItemBuilder.OverrideCost((IProvider)PricingStrategy); } else { shopItemBuilder.OverrideCost(Config.Cost?.Value ?? Cost); } }); } ApplyTagsTo((BaseInfoBuilder)(object)builder); }); } public ItemConfig CreateItemConfig(ConfigContext section) { //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Expected O, but got Unknown //IL_0444: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Expected O, but got Unknown ItemConfig itemConfig = new ItemConfig(section, EntityNameReference); itemConfig.MoonSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Moon Weights", "Preset moon weights for " + EntityNameReference + ".", (MoonSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(MoonSpawnWeightsConfig) : MoonSpawnWeightsCompat) : null); itemConfig.InteriorSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Interior Weights", "Preset interior weights for " + EntityNameReference + ".", (InteriorSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(InteriorSpawnWeightsConfig) : InteriorSpawnWeightsCompat) : null); itemConfig.WeatherSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Weather Weights", "Preset weather weights for " + EntityNameReference + ".", (WeatherSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(WeatherSpawnWeightsConfig) : WeatherSpawnWeightsCompat) : null); itemConfig.RouteSpawnWeights = (GenerateSpawnWeightsConfig ? section.Bind(EntityNameReference + " | Preset Route Weights", "Preset route weights for " + EntityNameReference + ".", IntComparisonConfigWeight.ConvertManyToString(RouteSpawnWeightsConfig)) : null); itemConfig.DisableUnlockRequirements = ((GenerateDisableUnlockConfig && Object.op_Implicit((Object)(object)TerminalPredicate)) ? section.Bind(EntityNameReference + " | Disable Unlock Requirements", "Whether " + EntityNameReference + " should have it's unlock requirements disabled.", defaultValue: false) : null); itemConfig.DisablePricingStrategy = ((GenerateDisablePricingStrategyConfig && Object.op_Implicit((Object)(object)PricingStrategy)) ? section.Bind(EntityNameReference + " | Disable Pricing Strategy", "Whether " + EntityNameReference + " should have it's pricing strategy disabled.", defaultValue: false) : null); itemConfig.IsScrapItem = (GenerateScrapConfig ? section.Bind(EntityNameReference + " | Is Scrap", "Whether " + EntityNameReference + " is a scrap item.", IsScrap) : null); itemConfig.Worth = ((itemConfig.IsScrapItem?.Value ?? IsScrap) ? section.Bind(EntityNameReference + " | Value", "How much " + EntityNameReference + " is worth when spawning.", new BoundedRange((float)Item.minValue * 0.4f, (float)Item.maxValue * 0.4f)) : null); itemConfig.IsShopItem = (GenerateShopItemConfig ? section.Bind(EntityNameReference + " | Is Shop Item", "Whether " + EntityNameReference + " is a shop item.", IsShopItem) : null); itemConfig.Cost = ((itemConfig.IsShopItem?.Value ?? IsShopItem) ? section.Bind(EntityNameReference + " | Cost", "Cost for " + EntityNameReference + " in the shop.", Cost) : null); if (!itemConfig.UserAllowedToEdit()) { DuskBaseConfig.AssignValueIfNotNull(itemConfig.MoonSpawnWeights, (MoonSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(MoonSpawnWeightsConfig) : MoonSpawnWeightsCompat); DuskBaseConfig.AssignValueIfNotNull(itemConfig.InteriorSpawnWeights, (InteriorSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(InteriorSpawnWeightsConfig) : InteriorSpawnWeightsCompat); DuskBaseConfig.AssignValueIfNotNull(itemConfig.WeatherSpawnWeights, (WeatherSpawnWeightsConfig.Count > 0) ? NamespacedConfigWeight.ConvertManyToString(WeatherSpawnWeightsConfig) : WeatherSpawnWeightsCompat); DuskBaseConfig.AssignValueIfNotNull(itemConfig.RouteSpawnWeights, IntComparisonConfigWeight.ConvertManyToString(RouteSpawnWeightsConfig)); DuskBaseConfig.AssignValueIfNotNull(itemConfig.DisableUnlockRequirements, value: false); DuskBaseConfig.AssignValueIfNotNull(itemConfig.DisablePricingStrategy, value: false); DuskBaseConfig.AssignValueIfNotNull(itemConfig.IsScrapItem, IsScrap); DuskBaseConfig.AssignValueIfNotNull(itemConfig.Worth, new BoundedRange((float)Item.minValue * 0.4f, (float)Item.maxValue * 0.4f)); DuskBaseConfig.AssignValueIfNotNull(itemConfig.IsShopItem, IsShopItem); DuskBaseConfig.AssignValueIfNotNull(itemConfig.Cost, Cost); } return itemConfig; } public override void TryNetworkRegisterAssets() { NetworkObject val = default(NetworkObject); if (Item.spawnPrefab.TryGetComponent(ref val)) { DawnLib.RegisterNetworkPrefab(Item.spawnPrefab); } } } [Serializable] public class DuskItemReference : DuskContentReference { public DuskItemReference() { } public DuskItemReference(NamespacedKey key) : base(key) { } public override bool TryResolve(out DawnItemInfo info) { return ((Registry)(object)LethalContent.Items).TryGetValue(base.TypedKey, ref info); } public override DawnItemInfo Resolve() { return ((Registry)(object)LethalContent.Items)[base.TypedKey]; } } public class ItemConfig : DuskBaseConfig { public ConfigEntry? Cost; public ConfigEntry? IsScrapItem; public ConfigEntry? IsShopItem; public ConfigEntry? DisableUnlockRequirements; public ConfigEntry? DisablePricingStrategy; public ConfigEntry? MoonSpawnWeights; public ConfigEntry? InteriorSpawnWeights; public ConfigEntry? WeatherSpawnWeights; public ConfigEntry? RouteSpawnWeights; public ConfigEntry? Worth; internal override List _configEntries => new List(10) { (ConfigEntryBase)(object)Cost, (ConfigEntryBase)(object)IsScrapItem, (ConfigEntryBase)(object)IsShopItem, (ConfigEntryBase)(object)DisableUnlockRequirements, (ConfigEntryBase)(object)DisablePricingStrategy, (ConfigEntryBase)(object)MoonSpawnWeights, (ConfigEntryBase)(object)InteriorSpawnWeights, (ConfigEntryBase)(object)WeatherSpawnWeights, (ConfigEntryBase)(object)RouteSpawnWeights, (ConfigEntryBase)(object)Worth }; public ItemConfig(ConfigContext section, string EntityNameReference) : base(section, EntityNameReference) { } } [AddComponentMenu("DawnLib/Progressive/Item Upgrade Scrap")] public class ItemUpgradeScrap : GrabbableObject { [field: SerializeReference] public DuskItemReference ItemReference { get; private set; } protected override void __initializeVariables() { ((GrabbableObject)this).__initializeVariables(); } protected override void __initializeRpcs() { ((GrabbableObject)this).__initializeRpcs(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "ItemUpgradeScrap"; } } [Serializable] public class ShopItemPreset { [field: SerializeField] public TerminalNode OrderRequestNode { get; private set; } [field: SerializeField] public TerminalNode OrderReceiptNode { get; private set; } [field: SerializeField] public TerminalNode ItemInfoNode { get; private set; } } [CreateAssetMenu(fileName = "New Map Definition", menuName = "DawnLib/Definitions/Map Object Definition")] public class DuskMapObjectDefinition : DuskContentDefinition { [field: FormerlySerializedAs("gameObject")] [field: SerializeField] public GameObject GameObject { get; private set; } [field: FormerlySerializedAs("objectName")] [field: FormerlySerializedAs("ObjectName")] [field: SerializeField] public string MapObjectName { get; private set; } [field: SerializeField] public InsideMapObjectSettings InsideMapObjectSettings { get; private set; } [field: SerializeField] public OutsideMapObjectSettings OutsideMapObjectSettings { get; private set; } [field: Space(10f)] [field: Header("Configs | Inside")] [field: SerializeField] public bool IsInsideHazard { get; private set; } [field: SerializeField] public bool CreateInsideHazardConfig { get; private set; } [field: SerializeField] public List InsideMoonCurveSpawnWeights { get; private set; } = new List(); [field: SerializeField] public List InsideInteriorCurveSpawnWeights { get; private set; } = new List(); [field: SerializeField] public bool InsidePrioritiseMoonConfig { get; private set; } = true; [field: SerializeField] public bool CreateInsideCurveSpawnWeightsConfig { get; private set; } [field: Header("Configs | Outside")] [field: SerializeField] public bool IsOutsideHazard { get; private set; } [field: SerializeField] public bool CreateOutsideHazardConfig { get; private set; } = true; [field: SerializeField] public List OutsideMoonCurveSpawnWeights { get; private set; } = new List(); [field: SerializeField] public List OutsideInteriorCurveSpawnWeights { get; private set; } = new List(); [field: SerializeField] public bool OutsidePrioritiseMoonConfig { get; private set; } = true; [field: SerializeField] public bool CreateOutsideCurveSpawnWeightsConfig { get; private set; } = true; [Obsolete] [field: SerializeField] [field: DontDrawIfEmpty("obsolete", "Obsolete")] public string DefaultOutsideCurveSpawnWeights { get; private set; } [Obsolete] [field: SerializeField] [field: DontDrawIfEmpty("obsolete", "Obsolete")] public string DefaultInsideCurveSpawnWeights { get; private set; } internal string DefaultOutsideCurveSpawnWeightsCompat => DefaultOutsideCurveSpawnWeights; internal string DefaultInsideCurveSpawnWeightsCompat => DefaultInsideCurveSpawnWeights; public MapObjectConfig Config { get; private set; } protected override string EntityNameReference => MapObjectName; public override void Register(DuskMod mod) { base.Register(mod); using ConfigContext section = mod.ConfigManager.CreateConfigSectionForBundleData(AssetBundleData); Config = CreateMapObjectConfig(section); base.BaseConfig = Config; DawnLib.DefineMapObject(base.TypedKey, GameObject, (Action)delegate(MapObjectInfoBuilder builder) { if (Config.InsideHazard?.Value ?? IsInsideHazard) { string text = Config.InsideMoonCurveSpawnWeights?.Value ?? DefaultInsideCurveSpawnWeightsCompat; if (Config.InsideMoonCurveSpawnWeights == null) { foreach (NamespacedKeyWithAnimationCurve insideMoonCurveSpawnWeight in InsideMoonCurveSpawnWeights) { text += $"{insideMoonCurveSpawnWeight.Key} - {ConfigManager.ParseString(insideMoonCurveSpawnWeight.Curve)} | "; } if (!string.IsNullOrWhiteSpace(text)) { string text2 = text; text = text2.Substring(0, text2.Length - 3); } } string text3 = Config.InsideInteriorCurveSpawnWeights?.Value ?? string.Empty; if (Config.InsideInteriorCurveSpawnWeights == null) { foreach (NamespacedKeyWithAnimationCurve insideInteriorCurveSpawnWeight in InsideInteriorCurveSpawnWeights) { text3 += $"{insideInteriorCurveSpawnWeight.Key} - {ConfigManager.ParseString(insideInteriorCurveSpawnWeight.Curve)} | "; } if (!string.IsNullOrWhiteSpace(text3)) { string text2 = text3; text3 = text2.Substring(0, text2.Length - 3); } } MapObjectSpawnMechanics InsideSpawnMechanics = new MapObjectSpawnMechanics(text, text3, Config.InsidePrioritiseMoon?.Value ?? InsidePrioritiseMoonConfig); builder.DefineInside((Action)delegate(InsideBuilder insideBuilder) { insideBuilder.OverrideSpawnFacingWall(InsideMapObjectSettings.spawnFacingWall); insideBuilder.OverrideSpawnFacingAwayFromWall(InsideMapObjectSettings.spawnFacingAwayFromWall); insideBuilder.OverrideRequireDistanceBetweenSpawns(InsideMapObjectSettings.requireDistanceBetweenSpawns); insideBuilder.OverrideDisallowSpawningNearEntrances(InsideMapObjectSettings.disallowSpawningNearEntrances); insideBuilder.OverrideSpawnWithBackToWall(InsideMapObjectSettings.spawnWithBackToWall); insideBuilder.OverrideSpawnWithBackFlushAgainstWall(InsideMapObjectSettings.spawnWithBackFlushAgainstWall); insideBuilder.OverrideAllowInMineshaft(InsideMapObjectSettings.allowInMineshaft); insideBuilder.SetWeights((Action>)delegate(CurveTableBuilder weightBuilder) { weightBuilder.SetGlobalCurve((IContextualProvider)(object)InsideSpawnMechanics); }); }); } if (Config.OutsideHazard?.Value ?? IsOutsideHazard) { string text4 = Config.OutsideMoonCurveSpawnWeights?.Value ?? DefaultOutsideCurveSpawnWeightsCompat; if (Config.OutsideMoonCurveSpawnWeights == null) { foreach (NamespacedKeyWithAnimationCurve outsideMoonCurveSpawnWeight in OutsideMoonCurveSpawnWeights) { text4 += $"{outsideMoonCurveSpawnWeight.Key} - {ConfigManager.ParseString(outsideMoonCurveSpawnWeight.Curve)} | "; } if (!string.IsNullOrWhiteSpace(text4)) { string text2 = text4; text4 = text2.Substring(0, text2.Length - 3); } } string text5 = Config.OutsideInteriorCurveSpawnWeights?.Value ?? string.Empty; if (Config.OutsideInteriorCurveSpawnWeights == null) { foreach (NamespacedKeyWithAnimationCurve outsideInteriorCurveSpawnWeight in OutsideInteriorCurveSpawnWeights) { text5 += $"{outsideInteriorCurveSpawnWeight.Key} - {ConfigManager.ParseString(outsideInteriorCurveSpawnWeight.Curve)} | "; } if (!string.IsNullOrWhiteSpace(text5)) { string text2 = text5; text5 = text2.Substring(0, text2.Length - 3); } } MapObjectSpawnMechanics OutsideSpawnMechanics = new MapObjectSpawnMechanics(text4, text5, Config.OutsidePrioritiseMoon?.Value ?? OutsidePrioritiseMoonConfig); builder.DefineOutside((Action)delegate(OutsideBuilder outsideBuilder) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) outsideBuilder.OverrideAlignWithTerrain(OutsideMapObjectSettings.alignWithTerrain); outsideBuilder.OverrideMinimumNodeSpawnRequirement(OutsideMapObjectSettings.minimumAINodeSpawnRequirement); outsideBuilder.OverrideObjectWidth(OutsideMapObjectSettings.objectWidth); outsideBuilder.OverrideRotationOffset(OutsideMapObjectSettings.rotationOffset); outsideBuilder.OverrideSpawnFacingAwayFromWall(OutsideMapObjectSettings.spawnFacingAwayFromWall); outsideBuilder.OverrideSpawnableFloorTags(OutsideMapObjectSettings.spawnableFloorTags); outsideBuilder.OverrideDestroyTrees(OutsideMapObjectSettings.destroyTrees); outsideBuilder.SetWeights((Action>)delegate(CurveTableBuilder weightBuilder) { weightBuilder.SetGlobalCurve((IContextualProvider)(object)OutsideSpawnMechanics); }); }); } ApplyTagsTo((BaseInfoBuilder)(object)builder); }); } public MapObjectConfig CreateMapObjectConfig(ConfigContext section) { MapObjectConfig mapObjectConfig = new MapObjectConfig(section, EntityNameReference); ConfigEntry val = null; ConfigEntry val2 = null; ConfigEntry insidePrioritiseMoon = null; ConfigEntry outsidePrioritiseMoon = null; ConfigEntry insideMoonCurveSpawnWeights = null; ConfigEntry insideInteriorCurveSpawnWeights = null; ConfigEntry outsideMoonCurveSpawnWeights = null; ConfigEntry outsideInteriorCurveSpawnWeights = null; if (CreateInsideHazardConfig) { val = section.Bind(EntityNameReference + " | Is Inside Hazard", "Whether " + EntityNameReference + " is an inside hazard", IsInsideHazard); } if (CreateOutsideHazardConfig) { val2 = section.Bind(EntityNameReference + " | Is Outside Hazard", "Whether " + EntityNameReference + " is an outside hazard", IsOutsideHazard); } string text = string.Empty; string text2 = string.Empty; if ((val?.Value ?? IsInsideHazard) && CreateInsideCurveSpawnWeightsConfig) { insidePrioritiseMoon = section.Bind(EntityNameReference + " | Inside Spawn Prioritise Moon", "Whether " + EntityNameReference + " should prioritise moon curves rather than interior curves when spawning inside.", InsidePrioritiseMoonConfig); text = DefaultInsideCurveSpawnWeightsCompat; if (string.IsNullOrWhiteSpace(text)) { foreach (NamespacedKeyWithAnimationCurve insideMoonCurveSpawnWeight in InsideMoonCurveSpawnWeights) { text += $"{insideMoonCurveSpawnWeight.Key} - {ConfigManager.ParseString(insideMoonCurveSpawnWeight.Curve)} | "; } if (!string.IsNullOrWhiteSpace(text)) { string text3 = text; text = text3.Substring(0, text3.Length - 3); } } text2 = string.Empty; if (string.IsNullOrWhiteSpace(text2)) { foreach (NamespacedKeyWithAnimationCurve insideInteriorCurveSpawnWeight in InsideInteriorCurveSpawnWeights) { text2 += $"{insideInteriorCurveSpawnWeight.Key} - {ConfigManager.ParseString(insideInteriorCurveSpawnWeight.Curve)} | "; } if (!string.IsNullOrWhiteSpace(text2)) { string text3 = text2; text2 = text3.Substring(0, text3.Length - 3); } } insideMoonCurveSpawnWeights = section.Bind(EntityNameReference + " | Inside Moon Spawn Weights", "Curve weights for " + EntityNameReference + " when spawning inside using Moon weights.", text); insideInteriorCurveSpawnWeights = section.Bind(EntityNameReference + " | Inside Interior Spawn Weights", "Curve weights for " + EntityNameReference + " when spawning inside using Interior weights.", text2); } string text4 = string.Empty; string text5 = string.Empty; if ((val2?.Value ?? IsOutsideHazard) && CreateOutsideCurveSpawnWeightsConfig) { outsidePrioritiseMoon = section.Bind(EntityNameReference + " | Outside Spawn Prioritise Moon", "Whether " + EntityNameReference + " should prioritise moon curves rather than interior curves when spawning outside.", OutsidePrioritiseMoonConfig); text4 = DefaultOutsideCurveSpawnWeightsCompat; if (string.IsNullOrWhiteSpace(text4)) { foreach (NamespacedKeyWithAnimationCurve outsideMoonCurveSpawnWeight in OutsideMoonCurveSpawnWeights) { text4 += $"{outsideMoonCurveSpawnWeight.Key} - {ConfigManager.ParseString(outsideMoonCurveSpawnWeight.Curve)} | "; } if (!string.IsNullOrWhiteSpace(text4)) { string text3 = text4; text4 = text3.Substring(0, text3.Length - 3); } } text5 = string.Empty; if (string.IsNullOrWhiteSpace(text5)) { foreach (NamespacedKeyWithAnimationCurve outsideInteriorCurveSpawnWeight in OutsideInteriorCurveSpawnWeights) { text5 += $"{outsideInteriorCurveSpawnWeight.Key} - {ConfigManager.ParseString(outsideInteriorCurveSpawnWeight.Curve)} | "; } if (!string.IsNullOrWhiteSpace(text5)) { string text3 = text5; text5 = text3.Substring(0, text3.Length - 3); } } outsideMoonCurveSpawnWeights = section.Bind(EntityNameReference + " | Outside Moon Spawn Weights", "Curve weights for " + EntityNameReference + " when spawning outside using Moon weights.", text4); outsideInteriorCurveSpawnWeights = section.Bind(EntityNameReference + " | Outside Interior Spawn Weights", "Curve weights for " + EntityNameReference + " when spawning outside using Interior weights.", text5); } mapObjectConfig.InsideHazard = val; mapObjectConfig.OutsideHazard = val2; mapObjectConfig.InsideMoonCurveSpawnWeights = insideMoonCurveSpawnWeights; mapObjectConfig.InsideInteriorCurveSpawnWeights = insideInteriorCurveSpawnWeights; mapObjectConfig.OutsideMoonCurveSpawnWeights = outsideMoonCurveSpawnWeights; mapObjectConfig.OutsideInteriorCurveSpawnWeights = outsideInteriorCurveSpawnWeights; mapObjectConfig.InsidePrioritiseMoon = insidePrioritiseMoon; mapObjectConfig.OutsidePrioritiseMoon = outsidePrioritiseMoon; if (!mapObjectConfig.UserAllowedToEdit()) { DuskBaseConfig.AssignValueIfNotNull(mapObjectConfig.InsideHazard, IsInsideHazard); DuskBaseConfig.AssignValueIfNotNull(mapObjectConfig.OutsideHazard, IsOutsideHazard); DuskBaseConfig.AssignValueIfNotNull(mapObjectConfig.InsideMoonCurveSpawnWeights, text); DuskBaseConfig.AssignValueIfNotNull(mapObjectConfig.InsideInteriorCurveSpawnWeights, text2); DuskBaseConfig.AssignValueIfNotNull(mapObjectConfig.OutsideMoonCurveSpawnWeights, text4); DuskBaseConfig.AssignValueIfNotNull(mapObjectConfig.OutsideInteriorCurveSpawnWeights, text5); DuskBaseConfig.AssignValueIfNotNull(mapObjectConfig.InsidePrioritiseMoon, InsidePrioritiseMoonConfig); DuskBaseConfig.AssignValueIfNotNull(mapObjectConfig.OutsidePrioritiseMoon, OutsidePrioritiseMoonConfig); } return mapObjectConfig; } public override void TryNetworkRegisterAssets() { NetworkObject val = default(NetworkObject); if (GameObject.TryGetComponent(ref val)) { DawnLib.RegisterNetworkPrefab(GameObject); } } } [Serializable] public class DuskMapObjectReference : DuskContentReference { public DuskMapObjectReference() { } public DuskMapObjectReference(NamespacedKey key) : base(key) { } public override bool TryResolve(out DawnMapObjectInfo info) { return ((Registry)(object)LethalContent.MapObjects).TryGetValue(base.TypedKey, ref info); } public override DawnMapObjectInfo Resolve() { return ((Registry)(object)LethalContent.MapObjects)[base.TypedKey]; } } public class MapObjectConfig : DuskBaseConfig { public ConfigEntry? InsideMoonCurveSpawnWeights; public ConfigEntry? InsideInteriorCurveSpawnWeights; public ConfigEntry? InsideHazard; public ConfigEntry? OutsideMoonCurveSpawnWeights; public ConfigEntry? OutsideInteriorCurveSpawnWeights; public ConfigEntry? OutsideHazard; public ConfigEntry? InsidePrioritiseMoon; public ConfigEntry? OutsidePrioritiseMoon; internal override List _configEntries => new List(8) { (ConfigEntryBase)(object)InsideMoonCurveSpawnWeights, (ConfigEntryBase)(object)InsideInteriorCurveSpawnWeights, (ConfigEntryBase)(object)InsideHazard, (ConfigEntryBase)(object)OutsideMoonCurveSpawnWeights, (ConfigEntryBase)(object)OutsideInteriorCurveSpawnWeights, (ConfigEntryBase)(object)OutsideHazard, (ConfigEntryBase)(object)InsidePrioritiseMoon, (ConfigEntryBase)(object)OutsidePrioritiseMoon }; public MapObjectConfig(ConfigContext section, string EntityNameReference) : base(section, EntityNameReference) { } } public class MapObjectSpawnMechanics : IContextualProvider { private Dictionary _spawnRateByMoonName { get; } = new Dictionary(); private Dictionary _spawnRateByInteriorName { get; } = new Dictionary(); public Dictionary CurvesByMoonOrTagName { get; } = new Dictionary(); public Dictionary CurvesByInteriorOrTagName { get; } = new Dictionary(); public bool PrioritiseMoons { get; } = true; public MapObjectSpawnMechanics(string moonConfigString, string interiorConfigString, bool prioritiseMoons = true) { _spawnRateByMoonName = ConfigManager.ParseNamespacedKeyWithCurves(moonConfigString); _spawnRateByInteriorName = ConfigManager.ParseNamespacedKeyWithCurves(interiorConfigString); string key; string value; foreach (KeyValuePair item in _spawnRateByMoonName) { item.Deconstruct(out key, out value); string text = key; string keyValuePairs = value; CurvesByMoonOrTagName[NamespacedKey.ForceParse(text, true)] = ConfigManager.ParseCurve(keyValuePairs); } foreach (KeyValuePair item2 in _spawnRateByInteriorName) { item2.Deconstruct(out value, out key); string text2 = value; string keyValuePairs2 = key; CurvesByInteriorOrTagName[NamespacedKey.ForceParse(text2, true)] = ConfigManager.ParseCurve(keyValuePairs2); } PrioritiseMoons = prioritiseMoons; ((Registry)(object)LethalContent.Moons).OnFreeze += ReregisterMoonCurves; ((Registry)(object)LethalContent.Dungeons).OnFreeze += ReregisterDungeonCurves; } private void ReregisterMoonCurves() { CurvesByMoonOrTagName.Clear(); foreach (var (text3, keyValuePairs) in _spawnRateByMoonName) { CurvesByMoonOrTagName[NamespacedKey.ForceParse(text3, true)] = ConfigManager.ParseCurve(keyValuePairs); } } private void ReregisterDungeonCurves() { CurvesByInteriorOrTagName.Clear(); foreach (var (text3, keyValuePairs) in _spawnRateByInteriorName) { CurvesByInteriorOrTagName[NamespacedKey.ForceParse(text3, true)] = ConfigManager.ParseCurve(keyValuePairs); } } public AnimationCurve CurveFunction(DawnMoonInfo moonInfo) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return CurveFunction(moonInfo, SpawnWeightContextFactory.FromCurrentGame()); } public AnimationCurve CurveFunction(DawnMoonInfo moonInfo, SpawnWeightContext ctx) { //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Expected O, but got Unknown //IL_01e1: Unknown result type (might be due to invalid IL or missing references) if (moonInfo == null || (Object)(object)moonInfo.Level == (Object)null) { return AnimationCurve.Constant(0f, 1f, 0f); } DawnDungeonInfo dungeon = ((SpawnWeightContext)(ref ctx)).Dungeon; if (PrioritiseMoons && CurvesByMoonOrTagName.TryGetValue(((DawnBaseInfo)(object)moonInfo).Key, out AnimationCurve value)) { return value; } if (dungeon != null && (Object)(object)dungeon.DungeonFlow != (Object)null && CurvesByInteriorOrTagName.TryGetValue(((DawnBaseInfo)(object)dungeon).Key, out value)) { return value; } if (!PrioritiseMoons && CurvesByMoonOrTagName.TryGetValue(((DawnBaseInfo)(object)moonInfo).Key, out value)) { return value; } if (dungeon == null || (Object)(object)dungeon.DungeonFlow == (Object)null) { return AnimationCurve.Constant(0f, 1f, 0f); } List list = new List(); NamespacedKey key; AnimationCurve value2; if (PrioritiseMoons) { foreach (KeyValuePair item3 in CurvesByMoonOrTagName) { item3.Deconstruct(out key, out value2); NamespacedKey val = key; AnimationCurve item = value2; if (((DawnBaseInfo)(object)moonInfo).HasTag(val)) { list.Add(item); } } } else { foreach (KeyValuePair item4 in CurvesByInteriorOrTagName) { item4.Deconstruct(out key, out value2); NamespacedKey val2 = key; AnimationCurve item2 = value2; if (((DawnBaseInfo)(object)dungeon).HasTag(val2)) { list.Add(item2); } } } if (list.Count > 0) { List list2 = new List(); for (float num = 0f; num < 1f; num += 0.01f) { List list3 = new List(); foreach (AnimationCurve item5 in list) { list3.Add(item5.Evaluate(num)); } float num2 = list3.Average(); list2.Add(new Keyframe(num, num2)); } return new AnimationCurve(list2.ToArray()); } DebugLogSource mapObjects = Debuggers.MapObjects; if (mapObjects != null) { mapObjects.Log((object)$"Failed to find curve for level: {moonInfo.Level}"); } return AnimationCurve.Constant(0f, 1f, 0f); } public AnimationCurve? Provide(DawnMoonInfo info, SpawnWeightContext ctx) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) return CurveFunction(info, ctx); } } [Serializable] public class NamespacedKeyWithAnimationCurve { [field: SerializeField] [field: UnlockedNamespacedKey] [field: InspectorName("Namespace")] public NamespacedKey Key { get; private set; } [field: SerializeField] [field: Tooltip("Make sure the curve goes from 0 to 1 in the X-axis at most, nothing more nothing less, Y-axis is what determines how many can spawn.")] public AnimationCurve Curve { get; private set; } } [CreateAssetMenu(fileName = "New Moon Definition", menuName = "DawnLib/Definitions/Moon Definition")] public class DuskMoonDefinition : DuskContentDefinition { [SerializeField] private List _scenes = new List(); [field: SerializeField] public SelectableLevel Level { get; private set; } [field: SerializeField] public DuskTerminalPredicate? TerminalPredicate { get; private set; } [field: SerializeField] public DuskPricingStrategy? PricingStrategy { get; private set; } [field: Header("Configs | Defaults")] [field: SerializeField] public int Cost { get; private set; } [field: SerializeField] [field: Tooltip("Vanilla typically hard codes this to a value of 3.")] public float OutsideEnemiesSpawnProbabilityRange { get; private set; } = 3f; [field: Header("Configs | Generation")] [field: SerializeField] public bool GenerateEnemyPowerCountConfigs { get; private set; } = true; [field: SerializeField] public bool GenerateEnemySpawnCurveConfigs { get; private set; } = true; [field: SerializeField] public bool GenerateEnemySpawnProbabilityRangeConfigs { get; private set; } = true; [field: SerializeField] public bool GenerateMinMaxScrapConfig { get; private set; } = true; [field: SerializeField] public bool GenerateTimeConfig { get; private set; } = true; [field: SerializeField] public bool GenerateCostConfig { get; private set; } = true; [field: SerializeField] public bool GenerateDisableUnlockConfig { get; private set; } = true; [field: SerializeField] public bool GenerateDisablePricingStrategyConfig { get; private set; } = true; public MoonConfig Config { get; private set; } protected override string EntityNameReference => Level?.PlanetName ?? string.Empty; public override void Register(DuskMod mod) { DuskMod mod2 = mod; base.Register(mod2); ConfigContext section = mod2.ConfigManager.CreateConfigSectionForBundleData(AssetBundleData); try { Config = CreateMoonConfig(section); base.BaseConfig = Config; DawnLib.DefineMoon(base.TypedKey, Level, (Action)delegate(MoonInfoBuilder builder) { //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Expected O, but got Unknown foreach (DuskMoonSceneData scene in _scenes) { builder.AddScene(scene.Key, scene.ShipLandingOverrideAnimation, scene.ShipTakeoffOverrideAnimation, scene.Weight(section, _scenes.Count), mod2.GetRelativePath("Assets", scene.BundleName), scene.Scene.ScenePath); } ConfigEntry? disableUnlockRequirements = Config.DisableUnlockRequirements; if ((disableUnlockRequirements == null || !disableUnlockRequirements.Value) && (Object)(object)TerminalPredicate != (Object)null) { TerminalPredicate.Register((NamespacedKey)(object)base.TypedKey); builder.SetPurchasePredicate((ITerminalPurchasePredicate)(object)TerminalPredicate); } ConfigEntry? disablePricingStrategy = Config.DisablePricingStrategy; if ((disablePricingStrategy == null || !disablePricingStrategy.Value) && (Object)(object)PricingStrategy != (Object)null) { PricingStrategy.Register(Key); builder.OverrideCost((IProvider)PricingStrategy); } else { builder.OverrideCost(Config.Cost?.Value ?? Cost); } builder.OverrideTimeMultiplier(Config.TimeFactor?.Value ?? Level.DaySpeedMultiplier); ConfigEntry? minMaxScrap = Config.MinMaxScrap; float num = ((minMaxScrap != null) ? minMaxScrap.Value.Min : ((float)Level.minScrap)); ConfigEntry? minMaxScrap2 = Config.MinMaxScrap; builder.OverrideMinMaxScrap(new BoundedRange(num, (minMaxScrap2 != null) ? minMaxScrap2.Value.Max : ((float)Level.maxScrap))); builder.OverrideEnemyPowerCount(Config.InsideEnemyPowerCount?.Value ?? Level.maxEnemyPowerCount, Config.OutsideEnemyPowerCount?.Value ?? Level.maxOutsideEnemyPowerCount, Config.DaytimeEnemyPowerCount?.Value ?? Level.maxDaytimeEnemyPowerCount); builder.OverrideEnemySpawnCurves(Config.InsideEnemySpawnCurve?.Value ?? Level.enemySpawnChanceThroughoutDay, Config.OutsideEnemySpawnCurve?.Value ?? Level.outsideEnemySpawnChanceThroughDay, Config.DaytimeEnemySpawnCurve?.Value ?? Level.daytimeEnemySpawnChanceThroughDay); builder.OverrideEnemySpawnRanges(Config.InsideEnemySpawnRange?.Value ?? Level.spawnProbabilityRange, Config.OutsideEnemySpawnRange?.Value ?? OutsideEnemiesSpawnProbabilityRange, Config.DaytimeEnemySpawnRange?.Value ?? Level.daytimeEnemiesProbabilityRange); ApplyTagsTo((BaseInfoBuilder)(object)builder); }); } finally { if (section != null) { ((IDisposable)section).Dispose(); } } } public MoonConfig CreateMoonConfig(ConfigContext section) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown //IL_04b9: Unknown result type (might be due to invalid IL or missing references) //IL_04c3: Expected O, but got Unknown MoonConfig moonConfig = new MoonConfig(section, EntityNameReference) { Cost = (GenerateCostConfig ? section.Bind(EntityNameReference + " | Cost", "Cost for " + EntityNameReference + " in the shop.", Cost) : null), MinMaxScrap = (GenerateMinMaxScrapConfig ? section.Bind(EntityNameReference + " | Min/Max Scrap", "Min/Max scrap for " + EntityNameReference + ".", new BoundedRange((float)Level.minScrap, (float)Level.maxScrap)) : null), TimeFactor = ((GenerateTimeConfig && Level.spawnEnemiesAndScrap) ? section.Bind(EntityNameReference + " | Time Multiplier", "Time multiplier for " + EntityNameReference + ".", Level.DaySpeedMultiplier) : null), InsideEnemyPowerCount = ((GenerateEnemyPowerCountConfigs && Level.spawnEnemiesAndScrap) ? section.Bind(EntityNameReference + " | Inside Enemy Power Count", "Inside enemy power count for " + EntityNameReference + ".", Level.maxEnemyPowerCount) : null), OutsideEnemyPowerCount = ((GenerateEnemyPowerCountConfigs && Level.spawnEnemiesAndScrap) ? section.Bind(EntityNameReference + " | Outside Enemy Power Count", "Outside enemy power count for " + EntityNameReference + ".", Level.maxOutsideEnemyPowerCount) : null), DaytimeEnemyPowerCount = ((GenerateEnemyPowerCountConfigs && Level.spawnEnemiesAndScrap) ? section.Bind(EntityNameReference + " | Daytime Enemy Power Count", "Daytime enemy power count for " + EntityNameReference + ".", Level.maxDaytimeEnemyPowerCount) : null), InsideEnemySpawnRange = ((GenerateEnemySpawnProbabilityRangeConfigs && Level.spawnEnemiesAndScrap) ? section.Bind(EntityNameReference + " | Inside Enemy Spawn Range", "Inside enemy spawn range for " + EntityNameReference + ".", Level.spawnProbabilityRange) : null), OutsideEnemySpawnRange = ((GenerateEnemySpawnProbabilityRangeConfigs && Level.spawnEnemiesAndScrap) ? section.Bind(EntityNameReference + " | Outside Enemy Spawn Range", "Outside enemy spawn range for " + EntityNameReference + ".", OutsideEnemiesSpawnProbabilityRange) : null), DaytimeEnemySpawnRange = ((GenerateEnemySpawnProbabilityRangeConfigs && Level.spawnEnemiesAndScrap) ? section.Bind(EntityNameReference + " | Daytime Enemy Spawn Range", "Daytime enemy spawn range for " + EntityNameReference + ".", Level.daytimeEnemiesProbabilityRange) : null), InsideEnemySpawnCurve = ((GenerateEnemySpawnCurveConfigs && Level.spawnEnemiesAndScrap) ? section.Bind(EntityNameReference + " | Inside Enemy Spawn Curve", "Inside enemy spawn curve for " + EntityNameReference + ".", Level.enemySpawnChanceThroughoutDay) : null), OutsideEnemySpawnCurve = ((GenerateEnemySpawnCurveConfigs && Level.spawnEnemiesAndScrap) ? section.Bind(EntityNameReference + " | Outside Enemy Spawn Curve", "Outside enemy spawn curve for " + EntityNameReference + ".", Level.outsideEnemySpawnChanceThroughDay) : null), DaytimeEnemySpawnCurve = ((GenerateEnemySpawnCurveConfigs && Level.spawnEnemiesAndScrap) ? section.Bind(EntityNameReference + " | Daytime Enemy Spawn Curve", "Daytime enemy spawn curve for " + EntityNameReference + ".", Level.daytimeEnemySpawnChanceThroughDay) : null), DisableUnlockRequirements = ((GenerateDisableUnlockConfig && Object.op_Implicit((Object)(object)TerminalPredicate)) ? section.Bind(EntityNameReference + " | Disable Unlock Requirements", "Whether " + EntityNameReference + " should have it's unlock requirements disabled.", defaultValue: false) : null), DisablePricingStrategy = ((GenerateDisablePricingStrategyConfig && Object.op_Implicit((Object)(object)PricingStrategy)) ? section.Bind(EntityNameReference + " | Disable Pricing Strategy", "Whether " + EntityNameReference + " should have it's pricing strategy disabled.", defaultValue: false) : null) }; if (!moonConfig.UserAllowedToEdit()) { DuskBaseConfig.AssignValueIfNotNull(moonConfig.Cost, Cost); DuskBaseConfig.AssignValueIfNotNull(moonConfig.MinMaxScrap, new BoundedRange((float)Level.minScrap, (float)Level.maxScrap)); DuskBaseConfig.AssignValueIfNotNull(moonConfig.TimeFactor, Level.DaySpeedMultiplier); DuskBaseConfig.AssignValueIfNotNull(moonConfig.InsideEnemyPowerCount, Level.maxEnemyPowerCount); DuskBaseConfig.AssignValueIfNotNull(moonConfig.OutsideEnemyPowerCount, Level.maxOutsideEnemyPowerCount); DuskBaseConfig.AssignValueIfNotNull(moonConfig.DaytimeEnemyPowerCount, Level.maxDaytimeEnemyPowerCount); DuskBaseConfig.AssignValueIfNotNull(moonConfig.InsideEnemySpawnRange, Level.spawnProbabilityRange); DuskBaseConfig.AssignValueIfNotNull(moonConfig.OutsideEnemySpawnRange, OutsideEnemiesSpawnProbabilityRange); DuskBaseConfig.AssignValueIfNotNull(moonConfig.DaytimeEnemySpawnRange, Level.daytimeEnemiesProbabilityRange); DuskBaseConfig.AssignValueIfNotNull(moonConfig.InsideEnemySpawnCurve, Level.enemySpawnChanceThroughoutDay); DuskBaseConfig.AssignValueIfNotNull(moonConfig.OutsideEnemySpawnCurve, Level.outsideEnemySpawnChanceThroughDay); DuskBaseConfig.AssignValueIfNotNull(moonConfig.DaytimeEnemySpawnCurve, Level.daytimeEnemySpawnChanceThroughDay); DuskBaseConfig.AssignValueIfNotNull(moonConfig.DisableUnlockRequirements, value: false); DuskBaseConfig.AssignValueIfNotNull(moonConfig.DisablePricingStrategy, value: false); } return moonConfig; } public override void TryNetworkRegisterAssets() { } } [Serializable] public class DuskMoonSceneData { public SceneReference Scene; [InspectorName("Namespace")] [DefaultKeySource("SceneName", true)] public NamespacedKey Key; private ProviderTable _weights; public string BundleName => Scene.BundleName; public string SceneName => Scene.SceneName; [field: SerializeField] public AnimationClip ShipLandingOverrideAnimation { get; private set; } [field: SerializeField] public AnimationClip ShipTakeoffOverrideAnimation { get; private set; } [field: SerializeField] public int BaseWeight { get; private set; } = 100; [field: Header("Configs | SpawnWeights")] [field: SerializeField] public List WeatherSpawnWeightsConfig { get; private set; } = new List(); [field: SerializeField] public bool GenerateWeightsConfig { get; private set; } = true; public SpawnWeightsPreset SpawnWeights { get; private set; } = new SpawnWeightsPreset(); public MoonSceneConfig MoonSceneConfig { get; private set; } public ProviderTable Weight(ConfigContext section, int sceneCount) { if (sceneCount > 1) { GenerateWeightsConfig = false; } MoonSceneConfig = CreateMoonSceneConfig(section); List weatherConfig = WeatherSpawnWeightsConfig; if (MoonSceneConfig.WeatherSpawnWeights != null) { weatherConfig = NamespacedConfigWeight.ConvertManyFromString(MoonSceneConfig.WeatherSpawnWeights.Value); } SpawnWeights.SetupSpawnWeightsPreset(new List(), new List(), weatherConfig, BaseWeight); WeightTableBuilder val = new WeightTableBuilder(); val.SetGlobalWeight((IWeighted)(object)SpawnWeights); _weights = val.Build(); return _weights; } public MoonSceneConfig CreateMoonSceneConfig(ConfigContext section) { MoonSceneConfig moonSceneConfig = new MoonSceneConfig(section, SceneName) { BaseWeight = (GenerateWeightsConfig ? section.Bind(SceneName + " | Base Weight", "Base Weight for Moon Scene: " + SceneName + ".", BaseWeight) : null), WeatherSpawnWeights = (GenerateWeightsConfig ? section.Bind(SceneName + " | Weather Spawn Weights", "Weather Weights for Moon Scene: " + SceneName + ".", NamespacedConfigWeight.ConvertManyToString(WeatherSpawnWeightsConfig)) : null) }; if (!moonSceneConfig.UserAllowedToEdit()) { DuskBaseConfig.AssignValueIfNotNull(moonSceneConfig.BaseWeight, BaseWeight); DuskBaseConfig.AssignValueIfNotNull(moonSceneConfig.WeatherSpawnWeights, NamespacedConfigWeight.ConvertManyToString(WeatherSpawnWeightsConfig)); } return moonSceneConfig; } } [Serializable] public class DuskMoonReference : DuskContentReference { public DuskMoonReference() { } public DuskMoonReference(NamespacedKey key) : base(key) { } public override bool TryResolve(out DawnMoonInfo info) { return ((Registry)(object)LethalContent.Moons).TryGetValue(base.TypedKey, ref info); } public override DawnMoonInfo Resolve() { return ((Registry)(object)LethalContent.Moons)[base.TypedKey]; } } public class MoonConfig : DuskBaseConfig { public ConfigEntry? Cost; public ConfigEntry? TimeFactor; public ConfigEntry? DisableUnlockRequirements; public ConfigEntry? DisablePricingStrategy; public ConfigEntry? MinMaxScrap; public ConfigEntry? InsideEnemyPowerCount; public ConfigEntry? OutsideEnemyPowerCount; public ConfigEntry? DaytimeEnemyPowerCount; public ConfigEntry? InsideEnemySpawnCurve; public ConfigEntry? OutsideEnemySpawnCurve; public ConfigEntry? DaytimeEnemySpawnCurve; public ConfigEntry? InsideEnemySpawnRange; public ConfigEntry? OutsideEnemySpawnRange; public ConfigEntry? DaytimeEnemySpawnRange; internal override List _configEntries => new List(14) { (ConfigEntryBase)(object)Cost, (ConfigEntryBase)(object)TimeFactor, (ConfigEntryBase)(object)DisableUnlockRequirements, (ConfigEntryBase)(object)DisablePricingStrategy, (ConfigEntryBase)(object)MinMaxScrap, (ConfigEntryBase)(object)InsideEnemyPowerCount, (ConfigEntryBase)(object)OutsideEnemyPowerCount, (ConfigEntryBase)(object)DaytimeEnemyPowerCount, (ConfigEntryBase)(object)InsideEnemySpawnCurve, (ConfigEntryBase)(object)OutsideEnemySpawnCurve, (ConfigEntryBase)(object)DaytimeEnemySpawnCurve, (ConfigEntryBase)(object)InsideEnemySpawnRange, (ConfigEntryBase)(object)OutsideEnemySpawnRange, (ConfigEntryBase)(object)DaytimeEnemySpawnRange }; public MoonConfig(ConfigContext section, string EntityNameReference) : base(section, EntityNameReference) { } } public class MoonSceneConfig : DuskBaseConfig { public ConfigEntry? WeatherSpawnWeights; public ConfigEntry? BaseWeight; internal override List _configEntries => new List(2) { (ConfigEntryBase)(object)WeatherSpawnWeights, (ConfigEntryBase)(object)BaseWeight }; public MoonSceneConfig(ConfigContext section, string EntityNameReference) : base(section, EntityNameReference) { } } [AddComponentMenu("DawnLib/Progressive/Moon Progressive Scrap")] public class MoonProgressiveScrap : GrabbableObject { [field: SerializeReference] public DuskMoonReference MoonReference { get; private set; } protected override void __initializeVariables() { ((GrabbableObject)this).__initializeVariables(); } protected override void __initializeRpcs() { ((GrabbableObject)this).__initializeRpcs(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "MoonProgressiveScrap"; } } [AddComponentMenu("DawnLib/Progressive/Planet Unlocker")] public class PlanetUnlocker : GrabbableObject { [CompilerGenerated] private sealed class d__7 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public PlanetUnlocker <>4__this; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Expected O, but got Unknown int num = <>1__state; PlanetUnlocker planetUnlocker = <>4__this; switch (num) { default: return false; case 0: <>1__state = -1; if (Object.op_Implicit((Object)(object)planetUnlocker._unlockAudio) && (Object)(object)planetUnlocker._unlockAudio.clip != (Object)null) { <>2__current = (object)new WaitForSeconds(planetUnlocker._unlockAudio.clip.length); <>1__state = 1; return true; } <>2__current = (object)new WaitForSeconds(1f); <>1__state = 2; return true; case 1: <>1__state = -1; break; case 2: <>1__state = -1; break; } ((GrabbableObject)planetUnlocker).playerHeldBy.inSpecialInteractAnimation = false; if (!PlayerControllerBExtensions.IsLocalPlayer(((GrabbableObject)planetUnlocker).playerHeldBy)) { return false; } if (planetUnlocker._consumeOnUnlock) { ((GrabbableObject)planetUnlocker).playerHeldBy.DespawnHeldObject(); } 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(); } } [Header("Planet Unlocker Settings")] [SerializeReference] private DuskMoonReference _moonReference; [SerializeField] private bool _consumeOnUnlock = true; [SerializeField] [Tooltip("Leave empty to have no audio")] private AudioSource _unlockAudio; [Header("Notification Settings")] [SerializeField] private bool _showDisplayTip; [SerializeField] private HUDDisplayTip _displayTip; public override void ItemActivate(bool used, bool buttonDown = true) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown ((GrabbableObject)this).ItemActivate(used, buttonDown); base.playerHeldBy.inSpecialInteractAnimation = true; if (!TryUnlock()) { HUDManagerExtensions.DisplayTip(HUDManager.Instance, new HUDDisplayTip("Error", "Coordinates to " + _moonReference.Key.Key + " could not be verified, Cancelling.", (AlertType)1)); } if (Object.op_Implicit((Object)(object)_unlockAudio)) { _unlockAudio.Play(); } ((MonoBehaviour)this).StartCoroutine(WaitToDespawn()); } private bool TryUnlock() { if (_moonReference.TryResolve(out DawnMoonInfo info)) { if (!(info.DawnPurchaseInfo.PurchasePredicate is ProgressivePredicate progressivePredicate)) { DuskPlugin.Logger.LogError((object)$"'{_moonReference.Key}' does not use a ProgressivePredicate"); return false; } progressivePredicate.Unlock(_showDisplayTip ? _displayTip : null); return true; } DuskPlugin.Logger.LogError((object)$"Couldn't resolve reference to '{_moonReference.Key}'. Is the bundle loaded?"); return false; } [IteratorStateMachine(typeof(d__7))] private IEnumerator WaitToDespawn() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__7(0) { <>4__this = this }; } protected override void __initializeVariables() { ((GrabbableObject)this).__initializeVariables(); } protected override void __initializeRpcs() { ((GrabbableObject)this).__initializeRpcs(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "PlanetUnlocker"; } } [CreateAssetMenu(fileName = "New StoryLog Definition", menuName = "DawnLib/Definitions/StoryLog Definition")] public class DuskStoryLogDefinition : DuskContentDefinition { [field: SerializeField] public GameObject StoryLogGameObject { get; private set; } [field: SerializeField] public string Title { get; private set; } [field: SerializeField] [field: TextArea(2, 20)] public string Description { get; private set; } [field: SerializeField] public string Keyword { get; private set; } [field: Header("Optional")] [field: SerializeField] public TerminalNode? OverrideTerminalNode { get; private set; } protected override string EntityNameReference => Title; public override void Register(DuskMod mod) { base.Register(mod); DawnLib.DefineStoryLog(base.TypedKey, StoryLogGameObject, (Action)delegate(StoryLogInfoBuilder builder) { builder.OverrideTerminalNode(OverrideTerminalNode); builder.SetTitle(Title); builder.SetDescription(Description); builder.SetKeyword(Keyword); ApplyTagsTo((BaseInfoBuilder)(object)builder); }); } public override void TryNetworkRegisterAssets() { NetworkObject val = default(NetworkObject); if (StoryLogGameObject.TryGetComponent(ref val)) { DawnLib.RegisterNetworkPrefab(StoryLogGameObject); } } } [Serializable] public class DuskStoryLogReference : DuskContentReference { public DuskStoryLogReference() { } public DuskStoryLogReference(NamespacedKey key) : base(key) { } public override bool TryResolve(out DawnStoryLogInfo info) { return LethalContent.StoryLogs.TryGetValue(base.TypedKey, ref info); } public override DawnStoryLogInfo Resolve() { return LethalContent.StoryLogs[base.TypedKey]; } } [CreateAssetMenu(fileName = "New Surface Definition", menuName = "DawnLib/Definitions/Surface Definition")] public class DuskSurfaceDefinition : DuskContentDefinition { [field: SerializeField] public FootstepSurface Surface { get; private set; } [field: SerializeField] public List CrouchClips { get; private set; } = new List(); [field: SerializeField] [field: Range(0f, 2f)] public float Volume { get; private set; } = 1f; [field: SerializeField] [field: Tooltip("This means that the earth leviathan can use this surface to emerge")] public bool IsNatural { get; private set; } [field: SerializeField] public bool QuicksandCompatible { get; private set; } [field: SerializeField] [field: Tooltip("Please make sure this is a prefab with a ParticleSystem!")] public GameObject? FootstepVFXPrefab { get; private set; } [field: SerializeField] public Vector3 PositionOffset { get; private set; } = Vector3.zero; protected override string EntityNameReference => Surface.surfaceTag; public override void Register(DuskMod mod) { base.Register(mod); if ((Object)(object)FootstepVFXPrefab != (Object)null && (Object)(object)FootstepVFXPrefab.GetComponentInChildren() == (Object)null) { DuskPlugin.Logger.LogError((object)("The FootstepVFXPrefab: " + ((Object)FootstepVFXPrefab).name + " has no ParticleSystem component, removed.")); FootstepVFXPrefab = null; } DawnLib.DefineSurface(base.TypedKey, Surface, (Action)delegate(SurfaceInfoBuilder builder) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) builder.SetSurfaceVFXPrefab(FootstepVFXPrefab); builder.OverrideSurfaceVFXOffset(PositionOffset); builder.OverrideIsNatural(IsNatural); builder.OverrideQuicksandCompatible(QuicksandCompatible); builder.SetCrouchClips(CrouchClips); builder.OverrideVolume(Volume); ApplyTagsTo((BaseInfoBuilder)(object)builder); }); } public override void TryNetworkRegisterAssets() { } } [Serializable] public class DuskSurfaceReference : DuskContentReference { public DuskSurfaceReference() { } public DuskSurfaceReference(NamespacedKey key) : base(key) { } public override bool TryResolve(out DawnSurfaceInfo info) { return LethalContent.Surfaces.TryGetValue(base.TypedKey, ref info); } public override DawnSurfaceInfo Resolve() { return LethalContent.Surfaces[base.TypedKey]; } } [Serializable] public class SimpleQueryCommand { [field: SerializeField] public bool Enabled { get; private set; } [field: SerializeField] [field: TextArea(3, 10)] public string ResultDisplayText { get; private set; } [field: SerializeField] [field: TextArea(3, 10)] public string ContinueOrCancelDisplayText { get; private set; } [field: SerializeField] [field: TextArea(3, 10)] public string CancelDisplayText { get; private set; } [field: SerializeField] public string CancelKeyword { get; private set; } [field: SerializeField] public string ContinueKeyword { get; private set; } } [Serializable] public class ComplexQueryCommand { [field: SerializeField] public bool Enabled { get; private set; } [field: SerializeField] [field: TextArea(3, 10)] public List ResultDisplayTexts { get; private set; } [field: SerializeField] public List ContinueKeywords { get; private set; } [field: SerializeField] [field: TextArea(3, 10)] public string ContinueOrCancelDisplayText { get; private set; } } [Serializable] public class ComplexCommand { [field: SerializeField] public bool Enabled { get; private set; } [field: SerializeField] public List SecondaryKeywords { get; private set; } [field: SerializeField] [field: TextArea(3, 10)] public List ResultDisplayTexts { get; private set; } } [Serializable] public class SimpleCommand { [field: SerializeField] public bool Enabled { get; private set; } [field: SerializeField] [field: TextArea(3, 10)] public string ResultDisplayText { get; private set; } } [Serializable] public class SimpleInputCommand { [field: SerializeField] public bool Enabled { get; private set; } [field: SerializeField] public List Inputs { get; private set; } [field: SerializeField] [field: TextArea(3, 10)] public List InputResults { get; private set; } [field: SerializeField] [field: TextArea(3, 10)] public string FailedInputResult { get; private set; } } [Serializable] public class StoryLogCommand { [field: SerializeField] public bool Enabled { get; private set; } [field: SerializeField] [field: Tooltip("Keywords such as sigurd `gold` or sigurd `work`, etc.")] public List InputKeywords { get; private set; } = new List(); [field: SerializeField] [field: Tooltip("Result of each keyword in the same order as InputKeywords.")] [field: TextArea(2, 10)] public List ResultDisplayTexts { get; private set; } = new List(); [field: SerializeField] [field: Tooltip("Keys that need to be saved in order to unlock the above entries.")] public List SavedResultKeys { get; private set; } = new List(); [field: SerializeField] [field: Tooltip("Appends text for each key that is in the save file.")] public List TextToAppendAfterEmptyResult { get; private set; } = new List(); [field: SerializeField] [field: Tooltip("Text added to the very beginning of the command when not given or given an invalid input.")] [field: TextArea(2, 10)] public string EmptyResultDisplayText { get; private set; } [field: SerializeField] [field: Tooltip("Text added to the very end of the command when not given or given an invalid input.")] [field: TextArea(2, 10)] public string PostEmptyResultDisplayText { get; private set; } internal string ResultDisplayText(string userInput) { PersistentDataContainer currentSave = DawnLib.GetCurrentSave(); if (currentSave == null) { return EmptyResultDisplayText; } HashSet orCreateDefault = ((DataContainer)currentSave).GetOrCreateDefault>(ExtraScanEvents._dataKey); orCreateDefault.UnionWith(((DataContainer)currentSave).GetOrCreateDefault>(CommitKeyToSave.DawnLibLoreKey)); for (int i = 0; i < InputKeywords.Count; i++) { if (orCreateDefault.Contains(SavedResultKeys[i]) && userInput.Equals(InputKeywords[i], StringComparison.OrdinalIgnoreCase)) { return ResultDisplayTexts[i]; } } StringBuilder stringBuilder = new StringBuilder(EmptyResultDisplayText); for (int j = 0; j < InputKeywords.Count; j++) { if (orCreateDefault.Contains(SavedResultKeys[j])) { stringBuilder.Append(TextToAppendAfterEmptyResult[j]); } } stringBuilder.Append(PostEmptyResultDisplayText); return stringBuilder.ToString(); } } [CreateAssetMenu(fileName = "New TerminalCommand Definition", menuName = "DawnLib/Definitions/TerminalCommand Definition")] public class DuskTerminalCommandDefinition : DuskContentDefinition { [field: SerializeField] public TerminalCommandBasicInformation CommandBasicInformation { get; private set; } [field: SerializeField] public List CommandKeywordsList { get; private set; } [field: SerializeField] [field: Tooltip("Your own sigurd-like storylog command, you'd need to implement gathering the entries in your own way, using Components like ExtraScanEvents and CommitKeyToSave.")] public StoryLogCommand StoryLogCommand { get; private set; } [field: SerializeField] [field: Tooltip("Setup a query command that involves a continue and cancel operation to reach the main command text.")] public SimpleQueryCommand SimpleQueryCommand { get; private set; } [field: SerializeField] [field: Tooltip("Setup a complex query command that can have multiple continues and one cancel operation to reach multiple main command texts.")] public ComplexQueryCommand ComplexQueryCommand { get; private set; } [field: SerializeField] public ComplexCommand ComplexCommand { get; private set; } [field: SerializeField] public SimpleCommand SimpleCommand { get; private set; } [field: SerializeField] public SimpleInputCommand SimpleInputCommand { get; private set; } protected override string EntityNameReference => CommandBasicInformation.CommandName ?? string.Empty; public override void Register(DuskMod mod) { base.Register(mod); DawnLib.DefineTerminalCommand(base.TypedKey, CommandBasicInformation, (Action)delegate(TerminalCommandInfoBuilder builder) { builder.SetKeywords(CommandKeywordsList); if (StoryLogCommand.Enabled) { builder.DefineInputCommand((Action)delegate(InputCommandBuilder inputCommandBuilder) { inputCommandBuilder.SetResultDisplayText((Func)StoryLogCommand.ResultDisplayText); }); } if (SimpleQueryCommand.Enabled) { builder.DefineSimpleQueryCommand((Action)delegate(SimpleQueryCommandBuilder simpleQueryBuilder) { simpleQueryBuilder.SetResult((Func)(() => SimpleQueryCommand.ResultDisplayText)); simpleQueryBuilder.SetCancel((Func)(() => SimpleQueryCommand.CancelDisplayText)); simpleQueryBuilder.SetContinueOrCancel((Func)(() => SimpleQueryCommand.ContinueOrCancelDisplayText)); simpleQueryBuilder.SetCancelWord(SimpleQueryCommand.CancelKeyword); simpleQueryBuilder.SetContinueWord(SimpleQueryCommand.ContinueKeyword); }); } if (ComplexQueryCommand.Enabled) { builder.DefineComplexQueryCommand((Action)delegate(ComplexQueryCommandBuilder complexQueryBuilder) { List> list2 = new List>(); foreach (string resultDisplayText2 in ComplexQueryCommand.ResultDisplayTexts) { list2.Add(() => resultDisplayText2); } complexQueryBuilder.SetResultDisplayTexts(list2); complexQueryBuilder.SetContinueOrCancelDisplayTexts((Func)(() => ComplexQueryCommand.ContinueOrCancelDisplayText)); complexQueryBuilder.SetContinueKeywords(ComplexQueryCommand.ContinueKeywords); }); } if (ComplexCommand.Enabled) { builder.DefineComplexCommand((Action)delegate(ComplexCommandBuilder complexCommandBuilder) { complexCommandBuilder.SetSecondaryKeywords(ComplexCommand.SecondaryKeywords); List> list = new List>(); foreach (string resultDisplayText in ComplexCommand.ResultDisplayTexts) { list.Add(() => resultDisplayText); } complexCommandBuilder.SetResultsDisplayText(list); }); } if (SimpleCommand.Enabled) { builder.DefineSimpleCommand((Action)delegate(SimpleCommandBuilder simpleCommandBuilder) { simpleCommandBuilder.SetResultDisplayText((Func)(() => SimpleCommand.ResultDisplayText)); }); } if (SimpleInputCommand.Enabled) { builder.DefineInputCommand((Action)delegate(InputCommandBuilder simpleInputCommandBuilder) { simpleInputCommandBuilder.SetResultDisplayText((Func)SimpleInputResult); }); } ApplyTagsTo((BaseInfoBuilder)(object)builder); }); } public string SimpleInputResult(string input) { for (int i = 0; i < SimpleInputCommand.Inputs.Count; i++) { string value = SimpleInputCommand.Inputs[i]; if (input.Equals(value, StringComparison.OrdinalIgnoreCase)) { return SimpleInputCommand.InputResults[i]; } } return SimpleInputCommand.FailedInputResult; } public override void TryNetworkRegisterAssets() { } } [Serializable] public class DuskTerminalCommandReference : DuskContentReference { public DuskTerminalCommandReference() { } public DuskTerminalCommandReference(NamespacedKey key) : base(key) { } public override bool TryResolve(out DawnTerminalCommandInfo info) { return LethalContent.TerminalCommands.TryGetValue(base.TypedKey, ref info); } public override DawnTerminalCommandInfo Resolve() { return LethalContent.TerminalCommands[base.TypedKey]; } } [CreateAssetMenu(fileName = "New Unlockable Definition", menuName = "DawnLib/Definitions/Unlockable Definition")] public class DuskUnlockableDefinition : DuskContentDefinition { [field: SerializeField] public UnlockableItem UnlockableItem { get; private set; } = new UnlockableItem(); [field: SerializeField] public string InfoNodeText { get; private set; } = string.Empty; [field: SerializeField] public DuskTerminalPredicate? TerminalPredicate { get; private set; } [field: SerializeField] public DuskPricingStrategy? PricingStrategy { get; private set; } [field: Space(10f)] [field: Header("Configs | Main")] [field: SerializeField] public int Cost { get; private set; } [field: SerializeField] public bool IsShipUpgrade { get; private set; } [field: SerializeField] public bool IsDecor { get; private set; } [field: Header("Configs | Misc")] [field: SerializeField] public bool GenerateCostConfig { get; private set; } = true; [field: SerializeField] public bool GenerateUnlockableTypeConfig { get; private set; } [field: SerializeField] public bool GenerateDisablePricingStrategyConfig { get; private set; } = true; [field: SerializeField] public bool GenerateDisableUnlockRequirementConfig { get; private set; } = true; public UnlockableConfig Config { get; private set; } protected override string EntityNameReference => UnlockableItem.unlockableName; public override void Register(DuskMod mod) { base.Register(mod); using ConfigContext section = mod.ConfigManager.CreateConfigSectionForBundleData(AssetBundleData); Config = CreateUnlockableConfig(section); base.BaseConfig = Config; DawnLib.DefineUnlockable(base.TypedKey, UnlockableItem, (Action)delegate(UnlockableInfoBuilder builder) { bool flag = Config.DisablePricingStrategy?.Value ?? false; if ((Object)(object)PricingStrategy != (Object)null && !flag) { PricingStrategy.Register(Key); builder.SetCost((IProvider)PricingStrategy); } else { builder.SetCost(Config.Cost?.Value ?? Cost); } if ((Object)(object)UnlockableItem.prefabObject != (Object)null) { builder.DefinePlaceableObject((Action)delegate(PlaceableObjectBuilder shopBuilder) { if (Config.IsShipUpgrade?.Value ?? IsShipUpgrade) { DebugLogSource unlockables = Debuggers.Unlockables; if (unlockables != null) { unlockables.Log((object)("Making " + UnlockableItem.unlockableName + " a Ship Upgrade")); } shopBuilder.SetShipUpgrade(); } else if (Config.IsDecor?.Value ?? IsDecor) { DebugLogSource unlockables2 = Debuggers.Unlockables; if (unlockables2 != null) { unlockables2.Log((object)("Making " + UnlockableItem.unlockableName + " a Decor")); } shopBuilder.SetDecor(); } }); } if ((Object)(object)UnlockableItem.suitMaterial != (Object)null) { builder.DefineSuit((Action)delegate(SuitBuilder suitBuilder) { suitBuilder.OverrideSuitMaterial(UnlockableItem.suitMaterial); suitBuilder.OverrideJumpAudioClip(UnlockableItem.jumpAudio); }); } ConfigEntry? disableUnlockRequirement = Config.DisableUnlockRequirement; if ((disableUnlockRequirement == null || !disableUnlockRequirement.Value) && (Object)(object)TerminalPredicate != (Object)null) { TerminalPredicate.Register(Key); builder.SetPurchasePredicate((ITerminalPurchasePredicate)(object)TerminalPredicate); } builder.SetInfoText(InfoNodeText); ApplyTagsTo((BaseInfoBuilder)(object)builder); }); } public UnlockableConfig CreateUnlockableConfig(ConfigContext section) { UnlockableConfig unlockableConfig = new UnlockableConfig(section, EntityNameReference) { Cost = (GenerateCostConfig ? section.Bind(EntityNameReference + " | Cost", "Cost for " + EntityNameReference + " in the shop.", Cost) : null), IsDecor = (GenerateUnlockableTypeConfig ? section.Bind(EntityNameReference + " | Is Decor", "Whether " + EntityNameReference + " is considered a decor.", IsDecor) : null), IsShipUpgrade = (GenerateUnlockableTypeConfig ? section.Bind(EntityNameReference + " | Is Ship Upgrade", "Whether " + EntityNameReference + " is considered a ship upgrade.", IsShipUpgrade) : null), DisableUnlockRequirement = (GenerateDisableUnlockRequirementConfig ? section.Bind(EntityNameReference + " | Disable Unlock Requirements", "Whether " + EntityNameReference + " should have it's unlock requirements disabled.", defaultValue: false) : null), DisablePricingStrategy = (GenerateDisablePricingStrategyConfig ? section.Bind(EntityNameReference + " | Disable Pricing Strategy", "Whether " + EntityNameReference + " should have it's pricing strategy disabled.", defaultValue: false) : null) }; if (!unlockableConfig.UserAllowedToEdit()) { DuskBaseConfig.AssignValueIfNotNull(unlockableConfig.Cost, Cost); DuskBaseConfig.AssignValueIfNotNull(unlockableConfig.IsDecor, IsDecor); DuskBaseConfig.AssignValueIfNotNull(unlockableConfig.IsShipUpgrade, IsShipUpgrade); DuskBaseConfig.AssignValueIfNotNull(unlockableConfig.DisableUnlockRequirement, value: false); DuskBaseConfig.AssignValueIfNotNull(unlockableConfig.DisablePricingStrategy, value: false); } return unlockableConfig; } public override void TryNetworkRegisterAssets() { NetworkObject val = default(NetworkObject); if (!((Object)(object)UnlockableItem.prefabObject == (Object)null) && UnlockableItem.prefabObject.TryGetComponent(ref val)) { DawnLib.RegisterNetworkPrefab(UnlockableItem.prefabObject); } } } [Serializable] public class DuskUnlockableReference : DuskContentReference { public DuskUnlockableReference() { } public DuskUnlockableReference(NamespacedKey key) : base(key) { } public override bool TryResolve(out DawnUnlockableItemInfo info) { return ((Registry)(object)LethalContent.Unlockables).TryGetValue(base.TypedKey, ref info); } public override DawnUnlockableItemInfo Resolve() { return ((Registry)(object)LethalContent.Unlockables)[base.TypedKey]; } } [AddComponentMenu("DawnLib/Progressive/Unlockable Upgrade Scrap")] public class UnlockableUpgradeScrap : GrabbableObject { [field: SerializeReference] public DuskUnlockableReference UnlockableReference { get; private set; } protected override void __initializeVariables() { ((GrabbableObject)this).__initializeVariables(); } protected override void __initializeRpcs() { ((GrabbableObject)this).__initializeRpcs(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "UnlockableUpgradeScrap"; } } public class UnlockableConfig : DuskBaseConfig { public ConfigEntry? Cost; public ConfigEntry? IsDecor; public ConfigEntry? IsShipUpgrade; public ConfigEntry? DisableUnlockRequirement; public ConfigEntry? DisablePricingStrategy; internal override List _configEntries => new List(5) { (ConfigEntryBase)(object)Cost, (ConfigEntryBase)(object)IsShipUpgrade, (ConfigEntryBase)(object)IsDecor, (ConfigEntryBase)(object)DisableUnlockRequirement, (ConfigEntryBase)(object)DisablePricingStrategy }; public UnlockableConfig(ConfigContext section, string EntityNameReference) : base(section, EntityNameReference) { } } public static class BuyableVehicleExtensions { public static NamespacedKey ToNamespacedKey(this BuyableVehicle buyableVehicle) { if (!buyableVehicle.TryGetDuskDefinition(out DuskVehicleDefinition buyableVehicleDefinition)) { DebugLogSource unlockables = Debuggers.Unlockables; if (unlockables != null) { unlockables.Log((object)$"BuyableVehicle {buyableVehicle} has no DuskDefinition"); } throw new Exception(); } return ((NamespacedKey)buyableVehicleDefinition.TypedKey).AsTyped(); } internal static bool TryGetDuskDefinition(this BuyableVehicle buyableVehicle, [NotNullWhen(true)] out DuskVehicleDefinition? buyableVehicleDefinition) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) buyableVehicleDefinition = (DuskVehicleDefinition)((IDawnObject)buyableVehicle).DawnInfo; return (Object)(object)buyableVehicleDefinition != (Object)null; } internal static void SetDuskDefinition(this BuyableVehicle buyableVehicle, DuskVehicleDefinition buyableVehicleDefinition) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((IDawnObject)buyableVehicle).DawnInfo = buyableVehicleDefinition; } } [Serializable] public class BuyableVehiclePreset { public GameObject VehiclePrefab; [Header("Optional")] public GameObject? StationPrefab; public GameObject? SecondaryPrefab; [TextArea(2, 20)] public string DisplayNodeText; public string BuyKeywordText; } [CreateAssetMenu(fileName = "New Vehicle Definition", menuName = "DawnLib/Definitions/Vehicle Definition")] public class DuskVehicleDefinition : DuskContentDefinition, INamespaced, INamespaced { [field: SerializeField] public string VehicleDisplayName { get; private set; } [field: SerializeField] public BuyableVehiclePreset BuyableVehiclePreset { get; private set; } [field: SerializeField] public DuskTerminalPredicate? TerminalPredicate { get; private set; } [field: SerializeField] public DuskPricingStrategy? PricingStrategy { get; private set; } [field: Space(10f)] [field: Header("Configs | Main")] [field: SerializeField] public int Cost { get; private set; } [field: Header("Configs | Misc")] [field: SerializeField] public bool GenerateCostConfig { get; private set; } = true; [field: SerializeField] public bool GenerateDisableUnlockConfig { get; private set; } = true; [field: SerializeField] public bool GenerateDisablePricingStrategyConfig { get; private set; } = true; public VehicleConfig Config { get; private set; } public DawnVehicleInfo DawnVehicleInfo { get; private set; } NamespacedKey INamespaced.TypedKey => ((NamespacedKey)base.TypedKey).AsTyped(); protected override string EntityNameReference => VehicleDisplayName; public override void Register(DuskMod mod) { //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) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Expected O, but got Unknown //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Expected O, but got Unknown if ((Object)(object)BuyableVehiclePreset.StationPrefab != (Object)null) { if ((Object)(object)BuyableVehiclePreset.StationPrefab.GetComponent() == (Object)null) { DuskPlugin.Logger.LogError((object)("The vehicle: " + ((Object)BuyableVehiclePreset.StationPrefab).name + " has no AutoParentToShip component.")); return; } if (BuyableVehiclePreset.StationPrefab.GetComponentsInChildren() == null) { DuskPlugin.Logger.LogError((object)("The vehicle: " + ((Object)BuyableVehiclePreset.StationPrefab).name + " has no PlaceableShipObject component.")); return; } NamespacedKey stationKey = BuyableVehiclePreset.StationPrefab.GetComponent().StationKey; UnlockableItem unlockableItem = new UnlockableItem { unlockableName = stationKey.Key + " (Station)", prefabObject = BuyableVehiclePreset.StationPrefab, unlockableType = 1, alwaysInStock = true, IsPlaceable = true }; DawnLib.DefineUnlockable(stationKey.AsTyped(), unlockableItem, (Action)delegate(UnlockableInfoBuilder builder) { builder.SetCost(99999); builder.DefinePlaceableObject((Action)delegate(PlaceableObjectBuilder shopBuilder) { DebugLogSource unlockables = Debuggers.Unlockables; if (unlockables != null) { unlockables.Log((object)("Making " + unlockableItem.unlockableName + " a Ship Upgrade")); } shopBuilder.SetShipUpgrade(); }); ITerminalPurchasePredicate purchasePredicate = ITerminalPurchasePredicate.AlwaysHide(); builder.SetPurchasePredicate(purchasePredicate); }); } base.Register(mod); using ConfigContext section = mod.ConfigManager.CreateConfigSectionForBundleData(AssetBundleData); Config = CreateVehicleConfig(section); base.BaseConfig = Config; if (GenerateCostConfig) { ConfigEntry cost = Config.Cost; if (cost != null) { Cost = Config.Cost.Value; } } ConfigEntry? disableUnlockRequirements = Config.DisableUnlockRequirements; if (disableUnlockRequirements != null && disableUnlockRequirements.Value) { TerminalPredicate = null; } ConfigEntry? disablePricingStrategy = Config.DisablePricingStrategy; if (disablePricingStrategy != null && disablePricingStrategy.Value) { PricingStrategy = null; } NamespacedKey typedKey = base.TypedKey; HashSet hashSet = _tags.ToHashSet(); GameObject vehiclePrefab = BuyableVehiclePreset.VehiclePrefab; GameObject? secondaryPrefab = BuyableVehiclePreset.SecondaryPrefab; GameObject? stationPrefab = BuyableVehiclePreset.StationPrefab; IProvider obj; if (!((Object)(object)PricingStrategy != (Object)null)) { IProvider val = (IProvider)(object)new SimpleProvider(Cost); obj = val; } else { IProvider val = PricingStrategy; obj = val; } ITerminalPurchasePredicate obj2; if (!((Object)(object)TerminalPredicate != (Object)null)) { obj2 = ITerminalPurchasePredicate.AlwaysSuccess(); } else { ITerminalPurchasePredicate terminalPredicate = (ITerminalPurchasePredicate)(object)TerminalPredicate; obj2 = terminalPredicate; } DawnVehicleInfo = new DawnVehicleInfo(typedKey, hashSet, vehiclePrefab, secondaryPrefab, stationPrefab, new DawnPurchaseInfo(obj, obj2), (IDataContainer)null); DuskModContent.Vehicles.Register(this); } public VehicleConfig CreateVehicleConfig(ConfigContext section) { VehicleConfig vehicleConfig = new VehicleConfig(section, EntityNameReference) { Cost = (GenerateCostConfig ? section.Bind(EntityNameReference + " | Cost", "Cost for " + EntityNameReference + " in the shop.", Cost) : null), DisableUnlockRequirements = (GenerateDisableUnlockConfig ? section.Bind(EntityNameReference + " | Disable Unlock Requirements", "Whether " + EntityNameReference + " should have it's unlock requirements disabled.", defaultValue: false) : null), DisablePricingStrategy = (GenerateDisablePricingStrategyConfig ? section.Bind(EntityNameReference + " | Disable Pricing Strategy", "Whether " + EntityNameReference + " should have it's pricing strategy disabled.", defaultValue: false) : null) }; if (!vehicleConfig.UserAllowedToEdit()) { DuskBaseConfig.AssignValueIfNotNull(vehicleConfig.Cost, Cost); DuskBaseConfig.AssignValueIfNotNull(vehicleConfig.DisableUnlockRequirements, value: false); DuskBaseConfig.AssignValueIfNotNull(vehicleConfig.DisablePricingStrategy, value: false); } return vehicleConfig; } public override void TryNetworkRegisterAssets() { NetworkObject val = default(NetworkObject); if ((Object)(object)BuyableVehiclePreset.VehiclePrefab != (Object)null && BuyableVehiclePreset.VehiclePrefab.TryGetComponent(ref val)) { DawnLib.RegisterNetworkPrefab(BuyableVehiclePreset.VehiclePrefab); } if ((Object)(object)BuyableVehiclePreset.SecondaryPrefab != (Object)null && BuyableVehiclePreset.SecondaryPrefab.TryGetComponent(ref val)) { DawnLib.RegisterNetworkPrefab(BuyableVehiclePreset.SecondaryPrefab); } if ((Object)(object)BuyableVehiclePreset.StationPrefab != (Object)null && BuyableVehiclePreset.StationPrefab.TryGetComponent(ref val)) { DawnLib.RegisterNetworkPrefab(BuyableVehiclePreset.StationPrefab); } } } [Serializable] public class DuskVehicleReference : DuskContentReference { public DuskVehicleReference() { } public DuskVehicleReference(NamespacedKey key) : base(key) { } public override bool TryResolve(out DuskVehicleDefinition info) { return DuskModContent.Vehicles.TryGetValue(base.TypedKey, ref info); } public override DuskVehicleDefinition Resolve() { return DuskModContent.Vehicles[base.TypedKey]; } } public class VehicleConfig : DuskBaseConfig { public ConfigEntry? Cost; public ConfigEntry? DisableUnlockRequirements; public ConfigEntry? DisablePricingStrategy; internal override List _configEntries => new List(3) { (ConfigEntryBase)(object)Cost, (ConfigEntryBase)(object)DisableUnlockRequirements, (ConfigEntryBase)(object)DisablePricingStrategy }; public VehicleConfig(ConfigContext section, string EntityNameReference) : base(section, EntityNameReference) { } } public interface IAnchorModule { IEnumerator EnableAnchor(IVehicle vehicle, IStation station); IEnumerator DisableAnchor(IVehicle vehicle, IStation station); } public interface IDropShipAttachment { Transform[] RopeAttachmentEndPoints { get; } int RealLength { get; } } public interface IStation : IAnchorModule { NamespacedKey StationKey { get; } Transform AnchorPoint { get; } bool IsOccupied { get; } IVehicle? CurrentVehicle { get; } bool CanAccept(IVehicle? vehicle); bool Engage(IVehicle? vehicle); bool Release(IVehicle? vehicle); } public interface IVehicle : IDropShipAttachment { NamespacedKey VehicleKey { get; } bool IsDocked { get; } IStation? CurrentStation { get; } UnityEvent Docked { get; } UnityEvent Undocked { get; } Collider[] VehicleColliders { get; } void RequestDock(IStation? station); void RequestUndock(IStation? station); void OnDocked(IStation station); void OnUndocked(IStation station); } [RequireComponent(typeof(AutoParentToShip))] [RequireComponent(typeof(PlaceableShipObject))] public abstract class StationBase : NetworkBehaviour, IStation, IAnchorModule { [field: SerializeField] public Transform AnchorPoint { get; private set; } public bool IsOccupied => CurrentVehicle != null; public IVehicle? CurrentVehicle { get; private set; } [field: SerializeField] public NamespacedKey StationKey { get; private set; } [field: SerializeField] public NamespacedKey CorrespondingVehicleKey { get; private set; } public virtual void Awake() { } public virtual bool CanAccept([NotNullWhen(true)] IVehicle? vehicle) { if (vehicle == null || vehicle.IsDocked) { return false; } if (CorrespondingVehicleKey != vehicle.VehicleKey) { return false; } if (IsOccupied) { return false; } return true; } public abstract IEnumerator DisableAnchor(IVehicle vehicle, IStation station); public abstract IEnumerator EnableAnchor(IVehicle vehicle, IStation station); public virtual bool Engage(IVehicle? vehicle) { if (!CanAccept(vehicle)) { return false; } CurrentVehicle = vehicle; vehicle.OnDocked(this); ((MonoBehaviour)this).StartCoroutine(EnableAnchor(vehicle, this)); return true; } public virtual bool Release(IVehicle? vehicle) { if (vehicle == null || vehicle != CurrentVehicle) { return false; } if (!IsOccupied) { return false; } CurrentVehicle = null; vehicle.OnUndocked(this); ((MonoBehaviour)this).StartCoroutine(DisableAnchor(vehicle, this)); return true; } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { ((NetworkBehaviour)this).__initializeRpcs(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "StationBase"; } } public abstract class VehicleBase : NetworkBehaviour, IVehicle, IDropShipAttachment { [field: SerializeField] public UnityEvent Docked { get; private set; } [field: SerializeField] public UnityEvent Undocked { get; private set; } public bool IsDocked { get; private set; } public IStation? CurrentStation { get; private set; } [field: SerializeField] public NamespacedKey VehicleKey { get; private set; } [field: SerializeField] public NamespacedKey CorrespondingStationKey { get; private set; } [field: SerializeField] public Transform[] RopeAttachmentEndPoints { get; private set; } NamespacedKey IVehicle.VehicleKey => (NamespacedKey)(object)VehicleKey; public bool InDropShipAnimation { get; internal set; } public int RealLength { get; private set; } = 4; public Collider[] VehicleColliders { get; private set; } public virtual void Awake() { //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) VehicleColliders = ((Component)this).GetComponentsInChildren(); int num = LayerMask.NameToLayer("Vehicle"); VehicleBase[] array = Object.FindObjectsOfType(); foreach (VehicleBase vehicleBase in array) { if ((Object)(object)vehicleBase == (Object)(object)this) { continue; } Collider[] vehicleColliders = vehicleBase.VehicleColliders; foreach (Collider val in vehicleColliders) { if (val.isTrigger || ((Component)val).gameObject.layer != num) { continue; } Collider[] vehicleColliders2 = VehicleColliders; foreach (Collider val2 in vehicleColliders2) { if (!val2.isTrigger && ((Component)val2).gameObject.layer == num) { Physics.IgnoreCollision(val, val2, false); } } } } if (RopeAttachmentEndPoints.Length > 4) { RopeAttachmentEndPoints = RopeAttachmentEndPoints.Take(4).ToArray(); } else if (RopeAttachmentEndPoints.Length < 4) { RealLength = RopeAttachmentEndPoints.Length; for (int l = RopeAttachmentEndPoints.Length; l < 4; l++) { RopeAttachmentEndPoints[l] = new GameObject($"RopeAttachmentPoint{l + 1}").transform; RopeAttachmentEndPoints[l].SetParent(((Component)this).transform, false); RopeAttachmentEndPoints[l].position = ((Component)this).transform.position; } } } public virtual void Update() { } public virtual void LateUpdate() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (InDropShipAnimation) { for (int i = 0; i < 4; i++) { RopeAttachmentEndPoints[i].position = ((Component)ItemDropshipRefs.Instance.ropes[i]).transform.position; } } } public virtual void FixedUpdate() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) if (InDropShipAnimation) { ((Component)this).transform.position = ItemDropshipRefs.Instance.deliverVehiclePoint.position; ((Component)this).transform.rotation = ItemDropshipRefs.Instance.deliverVehiclePoint.rotation; InDropShipAnimation = !StartOfRoundRefs.Instance.inShipPhase && TerminalRefs.LastVehicleDelivered == DuskModContent.Vehicles[VehicleKey].DawnVehicleInfo.BuyNode.buyVehicleIndex && ItemDropshipRefs.Instance.deliveringVehicle && !ItemDropshipRefs.Instance.untetheredVehicle; } } public virtual void RequestDock(IStation? station) { if (station != null && station.CanAccept(this) && CorrespondingStationKey == station.StationKey) { station.Engage(this); } } public virtual void RequestUndock(IStation? station) { if (CurrentStation != null && station == CurrentStation) { station.Release(this); } } public virtual void OnDocked(IStation station) { IsDocked = true; CurrentStation = station; Docked?.Invoke(station); } public virtual void OnUndocked(IStation station) { IsDocked = false; CurrentStation = null; Undocked?.Invoke(station); } protected override void __initializeVariables() { ((NetworkBehaviour)this).__initializeVariables(); } protected override void __initializeRpcs() { ((NetworkBehaviour)this).__initializeRpcs(); } [MethodImpl(MethodImplOptions.NoInlining)] protected internal override string __getTypeName() { return "VehicleBase"; } } [CreateAssetMenu(fileName = "New Weather Definition", menuName = "DawnLib/Definitions/Weather Definition")] public class DuskWeatherDefinition : DuskContentDefinition { [field: SerializeField] public string WeatherName { get; private set; } [field: SerializeField] public GameObject TemporaryEffectObject { get; private set; } [field: SerializeField] public GameObject PermanentEffectObject { get; private set; } [field: SerializeField] public string SunAnimatorBool { get; private set; } [field: SerializeField] public TMP_ColorGradient TerminalColorGradient { get; private set; } [field: Space(10f)] [field: Header("Configs | Main")] [field: SerializeField] public int SpawnWeight { get; private set; } [field: SerializeField] public float ScrapValueMultiplier { get; private set; } [field: SerializeField] public float ScrapAmountMultiplier { get; private set; } [field: Header("Configs | Misc")] [field: SerializeField] public bool IsExclude { get; private set; } [field: SerializeField] public bool CreateExcludeConfig { get; private set; } [field: SerializeField] public string ExcludeOrIncludeList { get; private set; } [field: Header("Configs | Obsolete")] [field: Obsolete] [field: SerializeField] public Color TerminalColour { get; private set; } protected override string EntityNameReference => WeatherName; public override void Register(DuskMod mod) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Expected O, but got Unknown //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Expected O, but got Unknown //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Expected O, but got Unknown //IL_0198: 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_01aa: Expected O, but got Unknown //IL_01af: Expected O, but got Unknown //IL_01b1: Expected O, but got Unknown //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) base.Register(mod); GameObject val = null; if ((Object)(object)TemporaryEffectObject != (Object)null) { val = Object.Instantiate(TemporaryEffectObject); if ((Object)(object)val != (Object)null) { ((Object)val).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val); } } GameObject val2 = null; if ((Object)(object)PermanentEffectObject != (Object)null) { val2 = Object.Instantiate(PermanentEffectObject); if ((Object)(object)val2 != (Object)null) { ((Object)val2).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val2); } } WeatherEffect val3 = new WeatherEffect { name = WeatherName, effectObject = val, effectPermanentObject = val2 }; ImprovedWeatherEffect val4 = new ImprovedWeatherEffect(val3); val4.SunAnimatorBool = SunAnimatorBool; GameObject effectObject = val4.EffectObject; if (effectObject != null) { effectObject.SetActive(false); } GameObject worldObject = val4.WorldObject; if (worldObject != null) { worldObject.SetActive(false); } if ((Object)(object)TerminalColorGradient == (Object)null) { TerminalColorGradient = ScriptableObject.CreateInstance(); TerminalColorGradient.colorMode = (ColorMode)0; TerminalColorGradient.topLeft = (TerminalColorGradient.topRight = (TerminalColorGradient.bottomLeft = (TerminalColorGradient.bottomRight = TerminalColour))); } Weather val5 = new Weather(WeatherName, val4) { ColorGradient = TerminalColorGradient, Config = new RegistryWeatherConfig { DefaultWeight = new IntegerConfigHandler(SpawnWeight, true), ScrapValueMultiplier = new FloatConfigHandler(ScrapValueMultiplier, true), ScrapAmountMultiplier = new FloatConfigHandler(ScrapAmountMultiplier, true), FilteringOption = new BooleanConfigHandler(!IsExclude, CreateExcludeConfig), LevelFilters = new LevelListConfigHandler(ExcludeOrIncludeList, true) } }; WeatherManager.RegisterWeather(val5); HashSet hashSet = _tags.ToHashSet(); DawnWeatherEffectInfo val6 = new DawnWeatherEffectInfo(base.TypedKey, hashSet, val4.VanillaWeatherEffect, (IDataContainer)null); WeatherEffectExtensions.SetDawnInfo(val4.VanillaWeatherEffect, val6); ((Registry)(object)LethalContent.Weathers).Register(val6); } public override void TryNetworkRegisterAssets() { NetworkObject val = default(NetworkObject); if ((Object)(object)TemporaryEffectObject != (Object)null && TemporaryEffectObject.TryGetComponent(ref val)) { DawnLib.RegisterNetworkPrefab(TemporaryEffectObject); } if ((Object)(object)PermanentEffectObject != (Object)null && PermanentEffectObject.TryGetComponent(ref val)) { DawnLib.RegisterNetworkPrefab(PermanentEffectObject); } } } [Serializable] public class DuskWeatherReference : DuskContentReference { public DuskWeatherReference() { } public DuskWeatherReference(NamespacedKey key) : base(key) { } public override bool TryResolve(out DawnWeatherEffectInfo info) { return ((Registry)(object)LethalContent.Weathers).TryGetValue(base.TypedKey, ref info); } public override DawnWeatherEffectInfo Resolve() { return ((Registry)(object)LethalContent.Weathers)[base.TypedKey]; } } public class DuskMod { public const string PLUGIN_GUID = "com.github.teamxiaolan.dawnlib.dusk"; private static readonly List _allMods = new List(); internal List _configEntries = new List(); private readonly string _basePath; public static IReadOnlyList AllMods => _allMods.AsReadOnly(); public IReadOnlyList ConfigEntries => _configEntries.AsReadOnly(); public ConfigManager ConfigManager { get; } public ContentContainer Content { get; } public Assembly? Assembly { get; } public DuskModInformation ModInformation { get; set; } public ManualLogSource? Logger { get; set; } public BepInPlugin Plugin { get; } internal DuskMod(Assembly assembly, BaseUnityPlugin plugin, AssetBundle mainBundle, string basePath, ConfigManager configManager) : this(MetadataHelper.GetMetadata(((object)plugin).GetType()), mainBundle, basePath, configManager) { Assembly = assembly; ResolveCodeModInformation(assembly); } public static DuskMod RegisterMod(BaseUnityPlugin plugin, AssetBundle mainBundle) { ConfigManager configManager = new ConfigManager(plugin.Config); return new DuskMod(((object)plugin).GetType().Assembly, plugin, mainBundle, Path.GetDirectoryName(((object)plugin).GetType().Assembly.Location), configManager); } internal static DuskMod RegisterNoCodeMod(DuskModInformation modInfo, AssetBundle mainBundle, string basePath) { BepInPlugin val = modInfo.CreatePluginMetadata(); DebugLogSource dusk = Debuggers.Dusk; if (dusk != null) { dusk.Log((object)"Registering no-code mod!"); } ConfigManager configManager = new ConfigManager(Dusk.ConfigManager.GenerateConfigFile(val)); DuskMod duskMod = new DuskMod(val, mainBundle, basePath, configManager) { ModInformation = modInfo, Logger = Logger.CreateLogSource(val.GUID) }; new DefaultContentHandler(duskMod); if (DuskLethalConfigCompat.Enabled) { DuskLethalConfigCompat.CreateLethalConfigMod(duskMod); } return duskMod; } private void ResolveCodeModInformation(Assembly assembly) { ModInformation = ScriptableObject.CreateInstance(); string text = Path.GetFullPath(assembly.Location); DirectoryInfo parent = Directory.GetParent(text); while (parent != null && !string.Equals(parent.Name, "plugins", StringComparison.OrdinalIgnoreCase)) { text = parent.FullName; parent = Directory.GetParent(text); } if (text.EndsWith(".dll")) { return; } try { string iconPath = Directory.EnumerateFiles(text, "icon.png", SearchOption.AllDirectories).FirstOrDefault(); ModInformation.ModIcon = LoadIcon(iconPath); string path = Directory.EnumerateFiles(text, "manifest.json", SearchOption.AllDirectories).FirstOrDefault(); string text2 = File.ReadAllText(path); ThunderstoreManifest val = JsonConvert.DeserializeObject(text2); ModInformation.ModDescription = val.description; ModInformation.ModName = val.name; ModInformation.AuthorName = val.author_name; ModInformation.Version = val.version_number; ModInformation.ExtraDependencies = val.dependencies; ModInformation.WebsiteUrl = val.website_url; DebugLogSource dusk = Debuggers.Dusk; if (dusk != null) { dusk.Log((object)$"Mod information found: {ModInformation.ModName}, {ModInformation.ModDescription}, {(Object)(object)ModInformation.ModIcon != (Object)null}, {ModInformation.AuthorName}, {ModInformation.Version}, {ModInformation.ExtraDependencies}, {ModInformation.WebsiteUrl}"); } } catch (Exception ex) { DuskPlugin.Logger.LogWarning((object)("Failed to load mod information, likely from locally imported mod: " + ex.Message)); } } private Sprite? LoadIcon(string iconPath) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Expected O, but got Unknown //IL_003f: 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) if (iconPath == null) { return null; } Texture2D val = new Texture2D(256, 256); if (!ImageConversion.LoadImage(val, File.ReadAllBytes(iconPath), true)) { return null; } return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f); } internal DuskMod(BepInPlugin plugin, AssetBundle mainBundle, string basePath, ConfigManager configManager) { ConfigManager = configManager; _basePath = basePath; Plugin = plugin; ContentContainer[] array = mainBundle.LoadAllAssets(); if (array.Length == 0) { throw new NoContentDefinitionInBundle(mainBundle); } if (array.Length >= 2) { throw new MultipleContentDefinitionsInBundle(mainBundle); } Content = array[0]; _allMods.Add(this); } public string GetRelativePath(params string[] path) { return Path.Combine(_basePath, Path.Combine(path)); } public bool TryGetRelativeFile(out string fullPath, params string[] path) { fullPath = GetRelativePath(path); return File.Exists(fullPath); } public bool TryGetBundleDataFromName(string bundleName, [NotNullWhen(true)] out AssetBundleData? data) { string bundleName2 = bundleName; data = Content.assetBundles.FirstOrDefault((AssetBundleData it) => it.assetBundleName == bundleName2); return data != null; } public void RegisterContentHandlers() { if (Assembly == null) { DawnPlugin.Logger.LogWarning((object)("Tried to Register Content Handlers for " + Plugin.Name + " but it is a no-code DuskMod!")); return; } IEnumerable enumerable = from x in Enumerable.ThenBy(from x in AssemblyExtensions.GetLoadableTypes(Assembly) where !x.IsNested && x.BaseType != null && x.BaseType.IsGenericType && x.BaseType.GetGenericTypeDefinition() == typeof(ContentHandler<>) select x into t select new { Type = t, Order = (t.GetCustomAttribute(inherit: false)?.Order ?? 0) } into x orderby x.Order descending select x, x => x.Type.FullName, StringComparer.Ordinal) select x.Type; foreach (Type item in enumerable) { item.GetConstructor(new Type[1] { typeof(DuskMod) }).Invoke(new object[1] { this }); } } } internal static class DuskModConstants { internal const string MenuName = "DawnLib"; internal const string Definitions = "DawnLib/Definitions"; internal const string Achievements = "DawnLib/Definitions/Achievements"; internal const string TerminalPredicates = "DawnLib/Terminal Predicates"; internal const string DuskPredicates = "DawnLib/Dusk Predicates"; internal const string PricingStrategies = "DawnLib/Pricing Strategies"; internal const string ProgressiveComponents = "DawnLib/Progressive"; internal const int PredicateOrder = -50; internal const int PricingStrategyOrder = -70; internal const int DuskModInfoOrder = -10; } public static class DuskModContent { public static Registry Achievements = new Registry(); public static Registry Vehicles = new Registry(); public static Registry EntityReplacements = new Registry(); } [Flags] public enum DateTimeFlags { Year = 1, Month = 2, Day = 4, Hour = 8, Minute = 0x10, Second = 0x20 } [CreateAssetMenu(menuName = "DawnLib/Dusk Predicates/Date Unlock Requirement", fileName = "New Date Predicate", order = -50)] public class DatePredicate : DuskPredicate { private NamespacedKey? _namespacedKey; [field: Header("Date Checks")] [field: SerializeField] public DateTimeFlags DateTimeFlags { get; private set; } [field: Header("Start Range Values")] [field: SerializeField] public DawnDateTime DawnStartDateTime { get; private set; } [field: Header("End Range Values")] [field: SerializeField] public DawnDateTime DawnEndDateTime { get; private set; } public override bool Evaluate() { if (_namespacedKey == null) { return true; } int year = DateTime.Now.Year; int month = DateTime.Now.Month; int day = DateTime.Now.Day; int hour = DateTime.Now.Hour; int minute = DateTime.Now.Minute; int second = DateTime.Now.Second; DateTime dateTime = new DateTime(DawnStartDateTime.Year, DawnStartDateTime.Month, DawnStartDateTime.Day, DawnStartDateTime.Hour, DawnStartDateTime.Minute, DawnStartDateTime.Second); DateTime dateTime2 = new DateTime(DawnEndDateTime.Year, DawnEndDateTime.Month, DawnEndDateTime.Day, DawnEndDateTime.Hour, DawnEndDateTime.Minute, DawnEndDateTime.Second); if (dateTime2 < dateTime) { DateTime dateTime3 = dateTime2; dateTime2 = dateTime; dateTime = dateTime3; } if (!DateTimeFlags.HasFlag(DateTimeFlags.Year)) { year = dateTime.Year; } if (!DateTimeFlags.HasFlag(DateTimeFlags.Month)) { month = dateTime.Month; } if (!DateTimeFlags.HasFlag(DateTimeFlags.Day)) { day = dateTime.Day; } if (!DateTimeFlags.HasFlag(DateTimeFlags.Hour)) { hour = dateTime.Hour; } if (!DateTimeFlags.HasFlag(DateTimeFlags.Minute)) { minute = dateTime.Minute; } if (!DateTimeFlags.HasFlag(DateTimeFlags.Second)) { second = dateTime.Second; } DateTime dateTime4 = new DateTime(year, month, day, hour, minute, second); DebugLogSource entityReplacements = Debuggers.EntityReplacements; if (entityReplacements != null) { entityReplacements.Log((object)$"datetime compared to start: {dateTime4.CompareTo(dateTime)}, compared to end: {dateTime4.CompareTo(dateTime2)}"); } if (dateTime4 >= dateTime) { return dateTime4 <= dateTime2; } return false; } public override void Register(NamespacedKey namespacedKey) { _namespacedKey = namespacedKey; } } [Serializable] public class DawnDateTime { [field: SerializeField] [field: Range(2025f, 2050f)] public int Year { get; private set; } [field: SerializeField] [field: Range(1f, 12f)] public int Month { get; private set; } [field: SerializeField] [field: Range(1f, 31f)] public int Day { get; private set; } [field: SerializeField] [field: Range(0f, 23f)] public int Hour { get; private set; } [field: SerializeField] [field: Range(0f, 59f)] public int Minute { get; private set; } [field: SerializeField] [field: Range(0f, 59f)] public int Second { get; private set; } } public abstract class DuskPredicate : ScriptableObject, IPredicate { public abstract void Register(NamespacedKey namespacedKey); public abstract bool Evaluate(); } [CreateAssetMenu(menuName = "DawnLib/Dusk Predicates/Predicate Collection", fileName = "New Predicate Collections", order = -50)] public class PredicateCollection : DuskPredicate { [SerializeField] private List _predicates; [SerializeField] private LogicOperation _operation; public override void Register(NamespacedKey namespacedKey) { foreach (DuskPredicate predicate in _predicates) { predicate.Register(namespacedKey); } } public override bool Evaluate() { foreach (DuskPredicate predicate in _predicates) { bool flag = predicate.Evaluate(); if (_operation == LogicOperation.And && !flag) { return false; } if (_operation == LogicOperation.Or && flag) { return true; } } return false; } } public class MultipleContentDefinitionsInBundle : BundleException { public MultipleContentDefinitionsInBundle(AssetBundle bundle) : base(bundle, "Main bundle contained too many ContentContainers!") { } } public class NoContentDefinitionInBundle : BundleException { public NoContentDefinitionInBundle(AssetBundle bundle) : base(bundle, "Main bundle did not contain a ContentContainer!") { } } public enum LogicOperation { And, Or } public enum MathOperation { Additive, Subtractive, Multiplicative, Divisive } public enum ComparisonOperation { Equal, NotEqual, Greater, Less, GreaterOrEqual, LessOrEqual } [CreateAssetMenu(menuName = "DawnLib/Pricing Strategies/Daily Pricing Strategy", fileName = "New Daily Pricing", order = -70)] public class DailyPricingStrategy : DuskPricingStrategy { [SerializeField] [Tooltip("The x axis represents the progress to the deadline. So 1 is company day.")] private AnimationCurve _priceCurve = AnimationCurve.Linear(0f, 100f, 1f, 20f); public override void Register(NamespacedKey id) { } public override int Provide() { float num = TimeOfDayRefs.Instance.totalTime * 4f; float num2 = TimeOfDayRefs.Instance.timeUntilDeadline / num; return (int)_priceCurve.Evaluate(1f - num2); } } public abstract class DuskPricingStrategy : ScriptableObject, IProvider { public abstract void Register(NamespacedKey id); public abstract int Provide(); } [CreateAssetMenu(menuName = "DawnLib/Terminal Predicates/Achievement Unlock Requirement", fileName = "New Achievement Predicate", order = -50)] public class AchievementPredicate : DuskTerminalPredicate { [SerializeField] private string _lockedName = ""; [SerializeField] private TerminalNode _failNode; [SerializeReference] private DuskAchievementReference _achievement; private NamespacedKey _namespacedKey; public override void Register(NamespacedKey namespacedKey) { _namespacedKey = namespacedKey; } public override TerminalPurchaseResult CanPurchase() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) if (!_achievement.TryResolve(out DuskAchievementDefinition info)) { DawnPlugin.Logger.LogError((object)$"Failed to resolve the achievement definition for '{_achievement.Key}'. Unlock Requirement NamespacedKey = {_namespacedKey}."); return (TerminalPurchaseResult)(object)TerminalPurchaseResult.Fail(new TerminalNodeBuilder("AchievementPredicateInternalFail").SetDisplayText("Couldn't find the achievement required, check the logs for more information\n\n").SetClearPreviousText(true).Build()); } if (info.Completed) { return (TerminalPurchaseResult)(object)TerminalPurchaseResult.Success(); } if (Object.op_Implicit((Object)(object)_failNode)) { return (TerminalPurchaseResult)(object)TerminalPurchaseResult.Fail(_failNode).SetOverrideName(_lockedName); } return (TerminalPurchaseResult)(object)TerminalPurchaseResult.Hidden(); } } public abstract class DuskTerminalPredicate : ScriptableObject, ITerminalPurchasePredicate { public abstract void Register(NamespacedKey namespacedKey); public abstract TerminalPurchaseResult CanPurchase(); } [Serializable] public class ProgressiveStates { public bool IsUnlocked { get; internal set; } public bool IsHidden { get; internal set; } public ProgressiveStates(bool isUnlocked, bool isHidden) { IsUnlocked = isUnlocked; IsHidden = isHidden; base..ctor(); } } [CreateAssetMenu(menuName = "DawnLib/Terminal Predicates/Progressive Unlockable", fileName = "New Progressive Predicate", order = -50)] public class ProgressivePredicate : DuskTerminalPredicate { [SerializeField] private bool _isHidden; [SerializeField] private bool _isLocked; [SerializeField] private string _lockedName = "???"; [SerializeField] private TerminalNode _failNode; private NamespacedKey _namespacedKey; internal static List AllProgressiveItems = new List(); public ProgressiveStates ProgressiveStates { get; private set; } internal ulong NetworkID => _namespacedKey.NetworkID; public override void Register(NamespacedKey namespacedKey) { if (!Object.op_Implicit((Object)(object)_failNode)) { _failNode = CreateDefaultProgressiveDenyNode(); } _namespacedKey = namespacedKey; ProgressiveStates = new ProgressiveStates(!_isLocked, _isHidden); AllProgressiveItems.Add(this); DebugLogSource progressive = Debuggers.Progressive; if (progressive != null) { progressive.Log((object)$"Registering unlockable: {_namespacedKey}."); } } public override TerminalPurchaseResult CanPurchase() { if (ProgressiveStates.IsHidden && ProgressiveStates.IsUnlocked) { return (TerminalPurchaseResult)(object)TerminalPurchaseResult.Hidden().SetFailure(false); } if (ProgressiveStates.IsHidden) { return (TerminalPurchaseResult)(object)TerminalPurchaseResult.Hidden().SetFailure(true).SetFailNode(_failNode); } if (!ProgressiveStates.IsUnlocked && _isLocked) { return (TerminalPurchaseResult)(object)TerminalPurchaseResult.Fail(_failNode).SetOverrideName(_lockedName); } return (TerminalPurchaseResult)(object)TerminalPurchaseResult.Success(); } public void Unlock(HUDDisplayTip? displayTip = null) { if (!ProgressiveStates.IsUnlocked) { ProgressiveStates.IsUnlocked = true; if (displayTip != null) { HUDManagerExtensions.DisplayTip(HUDManager.Instance, displayTip); } } } public void Unhide() { ProgressiveStates.IsHidden = false; } public void Load(IDataContainer dataContainer) { if (dataContainer.Has(_namespacedKey)) { ProgressiveStates.IsUnlocked = dataContainer.GetOrSetDefault(_namespacedKey, !_isLocked); DebugLogSource progressive = Debuggers.Progressive; if (progressive != null) { progressive.Log((object)$"Used older save data for unlockable: {_namespacedKey} for unlocked: {ProgressiveStates.IsUnlocked} with saveID: {_namespacedKey}"); } return; } ProgressiveStates = dataContainer.GetOrSetDefault(_namespacedKey, new ProgressiveStates(!_isLocked, _isHidden)); DebugLogSource progressive2 = Debuggers.Progressive; if (progressive2 != null) { progressive2.Log((object)$"IsUnlocked: {ProgressiveStates.IsUnlocked}, IsHidden: {ProgressiveStates.IsHidden}, Loaded unlockable: {_namespacedKey} with saveID: {_namespacedKey}"); } } public void Save(IDataContainer dataContainer) { DebugLogSource progressive = Debuggers.Progressive; if (progressive != null) { progressive.Log((object)$"Saving unlockable: {_namespacedKey} that is unlocked: {ProgressiveStates.IsUnlocked} with saveID: {_namespacedKey}"); } dataContainer.Set(_namespacedKey, ProgressiveStates); } internal static void LoadAll(IDataContainer dataContainer) { DebugLogSource progressive = Debuggers.Progressive; if (progressive != null) { progressive.Log((object)"Loading all unlockables"); } foreach (ProgressivePredicate allProgressiveItem in AllProgressiveItems) { allProgressiveItem.Load(dataContainer); } } internal static void SaveAll(IDataContainer dataContainer) { DebugLogSource progressive = Debuggers.Progressive; if (progressive != null) { progressive.Log((object)"Saving all unlockables"); } foreach (ProgressivePredicate allProgressiveItem in AllProgressiveItems) { allProgressiveItem.Save(dataContainer); } } internal void SetFromServer(bool isUnlocked, bool isHidden) { DebugLogSource progressive = Debuggers.Progressive; if (progressive != null) { progressive.Log((object)$"{_namespacedKey} is being set from the server; unlocked = {isUnlocked}"); } ProgressiveStates.IsUnlocked = isUnlocked; ProgressiveStates.IsHidden = isHidden; } private static TerminalNode CreateDefaultProgressiveDenyNode() { TerminalNode val = ScriptableObject.CreateInstance(); val.displayText = "Ship Upgrade or Decor is not unlocked"; return val; } } [CreateAssetMenu(menuName = "DawnLib/Terminal Predicates/Terminal Predicate Collection", fileName = "New Terminal Predicate Collection", order = -50)] public class TerminalPredicateCollection : DuskTerminalPredicate { [SerializeField] private List _predicates; [SerializeField] private LogicOperation _operation; public override void Register(NamespacedKey namespacedKey) { foreach (DuskTerminalPredicate predicate in _predicates) { predicate.Register(namespacedKey); } } public override TerminalPurchaseResult CanPurchase() { foreach (DuskTerminalPredicate predicate in _predicates) { TerminalPurchaseResult val = predicate.CanPurchase(); if (_operation == LogicOperation.And && !(val is SuccessPurchaseResult)) { return val; } if (_operation == LogicOperation.Or && val is SuccessPurchaseResult) { return val; } } return (TerminalPurchaseResult)(object)TerminalPurchaseResult.Success(); } } public static class DuskKeys { public const string Namespace = "dawn_lib"; public static readonly NamespacedKey EntityReplacements = NamespacedKey.From("dawn_lib", "entity_replacements"); } [BepInPlugin("com.github.teamxiaolan.dawnlib.dusk", "DawnLib.DuskMod", "0.9.21")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class DuskPlugin : BaseUnityPlugin { internal class DawnLibMainNetworkAssets : AssetBundleLoader { [LoadFromBundle("DawnLibNetworker.prefab")] public GameObject NetworkerPrefab { get; private set; } public DawnLibMainNetworkAssets(AssetBundle bundle) : base(bundle) { } } internal class DuskMainAssets : AssetBundleLoader { [LoadFromBundle("AchievementUICanvas.prefab")] public GameObject AchievementUICanvasPrefab { get; private set; } [LoadFromBundle("AchievementGetUICanvas.prefab")] public GameObject AchievementGetUICanvasPrefab { get; private set; } public DuskMainAssets(AssetBundle bundle) : base(bundle) { } } internal class DawnLibMainVanillaAssets : AssetBundleLoader { [LoadFromBundle("DawnLibRouteProgressUI.prefab")] public GameObject RouteProgressUIPrefab { get; private set; } public DawnLibMainVanillaAssets(AssetBundle bundle) : base(bundle) { } } internal static ManualLogSource Logger { get; private set; } internal static PersistentDataContainer PersistentData { get; private set; } internal static DuskMainAssets DuskMain { get; private set; } internal static DawnLibMainNetworkAssets DawnLibMainNetwork { get; private set; } internal static DawnLibMainVanillaAssets DawnLibMainVanilla { get; private set; } internal static DuskPlugin Instance { get; private set; } private void Awake() { Instance = this; Logger = ((BaseUnityPlugin)this).Logger; PersistentData = BepInPluginExtensions.GetPersistentDataContainer((BaseUnityPlugin)(object)this); Logger.LogInfo((object)"Doing patches"); AchievementRegistrationPatch.Init(); EntityReplacementRegistrationPatch.Init(); DuskSaveIntegration.Init(); CommitKeyToSave.Init(); if (!DawnConfig.VanillaCompatibility.Value) { NetworkerPatch.Init(); VehicleRegistrationPatch.Init(); } Logger.LogInfo((object)"Loading assets"); if (!DawnConfig.VanillaCompatibility.Value) { DawnLibMainNetwork = new DawnLibMainNetworkAssets(AssetBundleUtils.LoadBundle(Assembly.GetExecutingAssembly(), "dawnlibmainnetwork")); } DuskMain = new DuskMainAssets(AssetBundleUtils.LoadBundle(Assembly.GetExecutingAssembly(), "dusklibmain")); DawnLibMainVanilla = new DawnLibMainVanillaAssets(AssetBundleUtils.LoadBundle(Assembly.GetExecutingAssembly(), "dawnlibmainvanilla")); MoonRegistrationHandler.RouteProgressUIPrefab = DawnLibMainVanilla.RouteProgressUIPrefab; Logger.LogInfo((object)"Registering auto DuskMods!"); AutoDuskModHandler.AutoRegisterMods(); Logger.LogInfo((object)"com.github.teamxiaolan.dawnlib.dusk v0.9.21 has loaded!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.github.teamxiaolan.dawnlib.dusk"; public const string PLUGIN_NAME = "DawnLib.DuskMod"; public const string PLUGIN_VERSION = "0.9.21"; } } namespace Dusk.Utils { [Serializable] public class DungeonFlowReference { [Serializable] public class ArchetypeTileSetMapping { [SerializeField] private string _archetypeName; [SerializeField] private string[] _tileSetNames = Array.Empty(); public string ArchetypeName => _archetypeName; public string[] TileSetNames => _tileSetNames; } [SerializeField] private string _flowAssetName; [SerializeField] private string _bundleName; [SerializeField] private string[] _dungeonArchetypeNames = Array.Empty(); [SerializeField] private string[] _tileSetNames = Array.Empty(); [SerializeField] private ArchetypeTileSetMapping[] _archetypeTileSets = Array.Empty(); public string FlowAssetName => _flowAssetName; public string[] DungeonArchetypeNames => _dungeonArchetypeNames; public string[] TileSetNames => _tileSetNames; public ArchetypeTileSetMapping[] ArchetypeTileSets => _archetypeTileSets; public string BundleName => _bundleName; public static implicit operator string(DungeonFlowReference reference) { return reference.FlowAssetName; } public bool TryGetTileSetsForArchetype(string archetypeName, out string[] tileSets) { ArchetypeTileSetMapping[] archetypeTileSets = _archetypeTileSets; foreach (ArchetypeTileSetMapping archetypeTileSetMapping in archetypeTileSets) { if (string.Equals(archetypeTileSetMapping.ArchetypeName, archetypeName, StringComparison.Ordinal)) { tileSets = archetypeTileSetMapping.TileSetNames; return true; } } tileSets = Array.Empty(); return false; } } internal static class MenuUtils { internal static void InjectMenu(Transform mainButtonsTransform, GameObject quitButton) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) GameObject quitButton2 = quitButton; GameObject clonedButton = Object.Instantiate(quitButton2, mainButtonsTransform); Button component = clonedButton.GetComponent