Decompiled source of ConsoleTweaks v0.1.0

CommandsTweaks.dll

Decompiled 7 months ago
using System;
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 System.Text;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using Zorro.Core.CLI;

[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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CommandsTweaks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ConsoleTweaks")]
[assembly: AssemblyTitle("CommandsTweaks")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 ConsoleTweaks
{
	[ContentWarningPlugin("CommandsTweaks", "1.0.0", false)]
	[BepInPlugin("CommandsTweaks", "ConsoleTweaks", "1.0.0")]
	public class ConsoleTweaks : BaseUnityPlugin
	{
		public static ConsoleTweaks Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Patch();
			Logger.LogInfo((object)"CommandsTweaks v1.0.0 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: 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)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("CommandsTweaks");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	internal class PlayerTweaks
	{
		[ConsoleCommand]
		public static void Revive()
		{
			Player[] array = Object.FindObjectsOfType<Player>();
			for (int i = 0; i < array.Length; i++)
			{
				array[i].CallRevive();
			}
		}

		[ConsoleCommand]
		public static void ReviveMe()
		{
			Player.localPlayer.CallRevive();
		}

		[ConsoleCommand]
		public static void SetHealthMe(int health)
		{
			Player.localPlayer.data.health = health;
		}

		[ConsoleCommand]
		public static void SetHealthAll(int health)
		{
			Player[] array = Object.FindObjectsOfType<Player>();
			Player[] array2 = array;
			foreach (Player val in array2)
			{
				val.data.health = health;
			}
		}

		[ConsoleCommand]
		public static void SetMaxOxygenMe(int max)
		{
			Player.localPlayer.data.maxOxygen = max;
		}

		[ConsoleCommand]
		public static void SetMaxOxygenAll(int max)
		{
			Player[] array = Object.FindObjectsOfType<Player>();
			Player[] array2 = array;
			foreach (Player val in array2)
			{
				val.data.maxOxygen = max;
			}
		}

		[ConsoleCommand]
		public static void SetMassMe(int mass)
		{
			Player.localPlayer.data.totalMass = mass;
		}
	}
	internal class LobbyTweaks
	{
		private static float originalFixedDeltaTime;

		private static float originalTimeScale = 1f;

		private static bool isTimeStopped = false;

		private static Dictionary<Rigidbody, bool> originalKinematicStates = new Dictionary<Rigidbody, bool>();

		private static Vector3[] playerVelocities;

		[ConsoleCommand]
		public static void ShowPartyInfo()
		{
			if (!PhotonNetwork.IsConnected || PhotonNetwork.LocalPlayer == null)
			{
				Debug.LogError((object)"PhotonNetwork is not connected or LocalPlayer is not initialized.");
				return;
			}
			Player[] array = Object.FindObjectsOfType<Player>();
			if (array == null || array.Length == 0)
			{
				Debug.Log((object)"No players in the party.");
				return;
			}
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("Party Information:");
			Player[] array2 = array;
			foreach (Player val in array2)
			{
				string value = $"Player: {val.refs.view.Owner.NickName}, Actor Number: {val.refs.view.Owner.UserId}, Is Master: {val.refs.view.Owner.IsMasterClient}, TagObject: {val.refs.view.Owner.TagObject}";
				stringBuilder.AppendLine(value);
			}
			Debug.Log((object)stringBuilder.ToString());
		}

		[ConsoleCommand]
		public static void StopTime()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			if (isTimeStopped)
			{
				return;
			}
			isTimeStopped = true;
			GameObject[] array = GameObject.FindGameObjectsWithTag("Player");
			playerVelocities = (Vector3[])(object)new Vector3[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				Rigidbody component = array[i].GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					playerVelocities[i] = component.velocity;
					component.isKinematic = true;
				}
			}
		}

		[ConsoleCommand]
		public static void StartTime()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if (!isTimeStopped)
			{
				return;
			}
			isTimeStopped = false;
			GameObject[] array = GameObject.FindGameObjectsWithTag("Player");
			for (int i = 0; i < array.Length; i++)
			{
				Rigidbody component = array[i].GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.isKinematic = false;
					component.velocity = playerVelocities[i];
				}
			}
		}

		[ConsoleCommand]
		public static void SetTickRate(float tickrate)
		{
			float num = originalFixedDeltaTime / tickrate;
			Time.timeScale = tickrate;
			if (tickrate < 0.5f)
			{
				Time.fixedDeltaTime *= 2f;
			}
			else
			{
				Time.fixedDeltaTime = Mathf.Max(num, 0.0001f);
			}
		}
	}
	internal enum LobbyEvent : byte
	{
		StopTimeForPlayers = 1,
		StartTimeForPlayers,
		SetTickRateForPlayers
	}
	internal class MonsterTweaks
	{
		[ConsoleCommand]
		public static void BigSlap()
		{
			MonsterSpawner.SpawnMonster("BigSlap");
		}

		[ConsoleCommand]
		public static void SpawnMonsters(string monster, int amount)
		{
			for (int i = 0; i < amount; i++)
			{
				MonsterSpawner.SpawnMonster(monster);
			}
		}
	}
	internal class CheatTweaks
	{
		[ConsoleCommand]
		public static void SpawnItems(Item item, int amount)
		{
			for (int i = 0; i < amount; i++)
			{
				Item.SpawnItem(item);
			}
		}

		[ConsoleCommand]
		public static void KillPlayers()
		{
			Player[] array = Object.FindObjectsOfType<Player>();
			for (int i = 0; i < array.Length; i++)
			{
				array[i].RPCA_PlayerDie();
			}
		}

		[ConsoleCommand]
		public static void Noclip()
		{
			GameObject val = GameObject.FindWithTag("Player");
			if ((Object)(object)val != (Object)null)
			{
				CharacterController component = val.GetComponent<CharacterController>();
				if ((Object)(object)component != (Object)null)
				{
					((Collider)component).enabled = false;
					val.GetComponent<Collider>().enabled = false;
					Debug.Log((object)"Noclip enabled for local player.");
				}
				else
				{
					Debug.LogWarning((object)"CharacterController component not found.");
				}
			}
			else
			{
				Debug.LogWarning((object)"Local player not found.");
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "CommandsTweaks";

		public const string PLUGIN_NAME = "ConsoleTweaks";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ConsoleTweaks.Patches
{
	[HarmonyPatch(typeof(ShoppingCart))]
	public class ExampleShoppingCartPatch
	{
		[HarmonyPatch("AddItemToCart")]
		[HarmonyPostfix]
		private static void AddItemToCartPostfix(ShoppingCart __instance)
		{
			AccessTools.PropertySetter(typeof(ShoppingCart), "CartValue").Invoke(__instance, new object[1] { __instance.CartValue + new Random().Next(0, 100) });
		}
	}
}