Decompiled source of Powershakes v1.3.0

plugins/Powershakes.dll

Decompiled 6 months 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 HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;

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

[BepInPlugin("TinyOak.Powershakes", "Powershakes", "1.3.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("valheim.exe")]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
internal class PowershakesPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Ship), "GetSailForce")]
	private class Guckshake2000ShipEffectsPatch
	{
		private static void Postfix(Ship __instance, ref Vector3 __result)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			Player player = Player.GetPlayer(__instance.m_shipControlls.GetUser());
			if (!((Object)(object)player == (Object)null) && ((Character)player).m_seman.HaveStatusEffect(StringExtensionMethods.GetStableHashCode("GP_Custom_GutBlaster")))
			{
				__result *= 5f;
			}
		}
	}

	public const string PluginGUID = "TinyOak.Powershakes";

	public const string PluginName = "Powershakes";

	public const string PluginVersion = "1.3.0";

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

	private AssetBundle _powershakeAssets;

	private CustomStatusEffect GutBlasterStatusEffect;

	private CustomStatusEffect TreeMurdererStatusEffect;

	private CustomStatusEffect DeerGodStatusEffect;

	private readonly Harmony _harmonyPatcher = new Harmony("TinyOak.Powershakes");

	private void Awake()
	{
		Logger.LogInfo((object)"Loading...");
		_powershakeAssets = AssetUtils.LoadAssetBundleFromResources("powershakes");
		AddCustomStatusEffects();
		PrefabManager.OnVanillaPrefabsAvailable += AddCustomItems;
		_harmonyPatcher.PatchAll();
		Logger.LogInfo((object)"Loaded successfully!");
	}

	private void AddCustomItems()
	{
		AddGuckshakeItem();
		AddGuckshake2000Item();
		AddBuckshakeItem();
		AddBuckshake2000Item();
		AddChuckshakeItem();
		AddChuckshakeItem2000();
		PrefabManager.OnVanillaPrefabsAvailable -= AddCustomItems;
	}

	private void AddGuckshakeItem()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Expected O, but got Unknown
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Expected O, but got Unknown
		ItemConfig val = new ItemConfig
		{
			Name = "$item_guckshake",
			Description = "$item_guckshake_desc",
			CraftingStation = CraftingStations.Cauldron,
			Icon = _powershakeAssets.LoadAsset<Sprite>("assets/powershakes/icon/guckshakeicon.png")
		};
		val.AddRequirement(new RequirementConfig("Guck", 1, 0, false));
		val.AddRequirement(new RequirementConfig("Raspberry", 2, 0, false));
		val.AddRequirement(new RequirementConfig("Blueberries", 2, 0, false));
		CustomItem val2 = new CustomItem(_powershakeAssets, "assets/powershakes/shakemodels/guckshake.prefab", false, val);
		val2.ItemDrop.m_itemData.m_shared.m_consumeStatusEffect = _powershakeAssets.LoadAsset<StatusEffect>("assets/powershakes/statuseffects/GP_Custom_Moder.asset");
		ItemManager.Instance.AddItem(val2);
		CustomLocalization localization = Localization;
		string text = "English";
		localization.AddTranslation(ref text, new Dictionary<string, string>
		{
			{ "item_guckshake", "Guckshake" },
			{ "item_guckshake_desc", "Gotta go fast!" }
		});
	}

	private void AddGuckshake2000Item()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Expected O, but got Unknown
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Expected O, but got Unknown
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Expected O, but got Unknown
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Expected O, but got Unknown
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Expected O, but got Unknown
		ItemConfig val = new ItemConfig
		{
			Name = "$item_guckshake2000",
			Description = "$item_guckshake2000_desc",
			CraftingStation = CraftingStations.Cauldron,
			Icon = _powershakeAssets.LoadAsset<Sprite>("assets/powershakes/icon/guckshake2000icon.png"),
			Weight = 10f
		};
		val.AddRequirement(new RequirementConfig("Guck", 10, 0, false));
		val.AddRequirement(new RequirementConfig("Raspberry", 20, 0, false));
		val.AddRequirement(new RequirementConfig("Blueberries", 20, 0, false));
		CustomItem val2 = new CustomItem(_powershakeAssets, "assets/powershakes/shakemodels/guckshake2000.prefab", false, val);
		val2.ItemDrop.m_itemData.m_shared.m_consumeStatusEffect = GutBlasterStatusEffect.StatusEffect;
		ItemManager.Instance.AddItem(val2);
		CustomLocalization localization = Localization;
		string text = "English";
		localization.AddTranslation(ref text, new Dictionary<string, string>
		{
			{ "item_guckshake2000", "Guckshake2000" },
			{ "item_guckshake2000_desc", "Gotta go really fast!" }
		});
	}

	private void AddBuckshakeItem()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Expected O, but got Unknown
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Expected O, but got Unknown
		ItemConfig val = new ItemConfig
		{
			Name = "$item_buckshake",
			Description = "$item_buckshake_desc",
			CraftingStation = CraftingStations.Cauldron,
			Icon = _powershakeAssets.LoadAsset<Sprite>("assets/powershakes/icon/buckshakeicon.png")
		};
		val.AddRequirement(new RequirementConfig("TrophyDeer", 1, 0, false));
		val.AddRequirement(new RequirementConfig("Raspberry", 2, 0, false));
		val.AddRequirement(new RequirementConfig("Blueberries", 2, 0, false));
		CustomItem val2 = new CustomItem(_powershakeAssets, "assets/powershakes/shakemodels/buckshake.prefab", false, val);
		val2.ItemDrop.m_itemData.m_shared.m_consumeStatusEffect = _powershakeAssets.LoadAsset<StatusEffect>("assets/powershakes/statuseffects/GP_Custom_Eikthyr.asset");
		ItemManager.Instance.AddItem(val2);
		CustomLocalization localization = Localization;
		string text = "English";
		localization.AddTranslation(ref text, new Dictionary<string, string>
		{
			{ "item_buckshake", "Buckshake" },
			{ "item_buckshake_desc", "Move those trotters!" }
		});
	}

	private void AddBuckshake2000Item()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Expected O, but got Unknown
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Expected O, but got Unknown
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Expected O, but got Unknown
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Expected O, but got Unknown
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Expected O, but got Unknown
		ItemConfig val = new ItemConfig
		{
			Name = "$item_buckshake2000",
			Description = "$item_buckshake2000_desc",
			CraftingStation = CraftingStations.Cauldron,
			Icon = _powershakeAssets.LoadAsset<Sprite>("assets/powershakes/icon/buckshake2000icon.png"),
			Weight = 10f
		};
		val.AddRequirement(new RequirementConfig("TrophyDeer", 10, 0, false));
		val.AddRequirement(new RequirementConfig("Raspberry", 20, 0, false));
		val.AddRequirement(new RequirementConfig("Blueberries", 20, 0, false));
		CustomItem val2 = new CustomItem(_powershakeAssets, "assets/powershakes/shakemodels/buckshake2000.prefab", false, val);
		val2.ItemDrop.m_itemData.m_shared.m_consumeStatusEffect = DeerGodStatusEffect.StatusEffect;
		ItemManager.Instance.AddItem(val2);
		CustomLocalization localization = Localization;
		string text = "English";
		localization.AddTranslation(ref text, new Dictionary<string, string>
		{
			{ "item_buckshake2000", "Buckshake2000" },
			{ "item_buckshake2000_desc", "Oh deer!" }
		});
	}

	private void AddChuckshakeItem()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Expected O, but got Unknown
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Expected O, but got Unknown
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Expected O, but got Unknown
		ItemConfig val = new ItemConfig
		{
			Name = "$item_chuckshake",
			Description = "$item_chuckshake_desc",
			CraftingStation = CraftingStations.Cauldron,
			Icon = _powershakeAssets.LoadAsset<Sprite>("assets/powershakes/icon/chuckshakeicon.png")
		};
		val.AddRequirement(new RequirementConfig("AncientSeed", 1, 0, false));
		val.AddRequirement(new RequirementConfig("Raspberry", 2, 0, false));
		val.AddRequirement(new RequirementConfig("Blueberries", 2, 0, false));
		CustomItem val2 = new CustomItem(_powershakeAssets, "assets/powershakes/shakemodels/chuckshake.prefab", false, val);
		val2.ItemDrop.m_itemData.m_shared.m_consumeStatusEffect = _powershakeAssets.LoadAsset<StatusEffect>("assets/powershakes/statuseffects/GP_Custom_TheElder.asset");
		ItemManager.Instance.AddItem(val2);
		CustomLocalization localization = Localization;
		string text = "English";
		localization.AddTranslation(ref text, new Dictionary<string, string>
		{
			{ "item_chuckshake", "Chuckshake" },
			{ "item_chuckshake_desc", "How much wood can a woodchuck chuck?" }
		});
	}

	private void AddChuckshakeItem2000()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Expected O, but got Unknown
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Expected O, but got Unknown
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: Expected O, but got Unknown
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Expected O, but got Unknown
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Expected O, but got Unknown
		ItemConfig val = new ItemConfig
		{
			Name = "$item_chuckshake2000",
			Description = "$item_chuckshake2000_desc",
			CraftingStation = CraftingStations.Cauldron,
			Icon = _powershakeAssets.LoadAsset<Sprite>("assets/powershakes/icon/chuckshake2000icon.png"),
			Weight = 10f
		};
		val.AddRequirement(new RequirementConfig("AncientSeed", 10, 0, false));
		val.AddRequirement(new RequirementConfig("Raspberry", 20, 0, false));
		val.AddRequirement(new RequirementConfig("Blueberries", 20, 0, false));
		CustomItem val2 = new CustomItem(_powershakeAssets, "assets/powershakes/shakemodels/chuckshake2000.prefab", false, val);
		val2.ItemDrop.m_itemData.m_shared.m_consumeStatusEffect = TreeMurdererStatusEffect.StatusEffect;
		ItemManager.Instance.AddItem(val2);
		CustomLocalization localization = Localization;
		string text = "English";
		localization.AddTranslation(ref text, new Dictionary<string, string>
		{
			{ "item_chuckshake2000", "Chuckshake2000" },
			{ "item_chuckshake2000_desc", "A lot, as it turns out." }
		});
	}

	private void AddCustomStatusEffects()
	{
		AddGutBlasterStatusEffect();
		AddTreeMurdererStatusEffect();
		AddDeerGodStatusEffect();
	}

	private void AddGutBlasterStatusEffect()
	{
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		StatusEffect val = _powershakeAssets.LoadAsset<StatusEffect>("assets/powershakes/statuseffects/GP_Custom_GutBlaster.asset");
		CustomLocalization localization = Localization;
		string text = "English";
		localization.AddTranslation(ref text, new Dictionary<string, string>
		{
			{ "gutblaster_effectname", "Gut Blaster" },
			{ "gutblaster_effectstart", "You feel the guck hit your stomach..." },
			{ "gutblaster_effectstop", "You feel the effects of the guck waning" },
			{ "gutblaster_tooltip", "Your bodily gases will power the sails of your ship." }
		});
		GutBlasterStatusEffect = new CustomStatusEffect(val, false);
		ItemManager.Instance.AddStatusEffect(GutBlasterStatusEffect);
	}

	private void AddTreeMurdererStatusEffect()
	{
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		StatusEffect val = _powershakeAssets.LoadAsset<StatusEffect>("assets/powershakes/statuseffects/GP_Custom_Chuckshake2000.asset");
		CustomLocalization localization = Localization;
		string text = "English";
		localization.AddTranslation(ref text, new Dictionary<string, string>
		{
			{ "treemurderer_effectname", "Tree Murderer" },
			{ "treemurderer_effectstart", "You feel the ancient seeds rage in your mind..." },
			{ "treemurderer_effectstop", "The rage of the ancient seeds begins to fade" },
			{ "treemurderer_tooltip", "You do 2000% damage to trees." }
		});
		TreeMurdererStatusEffect = new CustomStatusEffect(val, false);
		ItemManager.Instance.AddStatusEffect(TreeMurdererStatusEffect);
	}

	private void AddDeerGodStatusEffect()
	{
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		SE_Stats val = _powershakeAssets.LoadAsset<SE_Stats>("assets/powershakes/statuseffects/GP_Custom_Buckshake2000.asset");
		CustomLocalization localization = Localization;
		string text = "English";
		localization.AddTranslation(ref text, new Dictionary<string, string>
		{
			{ "deergod_effectname", "Deer God" },
			{ "deergod_effectstart", "You feel a need, a need for speed..." },
			{ "deergod_effectstop", "The need for speed begins to fade" },
			{ "deergod_tooltip", "Running and jumping use 80% less stamina. You move 100% faster and jump 40% higher and take 90% less fall damage." }
		});
		DeerGodStatusEffect = new CustomStatusEffect((StatusEffect)(object)val, false);
		ItemManager.Instance.AddStatusEffect(DeerGodStatusEffect);
	}
}