Decompiled source of Playable Swordsmachine v1.0.1

plugins/PlayableSwordsMachine.dll

Decompiled a year ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.SceneManagement;

[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("PlayableSwordsMachine")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PlayableSwordsMachine")]
[assembly: AssemblyTitle("PlayableSwordsMachine")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PlayableSwordsMachine
{
	[BepInPlugin("com.lazy.mods.playable.swordsmachine", "Playable Swordsmachine", "1.0.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		private GameObject plrswordsmachine;

		private SwordsMachine plrsmcomp;

		private float SMComboCooldown = 0f;

		private float framesSinceSceneChange = 0f;

		private bool dostuff = false;

		private void Update()
		{
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			if (!(SceneHelper.CurrentScene != "Main Menu") || !(SceneHelper.CurrentScene != "Bootstrap") || !dostuff)
			{
				return;
			}
			framesSinceSceneChange += 1f;
			if (framesSinceSceneChange == 10f)
			{
				((Behaviour)plrsmcomp).enabled = false;
			}
			SMComboCooldown -= 4f * Time.deltaTime;
			GameObject val = GameObject.Find("Player/Main Camera");
			GameObject val2 = GameObject.Find("Player");
			NewMovement component = val2.GetComponent<NewMovement>();
			Rigidbody component2 = val2.GetComponent<Rigidbody>();
			CameraController component3 = val.GetComponent<CameraController>();
			component.modNoDashSlide = true;
			component.hp = 2000000100;
			component3.defaultPos = new Vector3(2f, 4f, -2f);
			component3.originalPos = new Vector3(2f, 4f, -2f);
			Animator component4 = plrswordsmachine.GetComponent<Animator>();
			Vector3 velocity = component2.velocity;
			if (((Vector3)(ref velocity)).magnitude > 1f)
			{
				component4.SetTrigger("Running");
			}
			else
			{
				component4.ResetTrigger("Running");
			}
			component.jumpPower = 0f;
			component.modNoJump = true;
			if (Input.GetKeyDown((KeyCode)324) && SMComboCooldown < 0f && SceneHelper.CurrentScene != "Main Menu" && SceneHelper.CurrentScene != "Bootstrap")
			{
				SMComboCooldown = 3f;
				Debug.Log((object)"Doing Swordsmachine Slash Move");
				plrsmcomp.RunningSwing();
			}
			if (Input.GetKeyDown((KeyCode)323) && SMComboCooldown < 0f && SceneHelper.CurrentScene != "Main Menu" && SceneHelper.CurrentScene != "Bootstrap")
			{
				SMComboCooldown = 9f;
				Debug.Log((object)"Doing Swordsmachine Combo Move");
				((Component)plrsmcomp).SendMessage("Combo");
			}
			for (int i = 0; i < ((Component)MonoSingleton<GunControl>.Instance).transform.childCount; i++)
			{
				GameObject gameObject = ((Component)((Component)MonoSingleton<GunControl>.Instance).transform.GetChild(i)).gameObject;
				if (((Object)gameObject).name != "Spawner Arm(Clone) - MoveHand" && ((Object)gameObject).name != "Spawner Arm(Clone) - AlterHand" && ((Object)gameObject).name != "Spawner Arm(Clone) - DestroyHand" && ((Object)gameObject).name != "Spawner Arm(Clone) - Prop")
				{
					gameObject.SetActive(false);
				}
			}
			for (int j = 0; j < ((Component)MonoSingleton<FistControl>.Instance).transform.childCount; j++)
			{
				GameObject gameObject2 = ((Component)((Component)MonoSingleton<GunControl>.Instance).transform.GetChild(j)).gameObject;
				gameObject2.SetActive(false);
			}
		}

		public static T Fetch<T>(string key)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<T>((object)key).WaitForCompletion();
		}

		public static void SendHudMessage(string msg, int delay, bool silent)
		{
			MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage(msg, "", "", delay, silent);
		}

		private void OnSceneChange(Scene before, Scene after)
		{
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			if (SceneHelper.CurrentScene == "Main Menu")
			{
				dostuff = true;
			}
			if (SceneHelper.CurrentScene != "Main Menu" && SceneHelper.CurrentScene != "Bootstrap")
			{
				framesSinceSceneChange = 0f;
				SMComboCooldown = 0f;
				GameObject val = GameObject.Find("Player");
				GameObject.Find("Canvas/HurtScreen").SetActive(false);
				for (int i = 0; i < ((Component)MonoSingleton<GunControl>.Instance).transform.childCount; i++)
				{
					((Component)((Component)MonoSingleton<GunControl>.Instance).transform.GetChild(i)).gameObject.SetActive(false);
				}
				GameObject val2 = new GameObject();
				((Object)val2).name = "SM Target Transform";
				val2.transform.parent = val.transform;
				val2.transform.localPosition = new Vector3(0f, 0f, 50f);
				val2.transform.localRotation = new Quaternion(0f, 0f, 0f, 0f);
				plrswordsmachine = Object.Instantiate<GameObject>(Fetch<GameObject>("Assets/Prefabs/Enemies/SwordsMachineNonboss.prefab"));
				CapsuleCollider component = plrswordsmachine.GetComponent<CapsuleCollider>();
				((Collider)component).enabled = false;
				Debug.Log((object)"Instantiated SM and disabled default collider");
				plrswordsmachine.transform.parent = val.transform;
				plrswordsmachine.transform.position = val.transform.position;
				plrswordsmachine.transform.localScale = new Vector3(0.8f, 0.8f, 0.8f);
				EnemyIdentifier component2 = plrswordsmachine.GetComponent<EnemyIdentifier>();
				plrsmcomp = plrswordsmachine.GetComponent<SwordsMachine>();
				plrsmcomp.firstPhase = false;
				CopyPositionAndRotation val3 = plrswordsmachine.AddComponent<CopyPositionAndRotation>();
				val3.target = val.transform;
				component2.blessed = true;
				component2.ignorePlayer = true;
				component2.attackEnemies = false;
				component2.fallbackTarget = val2.transform;
			}
		}

		private void Awake()
		{
			SceneManager.activeSceneChanged += OnSceneChange;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin PlayableSwordsMachine is loaded!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "PlayableSwordsMachine";

		public const string PLUGIN_NAME = "PlayableSwordsMachine";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}