using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MauriceSkulls")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MauriceSkulls")]
[assembly: AssemblyTitle("MauriceSkulls")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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]
[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;
}
}
}
namespace MauriceSkullsMod
{
[BepInPlugin("com.yourname.mauriceskulls", "Maurice Skulls Mod", "1.0.0")]
public class MauriceSkullMod : BaseUnityPlugin
{
public static GameObject mauricePrefab;
private void Awake()
{
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"=== MAURICE MOD DEBUG: STARTING AWAKE ===");
string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
string text = Path.Combine(directoryName, "MauriceSkulls", "mauriceprefab.maurice");
if (!File.Exists(text))
{
((BaseUnityPlugin)this).Logger.LogError((object)("DEBUG FATAL ERROR: The file DOES NOT EXIST at: " + text));
return;
}
AssetBundle val = AssetBundle.LoadFromFile(text);
if ((Object)(object)val != (Object)null)
{
mauricePrefab = val.LoadAsset<GameObject>("assets/maurice.prefab");
if ((Object)(object)mauricePrefab != (Object)null)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"DEBUG: SUCCESS! Maurice Prefab found.");
}
}
try
{
Harmony val2 = new Harmony("com.yourname.mauriceskulls");
val2.PatchAll();
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("DEBUG ERROR: Harmony patching failed! " + ex.Message));
}
}
}
[HarmonyPatch(typeof(Skull), "Awake")]
public class SkullReplacementPatch
{
private static void Postfix(Skull __instance)
{
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0182: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
Debug.Log((object)"=== MAURICE MOD DEBUG: A SKULL JUST SPAWNED ===");
if (!((Object)(object)MauriceSkullMod.mauricePrefab != (Object)null))
{
return;
}
string text = ((Object)((Component)__instance).gameObject).name.ToLower();
bool flag = text.Contains("blue") || text.Contains("blu");
bool flag2 = text.Contains("red");
FieldInfo fieldInfo = AccessTools.Field(typeof(Skull), "blue");
bool flag3 = default(bool);
int num;
if (fieldInfo != null)
{
object value = fieldInfo.GetValue(__instance);
if (value is bool)
{
flag3 = (bool)value;
num = 1;
}
else
{
num = 0;
}
}
else
{
num = 0;
}
if (((uint)num & (flag3 ? 1u : 0u)) != 0)
{
flag = true;
}
FieldInfo fieldInfo2 = AccessTools.Field(typeof(Skull), "red");
bool flag4 = default(bool);
int num2;
if (fieldInfo2 != null)
{
object value = fieldInfo2.GetValue(__instance);
if (value is bool)
{
flag4 = (bool)value;
num2 = 1;
}
else
{
num2 = 0;
}
}
else
{
num2 = 0;
}
if (((uint)num2 & (flag4 ? 1u : 0u)) != 0)
{
flag2 = true;
}
MeshRenderer componentInChildren = ((Component)__instance).GetComponentInChildren<MeshRenderer>();
if ((Object)(object)componentInChildren != (Object)null)
{
((Renderer)componentInChildren).enabled = false;
}
SkinnedMeshRenderer componentInChildren2 = ((Component)__instance).GetComponentInChildren<SkinnedMeshRenderer>();
if ((Object)(object)componentInChildren2 != (Object)null)
{
((Renderer)componentInChildren2).enabled = false;
}
GameObject val = Object.Instantiate<GameObject>(MauriceSkullMod.mauricePrefab, ((Component)__instance).transform);
if (!((Object)(object)val != (Object)null))
{
return;
}
val.transform.localPosition = Vector3.zero;
val.transform.localScale = new Vector3(25f, 25f, 25f);
val.transform.localRotation = Quaternion.Euler(0f, 9f, 90f);
Renderer componentInChildren3 = val.GetComponentInChildren<Renderer>();
if ((Object)(object)componentInChildren3 != (Object)null)
{
if (flag)
{
componentInChildren3.material.color = new Color(0f, 0.2f, 1f);
}
else if (flag2)
{
componentInChildren3.material.color = new Color(1f, 0f, 0f);
}
}
Debug.Log((object)"DEBUG: Maurice spawned with deep auto-swapped coloring!");
}
}
}