Decompiled source of Modo Versus RoR2 v1.0.0

Modo ROR2.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Modo ROR2")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Modo ROR2")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6e18e26f-0618-4da3-995d-76250fb47d48")]
[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 ModoROR2;

[BepInPlugin("com.seuusuario.modors2versus", "Modo Versus RoR2", "1.0.0")]
public class PluginPrincipal : BaseUnityPlugin
{
	private static Random random = new Random();

	private float contadorOuro;

	private const float INTERVALO_OURO = 5f;

	public void Awake()
	{
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Modo Versus: Modulo principal ativo!");
		Stage.onStageStartGlobal += Stage_onStageStartGlobal;
		GlobalEventManager.onCharacterDeathGlobal += GlobalEventManager_onCharacterDeathGlobal;
	}

	public void Update()
	{
		contadorOuro += Time.deltaTime;
		if (contadorOuro >= 5f)
		{
			contadorOuro = 0f;
			DarOuroPassivoAosMonstros();
		}
	}

	private void DarOuroPassivoAosMonstros()
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Invalid comparison between Unknown and I4
		if ((Object)(object)Run.instance == (Object)null)
		{
			return;
		}
		foreach (CharacterMaster readOnlyInstances in CharacterMaster.readOnlyInstancesList)
		{
			if ((Object)(object)readOnlyInstances.playerCharacterMasterController != (Object)null && (int)readOnlyInstances.teamIndex == 2)
			{
				uint num = (uint)Mathf.Max(1f, 1f * Run.instance.difficultyCoefficient);
				readOnlyInstances.GiveMoney(num);
			}
		}
	}

	private void Stage_onStageStartGlobal(Stage stage)
	{
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Expected O, but got Unknown
		List<CharacterMaster> list = CharacterMaster.readOnlyInstancesList.Where((CharacterMaster m) => (Object)(object)m.playerCharacterMasterController != (Object)null).ToList();
		if (list.Count == 0)
		{
			return;
		}
		list = list.OrderBy((CharacterMaster x) => random.Next()).ToList();
		int num = ((list.Count == 1) ? random.Next(0, 2) : (list.Count / 2));
		for (int num2 = 0; num2 < list.Count; num2++)
		{
			CharacterMaster val = list[num2];
			if (num2 < num)
			{
				ConfigurarJogadorComoMonstro(val);
			}
			else
			{
				val.teamIndex = (TeamIndex)1;
			}
		}
		Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
		{
			baseToken = $"<color=#e55b5b>[VERSUS]</color> Partida iniciada! <color=#FF0000>{num} Monstros</color> vs <color=#00FF00>{list.Count - num} Sobreviventes</color>!"
		});
	}

	private void ConfigurarJogadorComoMonstro(CharacterMaster playerMaster)
	{
		//IL_0038: 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_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: 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_0059: Unknown result type (might be due to invalid IL or missing references)
		playerMaster.teamIndex = (TeamIndex)2;
		GameObject val = ObterMonstroValidoDoMapa();
		if ((Object)(object)val != (Object)null)
		{
			playerMaster.bodyPrefab = val;
			Vector3 val2 = (Object.op_Implicit((Object)(object)playerMaster.GetBody()) ? (playerMaster.GetBody().corePosition + new Vector3(5f, 0f, 5f)) : Vector3.zero);
			playerMaster.Respawn(val2, Quaternion.identity, false);
		}
	}

	private GameObject ObterMonstroValidoDoMapa()
	{
		if ((Object)(object)ClassicStageInfo.instance != (Object)null && ClassicStageInfo.instance.monsterSelection != null)
		{
			WeightedSelection<DirectorCard> monsterSelection = ClassicStageInfo.instance.monsterSelection;
			if (monsterSelection.Count > 0)
			{
				float num = (float)random.NextDouble();
				DirectorCard val = monsterSelection.Evaluate(num);
				if (val != null && (Object)(object)val.spawnCard != (Object)null && (Object)(object)val.spawnCard.prefab != (Object)null)
				{
					CharacterMaster component = val.spawnCard.prefab.GetComponent<CharacterMaster>();
					if ((Object)(object)component != (Object)null && (Object)(object)component.bodyPrefab != (Object)null && ((Object)component.bodyPrefab).name != "BeetleBody")
					{
						return component.bodyPrefab;
					}
				}
			}
		}
		return BodyCatalog.FindBodyPrefab("LemurianBody");
	}

	private void GlobalEventManager_onCharacterDeathGlobal(DamageReport damageReport)
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Invalid comparison between Unknown and I4
		if ((Object)(object)damageReport.victimMaster != (Object)null && (Object)(object)damageReport.victimMaster.playerCharacterMasterController != (Object)null)
		{
			CharacterMaster victimMaster = damageReport.victimMaster;
			if ((int)victimMaster.teamIndex == 2 && (!((Object)(object)TeleporterInteraction.instance != (Object)null) || !TeleporterInteraction.instance.isCharged))
			{
				EncarnarEmOutroMonstro(victimMaster);
			}
		}
	}

	private void EncarnarEmOutroMonstro(CharacterMaster playerMaster)
	{
		//IL_0033: 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)
		//IL_0050: 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_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		CharacterMaster val = ((IEnumerable<CharacterMaster>)CharacterMaster.readOnlyInstancesList).FirstOrDefault((Func<CharacterMaster, bool>)((CharacterMaster m) => (int)m.teamIndex == 2 && (Object)(object)m != (Object)(object)playerMaster && m.hasBody && m.GetBody().healthComponent.alive && ((Object)m.bodyPrefab).name != "BeetleBody"));
		if ((Object)(object)val != (Object)null)
		{
			Vector3 corePosition = val.GetBody().corePosition;
			playerMaster.bodyPrefab = val.bodyPrefab;
			playerMaster.Respawn(corePosition, Quaternion.identity, false);
			Object.Destroy((Object)(object)((Component)val.GetBody()).gameObject);
		}
		else
		{
			GameObject bodyPrefab = ObterMonstroValidoDoMapa();
			Vector3 val2 = (Object.op_Implicit((Object)(object)playerMaster.GetBody()) ? playerMaster.GetBody().corePosition : Vector3.zero);
			playerMaster.bodyPrefab = bodyPrefab;
			playerMaster.Respawn(val2, Quaternion.identity, false);
		}
	}

	public void OnDestroy()
	{
		Stage.onStageStartGlobal -= Stage_onStageStartGlobal;
		GlobalEventManager.onCharacterDeathGlobal -= GlobalEventManager_onCharacterDeathGlobal;
	}
}