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.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using On;
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("snrk.tbhCreature")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("tbhcreatureHoarderbug")]
[assembly: AssemblyTitle("snrk.tbhCreature")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
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 YippeeBugMod
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "snrk.tbhCreature";
public const string PLUGIN_NAME = "tbh Creature Hoarding Bug Replacement Mod";
public const string PLUGIN_VERSION = "1.0.0";
}
[BepInPlugin("snrk.tbhCreature", "tbh Creature Hoarding Bug Replacement Mod", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static GameObject YipeeBug;
public static AudioClip[] YIPEE;
public static AudioClip YIPEEAngry;
public static Texture2D tbhcreature;
public static Texture2D tbhcreatureGlowTex;
public static Material tbhcreatureMat;
public static Material defaultMaterial;
public static ConfigEntry<bool> useGlowTextures;
private void Awake()
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"tbh Creature Hoarding Bug Replacement Mod v1.0.0 loaded!");
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "tbhcreature");
AssetBundle val = AssetBundle.LoadFromFile(text);
YipeeBug = val.LoadAsset<GameObject>("assets/yipeebug/tbhcreature.prefab");
YIPEE = (AudioClip[])(object)new AudioClip[1] { val.LoadAsset<AudioClip>("assets/yipeebug/yippee.wav") };
YIPEEAngry = val.LoadAsset<AudioClip>("assets/yipeebug/yippee.wav");
tbhcreature = val.LoadAsset<Texture2D>("assets/yipeebug/tbhcreature.png");
tbhcreatureGlowTex = val.LoadAsset<Texture2D>("assets/yipeebug/tbhcreatureGlow.png");
tbhcreatureMat = val.LoadAsset<Material>("assets/yipeebug/tbhcreatureMat.mat");
useGlowTextures = ((BaseUnityPlugin)this).Config.Bind<bool>("tbhcreature", "GlowingEyesTexture", false, "Swap the eyes for a variant that glows in the dark. True = Glowing texture, False = Default");
SkinnedMeshRenderer componentInChildren = YipeeBug.GetComponentInChildren<SkinnedMeshRenderer>();
if ((Object)(object)componentInChildren != (Object)null)
{
defaultMaterial = ((Renderer)componentInChildren).sharedMaterial;
}
SkinnedMeshRenderer[] componentsInChildren = YipeeBug.GetComponentsInChildren<SkinnedMeshRenderer>(true);
SkinnedMeshRenderer[] array = componentsInChildren;
foreach (SkinnedMeshRenderer val2 in array)
{
if (useGlowTextures.Value)
{
((Renderer)val2).material = tbhcreatureMat;
}
else if ((Object)(object)defaultMaterial != (Object)null)
{
((Renderer)val2).material = defaultMaterial;
}
((Component)val2).gameObject.layer = LayerMask.NameToLayer("Enemies");
}
}
}
}
namespace YippeeBugMod.YippeeBug.Patches
{
[HarmonyPatch(typeof(HoarderBugAI), "Start")]
internal class HoarderBugPatch
{
private static void Postfix(HoarderBugAI __instance)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Expected O, but got Unknown
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Expected O, but got Unknown
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Expected O, but got Unknown
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_0246: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
Transform headLookTarget = __instance.headLookTarget;
if ((Object)(object)headLookTarget != (Object)null)
{
headLookTarget.localPosition = Vector3.zero;
}
Transform val = ((Component)__instance).transform.Find("HoarderBugModel");
object obj;
if ((Object)(object)val == (Object)null)
{
obj = null;
}
else
{
Transform val2 = val.Find("Cube");
obj = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<SkinnedMeshRenderer>() : null);
}
Transform val3 = val.Find("Cube.001");
if ((Object)(object)val3 != (Object)null)
{
Transform val4 = Plugin.YipeeBug.transform.Find("Cube.001");
if ((Object)(object)val4 != (Object)null)
{
GameObject val5 = Object.Instantiate<GameObject>(((Component)val4).gameObject);
((Object)val5).name = "Cube.001";
val5.transform.SetParent(val3.parent);
val5.transform.localPosition = val3.localPosition;
val5.transform.localRotation = val3.localRotation;
val5.transform.localScale = val3.localScale;
Object.Destroy((Object)(object)((Component)val3).gameObject);
Debug.Log((object)"replaced 'Cube.001' with 'Cube.001'.");
}
else
{
Debug.LogWarning((object)"'Cube.001' not found in the prefab.");
}
}
else
{
Debug.LogWarning((object)"'Cube.001' not found in the model hierarchy.");
}
SkinnedMeshRenderer val6 = (SkinnedMeshRenderer)obj;
object obj2;
if ((Object)(object)val == (Object)null)
{
obj2 = null;
}
else
{
Transform val7 = val.Find("AnimContainer");
obj2 = (((Object)(object)val7 != (Object)null) ? val7.Find("Armature") : null);
}
Transform val8 = (Transform)obj2;
if (!((Object)val6 == (Object)null) && ((Renderer)val6).enabled)
{
((Renderer)val6).enabled = false;
Renderer[] componentsInChildren = ((Component)val8).gameObject.GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
foreach (Renderer val9 in array)
{
val9.enabled = false;
}
GameObject val10 = Object.Instantiate<GameObject>(Plugin.YipeeBug);
val10.transform.SetParent(val);
val10.transform.localPosition = Vector3.zero;
val10.transform.localRotation = Quaternion.identity;
val10.transform.localScale = Vector3.one;
Transform val11 = val10.transform.Find("tbhcreature");
Transform val12 = val10.transform.Find("HoarderBug/HoarderBugModel/AnimContainer/Armature");
val12.SetParent(val8.parent, true);
((Component)val12).transform.localScale = ((Component)val8).transform.localScale;
((Component)val12).transform.localRotation = ((Component)val8).transform.localRotation;
((Component)val12).transform.localPosition = ((Component)val8).transform.localPosition;
SkinnedMeshRenderer component = ((Component)val11).GetComponent<SkinnedMeshRenderer>();
if (Plugin.useGlowTextures.Value)
{
((Renderer)component).material = Plugin.tbhcreatureMat;
}
else if ((Object)(object)Plugin.defaultMaterial != (Object)null)
{
((Renderer)component).material = Plugin.defaultMaterial;
}
component.rootBone = val12;
GameObject yipeeBug = Plugin.YipeeBug;
Transform val13 = ((Component)__instance).transform.Find("HoarderBugModel/AnimContainer/Armature");
if ((Object)(object)val13 != (Object)null)
{
Debug.Log((object)("[BoneReset] Resetting all bones for: " + ((Object)val13).name));
ResetBones(val13);
}
else
{
Debug.LogWarning((object)"[BoneReset] Root bone not found. Cannot reset bones.");
}
((Object)val8).name = "old-Armature";
__instance.chitterSFX = Plugin.YIPEE;
__instance.angryVoiceSFX = Plugin.YIPEEAngry;
((Component)((Component)__instance).transform).GetComponentInChildren<ScanNodeProperties>().headerText = "tbh creature";
}
}
private static void ResetBones(Transform bone)
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00cb: Expected O, but got Unknown
if ((Object)(object)bone == (Object)null)
{
return;
}
if (((Object)bone).name == "Chest" || ((Object)bone).name == "Head")
{
bone.localRotation = Quaternion.identity;
bone.localPosition = new Vector3(0f, 0.01586331f, 0f);
Debug.Log((object)("[BoneReset] Bone: " + ((Object)bone).name + " - Position preserved, rotation reset."));
}
else
{
bone.localPosition = Vector3.zero;
bone.localRotation = Quaternion.identity;
Debug.Log((object)("[BoneReset] Bone: " + ((Object)bone).name + " - Position and rotation reset."));
}
foreach (Transform item in bone)
{
Transform bone2 = item;
ResetBones(bone2);
}
}
}
}
namespace tbhcreatureHoarderbug
{
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "snrk.tbhCreature";
public const string PLUGIN_NAME = "tbhcreatureHoarderbug";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace tbhcreatureHoarderbug.Hooks
{
public class ExampleTVPatch
{
internal static void SwitchTVPatch(orig_SwitchTVLocalClient original, TVScript self)
{
StartOfRound.Instance.shipRoomLights.SetShipLightsBoolean(self.tvOn);
original.Invoke(self);
}
}
}