Decompiled source of MediocratesRandomMonsterTurret v1.0.1

MediocratesRandomMonsterTurret.dll

Decompiled 2 months ago
using System.Collections.Generic;
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.Logging;
using On.RoR2;
using RoR2;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("MediocratesRandomMonsterTurret")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MediocratesRandomMonsterTurret")]
[assembly: AssemblyTitle("MediocratesRandomMonsterTurret")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace MediocratesRandomMonsterTurret;

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);
	}
}
[BepInPlugin("MediocratesLIVE.MediocratesRandomMonsterTurretPlugin", "MediocratesRandomMonsterTurretPlugin", "1.3.0")]
public class MediocratesRandomMonsterTurretPlugin : BaseUnityPlugin
{
	public const string PluginGUID = "MediocratesLIVE.MediocratesRandomMonsterTurretPlugin";

	public const string PluginAuthor = "MediocratesLIVE";

	public const string PluginName = "MediocratesRandomMonsterTurretPlugin";

	public const string PluginVersion = "1.3.0";

	public void Awake()
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Expected O, but got Unknown
		Log.Init(((BaseUnityPlugin)this).Logger);
		CharacterBody.OnSkillActivated += new hook_OnSkillActivated(OnSkillActivated);
	}

	private void Update()
	{
	}

	private void OnSkillActivated(orig_OnSkillActivated orig, CharacterBody self, GenericSkill skill)
	{
		if (Object.op_Implicit((Object)(object)self.master) && Object.op_Implicit((Object)(object)self.master.playerCharacterMasterController) && IsSkillMatched(skill))
		{
			Log.Info("is turret: " + skill.skillDef.skillName);
			SpawnEngineerAlly(self);
		}
		else
		{
			orig.Invoke(self, skill);
		}
	}

	private bool IsSkillMatched(GenericSkill skill)
	{
		string text = skill.skillDef.skillName.ToLower();
		List<string> list = new List<string> { "turret", "engi" };
		foreach (string item in list)
		{
			if (text.Contains(item))
			{
				return true;
			}
		}
		return false;
	}

	private void SpawnEngineerAlly(CharacterBody summonerBody)
	{
		//IL_0023: 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)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: 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_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Expected O, but got Unknown
		if ((Object)(object)summonerBody == (Object)null || (Object)(object)summonerBody.master == (Object)null)
		{
			return;
		}
		Vector3 position = summonerBody.corePosition + new Vector3(3f, 0f, 0f);
		GameObject val = MasterCatalog.FindMasterPrefab("EngiMonsterMaster");
		if ((Object)(object)val != (Object)null)
		{
			Log.Info("Spawning friendly Engineer!");
			MasterSummon val2 = new MasterSummon
			{
				masterPrefab = val,
				position = position,
				rotation = Quaternion.identity,
				summonerBodyObject = ((Component)summonerBody).gameObject,
				teamIndexOverride = (TeamIndex)1,
				ignoreTeamMemberLimit = true
			};
			CharacterMaster val3 = val2.Perform();
			if ((Object)(object)val3 != (Object)null && Object.op_Implicit((Object)(object)val3.GetBody()))
			{
				Log.Info("Friendly Engineer spawned successfully!");
			}
		}
		else
		{
			Log.Info("Could not find Engineer Master prefab!");
		}
	}

	public void OnDisable()
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		CharacterBody.OnSkillActivated -= new hook_OnSkillActivated(OnSkillActivated);
	}
}