using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LandShark.Patches;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("LandShark")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LandShark")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d7d99fd6-e68b-43b3-a34e-fad20b40b714")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LandShark
{
[BepInPlugin("Ex.LandShark", "Ex Shark Worm Replacement Mod", "1.0.0")]
public class LandSharkBase : BaseUnityPlugin
{
private const string modGUID = "Ex.LandShark";
private const string modName = "Ex Shark Worm Replacement Mod";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("Ex.LandShark");
private static LandSharkBase Instance;
internal ManualLogSource mls;
public static GameObject sharkModel;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
mls = Logger.CreateLogSource("Ex.LandShark");
mls.LogInfo((object)"Shark Worm Replacement mod has initiated");
string location = ((BaseUnityPlugin)Instance).Info.Location;
string text = "LandShark.dll";
string text2 = location.TrimEnd(text.ToCharArray());
string text3 = text2 + "sharkworm";
AssetBundle val = AssetBundle.LoadFromFile(text3);
if ((Object)(object)val == (Object)null)
{
mls.LogError((object)"Failed to load assets!");
return;
}
sharkModel = val.LoadAsset<GameObject>("Assets/SharkWorm1.prefab");
SkinnedMeshRenderer[] componentsInChildren = sharkModel.GetComponentsInChildren<SkinnedMeshRenderer>(true);
SkinnedMeshRenderer[] array = componentsInChildren;
foreach (SkinnedMeshRenderer val2 in array)
{
((Component)val2).gameObject.layer = LayerMask.NameToLayer("Enemies");
}
harmony.PatchAll(typeof(LandSharkBase));
harmony.PatchAll(typeof(WormPatch));
mls.LogInfo((object)"Der duh, derr duh...");
}
}
}
namespace LandShark.Patches
{
[HarmonyPatch(typeof(SandWormAI))]
internal class WormPatch : MonoBehaviour
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void GiantPreLoadPatch(SandWormAI __instance)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
Transform val = ((Component)__instance).transform.Find("MeshContainer");
SkinnedMeshRenderer val2 = ((val != null) ? ((Component)val.Find("Renderer")).GetComponent<SkinnedMeshRenderer>() : null);
object obj;
if (val == null)
{
obj = null;
}
else
{
Transform obj2 = val.Find("Armature");
obj = ((obj2 != null) ? obj2.Find("Bone") : null);
}
Transform val3 = (Transform)obj;
Debug.Log((object)("Shark Instance " + (object)val3));
if (!((Object)(object)val2 == (Object)null) && ((Renderer)val2).enabled)
{
((Renderer)val2).enabled = false;
Renderer[] componentsInChildren = ((Component)val3).gameObject.GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
foreach (Renderer val4 in array)
{
Debug.Log((object)val4);
Debug.Log((object)val2);
val4.enabled = false;
}
GameObject val5 = Object.Instantiate<GameObject>(LandSharkBase.sharkModel);
val5.transform.SetParent(val);
val5.transform.localPosition = Vector3.zero;
val5.transform.localRotation = Quaternion.identity;
val5.transform.localScale = Vector3.one;
Debug.Log((object)("Shark Instance " + (object)val5));
Transform val6 = val5.transform.Find("body");
Debug.Log((object)("Shark Instance " + (object)val6));
Transform val7 = val5.transform.Find("MeshContainer/Armature/Bone");
Debug.Log((object)("Shark Instance " + (object)val7));
val7.SetParent(val3.parent, true);
((Component)val7).transform.localScale = ((Component)val3).transform.localScale;
((Component)val7).transform.localRotation = ((Component)val3).transform.localRotation;
((Component)val7).transform.localPosition = ((Component)val3).transform.localPosition;
SkinnedMeshRenderer component = ((Component)val6).GetComponent<SkinnedMeshRenderer>();
component.rootBone = val7;
Debug.Log((object)("Shark Instance " + (object)component.rootBone));
((Object)val3).name = "old-metarig";
}
}
}
}