Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of WeightWrite v1.0.1
plugins/WeightWrite/WeightWrite.dll
Decompiled 6 months agousing System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Diagnostics; 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 BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HG; using Microsoft.CodeAnalysis; using R2API.Utils; using RiskOfOptions; using RiskOfOptions.OptionConfigs; using RiskOfOptions.Options; using RoR2; using RoR2BepInExPack.GameAssetPathsBetter; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.ResourceManagement.AsyncOperations; using WeightWrite.Config; using WeightWrite.ModCompatibility; using WeightWrite.Utilities.Extensions; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: NetworkCompatibility(/*Could not decode attribute arguments.*/)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: IgnoresAccessChecksTo("BepInEx")] [assembly: AssemblyCompany("WeightWrite")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+e48591ed7834ce239349fab4e7ae50a468deade5")] [assembly: AssemblyProduct("WeightWrite")] [assembly: AssemblyTitle("WeightWrite")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace WeightWrite { public sealed class ConfigurableSceneCollection { private readonly SceneCollection _sceneCollection; private readonly ConfigFile _config; public readonly string Name; private readonly List<ConfigEntry<float>> _weightConfigs; public readonly ReadOnlyCollection<ConfigEntry<float>> WeightConfigs; public unsafe ConfigurableSceneCollection(SceneCollection sceneCollection, string name, ConfigFile config) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) _sceneCollection = sceneCollection; _config = config; Name = name.FilterConfigKey(); _weightConfigs = new List<ConfigEntry<float>>(); WeightConfigs = new ReadOnlyCollection<ConfigEntry<float>>(_weightConfigs); if (Object.op_Implicit((Object)(object)_sceneCollection)) { for (int i = 0; i < _sceneCollection.sceneEntries.Length; i++) { createSceneConfig(Unsafe.Read<SceneEntry>((void*)_sceneCollection.sceneEntries[i])); } } } public ConfigurableSceneCollection(string sceneCollectionPath, string name, ConfigFile config) : this(Addressables.LoadAssetAsync<SceneCollection>((object)sceneCollectionPath).WaitForCompletion(), name, config) { }//IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) private static string getDefaultSceneConfigName(SceneDef sceneDef) { if (!Object.op_Implicit((Object)(object)sceneDef)) { return "Invalid Scene"; } string key = sceneDef.cachedName; if (Language.english.TokenIsRegistered(sceneDef.nameToken)) { key = Language.english.GetLocalizedStringByToken(sceneDef.nameToken); } key = key.FilterConfigKey(); if (string.IsNullOrWhiteSpace(key)) { key = "(Invalid Name)"; } return key; } private void createSceneConfig(SceneEntry entry) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Expected O, but got Unknown SceneDef sceneDef = entry.sceneDef; if (!Object.op_Implicit((Object)(object)sceneDef)) { return; } string text = getDefaultSceneConfigName(sceneDef); List<SceneDef> list = new List<SceneDef>(_sceneCollection.sceneEntries.Length); for (int i = 0; i < _sceneCollection.sceneEntries.Length; i++) { SceneDef sceneDef2 = ((SceneEntry)_sceneCollection.sceneEntries[i]).sceneDef; if ((Object)(object)sceneDef2 != (Object)(object)sceneDef) { string defaultSceneConfigName = getDefaultSceneConfigName(sceneDef2); if (string.Equals(text, defaultSceneConfigName)) { list.Add(sceneDef2); } } } if (list.Count > 0) { list.Add(sceneDef); list.Sort(delegate(SceneDef a, SceneDef b) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) SceneIndex sceneDefIndex = a.sceneDefIndex; return ((Enum)(SceneIndex)(ref sceneDefIndex)).CompareTo((object?)b.sceneDefIndex); }); int num = list.IndexOf(sceneDef); text += $" ({num + 1})"; } float weight = ((SceneEntry)(ref entry)).weight; ConfigEntry<float> weightConfig = _config.Bind<float>(Name, text + " Weight", weight, new ConfigDescription("How likely this stage should be in this group, set to 0 to remove completely", (AcceptableValueBase)(object)new AcceptableValueMin<float>(0f), Array.Empty<object>())); weightConfig.SettingChanged += delegate { setSceneWeight(sceneDef, weightConfig.Value); }; if (weightConfig.Value != weight) { setSceneWeight(sceneDef, weightConfig.Value); } _weightConfigs.Add(weightConfig); } private void setSceneWeight(SceneDef scene, float weight) { if (!Object.op_Implicit((Object)(object)scene)) { return; } for (int i = 0; i < _sceneCollection._sceneEntries.Length; i++) { ref SceneEntry reference = ref _sceneCollection._sceneEntries[i]; if ((Object)(object)reference.sceneDef == (Object)(object)scene) { ((SceneEntry)(ref reference)).weight = weight; return; } } Log.Warning($"Failed to find '{scene}' in {_sceneCollection}", "D:\\Git\\RoR2\\WeightWrite\\WeightWrite\\ConfigurableSceneCollection.cs", "setSceneWeight", 126); } } internal static class Log { private static readonly StringBuilder _sharedStringBuilder; private static readonly object _stringBuilderLock; private static readonly int _cachedCallerPathPrefixLength; private static ManualLogSource _logSource; static Log() { _sharedStringBuilder = new StringBuilder(256); _stringBuilderLock = new object(); _cachedCallerPathPrefixLength = getCallerPathPrefixLength("D:\\Git\\RoR2\\WeightWrite\\WeightWrite\\Log.cs"); static int getCallerPathPrefixLength([CallerFilePath] string callerPath = null) { int num = callerPath.LastIndexOf("WeightWrite\\"); if (num >= 0) { return num + "WeightWrite\\".Length; } Debug.LogError((object)"[WeightWrite] Logger failed to determine caller path prefix length"); return 0; } } internal static void Init(ManualLogSource logSource) { _logSource = logSource; } private static string buildCallerLogString(string callerPath, string callerMemberName, int callerLineNumber, object data) { lock (_stringBuilderLock) { return _sharedStringBuilder.Clear().Append(callerPath, _cachedCallerPathPrefixLength, callerPath.Length - _cachedCallerPathPrefixLength).Append(':') .Append(callerLineNumber) .Append(" (") .Append(callerMemberName) .Append("): ") .Append(data) .ToString(); } } [Conditional("DEBUG")] internal static void Debug(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogDebug((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] [Conditional("DEBUG")] internal static void Debug_NoCallerPrefix(object data) { _logSource.LogDebug(data); } internal static void Error(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogError((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Error_NoCallerPrefix(object data) { _logSource.LogError(data); } internal static void Fatal(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogFatal((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Fatal_NoCallerPrefix(object data) { _logSource.LogFatal(data); } internal static void Info(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogInfo((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Info_NoCallerPrefix(object data) { _logSource.LogInfo(data); } internal static void Message(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogMessage((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Message_NoCallerPrefix(object data) { _logSource.LogMessage(data); } internal static void Warning(object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { _logSource.LogWarning((object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void Warning_NoCallerPrefix(object data) { _logSource.LogWarning(data); } internal static void LogType(LogLevel level, object data, [CallerFilePath] string callerPath = "", [CallerMemberName] string callerMemberName = "", [CallerLineNumber] int callerLineNumber = -1) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) if ((level & 0x20) == 0) { _logSource.Log(level, (object)buildCallerLogString(callerPath, callerMemberName, callerLineNumber, data)); } } [MethodImpl(MethodImplOptions.AggressiveInlining)] internal static void LogType_NoCallerPrefix(LogLevel level, object data) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) if ((level & 0x20) == 0) { _logSource.Log(level, data); } } } [BepInPlugin("com.Gorakh.WeightWrite", "WeightWrite", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class WeightWritePlugin : BaseUnityPlugin { public const string PluginGUID = "com.Gorakh.WeightWrite"; public const string PluginAuthor = "Gorakh"; public const string PluginName = "WeightWrite"; public const string PluginVersion = "1.0.1"; private static WeightWritePlugin _instance; private readonly List<ConfigurableSceneCollection> _configurableSceneCollections = new List<ConfigurableSceneCollection>(); internal static WeightWritePlugin Instance => _instance; public ReadOnlyCollection<ConfigurableSceneCollection> ConfigurableSceneCollections { get; private set; } private void Awake() { Stopwatch stopwatch = Stopwatch.StartNew(); SingletonHelper.Assign<WeightWritePlugin>(ref _instance, this); Log.Init(((BaseUnityPlugin)this).Logger); ConfigurableSceneCollections = new ReadOnlyCollection<ConfigurableSceneCollection>(_configurableSceneCollections); RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(onLoad)); stopwatch.Stop(); Log.Message_NoCallerPrefix($"Initialized in {stopwatch.Elapsed.TotalMilliseconds:F0}ms"); } private void OnDestroy() { SingletonHelper.Unassign<WeightWritePlugin>(ref _instance, this); } private void onLoad() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //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_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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) //IL_0187: 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_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019b: 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_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_025a: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) SceneCollection[] array = (SceneCollection[])(object)new SceneCollection[5] { Addressables.LoadAssetAsync<SceneCollection>((object)RoR2_Base_SceneGroups.sgStage1_asset).WaitForCompletion(), Addressables.LoadAssetAsync<SceneCollection>((object)RoR2_Base_SceneGroups.sgStage2_asset).WaitForCompletion(), Addressables.LoadAssetAsync<SceneCollection>((object)RoR2_Base_SceneGroups.sgStage3_asset).WaitForCompletion(), Addressables.LoadAssetAsync<SceneCollection>((object)RoR2_Base_SceneGroups.sgStage4_asset).WaitForCompletion(), Addressables.LoadAssetAsync<SceneCollection>((object)RoR2_Base_SceneGroups.sgStage5_asset).WaitForCompletion() }; SceneCollection[] array2 = (SceneCollection[])(object)new SceneCollection[5] { Addressables.LoadAssetAsync<SceneCollection>((object)RoR2_Base_SceneGroups.loopSgStage1_asset).WaitForCompletion(), Addressables.LoadAssetAsync<SceneCollection>((object)RoR2_Base_SceneGroups.loopSgStage2_asset).WaitForCompletion(), Addressables.LoadAssetAsync<SceneCollection>((object)RoR2_Base_SceneGroups.loopSgStage3_asset).WaitForCompletion(), Addressables.LoadAssetAsync<SceneCollection>((object)RoR2_Base_SceneGroups.loopSgStage4_asset).WaitForCompletion(), Addressables.LoadAssetAsync<SceneCollection>((object)RoR2_Base_SceneGroups.loopSgStage5_asset).WaitForCompletion() }; tryAddSceneByName(array[1], "lemuriantemple"); tryAddSceneByName(array[2], "habitat"); tryAddSceneByName(array2[2], "habitatfall"); for (int i = 0; i < array.Length; i++) { SceneCollection val = array[i]; SceneCollection val2 = array2[i]; List<SceneEntry> list = new List<SceneEntry>(); List<SceneEntry> list2 = new List<SceneEntry>(); Enumerator<SceneEntry> enumerator = val.sceneEntries.GetEnumerator(); SceneEntry item; try { while (enumerator.MoveNext()) { SceneEntry current = enumerator.Current; if (!containsScene(val2, current.sceneDef)) { item = current; ((SceneEntry)(ref item)).weight = 0f; list2.Add(item); } } } finally { ((IDisposable)enumerator).Dispose(); } enumerator = val2.sceneEntries.GetEnumerator(); try { while (enumerator.MoveNext()) { SceneEntry current2 = enumerator.Current; if (!containsScene(val, current2.sceneDef)) { item = current2; ((SceneEntry)(ref item)).weight = 0f; list.Add(item); } } } finally { ((IDisposable)enumerator).Dispose(); } SceneCollection val3; SceneEntry[] array3; List<SceneEntry> list3; SceneEntry[] sceneEntries; ReadOnlySpan<SceneEntry> readOnlySpan; int num; if (list.Count > 0) { val3 = val; sceneEntries = val._sceneEntries; list3 = list; num = 0; array3 = (SceneEntry[])(object)new SceneEntry[sceneEntries.Length + list3.Count]; readOnlySpan = new ReadOnlySpan<SceneEntry>(sceneEntries); readOnlySpan.CopyTo(new Span<SceneEntry>(array3).Slice(num, readOnlySpan.Length)); num += readOnlySpan.Length; foreach (SceneEntry item2 in list3) { item = (array3[num] = item2); num++; } val3._sceneEntries = array3; } if (list2.Count <= 0) { continue; } val3 = val2; array3 = val2._sceneEntries; list3 = list2; num = 0; sceneEntries = (SceneEntry[])(object)new SceneEntry[array3.Length + list3.Count]; readOnlySpan = new ReadOnlySpan<SceneEntry>(array3); readOnlySpan.CopyTo(new Span<SceneEntry>(sceneEntries).Slice(num, readOnlySpan.Length)); num += readOnlySpan.Length; foreach (SceneEntry item3 in list3) { item = (sceneEntries[num] = item3); num++; } val3._sceneEntries = sceneEntries; } ((BaseUnityPlugin)this).Config.SaveOnConfigSet = false; ListUtils.EnsureCapacity<ConfigurableSceneCollection>(_configurableSceneCollections, array.Length + array2.Length); for (int j = 0; j < array.Length; j++) { _configurableSceneCollections.Add(new ConfigurableSceneCollection(array[j], $"Stage {j + 1}", ((BaseUnityPlugin)this).Config)); } for (int k = 0; k < array2.Length; k++) { _configurableSceneCollections.Add(new ConfigurableSceneCollection(array2[k], $"Stage {k + 1} (Loop)", ((BaseUnityPlugin)this).Config)); } ((BaseUnityPlugin)this).Config.SaveOnConfigSet = true; ((BaseUnityPlugin)this).Config.Save(); if (RiskOfOptionsCompat.Enabled) { RiskOfOptionsCompat.AddOptions(); } RoR2Application.onLoad = (Action)Delegate.Remove(RoR2Application.onLoad, new Action(onLoad)); static bool containsScene(SceneCollection sceneCollection, SceneDef sceneDef) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) Enumerator<SceneEntry> enumerator3 = sceneCollection.sceneEntries.GetEnumerator(); try { while (enumerator3.MoveNext()) { if ((Object)(object)enumerator3.Current.sceneDef == (Object)(object)sceneDef) { return true; } } } finally { ((IDisposable)enumerator3).Dispose(); } return false; } static void tryAddScene(SceneCollection sceneCollection, SceneIndex sceneIndex) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) SceneDef sceneDef2 = SceneCatalog.GetSceneDef(sceneIndex); if (!Object.op_Implicit((Object)(object)sceneDef2)) { Log.Error("Null scenedef", "D:\\Git\\RoR2\\WeightWrite\\WeightWrite\\WeightWritePlugin.cs", "onLoad", 83); } else if (!containsScene(sceneCollection, sceneDef2)) { ref SceneEntry[] sceneEntries2 = ref sceneCollection._sceneEntries; SceneEntry val4 = new SceneEntry { sceneDef = sceneDef2 }; ((SceneEntry)(ref val4)).weight = 0f; ArrayUtils.ArrayAppend<SceneEntry>(ref sceneEntries2, ref val4); } } static void tryAddSceneByName(SceneCollection sceneCollection, string sceneName) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Invalid comparison between Unknown and I4 //IL_002e: Unknown result type (might be due to invalid IL or missing references) SceneIndex val5 = SceneCatalog.FindSceneIndex(sceneName); if ((int)val5 == -1) { Log.Error("Failed to find scene '" + sceneName + "'", "D:\\Git\\RoR2\\WeightWrite\\WeightWrite\\WeightWritePlugin.cs", "onLoad", 102); } else { tryAddScene(sceneCollection, val5); } } } } } namespace WeightWrite.Utilities.Extensions { public static class AssetLoadExtensions { public static void CallOnSuccess<T>(this AsyncOperationHandle<T> handle, Action<T> onSuccess) { handle.Completed += delegate(AsyncOperationHandle<T> handle) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)handle.Status == 2) { Log.Error("Failed to load asset '" + handle.LocationName + "'", "D:\\Git\\RoR2\\WeightWrite\\WeightWrite\\Utilities\\Extensions\\AssetLoadExtensions.cs", "CallOnSuccess", 18); } else { onSuccess(handle.Result); } }; } } public static class StringExtensions { public static string FilterChars(this string str, char[] invalidChars) { if (invalidChars == null || invalidChars.Length == 0) { return str; } if (str.IndexOfAny(invalidChars) == -1) { return str; } StringBuilder stringBuilder = StringBuilderPool.RentStringBuilder(); foreach (char value in str) { if (Array.IndexOf(invalidChars, value) == -1) { stringBuilder.Append(value); } } string result = stringBuilder.ToString(); StringBuilderPool.ReturnStringBuilder(stringBuilder); return result; } public static string FilterConfigKey(this string key) { return key.FilterChars(ConfigDefinition._invalidConfigChars); } } } namespace WeightWrite.ModCompatibility { internal static class RiskOfOptionsCompat { private static Sprite _iconSprite; private const string MOD_GUID = "com.Gorakh.WeightWrite"; private const string MOD_NAME = "WeightWrite"; public static bool Enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"); [MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)] public static void AddOptions() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_0072: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Expected O, but got Unknown ModSettingsManager.SetModDescription("Options for WeightWrite", "com.Gorakh.WeightWrite", "WeightWrite"); Sprite val = tryGetIcon(); if (Object.op_Implicit((Object)(object)val)) { ModSettingsManager.SetModIcon(val, "com.Gorakh.WeightWrite", "WeightWrite"); } foreach (ConfigurableSceneCollection configurableSceneCollection in WeightWritePlugin.Instance.ConfigurableSceneCollections) { foreach (ConfigEntry<float> weightConfig in configurableSceneCollection.WeightConfigs) { FloatFieldConfig val2 = new FloatFieldConfig(); ((NumericFieldConfig<float>)val2).Min = 0f; ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(weightConfig, val2), "com.Gorakh.WeightWrite", "WeightWrite"); } } } private static Sprite tryGetIcon() { if (!Object.op_Implicit((Object)(object)_iconSprite)) { _iconSprite = tryGenerateIcon(); if (!Object.op_Implicit((Object)(object)_iconSprite)) { Log.Warning("Failed to get config icon", "D:\\Git\\RoR2\\WeightWrite\\WeightWrite\\ModCompatibility\\RiskOfOptionsCompat.cs", "tryGetIcon", 54); } } return _iconSprite; } private static Sprite tryGenerateIcon() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) FileInfo fileInfo = findIconFileRecursive(new DirectoryInfo(Path.GetDirectoryName(((BaseUnityPlugin)WeightWritePlugin.Instance).Info.Location))); if (fileInfo == null) { return null; } byte[] array; try { array = File.ReadAllBytes(fileInfo.FullName); } catch (Exception arg) { Log.Error_NoCallerPrefix($"Failed to read icon file '{fileInfo.FullName}': {arg}"); return null; } Texture2D val = new Texture2D(256, 256); ((Object)val).name = "texWeightWriteIcon"; if (!ImageConversion.LoadImage(val, array)) { Log.Error("Failed to load icon into texture", "D:\\Git\\RoR2\\WeightWrite\\WeightWrite\\ModCompatibility\\RiskOfOptionsCompat.cs", "tryGenerateIcon", 83); return null; } Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); ((Object)obj).name = "WeightWriteIcon"; return obj; } private static FileInfo findIconFileRecursive(DirectoryInfo dir) { if (dir == null) { return null; } if (string.Equals(dir.FullName, Paths.PluginPath, StringComparison.OrdinalIgnoreCase)) { return null; } FileInfo fileInfo = dir.EnumerateFiles("icon.png", SearchOption.TopDirectoryOnly).FirstOrDefault(); if (fileInfo != null) { return fileInfo; } return findIconFileRecursive(dir.Parent); } } } namespace WeightWrite.Config { public sealed class AcceptableValueMin<T> : AcceptableValueBase where T : IComparable { public T MinValue { get; } public AcceptableValueMin(T minValue) : base(typeof(T)) { if (minValue == null) { throw new ArgumentNullException("minValue"); } MinValue = minValue; } public override object Clamp(object value) { if (MinValue.CompareTo(value) > 0) { return MinValue; } return value; } public override bool IsValid(object value) { return MinValue.CompareTo(value) <= 0; } public override string ToDescriptionString() { return $"# Acceptable value range: Greater than or equal to {MinValue}"; } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { internal IgnoresAccessChecksToAttribute(string assemblyName) { } } }