Decompiled source of WispArrow v0.3.0

plugins/WispArrow.dll

Decompiled 2 days 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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Jotunn;
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: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
[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 WispArrow
{
	internal static class MistField
	{
		private static readonly List<KeyValuePair<PropertyInfo, object>> template = new List<KeyValuePair<PropertyInfo, object>>();

		public static void Capture(ParticleSystemForceField from)
		{
			template.Clear();
			PropertyInfo[] properties = typeof(ParticleSystemForceField).GetProperties(BindingFlags.Instance | BindingFlags.Public);
			foreach (PropertyInfo propertyInfo in properties)
			{
				if (propertyInfo.CanRead && propertyInfo.CanWrite && propertyInfo.DeclaringType == typeof(ParticleSystemForceField))
				{
					template.Add(new KeyValuePair<PropertyInfo, object>(propertyInfo, propertyInfo.GetValue(from)));
				}
			}
		}

		public static GameObject Create(Transform parent, Vector3 position, float radius, float push)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_002f: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("wisp_demister");
			val.SetActive(false);
			if (Object.op_Implicit((Object)(object)parent))
			{
				val.transform.SetParent(parent, false);
			}
			else
			{
				val.transform.position = position;
			}
			ParticleSystemForceField val2 = val.AddComponent<ParticleSystemForceField>();
			foreach (KeyValuePair<PropertyInfo, object> item in template)
			{
				item.Key.SetValue(val2, item.Value);
			}
			val2.endRange = radius;
			MinMaxCurve gravity = val2.gravity;
			val2.gravity = new MinMaxCurve(((MinMaxCurve)(ref gravity)).constant * push);
			val.AddComponent<Demister>();
			val.SetActive(true);
			return val;
		}

		public static void AddLight(Transform parent, float range, float intensity)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (Settings.LightEnabled.Value && !(intensity <= 0f))
			{
				GameObject val = new GameObject("wisp_light");
				val.transform.SetParent(parent, false);
				Light obj = val.AddComponent<Light>();
				obj.type = (LightType)2;
				obj.color = Settings.LightColor.Value;
				obj.range = Mathf.Max(3f, range);
				obj.intensity = intensity;
				obj.shadows = (LightShadows)0;
			}
		}
	}
	internal class WispFlight : MonoBehaviour
	{
		private Vector3 spawn;

		private Vector3 lastDrop;

		private bool flying;

		private void Start()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			spawn = ((Component)this).transform.position;
		}

		private void Update()
		{
			//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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: 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_010e: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)this).transform.position;
			Vector3 val;
			if (!flying)
			{
				val = position - spawn;
				if (((Vector3)(ref val)).sqrMagnitude < 1f)
				{
					return;
				}
				flying = true;
				lastDrop = spawn;
				if (Settings.FlightRadius.Value > 0f)
				{
					MistField.Create(((Component)this).transform, Vector3.zero, Settings.FlightRadius.Value, Settings.PushStrength.Value);
				}
				MistField.AddLight(((Component)this).transform, Settings.FlightRadius.Value, Settings.FlightLight.Value);
				Plugin.Log.LogDebug((object)$"wisp arrow flying from {spawn}");
			}
			float num = Mathf.Max(0.5f, Settings.TrailSpacing.Value);
			if (Settings.TrailRadius.Value <= 0f || Settings.TrailDuration.Value <= 0f)
			{
				return;
			}
			while (true)
			{
				val = position - lastDrop;
				if (((Vector3)(ref val)).sqrMagnitude >= num * num)
				{
					Vector3 val2 = lastDrop;
					val = position - lastDrop;
					lastDrop = val2 + ((Vector3)(ref val)).normalized * num;
					if (TrailPoint.Alive < Settings.MaxTrailPoints.Value)
					{
						GameObject obj = MistField.Create(null, lastDrop, Settings.TrailRadius.Value, Settings.PushStrength.Value);
						obj.AddComponent<TrailPoint>();
						Object.Destroy((Object)(object)obj, Settings.TrailDuration.Value);
					}
					continue;
				}
				break;
			}
		}
	}
	internal class TrailPoint : MonoBehaviour
	{
		public static int Alive;

		private void Awake()
		{
			Alive++;
		}

		private void OnDestroy()
		{
			Alive--;
		}
	}
	internal class WispGlow : MonoBehaviour
	{
		private void Start()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).GetComponent<TimedDestruction>().Trigger(Mathf.Max(1f, Settings.ImpactDuration.Value));
			if (Settings.ImpactRadius.Value > 0f)
			{
				MistField.Create(((Component)this).transform, Vector3.zero, Settings.ImpactRadius.Value, Settings.PushStrength.Value);
			}
			MistField.AddLight(((Component)this).transform, Settings.ImpactRadius.Value, Settings.ImpactLight.Value);
		}
	}
	[BepInPlugin("okothings.wisparrow", "WispArrow", "0.3.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "okothings.wisparrow";

		public const string Name = "WispArrow";

		public const string Version = "0.3.0";

		internal const string ItemName = "ArrowWisp";

		private const string ProjectileName = "bow_projectile_wisp";

		private const string GlowName = "ArrowWisp_glow";

		internal static ManualLogSource Log;

		internal static Plugin Instance;

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Settings.Bind(((BaseUnityPlugin)this).Config);
			AddTranslations();
			PrefabManager.OnVanillaPrefabsAvailable += AddItem;
			ItemManager.OnItemsRegistered += Settings.ApplyAll;
			SynchronizationManager.OnConfigurationSynchronized += delegate
			{
				Settings.ApplyAll();
			};
		}

		private static void AddTranslations()
		{
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			string text = "English";
			localization.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "item_arrow_wisp", "Wisp arrow" },
				{ "item_arrow_wisp_description", "A wisp bound to a shaft. It pushes the mist away as it flies, leaves a clear path behind it, and keeps the spot where it lands clear for a while." }
			});
			text = "French";
			localization.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "item_arrow_wisp", "Flèche feu-follet" },
				{ "item_arrow_wisp_description", "Un feu follet lié à une flèche. Elle repousse la brume en vol, laisse un chemin dégagé derrière elle, et dégage pour un temps l'endroit où elle se plante." }
			});
		}

		private void AddItem()
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Expected O, but got Unknown
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: 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_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Expected O, but got Unknown
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Expected O, but got Unknown
			PrefabManager.OnVanillaPrefabsAvailable -= AddItem;
			Demister val = FindVanillaDemister();
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"no vanilla Demister found; Wisp arrows not added");
				return;
			}
			ParticleSystemForceField component = ((Component)val).GetComponent<ParticleSystemForceField>();
			ManualLogSource logger = ((BaseUnityPlugin)this).Logger;
			object[] obj = new object[4]
			{
				((Object)((Component)val).transform.root).name,
				((Object)val).name,
				component.endRange,
				null
			};
			MinMaxCurve gravity = component.gravity;
			obj[3] = ((MinMaxCurve)(ref gravity)).constant;
			logger.LogInfo((object)string.Format("demister source: {0}/{1}, endRange {2}, push {3}", obj));
			MistField.Capture(component);
			GameObject val2 = PrefabManager.Instance.CreateEmptyPrefab("ArrowWisp_glow", true);
			Object.DestroyImmediate((Object)(object)val2.GetComponent<Collider>());
			Object.DestroyImmediate((Object)(object)val2.GetComponent<MeshRenderer>());
			Object.DestroyImmediate((Object)(object)val2.GetComponent<MeshFilter>());
			val2.GetComponent<ZNetView>().m_persistent = false;
			val2.AddComponent<TimedDestruction>();
			val2.AddComponent<WispGlow>();
			PrefabManager.Instance.AddPrefab(new CustomPrefab(val2, false));
			ItemDrop component2 = PrefabManager.Instance.GetPrefab("ArrowWood").GetComponent<ItemDrop>();
			GameObject val3 = PrefabManager.Instance.CreateClonedPrefab("bow_projectile_wisp", component2.m_itemData.m_shared.m_attack.m_attackProjectile);
			val3.AddComponent<WispFlight>();
			Projectile component3 = val3.GetComponent<Projectile>();
			component3.m_spawnOnHit = val2;
			component3.m_spawnOnHitChance = 1f;
			component3.m_spawnCount = 1;
			component3.m_spawnOnTerrain = (component3.m_spawnOnCharacters = (component3.m_spawnOnWearNTear = true));
			Settings.Projectile = component3;
			PrefabManager.Instance.AddPrefab(new CustomPrefab(val3, false));
			CustomItem val4 = new CustomItem("ArrowWisp", "ArrowWood", new ItemConfig
			{
				Name = "$item_arrow_wisp",
				Description = "$item_arrow_wisp_description",
				Icon = LoadIcon("ArrowWisp.png"),
				CraftingStation = Settings.Station.Value,
				MinStationLevel = Settings.StationLevel.Value,
				Amount = Settings.Amount.Value,
				Requirements = Settings.ParseIngredients(Settings.Ingredients.Value).Select((Func<KeyValuePair<string, int>, RequirementConfig>)((KeyValuePair<string, int> r) => new RequirementConfig(r.Key, r.Value, 0, true))).ToArray()
			});
			val4.ItemDrop.m_itemData.m_shared.m_attack.m_attackProjectile = val3;
			Settings.Item = val4.ItemDrop;
			ItemManager.Instance.AddItem(val4);
			Settings.ApplyArrow();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Wisp arrows added");
		}

		private static Demister FindVanillaDemister()
		{
			GameObject prefab = PrefabManager.Instance.GetPrefab("demister_ball");
			Demister val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponentInChildren<Demister>(true) : null);
			if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Component)val).GetComponent<ParticleSystemForceField>()))
			{
				return val;
			}
			return (from x in ZNetScene.instance.m_prefabs
				where Object.op_Implicit((Object)(object)x)
				select x.GetComponentInChildren<Demister>(true)).FirstOrDefault((Func<Demister, bool>)((Demister x) => Object.op_Implicit((Object)(object)x) && Object.op_Implicit((Object)(object)((Component)x).GetComponent<ParticleSystemForceField>())));
		}

		private static Sprite LoadIcon(string resource)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resource);
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			typeof(ImageConversion).GetMethod("LoadImage", new Type[3]
			{
				typeof(Texture2D),
				typeof(byte[]),
				typeof(bool)
			}).Invoke(null, new object[3]
			{
				val,
				memoryStream.ToArray(),
				false
			});
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}
	}
	internal static class Settings
	{
		public static ConfigEntry<bool> AllowRecipe;

		public static ConfigEntry<bool> AllowArrow;

		public static ConfigEntry<bool> AllowMist;

		public static ConfigEntry<bool> AllowTrail;

		public static Setting<string> Ingredients;

		public static Setting<string> Station;

		public static Setting<int> Amount;

		public static Setting<int> StationLevel;

		public static Setting<int> MaxTrailPoints;

		public static Setting<bool> RecipeEnabled;

		public static Setting<bool> ClearWhereItFades;

		public static Setting<float> PierceDamage;

		public static Setting<float> FlightRadius;

		public static Setting<float> ImpactRadius;

		public static Setting<float> ImpactDuration;

		public static Setting<float> PushStrength;

		public static Setting<float> TrailRadius;

		public static Setting<float> TrailDuration;

		public static Setting<float> TrailSpacing;

		public static ConfigEntry<bool> LightEnabled;

		public static ConfigEntry<float> FlightLight;

		public static ConfigEntry<float> ImpactLight;

		public static ConfigEntry<Color> LightColor;

		public static ItemDrop Item;

		public static Projectile Projectile;

		public static void Bind(ConfigFile cfg)
		{
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			AllowRecipe = Admin(cfg, "0 - Server", "PlayersSetRecipe", value: false, "Each player uses the recipe of their own file (section 1). The server's value decides; on a client this line has no effect.");
			AllowArrow = Admin(cfg, "0 - Server", "PlayersSetArrow", value: false, "Each player uses the arrow settings of their own file (section 2: damage...). The server's value decides; on a client this line has no effect.");
			AllowMist = Admin(cfg, "0 - Server", "PlayersSetMist", value: false, "Each player uses the mist settings of their own file (section 3). The server's value decides; on a client this line has no effect.");
			AllowTrail = Admin(cfg, "0 - Server", "PlayersSetTrail", value: false, "Each player uses the trail settings of their own file (section 4). The server's value decides; on a client this line has no effect.");
			Ingredients = Synced(cfg, AllowRecipe, "1 - Recipe", "Ingredients", "Wood:8,Feathers:2,Wisp:1", "Ingredients as Item:amount, comma separated (game prefab names, e.g. Wood, Feathers, Wisp, Resin).");
			Amount = Synced(cfg, AllowRecipe, "1 - Recipe", "Amount", 20, "Arrows made per craft.");
			Station = Synced(cfg, AllowRecipe, "1 - Recipe", "CraftingStation", "piece_workbench", "Crafting station prefab (piece_workbench, forge, piece_artisanstation, blackforge, piece_magetable...). Empty = craft by hand.");
			StationLevel = Synced(cfg, AllowRecipe, "1 - Recipe", "StationLevel", 1, "Minimum level of the crafting station.");
			RecipeEnabled = Synced(cfg, AllowRecipe, "1 - Recipe", "Enabled", value: true, "Whether the arrows can be crafted at all.");
			PierceDamage = Synced(cfg, AllowArrow, "2 - Arrow", "PierceDamage", 22f, "Pierce damage of the arrow (wood arrow: 22).");
			ClearWhereItFades = Synced(cfg, AllowArrow, "2 - Arrow", "ClearWhereItFades", value: true, "An arrow that hits nothing still leaves a clear spot where it fades out.");
			FlightRadius = Synced(cfg, AllowMist, "3 - Mist", "FlightRadius", 6f, "Radius (m) of clear air around the arrow while it flies.");
			ImpactRadius = Synced(cfg, AllowMist, "3 - Mist", "ImpactRadius", 10f, "Radius (m) of clear air where the arrow lands.");
			ImpactDuration = Synced(cfg, AllowMist, "3 - Mist", "ImpactDuration", 60f, "Seconds the landing spot stays clear.");
			PushStrength = Synced(cfg, AllowMist, "3 - Mist", "PushStrength", 5f, "How hard the mist is pushed away, as a multiple of the Wisplight's push (1 = same speed).");
			TrailRadius = Synced(cfg, AllowTrail, "4 - Trail", "TrailRadius", 4f, "Radius (m) of the clear path left behind the arrow (0 = no trail).");
			TrailDuration = Synced(cfg, AllowTrail, "4 - Trail", "TrailDuration", 5f, "Seconds the path behind the arrow stays clear.");
			TrailSpacing = Synced(cfg, AllowTrail, "4 - Trail", "TrailSpacing", 3f, "Distance (m) between two points of the trail.");
			MaxTrailPoints = Synced(cfg, AllowTrail, "4 - Trail", "MaxTrailPoints", 150, "Most trail points alive at once, all arrows together (each one costs the mist a little work; lower it if volleys lag).");
			LightEnabled = cfg.Bind<bool>("5 - Light (local)", "Enabled", true, "Pale light on flying arrows and landing spots.");
			LightColor = cfg.Bind<Color>("5 - Light (local)", "Color", new Color(0.55f, 0.8f, 1f), "Colour of the light.");
			FlightLight = cfg.Bind<float>("5 - Light (local)", "FlightIntensity", 1f, "Light intensity on a flying arrow.");
			ImpactLight = cfg.Bind<float>("5 - Light (local)", "ImpactIntensity", 1.2f, "Light intensity on a landing spot.");
			Ingredients.Entry.SettingChanged += delegate
			{
				ApplyRecipe();
			};
			Amount.Entry.SettingChanged += delegate
			{
				ApplyRecipe();
			};
			Station.Entry.SettingChanged += delegate
			{
				ApplyRecipe();
			};
			StationLevel.Entry.SettingChanged += delegate
			{
				ApplyRecipe();
			};
			RecipeEnabled.Entry.SettingChanged += delegate
			{
				ApplyRecipe();
			};
			AllowRecipe.SettingChanged += delegate
			{
				ApplyRecipe();
			};
			PierceDamage.Entry.SettingChanged += delegate
			{
				ApplyArrow();
			};
			ClearWhereItFades.Entry.SettingChanged += delegate
			{
				ApplyArrow();
			};
			AllowArrow.SettingChanged += delegate
			{
				ApplyArrow();
			};
		}

		private static ConfigEntry<T> Admin<T>(ConfigFile cfg, string section, string key, T value, string description)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			return cfg.Bind<T>(section, key, value, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
		}

		private static Setting<T> Synced<T>(ConfigFile cfg, ConfigEntry<bool> allow, string section, string key, T value, string description)
		{
			return new Setting<T>(Admin(cfg, section, key, value, description), allow);
		}

		public static IEnumerable<KeyValuePair<string, int>> ParseIngredients(string text)
		{
			string[] array = (text ?? "").Split(new char[1] { ',' });
			foreach (string text2 in array)
			{
				string[] array2 = text2.Split(new char[1] { ':' });
				if (array2.Length != 2 || !int.TryParse(array2[1].Trim(), out var result) || result <= 0 || array2[0].Trim() == "")
				{
					if (text2.Trim() != "")
					{
						Plugin.Log.LogWarning((object)("ingredient ignored (expected Item:amount): '" + text2.Trim() + "'"));
					}
				}
				else
				{
					yield return new KeyValuePair<string, int>(array2[0].Trim(), result);
				}
			}
		}

		public static void ApplyAll()
		{
			ApplyRecipe();
			ApplyArrow();
		}

		public static void ApplyArrow()
		{
			if (Object.op_Implicit((Object)(object)Item))
			{
				Item.m_itemData.m_shared.m_damages.m_pierce = PierceDamage.Value;
			}
			if (Object.op_Implicit((Object)(object)Projectile))
			{
				Projectile.m_spawnOnTtl = ClearWhereItFades.Value;
			}
		}

		public static void ApplyRecipe()
		{
			//IL_00bc: 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)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			ObjectDB instance = ObjectDB.instance;
			Recipe val = (Object.op_Implicit((Object)(object)instance) ? ((IEnumerable<Recipe>)instance.m_recipes).FirstOrDefault((Func<Recipe, bool>)((Recipe r) => Object.op_Implicit((Object)(object)r) && Object.op_Implicit((Object)(object)r.m_item) && ((Object)r.m_item).name == "ArrowWisp")) : null);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			List<Requirement> list = new List<Requirement>();
			foreach (KeyValuePair<string, int> item in ParseIngredients(Ingredients.Value))
			{
				GameObject itemPrefab = instance.GetItemPrefab(item.Key);
				ItemDrop val2 = (Object.op_Implicit((Object)(object)itemPrefab) ? itemPrefab.GetComponent<ItemDrop>() : null);
				if (!Object.op_Implicit((Object)(object)val2))
				{
					Plugin.Log.LogWarning((object)("unknown ingredient '" + item.Key + "', ignored"));
					continue;
				}
				list.Add(new Requirement
				{
					m_resItem = val2,
					m_amount = item.Value,
					m_recover = true
				});
			}
			val.m_resources = list.ToArray();
			val.m_amount = Mathf.Max(1, Amount.Value);
			val.m_minStationLevel = Mathf.Max(1, StationLevel.Value);
			val.m_enabled = RecipeEnabled.Value;
			CraftingStation val3 = null;
			if (!string.IsNullOrWhiteSpace(Station.Value))
			{
				GameObject prefab = PrefabManager.Instance.GetPrefab(Station.Value.Trim());
				val3 = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<CraftingStation>() : null);
				if (!Object.op_Implicit((Object)(object)val3))
				{
					Plugin.Log.LogWarning((object)("unknown crafting station '" + Station.Value + "', the arrows are crafted by hand"));
				}
			}
			val.m_craftingStation = val3;
		}
	}
	internal class Setting<T>
	{
		public readonly ConfigEntry<T> Entry;

		private readonly ConfigEntry<bool> allow;

		public T Value
		{
			get
			{
				if (allow.Value)
				{
					object obj = LocalValue.Get((ConfigEntryBase)(object)Entry);
					if (obj is T)
					{
						return (T)obj;
					}
				}
				return Entry.Value;
			}
		}

		public Setting(ConfigEntry<T> entry, ConfigEntry<bool> allow)
		{
			Entry = entry;
			this.allow = allow;
		}
	}
	internal static class LocalValue
	{
		private static readonly MethodInfo method = typeof(ConfigEntryBaseExtension).GetMethod("GetLocalValue", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);

		private static bool warned;

		public static object Get(ConfigEntryBase entry)
		{
			if (method == null)
			{
				if (!warned)
				{
					Plugin.Log.LogWarning((object)"this Jotunn version hides players' own values: the server's are used");
				}
				warned = true;
				return null;
			}
			return method.Invoke(null, new object[1] { entry });
		}
	}
}