Decompiled source of EveryItemBonks v1.0.0

plugins/com.github.MusicallyUntalented.EveryItemBonks.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("com.github.MusicallyUntalented.EveryItemBonks")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("com.github.MusicallyUntalented.EveryItemBonks")]
[assembly: AssemblyTitle("EveryItemBonks")]
[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace EveryItemBonks
{
	[BepInPlugin("com.MusicallyUntalented.EveryItemBonks", "Every Items Bonk", "1.1.0")]
	public class Plugin : BaseUnityPlugin, IConnectionCallbacks, IMatchmakingCallbacks
	{
		private class Patcher
		{
			[HarmonyPatch(typeof(Item), "Start")]
			[HarmonyPostfix]
			public static void ItemStartPostfix(Item __instance)
			{
				if (!((Object)(object)__instance != (Object)null))
				{
					return;
				}
				Bonkable component = ((Component)__instance).gameObject.GetComponent<Bonkable>();
				if ((Object)(object)component == (Object)null)
				{
					component = ((Component)__instance).gameObject.AddComponent<Bonkable>();
					float num = 400f;
					if (PhotonNetwork.InRoom && ((Dictionary<object, object>)(object)((RoomInfo)PhotonNetwork.CurrentRoom).CustomProperties).TryGetValue((object)"BonkingPower", out object value) && value is float num2)
					{
						num = num2;
					}
					component.bonkCooldown = 1f;
					component.bonkForce = num;
					component.bonkRange = 1f;
					component.minBonkVelocity = 10f;
					component.ragdollTime = 1f;
					ManualLogSource log = Log;
					if (log != null)
					{
						log.LogInfo((object)$"Bonkable added to {((Object)__instance).name} with force: {num}");
					}
				}
			}
		}

		internal static ManualLogSource Log;

		public static ConfigEntry<float> BonkingPower { get; set; }

		private void Awake()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			BonkingPower = ((BaseUnityPlugin)this).Config.Bind<float>("General", "BonkingPower", 400f, "The force of the bonking (Default=400f, Host-Dependant) note: doesn't have any effect unfortunately, mainly for testing");
			Log = ((BaseUnityPlugin)this).Logger;
			PhotonNetwork.AddCallbackTarget((object)this);
			new Harmony("com.MusicallyUntalented.EveryItemsBonk").PatchAll(typeof(Patcher));
			Log.LogInfo((object)"EveryItemBonks plugin loaded.");
		}

		public void OnJoinedRoom()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0027: Expected O, but got Unknown
			if (PhotonNetwork.IsMasterClient)
			{
				Hashtable val = new Hashtable();
				((Dictionary<object, object>)val).Add((object)"BonkingPower", (object)BonkingPower.Value);
				Hashtable val2 = val;
				PhotonNetwork.CurrentRoom.SetCustomProperties(val2, (Hashtable)null, (WebFlags)null);
				Log.LogInfo((object)$"Host set BonkingPower room property: {BonkingPower.Value}");
			}
		}

		public void OnConnected()
		{
		}

		public void OnConnectedToMaster()
		{
		}

		public void OnDisconnected(DisconnectCause cause)
		{
			throw new NotImplementedException();
		}

		public void OnRegionListReceived(RegionHandler regionHandler)
		{
		}

		public void OnCustomAuthenticationResponse(Dictionary<string, object> data)
		{
			throw new NotImplementedException();
		}

		public void OnCustomAuthenticationFailed(string debugMessage)
		{
		}

		public void OnFriendListUpdate(List<FriendInfo> friendList)
		{
		}

		void IMatchmakingCallbacks.OnFriendListUpdate(List<FriendInfo> friendList)
		{
			OnFriendListUpdate(friendList);
		}

		public void OnCreatedRoom()
		{
		}

		public void OnCreateRoomFailed(short returnCode, string message)
		{
		}

		public void OnJoinRoomFailed(short returnCode, string message)
		{
		}

		public void OnJoinRandomFailed(short returnCode, string message)
		{
		}

		public void OnLeftRoom()
		{
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}