Decompiled source of Yarpheim v0.2.2

plugins\Yarpheim.dll

Decompiled 2 weeks ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;
using UnityEngine.Audio;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Yarpheim")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Yarpheim")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.2.2")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.2.0")]
namespace Yartch.Yarpheim;

[BepInPlugin("com.yartch.yarpheim", "Yarpheim", "0.2.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
internal class YarpheimMod : BaseUnityPlugin
{
	public const string PluginGUID = "com.yartch.yarpheim";

	public const string PluginName = "Yarpheim";

	public const string PluginVersion = "0.2.2";

	public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization();

	public static AssetBundle MonstersBundle;

	public static AssetBundle AnimalsBundle;

	public static AudioMixerGroup MixerSfx;

	private void Awake()
	{
		Logger.LogInfo((object)"Yarpheim has landed");
		AddLocalization();
		MonstersBundle = AssetUtils.LoadAssetBundleFromResources("monsters");
		AnimalsBundle = AssetUtils.LoadAssetBundleFromResources("animals");
		PrefabManager.OnVanillaPrefabsAvailable += VanillaPrefabsReady;
		CreatureManager.OnVanillaCreaturesAvailable += VanillaCreaturesReady;
	}

	private void AddLocalization()
	{
		CustomLocalization localization = Localization;
		string text = "English";
		localization.AddTranslation(ref text, new Dictionary<string, string>
		{
			{ "enemy_yarpsquito", "Yarpsquito" },
			{ "sfx_yarpsquito_attack", "Tricked by the Yarpsquito" },
			{ "yarp_cat", "Cat" },
			{ "$yarp_cat_kitten", "Kitten" },
			{ "caption_yarp_cat_meow", "Cat" }
		});
	}

	private void VanillaPrefabsReady()
	{
		LoadVanillaPrefabReferences();
		CreateCat();
		CreateKitten();
		PrefabManager.OnVanillaPrefabsAvailable -= VanillaPrefabsReady;
	}

	private void VanillaCreaturesReady()
	{
		CreateYarpsquito();
		CreatureManager.OnVanillaCreaturesAvailable -= VanillaCreaturesReady;
	}

	private void LoadVanillaPrefabReferences()
	{
		MixerSfx = PrefabManager.Instance.GetPrefab("sfx_creature_consume").GetComponent<AudioSource>().outputAudioMixerGroup;
	}

	private void CreateYarpsquito()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Expected O, but got Unknown
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected O, but got Unknown
		CreatureConfig val = new CreatureConfig();
		val.AddSpawnConfig(new SpawnConfig
		{
			Name = "Yarpheim_YarpsquitoSpawn1",
			SpawnChance = 50f,
			MaxSpawned = 1,
			Biome = (Biome)16
		});
		GameObject val2 = MonstersBundle.LoadAsset<GameObject>("Yarpsquito_sting");
		CustomCreature val3 = new CustomCreature("Yarpsquito", "Deathsquito", val);
		val3.Prefab.GetComponent<Humanoid>().m_defaultItems[0] = val2;
		CreatureManager.Instance.AddCreature(val3);
	}

	private void CreateCat()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Expected O, but got Unknown
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Expected O, but got Unknown
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Expected O, but got Unknown
		GameObject obj = AnimalsBundle.LoadAsset<GameObject>("YarpCatAnimal");
		CreatureConfig val = new CreatureConfig
		{
			Name = "$yarp_cat",
			Faction = (Faction)2
		};
		val.AddSpawnConfig(new SpawnConfig
		{
			Name = "Yarpheim_CatSpawn1",
			SpawnChance = 35f,
			MaxSpawned = 2,
			Biome = (Biome)8
		});
		val.AddSpawnConfig(new SpawnConfig
		{
			Name = "Yarpheim_CatSpawn2",
			SpawnChance = 20f,
			MaxSpawned = 2,
			Biome = (Biome)1
		});
		((BaseAI)obj.GetComponent<MonsterAI>()).m_idleSound.m_effectPrefabs[0].m_prefab.GetComponent<AudioSource>().outputAudioMixerGroup = MixerSfx;
		CustomCreature val2 = new CustomCreature(obj, true, val);
		CreatureManager.Instance.AddCreature(val2);
	}

	private void CreateKitten()
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Expected O, but got Unknown
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Expected O, but got Unknown
		GameObject obj = AnimalsBundle.LoadAsset<GameObject>("YarpCatAnimal_kitten");
		CreatureConfig val = new CreatureConfig
		{
			Name = "$yarp_cat_kitten",
			Faction = (Faction)2
		};
		((BaseAI)obj.GetComponent<AnimalAI>()).m_idleSound.m_effectPrefabs[0].m_prefab.GetComponent<AudioSource>().outputAudioMixerGroup = MixerSfx;
		CustomCreature val2 = new CustomCreature(obj, true, val);
		CreatureManager.Instance.AddCreature(val2);
	}
}