using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using GameModes; using HarmonyLib; using Il2CppExitGames.Client.Photon; using Il2CppPhoton.Realtime; using Il2CppRUMBLE.Managers; using Il2CppRUMBLE.MoveSystem; using Il2CppRUMBLE.Players; using Il2CppRUMBLE.Social.Party; using Il2CppSystem; using Il2CppTMPro; using MelonLoader; using RockUI; using RumbleModdingAPI.RMAPI; using UnityEngine; using UnityEngine.VFX; [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), "GameModes", "1.0.0", "GreyBeetle", null)] [assembly: MelonGame("Buckethead Entertainment", "RUMBLE")] [assembly: MelonColor(255, 0, 255, 255)] [assembly: MelonAuthorColor(255, 0, 255, 255)] [assembly: VerifyLoaderVersion(0, 6, 2, true)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.0.0.0")] namespace GameModes; public class ModeSelector { public ModeSelector() { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: 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_0148: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) RockPanel val = new RockPanel(); val.size = new Vector2(10f, 5f); RockText val2 = new RockText(); val2.text = "None\n\n\nSteel Boulder Run"; ((UIElement)val2).anchor = (AnchorType)8; ((UIElement)val).AddChildUI((UIElement)(object)val2); GameObject val3 = RockUI.CreateFinalisedUI((UIElement)(object)val, false); val3.transform.position = new Vector3(6.2127f, 1.7545f, 14.35f); val3.transform.rotation = Quaternion.Euler(new Vector3(0f, 333.0468f, 0f)); RockSlider val4 = new RockSlider(); val4.useSteps = true; val4.stepCount = 2; val4.stepReachedAction = onSliderMove; GameObject val5 = ((UIElement)val4).Create(); val5.transform.rotation = Quaternion.Euler(0f, 244.7037f, 90f); val5.transform.position = new Vector3(5.8687f, 1.8809f, 14.0572f); val5.transform.parent = val3.transform; val3.transform.position = new Vector3(4.589f, 1.8545f, 12.6535f); val3.transform.rotation = Quaternion.Euler(new Vector3(0f, 309.0562f, 0f)); } private void onSliderMove(int selected) { switch (selected) { case 0: Main.selectedGameMode = "None"; break; case 1: Main.selectedGameMode = "SteelBoulderRun"; break; } } } public class Main : RumbleMod { public static PlayerManager playerManager; public static string currentMap; public static Main This; public static string selectedGameMode = "None"; public override void OnLateInitializeMelon() { This = this; Actions.onMapInitialized += delegate(string map) { if (map == "Gym") { new ModeSelector(); SteelBoulderRun.enabled = false; ((RumbleMod)this).RegisterEvents(); SteelBoulderRun.ResetScores(); if (SteelBoulderRun.debug) { MelonLogger.Msg((object)getPartyHandler().IsPartyOwner); SteelBoulderRun.enabled = true; SteelBoulderRun.createScore(); SteelBoulderRun.displayScore(); MelonLogger.Msg("DEBUG: enabled in gym"); } } currentMap = map; playerManager = PlayerManager.GetGameObject().GetComponent(); }; Actions.onPlayerSpawned += delegate(Player player) { SteelBoulderRun.addPlayer(player.Data.GeneralData.PublicUsername); }; Actions.onModStringReceived += delegate { if (Mods.doesOpponentHaveMod("GameModes", "", false) && currentMap == "Map1" && !(selectedGameMode != "SteelBoulderRun") && getPartyHandler().IsPartyOwner) { SteelBoulderRun.sendEnable(); SteelBoulderRun.enable(); } }; } public static PartyHandler getPartyHandler() { return Initializable.GetGameObject().GetComponentInChildren(); } public override void OnEvent(List data) { //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_00cc: 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) string text = data[0].ToString(); if (text.Contains("SteelBoulderRunEnabled")) { SteelBoulderRun.enable(); } else if (SteelBoulderRun.enabled) { Vector3 pos = default(Vector3); ((Vector3)(ref pos))..ctor(float.Parse(data[1].ToString()), float.Parse(data[2].ToString()), float.Parse(data[3].ToString())); int num = int.Parse(data[4].ToString()); SteelBoulderRun.incrementScore(text, num); switch (num) { case 1: new BoulderDeathText(text + ": +1", Color.green, pos); break; case -1: new BoulderDeathText(text + ": -1", Color.red, pos); break; } } } } public class ScoreText { private TextMeshPro textMeshPro; private GameObject label; public static ScoreText currentScoreText; public ScoreText() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) if (currentScoreText != null) { Object.Destroy((Object)(object)currentScoreText.label); } currentScoreText = this; label = Create.NewText(); textMeshPro = label.GetComponent(); ((TMP_Text)textMeshPro).color = Color.white; ((TMP_Text)textMeshPro).fontSize = 10f; ((TMP_Text)textMeshPro).text = "Hello, World!"; ((TMP_Text)textMeshPro).enableWordWrapping = false; label.transform.position = new Vector3(-13f, 10f, -3f); label.transform.rotation = Quaternion.Euler(0f, 250f, 0f); } public void setText(string text) { ((TMP_Text)textMeshPro).text = text; } } [RegisterTypeInIl2Cpp] public class RotatingText : MonoBehaviour { private TextMeshPro textMeshPro; private GameObject textAnchor; private float distance = 1.5f; private GameObject label; private bool started = false; private Color startColor = Color.white; private string startText = " "; public void Start() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) label = Create.NewText(); textMeshPro = label.GetComponent(); ((TMP_Text)textMeshPro).color = startColor; ((TMP_Text)textMeshPro).fontSize = 2f; ((TMP_Text)textMeshPro).text = startText; ((TMP_Text)textMeshPro).enableWordWrapping = false; textAnchor = new GameObject("TextAnchor"); textAnchor.transform.position = ((Component)this).transform.position; label.transform.RotateAround(((Component)this).transform.position, ((Component)this).transform.up, 180f); textAnchor.transform.parent = ((Component)this).transform; label.transform.parent = textAnchor.transform; label.transform.position = ((Component)this).transform.position + new Vector3(0f, 0f, distance); started = true; } public void LateUpdate() { RotateText(); } public void setDistance(float d) { distance = d; } private void RotateText() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)Players.GetLocalPlayerController().PlayerVR != (Object)null) { textAnchor.transform.LookAt(Players.GetLocalPlayerController().PlayerVR.Headset.Transform.position); } } catch { } } public void setText(string text) { if (started) { ((TMP_Text)textMeshPro).text = text; } else { startText = text; } } public void setColor(Color color) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) if (started) { ((TMP_Text)textMeshPro).color = color; } else { startColor = color; } } } public class BoulderDeathText { private RotatingText text; public BoulderDeathText(string msg, Color color, Vector3 pos) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Expected O, but got Unknown //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(); val.transform.position = pos; text = val.AddComponent(); text.setDistance(0.1f); text.setText(msg); text.setColor(color); Object.Destroy((Object)(object)((Component)text).gameObject, 3f); } } [RegisterTypeInIl2Cpp] public class BoulderTracker : MonoBehaviour { private const float OWNERSHIP_LENGTH = 3f; private PlayerController lastModifiedBy; private float timeSinceModified = 0f; private RotatingText text; private bool flicked = false; private bool held = false; public void Start() { text = ((Component)this).gameObject.AddComponent(); } public void LateUpdate() { updateFlicked(); updateHeld(); updateOwner(); } private void updateOwner() { if (timeSinceModified < 3f) { timeSinceModified += Time.deltaTime; if (timeSinceModified >= 3f) { text.setText(""); lastModifiedBy = null; } } } private void updateFlicked() { if (flicked) { if (((IEnumerable)((Component)this).gameObject.GetComponentsInChildren()).Any((VisualEffect vfx) => ((Object)vfx).name.Contains("Flick_VFX"))) { timeSinceModified = 0f; } else { flicked = false; } } } private void updateHeld() { if (held) { if (((IEnumerable)((Component)this).gameObject.GetComponentsInChildren()).Any((VisualEffect vfx) => ((Object)vfx).name.Contains("Hold_VFX"))) { timeSinceModified = 0f; } else { held = false; } } } public void onModified(PlayerController player) { if (!flicked && !held) { lastModifiedBy = player; timeSinceModified = 0f; text.setText(player.assignedPlayer.Data.GeneralData.PublicUsername); } } public void onFlicked(PlayerController player) { onModified(player); flicked = true; } public void onHeld(PlayerController player) { onModified(player); held = true; } public void onCollision(Structure structure) { //IL_0106: 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) if ((!Players.IsHost() && !SteelBoulderRun.debug) || structure.GetTotalTier() < ((Component)this).GetComponent().GetTotalTier()) { return; } Player val; if ((Object)(object)((Component)structure).GetComponent() == (Object)null) { if (structure.processableComponent.previousStackConfiguration == null) { return; } val = Main.playerManager.GetPlayerByActorNo((int)structure.processableComponent.previousStackConfiguration.CastingPlayerActorNo); } else { if ((Object)(object)((Component)structure).GetComponent().lastModifiedBy == (Object)null) { return; } val = ((Component)structure).GetComponent().lastModifiedBy.assignedPlayer; } if ((Object)(object)lastModifiedBy == (Object)(object)val.Controller || (Object)(object)lastModifiedBy == (Object)null) { SteelBoulderRun.incrementScore(val.Data.GeneralData.PublicUsername, -1); sendScoreChange(val.Data.GeneralData.PublicUsername, ((Component)this).transform.position, -1); displayDeathText(val.Data.GeneralData.PublicUsername + ": -1", Color.red); } } public void onPlayerHit(PlayerController player) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) if ((Players.IsHost() || SteelBoulderRun.debug) && !((Object)(object)lastModifiedBy == (Object)null) && !((Object)(object)player == (Object)(object)lastModifiedBy)) { SteelBoulderRun.incrementScore(lastModifiedBy.assignedPlayer.Data.GeneralData.PublicUsername, 1); sendScoreChange(lastModifiedBy.assignedPlayer.Data.GeneralData.PublicUsername, ((Component)this).transform.position, 1); displayDeathText(lastModifiedBy.assignedPlayer.Data.GeneralData.PublicUsername + ": +1", Color.green); } } public void onIronFeet(PlayerController player) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) if ((Players.IsHost() || SteelBoulderRun.debug) && ((Object)(object)lastModifiedBy == (Object)null || (Object)(object)lastModifiedBy == (Object)(object)player)) { SteelBoulderRun.incrementScore(player.assignedPlayer.Data.GeneralData.PublicUsername, -1); sendScoreChange(player.assignedPlayer.Data.GeneralData.PublicUsername, ((Component)this).transform.position, -1); displayDeathText(player.assignedPlayer.Data.GeneralData.PublicUsername + ": -1", Color.red); } } private void displayDeathText(string msg, Color color) { //IL_0002: 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) new BoulderDeathText(msg, color, ((Component)this).transform.position); lastModifiedBy = null; timeSinceModified = 1000f; text.setText(""); } public void sendScoreChange(string name, Vector3 pos, int change) { //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_008b: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) if (!SteelBoulderRun.debug) { List list = new List(); list.Add((Object)(object)String.op_Implicit(name)); list.Add((Object)(object)String.op_Implicit(pos.x.ToString())); list.Add((Object)(object)String.op_Implicit(pos.y.ToString())); list.Add((Object)(object)String.op_Implicit(pos.z.ToString())); list.Add((Object)(object)String.op_Implicit(change.ToString())); RaiseEventOptions val = new RaiseEventOptions { Receivers = (ReceiverGroup)0 }; ((RumbleMod)Main.This).RaiseEvent(list, val, SendOptions.SendReliable); } } } public class SteelBoulderRun { public static bool enabled = false; public static Dictionary playerScores = new Dictionary(); public static ScoreText scoreText; public static bool debug = false; public static void incrementScore(string name, int change) { if (!debug) { playerScores[name] += change; displayScore(); } } public static void enable() { enabled = true; createScore(); displayScore(); } public static void sendEnable() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) List list = new List(); string text = "SteelBoulderRunEnabled"; list.Add((Object)(object)String.op_Implicit(text)); RaiseEventOptions val = new RaiseEventOptions { Receivers = (ReceiverGroup)0 }; ((RumbleMod)Main.This).RaiseEvent(list, val, SendOptions.SendReliable); } public static void ResetScores() { playerScores.Clear(); } public static void displayScore() { string text = ""; foreach (string key in playerScores.Keys) { text = text + key + ": " + playerScores[key] + "\n"; } scoreText.setText(text); } public static void addPlayer(string name) { if (!playerScores.ContainsKey(name)) { playerScores.Add(name, 0); } } public static void createScore() { scoreText = new ScoreText(); } } [HarmonyPatch(typeof(Structure), "Awake")] public static class StructureStartPatch { private static void Postfix(ref Structure __instance) { if (((Object)__instance).name.Contains("LargeRock")) { ((Component)__instance).gameObject.AddComponent(); } } } [HarmonyPatch(typeof(AddForceModifier), "Execute")] public static class AddForceModifierExecutePatch { private static void Postfix(AddForceModifier __instance, IProcessor processor, StackConfiguration config) { try { if (SteelBoulderRun.enabled) { BoulderTracker component = ((Component)config.TargetProcessable.GetProcessorComponent(false)).GetComponent(); if (!((Object)(object)component == (Object)null)) { PlayerController controller = Main.playerManager.GetPlayerByActorNo((int)config.CastingPlayerActorNo).Controller; component.onModified(controller); } } } catch (Exception ex) { MelonLogger.Msg((object)ex); } } } [HarmonyPatch(typeof(AddForcePlanarModifier), "Execute")] public static class AddForcePlanarModifierExecutePatch { public static void Postfix(AddForcePlanarModifier __instance, IProcessor processor, StackConfiguration config) { try { if (SteelBoulderRun.enabled) { BoulderTracker component = ((Component)config.TargetProcessable.GetProcessorComponent(false)).GetComponent(); if (!((Object)(object)component == (Object)null)) { PlayerController controller = Main.playerManager.GetPlayerByActorNo((int)config.CastingPlayerActorNo).Controller; component.onModified(controller); } } } catch (Exception ex) { MelonLogger.Msg((object)ex); } } } [HarmonyPatch(typeof(FlickModifier), "Execute")] public static class FlickModifierExecutePatch { public static void Postfix(FlickModifier __instance, IProcessor processor, StackConfiguration config) { try { if (SteelBoulderRun.enabled) { BoulderTracker component = ((Component)config.TargetProcessable.GetProcessorComponent(false)).GetComponent(); if (!((Object)(object)component == (Object)null)) { PlayerController controller = Main.playerManager.GetPlayerByActorNo((int)config.CastingPlayerActorNo).Controller; component.onFlicked(controller); } } } catch (Exception ex) { MelonLogger.Msg((object)ex); } } } [HarmonyPatch(typeof(HoldModifier), "Execute")] public static class HoldModifierExecutePatch { public static void Postfix(HoldModifier __instance, IProcessor processor, StackConfiguration config) { try { if (SteelBoulderRun.enabled) { BoulderTracker component = ((Component)config.TargetProcessable.GetProcessorComponent(false)).GetComponent(); if (!((Object)(object)component == (Object)null)) { PlayerController controller = Main.playerManager.GetPlayerByActorNo((int)config.CastingPlayerActorNo).Controller; component.onHeld(controller); } } } catch (Exception ex) { MelonLogger.Msg((object)ex); } } } [HarmonyPatch(typeof(CombatManager), "ProcessPlayerHitEvent")] public class PlayerHitPatch { public static void Postfix(PlayerHitEvent playerHitEvent) { try { if (SteelBoulderRun.enabled) { Structure structure = playerHitEvent.StructureSnapshot.structure; BoulderTracker component = ((Component)structure).GetComponent(); if (!((Object)(object)component == (Object)null)) { component.onPlayerHit(playerHitEvent.player.Controller); } } } catch (Exception ex) { MelonLogger.Msg((object)ex); } } } [HarmonyPatch(typeof(CombatManager), "RegisterStructureCollisionEvent")] public class StructureCollisionPatch { public static void Prefix(Structure first, Structure second, Collision collision) { try { if (SteelBoulderRun.enabled) { BoulderTracker component = ((Component)first).GetComponent(); if ((Object)(object)component != (Object)null) { component.onCollision(second); } BoulderTracker component2 = ((Component)second).GetComponent(); if ((Object)(object)component2 != (Object)null) { component2.onCollision(first); } } } catch (Exception ex) { MelonLogger.Msg((object)ex); } } } [HarmonyPatch(typeof(CombatManager), "ProcessJumpOnStructureEvent")] public class IronFeetPatch { public static void Postfix(JumpOnStructureEvent jumpOnStructureEvent) { try { if (SteelBoulderRun.enabled) { Player player = jumpOnStructureEvent.player; BoulderTracker component = ((Component)jumpOnStructureEvent.structureSnapshot.structure).GetComponent(); if (!((Object)(object)component == (Object)null)) { component.onIronFeet(player.Controller); } } } catch (Exception ex) { MelonLogger.Msg((object)ex); } } }