Decompiled source of Valweed v0.3.5

plugins/Valweed/Valweed.dll

Decompiled 5 days ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.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;
		}
	}
}
public class Bong : MonoBehaviour, Hoverable, Interactable
{
	public static readonly int BongEffectHash = StringExtensionMethods.GetStableHashCode("BongStatusEffect");

	private ZNetView m_nview;

	[Header("Bong")]
	public string m_name = "$piece_bong";

	public float m_startFuel = 3f;

	public float m_maxFuel = 10f;

	public float m_secPerFuel = 3f;

	public float m_checkTerrainOffset = 0.2f;

	public float m_coverCheckOffset = 0.5f;

	public float m_hoverOffset;

	public ItemDrop m_fuelItem;

	public EffectList m_fuelAddedEffects = new EffectList();

	public EffectList m_smokedEffects = new EffectList();

	public float ttl;

	public bool cosmeticOnly;

	public void Awake()
	{
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: 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)
		m_nview = ((Component)this).GetComponent<ZNetView>();
		if (m_nview.GetZDO() == null)
		{
			return;
		}
		if (m_nview.IsOwner() && m_nview.GetZDO().GetFloat("fuel", -1f) == -1f)
		{
			m_nview.GetZDO().Set("fuel", m_startFuel);
			if (m_startFuel > 0f)
			{
				m_fuelAddedEffects.Create(((Component)this).transform.position, ((Component)this).transform.rotation, (Transform)null, 1f, -1, default(ZDOID));
			}
		}
		m_nview.Register("AddFuel", (Action<long>)RPC_AddFuel);
	}

	private float GetFuel()
	{
		return m_nview.GetZDO().GetFloat("fuel", 0f);
	}

	private void SetBowlVisible(bool visible)
	{
		Transform val = ((Component)this).transform.Find("_enabled");
		if (Object.op_Implicit((Object)(object)val))
		{
			((Component)val).gameObject.SetActive(visible);
		}
	}

	public string GetHoverText()
	{
		return Localization.instance.Localize(m_name + " ( $piece_fire_fuel " + Mathf.Ceil(GetFuel()) + "/" + (int)m_maxFuel + " )\n[<color=yellow><b>$KEY_Use</b></color>] $piece_use " + m_fuelItem.m_itemData.m_shared.m_name + "\n[<color=yellow><b>1-8</b></color>] $piece_useitem");
	}

	public string GetHoverName()
	{
		return m_name;
	}

	public float GetHoverOffset()
	{
		return m_hoverOffset;
	}

	public bool Interact(Humanoid user, bool hold, bool alt)
	{
		if (hold)
		{
			return false;
		}
		if (!m_nview.HasOwner())
		{
			m_nview.ClaimOwnership();
		}
		Inventory inventory = user.GetInventory();
		if (inventory == null)
		{
			return true;
		}
		string name = m_fuelItem.m_itemData.m_shared.m_name;
		if ((float)Mathf.CeilToInt(GetFuel()) >= m_maxFuel)
		{
			Smoke(user);
			return true;
		}
		if (inventory.HaveItem(name, true))
		{
			((Character)user).Message((MessageType)2, Localization.instance.Localize("$bong_addbud", new string[1] { name }), 0, (Sprite)null, false);
			inventory.RemoveItem(name, 1, -1, true);
			SetBowlVisible(visible: true);
			m_nview.InvokeRPC("AddFuel", Array.Empty<object>());
			return true;
		}
		((Character)user).Message((MessageType)2, "$msg_outof " + name, 0, (Sprite)null, false);
		return false;
	}

	private void Smoke(Humanoid user)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = ((Component)this).transform.position;
		position.y += 1.65f;
		((Character)user).Message((MessageType)2, Localization.instance.Localize("$bong_effectstart", new string[1] { m_fuelItem.m_itemData.m_shared.m_name }), 0, (Sprite)null, false);
		((Character)user).GetSEMan().AddStatusEffect(BongEffectHash, true, 0, 0f, (short)(-1));
		m_fuelAddedEffects.Create(position, ((Component)this).transform.rotation, (Transform)null, 1f, -1, default(ZDOID));
		m_nview.GetZDO().Set("fuel", Mathf.Max(GetFuel() - 1f, 0f));
		SetBowlVisible(visible: false);
		if (!cosmeticOnly && user is Player)
		{
			SE_Valweed.ExtendRested((Character)(object)user, ttl);
		}
	}

	public bool UseItem(Humanoid user, ItemData item)
	{
		if (item.m_shared.m_name != m_fuelItem.m_itemData.m_shared.m_name)
		{
			return false;
		}
		((Character)user).Message((MessageType)2, Localization.instance.Localize("$msg_fireadding", new string[1] { item.m_shared.m_name }), 0, (Sprite)null, false);
		user.GetInventory().RemoveItem(item, 1);
		SetBowlVisible(visible: true);
		m_nview.InvokeRPC("AddFuel", Array.Empty<object>());
		return true;
	}

	private void RPC_AddFuel(long sender)
	{
		if (m_nview.IsOwner())
		{
			float fuel = GetFuel();
			if ((float)Mathf.CeilToInt(fuel) < m_maxFuel)
			{
				m_nview.GetZDO().Set("fuel", Mathf.Clamp(fuel + 1f, 0f, m_maxFuel));
			}
		}
	}
}
public class SE_Bong : SE_Valweed
{
	protected override float CosmeticTtl => 20f;

	public override bool SlowsHunger => !cosmeticOnly;

	public override void Setup(Character character)
	{
		((SE_Stats)this).m_eitrOverTime = 10f;
		((SE_Stats)this).m_eitrOverTimeDuration = 10f;
		((SE_Stats)this).m_eitrRegenMultiplier = 10f;
		base.Setup(character);
	}
}
public class SE_Hybrid : SE_Valweed
{
}
public class SE_Indica : SE_Valweed
{
	public override void Setup(Character character)
	{
		base.Setup(character);
		if (!cosmeticOnly)
		{
			SE_Valweed.ExtendRested(((StatusEffect)this).m_character, ttl);
		}
	}

	public override void ResetTime()
	{
		base.ResetTime();
		if (!cosmeticOnly)
		{
			SE_Valweed.ExtendRested(((StatusEffect)this).m_character, ttl / 2f);
		}
	}
}
public class SE_Sativa : SE_Valweed
{
	public override bool SlowsHunger => !cosmeticOnly;
}
public abstract class SE_Valweed : SE_Stats
{
	public static readonly int RestedHash = StringExtensionMethods.GetStableHashCode("Rested");

	public int healthRegenVal;

	public int staminaRegenVal;

	public float ttl;

	public bool cosmeticOnly;

	protected virtual float CosmeticTtl => 10f;

	public virtual bool SlowsHunger => false;

	public override void Setup(Character character)
	{
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		((StatusEffect)this).m_character = character;
		base.m_healthRegenMultiplier = (cosmeticOnly ? 1f : (1f + (float)healthRegenVal / 100f));
		base.m_staminaRegenMultiplier = (cosmeticOnly ? 1f : (1f + (float)staminaRegenVal / 100f));
		((StatusEffect)this).m_ttl = (cosmeticOnly ? CosmeticTtl : ttl);
		if (!string.IsNullOrEmpty(((StatusEffect)this).m_startMessage))
		{
			((StatusEffect)this).m_character.Message(((StatusEffect)this).m_startMessageType, ((StatusEffect)this).m_startMessage, 0, (Sprite)null, false);
		}
		((StatusEffect)this).m_startEffectInstances = CreateHeadEffects();
	}

	public override void ResetTime()
	{
		((SE_Stats)this).ResetTime();
		CreateHeadEffects();
	}

	protected GameObject[] CreateHeadEffects()
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		Transform val = (Object.op_Implicit((Object)(object)((StatusEffect)this).m_character.m_head) ? ((StatusEffect)this).m_character.m_head : ((Component)((StatusEffect)this).m_character).transform);
		return ((StatusEffect)this).m_startEffects.Create(val.position, val.rotation, val, ((StatusEffect)this).m_character.GetRadius() * 2f, -1, default(ZDOID));
	}

	public static void ExtendRested(Character character, float seconds)
	{
		SEMan sEMan = character.GetSEMan();
		foreach (StatusEffect statusEffect in sEMan.GetStatusEffects())
		{
			if (statusEffect is SE_Rested)
			{
				statusEffect.m_ttl = statusEffect.m_ttl - statusEffect.m_time + seconds;
				statusEffect.m_time = 0f;
				return;
			}
		}
		sEMan.AddStatusEffect(RestedHash, true, 0, 0f, (short)(-1));
	}
}
namespace Valweed
{
	[BepInPlugin("com.drod917.Valweed", "Valweed", "0.3.5")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class Valweed : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Plant), "HaveRoof")]
		public static class PlantHaveRoof
		{
			public static bool Prefix(Plant __instance, ref bool __result)
			{
				if (__instance.m_name == "$piece_sapling_weed" || __instance.m_name == "$piece_sapling_weed_seeds")
				{
					__result = false;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Player), "CanConsumeItem")]
		public static class PlayerCanConsumeItem
		{
			public static bool Prefix(Player __instance, ItemData item, ref bool __result)
			{
				StatusEffect consumeStatusEffect = item.m_shared.m_consumeStatusEffect;
				if (Object.op_Implicit((Object)(object)consumeStatusEffect) && consumeStatusEffect is SE_Valweed && ((Character)__instance).GetSEMan().HaveStatusEffect(consumeStatusEffect.NameHash()))
				{
					__result = true;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Player), "UpdateFood")]
		public static class PlayerUpdateFood
		{
			private const float HungerRateBonus = 50f;

			public static void Prefix(Player __instance, float dt, bool forceUpdate)
			{
				if (forceUpdate || dt <= 0f)
				{
					return;
				}
				foreach (StatusEffect statusEffect in ((Character)__instance).GetSEMan().GetStatusEffects())
				{
					if (statusEffect is SE_Valweed { SlowsHunger: not false })
					{
						float num = 2f / 3f;
						__instance.m_foodUpdateTimer -= dt * Game.m_foodRate * (1f - num);
						break;
					}
				}
			}
		}

		public const string PluginGUID = "com.drod917.Valweed";

		public const string PluginName = "Valweed";

		public const string PluginVersion = "0.3.5";

		private readonly Harmony harmony = new Harmony("com.drod917.Valweed");

		private AssetBundle jointResourceBundle;

		private AssetBundle plantResourceBundle;

		private AssetBundle bongResourceBundle;

		private AssetBundle spriteBundle;

		private GameObject hybridJointPrefab;

		private GameObject indicaJointPrefab;

		private GameObject sativaJointPrefab;

		private GameObject weedSaplingPrefab;

		private GameObject weedSeedSaplingPrefab;

		private GameObject pickableWeedPrefab;

		private GameObject pickableSeedWeedPrefab;

		private GameObject weedNugsPrefab;

		private GameObject weedNugPrefab;

		private GameObject weedSeedsPrefab;

		private GameObject weedPaperPrefab;

		private GameObject bongPrefab;

		private GameObject bongNoisePrefab;

		private GameObject bongSmokePrefab;

		private GameObject bongMouthSmokePrefab;

		private GameObject bongInhaleNoisePrefab;

		private GameObject mouthSmokePrefab;

		private GameObject jointNoisePrefab;

		private SE_Hybrid hybridEffect;

		private SE_Indica indicaEffect;

		private SE_Sativa sativaEffect;

		private SE_Bong bongEffect;

		private int jointHealthRegenVal;

		private int jointStamRegenVal;

		private float jointEffectTime;

		private bool cosmeticOnly;

		private int seedGrowTime;

		private int seedYield;

		private int seedYieldBonus;

		private float seedYieldBonusChance;

		private int budGrowTime;

		private int budYield;

		private int budYieldBonus;

		private float budYieldBonusChance;

		private void Awake()
		{
			initConfig();
			LoadAssets();
			AddStatusEffects();
			CreateItems();
			CreatePieces();
			harmony.PatchAll(typeof(PlantHaveRoof));
			harmony.PatchAll(typeof(PlayerCanConsumeItem));
			harmony.PatchAll(typeof(PlayerUpdateFood));
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
			((BaseUnityPlugin)this).Config.SettingChanged += delegate
			{
				SettingChanged();
			};
		}

		private static ConfigDescription AdminDescription(string description, AcceptableValueBase range = null)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			return new ConfigDescription(description, range, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} });
		}

		private void initConfig()
		{
			jointHealthRegenVal = ((BaseUnityPlugin)this).Config.Bind<int>("Buff Settings", "Joint Health Regen Rate", 50, AdminDescription("Percent rate to increase health regen (Default 50 (+50%))", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000))).Value;
			jointStamRegenVal = ((BaseUnityPlugin)this).Config.Bind<int>("Buff Settings", "Joint Stamina Regen Rate", 100, AdminDescription("Percent rate to increase stamina regen (Default 100 (+100%))", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000))).Value;
			jointEffectTime = ((BaseUnityPlugin)this).Config.Bind<int>("Buff Settings", "Joint Buff Duration", 600, AdminDescription("Effective time for smoking to last (Default 600s (10m))", (AcceptableValueBase)(object)new AcceptableValueRange<int>(20, 3600))).Value;
			cosmeticOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("Buff Settings", "Cosmetic Effects Only", false, AdminDescription("Disables health and stamina regen modifiers. (Default Off)")).Value;
			seedGrowTime = ((BaseUnityPlugin)this).Config.Bind<int>("Yield Settings", "Seed Grow Time", 4000, AdminDescription("Adjusts how long until seeds can be harvested. (Default 4000)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 16000))).Value;
			seedYield = ((BaseUnityPlugin)this).Config.Bind<int>("Yield Settings", "Seed Yield", 2, AdminDescription("Adjusts how many seeds are harvested. (Default 2)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 99))).Value;
			seedYieldBonus = ((BaseUnityPlugin)this).Config.Bind<int>("Yield Settings", "Seed Yield Bonus", 1, AdminDescription("Adjusts how many bonus seeds are harvested. (Default 1)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 99))).Value;
			seedYieldBonusChance = (float)((BaseUnityPlugin)this).Config.Bind<int>("Yield Settings", "Seed Yield Bonus Chance", 75, AdminDescription("Adjusts the chance to harvest bonus seeds. (Default 75%)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100))).Value / 100f;
			budGrowTime = ((BaseUnityPlugin)this).Config.Bind<int>("Yield Settings", "Bud Grow Time", 4000, AdminDescription("Adjusts how long until buds can be harvested. (Default 4000)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 16000))).Value;
			budYield = ((BaseUnityPlugin)this).Config.Bind<int>("Yield Settings", "Bud Yield", 1, AdminDescription("Adjusts how many buds are harvested. (Default 1)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 99))).Value;
			budYieldBonus = ((BaseUnityPlugin)this).Config.Bind<int>("Yield Settings", "Bud Yield Bonus", 2, AdminDescription("Adjusts how many bonus buds are harvested. (Default 2)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 99))).Value;
			budYieldBonusChance = (float)((BaseUnityPlugin)this).Config.Bind<int>("Yield Settings", "Bud Yield Bonus Chance", 75, AdminDescription("Adjusts the chance to harvest bonus buds. (Default 75%)", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100))).Value / 100f;
		}

		private void SettingChanged()
		{
			initConfig();
			ApplyPlantSettings(PrefabManager.Instance.GetPrefab("sapling_weed"), PrefabManager.Instance.GetPrefab("Pickable_WeedPlant"), budGrowTime, budYield, budYieldBonus, budYieldBonusChance);
			ApplyPlantSettings(PrefabManager.Instance.GetPrefab("sapling_seedweed"), PrefabManager.Instance.GetPrefab("Pickable_SeedWeedPlant"), seedGrowTime, seedYield, seedYieldBonus, seedYieldBonusChance);
			ApplyEffectSettings();
			GameObject prefab = PrefabManager.Instance.GetPrefab("Bong");
			if (Object.op_Implicit((Object)(object)prefab))
			{
				Bong component = prefab.GetComponent<Bong>();
				component.cosmeticOnly = cosmeticOnly;
				component.ttl = jointEffectTime / 2f;
			}
		}

		private static void ApplyPlantSettings(GameObject sapling, GameObject pickable, int growTime, int yield, int yieldBonus, float yieldBonusChance)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)sapling))
			{
				Plant component = sapling.GetComponent<Plant>();
				component.m_growTime = growTime;
				component.m_growTimeMax = growTime;
				component.m_biome = (Biome)25;
			}
			if (Object.op_Implicit((Object)(object)pickable))
			{
				Pickable component2 = pickable.GetComponent<Pickable>();
				component2.m_amount = yield;
				component2.m_extraDrops.m_dropMin = yieldBonus;
				component2.m_extraDrops.m_dropMax = yieldBonus;
				component2.m_extraDrops.m_dropChance = yieldBonusChance;
			}
		}

		private void ApplyEffectSettings()
		{
			ConfigureEffect(hybridEffect, jointEffectTime, "$hybrid_joint_tooltip");
			ConfigureEffect(indicaEffect, jointEffectTime, "$indica_joint_tooltip");
			ConfigureEffect(sativaEffect, jointEffectTime, "$sativa_joint_tooltip" + (cosmeticOnly ? "" : "\n\nHunger Rate -50%"));
			ConfigureEffect(bongEffect, jointEffectTime * 3f, "$bong_tooltip" + (cosmeticOnly ? "" : "\nHunger Rate -50%"));
		}

		private void ConfigureEffect(SE_Valweed effect, float ttl, string tooltip)
		{
			effect.cosmeticOnly = cosmeticOnly;
			effect.healthRegenVal = jointHealthRegenVal;
			effect.staminaRegenVal = jointStamRegenVal;
			effect.ttl = ttl;
			((StatusEffect)effect).m_tooltip = tooltip;
		}

		private void LoadAssets()
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			jointResourceBundle = AssetUtils.LoadAssetBundleFromResources("joint", executingAssembly);
			hybridJointPrefab = jointResourceBundle.LoadAsset<GameObject>("JointHybrid");
			indicaJointPrefab = jointResourceBundle.LoadAsset<GameObject>("JointIndica");
			sativaJointPrefab = jointResourceBundle.LoadAsset<GameObject>("JointSativa");
			weedPaperPrefab = jointResourceBundle.LoadAsset<GameObject>("JointPaper");
			jointNoisePrefab = jointResourceBundle.LoadAsset<GameObject>("sfx_hit_joint");
			plantResourceBundle = AssetUtils.LoadAssetBundleFromResources("plant", executingAssembly);
			weedSaplingPrefab = plantResourceBundle.LoadAsset<GameObject>("sapling_weed");
			weedSeedSaplingPrefab = plantResourceBundle.LoadAsset<GameObject>("sapling_seedweed");
			pickableWeedPrefab = plantResourceBundle.LoadAsset<GameObject>("Pickable_WeedPlant");
			pickableSeedWeedPrefab = plantResourceBundle.LoadAsset<GameObject>("Pickable_SeedWeedPlant");
			weedNugsPrefab = plantResourceBundle.LoadAsset<GameObject>("WeedBuds");
			weedSeedsPrefab = plantResourceBundle.LoadAsset<GameObject>("WeedSeeds");
			bongResourceBundle = AssetUtils.LoadAssetBundleFromResources("bong", executingAssembly);
			bongPrefab = bongResourceBundle.LoadAsset<GameObject>("Bong");
			weedNugPrefab = bongResourceBundle.LoadAsset<GameObject>("bud");
			bongNoisePrefab = bongResourceBundle.LoadAsset<GameObject>("sfx_hit_bong");
			bongInhaleNoisePrefab = bongResourceBundle.LoadAsset<GameObject>("sfx_hit_bong_inhale");
			bongSmokePrefab = bongResourceBundle.LoadAsset<GameObject>("vfx_bong_smoke");
			mouthSmokePrefab = bongResourceBundle.LoadAsset<GameObject>("vfx_mouth_smoke");
			bongMouthSmokePrefab = bongResourceBundle.LoadAsset<GameObject>("vfx_mouth_smoke_bong");
			ApplyPlantSettings(weedSaplingPrefab, pickableWeedPrefab, budGrowTime, budYield, budYieldBonus, budYieldBonusChance);
			ApplyPlantSettings(weedSeedSaplingPrefab, pickableSeedWeedPrefab, seedGrowTime, seedYield, seedYieldBonus, seedYieldBonusChance);
			PrefabManager.Instance.AddPrefab(pickableWeedPrefab);
			PrefabManager.Instance.AddPrefab(pickableSeedWeedPrefab);
			PrefabManager.Instance.AddPrefab(weedNugPrefab);
			PrefabManager.Instance.AddPrefab(bongSmokePrefab);
			PrefabManager.Instance.AddPrefab(bongNoisePrefab);
			PrefabManager.Instance.AddPrefab(mouthSmokePrefab);
			PrefabManager.Instance.AddPrefab(jointNoisePrefab);
			PrefabManager.Instance.AddPrefab(bongMouthSmokePrefab);
		}

		private T CreateEffect<T>(string name, string displayName, Sprite icon, string startMessage, EffectData[] startEffects) where T : SE_Valweed
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			T val = ScriptableObject.CreateInstance<T>();
			((Object)val).name = name;
			((StatusEffect)val).m_name = displayName;
			((StatusEffect)val).m_icon = icon;
			((StatusEffect)val).m_startMessageType = (MessageType)2;
			((StatusEffect)val).m_startMessage = startMessage;
			((StatusEffect)val).m_stopMessageType = (MessageType)2;
			((StatusEffect)val).m_stopMessage = "$joint_effectstop";
			((StatusEffect)val).m_startEffects.m_effectPrefabs = startEffects;
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val, false));
			return val;
		}

		private void AddStatusEffects()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Expected O, but got Unknown
			spriteBundle = AssetUtils.LoadAssetBundleFromResources("high_eyes", Assembly.GetExecutingAssembly());
			Sprite val = spriteBundle.LoadAsset<Sprite>("Assets/Joint/high_eyes.png");
			if (!Object.op_Implicit((Object)(object)val))
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"statusIcon NULL");
			}
			EffectData[] startEffects = (EffectData[])(object)new EffectData[2]
			{
				new EffectData
				{
					m_prefab = mouthSmokePrefab,
					m_attach = true,
					m_enabled = true
				},
				new EffectData
				{
					m_prefab = jointNoisePrefab,
					m_enabled = true
				}
			};
			EffectData[] startEffects2 = (EffectData[])(object)new EffectData[2]
			{
				new EffectData
				{
					m_prefab = bongMouthSmokePrefab,
					m_attach = true,
					m_enabled = true
				},
				new EffectData
				{
					m_prefab = bongInhaleNoisePrefab,
					m_attach = true,
					m_enabled = true
				}
			};
			hybridEffect = CreateEffect<SE_Hybrid>("HybridJointStatusEffect", "$hybrid_joint_effectname", val, "$joint_effectstart", startEffects);
			indicaEffect = CreateEffect<SE_Indica>("IndicaJointStatusEffect", "$indica_joint_effectname", val, "$joint_effectstart", startEffects);
			sativaEffect = CreateEffect<SE_Sativa>("SativaJointStatusEffect", "$sativa_joint_effectname", val, "$joint_effectstart", startEffects);
			bongEffect = CreateEffect<SE_Bong>("BongStatusEffect", "$bong_effectname", val, "$bong_effectstart", startEffects2);
			ApplyEffectSettings();
		}

		private static RequirementConfig Req(string item, int amount)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			return new RequirementConfig
			{
				Item = item,
				Amount = amount
			};
		}

		private static void AddJoint(GameObject prefab, string flavorItem, StatusEffect effect)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			ItemConfig val = new ItemConfig();
			val.Amount = 1;
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[3]
			{
				Req("JointPaper", 1),
				Req("WeedBuds", 1),
				Req(flavorItem, 1)
			};
			ItemConfig val2 = val;
			CustomItem val3 = new CustomItem(prefab, false, val2);
			val3.ItemDrop.m_itemData.m_shared.m_itemType = (ItemType)2;
			val3.ItemDrop.m_itemData.m_shared.m_consumeStatusEffect = effect;
			ItemManager.Instance.AddItem(val3);
		}

		private void CreateItems()
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			AddJoint(hybridJointPrefab, "Raspberry", (StatusEffect)(object)hybridEffect);
			AddJoint(indicaJointPrefab, "Blueberries", (StatusEffect)(object)indicaEffect);
			AddJoint(sativaJointPrefab, "Honey", (StatusEffect)(object)sativaEffect);
			ItemManager instance = ItemManager.Instance;
			GameObject obj = weedPaperPrefab;
			ItemConfig val = new ItemConfig();
			val.Amount = 1;
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { Req("Dandelion", 2) };
			instance.AddItem(new CustomItem(obj, false, val));
			ItemManager.Instance.AddItem(new CustomItem(weedNugsPrefab, false));
			ItemManager instance2 = ItemManager.Instance;
			GameObject obj2 = weedSeedsPrefab;
			val = new ItemConfig();
			val.Amount = 1;
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { Req("AncientSeed", 3) };
			instance2.AddItem(new CustomItem(obj2, false, val));
		}

		private void CreatePieces()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Expected O, but got Unknown
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Expected O, but got Unknown
			PieceManager instance = PieceManager.Instance;
			GameObject obj = weedSaplingPrefab;
			PieceConfig val = new PieceConfig();
			val.PieceTable = "Cultivator";
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { Req("WeedSeeds", 1) };
			instance.AddPiece(new CustomPiece(obj, true, val));
			PieceManager instance2 = PieceManager.Instance;
			GameObject obj2 = weedSeedSaplingPrefab;
			val = new PieceConfig();
			val.PieceTable = "Cultivator";
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { Req("WeedBuds", 1) };
			instance2.AddPiece(new CustomPiece(obj2, true, val));
			GameObject obj3 = bongPrefab;
			val = new PieceConfig();
			val.PieceTable = "Hammer";
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[4]
			{
				Req("BronzeNails", 5),
				Req("Resin", 10),
				Req("TrophySkeleton", 1),
				Req("GreydwarfEye", 5)
			};
			CustomPiece val2 = new CustomPiece(obj3, true, val);
			Requirement[] resources = val2.Piece.m_resources;
			for (int i = 0; i < resources.Length; i++)
			{
				resources[i].m_recover = true;
			}
			val2.Piece.m_onlyInBiome = (Biome)0;
			Bong bong = val2.PiecePrefab.AddComponent<Bong>();
			bong.m_name = "$piece_bong";
			bong.m_startFuel = 0f;
			bong.m_maxFuel = 1f;
			bong.m_secPerFuel = 1E+09f;
			bong.m_checkTerrainOffset = 0f;
			bong.m_coverCheckOffset = 0f;
			bong.m_fuelItem = weedNugsPrefab.GetComponent<ItemDrop>();
			bong.cosmeticOnly = cosmeticOnly;
			bong.ttl = jointEffectTime / 2f;
			bongSmokePrefab.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
			bong.m_fuelAddedEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[2]
			{
				new EffectData
				{
					m_prefab = bongNoisePrefab,
					m_enabled = true
				},
				new EffectData
				{
					m_prefab = bongSmokePrefab,
					m_enabled = true,
					m_inheritParentScale = true,
					m_attach = true
				}
			};
			PieceManager.Instance.AddPiece(val2);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}