using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
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 UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("HideosKojimass")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HideosKojimass")]
[assembly: AssemblyTitle("HideosKojimass")]
[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 HideosKojimass
{
public class AssetStorage : MonoBehaviour
{
private static AssetStorage _instance;
private AssetBundle _bundle;
public static AssetStorage Instance => _instance;
private void Awake()
{
if ((Object)(object)_instance == (Object)null)
{
_instance = this;
}
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
_bundle = AssetBundle.LoadFromFile(Path.Combine(directoryName, "hideos_kojimass"));
if ((Object)(object)_bundle == (Object)null)
{
HideosKojimass.Logger.LogError((object)"Failed to load bundle");
}
}
public T LoadAsset<T>(string path) where T : Object
{
return _bundle.LoadAsset<T>(path);
}
}
[BepInPlugin("com.d4navi0.HideosKojimass", "Hideos Kojimass", "1.0.0")]
public class HideosKojimass : BaseUnityPlugin
{
internal class HideosKojimassInfo
{
internal const string NAME = "Hideos Kojimass";
internal const string GUID = "com.d4navi0.HideosKojimass";
internal const string VERSION = "1.0.0";
}
internal static ManualLogSource Logger;
private readonly Harmony harmony = new Harmony("com.d4navi0.HideosKojimass");
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"hideos kojimass");
((Component)this).gameObject.AddComponent<AssetStorage>();
harmony.PatchAll();
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "HideosKojimass";
public const string PLUGIN_NAME = "HideosKojimass";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace HideosKojimass.Patches
{
[HarmonyPatch(typeof(MassAnimationReceiver), "Start")]
public class MassAnimationReceiver_Start_Patch
{
private static void Postfix(MassAnimationReceiver __instance)
{
HideosKojimass.Logger.LogInfo((object)"replacing hideos kojimass texture");
Texture2D mainTexture = AssetStorage.Instance.LoadAsset<Texture2D>("hideos_kojimass");
EnemySimplifier[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<EnemySimplifier>();
if (componentsInChildren.Length == 0)
{
HideosKojimass.Logger.LogInfo((object)"no simplifiers so i guess its a fake, falling back to manual replace");
((Renderer)((Component)((Component)__instance).transform.Find("Body")).GetComponent<SkinnedMeshRenderer>()).material.mainTexture = (Texture)(object)mainTexture;
}
EnemySimplifier[] array = componentsInChildren;
foreach (EnemySimplifier obj in array)
{
obj.ChangeTexture((MaterialState)0, (Texture)(object)AssetStorage.Instance.LoadAsset<Texture2D>("hideos_kojimass"));
obj.ChangeTexture((MaterialState)2, (Texture)(object)AssetStorage.Instance.LoadAsset<Texture2D>("hideos_kojimass_enraged"));
}
}
}
[HarmonyPatch(typeof(Mass), "Start")]
public class Mass_Start_Patch
{
private static void Postfix(Mass __instance)
{
BossHealthBar component = ((Component)__instance).GetComponent<BossHealthBar>();
if (!((Object)(object)component == (Object)null))
{
HideosKojimass.Logger.LogInfo((object)"replacing hideos kojimass boss bar");
component.ChangeName("Hideos Kojimass");
}
}
}
}