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 BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("VACNET")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("VACNET")]
[assembly: AssemblyTitle("VACNET")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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 BalloonMerger
{
[BepInPlugin("com.gedisu.balloonmerger", "Balloon Merger", "1.0.0")]
public class BalloonMergerPlugin : BaseUnityPlugin
{
public static ConfigEntry<KeyCode> CraftKeyConfig;
private void Awake()
{
CraftKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "CraftHotkey", (KeyCode)118, "Key used to combine 3 single ballons into a bundle.");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Мод Balloon Merger успешно загружен! Нажмите 'V(as default)' для крафта.");
}
private void Update()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(CraftKeyConfig.Value))
{
TryCraftBalloons();
}
}
private void TryCraftBalloons()
{
if ((Object)(object)Character.localCharacter == (Object)null || (Object)(object)Character.localCharacter.player == (Object)null)
{
return;
}
Player player = Character.localCharacter.player;
if (player.itemSlots == null || player.itemSlots.Length < 3)
{
return;
}
bool flag = true;
for (int i = 0; i < 3; i++)
{
ItemSlot val = player.itemSlots[i];
if (val.IsEmpty() || (Object)(object)val.prefab == (Object)null)
{
flag = false;
break;
}
string text = ((Object)val.prefab).name.Replace("(Clone)", "").Trim();
if (text != "Balloon")
{
flag = false;
break;
}
}
if (!flag)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Крафт отменен: в первых трех слотах должны лежать шарики!");
return;
}
for (byte b = 0; b < 3; b++)
{
player.itemSlots[b].EmptyOut();
if (!PhotonNetwork.IsMasterClient)
{
((MonoBehaviourPun)player).photonView.RPC("RPCRemoveItemFromSlot", (RpcTarget)2, new object[1] { b });
}
}
CharacterItems items = Character.localCharacter.refs.items;
if ((Object)(object)items != (Object)null)
{
MethodInfo methodInfo = AccessTools.Method(((object)items).GetType(), "SpawnItemInHand", (Type[])null, (Type[])null);
if (methodInfo != null)
{
methodInfo.Invoke(items, new object[1] { "BalloonBunch" });
((BaseUnityPlugin)this).Logger.LogInfo((object)"Успешный вызов SpawnItemInHand для связки шаров!");
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)"Не удалось найти метод SpawnItemInHand в классе CharacterItems!");
}
}
}
}
}