Decompiled source of SakeysValhalaEnergyForsakenDrink v1.0.5

BepInEx/plugins/SakeysValhalaEnergy.dll

Decompiled 11 hours ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("SakeysValhalaEnergy")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SakeysValhalaEnergy")]
[assembly: AssemblyTitle("SakeysValhalaEnergy")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SakeysValhalaEnergy;

[BepInPlugin("com.sakey.valhala.energy.drinks", "Sakey's Valhala Energy Forsaken Drink", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Class1 : BaseUnityPlugin
{
	public struct EnergyDrinkData
	{
		public string prefabName;

		public string itemId;

		public string displayName;

		public string description;

		public string powerId;

		public string iconName;

		public string bossKey;

		public string message;

		public int craftAmount;

		public string recipeItem1;

		public int recipeAmount1;

		public string recipeItem2;

		public int recipeAmount2;

		public string recipeItem3;

		public int recipeAmount3;

		public string recipeItem4;

		public int recipeAmount4;
	}

	[HarmonyPatch(typeof(Trader), "Start")]
	private static class TraderStartPatch
	{
		[HarmonyPostfix]
		private static void Postfix(Trader __instance)
		{
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Expected O, but got Unknown
			if ((Object)(object)__instance == (Object)null || __instance.m_items == null)
			{
				return;
			}
			string obj = __instance.m_name ?? "";
			string text = ((Object)((Component)__instance).gameObject).name ?? "";
			bool flag = false;
			if ((obj.Contains("Haldor") || text.Contains("Haldor")) && sellAtHaldor.Value)
			{
				flag = true;
			}
			if ((obj.Contains("Hildir") || text.Contains("Hildir")) && sellAtHildir.Value)
			{
				flag = true;
			}
			if ((obj.Contains("BogWitch") || text.Contains("BogWitch")) && sellAtBogWitch.Value)
			{
				flag = true;
			}
			if (!flag && (text.Contains("Haldor") || text.Contains("Hildir") || text.Contains("BogWitch")))
			{
				flag = true;
			}
			if (!flag)
			{
				return;
			}
			int result;
			int price = (int.TryParse(drinkPrice.Value, out result) ? result : 10);
			foreach (EnergyDrinkData drink in drinkList)
			{
				bool flag2 = false;
				if ((Object)(object)ZoneSystem.instance != (Object)null && !string.IsNullOrEmpty(drink.bossKey))
				{
					flag2 = ZoneSystem.instance.GetGlobalKey(drink.bossKey);
				}
				if (!(unlockAllMerchant.Value || flag2))
				{
					continue;
				}
				bool flag3 = false;
				foreach (TradeItem item in __instance.m_items)
				{
					if ((Object)(object)item.m_prefab != (Object)null && (((Object)((Component)item.m_prefab).gameObject).name == drink.itemId || ((Object)item.m_prefab).name == drink.itemId))
					{
						flag3 = true;
						break;
					}
				}
				if (flag3)
				{
					continue;
				}
				ItemDrop val = null;
				if ((Object)(object)ObjectDB.instance != (Object)null)
				{
					GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(drink.itemId);
					if ((Object)(object)itemPrefab != (Object)null)
					{
						val = itemPrefab.GetComponent<ItemDrop>();
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					GameObject prefab = PrefabManager.Instance.GetPrefab(drink.itemId);
					if ((Object)(object)prefab != (Object)null)
					{
						val = prefab.GetComponent<ItemDrop>();
					}
				}
				if ((Object)(object)val != (Object)null)
				{
					__instance.m_items.Add(new TradeItem
					{
						m_prefab = val,
						m_price = price,
						m_stack = 1,
						m_requiredGlobalKey = ""
					});
					Debug.Log((object)("[EnergyDrinks] 商人(Trader.Start)にアイテムを追加しました: " + drink.itemId));
				}
			}
		}
	}

	public const string PluginGUID = "com.sakey.valhala.energy.drinks";

	public const string PluginName = "Sakey's Valhala Energy Forsaken Drink";

	public const string PluginVersion = "1.0.0";

	public const string ASSET_BUNDLE_NAME = "forsakendrink";

	public const string DRINK_BASE_NAME = "valhala_energy";

	public const string ICON_BASE_NAME = "icon_valhalaenergy";

	public static readonly Vector3 MODEL_TARGET_SCALE = new Vector3(0.012f, 0.012f, 0.012f);

	public const float MODEL_Y_OFFSET = 0.45f;

	private static AssetBundle assetBundle;

	private Harmony harmony;

	private static ConfigEntry<string> drinkPrice;

	private static ConfigEntry<bool> unlockAllRecipes;

	private static ConfigEntry<bool> unlockAllMerchant;

	private static ConfigEntry<bool> sellAtHaldor;

	private static ConfigEntry<bool> sellAtHildir;

	private static ConfigEntry<bool> sellAtBogWitch;

	public static List<EnergyDrinkData> drinkList;

	public static HashSet<string> drinkPrefabNames = new HashSet<string>();

	private void Awake()
	{
		//IL_07bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c7: Expected O, but got Unknown
		drinkPrice = ((BaseUnityPlugin)this).Config.Bind<string>("General", "DrinkPrice", "10", "商人から購入するときのコインの価格です。");
		sellAtHaldor = ((BaseUnityPlugin)this).Config.Bind<bool>("Merchant Settings", "SellAtHaldor", true, "ハルドルで販売するかどうか");
		sellAtHildir = ((BaseUnityPlugin)this).Config.Bind<bool>("Merchant Settings", "SellAtHildir", false, "ヒルディルで販売するかどうか");
		sellAtBogWitch = ((BaseUnityPlugin)this).Config.Bind<bool>("Merchant Settings", "SellAtBogWitch", true, "ボグウィッチで販売するかどうか");
		unlockAllRecipes = ((BaseUnityPlugin)this).Config.Bind<bool>("2nd Play - CheatMode", "UnlockAllRecipes", false, "レシピ全解放");
		unlockAllMerchant = ((BaseUnityPlugin)this).Config.Bind<bool>("2nd Play - CheatMode", "UnlockAllMerchant", false, "商人ラインナップ全解放");
		drinkList = new List<EnergyDrinkData>
		{
			new EnergyDrinkData
			{
				prefabName = "valhala_energy1",
				itemId = "valhala_energy1",
				displayName = "ヴァルハラエナジー1「Meadows Sweet」",
				description = "エイクスュル?エイクスュニル?\n翻訳の揺れは気になるよな。\n日本人には発音しづらい。\nなんだよ、「ス」の後に小さい「ュ」って。\n\n鹿のエイクスュル。北欧神話では神々の主・オーディンの館「ヴァルハラ」の屋根の上に立っていてユグドラシルの葉や若芽を食べる。枝角から流れる水滴が滴り落ちて地上の皮の源流になるって言い逃れらしいね。\n\n彼の加護を受けると走り回れるようになるぜ!\n死亡ロス回収にはお世話になったよ。",
				powerId = "GP_Eikthyr",
				iconName = "icon_valhalaenergy1",
				bossKey = "defeated_eikthyr",
				message = "エイクスュルの風のような脚力がみなぎる!",
				craftAmount = 10,
				recipeItem1 = "TrophyEikthyr",
				recipeAmount1 = 1,
				recipeItem2 = "Raspberry",
				recipeAmount2 = 3,
				recipeItem3 = "Honey",
				recipeAmount3 = 1,
				recipeItem4 = "Dandelion",
				recipeAmount4 = 2
			},
			new EnergyDrinkData
			{
				prefabName = "valhala_energy2",
				itemId = "valhala_energy2",
				displayName = "ヴァルハラエナジー2「Traveling Forest」",
				description = "遠いよな。ボス登録できたと思ったらなんで長老ってあんなに遠いんだ?Google検索では「長老 遠すぎる」属性補助が出るんだ。\n長老というのはそこに辿り着くまでがゲームんだろうね。\n\nエルダーという神話キャラはいなくてオリジナルなんだってよ。\nなにやらオーディンに歯向かったことで10番世界に追放されたんだって。もちろん木の怪物で、ドワーフの王。プレハブネームはgd_kingんだ。\nこの長老が縦長いからこのエナドリ風にしたら合いそうだなと思ったのがこのValhala Eenery企画の始まり。\nさぁ、これを飲んで長老遠すぎ問題に対峙しようぜ。Cheers!",
				powerId = "GP_TheElder",
				iconName = "icon_valhalaenergy2",
				bossKey = "defeated_gdking",
				message = "長老の力により、木々の伐採力が覚醒した!",
				craftAmount = 10,
				recipeItem1 = "TrophyTheElder",
				recipeAmount1 = 1,
				recipeItem2 = "Blueberries",
				recipeAmount2 = 2,
				recipeItem3 = "Thistle",
				recipeAmount3 = 2,
				recipeItem4 = "AncientSeed",
				recipeAmount4 = 1
			},
			new EnergyDrinkData
			{
				prefabName = "valhala_energy3",
				itemId = "valhala_energy3",
				displayName = "ヴァルハラエナジー3「Swamp Stand!!」",
				description = "大骨は果たして骨なのか。\nそれともスライムなのか。\n\n彼も神話にはいないが、アンデットの集合体のような者というのが、元ネタの1つじゃないかという説がある。骨や腐肉とスライムの塊。ほらやっぱり大骨というより巨大版ブロブじゃないか。\n\nきみは彼をどうやって倒した?近くのダンジョンの上からやったさ。\n\n体に良い保存食は物理防御があがるんだよ。\n中盤はお世話になったよな。ストーンゴーレムやゴブリンがきたらすぐに飲むんだ!",
				powerId = "GP_Bonemass",
				iconName = "icon_valhalaenergy3",
				bossKey = "defeated_bonemass",
				message = "大骨の硬化作用で物理防御が大幅に上がった!",
				craftAmount = 10,
				recipeItem1 = "TrophyBonemass",
				recipeAmount1 = 1,
				recipeItem2 = "BoneFragments",
				recipeAmount2 = 2,
				recipeItem3 = "ShocklateSmoothie",
				recipeAmount3 = 1,
				recipeItem4 = "MeadStaminaMinor",
				recipeAmount4 = 1
			},
			new EnergyDrinkData
			{
				prefabName = "valhala_energy4",
				itemId = "valhala_energy4",
				displayName = "ヴァルハラエナジー4「ABSOLUTE MOUNTAIN」",
				description = "攻略ではよく環「モデル」と呼ばれてるのに地図上では「ムーデル」と表記される。\nここでも翻訳が揺れている。\n\n北欧スウェーデン語で「母親」の意味のModerを発音記号をカタカナにした結果ムーデルになったが、初期は英語綴り通りモデルと呼ばれることが多かったためそちらが定着している。ちなみに北欧神話に居ないオリジナルだが、北欧神話の邪竜ニドヘグや古のノルドの詩にムーデルという女性が出てくる。その辺がモチーフになったという説がある。\n\nさぁ、彼の力を狩りて、山を制覇したら船旅に出よう。\n山の母は風を味方にしてくれる",
				powerId = "GP_Moder",
				iconName = "icon_valhalaenergy4",
				bossKey = "defeated_dragon",
				message = "山の母の加護で追い風が約束された!",
				craftAmount = 10,
				recipeItem1 = "TrophyDragonQueen",
				recipeAmount1 = 1,
				recipeItem2 = "FreezeGland",
				recipeAmount2 = 2,
				recipeItem3 = "DragonEgg",
				recipeAmount3 = 1,
				recipeItem4 = "MeadFrostResist",
				recipeAmount4 = 1
			},
			new EnergyDrinkData
			{
				prefabName = "valhala_energy5",
				itemId = "valhala_energy5",
				displayName = "ヴァルハラエナジー5「Elemental Goblin King」",
				description = "平地は急にダンジョンがなくなる。ヴェグヴィシルを見つけるのには苦労したんじゃないだろうか?\n\nヤグルスもオリジナルだけれど、モチーフになったクトゥル神話のイゴールナクなどがいてるらしい。\nこの世界ではかつてはオーディンを信仰していた偉大な王であったが、オーディンに捨てられ怨念を抱き、朽ちて骨となった今もそのまま君臨している。\n大骨が物理耐性だったのに対し、彼のフォーセイクンパワーは属性ダメージ耐性となっている。\nメタルロックなBGMを楽しみながら彼との戦闘を楽しもう",
				powerId = "GP_Yagluth",
				iconName = "icon_valhalaenergy5",
				bossKey = "defeated_goblinking",
				message = "ヤグルスの力で属性ダメージに対する耐性を得た!",
				craftAmount = 10,
				recipeItem1 = "TrophyGoblinKing",
				recipeAmount1 = 1,
				recipeItem2 = "Cloudberry",
				recipeAmount2 = 2,
				recipeItem3 = "Barley",
				recipeAmount3 = 2,
				recipeItem4 = "MeadHealthMinor",
				recipeAmount4 = 1
			},
			new EnergyDrinkData
			{
				prefabName = "valhala_energy6",
				itemId = "valhala_energy6",
				displayName = "ヴァルハラエナジー6「Mistlands Awakened」",
				description = "この女王を倒すのに君は何時間かかった?私は6時間もかかったよ。\n\nクイーンにも元ネタは多少あるが基本はオリジナルで北欧神話にはいない。\nValheim上ではかつて霧の地を古代種族を駆逐してシーカー達の巣窟に変えたという歴史が石碑には記されています。\n恐らくは封印されて侵略された砦にずっと引きこもっている。シーカー達の絶対的な女王であり、奴らを召喚するので非常にやっかい。ついでに再戦に必要な兵士のトロフィーのドロップ率が低いことも厄介。\n\n彼女のパワーを借りると採掘の力があがりエイトルの回復速度も2倍になる。",
				powerId = "GP_Queen",
				iconName = "icon_valhalaenergy6",
				bossKey = "defeated_queen",
				message = "クイーンの猛威で採掘力とエイトル回復速度が倍増!",
				craftAmount = 10,
				recipeItem1 = "TrophySeekerQueen",
				recipeAmount1 = 1,
				recipeItem2 = "MushroomMagecap",
				recipeAmount2 = 1,
				recipeItem3 = "RoyalJelly",
				recipeAmount3 = 2,
				recipeItem4 = "QueensJam",
				recipeAmount4 = 1
			},
			new EnergyDrinkData
			{
				prefabName = "valhala_energy7",
				itemId = "valhala_energy7",
				displayName = "ヴァルハラエナジー7「FADER FIRE FREE」",
				description = "アーリーの実質ラスボス状態だったフェーダー。火力がハンパなかったよね。彼もモチーフネタはあるものの神話にはいないオリジナル。\n\nこの翠炎の王には灰の地誕生の物語が石碑に刻まれている。彼はかつて王として統治していたが、家臣の裏切りに遭い、特別気にかけている冬の子と呼ばれる少年を焼き殺された。国に戻ったフェーダーは激怒し、裏切った家臣の小さな灯とは比べものにならない業火でその全土を焼いて、焦げた者たちで覆い\r\n尽くされ、自信も変わり果てた\r\n黒焦げの骨の竜となったとか。\r\n\r\n建築制限解除MODで最寄りダン\r\nジョン内部にガチ拠点作ったけど\r\n死にまくったのは忘れないよ。\r\n",
				powerId = "GP_Fader",
				iconName = "icon_valhalaenergy7",
				bossKey = "defeated_fader",
				message = "フェーダーの業火が宿り、炎の力が開放された!",
				craftAmount = 10,
				recipeItem1 = "TrophyFader",
				recipeAmount1 = 1,
				recipeItem2 = "Vineberry",
				recipeAmount2 = 2,
				recipeItem3 = "Fiddleheadfern",
				recipeAmount3 = 2,
				recipeItem4 = "BarleyWine",
				recipeAmount4 = 1
			},
			new EnergyDrinkData
			{
				prefabName = "valhala_energy8",
				itemId = "valhala_energy8",
				displayName = "ヴァルハラエナジー8「Early Storm」",
				description = "よう。ここまできたか。\nアーリーのボス達を一気に得ようなんて、欲張りにも程がある。\n\nだがそれがゲーマーなのだ。\nMODならではなのだ。\n\nえ?ボスのトロフィー?\nいいよいいよ、そんなの。余ってるもんでいいよ。\n君がここまで来たならこのぐらい余ってるだろ?\n\nきみはまさか商人の売値を1コインに設定してないか?\n尚、作り手は1コインにする気満々だぞ。\n船旅に持ってって追い風にしまくってやるんだ!",
				powerId = "GP_ALL_ULTIMATE",
				iconName = "icon_valhalaenergy8",
				bossKey = "defeated_fader",
				message = "アーリーのボス達が叫んだ!",
				craftAmount = 10,
				recipeItem1 = "BoneFragments",
				recipeAmount1 = 100,
				recipeItem2 = "LeatherScraps",
				recipeAmount2 = 100,
				recipeItem3 = "Feathers",
				recipeAmount3 = 100,
				recipeItem4 = "TrophyBoar",
				recipeAmount4 = 20
			}
		};
		foreach (EnergyDrinkData drink in drinkList)
		{
			drinkPrefabNames.Add(drink.itemId);
		}
		string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "forsakendrink");
		assetBundle = AssetBundle.LoadFromFile(text);
		if ((Object)(object)assetBundle == (Object)null)
		{
			Logger.LogError((object)("[EnergyDrinks] AssetBundleの読み込みに失敗しました: " + text));
			return;
		}
		ItemManager.OnItemsRegistered += OnItemsRegistered;
		PrefabManager.OnPrefabsRegistered += OnPrefabsRegistered;
		harmony = new Harmony("com.sakey.valhala.energy.drinks");
		harmony.PatchAll();
	}

	private void OnPrefabsRegistered()
	{
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Expected O, but got Unknown
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ad: Expected O, but got Unknown
		//IL_0412: Unknown result type (might be due to invalid IL or missing references)
		//IL_0417: Unknown result type (might be due to invalid IL or missing references)
		//IL_0423: Unknown result type (might be due to invalid IL or missing references)
		//IL_042e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0435: Unknown result type (might be due to invalid IL or missing references)
		//IL_0441: Unknown result type (might be due to invalid IL or missing references)
		//IL_0457: Expected O, but got Unknown
		//IL_0452: Unknown result type (might be due to invalid IL or missing references)
		//IL_0459: Expected O, but got Unknown
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_029a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0357: Unknown result type (might be due to invalid IL or missing references)
		//IL_0370: Unknown result type (might be due to invalid IL or missing references)
		PrefabManager.OnPrefabsRegistered -= OnPrefabsRegistered;
		foreach (EnergyDrinkData drink in drinkList)
		{
			GameObject val = PrefabManager.Instance.CreateClonedPrefab(drink.itemId, "MeadHealthMinor");
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			ItemDrop component = val.GetComponent<ItemDrop>();
			ZNetView component2 = val.GetComponent<ZNetView>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.m_persistent = true;
			}
			string text = ((drink.itemId == "valhala_energy8") ? "icon_valhalaenergy8" : drink.iconName);
			Sprite val2 = assetBundle.LoadAsset<Sprite>(text);
			component.m_itemData.m_shared.m_name = drink.displayName;
			component.m_itemData.m_shared.m_description = drink.description;
			component.m_itemData.m_shared.m_maxStackSize = 10;
			component.m_itemData.m_shared.m_itemType = (ItemType)2;
			component.m_itemData.m_shared.m_isDrink = true;
			component.m_itemData.m_shared.m_food = 0f;
			component.m_itemData.m_shared.m_foodStamina = 0f;
			component.m_itemData.m_shared.m_foodRegen = 0f;
			component.m_itemData.m_shared.m_foodBurnTime = 0f;
			component.m_itemData.m_shared.m_consumeStatusEffect = null;
			component.m_itemData.m_shared.m_icons = (Sprite[])(object)((!((Object)(object)val2 != (Object)null)) ? new Sprite[0] : new Sprite[1] { val2 });
			for (int num = val.transform.childCount - 1; num >= 0; num--)
			{
				Object.DestroyImmediate((Object)(object)((Component)val.transform.GetChild(num)).gameObject);
			}
			val.transform.localScale = Vector3.one;
			GameObject val3 = new GameObject("attach");
			val3.transform.SetParent(val.transform, false);
			val3.transform.localPosition = Vector3.zero;
			val3.transform.localRotation = Quaternion.identity;
			val3.transform.localScale = Vector3.one;
			string text2 = ((drink.itemId == "valhala_energy8") ? "valhala_energy8" : drink.prefabName);
			GameObject val4 = assetBundle.LoadAsset<GameObject>(text2);
			if ((Object)(object)val4 != (Object)null)
			{
				GameObject obj = Object.Instantiate<GameObject>(val4, val3.transform);
				((Object)obj).name = "model";
				obj.transform.localPosition = new Vector3(0f, 0.45f, 0f);
				obj.transform.localEulerAngles = Vector3.zero;
				obj.transform.localScale = MODEL_TARGET_SCALE;
				LODGroup[] componentsInChildren = obj.GetComponentsInChildren<LODGroup>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren[i]);
				}
				int num2 = LayerMask.NameToLayer("item");
				if (num2 == -1)
				{
					num2 = 12;
				}
				Transform[] componentsInChildren2 = val.GetComponentsInChildren<Transform>(true);
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					((Component)componentsInChildren2[i]).gameObject.layer = num2;
				}
				Collider[] componentsInChildren3 = val.GetComponentsInChildren<Collider>(true);
				for (int i = 0; i < componentsInChildren3.Length; i++)
				{
					Object.DestroyImmediate((Object)(object)componentsInChildren3[i]);
				}
				BoxCollider obj2 = val.AddComponent<BoxCollider>();
				obj2.center = new Vector3(0f, 0.45f, 0f);
				obj2.size = new Vector3(0.12f, 0.6f, 0.12f);
				Rigidbody val5 = val.GetComponent<Rigidbody>();
				if ((Object)(object)val5 == (Object)null)
				{
					val5 = val.AddComponent<Rigidbody>();
				}
				val5.isKinematic = false;
				val5.useGravity = true;
			}
			CustomItem val6 = new CustomItem(val, true);
			ItemManager.Instance.AddItem(val6);
			List<RequirementConfig> reqList = new List<RequirementConfig>();
			AddValidRequirement(drink.recipeItem1, drink.recipeAmount1);
			AddValidRequirement(drink.recipeItem2, drink.recipeAmount2);
			AddValidRequirement(drink.recipeItem3, drink.recipeAmount3);
			AddValidRequirement(drink.recipeItem4, drink.recipeAmount4);
			CustomRecipe val7 = new CustomRecipe(new RecipeConfig
			{
				Item = drink.itemId,
				CraftingStation = "piece_cauldron",
				MinStationLevel = 1,
				Amount = drink.craftAmount,
				Requirements = reqList.ToArray()
			});
			ItemManager.Instance.AddRecipe(val7);
			void AddValidRequirement(string itemName, int amount)
			{
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Expected O, but got Unknown
				if (!string.IsNullOrEmpty(itemName) && amount > 0)
				{
					GameObject prefab = PrefabManager.Instance.GetPrefab(itemName);
					if ((Object)(object)prefab != (Object)null && (Object)(object)prefab.GetComponent<ItemDrop>() != (Object)null)
					{
						reqList.Add(new RequirementConfig
						{
							Item = itemName,
							Amount = amount
						});
					}
				}
			}
		}
	}

	private void OnItemsRegistered()
	{
	}

	public static void TriggerEnergyDrinkPower(Player player, string itemId, string message)
	{
		if ((Object)(object)player == (Object)null)
		{
			return;
		}
		if (itemId == "valhala_energy8")
		{
			string[] array = new string[7] { "GP_Eikthyr", "GP_TheElder", "GP_Bonemass", "GP_Moder", "GP_Yagluth", "GP_Queen", "GP_Fader" };
			foreach (string text in array)
			{
				((Character)player).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode(text), true, 0, 0f);
			}
			player.m_guardianPowerCooldown = 0f;
			((Character)player).Message((MessageType)2, message, 0, (Sprite)null);
			Debug.Log((object)"[EnergyDrinks Mod]7パワー同時発動(SEMan追加)成功!");
			return;
		}
		foreach (EnergyDrinkData drink in drinkList)
		{
			if (drink.itemId == itemId)
			{
				player.SetGuardianPower(drink.powerId);
				player.m_guardianPowerCooldown = 0f;
				player.ActivateGuardianPower();
				string text2 = ((!string.IsNullOrEmpty(message)) ? message : "ヴァルハラエナジーにより、見捨てられた者の力が目覚めた!");
				((Character)player).Message((MessageType)2, text2, 0, (Sprite)null);
				break;
			}
		}
	}

	private void OnDestroy()
	{
		Harmony obj = harmony;
		if (obj != null)
		{
			obj.UnpatchSelf();
		}
		ItemManager.OnItemsRegistered -= OnItemsRegistered;
		PrefabManager.OnPrefabsRegistered -= OnPrefabsRegistered;
		if ((Object)(object)assetBundle != (Object)null)
		{
			assetBundle.Unload(false);
		}
	}
}
[HarmonyPatch(typeof(Player), "ConsumeItem")]
public static class EnergyDrinkInstantConsumePatch
{
	[HarmonyPrefix]
	public static bool Prefix(Player __instance, Inventory inventory, ItemData item, ref bool __result)
	{
		if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer || item == null)
		{
			return true;
		}
		string text = (((Object)(object)item.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : ((item.m_shared != null) ? item.m_shared.m_name : "")).Replace("(Clone)", "").Trim();
		foreach (Class1.EnergyDrinkData drink in Class1.drinkList)
		{
			if (text == drink.itemId || text == drink.prefabName || text.Contains(drink.itemId))
			{
				if (inventory != null)
				{
					inventory.RemoveItem(item, 1);
				}
				else if (((Humanoid)__instance).GetInventory() != null)
				{
					((Humanoid)__instance).GetInventory().RemoveItem(item, 1);
				}
				Debug.Log((object)("[EnergyDrinks Mod] モーションなし即座消費: " + text));
				Class1.TriggerEnergyDrinkPower(__instance, drink.itemId, drink.message);
				__result = true;
				return false;
			}
		}
		return true;
	}
}
[HarmonyPatch(typeof(CookingStation), "UpdateVisual")]
public static class CookingStation_UpdateVisual_Patch
{
	[HarmonyPostfix]
	public static void Postfix(CookingStation __instance)
	{
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__instance == (Object)null || __instance.m_slots == null)
		{
			return;
		}
		for (int i = 0; i < __instance.m_slots.Length; i++)
		{
			Transform val = __instance.m_slots[i];
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			for (int j = 0; j < val.childCount; j++)
			{
				Transform child = val.GetChild(j);
				if ((Object)(object)child == (Object)null)
				{
					continue;
				}
				string text = ((Object)((Component)child).gameObject).name.Replace("(Clone)", "").Trim();
				if (Class1.drinkPrefabNames.Contains(text) || text.StartsWith("valhala_energy"))
				{
					Transform val2 = child.Find("attach/model");
					if ((Object)(object)val2 == (Object)null)
					{
						val2 = child.Find("model");
					}
					if ((Object)(object)val2 != (Object)null)
					{
						val2.localPosition = new Vector3(0f, 0.45f, 0f);
						val2.localRotation = Quaternion.identity;
					}
				}
			}
		}
	}
}
[HarmonyPatch(typeof(ItemDrop), "Start")]
public static class ItemDrop_Start_Patch
{
	[HarmonyPostfix]
	public static void Postfix(ItemDrop __instance)
	{
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__instance == (Object)null || __instance.m_itemData == null || __instance.m_itemData.m_shared == null)
		{
			return;
		}
		string name = __instance.m_itemData.m_shared.m_name;
		string item = ((Object)((Component)__instance).gameObject).name.Replace("(Clone)", "").Trim();
		if (!Class1.drinkPrefabNames.Contains(item) && !Class1.drinkPrefabNames.Contains(name) && !name.StartsWith("valhala_energy"))
		{
			return;
		}
		Transform val = ((Component)__instance).transform.Find("attach");
		if ((Object)(object)val != (Object)null)
		{
			Transform val2 = val.Find("model");
			if ((Object)(object)val2 != (Object)null)
			{
				val2.localPosition = new Vector3(0f, 0.45f, 0f);
				val2.localRotation = Quaternion.identity;
			}
		}
	}
}
[HarmonyPatch(typeof(Humanoid), "SetupEquipment")]
public static class Humanoid_SetupEquipment_Patch
{
	[HarmonyPostfix]
	public static void Postfix(Humanoid __instance)
	{
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)__instance == (Object)null)
		{
			return;
		}
		object? obj = AccessTools.Field(typeof(Humanoid), "m_visEquipment")?.GetValue(__instance);
		VisEquipment val = (VisEquipment)((obj is VisEquipment) ? obj : null);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		object? obj2 = AccessTools.Field(typeof(VisEquipment), "m_rightItemInstance")?.GetValue(val);
		GameObject val2 = (GameObject)((obj2 is GameObject) ? obj2 : null);
		if ((Object)(object)val2 == (Object)null)
		{
			return;
		}
		string text = ((Object)val2).name.Replace("(Clone)", "").Trim();
		if (Class1.drinkPrefabNames.Contains(text) || text.StartsWith("valhala_energy"))
		{
			Transform val3 = val2.transform.Find("attach/model");
			if ((Object)(object)val3 == (Object)null)
			{
				val3 = val2.transform.Find("model");
			}
			if ((Object)(object)val3 != (Object)null)
			{
				val3.localEulerAngles = new Vector3(180f, 0f, 0f);
			}
		}
	}
}