Decompiled source of EverythingMotive v2.0.1

EverythingMotive.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using EverythingMotive.Patches;
using EverythingMotive.Resources;
using EverythingMotive.Types;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("EverythingMotive")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0")]
[assembly: AssemblyProduct("Everything Motive")]
[assembly: AssemblyTitle("EverythingMotive")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace EverythingMotive
{
	[BepInPlugin("ro.wolftech.dogle.everythingmotive", "Everything Motive", "2.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("ro.wolftech.dogle.everythingmotive");
			val.PatchAll(typeof(AssetManager));
			val.PatchAll(typeof(PlayerAddPerk));
			val.PatchAll(typeof(ItemWeight));
			Logger.LogInfo((object)"Everything Motive has loaded!");
		}
	}
	public static class PluginInformation
	{
		public const string GUID = "ro.wolftech.dogle.everythingmotive";

		public const string Name = "Everything Motive";

		public const string Version = "2.0.0";
	}
}
namespace EverythingMotive.Types
{
	public class PerkModule_BuffFromInventoryCustom : PerkModule
	{
		public enum Kind
		{
			ItemTag,
			PrefabName
		}

		public BuffContainer buff;

		public float buffMultiplier = 0.1f;

		public Kind lookupKind;

		public string lookup = "";

		private BuffContainer currentBuff;

		private Perk perk => AccessTools.FieldRefAccess<PerkModule, Perk>((PerkModule)(object)this, "perk");

		private ENT_Player perkPlayer => AccessTools.FieldRefAccess<Perk, ENT_Player>(perk, "player");

		public override void Initialize(Perk p, bool firstTime)
		{
			((PerkModule)this).Initialize(p, firstTime);
			if (buff.id != "")
			{
				currentBuff = ((GameEntity)perkPlayer).curBuffs.GetBuffContainer(buff.id);
			}
			if (currentBuff == null)
			{
				((GameEntity)perkPlayer).curBuffs.AddBuff(buff);
				currentBuff = ((GameEntity)perkPlayer).curBuffs.GetBuffContainer(buff.id);
			}
			currentBuff.SetMultiplier(1f * buffMultiplier);
		}

		public override void Update()
		{
			((PerkModule)this).Update();
			currentBuff.SetMultiplier(GetMults() * buffMultiplier);
		}

		public float GetMults()
		{
			return Inventory.instance.GetItems(true, false, true).Count((Item x) => (lookupKind != Kind.ItemTag) ? (x.prefabName == lookup) : x.HasTag(lookup));
		}

		public override void OnDestroy(Perk p)
		{
			if ((Object)(object)perkPlayer != (Object)null)
			{
				((GameEntity)perkPlayer).curBuffs.RemoveBuffContainer(buff.id);
			}
			((PerkModule)this).OnDestroy(p);
		}

		public override float GetStatBuff(string key, bool total = false)
		{
			float num = 1f;
			if ((Object)(object)perk != (Object)null && total)
			{
				num = Mathf.Max(perk.GetStackEvaluationMultiplier(), 1f);
			}
			return key switch
			{
				"bfic_buff" => buff.buffs[0].maxAmount * num * buffMultiplier, 
				"bfic_current" => buff.buffs[0].maxAmount * GetMults() * num * buffMultiplier, 
				"bfic_items" => GetMults(), 
				_ => ((PerkModule)this).GetStatBuff(key, false), 
			};
		}

		public override string GetCounterString()
		{
			float mults = GetMults();
			if (mults == 0f)
			{
				return "";
			}
			return ((int)mults).ToString();
		}

		public override string GetDescriptionFromKey(string key)
		{
			if ((Object)(object)perk == (Object)null)
			{
				return "";
			}
			return ((PerkModule)this).GetDescriptionFromKey(key);
		}
	}
	public class PerkModule_BuffFromPerks : PerkModule
	{
		public BuffContainer buff;

		public float buffMultiplier = 0.1f;

		public HashSet<string> lookup = new HashSet<string>
		{
			"Perk_ProfitMotive", "Perk_EverythingMotive", "Perk_MortarMotive", "Perk_MedicineMotive", "Perk_ClimberMotive", "Perk_Rhotive", "Perk_MotiveMotive", "Perk_HungerMotive", "Perk_SteelMotive", "Perk_ManuscriptMotive",
			"Perk_SkeletalMotive"
		};

		private BuffContainer currentBuff;

		private Perk _perk;

		private ENT_Player _perkPlayer;

		private Perk perk
		{
			get
			{
				try
				{
					if ((Object)(object)_perk == (Object)null)
					{
						_perk = AccessTools.FieldRefAccess<PerkModule, Perk>((PerkModule)(object)this, "perk");
					}
					return _perk;
				}
				catch
				{
					return null;
				}
			}
		}

		private ENT_Player perkPlayer
		{
			get
			{
				try
				{
					if ((Object)(object)_perkPlayer == (Object)null)
					{
						_perkPlayer = AccessTools.FieldRefAccess<Perk, ENT_Player>(perk, "player");
					}
					return _perkPlayer;
				}
				catch
				{
					return null;
				}
			}
		}

		public override void Initialize(Perk p, bool firstTime)
		{
			((PerkModule)this).Initialize(p, firstTime);
			if (buff.id != "")
			{
				currentBuff = ((GameEntity)perkPlayer).curBuffs.GetBuffContainer(buff.id);
			}
			if (currentBuff == null)
			{
				((GameEntity)perkPlayer).curBuffs.AddBuff(buff);
				currentBuff = ((GameEntity)perkPlayer).curBuffs.GetBuffContainer(buff.id);
			}
			currentBuff.SetMultiplier(1f * buffMultiplier);
		}

		public override void Update()
		{
			((PerkModule)this).Update();
			currentBuff.SetMultiplier(GetMults() * buffMultiplier);
		}

		public float GetMults()
		{
			return (((Object)(object)perkPlayer == (Object)null) ? new List<Perk>() : perkPlayer.perks).Where((Perk x) => lookup.Count == 0 || lookup.Contains(x.id)).Sum((Perk x) => x.stackAmount);
		}

		public override void OnDestroy(Perk p)
		{
			if ((Object)(object)perkPlayer != (Object)null)
			{
				((GameEntity)perkPlayer).curBuffs.RemoveBuffContainer(buff.id);
			}
			((PerkModule)this).OnDestroy(p);
		}

		public override float GetStatBuff(string key, bool total = false)
		{
			float num = 1f;
			if ((Object)(object)perk != (Object)null && total)
			{
				num = Mathf.Max(perk.GetStackEvaluationMultiplier(), 1f);
			}
			return key switch
			{
				"bfp_buff" => buff.buffs[0].maxAmount * num * buffMultiplier, 
				"bfp_current" => buff.buffs[0].maxAmount * GetMults() * num * buffMultiplier, 
				"bfp_items" => GetMults(), 
				_ => ((PerkModule)this).GetStatBuff(key, false), 
			};
		}

		public override string GetCounterString()
		{
			float mults = GetMults();
			if (mults == 0f)
			{
				return "";
			}
			return ((int)mults).ToString();
		}

		public override string GetDescriptionFromKey(string key)
		{
			if ((Object)(object)perk == (Object)null)
			{
				return "";
			}
			return ((PerkModule)this).GetDescriptionFromKey(key);
		}
	}
	public class PerkModule_BuffFromStacks : PerkModule
	{
		public BuffContainer buff;

		public float buffMultiplier = 0.1f;

		private BuffContainer currentBuff;

		private Perk perk => AccessTools.FieldRefAccess<PerkModule, Perk>((PerkModule)(object)this, "perk");

		private ENT_Player perkPlayer => AccessTools.FieldRefAccess<Perk, ENT_Player>(perk, "player");

		private static IEnumerable<IGrouping<string, Item>> ItemsGroupedByStacks => from x in Inventory.instance.GetItems(true, false, true)
			group x by (!string.IsNullOrWhiteSpace(x.itemTag)) ? x.itemTag : x.prefabName;

		public override void Initialize(Perk p, bool firstTime)
		{
			((PerkModule)this).Initialize(p, firstTime);
			if (buff.id != "")
			{
				currentBuff = ((GameEntity)perkPlayer).curBuffs.GetBuffContainer(buff.id);
			}
			if (currentBuff == null)
			{
				((GameEntity)perkPlayer).curBuffs.AddBuff(buff);
				currentBuff = ((GameEntity)perkPlayer).curBuffs.GetBuffContainer(buff.id);
			}
			currentBuff.SetMultiplier(1f * buffMultiplier);
		}

		public override void Update()
		{
			((PerkModule)this).Update();
			currentBuff.SetMultiplier(GetMults() * buffMultiplier * GetStacks());
		}

		public static bool ItemInStack(Item item)
		{
			return ItemsGroupedByStacks.Where((IGrouping<string, Item> x) => x.Count() > 1).SelectMany((IGrouping<string, Item> x) => x).Any((Item x) => x.itemTag == item.itemTag || x.prefabName == item.prefabName);
		}

		public float GetStacks()
		{
			return ItemsGroupedByStacks.Count((IGrouping<string, Item> x) => x.Count() > 1);
		}

		public float GetMults()
		{
			return ItemsGroupedByStacks.Where((IGrouping<string, Item> x) => x.Count() > 1).Sum((IGrouping<string, Item> x) => x.Count() - 1);
		}

		public override void OnDestroy(Perk p)
		{
			if ((Object)(object)perkPlayer != (Object)null)
			{
				((GameEntity)perkPlayer).curBuffs.RemoveBuffContainer(buff.id);
			}
			((PerkModule)this).OnDestroy(p);
		}

		public override float GetStatBuff(string key, bool total = false)
		{
			float num = 1f;
			if ((Object)(object)perk != (Object)null && total)
			{
				num = Mathf.Max(perk.GetStackEvaluationMultiplier(), 1f);
			}
			return key switch
			{
				"em_item_count" => buff.buffs[0].maxAmount * num * buffMultiplier, 
				"em_current" => buff.buffs[0].maxAmount * GetMults() * GetStacks() * num * buffMultiplier, 
				"em_items" => GetMults(), 
				"em_stacks" => GetStacks(), 
				_ => ((PerkModule)this).GetStatBuff(key, false), 
			};
		}

		public override string GetCounterString()
		{
			float num = GetMults() * GetStacks();
			if (num == 0f)
			{
				return "";
			}
			return ((int)num).ToString();
		}

		public override string GetDescriptionFromKey(string key)
		{
			if ((Object)(object)perk == (Object)null)
			{
				return "";
			}
			return ((PerkModule)this).GetDescriptionFromKey(key);
		}
	}
}
namespace EverythingMotive.Resources
{
	public static class BuffResources
	{
		public static BuffContainer CreateBuffContainer(string name, float amnt = 0.3f, float fov = 10f)
		{
			//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_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			//IL_0130: Expected O, but got Unknown
			return new BuffContainer
			{
				id = "Perk_" + name.Replace(" ", string.Empty),
				loseRate = 0f,
				loseOverTime = false,
				buffs = new List<Buff>(6)
				{
					new Buff
					{
						id = "addSpeed",
						amount = amnt,
						maxAmount = amnt
					},
					new Buff
					{
						id = "addClimb",
						amount = 0f,
						maxAmount = amnt
					},
					new Buff
					{
						id = "addStaminaRegen",
						amount = 0f,
						maxAmount = amnt
					},
					new Buff
					{
						id = "addJump",
						amount = 0f,
						maxAmount = amnt
					},
					new Buff
					{
						id = "addReach",
						amount = 0f,
						maxAmount = amnt
					},
					new Buff
					{
						id = "addFOV",
						amount = 0f,
						maxAmount = fov
					}
				}
			};
		}
	}
	public static class PerkResources
	{
		public const string CheatingDescription = "(-)<color=#9E3636>Counts as cheating, leaderboards are disabled";

		private static readonly Dictionary<string, Perk> PerkCache = new Dictionary<string, Perk>();

		public static Perk ClimberMotive => CreateMotive("Climber Motive", new string[3] { "(+)Each piton (including subtypes of pitons) in your inventory buffs most stats by {%bfic_buff}%", "(-)<color=#9E3636>Counts as cheating, leaderboards are disabled", "[$<color=yellow>Current: +{%bfic_current}% | Pitons: {bfic_items}]" }, (PerkModule[])(object)new PerkModule[1]
		{
			new PerkModule_BuffFromInventoryCustom
			{
				lookupKind = PerkModule_BuffFromInventoryCustom.Kind.ItemTag,
				lookup = "piton",
				buff = BuffResources.CreateBuffContainer("Climber Motive")
			}
		});

		public static Perk EverythingMotive => CreateMotive("Everything Motive", new string[5] { "(+)Each item in a stack buffs most stats by {%em_item_count}%", "(+)Each unique item stack increases the base multiplier", "(+)Items, if in a stack, count less towards encumberance", "(-)<color=#9E3636>Counts as cheating, leaderboards are disabled", "[$<color=yellow>Current: +{%em_current}% | Items: {em_items} | Stacks: {em_stacks}]" }, (PerkModule[])(object)new PerkModule[1]
		{
			new PerkModule_BuffFromStacks
			{
				buff = BuffResources.CreateBuffContainer("Everything Motive", 0.1f, 3.33f)
			}
		});

		public static Perk HungerMotive => CreateMotive("Hunger Motive", new string[3] { "(+)Each food item in your inventory buffs most stats by {%bfic_buff}%", "(-)<color=#9E3636>Counts as cheating, leaderboards are disabled", "[$<color=yellow>Current: +{%bfic_current}% | Food: {bfic_items}]" }, (PerkModule[])(object)new PerkModule[1]
		{
			new PerkModule_BuffFromInventoryCustom
			{
				lookupKind = PerkModule_BuffFromInventoryCustom.Kind.ItemTag,
				lookup = "food",
				buff = BuffResources.CreateBuffContainer("Hunger Motive")
			}
		});

		public static Perk ManuscriptMotive => CreateMotive("Manuscript Motive", new string[3] { "(+)Each note in your inventory buffs most stats by {%bfic_buff}%", "(-)<color=#9E3636>Counts as cheating, leaderboards are disabled", "[$<color=yellow>Current: +{%bfic_current}% | Notes: {bfic_items}]" }, (PerkModule[])(object)new PerkModule[1]
		{
			new PerkModule_BuffFromInventoryCustom
			{
				lookupKind = PerkModule_BuffFromInventoryCustom.Kind.ItemTag,
				lookup = "note",
				buff = BuffResources.CreateBuffContainer("Manuscript Motive")
			}
		});

		public static Perk MedicineMotive => CreateMotive("Medicine Motive", new string[3] { "(+)Drugs in your inventory (primarily pill bottles and injectors) buff most stats by {%bfic_buff}%", "(-)<color=#9E3636>Counts as cheating, leaderboards are disabled", "[$<color=yellow>Current: +{%bfic_current}% | Drugs: {bfic_items}]" }, (PerkModule[])(object)new PerkModule[1]
		{
			new PerkModule_BuffFromInventoryCustom
			{
				lookupKind = PerkModule_BuffFromInventoryCustom.Kind.ItemTag,
				lookup = "drug",
				buff = BuffResources.CreateBuffContainer("Medicine Motive")
			}
		});

		public static Perk MortarMotive => CreateMotive("Mortar Motive", new string[3] { "(+)Each brick in your inventory buffs most stats by {%bfic_buff}%", "(-)<color=#9E3636>Counts as cheating, leaderboards are disabled", "[$<color=yellow>Current: +{%bfic_current}% | Bricks: {bfic_items}]" }, (PerkModule[])(object)new PerkModule[1]
		{
			new PerkModule_BuffFromInventoryCustom
			{
				lookupKind = PerkModule_BuffFromInventoryCustom.Kind.ItemTag,
				lookup = "brick",
				buff = BuffResources.CreateBuffContainer("Mortar Motive")
			}
		});

		public static Perk MotiveMotive => CreateMotive("Motive Motive", new string[4] { "(+)Each motive perk buffs most stats by {%bfp_buff}% (stacks are accounted for)", "(-)<color=#9E3636>Will lag your game a LOT", "(-)<color=#9E3636>Counts as cheating, leaderboards are disabled", "[$<color=yellow>Current: +{%bfp_current}% | Motives: {bfp_items}]" }, (PerkModule[])(object)new PerkModule[1]
		{
			new PerkModule_BuffFromPerks
			{
				buff = BuffResources.CreateBuffContainer("Motive Motive", 0.1f, 3.33f)
			}
		}, "Are you okay in the head?");

		public static Perk RhotivePerk => CreateMotive("Rhotive", new string[3] { "(+)Each artifact (both minor and major) in your inventory buffs most stats by {%bfic_buff}%", "(-)<color=#9E3636>Counts as cheating, leaderboards are disabled", "[$<color=yellow>Current: +{%bfic_current}% | Artifacts: {bfic_items}]" }, (PerkModule[])(object)new PerkModule[1]
		{
			new PerkModule_BuffFromInventoryCustom
			{
				lookupKind = PerkModule_BuffFromInventoryCustom.Kind.ItemTag,
				lookup = "artifact",
				buff = BuffResources.CreateBuffContainer("Rhotive")
			}
		});

		public static Perk SkeletalMotive => CreateMotive("Skeletal Motive", new string[4] { "(+)Anything made of bone (as of right now only bone spears) in your inventory buffs most stats by {%bfic_buff}%", "(+)Items that affect this perk count less towards encumberance", "(-)<color=#9E3636>Counts as cheating, leaderboards are disabled", "[$<color=yellow>Current: +{%bfic_current}% | Bones: {bfic_items}]" }, (PerkModule[])(object)new PerkModule[1]
		{
			new PerkModule_BuffFromInventoryCustom
			{
				lookupKind = PerkModule_BuffFromInventoryCustom.Kind.PrefabName,
				lookup = "Item_Rebar_Bone",
				buff = BuffResources.CreateBuffContainer("Skeletal Motive", 0.15f, 5f)
			}
		});

		public static Perk SteelMotive => CreateMotive("Steel Motive", new string[3] { "(+)Each rebar (including subtypes of rebar) in your inventory buffs most stats by {%bfic_buff}%", "(-)<color=#9E3636>Counts as cheating, leaderboards are disabled", "[$<color=yellow>Current: +{%bfic_current}% | Rebar: {bfic_items}]" }, (PerkModule[])(object)new PerkModule[1]
		{
			new PerkModule_BuffFromInventoryCustom
			{
				lookupKind = PerkModule_BuffFromInventoryCustom.Kind.ItemTag,
				lookup = "rebar",
				buff = BuffResources.CreateBuffContainer("Steel Motive")
			}
		});

		private static Perk CreateMotive(string name, string[] descStuff, PerkModule[] perkModules, string flavor = "")
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Expected O, but got Unknown
			if (PerkCache.TryGetValue(name, out var value))
			{
				return value;
			}
			string text = name.Replace(" ", string.Empty);
			Perk val = ScriptableObject.CreateInstance<Perk>();
			val.tags = new List<string>(2) { "standard", "tier2" };
			((Object)val).name = "Perk_T2_" + text;
			val.id = "Perk_" + text;
			val.description = string.Join("\n", descStuff);
			if (!string.IsNullOrWhiteSpace(flavor))
			{
				val.flavorText = flavor;
			}
			val.title = name;
			val.perkType = (PerkType)1;
			val.cost = 10;
			val.stackMax = 5;
			val.useBuff = false;
			val.multiplierCurve = AnimationCurve.Linear(0f, 1f, 1f, 1f);
			val.unlockProgressionID = "perk_t4";
			val.unlockXP = -4;
			val.spawnPool = (PerkPool)0;
			val.sortingCategory = 2;
			val.spawnSettings = new SpawnSettings
			{
				spawnChance = 3f,
				settingModules = new List<SpawnSettingModule>()
			};
			val.competitive = false;
			val.perkFrame = SpriteResources.PerkFrame;
			val.perkCard = SpriteResources.GetSpriteFromModResources("Cards/Perk_Card_" + text + ".png");
			val.icon = SpriteResources.GetSpriteFromModResources("Icons/Perk_Icon_" + text + ".png");
			val.buff = new BuffContainer
			{
				buffs = new List<Buff>()
			};
			val.modules = perkModules.ToList();
			PerkCache[name] = val;
			return val;
		}
	}
	public static class SpriteResources
	{
		private static Sprite _perkFrame;

		public static Sprite PerkFrame
		{
			get
			{
				if ((Object)(object)_perkFrame == (Object)null)
				{
					_perkFrame = CL_AssetManager.baseDatabase.perkAssets.First((Perk x) => x.title == "Profit Motive").perkFrame;
				}
				return _perkFrame;
			}
		}

		public static Sprite GetSpriteFromModResources(string name)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("EverythingMotive.Assets." + name.Replace('/', '.'));
			byte[] array = new byte[manifestResourceStream.Length];
			manifestResourceStream.Read(array, 0, (int)manifestResourceStream.Length);
			manifestResourceStream.Dispose();
			Texture2D val = new Texture2D(1, 1);
			ImageConversion.LoadImage(val, array);
			Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.one * 0.5f, 100f);
			((Texture)obj.texture).filterMode = (FilterMode)0;
			return obj;
		}
	}
}
namespace EverythingMotive.Patches
{
	[HarmonyPatch(typeof(CL_AssetManager), "Initialize")]
	internal static class AssetManager
	{
		public static readonly List<Perk> ModdedPerks = new List<Perk>(10)
		{
			PerkResources.EverythingMotive,
			PerkResources.MortarMotive,
			PerkResources.MedicineMotive,
			PerkResources.ClimberMotive,
			PerkResources.RhotivePerk,
			PerkResources.MotiveMotive,
			PerkResources.HungerMotive,
			PerkResources.SteelMotive,
			PerkResources.ManuscriptMotive,
			PerkResources.SkeletalMotive
		};

		[HarmonyPostfix]
		public static void Postfix(ref CL_AssetManager __instance)
		{
			WKAssetDatabase val = ScriptableObject.CreateInstance<WKAssetDatabase>();
			val.id = "ro.wolftech.dogle.everythingmotive";
			val.perkAssets = ModdedPerks;
			CL_AssetManager.AddNewDatabase(val.id, val);
		}
	}
	[HarmonyPatch(typeof(Inventory), "CalculateItemWeight")]
	internal static class ItemWeight
	{
		[HarmonyPostfix]
		public static void Postfix(ref Item __0, ref float __result)
		{
			Perk perk = ENT_Player.playerObject.GetPerk("Perk_EverythingMotive");
			Perk perk2 = ENT_Player.playerObject.GetPerk("Perk_SkeletalMotive");
			if (Object.op_Implicit((Object)(object)perk) && PerkModule_BuffFromStacks.ItemInStack(__0))
			{
				__result /= 2.5f * Mathf.Max(perk.GetStackEvaluationMultiplier(), 1f);
			}
			if (Object.op_Implicit((Object)(object)perk2) && __0.prefabName == "Item_Rebar_Bone")
			{
				__result /= 1.5f * Mathf.Max(perk2.GetStackEvaluationMultiplier(), 1f);
			}
		}
	}
	[HarmonyPatch(typeof(ENT_Player), "AddPerk")]
	internal static class PlayerAddPerk
	{
		[HarmonyPostfix]
		public static void Postfix(ref Perk __0)
		{
			string id = __0.id;
			bool flag = false;
			foreach (Perk moddedPerk in AssetManager.ModdedPerks)
			{
				if (moddedPerk.id.ToLower() == id.ToLower())
				{
					flag = true;
					break;
				}
			}
			if (flag)
			{
				CommandConsole.hasCheated = true;
				CL_UIManager.instance.cheatTracker.SetActive(true);
			}
		}
	}
}