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 HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
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("DaBabyCrawler")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Replaces thumper with dababy car")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DaBabyCrawler")]
[assembly: AssemblyTitle("DaBabyCrawler")]
[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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace DaBabyCrawler
{
[BepInPlugin("DaBabyCrawler", "DaBabyCrawler", "1.0")]
public class Plugin : BaseUnityPlugin
{
public static AudioClip BiteAudio;
public static AudioClip AngeredAudio;
public static AudioClip ShortRoar;
public static AudioClip dieSFX;
public static GameObject DaBabyModel;
public static string pluginDir;
public static AssetBundle AlBundle;
private void Awake()
{
pluginDir = ((BaseUnityPlugin)this).Info.Location;
LoadAssets();
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
}
private static void LoadAssets()
{
try
{
AlBundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(pluginDir), "dababybundle"));
}
catch (Exception ex)
{
Debug.LogError((object)("DaBabyCrawler: AssetBundle failed to load -- " + ex.Message));
return;
}
try
{
DaBabyModel = AlBundle.LoadAsset<GameObject>("dababy2.prefab");
Debug.Log((object)$"DaBabyCrawler: GameObject is loaded as {DaBabyModel}");
BiteAudio = AlBundle.LoadAsset<AudioClip>("letsgoshort.wav");
ShortRoar = AlBundle.LoadAsset<AudioClip>("ipullup.wav");
AngeredAudio = AlBundle.LoadAsset<AudioClip>("lessgoLOUD.wav");
dieSFX = AlBundle.LoadAsset<AudioClip>("die.wav");
Debug.Log((object)"DaBabyCrawler: Successfully loaded assets.");
}
catch (Exception ex2)
{
Debug.LogError((object)("DaBabyCrawler: Failed to load assets -- " + ex2.Message));
}
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "DaBabyCrawler";
public const string PLUGIN_NAME = "DaBabyCrawler";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace DaBabyCrawler.Patches
{
[HarmonyPatch(typeof(CrawlerAI))]
internal class CrawlerReplace
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void SummonDababy(CrawlerAI __instance)
{
Transform transform = ((Component)__instance).transform;
Renderer[] componentsInChildren = ((Component)transform).GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
Renderer[] array2 = array;
foreach (Renderer val in array2)
{
val.enabled = false;
}
GameObject val2 = InstantiateDababy(transform);
((EnemyAI)__instance).creatureAnimator = val2.GetComponent<Animator>();
__instance.shortRoar = Plugin.ShortRoar;
__instance.bitePlayerSFX = Plugin.BiteAudio;
__instance.longRoarSFX = (AudioClip[])(object)new AudioClip[2]
{
Plugin.AngeredAudio,
Plugin.ShortRoar
};
((EnemyAI)__instance).dieSFX = Plugin.dieSFX;
}
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
public static void KillEnemy(CrawlerAI __instance)
{
Debug.Log((object)$"DaBabyCrawler: Killed Dababy {__instance}");
((EnemyAI)__instance).creatureAnimator.SetBool("isDead", true);
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
public static void CrawlerUpdate(CrawlerAI __instance, ref float ___averageVelocity)
{
((EnemyAI)__instance).creatureAnimator.SetFloat("Speed", ___averageVelocity);
((EnemyAI)__instance).creatureAnimator.SetFloat("WalkMult", ___averageVelocity + 1f);
}
private static GameObject InstantiateDababy(Transform parent)
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)Plugin.DaBabyModel == (Object)null))
{
GameObject val = Object.Instantiate<GameObject>(Plugin.DaBabyModel);
val.transform.SetParent(parent);
val.transform.localPosition = Vector3.zero;
val.transform.localRotation = Quaternion.identity;
val.transform.localScale = new Vector3(1f, 1f, 1f);
((Renderer)val.GetComponentInChildren<MeshRenderer>()).enabled = true;
Debug.Log((object)("DaBabyCrawler: DaBaby Instance: " + (object)val));
return val;
}
return null;
}
[HarmonyPatch("BeginChasingPlayerClientRpc")]
[HarmonyPostfix]
[ClientRpc]
private static void StartDababySound(CrawlerAI __instance)
{
if (!((Object)(object)Plugin.AngeredAudio == (Object)null))
{
((EnemyAI)__instance).creatureSFX.PlayOneShot(Plugin.AngeredAudio, 0.6f);
WalkieTalkie.TransmitOneShotAudio(((EnemyAI)__instance).creatureSFX, Plugin.AngeredAudio, 0.6f);
}
}
[HarmonyPatch("EatPlayerBodyClientRpc")]
[HarmonyPostfix]
[ClientRpc]
public static void StopDababySound(CrawlerAI __instance)
{
if (!((Object)(object)Plugin.AngeredAudio == (Object)null) && ((EnemyAI)__instance).creatureSFX.isPlaying)
{
((EnemyAI)__instance).creatureSFX.Stop();
}
}
}
public class DaBabyAudio : MonoBehaviour
{
private Animator animator;
private AudioSource audioSource;
private void Start()
{
animator = ((Component)this).gameObject.GetComponent<Animator>();
audioSource = ((Component)this).gameObject.GetComponentInChildren<AudioSource>();
}
private void Update()
{
if (animator.GetBool("isDead") && !audioSource.mute)
{
Debug.Log((object)"DaBabyCrawler: Stopping clip...");
audioSource.mute = true;
}
}
}
}