using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppRUMBLE.Environment;
using Il2CppRUMBLE.MoveSystem;
using MelonLoader;
using RumbleModUI;
using RumbleModdingAPI;
using StructureStones;
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), "StructureStones", "2.1.0", "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("StructureStones")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StructureStones")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("26c0135e-fa6a-4ddb-a5d5-44e667a0272b")]
[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 StructureStones;
public class main : MelonMod
{
[HarmonyPatch(typeof(Structure), "Start")]
public static class StructureSpawn
{
private static void Postfix(ref Structure __instance)
{
if (!init)
{
return;
}
try
{
if ((Object)(object)((Component)__instance.processableComponent).gameObject.GetComponent<Tetherball>() != (Object)null)
{
MeshRenderer component = ((Component)((Component)__instance.processableComponent).gameObject.transform.GetChild(0)).GetComponent<MeshRenderer>();
((Renderer)component).material = stoneMaterials[(int)StructureStones.Settings[8].SavedValue];
}
}
catch (Exception ex)
{
MelonLogger.Error((object)ex);
}
}
}
[HarmonyPatch(typeof(Structure), "OnFetchFromPool")]
public static class StructureRespawn
{
private static void Postfix(ref Structure __instance)
{
if (!init)
{
return;
}
string text = ((Object)((Component)__instance.processableComponent).gameObject).name;
MeshRenderer val;
try
{
if (!((Object)(object)((Component)__instance.processableComponent).gameObject.GetComponent<Tetherball>() != (Object)null))
{
val = ((!((Object)(object)((Component)__instance.processableComponent).gameObject.GetComponent<MeshRenderer>() != (Object)null)) ? ((Component)((Component)__instance.processableComponent).gameObject.transform).GetComponentInChildren<MeshRenderer>() : ((Component)__instance.processableComponent).gameObject.GetComponent<MeshRenderer>());
}
else
{
text = "BoulderBall";
val = ((Component)((Component)__instance.processableComponent).gameObject.transform.GetChild(0)).GetComponent<MeshRenderer>();
}
}
catch (Exception ex)
{
MelonLogger.Error((object)ex);
return;
}
switch (text)
{
case "LargeRock":
((Renderer)val).material = stoneMaterials[(int)StructureStones.Settings[7].SavedValue];
break;
case "SmallRock":
((Renderer)val).material = stoneMaterials[(int)StructureStones.Settings[6].SavedValue];
break;
case "Pillar":
((Renderer)val).material = stoneMaterials[(int)StructureStones.Settings[2].SavedValue];
break;
case "Disc":
((Renderer)val).material = stoneMaterials[(int)StructureStones.Settings[1].SavedValue];
break;
case "Wall":
((Renderer)val).material = stoneMaterials[(int)StructureStones.Settings[5].SavedValue];
break;
case "RockCube":
((Renderer)val).material = stoneMaterials[(int)StructureStones.Settings[4].SavedValue];
break;
case "Ball":
((Renderer)val).material = stoneMaterials[(int)StructureStones.Settings[3].SavedValue];
break;
case "BoulderBall":
((Renderer)val).material = stoneMaterials[(int)StructureStones.Settings[8].SavedValue];
break;
}
}
}
private bool sceneChanged = false;
private string currentScene = "";
private static bool init = false;
public GameObject materialsParent;
public GameObject[] materialsHolder;
public static Material[] stoneMaterials = (Material[])(object)new Material[8];
private UI UI = UI.instance;
public static Mod StructureStones = new Mod();
private int[] preSavedValues = new int[8];
public override void OnLateInitializeMelon()
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Expected O, but got Unknown
//IL_018d: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Expected O, but got Unknown
//IL_022d: Unknown result type (might be due to invalid IL or missing references)
//IL_0237: Expected O, but got Unknown
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_02d7: Expected O, but got Unknown
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_0377: Expected O, but got Unknown
//IL_040d: Unknown result type (might be due to invalid IL or missing references)
//IL_0417: Expected O, but got Unknown
//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
//IL_04b7: Expected O, but got Unknown
//IL_054d: Unknown result type (might be due to invalid IL or missing references)
//IL_0557: Expected O, but got Unknown
StructureStones.ModName = "StructureStones";
StructureStones.ModVersion = "2.0.2";
StructureStones.SetFolder("StructureStones");
StructureStones.AddDescription("Description", "Description", "Sets Structure Skins to Shiftstone Skins", new Tags
{
IsSummary = true
});
StructureStones.AddToList("Disc", 1, "Volatile Stone: 0" + Environment.NewLine + "Charge Stone: 1" + Environment.NewLine + "Surge Stone: 2" + Environment.NewLine + "Flow Stone: 3" + Environment.NewLine + "Guard Stone: 4" + Environment.NewLine + "Stubborn Stone: 5" + Environment.NewLine + "Adamant Stone: 6" + Environment.NewLine + "Vigor Stone: 7", new Tags());
StructureStones.AddToList("Pillar", 2, "Volatile Stone: 0" + Environment.NewLine + "Charge Stone: 1" + Environment.NewLine + "Surge Stone: 2" + Environment.NewLine + "Flow Stone: 3" + Environment.NewLine + "Guard Stone: 4" + Environment.NewLine + "Stubborn Stone: 5" + Environment.NewLine + "Adamant Stone: 6" + Environment.NewLine + "Vigor Stone: 7", new Tags());
StructureStones.AddToList("Ball", 3, "Volatile Stone: 0" + Environment.NewLine + "Charge Stone: 1" + Environment.NewLine + "Surge Stone: 2" + Environment.NewLine + "Flow Stone: 3" + Environment.NewLine + "Guard Stone: 4" + Environment.NewLine + "Stubborn Stone: 5" + Environment.NewLine + "Adamant Stone: 6" + Environment.NewLine + "Vigor Stone: 7", new Tags());
StructureStones.AddToList("Cube", 4, "Volatile Stone: 0" + Environment.NewLine + "Charge Stone: 1" + Environment.NewLine + "Surge Stone: 2" + Environment.NewLine + "Flow Stone: 3" + Environment.NewLine + "Guard Stone: 4" + Environment.NewLine + "Stubborn Stone: 5" + Environment.NewLine + "Adamant Stone: 6" + Environment.NewLine + "Vigor Stone: 7", new Tags());
StructureStones.AddToList("Wall", 5, "Volatile Stone: 0" + Environment.NewLine + "Charge Stone: 1" + Environment.NewLine + "Surge Stone: 2" + Environment.NewLine + "Flow Stone: 3" + Environment.NewLine + "Guard Stone: 4" + Environment.NewLine + "Stubborn Stone: 5" + Environment.NewLine + "Adamant Stone: 6" + Environment.NewLine + "Vigor Stone: 7", new Tags());
StructureStones.AddToList("Small Rock", 6, "Volatile Stone: 0" + Environment.NewLine + "Charge Stone: 1" + Environment.NewLine + "Surge Stone: 2" + Environment.NewLine + "Flow Stone: 3" + Environment.NewLine + "Guard Stone: 4" + Environment.NewLine + "Stubborn Stone: 5" + Environment.NewLine + "Adamant Stone: 6" + Environment.NewLine + "Vigor Stone: 7", new Tags());
StructureStones.AddToList("Large Rock", 0, "Volatile Stone: 0" + Environment.NewLine + "Charge Stone: 1" + Environment.NewLine + "Surge Stone: 2" + Environment.NewLine + "Flow Stone: 3" + Environment.NewLine + "Guard Stone: 4" + Environment.NewLine + "Stubborn Stone: 5" + Environment.NewLine + "Adamant Stone: 6" + Environment.NewLine + "Vigor Stone: 7", new Tags());
StructureStones.AddToList("BoulderBall", 7, "Volatile Stone: 0" + Environment.NewLine + "Charge Stone: 1" + Environment.NewLine + "Surge Stone: 2" + Environment.NewLine + "Flow Stone: 3" + Environment.NewLine + "Guard Stone: 4" + Environment.NewLine + "Stubborn Stone: 5" + Environment.NewLine + "Adamant Stone: 6" + Environment.NewLine + "Vigor Stone: 7", new Tags());
StructureStones.GetFromFile();
for (int i = 0; i < StructureStones.Settings.Count - 1; i++)
{
preSavedValues[i] = (int)StructureStones.Settings[i + 1].SavedValue;
}
UI.instance.UI_Initialized += UIInit;
StructureStones.ModSaved += Save;
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_0035: Expected O, but got Unknown
//IL_034f: Unknown result type (might be due to invalid IL or missing references)
//IL_0355: Expected O, but got Unknown
//IL_037f: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: Expected O, but got Unknown
currentScene = sceneName;
sceneChanged = true;
if (!(currentScene == "Loader"))
{
return;
}
GameObject val = new GameObject();
GameObject val2 = val;
materialsParent = val;
Object.DontDestroyOnLoad((Object)(object)val2);
((Object)materialsParent).name = "StructureStonesMaterialsParent";
GameObject[] array = Il2CppArrayBase<GameObject>.op_Implicit(Resources.FindObjectsOfTypeAll<GameObject>());
List<GameObject> list = new List<GameObject>();
GameObject[] array2 = array;
foreach (GameObject val3 in array2)
{
if (((Object)val3).name.Contains("Stone") && (Object)(object)val3.transform.parent == (Object)null)
{
list.Add(val3);
}
}
materialsHolder = (GameObject[])(object)new GameObject[8];
Material[] array3 = (Material[])(object)new Material[8];
foreach (GameObject item in list)
{
switch (((Object)item).name)
{
case "VolatileStone":
array3[0] = ((Renderer)((Component)item.transform.GetChild(0)).GetComponent<MeshRenderer>()).material;
break;
case "ChargeStone":
array3[1] = ((Renderer)((Component)item.transform.GetChild(0)).GetComponent<MeshRenderer>()).material;
break;
case "SurgeStone":
array3[2] = ((Renderer)((Component)item.transform.GetChild(0)).GetComponent<MeshRenderer>()).material;
break;
case "FlowStone":
array3[3] = ((Renderer)((Component)item.transform.GetChild(0)).GetComponent<MeshRenderer>()).material;
break;
case "GuardStone":
array3[4] = ((Renderer)((Component)item.transform.GetChild(0)).GetComponent<MeshRenderer>()).material;
break;
case "StubbornStone":
array3[5] = ((Renderer)((Component)item.transform.GetChild(0)).GetComponent<MeshRenderer>()).material;
break;
case "AdamantStone":
array3[6] = ((Renderer)((Component)item.transform.GetChild(0)).GetComponent<MeshRenderer>()).material;
break;
case "VigorStone":
array3[7] = ((Renderer)((Component)item.transform.GetChild(0)).GetComponent<MeshRenderer>()).material;
break;
}
}
for (int j = 0; j < 8; j++)
{
materialsHolder[j] = new GameObject();
materialsHolder[j].transform.parent = materialsParent.transform;
stoneMaterials[j] = new Material(array3[j]);
((Object)materialsHolder[j]).name = ((Object)stoneMaterials[j]).name;
materialsHolder[j].AddComponent<MeshRenderer>();
((Renderer)materialsHolder[j].GetComponent<MeshRenderer>()).material = stoneMaterials[j];
}
init = true;
Log("Initialized");
}
public override void OnFixedUpdate()
{
if (!sceneChanged)
{
return;
}
try
{
if (!init)
{
return;
}
}
catch (Exception ex)
{
MelonLogger.Error((object)ex);
return;
}
sceneChanged = false;
}
public static void Log(string msg)
{
MelonLogger.Msg(msg);
}
private void Save()
{
for (int i = 0; i < StructureStones.Settings.Count - 1; i++)
{
Log(i + " of " + (StructureStones.Settings.Count - 1));
if (preSavedValues[i] == (int)StructureStones.Settings[i + 1].SavedValue)
{
continue;
}
switch (i)
{
case 0:
{
GameObject poolDisc = Structures.GetPoolDisc();
Log(i + ((Object)poolDisc).name);
for (int n = 0; n < poolDisc.transform.childCount; n++)
{
if (((Component)poolDisc.transform.GetChild(n)).gameObject.active)
{
((Renderer)((Component)poolDisc.transform.GetChild(n).GetChild(0)).GetComponent<MeshRenderer>()).material = stoneMaterials[(int)StructureStones.Settings[i + 1].SavedValue];
}
}
break;
}
case 1:
{
GameObject poolPillar = Structures.GetPoolPillar();
Log(i + ((Object)poolPillar).name);
for (int num3 = 0; num3 < poolPillar.transform.childCount; num3++)
{
if (((Component)poolPillar.transform.GetChild(num3)).gameObject.active)
{
((Renderer)((Component)poolPillar.transform.GetChild(num3).GetChild(0)).GetComponent<MeshRenderer>()).material = stoneMaterials[(int)StructureStones.Settings[i + 1].SavedValue];
}
}
break;
}
case 2:
{
GameObject poolBall = Structures.GetPoolBall();
Log(i + ((Object)poolBall).name);
for (int l = 0; l < poolBall.transform.childCount; l++)
{
if (((Component)poolBall.transform.GetChild(l)).gameObject.active)
{
((Renderer)((Component)poolBall.transform.GetChild(l).GetChild(0)).GetComponent<MeshRenderer>()).material = stoneMaterials[(int)StructureStones.Settings[i + 1].SavedValue];
}
}
break;
}
case 3:
{
GameObject poolCube = Structures.GetPoolCube();
Log(i + ((Object)poolCube).name);
for (int num = 0; num < poolCube.transform.childCount; num++)
{
if (((Component)poolCube.transform.GetChild(num)).gameObject.active)
{
((Renderer)((Component)poolCube.transform.GetChild(num).GetChild(0)).GetComponent<MeshRenderer>()).material = stoneMaterials[(int)StructureStones.Settings[i + 1].SavedValue];
}
}
break;
}
case 4:
{
GameObject poolWall = Structures.GetPoolWall();
Log(i + ((Object)poolWall).name);
for (int m = 0; m < poolWall.transform.childCount; m++)
{
if (((Component)poolWall.transform.GetChild(m)).gameObject.active)
{
((Renderer)((Component)poolWall.transform.GetChild(m).GetChild(0)).GetComponent<MeshRenderer>()).material = stoneMaterials[(int)StructureStones.Settings[i + 1].SavedValue];
}
}
break;
}
case 5:
{
GameObject poolSmallRock = Structures.GetPoolSmallRock();
Log(i + ((Object)poolSmallRock).name);
for (int k = 0; k < poolSmallRock.transform.childCount; k++)
{
if (((Component)poolSmallRock.transform.GetChild(k)).gameObject.active)
{
((Renderer)((Component)poolSmallRock.transform.GetChild(k)).GetComponent<MeshRenderer>()).material = stoneMaterials[(int)StructureStones.Settings[i + 1].SavedValue];
}
}
break;
}
case 6:
{
GameObject poolLargeRock = Structures.GetPoolLargeRock();
Log(i + ((Object)poolLargeRock).name);
for (int num2 = 0; num2 < poolLargeRock.transform.childCount; num2++)
{
if (((Component)poolLargeRock.transform.GetChild(num2)).gameObject.active)
{
((Renderer)((Component)poolLargeRock.transform.GetChild(num2)).GetComponent<MeshRenderer>()).material = stoneMaterials[(int)StructureStones.Settings[i + 1].SavedValue];
}
}
break;
}
case 7:
{
GameObject poolBoulderBall = Structures.GetPoolBoulderBall();
Log(i + ((Object)poolBoulderBall).name);
for (int j = 0; j < poolBoulderBall.transform.childCount; j++)
{
if (((Component)poolBoulderBall.transform.GetChild(j)).gameObject.active)
{
((Renderer)((Component)poolBoulderBall.transform.GetChild(j)).GetComponent<MeshRenderer>()).material = stoneMaterials[(int)StructureStones.Settings[i + 1].SavedValue];
}
}
if (currentScene == "Gym")
{
((Renderer)((Component)Ball.GetGameObject().transform.GetChild(0)).GetComponent<MeshRenderer>()).material = stoneMaterials[(int)StructureStones.Settings[i + 1].SavedValue];
((Renderer)((Component)Ball.GetGameObject().transform.GetChild(0)).GetComponent<MeshRenderer>()).material = stoneMaterials[(int)StructureStones.Settings[i + 1].SavedValue];
}
else if (currentScene == "Park")
{
((Renderer)Ball_.GetGameObject().GetComponent<MeshRenderer>()).material = stoneMaterials[(int)StructureStones.Settings[i + 1].SavedValue];
((Renderer)Ball_.GetGameObject().GetComponent<MeshRenderer>()).material = stoneMaterials[(int)StructureStones.Settings[i + 1].SavedValue];
}
break;
}
}
preSavedValues[i] = (int)StructureStones.Settings[i + 1].SavedValue;
}
}
private void UIInit()
{
UI.AddMod(StructureStones);
}
}