using System;
using System.Collections.Generic;
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 UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("CoolBracken")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Cool Bracken")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CoolBracken")]
[assembly: AssemblyTitle("CoolBracken")]
[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 CoolBracken
{
[HarmonyPatch(typeof(FlowermanAI))]
public static class CoolBrackenPatch
{
public static AudioClip GetRandomAudio()
{
return CoolBrackenBase.AngerSounds[Random.Range(0, 5)];
}
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void Postfix(FlowermanAI __instance)
{
GetRandomAudio();
AudioClip val = CoolBrackenBase.Assets.LoadAsset<AudioClip>("brackson-kill.mp3");
SwapAngerAudio(__instance);
__instance.crackNeckSFX = val;
__instance.crackNeckAudio.clip = val;
SkinnedMeshRenderer component = ((Component)((Component)__instance).gameObject.transform.Find("FlowermanModel").Find("LOD1")).gameObject.GetComponent<SkinnedMeshRenderer>();
Material val2 = CoolBrackenBase.Assets.LoadAsset<Material>("brackson-material.mat");
if ((Object)(object)val2 == (Object)null)
{
Debug.Log((object)"Failed to load custom asset: Brackson-Material");
}
((Renderer)component).SetMaterials(new List<Material>
{
val2,
((Renderer)component).materials[1]
});
((Component)__instance).gameObject.AddComponent<CoolBrackenSoundPlayerScript>();
}
[HarmonyPatch("LookAtFlowermanTrigger")]
[HarmonyPostfix]
public static void LookAtFlowermanTriggerPatch(FlowermanAI __instance)
{
CoolBrackenSoundPlayerScript component = ((Component)__instance).GetComponent<CoolBrackenSoundPlayerScript>();
component.UpdateSightedPlayer();
if (!((EnemyAI)__instance).creatureSFX.isPlaying && !__instance.creatureAngerVoice.isPlaying && component.canPlayAudio)
{
Debug.Log((object)"CMB - Playing audtio from TriggerPatch");
((EnemyAI)__instance).creatureSFX.PlayOneShot(GetRandomAudio());
SwapAngerAudio(__instance);
}
}
public static void SwapAngerAudio(FlowermanAI __instance)
{
((EnemyAI)__instance).creatureSFX.clip = GetRandomAudio();
((EnemyAI)__instance).enemyBehaviourStates[1].VoiceClip = ((EnemyAI)__instance).creatureSFX.clip;
}
}
[HarmonyPatch(typeof(EnemyAI))]
public static class CoolBrackenEnemyAIPatch
{
[HarmonyPatch("PlayAudioOfCurrentState")]
[HarmonyPostfix]
public static void PlayAudioOfCurrentState(EnemyAI __instance)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Expected O, but got Unknown
if (((object)__instance).GetType() == typeof(FlowermanAI))
{
CoolBrackenPatch.SwapAngerAudio((FlowermanAI)__instance);
}
}
}
public class CoolBrackenSoundPlayerScript : MonoBehaviour
{
public bool canPlayAudio = true;
public float audioDelayTime;
public bool UpdateSightedPlayer()
{
if (canPlayAudio)
{
return true;
}
canPlayAudio = false;
audioDelayTime = 25f;
return false;
}
public void SetNeutralState()
{
canPlayAudio = true;
}
private void Update()
{
if (!canPlayAudio)
{
audioDelayTime -= Time.deltaTime;
if (audioDelayTime <= 0f)
{
canPlayAudio = true;
}
}
}
}
[BepInPlugin("Bobbyboy222.CoolBracken", "Cool Bracken", "1.0.0")]
public class CoolBrackenBase : BaseUnityPlugin
{
private const string modGUID = "Bobbyboy222.CoolBracken";
private const string modName = "Cool Bracken";
private const string modVersion = "1.0.0";
private Harmony harmony;
public static TextAsset TerminalText;
public static AssetBundle Assets;
public static List<AudioClip> AngerSounds;
public const int AUDIO_COUNT = 5;
private void Awake()
{
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
AngerSounds = new List<AudioClip>();
Assets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "brackson"));
if ((Object)(object)Assets == (Object)null)
{
Debug.Log((object)"CBM - Failed to load custom assets.");
return;
}
for (int i = 1; i <= 5; i++)
{
AngerSounds.Add(Assets.LoadAsset<AudioClip>($"brackson anger{i}.mp3"));
}
harmony = new Harmony("CoolBracken");
harmony.PatchAll();
Debug.Log((object)"CBM - COOL BRACKEN LOADED");
}
}
[HarmonyPatch(typeof(Terminal))]
public class TerminalPatches
{
[HarmonyPatch("BeginUsingTerminal")]
[HarmonyPostfix]
public static void BeginTerminalPatch(Terminal __instance)
{
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "CoolBracken";
public const string PLUGIN_NAME = "CoolBracken";
public const string PLUGIN_VERSION = "1.0.0";
}
}