Decompiled source of DragonideQuiet v1.0.0

plugins/DragonideQuiet.dll

Decompiled a day ago
using System.Reflection;
using BepInEx;
using Jotunn.Managers;
using UnityEngine;

[assembly: AssemblyVersion("1.0.0.0")]
namespace Fai.DragonideQuiet;

[BepInPlugin("fai.dragonidequiet", "Dragonide Quiet", "1.0.0")]
[BepInDependency("com.jotunn.jotunn", "2.30.2")]
[BepInDependency("soloredis.rtdlegends", "1.4.3")]
public sealed class Plugin : BaseUnityPlugin
{
	private void Awake()
	{
		PrefabManager.OnPrefabsRegistered += Apply;
	}

	private void OnDestroy()
	{
		PrefabManager.OnPrefabsRegistered -= Apply;
	}

	private void Apply()
	{
		GameObject prefab = PrefabManager.Instance.GetPrefab("PlainsDragonide_RtD");
		if (!Object.op_Implicit((Object)(object)prefab))
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"PlainsDragonide_RtD was not registered.");
			return;
		}
		Component component = prefab.GetComponent(typeof(BaseAI));
		BaseAI val = (BaseAI)(object)((component is BaseAI) ? component : null);
		if (!Object.op_Implicit((Object)(object)val))
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"PlainsDragonide_RtD has no BaseAI.");
		}
		else if (SuppressRoars(val.m_alertedEffects) + SuppressRoars(val.m_idleSound) == 0)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"No recognized Dragonide roar effects were found.");
		}
		else
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Dragonide roar and its camera shake disabled.");
		}
	}

	private static int SuppressRoars(EffectList P_0)
	{
		if (P_0 != null)
		{
			EffectData[] effectPrefabs = P_0.m_effectPrefabs;
			if (effectPrefabs != null)
			{
				int num = 0;
				foreach (EffectData val in effectPrefabs)
				{
					if (val != null && Object.op_Implicit((Object)(object)val.m_prefab) && IsRoar(((Object)val.m_prefab).name))
					{
						val.m_enabled = false;
						num++;
					}
				}
				return num;
			}
		}
		return 0;
	}

	private static bool IsRoar(string P_0)
	{
		switch (P_0)
		{
		default:
			return false;
		case "sfx_goblinbrute_alerted":
		case "sfx_goblinking_taunt":
		case "sfx_Goblin_Orc_Dragonide_alerted_RtD":
		case "sfx_Goblin_Orc_Dragonide_idle_RtD":
			return true;
		}
	}
}