using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Needleforge;
using Needleforge.Data;
using TeamCherry.Localization;
using TuneWeaver;
using TuneWeaver.Data;
using UnityEngine;
[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("HornetSings")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.4.0")]
[assembly: AssemblyInformationalVersion("0.2.4+a31ae7b115f74484c5b3576b6b828fa4f9b68bb3")]
[assembly: AssemblyProduct("HornetSings")]
[assembly: AssemblyTitle("HornetSings")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/GamingInfinite/HornetSings")]
[assembly: NeutralResourcesLanguage("EN")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.4.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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")]
[Microsoft.CodeAnalysis.Embedded]
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")]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace Microsoft.CodeAnalysis
{
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace HornetSings
{
[BepInPlugin("io.github.gaminginfinite.hornetsings", "HornetSings", "0.2.4")]
public class HornetSingsPlugin : BaseUnityPlugin
{
public static ManualLogSource logSource;
public static AssetBundle modBundle;
public static ToolData shermaBell;
public static SongData shermaSong;
public static GameObject Anim;
public FsmTemplate _trackedNeedolin;
public static Harmony harmony;
public const string Id = "io.github.gaminginfinite.hornetsings";
public static string Name => "HornetSings";
public static string Version => "0.2.4";
private void Awake()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Expected O, but got Unknown
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
logSource = ((BaseUnityPlugin)this).Logger;
harmony = new Harmony("voidbaroness.hornetshermasong");
modBundle = ModHelper.LoadBundleFromAssembly("HornetSings.Resources.AssetBundles.hornetshermasing");
Anim = modBundle.LoadAsset<GameObject>("assets/hornetshermasong/hornetshermaanim.prefab");
modBundle.LoadAsset<GameObject>("path/to/prefab");
((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin " + Name + " (io.github.gaminginfinite.hornetsings) has loaded!"));
harmony.PatchAll();
string[] allAssetNames = modBundle.GetAllAssetNames();
for (int i = 0; i < allAssetNames.Length; i++)
{
ModHelper.Log(allAssetNames[i]);
}
AudioClip val = modBundle.LoadAsset<AudioClip>("assets/hornetshermasong/hornet_sing.wav");
shermaSong = TuneWeaverPlugin.RegisterSong("hornetshermasong", val);
shermaSong.AssignAnims("hornetShermaSingStart", "", "hornetShermaSing", "");
Texture2D val2 = ModHelper.LoadTexFromAssembly("HornetSings.Resources.Images.hornetBell.png");
Sprite val3 = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 420f);
shermaBell = NeedleforgePlugin.AddTool("Sherma's Bell", (ToolItemType)2, new LocalisedString
{
Key = "ShermaBellTool",
Sheet = "Mods.io.github.gaminginfinite.hornetsings"
}, new LocalisedString
{
Key = "ShermaBellToolDesc",
Sheet = "Mods.io.github.gaminginfinite.hornetsings"
}, val3);
TuneWeaverPlugin.ActivationCheck = (Action)Delegate.Combine(TuneWeaverPlugin.ActivationCheck, (Action)delegate
{
if (shermaBell.IsEquipped)
{
shermaSong.Activate();
}
else
{
shermaSong.Deactivate();
}
});
}
}
internal class ModHelper
{
public static void Log(string msg)
{
HornetSingsPlugin.logSource.LogInfo((object)msg);
}
public static void LogError(string msg)
{
HornetSingsPlugin.logSource.LogError((object)msg);
}
public static AssetBundle? LoadBundleFromAssembly(string resourceName)
{
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
if (stream == null)
{
LogError("Couldnt load resoruce lol");
return null;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
return AssetBundle.LoadFromMemory(array);
}
public static Texture2D LoadTexFromAssembly(string resourceName)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_0049: Expected O, but got Unknown
using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName);
if (stream == null)
{
LogError("Couldnt load resoruce lol");
return null;
}
byte[] array = new byte[stream.Length];
stream.Read(array, 0, array.Length);
Texture2D val = new Texture2D(2, 2, (TextureFormat)72, false);
ImageConversion.LoadImage(val, array);
return val;
}
}
}
namespace HornetSings.Patches
{
[HarmonyPatch(typeof(HeroController), "Start")]
internal class AddAnims
{
[HarmonyPostfix]
public static void Postfix(HeroController __instance)
{
tk2dSpriteAnimation component = HornetSingsPlugin.Anim.GetComponent<tk2dSpriteAnimation>();
component.isValid = false;
component.ValidateLookup();
tk2dSpriteAnimation library = __instance.AnimCtrl.animator.Library;
tk2dSpriteAnimationClip[] clips = library.clips;
tk2dSpriteAnimationClip[] clips2 = component.clips;
int num = 0;
tk2dSpriteAnimationClip[] array = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[clips.Length + clips2.Length];
ReadOnlySpan<tk2dSpriteAnimationClip> readOnlySpan = new ReadOnlySpan<tk2dSpriteAnimationClip>(clips);
readOnlySpan.CopyTo(new Span<tk2dSpriteAnimationClip>(array).Slice(num, readOnlySpan.Length));
num += readOnlySpan.Length;
ReadOnlySpan<tk2dSpriteAnimationClip> readOnlySpan2 = new ReadOnlySpan<tk2dSpriteAnimationClip>(clips2);
readOnlySpan2.CopyTo(new Span<tk2dSpriteAnimationClip>(array).Slice(num, readOnlySpan2.Length));
num += readOnlySpan2.Length;
library.clips = array;
library.isValid = false;
library.ValidateLookup();
}
}
}