Decompiled source of Salty Stuff v0.1.1

HolyEnergyDrinks.dll

Decompiled 10 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using GameNetcodeStuff;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.UI;

[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("HolyEnergyDrinks")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HolyEnergyDrinks")]
[assembly: AssemblyTitle("HolyEnergyDrinks")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace HolyEnergyDrinks
{
	public class HolyEnergyItem : GrabbableObject
	{
		private bool hasUsedEnergy;

		public ParticleSystem useParticle;

		public AudioSource useAudioSource;

		public AudioClip useAudioClip;

		public override void ItemActivate(bool used, bool buttonDown = true)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			((GrabbableObject)this).ItemActivate(used, buttonDown);
			if (!((Object)(object)base.playerHeldBy == (Object)null) && !hasUsedEnergy)
			{
				hasUsedEnergy = true;
				base.playerHeldBy.activatingItem = true;
				useAudioSource.PlayOneShot(useAudioClip);
				WalkieTalkie.TransmitOneShotAudio(useAudioSource, useAudioClip, 1f);
				RoundManager.Instance.PlayAudibleNoise(((Component)useAudioSource).transform.position, 8f, 0.5f, 0, base.isInShipRoom && StartOfRound.Instance.hangarDoorsClosed, 0);
				((MonoBehaviour)this).StartCoroutine(Plugin.Instance.TempMoveSpeedBuff(base.playerHeldBy));
				UseHolyEnergyServerRpc();
				((GrabbableObject)this).DestroyObjectInHand(base.playerHeldBy);
			}
		}

		public override void PocketItem()
		{
			((GrabbableObject)this).PocketItem();
			base.playerHeldBy.activatingItem = false;
		}

		[ServerRpc(RequireOwnership = false)]
		public void UseHolyEnergyServerRpc()
		{
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening && (networkManager.IsServer || networkManager.IsHost))
			{
				UseHolyEnergyClientRpc();
			}
		}

		[ClientRpc]
		public void UseHolyEnergyClientRpc()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			NetworkManager networkManager = ((NetworkBehaviour)this).NetworkManager;
			if (!((Object)(object)networkManager == (Object)null) && networkManager.IsListening)
			{
				useAudioSource.PlayOneShot(useAudioClip);
				WalkieTalkie.TransmitOneShotAudio(useAudioSource, useAudioClip, 1f);
				RoundManager.Instance.PlayAudibleNoise(((Component)useAudioSource).transform.position, 8f, 0.5f, 0, base.isInShipRoom && StartOfRound.Instance.hangarDoorsClosed, 0);
				if ((Object)(object)base.playerHeldBy != (Object)null)
				{
					base.playerHeldBy.activatingItem = false;
					((GrabbableObject)this).DestroyObjectInHand(base.playerHeldBy);
				}
			}
		}
	}
	[BepInPlugin("TheBonBon.SaltyStuff", "Salty Stuff", "0.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(HUDManager))]
		internal class HUDManagerPatch
		{
			[HarmonyPostfix]
			[HarmonyPatch("Start")]
			private static void StartPatch(ref HUDManager __instance)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Expected O, but got Unknown
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = GameObject.Find("Systems/UI/Canvas/IngamePlayerHUD/HandsFullText");
				GameObject val2 = new GameObject("BuffIcon");
				val2.transform.SetParent(val.transform, false);
				buffUI = val2.AddComponent<TextMeshProUGUI>();
				((TMP_Text)buffUI).font = ((TMP_Text)__instance.controlTipLines[0]).font;
				((TMP_Text)buffUI).fontSize = 8f;
				((Behaviour)buffUI).enabled = false;
				((Graphic)buffUI).color = Color.white;
				((TMP_Text)buffUI).alignment = (TextAlignmentOptions)514;
				val2.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, -35f);
			}
		}

		private const string modGUID = "TheBonBon.SaltyStuff";

		private const string modName = "Salty Stuff";

		private const string modVersion = "0.0.1";

		public static Plugin Instance;

		private static TextMeshProUGUI buffUI;

		private void Awake()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			if ((Object)(object)Instance == (Object)null)
			{
				Instance = this;
			}
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "holyenergydrinks");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			Harmony val2 = new Harmony("TheBonBon.SaltyStuff");
			val2.PatchAll();
			List<string> list = new List<string>
			{
				"Assets/Items/Hydration/HolyHydrationKiwi.asset", "Assets/Items/Hydration/HolyHydrationGrapefruit.asset", "Assets/Items/Hydration/HolyHydrationPeach.asset", "Assets/Items/Ice/HolyIceRaspberryVanilla.asset", "Assets/Items/Ice/HolyIcePeachNectarine.asset", "Assets/Items/Ice/HolyIceLimeMint.asset", "Assets/Items/Energy/HolyEnergyShark.asset", "Assets/Items/Energy/HolyEnergyBear.asset", "Assets/Items/Energy/HolyEnergyWolf.asset", "Assets/Items/Energy/HolyEnergyCheetah.asset",
				"Assets/Items/Energy/HolyEnergyCobra.asset", "Assets/Items/Energy/HolyEnergyRaptor.asset", "Assets/Items/Shaker/HolyShakerEnergyCobra.asset", "Assets/Items/Shaker/HolyShakerEnergyCheetah.asset", "Assets/Items/Shaker/HolyShakerEnergyWolf.asset", "Assets/Items/Shaker/HolyShakerEnergyShark.asset", "Assets/Items/Shaker/HolyShakerEnergyRaptor.asset", "Assets/Items/Shaker/HolyShakerEnergyBear.asset"
			};
			foreach (string item in list)
			{
				Item val3 = val.LoadAsset<Item>(item);
				NetworkPrefabs.RegisterNetworkPrefab(val3.spawnPrefab);
				Items.RegisterScrap(val3, 40, (LevelTypes)(-1));
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin TheBonBon.SaltyStuff is loaded!");
		}

		public IEnumerator TempMoveSpeedBuff(PlayerControllerB player)
		{
			((Behaviour)buffUI).enabled = true;
			float normalSpeed = player.movementSpeed;
			player.movementSpeed *= 2f;
			for (float buffTime = 60f; buffTime > 0f; buffTime -= 1f)
			{
				((TMP_Text)buffUI).text = "Speed Buff: " + Mathf.CeilToInt(buffTime);
				yield return (object)new WaitForSeconds(1f);
			}
			player.movementSpeed = normalSpeed;
			((Behaviour)buffUI).enabled = false;
		}
	}
}