using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppRUMBLE.Combat.ShiftStones;
using Il2CppRUMBLE.Managers;
using Il2CppRUMBLE.Utilities;
using MelonLoader;
using NostalgicRing;
using RumbleModUI;
using RumbleModdingAPI;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(main), "Ring Swapper", "2.1.1", "UlvakSkillz", null)]
[assembly: MelonGame("Buckethead Entertainment", "RUMBLE")]
[assembly: MelonColor(255, 195, 0, 255)]
[assembly: MelonAuthorColor(255, 195, 0, 255)]
[assembly: VerifyLoaderVersion(0, 6, 2, true)]
[assembly: AssemblyTitle("RingSwapper")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RingSwapper")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("2fa22153-4207-4920-b248-5fd3db5f3f12")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NostalgicRing;
public class main : MelonMod
{
private string currentScene = "Loader";
private bool sceneChanged = false;
private int[] ringTypes = new int[3];
private int ringType = 0;
private bool gymInitRan = false;
private GameObject materialsGameObject;
private Material[] materials;
private Random random = new Random();
private UI UI = UI.instance;
private Mod RingSwapper = new Mod();
private Material[] originalRing;
private GameObject originalRingGameObject;
public override void OnLateInitializeMelon()
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Expected O, but got Unknown
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00fd: Expected O, but got Unknown
//IL_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: 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
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_025c: Expected O, but got Unknown
RingSwapper.ModName = "Ring Swapper";
RingSwapper.ModVersion = "2.1.1";
RingSwapper.SetFolder("RingSwapper");
RingSwapper.AddDescription("Description", "Description", "Changes the Rings in each Map", new Tags
{
IsSummary = true
});
RingSwapper.AddToList("Park", 14, "0 = Default | 1 = Dusty Metal" + Environment.NewLine + "2 = Deep Metal | 3 = Bright Metal" + Environment.NewLine + "4 = Yin and Yang | 5 = Rustic" + Environment.NewLine + "6 = Plant Life | 7 = Wooden" + Environment.NewLine + "8 = RumbleBee | 9 = Rumblekai" + Environment.NewLine + "10 = UlvakSkillz | 11 = Honey" + Environment.NewLine + "12 = Christmas | 13 = Rocky" + Environment.NewLine + "14 = Spaceship | 15 = Candy", new Tags());
RingSwapper.AddToList("Ring", 7, "0 = Default | 1 = Dusty Metal" + Environment.NewLine + "2 = Deep Metal | 3 = Bright Metal" + Environment.NewLine + "4 = Yin and Yang | 5 = Rustic" + Environment.NewLine + "6 = Plant Life | 7 = Wooden" + Environment.NewLine + "8 = RumbleBee | 9 = Rumblekai" + Environment.NewLine + "10 = UlvakSkillz | 11 = Honey" + Environment.NewLine + "12 = Christmas | 13 = Rocky" + Environment.NewLine + "14 = Spaceship | 15 = Candy", new Tags());
RingSwapper.AddToList("Pit", 3, "0 = Default | 1 = Dusty Metal" + Environment.NewLine + "2 = Deep Metal | 3 = Bright Metal" + Environment.NewLine + "4 = Yin and Yang | 5 = Rustic" + Environment.NewLine + "6 = Plant Life | 7 = Wooden" + Environment.NewLine + "8 = RumbleBee | 9 = Rumblekai" + Environment.NewLine + "10 = UlvakSkillz | 11 = Honey" + Environment.NewLine + "12 = Christmas | 13 = Rocky" + Environment.NewLine + "14 = Spaceship | 15 = Candy", new Tags());
RingSwapper.AddToList("Random", false, 0, "Changes Rings to Random Types", new Tags());
RingSwapper.GetFromFile();
ringTypes[0] = (int)RingSwapper.Settings[1].Value;
ringTypes[1] = (int)RingSwapper.Settings[2].Value;
ringTypes[2] = (int)RingSwapper.Settings[3].Value;
RingSwapper.ModSaved += Save;
UI.instance.UI_Initialized += UIInit;
Calls.onMapInitialized += MapChange;
}
public void UIInit()
{
UI.AddMod(RingSwapper);
}
public void Save()
{
ringTypes[0] = (int)RingSwapper.Settings[1].Value;
ringTypes[1] = (int)RingSwapper.Settings[2].Value;
ringTypes[2] = (int)RingSwapper.Settings[3].Value;
if (currentScene == "Map0")
{
SwitchRingType(RingBoarder.GetGameObject());
}
else if (currentScene == "Map1")
{
SwitchRingType(RingClamp.GetGameObject());
}
else if (currentScene == "Park")
{
SwitchRingType(Arena.GetGameObject());
}
}
private void MapChange()
{
try
{
if (currentScene != "Loader")
{
ringTypes[0] = (int)RingSwapper.Settings[1].Value;
ringTypes[1] = (int)RingSwapper.Settings[2].Value;
ringTypes[2] = (int)RingSwapper.Settings[3].Value;
if ((bool)RingSwapper.Settings[4].Value)
{
ringTypes[0] = random.Next(0, 15);
ringTypes[1] = random.Next(0, 15);
ringTypes[2] = random.Next(0, 15);
}
if (ringType < 0 || 15 < ringType)
{
ringType = 0;
}
MelonCoroutines.Start(WaitThenSwap());
}
}
catch
{
}
}
private IEnumerator WaitThenSwap()
{
if (currentScene == "Map0")
{
originalRing = (Material[])(object)new Material[((Il2CppArrayBase<Material>)(object)((Renderer)RingBoarder.GetGameObject().GetComponent<MeshRenderer>()).materials).Count];
for (int j = 0; j < ((Il2CppArrayBase<Material>)(object)((Renderer)RingBoarder.GetGameObject().GetComponent<MeshRenderer>()).materials).Count; j++)
{
originalRing[j] = new Material(((Il2CppArrayBase<Material>)(object)((Renderer)RingBoarder.GetGameObject().GetComponent<MeshRenderer>()).materials)[j]);
}
SwitchRingType(RingBoarder.GetGameObject());
}
else if (currentScene == "Map1")
{
originalRing = (Material[])(object)new Material[((Il2CppArrayBase<Material>)(object)((Renderer)RingClamp.GetGameObject().GetComponent<MeshRenderer>()).materials).Count];
for (int i = 0; i < ((Il2CppArrayBase<Material>)(object)((Renderer)RingClamp.GetGameObject().GetComponent<MeshRenderer>()).materials).Count; i++)
{
originalRing[i] = new Material(((Il2CppArrayBase<Material>)(object)((Renderer)RingClamp.GetGameObject().GetComponent<MeshRenderer>()).materials)[i]);
}
SwitchRingType(RingClamp.GetGameObject());
}
else if (currentScene == "Park")
{
yield return (object)new WaitForFixedUpdate();
yield return (object)new WaitForFixedUpdate();
SwitchRingType(Arena.GetGameObject());
}
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
currentScene = sceneName;
sceneChanged = true;
}
public override void OnFixedUpdate()
{
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Expected O, but got Unknown
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Expected O, but got Unknown
if (!sceneChanged)
{
return;
}
if (currentScene == "Gym")
{
if (!gymInitRan)
{
MelonCoroutines.Start(Init());
}
}
else if (currentScene == "Park")
{
GameObject val = GameObject.Find("________________SCENE_________________/Park/Main static group/Arenas/Gymarena/Arena");
originalRing = (Material[])(object)new Material[((Il2CppArrayBase<Material>)(object)((Renderer)val.GetComponent<MeshRenderer>()).materials).Count];
for (int i = 0; i < ((Il2CppArrayBase<Material>)(object)((Renderer)val.GetComponent<MeshRenderer>()).materials).Count; i++)
{
originalRing[i] = new Material(((Il2CppArrayBase<Material>)(object)((Renderer)val.GetComponent<MeshRenderer>()).materials)[i]);
}
originalRingGameObject = new GameObject();
((Renderer)originalRingGameObject.AddComponent<MeshRenderer>()).materials = Il2CppReferenceArray<Material>.op_Implicit(originalRing);
originalRingGameObject.SetActive(false);
}
sceneChanged = false;
}
private IEnumerator Init()
{
while (!gymInitRan)
{
yield return (object)new WaitForFixedUpdate();
try
{
materials = (Material[])(object)new Material[13];
materials[0] = new Material(((Renderer)((Component)((Component)Singleton<PlayerManager>.instance.localPlayer.Controller).gameObject.transform.GetChild(0).GetChild(0)).gameObject.GetComponent<SkinnedMeshRenderer>()).material);
materials[1] = new Material(((Renderer)Root.GetGameObject().GetComponent<MeshRenderer>()).material);
materials[2] = new Material(((Renderer)SpawnRingFloor.GetGameObject().GetComponent<MeshRenderer>()).material);
materials[3] = new Material(((Renderer)RootLeaves000.GetGameObject().GetComponent<MeshRenderer>()).material);
materials[4] = new Material(((Renderer)FloorMesh.GetGameObject().GetComponent<MeshRenderer>()).material);
materials[5] = new Material(((Renderer)WoodsetLarge.GetGameObject().GetComponent<MeshRenderer>()).material);
materials[6] = new Material(((ShiftStone)ChargeStone.GetGameObject().GetComponent<ChargeStone>()).gemRenderer.material);
materials[7] = new Material(((ShiftStone)AdamantStone.GetGameObject().GetComponent<UnyieldingStone>()).gemRenderer.material);
materials[8] = new Material(((ShiftStone)GuardStone.GetGameObject().GetComponent<GuardStone>()).gemRenderer.material);
materials[9] = new Material(((ShiftStone)VolatileStone.GetGameObject().GetComponent<VolatileStone>()).gemRenderer.material);
materials[10] = new Material(((ShiftStone)SurgeStone.GetGameObject().GetComponent<CounterStone>()).gemRenderer.material);
materials[11] = new Material(((Renderer)FarRocks0.GetGameObject().GetComponent<MeshRenderer>()).material);
materials[12] = new Material(((ShiftStone)FlowStone.GetGameObject().GetComponent<FlowStone>()).gemRenderer.material);
materialsGameObject = new GameObject();
((Object)materialsGameObject).name = "RingSwapper Materials";
materialsGameObject.AddComponent<MeshRenderer>();
((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials = Il2CppReferenceArray<Material>.op_Implicit(materials);
Object.DontDestroyOnLoad((Object)(object)materialsGameObject);
gymInitRan = true;
Log("Initialized");
}
catch
{
}
}
}
private void SwitchRingType(GameObject objectToModify)
{
try
{
switch (currentScene)
{
case "Park":
ringType = ringTypes[0];
break;
case "Map0":
ringType = ringTypes[1];
break;
case "Map1":
ringType = ringTypes[2];
break;
}
((Renderer)objectToModify.GetComponent<MeshRenderer>()).materials = Il2CppReferenceArray<Material>.op_Implicit(originalRing);
switch (ringType)
{
case 0:
break;
case 1:
ReskinRing(objectToModify.GetComponent<MeshRenderer>(), ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[1].shader, ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[1].shader);
break;
case 2:
CopyReskinRing(objectToModify.GetComponent<MeshRenderer>(), ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[1], ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[1]);
break;
case 3:
ReskinRing(objectToModify.GetComponent<MeshRenderer>(), ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[0].shader, ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[0].shader);
break;
case 4:
ReskinRing(objectToModify.GetComponent<MeshRenderer>(), ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[2].shader, ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[0].shader);
break;
case 5:
ReskinRing(objectToModify.GetComponent<MeshRenderer>(), ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[1], ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[1]);
break;
case 6:
ReskinRing(objectToModify.GetComponent<MeshRenderer>(), ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[4], ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[3]);
break;
case 7:
ReskinRing(objectToModify.GetComponent<MeshRenderer>(), ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[5], ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[5]);
break;
case 8:
ReskinRing(objectToModify.GetComponent<MeshRenderer>(), ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[2].shader, ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[6]);
break;
case 9:
ReskinRing(objectToModify.GetComponent<MeshRenderer>(), ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[6], ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[2].shader);
break;
case 10:
ReskinRing(objectToModify.GetComponent<MeshRenderer>(), ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[7], ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[0].shader);
break;
case 11:
ReskinRing(objectToModify.GetComponent<MeshRenderer>(), ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[8], ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[6]);
break;
case 12:
ReskinRing(objectToModify.GetComponent<MeshRenderer>(), ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[9], ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[10]);
break;
case 13:
ReskinRing(objectToModify.GetComponent<MeshRenderer>(), ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[11], ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[11]);
break;
case 14:
ReskinRing(objectToModify.GetComponent<MeshRenderer>(), ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[12], ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[8]);
break;
case 15:
ReskinRing(objectToModify.GetComponent<MeshRenderer>(), ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[9], ((Il2CppArrayBase<Material>)(object)((Renderer)materialsGameObject.GetComponent<MeshRenderer>()).materials)[12]);
break;
}
}
catch (Exception ex)
{
MelonLogger.Error((object)ex);
}
}
public static void Log(string msg)
{
MelonLogger.Msg(msg);
}
private void CopyReskinRing(MeshRenderer meshRendererToBeReskinned, Material mat1, Material mat2)
{
if (currentScene == "Map0")
{
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[0].CopyPropertiesFromMaterial(mat1);
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[1].CopyPropertiesFromMaterial(mat2);
}
else if (currentScene == "Map1")
{
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[0].CopyPropertiesFromMaterial(mat2);
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[1].CopyPropertiesFromMaterial(mat1);
}
else if (currentScene == "Park")
{
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[1].CopyPropertiesFromMaterial(mat1);
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[2].CopyPropertiesFromMaterial(mat2);
}
}
private void ReskinRing(MeshRenderer meshRendererToBeReskinned, Shader shader, Material material)
{
if (currentScene == "Map0")
{
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[0].shader = shader;
((Renderer)meshRendererToBeReskinned).materials = Il2CppReferenceArray<Material>.op_Implicit((Material[])(object)new Material[2]
{
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[0],
material
});
}
else if (currentScene == "Map1")
{
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[0].shader = shader;
Material[] array = (Material[])(object)new Material[2];
array[1] = ((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[0];
array[0] = material;
((Renderer)meshRendererToBeReskinned).materials = Il2CppReferenceArray<Material>.op_Implicit(array);
}
else if (currentScene == "Park")
{
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[1].shader = shader;
((Renderer)meshRendererToBeReskinned).materials = Il2CppReferenceArray<Material>.op_Implicit((Material[])(object)new Material[3]
{
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[0],
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[1],
material
});
}
}
private void ReskinRing(MeshRenderer meshRendererToBeReskinned, Material material, Shader shader)
{
if (currentScene == "Map0")
{
Material[] array = (Material[])(object)new Material[2]
{
material,
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[1]
};
array[1].shader = shader;
((Renderer)meshRendererToBeReskinned).materials = Il2CppReferenceArray<Material>.op_Implicit(array);
}
else if (currentScene == "Map1")
{
Material[] array2 = (Material[])(object)new Material[2];
array2[1] = material;
array2[0] = ((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[1];
array2[0].shader = shader;
((Renderer)meshRendererToBeReskinned).materials = Il2CppReferenceArray<Material>.op_Implicit(array2);
}
else if (currentScene == "Park")
{
Material[] array3 = (Material[])(object)new Material[3]
{
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[0],
material,
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[2]
};
array3[2].shader = shader;
((Renderer)meshRendererToBeReskinned).materials = Il2CppReferenceArray<Material>.op_Implicit(array3);
}
}
private void ReskinRing(MeshRenderer meshRendererToBeReskinned, Shader shader1, Shader shader2)
{
if (currentScene == "Map0")
{
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[0].shader = shader1;
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[1].shader = shader2;
}
else if (currentScene == "Map1")
{
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[1].shader = shader1;
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[0].shader = shader2;
}
else if (currentScene == "Park")
{
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[1].shader = shader1;
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[2].shader = shader2;
}
}
private void ReskinRing(MeshRenderer meshRendererToBeReskinned, Material mat1, Material mat2)
{
if (currentScene == "Map0")
{
((Renderer)meshRendererToBeReskinned).materials = Il2CppReferenceArray<Material>.op_Implicit((Material[])(object)new Material[2] { mat1, mat2 });
}
else if (currentScene == "Map1")
{
Material[] array = (Material[])(object)new Material[2];
array[1] = mat1;
array[0] = mat2;
((Renderer)meshRendererToBeReskinned).materials = Il2CppReferenceArray<Material>.op_Implicit(array);
}
else if (currentScene == "Park")
{
((Renderer)meshRendererToBeReskinned).materials = Il2CppReferenceArray<Material>.op_Implicit((Material[])(object)new Material[3]
{
((Il2CppArrayBase<Material>)(object)((Renderer)meshRendererToBeReskinned).materials)[0],
mat1,
mat2
});
}
}
}