Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of ColossusMainStages v1.0.2
ColossusMainStages.dll
Decompiled 6 months agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HG; using Microsoft.CodeAnalysis; using On.RoR2; using RoR2; using UnityEngine; using UnityEngine.AddressableAssets; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ColossusMainStages")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ColossusMainStages")] [assembly: AssemblyTitle("ColossusMainStages")] [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 ColossusMainStages { [BepInPlugin("Jeffdev.ColossusMainStages", "ColossusMainStages", "1.0.2")] public class ColossusMainStages : BaseUnityPlugin { public ConfigEntry<int> villageStage; public ConfigEntry<int> templeStage; public ConfigEntry<int> habitatStage; public ConfigEntry<int> lakesStage; public ConfigEntry<bool> nightStageAsAlt; public const string PluginGUID = "Jeffdev.ColossusMainStages"; public const string PluginAuthor = "Jeffdev"; public const string PluginName = "ColossusMainStages"; public const string PluginVersion = "1.0.2"; public static ColossusMainStages instance; public static ChangeStages changer; public void Awake() { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown Log.Init(((BaseUnityPlugin)this).Logger); instance = this; villageStage = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Shattered Abodes Stage", 1, "Which stage Shattered Abodes/Disturbed Impact should be(1-5)"); templeStage = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Reformed Altar Stage", 2, "Which regular stage Reformed Altar should be(1-5 for addition)(0 for no addition)"); habitatStage = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Treeborn Colony Stage", 3, "Which regular stage Treeborn Colony/Goldan Dieback should be(1-5 for addition)(0 for no addition)"); lakesStage = ((BaseUnityPlugin)this).Config.Bind<int>("General", "Verdant Falls Stage", 1, "Which stage Verdant/Vicious Falls should be(1-5)"); changer = new ChangeStages(); changer.Init(); changer.EditStages(); Run.Start += new hook_Start(Run_Start); } private void Run_Start(orig_Start orig, Run self) { changer.EditStages(); orig.Invoke(self); } } public class StageVars { public SceneDef def { get; set; } public SceneEntry sceneEntry { get; set; } public StageVars(SceneDef newDef) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) def = newDef; SceneEntry val = new SceneEntry { sceneDef = def }; ((SceneEntry)(ref val)).weight = 1f; val.weightMinusOne = 0f; sceneEntry = val; } } public class ChangeStages { private static SceneCollection[] sceneCollections = (SceneCollection[])(object)new SceneCollection[5]; private static SceneCollection[] loopSceneCollections = (SceneCollection[])(object)new SceneCollection[5]; private static StageVars temple = new StageVars(Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/lemuriantemple/lemuriantemple.asset").WaitForCompletion()); private static StageVars habitat = new StageVars(Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/habitat/habitat.asset").WaitForCompletion()); private static StageVars habitatnight = new StageVars(Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/habitatfall/habitatfall.asset").WaitForCompletion()); private static StageVars village = new StageVars(Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/village/village.asset").WaitForCompletion()); private static StageVars villagenight = new StageVars(Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/villagenight/villagenight.asset").WaitForCompletion()); private static StageVars lakes = new StageVars(Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/lakes/lakes.asset").WaitForCompletion()); private static StageVars lakesnight = new StageVars(Addressables.LoadAssetAsync<SceneDef>((object)"RoR2/DLC2/lakesnight/lakesnight.asset").WaitForCompletion()); private void ChangeStageInternal(int stageNum, StageVars dayVar) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_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) dayVar.def.stageOrder = stageNum; ref SceneEntry[] sceneEntries = ref sceneCollections[stageNum - 1]._sceneEntries; SceneEntry sceneEntry = dayVar.sceneEntry; ArrayUtils.ArrayAppend<SceneEntry>(ref sceneEntries, ref sceneEntry); ref SceneEntry[] sceneEntries2 = ref loopSceneCollections[stageNum - 1]._sceneEntries; sceneEntry = dayVar.sceneEntry; ArrayUtils.ArrayAppend<SceneEntry>(ref sceneEntries2, ref sceneEntry); if (stageNum == 5) { dayVar.def.destinationsGroup = sceneCollections[0]; dayVar.def.loopedDestinationsGroup = loopSceneCollections[0]; } else { dayVar.def.destinationsGroup = sceneCollections[stageNum]; dayVar.def.loopedDestinationsGroup = loopSceneCollections[stageNum]; } } private void ChangeStageInternal(int stageNum, StageVars dayVar, StageVars nightVar) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) dayVar.def.stageOrder = stageNum; nightVar.def.stageOrder = stageNum; ref SceneEntry[] sceneEntries = ref sceneCollections[stageNum - 1]._sceneEntries; SceneEntry sceneEntry = dayVar.sceneEntry; ArrayUtils.ArrayAppend<SceneEntry>(ref sceneEntries, ref sceneEntry); ref SceneEntry[] sceneEntries2 = ref loopSceneCollections[stageNum - 1]._sceneEntries; sceneEntry = nightVar.sceneEntry; ArrayUtils.ArrayAppend<SceneEntry>(ref sceneEntries2, ref sceneEntry); if (stageNum == 5) { dayVar.def.destinationsGroup = loopSceneCollections[0]; nightVar.def.destinationsGroup = sceneCollections[0]; dayVar.def.loopedDestinationsGroup = loopSceneCollections[0]; nightVar.def.loopedDestinationsGroup = sceneCollections[0]; } else { dayVar.def.destinationsGroup = sceneCollections[stageNum]; nightVar.def.destinationsGroup = sceneCollections[stageNum]; dayVar.def.loopedDestinationsGroup = loopSceneCollections[stageNum]; nightVar.def.loopedDestinationsGroup = loopSceneCollections[stageNum]; } } private void ChangeStage(int stageNum, StageVars dayVar) { if (stageNum >= 0 && stageNum <= 5) { ChangeStageInternal(stageNum, dayVar); } } private void ChangeStage(int stageNum, StageVars dayVar, StageVars nightVars) { if (stageNum >= 0 && stageNum <= 5) { ChangeStageInternal(stageNum, dayVar, nightVars); } } public void Init() { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < 5; i++) { string text = "RoR2/Base/SceneGroups/sgStage" + (i + 1) + ".asset"; string text2 = "RoR2/Base/SceneGroups/loopSgStage" + (i + 1) + ".asset"; sceneCollections[i] = Addressables.LoadAssetAsync<SceneCollection>((object)text).WaitForCompletion(); loopSceneCollections[i] = Addressables.LoadAssetAsync<SceneCollection>((object)text2).WaitForCompletion(); } } private void PurgeStages(StageVars stage) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) SceneCollection[] array = sceneCollections; foreach (SceneCollection val in array) { for (int j = 0; j < val._sceneEntries.Length; j++) { if ((Object)(object)((SceneEntry)val.sceneEntries[j]).sceneDef == (Object)(object)stage.def) { ArrayUtils.ArrayRemoveAtAndResize<SceneEntry>(ref val._sceneEntries, j, 1); break; } } } array = loopSceneCollections; foreach (SceneCollection val2 in array) { for (int k = 0; k < val2._sceneEntries.Length; k++) { if ((Object)(object)((SceneEntry)val2.sceneEntries[k]).sceneDef == (Object)(object)stage.def) { ArrayUtils.ArrayRemoveAtAndResize<SceneEntry>(ref val2._sceneEntries, k, 1); break; } } } } public void EditStages() { PurgeStages(village); PurgeStages(villagenight); PurgeStages(temple); PurgeStages(habitat); PurgeStages(habitatnight); PurgeStages(lakes); PurgeStages(lakesnight); ChangeStage(ColossusMainStages.instance.lakesStage.Value, lakes, lakesnight); ChangeStage(ColossusMainStages.instance.villageStage.Value, village, villagenight); ChangeStage(ColossusMainStages.instance.templeStage.Value, temple); ChangeStage(ColossusMainStages.instance.habitatStage.Value, habitat, habitatnight); } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(data); } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } }