using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FrenchFurryTwitchGang.Patches;
using HarmonyLib;
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("FrenchFurryTwitchGang")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FrenchFurryTwitchGang")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b6ea1290-0853-49bb-a534-67b87a7bdd92")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FrenchFurryTwitchGang
{
[BepInPlugin("AddranorLive-FrenchFurryTwitchGang", "FrenchFurryTwitchGang", "0.0.1.0")]
public class Plugin : BaseUnityPlugin
{
internal const string modGUID = "AddranorLive-FrenchFurryTwitchGang";
internal const string modName = "FrenchFurryTwitchGang";
internal const string modVersion = "0.0.1.0";
internal readonly Harmony harmony = new Harmony("AddranorLive-FrenchFurryTwitchGang");
internal static Plugin Instance;
internal static ManualLogSource MLS;
internal static AssetBundle ModBundle;
internal static string Location;
internal static ConfigEntry<bool> c_Airhorn_Chapho;
internal static ConfigEntry<bool> c_Airhorn_Bluedragon;
internal static ConfigEntry<bool> c_Airhorn_StanRenart;
internal static ConfigEntry<bool> c_Clohorn_Bluedragon;
internal static ConfigEntry<bool> c_Clohorn_StanRenart;
internal static ConfigEntry<bool> c_Clohorn_DodgerAkame;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
Location = ((BaseUnityPlugin)Instance).Info.Location.TrimEnd("AddranorLive-FrenchFurryTwitchGang.dll".ToCharArray());
ModBundle = AssetBundle.LoadFromFile(Location + "frenchfurrytwitchgang");
MLS = Logger.CreateLogSource("AddranorLive-FrenchFurryTwitchGang");
PatchNoisemakerProp.AirhornPackages = new List<NoiseMakerPackage>();
PatchNoisemakerProp.ClohornPackages = new List<NoiseMakerPackage>();
AddNewAirHorn(ref c_Airhorn_Chapho, "Chaphogriff");
AddNewAirHorn(ref c_Airhorn_Bluedragon, "BlueDragon");
AddNewAirHorn(ref c_Airhorn_StanRenart, "StanRenart");
AddNewClownHorn(ref c_Clohorn_Bluedragon, "BlueDragon");
AddNewClownHorn(ref c_Clohorn_StanRenart, "StanRenart");
AddNewClownHorn(ref c_Clohorn_DodgerAkame, "DodgerAkame");
if ((Object)(object)ModBundle != (Object)null)
{
harmony.PatchAll(typeof(Plugin));
harmony.PatchAll(typeof(PatchNoisemakerProp));
LogInfo("Mod has been initialized.");
}
else
{
LogError("Initialization failed !");
}
}
public void AddNewAirHorn(ref ConfigEntry<bool> config, string prefix)
{
BindConfig(ref config, "Airhorn", prefix);
if (config.Value)
{
PatchNoisemakerProp.AirhornPackages.Add(new NoiseMakerPackage("airhorn", prefix.ToLower()));
LogInfo("New Entry : " + prefix + " airhorn added.");
}
}
public void AddNewClownHorn(ref ConfigEntry<bool> config, string prefix)
{
BindConfig(ref config, "Clownhorn", prefix);
if (config.Value)
{
PatchNoisemakerProp.ClohornPackages.Add(new NoiseMakerPackage("clownhorn", prefix.ToLower()));
LogInfo("New Entry : " + prefix + " clownhorn added.");
}
}
public static void LogInfo(object info)
{
MLS.LogInfo((object)(info?.ToString() + " (AddranorLive_LethalMods)"));
}
public static void LogWarning(object warning)
{
MLS.LogWarning((object)(warning?.ToString() + " (AddranorLive_LethalMods)"));
}
public static void LogError(object error)
{
MLS.LogError((object)(error?.ToString() + " (AddranorLive_LethalMods)"));
}
public void BindConfig(ref ConfigEntry<bool> config, string section, string key, bool defaultValue = true)
{
config = ((BaseUnityPlugin)this).Config.Bind<bool>(section, key, defaultValue, "Enables \"" + key + "\"'x custom SFX and custom texture for the " + section + ".");
}
}
public class NoiseMakerPackage
{
public string Name;
public float ClipDuration;
public AudioClip RegularClip;
public AudioClip FarClip;
public Texture2D Texture;
public NoiseMakerPackage(string item, string prefix)
{
RegularClip = Plugin.ModBundle.LoadAssetWithSubAssets<AudioClip>("assets/frenchfurrytwitchgang/" + prefix + "/" + item + "_" + prefix + ".wav")[0];
FarClip = Plugin.ModBundle.LoadAssetWithSubAssets<AudioClip>("assets/frenchfurrytwitchgang/" + prefix + "/" + item + "_" + prefix + "_Far.wav")[0];
Texture = Plugin.ModBundle.LoadAssetWithSubAssets<Texture2D>("assets/frenchfurrytwitchgang/" + prefix + "/Texture_" + prefix + ".png")[0];
ClipDuration = RegularClip.length + 0.1f;
Name = prefix;
}
}
}
namespace FrenchFurryTwitchGang.Patches
{
internal class PatchNoisemakerProp
{
internal static List<NoiseMakerPackage> AirhornPackages;
internal static List<NoiseMakerPackage> ClohornPackages;
internal static int __randomNumber;
[HarmonyPatch(typeof(NoisemakerProp), "Start")]
[HarmonyPostfix]
private static void AudioPatch(NoisemakerProp __instance)
{
if (AirhornPackages.Count == 0 && ClohornPackages.Count == 0)
{
return;
}
if (((Object)((GrabbableObject)__instance).itemProperties).name == "Airhorn")
{
if (AirhornPackages.Count == 0)
{
return;
}
__randomNumber = new Random().Next(0, AirhornPackages.Count);
((GrabbableObject)__instance).useCooldown = AirhornPackages[__randomNumber].ClipDuration;
__instance.noiseSFX[0] = AirhornPackages[__randomNumber].RegularClip;
__instance.noiseSFXFar[0] = AirhornPackages[__randomNumber].FarClip;
((Renderer)((Component)__instance).GetComponent<MeshRenderer>()).materials[0].mainTexture = (Texture)(object)AirhornPackages[__randomNumber].Texture;
}
if (((Object)((GrabbableObject)__instance).itemProperties).name == "ClownHorn" && ClohornPackages.Count != 0)
{
__randomNumber = new Random().Next(0, ClohornPackages.Count);
((GrabbableObject)__instance).useCooldown = ClohornPackages[__randomNumber].ClipDuration;
__instance.noiseSFX[0] = ClohornPackages[__randomNumber].RegularClip;
__instance.noiseSFXFar[0] = ClohornPackages[__randomNumber].FarClip;
((Renderer)((Component)__instance).GetComponent<MeshRenderer>()).materials[0].mainTexture = (Texture)(object)ClohornPackages[__randomNumber].Texture;
}
}
}
}