using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using Zorro.Core;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BalloonMerger")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.1.0")]
[assembly: AssemblyInformationalVersion("1.2.1")]
[assembly: AssemblyProduct("BalloonMerger")]
[assembly: AssemblyTitle("BalloonMerger")]
[assembly: AssemblyVersion("1.2.1.0")]
[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.2.1")]
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 balloons into a bundle.");
((BaseUnityPlugin)this).Logger.LogInfo((object)"Мод Balloon Merger успешно загружен! Нажмите 'V (по умолчанию)' для крафта.");
}
private void Update()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(CraftKeyConfig.Value))
{
TryCraftBalloons();
}
}
private void TryCraftBalloons()
{
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
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;
}
for (int i = 0; i < 3; i++)
{
ItemSlot val = player.itemSlots[i];
if (val.IsEmpty() || (Object)(object)val.prefab == (Object)null || ((Object)val.prefab).name.Replace("(Clone)", "").Trim() != "Balloon")
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Крафт отменён: в первых трёх слотах должны лежать шарики!");
return;
}
}
for (byte b = 0; b < 3; b++)
{
player.EmptySlot(Optionable<byte>.Some(b), true);
}
CharacterItems items = Character.localCharacter.refs.items;
if (!((Object)(object)items == (Object)null))
{
MethodInfo methodInfo = AccessTools.Method(typeof(CharacterItems), "SpawnItemInHand", new Type[1] { typeof(string) }, (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!");
}
}
}
}
}