using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
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("RicardoBracken3d")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+8e1a856e1477ca630de3818d5e3f969061170327")]
[assembly: AssemblyProduct("RicardoBracken3d")]
[assembly: AssemblyTitle("RicardoBracken3d")]
[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 RicardoBracken3d
{
[BepInPlugin("RicardoBracken3d", "RicardoBracken3d", "1.0.0")]
public class RicardoBracken3d : BaseUnityPlugin
{
internal static Random AudioRandom = new Random(0);
public static RicardoBracken3d Instance { get; private set; } = null;
internal static ManualLogSource Logger { get; private set; } = null;
internal static Harmony? Harmony { get; set; }
internal static Dictionary<string, AudioClip> Sfx { get; private set; } = new Dictionary<string, AudioClip>();
internal static Dictionary<string, GameObject> Models { get; private set; } = new Dictionary<string, GameObject>();
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
Patch();
if (LoadBundles())
{
Logger.LogInfo((object)"RicardoBracken3d v1.0.0 has loaded!");
}
else
{
Unpatch();
}
}
internal static void Patch()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("RicardoBracken3d");
}
Logger.LogDebug((object)"Patching...");
Harmony.PatchAll();
Logger.LogDebug((object)"Finished patching!");
}
internal static void Unpatch()
{
Logger.LogDebug((object)"Unpatching...");
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogDebug((object)"Finished unpatching!");
}
internal static bool LoadBundles()
{
bool result = true;
string location = ((BaseUnityPlugin)Instance).Info.Location;
location = location.TrimEnd("RicardoBracken3d.dll".ToCharArray());
AssetBundle val = AssetBundle.LoadFromFile(location + "audios");
AssetBundle val2 = AssetBundle.LoadFromFile(location + "models");
if ((Object)(object)val != (Object)null)
{
AudioClip[] array = val.LoadAllAssets<AudioClip>();
List<AudioClip> list = new List<AudioClip>(array.Length);
list.AddRange(array);
List<AudioClip> list2 = list;
list2.ForEach(delegate(AudioClip sound)
{
Sfx.Add(((Object)sound).name, sound);
Logger.LogInfo((object)("Loaded sound " + ((Object)sound).name));
});
Logger.LogInfo((object)"Successfully loaded the audio files");
}
else
{
result = false;
Logger.LogError((object)"Failed to load audio files");
}
if ((Object)(object)val2 != (Object)null)
{
GameObject[] array2 = val2.LoadAllAssets<GameObject>();
List<GameObject> list3 = new List<GameObject>(array2.Length);
list3.AddRange(array2);
List<GameObject> list4 = list3;
list4.ForEach(delegate(GameObject model)
{
Models.Add(((Object)model).name, model);
Logger.LogInfo((object)("Loaded model " + ((Object)model).name));
});
Logger.LogInfo((object)"Successfully loaded the model files");
}
else
{
result = false;
Logger.LogError((object)"Failed to load model files");
}
return result;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "RicardoBracken3d";
public const string PLUGIN_NAME = "RicardoBracken3d";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace RicardoBracken3d.Patches
{
[HarmonyPatch(typeof(FlowermanAI))]
internal class FlowermanAIPatch
{
public const string PREFIX_NECK = "crackneck_";
public const string PREFIX_ANGY = "anger_";
public const string PREFIX_DED = "death_";
public const string PREFIX_FOUND = "found_";
public const int clipCount = 4;
public const float randomPitchStart = 0.8f;
public const float randomPitchEnd = 1.2f;
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void FlowerManToRicardo(FlowermanAI __instance)
{
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
Renderer[] componentsInChildren = ((Component)((Component)__instance).transform.Find("FlowermanModel")).GetComponentsInChildren<Renderer>();
Renderer[] array = componentsInChildren;
foreach (Renderer val in array)
{
val.enabled = false;
}
RicardoBracken3d.Logger.LogInfo((object)(((Object)__instance).GetInstanceID() + " instance - Default bracken model hidden"));
if (RicardoBracken3d.Models.TryGetValue("ricardo", out GameObject value))
{
RicardoBracken3d.Logger.LogInfo((object)(((Object)__instance).GetInstanceID() + " instance - setting ricardo bracken model to " + ((Object)value).name));
GameObject val2 = Object.Instantiate<GameObject>(value, ((Component)__instance).gameObject.transform);
((Object)val2).name = "Ricardo(Clone)";
val2.transform.localPosition = Vector3.zero;
Transform transform = val2.transform;
transform.localScale += new Vector3(0.6f, 0.6f, 0.6f);
val2.SetActive(true);
}
int num = RicardoBracken3d.AudioRandom.Next(0, RicardoBracken3d.Sfx.Keys.Count / 4);
RicardoBracken3d.Logger.LogInfo((object)(((Object)__instance).GetInstanceID() + " instance - ricardo audio index is " + num));
if (RicardoBracken3d.Sfx.TryGetValue("crackneck_" + num, out AudioClip value2))
{
RicardoBracken3d.Logger.LogInfo((object)(((Object)__instance).GetInstanceID() + " instance - setting ricardo sound crackneck_ to " + ((Object)value2).name));
__instance.crackNeckSFX = value2;
__instance.crackNeckAudio.clip = value2;
}
if (RicardoBracken3d.Sfx.TryGetValue("anger_" + num, out AudioClip value3))
{
RicardoBracken3d.Logger.LogInfo((object)(((Object)__instance).GetInstanceID() + " instance - setting ricardo sound anger_ to " + ((Object)value3).name));
__instance.creatureAngerVoice.clip = value3;
}
if (RicardoBracken3d.Sfx.TryGetValue("death_" + num, out AudioClip value4))
{
RicardoBracken3d.Logger.LogInfo((object)(((Object)__instance).GetInstanceID() + " instance - setting ricardo sound death_ to " + ((Object)value4).name));
((EnemyAI)__instance).dieSFX = value4;
}
if (RicardoBracken3d.Sfx.TryGetValue("found_" + num, out AudioClip value5))
{
RicardoBracken3d.Logger.LogInfo((object)(((Object)__instance).GetInstanceID() + " instance - setting ricardo sound found_ to " + ((Object)value5).name));
((Component)((Component)__instance).transform.Find("FlowermanModel").Find("AnimContainer")).GetComponent<PlayAudioAnimationEvent>().audioClip = value5;
}
RicardoBracken3d.Logger.LogInfo((object)"setting ricardo tag");
((Component)__instance).GetComponentInChildren<ScanNodeProperties>().headerText = "Ricardo Milos";
}
[HarmonyPatch("KillEnemy")]
[HarmonyPostfix]
private static void FreezeAddedModelonKillEnemy(FlowermanAI __instance)
{
((Behaviour)((Component)((Component)__instance).transform.Find("Ricardo(Clone)")).GetComponent<Animator>()).enabled = false;
((Component)((Component)__instance).transform.Find("Ricardo(Clone)")).transform.Rotate(0f, 0f, 90f);
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void patchUpdate(FlowermanAI __instance)
{
if (!__instance.isInAngerMode)
{
__instance.creatureAngerVoice.pitch = Random.Range(0.8f, 1.2f);
}
}
}
[HarmonyPatch(typeof(RoundManager))]
internal class RoundManagerFlowermanSetRandomPartch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void InitRandom()
{
RicardoBracken3d.AudioRandom = new Random(StartOfRound.Instance.randomMapSeed);
RicardoBracken3d.Logger.LogDebug((object)("Set Random from StartOfRound.Instance.randomMapSeed - " + StartOfRound.Instance.randomMapSeed));
}
}
}