Decompiled source of ShardGlow v0.2.2

plugins/ShardGlow.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
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 BepInEx.Logging;
using EpicLoot;
using HarmonyLib;
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.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("ShardGlow")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.2.0")]
[assembly: AssemblyInformationalVersion("0.2.2")]
[assembly: AssemblyProduct("ShardGlow")]
[assembly: AssemblyTitle("ShardGlow")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.2.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 ShardGlow
{
	internal static class EpicLootBridge
	{
		private static bool broken;

		private static readonly HashSet<string> loggedItems = new HashSet<string>();

		public static string ElementOf(ItemData item)
		{
			if (item == null || broken)
			{
				return null;
			}
			try
			{
				return ElementOfUnsafe(item, GlowConfig.IncludeEnchantments.Value);
			}
			catch (Exception ex) when (ex is TypeLoadException || ex is MissingMemberException)
			{
				broken = true;
				ShardGlowPlugin.Log.LogError((object)$"EpicLoot's item data has changed shape; glows disabled. Is EpicLoot a supported version? {ex}");
				return null;
			}
			catch (Exception arg)
			{
				if (loggedItems.Add(item.m_shared?.m_name ?? "?"))
				{
					ShardGlowPlugin.Log.LogWarning((object)$"Could not read EpicLoot data for {item.m_shared?.m_name}; skipping it. {arg}");
				}
				return null;
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		private static string ElementOfUnsafe(ItemData item, bool includeEnchantments)
		{
			MagicItem magicItem = ItemDataExtensions.GetMagicItem(item);
			if (magicItem == null)
			{
				return null;
			}
			if (magicItem.Sockets != null)
			{
				foreach (SocketedEffect socket in magicItem.Sockets)
				{
					object effectType;
					if (socket == null)
					{
						effectType = null;
					}
					else
					{
						MagicItemEffect effect = socket.Effect;
						effectType = ((effect != null) ? effect.EffectType : null);
					}
					string text = GlowConfig.ElementForEffect((string)effectType);
					if (text != null)
					{
						return text;
					}
				}
			}
			if (includeEnchantments && magicItem.Effects != null)
			{
				foreach (MagicItemEffect effect2 in magicItem.Effects)
				{
					string text2 = GlowConfig.ElementForEffect((effect2 != null) ? effect2.EffectType : null);
					if (text2 != null)
					{
						return text2;
					}
				}
			}
			return null;
		}
	}
	internal sealed class GlowElement
	{
		public string Name;

		public ConfigEntry<bool> Enabled;

		public ConfigEntry<Color> Color;

		public ConfigEntry<string> Effects;
	}
	internal static class GlowConfig
	{
		public static ConfigEntry<bool> Enabled;

		public static ConfigEntry<bool> IncludeEnchantments;

		public static ConfigEntry<bool> GlowShields;

		public static ConfigEntry<float> IntensityMultiplier;

		public static ConfigEntry<float> RangeMultiplier;

		public static ConfigEntry<float> PulseStrength;

		public static ConfigEntry<float> PulseSpeed;

		public static ConfigEntry<bool> SurfaceGlow;

		public static ConfigEntry<float> SurfaceGlowStrength;

		public static readonly List<GlowElement> Elements = new List<GlowElement>();

		public static int Revision;

		private static readonly Dictionary<string, GlowElement> byEffect = new Dictionary<string, GlowElement>(StringComparer.OrdinalIgnoreCase);

		private static readonly Dictionary<string, GlowElement> byName = new Dictionary<string, GlowElement>(StringComparer.OrdinalIgnoreCase);

		private static readonly (string name, Color color, string effects)[] Defaults = new(string, Color, string)[8]
		{
			("Lightning", new Color(0.35f, 0.6f, 1f), "ShockingCharge, StrikeCausesLightning, StormFury, StormRider, Conduit, AddLightningDamage, PhysToLightning, PhysToLightningOnBlock, ConvertPhysicalDamageToLightning, ChainLightning, AxeBerzerkrLightning"),
			("Fire", new Color(1f, 0.5f, 0.12f), "AddFireDamage, BurningAdrenaline, PhysToFire, PhysToFireOnBlock, Kindling, BurningSpeed, MeteorSummoner, Trailblazer"),
			("Frost", new Color(0.6f, 0.95f, 1f), "AddFrostDamage, AdrenalineFrostWave, PhysToFrost, PhysToFrostOnBlock, IcyRetribution, IcyWeight, FrostDamageAOE"),
			("Poison", new Color(0.45f, 1f, 0.2f), "AddPoisonDamage, GainAdrenalineWhenApplyingPoison, PhysToPoison, PhysToPoisonOnBlock, PoisonToTrueDamage, IncreaseAllPoisonDamageDone, CorpseRot"),
			("Spirit", new Color(1f, 0.95f, 0.7f), "AddSpiritDamage"),
			("Necrotic", new Color(0.55f, 0.2f, 0.95f), "NecroticFire"),
			("Nature", new Color(0.55f, 0.9f, 0.3f), "ForestsAid"),
			("Eitr", new Color(0.85f, 0.4f, 1f), "Everflow")
		};

		public static void Bind(ConfigFile cfg)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Expected O, but got Unknown
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Expected O, but got Unknown
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Expected O, but got Unknown
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			Enabled = cfg.Bind<bool>("General", "Enabled", true, "Show element glows on equipped weapons and tools.");
			IncludeEnchantments = cfg.Bind<bool>("General", "IncludeEnchantments", false, "Also use an item's rolled enchantments (not just socketed shards) to pick the element.");
			GlowShields = cfg.Bind<bool>("General", "GlowShields", false, "Also glow shields held in the off hand.");
			IntensityMultiplier = cfg.Bind<float>("Light", "IntensityMultiplier", 1f, new ConfigDescription("Brightness relative to a handheld torch.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			RangeMultiplier = cfg.Bind<float>("Light", "RangeMultiplier", 1f, new ConfigDescription("Light radius relative to a handheld torch.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			PulseStrength = cfg.Bind<float>("Light", "PulseStrength", 0.12f, new ConfigDescription("How much the glow breathes. 0 = steady.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			PulseSpeed = cfg.Bind<float>("Light", "PulseSpeed", 2.5f, new ConfigDescription("Pulse speed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>()));
			SurfaceGlow = cfg.Bind<bool>("Weapon", "SurfaceGlow", true, "Make the weapon model itself glow (material emission), not just light the area around it.");
			SurfaceGlowStrength = cfg.Bind<float>("Weapon", "SurfaceGlowStrength", 0.4f, new ConfigDescription("How strongly the weapon surface glows. Low values tint the weapon; around 1 and up it washes out toward white.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
			(string, Color, string)[] defaults = Defaults;
			for (int i = 0; i < defaults.Length; i++)
			{
				(string, Color, string) tuple = defaults[i];
				string item = tuple.Item1;
				Color item2 = tuple.Item2;
				string item3 = tuple.Item3;
				string text = "Element." + item;
				Elements.Add(new GlowElement
				{
					Name = item,
					Enabled = cfg.Bind<bool>(text, "Enabled", true, "Glow for " + item + " effects."),
					Color = cfg.Bind<Color>(text, "Color", item2, "Glow color (RGBA hex)."),
					Effects = cfg.Bind<string>(text, "Effects", item3, "Comma-separated EpicLoot effect types that count as this element. The first matching element wins.")
				});
			}
			Rebuild();
			cfg.SettingChanged += delegate
			{
				Rebuild();
			};
		}

		private static void Rebuild()
		{
			byEffect.Clear();
			byName.Clear();
			foreach (GlowElement element in Elements)
			{
				byName[element.Name] = element;
				if (!element.Enabled.Value)
				{
					continue;
				}
				string[] array = element.Effects.Value.Split(new char[1] { ',' });
				for (int i = 0; i < array.Length; i++)
				{
					string text = array[i].Trim();
					if (text.Length > 0 && !byEffect.ContainsKey(text))
					{
						byEffect[text] = element;
					}
				}
			}
			Revision++;
		}

		public static string ElementForEffect(string effectType)
		{
			if (effectType == null || !byEffect.TryGetValue(effectType, out var value))
			{
				return null;
			}
			return value.Name;
		}

		public static bool TryGetColor(string elementName, out Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			color = default(Color);
			if (string.IsNullOrEmpty(elementName) || !byName.TryGetValue(elementName, out var value) || !value.Enabled.Value)
			{
				return false;
			}
			color = value.Color.Value;
			return true;
		}
	}
	public class PlayerGlow : MonoBehaviour
	{
		private sealed class HandGlow
		{
			public GameObject Instance;

			public string Element;

			public int Revision = -1;

			public Light Light;

			public float BaseIntensity;

			public readonly List<(Renderer renderer, Material[] original)> Swapped = new List<(Renderer, Material[])>();

			public readonly List<Material> Emissive = new List<Material>();

			public Color BaseEmission;

			public bool Active
			{
				get
				{
					if (!Object.op_Implicit((Object)(object)Light))
					{
						return Emissive.Count > 0;
					}
					return true;
				}
			}
		}

		private const string ZdoKey = "ShardGlow_Element";

		private const float ResolveInterval = 0.5f;

		private const float RefreshInterval = 0.25f;

		private const float FallbackIntensity = 1.5f;

		private const float FallbackRange = 6f;

		private static bool torchRead;

		private static float torchIntensity = 1.5f;

		private static float torchRange = 6f;

		private static readonly Dictionary<int, ItemType> itemTypeByHash = new Dictionary<int, ItemType>();

		private static readonly int EmissionColorId = Shader.PropertyToID("_EmissionColor");

		private static readonly int EmissionMapId = Shader.PropertyToID("_EmissionMap");

		private static readonly int MainTexId = Shader.PropertyToID("_MainTex");

		private static readonly HashSet<string> reportedShaders = new HashSet<string>();

		private Player player;

		private ZNetView nview;

		private readonly HandGlow right = new HandGlow();

		private readonly HandGlow left = new HandGlow();

		private float resolveTimer;

		private float refreshTimer;

		private float phase;

		private void Awake()
		{
			player = ((Component)this).GetComponent<Player>();
			nview = ((Component)this).GetComponent<ZNetView>();
			phase = Random.value * (float)Math.PI * 2f;
		}

		private void Update()
		{
			if (!Object.op_Implicit((Object)(object)player) || !Object.op_Implicit((Object)(object)nview) || !nview.IsValid())
			{
				return;
			}
			float deltaTime = Time.deltaTime;
			if ((Object)(object)player == (Object)(object)Player.m_localPlayer && nview.IsOwner() && (resolveTimer -= deltaTime) <= 0f)
			{
				resolveTimer = 0.5f;
				PublishElement();
			}
			if ((refreshTimer -= deltaTime) <= 0f)
			{
				refreshTimer = 0.25f;
				string element = (GlowConfig.Enabled.Value ? nview.GetZDO().GetString("ShardGlow_Element", "") : "");
				VisEquipment visEquipment = ((Humanoid)player).m_visEquipment;
				if (Object.op_Implicit((Object)(object)visEquipment))
				{
					Refresh(right, visEquipment.m_rightItemInstance, visEquipment.m_rightItem, element);
					Refresh(left, visEquipment.m_leftItemInstance, visEquipment.m_leftItem, element);
				}
			}
			Pulse(right);
			Pulse(left);
		}

		private void OnDestroy()
		{
			Clear(right);
			Clear(left);
		}

		private void PublishElement()
		{
			string text = EpicLootBridge.ElementOf(((Humanoid)player).m_trinketItem) ?? EpicLootBridge.ElementOf(((Humanoid)player).m_rightItem) ?? EpicLootBridge.ElementOf(((Humanoid)player).m_leftItem) ?? "";
			ZDO zDO = nview.GetZDO();
			if (zDO.GetString("ShardGlow_Element", "") != text)
			{
				zDO.Set("ShardGlow_Element", text);
			}
		}

		private void Refresh(HandGlow hand, GameObject instance, int itemHash, string element)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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)
			if ((Object)(object)hand.Instance == (Object)(object)instance && hand.Element == element && hand.Revision == GlowConfig.Revision)
			{
				return;
			}
			Clear(hand);
			hand.Instance = instance;
			hand.Element = element;
			hand.Revision = GlowConfig.Revision;
			if (Object.op_Implicit((Object)(object)instance) && IsEligible(itemHash) && GlowConfig.TryGetColor(element, out var color))
			{
				ReadTorchLight();
				GameObject val = new GameObject("ShardGlowLight");
				val.transform.SetParent(instance.transform, false);
				val.transform.position = VisualCenter(instance);
				Light val2 = val.AddComponent<Light>();
				val2.type = (LightType)2;
				val2.color = color;
				val2.intensity = torchIntensity * GlowConfig.IntensityMultiplier.Value;
				val2.range = torchRange * GlowConfig.RangeMultiplier.Value;
				val2.shadows = (LightShadows)0;
				val.AddComponent<LightLod>();
				hand.Light = val2;
				hand.BaseIntensity = val2.intensity;
				if (GlowConfig.SurfaceGlow.Value)
				{
					ApplySurfaceGlow(hand, instance, color * GlowConfig.SurfaceGlowStrength.Value);
				}
			}
		}

		private void Pulse(HandGlow hand)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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)
			if (!hand.Active)
			{
				return;
			}
			float value = GlowConfig.PulseStrength.Value;
			float num = ((value <= 0f) ? 1f : (1f + value * Mathf.Sin(Time.time * GlowConfig.PulseSpeed.Value + phase)));
			if (Object.op_Implicit((Object)(object)hand.Light))
			{
				hand.Light.intensity = hand.BaseIntensity * num;
			}
			if (!(value > 0f))
			{
				return;
			}
			Color val = hand.BaseEmission * num;
			foreach (Material item in hand.Emissive)
			{
				item.SetColor(EmissionColorId, val);
			}
		}

		private static void ApplySurfaceGlow(HandGlow hand, GameObject instance, Color emission)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			hand.BaseEmission = emission;
			Renderer[] componentsInChildren = instance.GetComponentsInChildren<Renderer>();
			foreach (Renderer val in componentsInChildren)
			{
				if (!(val is MeshRenderer) && !(val is SkinnedMeshRenderer))
				{
					continue;
				}
				Material[] sharedMaterials = val.sharedMaterials;
				Material[] array = (Material[])(object)new Material[sharedMaterials.Length];
				bool flag = false;
				for (int j = 0; j < sharedMaterials.Length; j++)
				{
					Material val2 = (array[j] = sharedMaterials[j]);
					if (!Object.op_Implicit((Object)(object)val2) || !SupportsEmission(val2))
					{
						continue;
					}
					Material val3 = new Material(val2)
					{
						name = ((Object)val2).name + " (ShardGlow)"
					};
					val3.EnableKeyword("_EMISSION");
					val3.globalIlluminationFlags = (MaterialGlobalIlluminationFlags)1;
					if (val3.HasProperty(EmissionMapId) && !Object.op_Implicit((Object)(object)val3.GetTexture(EmissionMapId)))
					{
						if (val3.HasProperty(MainTexId) && Object.op_Implicit((Object)(object)val3.GetTexture(MainTexId)))
						{
							val3.SetTexture(EmissionMapId, val3.GetTexture(MainTexId));
							val3.SetTextureScale(EmissionMapId, val3.GetTextureScale(MainTexId));
							val3.SetTextureOffset(EmissionMapId, val3.GetTextureOffset(MainTexId));
						}
						else
						{
							val3.SetTexture(EmissionMapId, (Texture)(object)Texture2D.whiteTexture);
						}
					}
					val3.SetColor(EmissionColorId, emission);
					array[j] = val3;
					hand.Emissive.Add(val3);
					flag = true;
				}
				if (flag)
				{
					hand.Swapped.Add((val, sharedMaterials));
					val.sharedMaterials = array;
				}
			}
		}

		private static bool SupportsEmission(Material material)
		{
			bool flag = material.HasProperty(EmissionColorId);
			string text = (Object.op_Implicit((Object)(object)material.shader) ? ((Object)material.shader).name : "<none>");
			if (reportedShaders.Add(text))
			{
				ShardGlowPlugin.Log.LogInfo((object)(flag ? ("Shader '" + text + "' supports surface glow.") : ("Shader '" + text + "' has no _EmissionColor; weapons using it only get the light glow.")));
			}
			return flag;
		}

		private static void Clear(HandGlow hand)
		{
			if (Object.op_Implicit((Object)(object)hand.Light))
			{
				Object.Destroy((Object)(object)((Component)hand.Light).gameObject);
			}
			hand.Light = null;
			foreach (var (val, sharedMaterials) in hand.Swapped)
			{
				if (Object.op_Implicit((Object)(object)val))
				{
					val.sharedMaterials = sharedMaterials;
				}
			}
			hand.Swapped.Clear();
			foreach (Material item in hand.Emissive)
			{
				if (Object.op_Implicit((Object)(object)item))
				{
					Object.Destroy((Object)(object)item);
				}
			}
			hand.Emissive.Clear();
		}

		private static bool IsEligible(int itemHash)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Invalid comparison between Unknown and I4
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Invalid comparison between Unknown and I4
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Invalid comparison between Unknown and I4
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Invalid comparison between Unknown and I4
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Invalid comparison between Unknown and I4
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Invalid comparison between Unknown and I4
			if (itemHash == 0 || !Object.op_Implicit((Object)(object)ObjectDB.instance))
			{
				return false;
			}
			if (!itemTypeByHash.TryGetValue(itemHash, out var value))
			{
				GameObject val = default(GameObject);
				ItemDrop val2 = default(ItemDrop);
				value = (ItemType)((ObjectDB.instance.TryGetItemPrefab(itemHash, ref val) && val.TryGetComponent<ItemDrop>(ref val2)) ? ((int)val2.m_itemData.m_shared.m_itemType) : 0);
				itemTypeByHash[itemHash] = value;
			}
			if ((int)value <= 5)
			{
				if (value - 3 <= 1)
				{
					goto IL_007a;
				}
				if ((int)value == 5)
				{
					return GlowConfig.GlowShields.Value;
				}
			}
			else if ((int)value == 14 || value - 19 <= 1 || (int)value == 22)
			{
				goto IL_007a;
			}
			return false;
			IL_007a:
			return true;
		}

		private static void ReadTorchLight()
		{
			if (!torchRead && Object.op_Implicit((Object)(object)ObjectDB.instance))
			{
				torchRead = true;
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Torch");
				Light val = (Object.op_Implicit((Object)(object)itemPrefab) ? itemPrefab.GetComponentInChildren<Light>(true) : null);
				if (Object.op_Implicit((Object)(object)val))
				{
					torchIntensity = val.intensity;
					torchRange = val.range;
					ShardGlowPlugin.Log.LogInfo((object)$"Matching torch light: intensity {torchIntensity}, range {torchRange}.");
				}
				else
				{
					ShardGlowPlugin.Log.LogWarning((object)$"Torch light not found; using intensity {1.5f}, range {6f}.");
				}
			}
		}

		private static Vector3 VisualCenter(GameObject instance)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			bool flag = false;
			Bounds val = default(Bounds);
			Renderer[] componentsInChildren = instance.GetComponentsInChildren<Renderer>();
			foreach (Renderer val2 in componentsInChildren)
			{
				if (val2 is MeshRenderer || val2 is SkinnedMeshRenderer)
				{
					if (!flag)
					{
						val = val2.bounds;
						flag = true;
					}
					else
					{
						((Bounds)(ref val)).Encapsulate(val2.bounds);
					}
				}
			}
			if (!flag)
			{
				return instance.transform.position;
			}
			return ((Bounds)(ref val)).center;
		}
	}
	[BepInPlugin("brydonm.valheim.shardglow", "ShardGlow", "0.2.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class ShardGlowPlugin : BaseUnityPlugin
	{
		public const string Guid = "brydonm.valheim.shardglow";

		public const string Name = "ShardGlow";

		public const string Version = "0.2.2";

		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			if ((int)SystemInfo.graphicsDeviceType == 4)
			{
				Log.LogInfo((object)"Headless server detected, not patching.");
				return;
			}
			GlowConfig.Bind(((BaseUnityPlugin)this).Config);
			new Harmony("brydonm.valheim.shardglow").PatchAll();
		}
	}
	[HarmonyPatch(typeof(Player), "Awake")]
	internal static class Player_Awake_Patch
	{
		private static void Postfix(Player __instance)
		{
			if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<PlayerGlow>()))
			{
				((Component)__instance).gameObject.AddComponent<PlayerGlow>();
			}
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}