Decompiled source of Ljosgjord v1.0.0

Ljosgjord.dll

Decompiled a day ago
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace Ljosgjord;

[BepInPlugin("com.parallel53.ljosgjord", "Ljósgjörð", "1.0.0")]
public class LjosgjordPlugin : BaseUnityPlugin
{
	private const string BeltPrefab = "BeltStrength";

	private const string CircletPrefab = "HelmetDverger";

	private GameObject glow;

	private bool warned;

	private void Update()
	{
		Player localPlayer = Player.m_localPlayer;
		bool flag = (Object)(object)localPlayer != (Object)null && ((Humanoid)localPlayer).GetInventory().GetEquippedItems().Any((ItemData item) => (Object)(object)item.m_dropPrefab != (Object)null && ((Object)item.m_dropPrefab).name == "BeltStrength");
		if (flag && (Object)(object)glow == (Object)null)
		{
			glow = CreateGlow(localPlayer);
		}
		if ((Object)(object)glow != (Object)null && glow.activeSelf != flag)
		{
			glow.SetActive(flag);
		}
	}

	private GameObject CreateGlow(Player player)
	{
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("HelmetDverger");
		Light val = (((Object)(object)itemPrefab != (Object)null) ? itemPrefab.GetComponentInChildren<Light>(true) : null);
		Transform helmet = ((Component)player).GetComponent<VisEquipment>().m_helmet;
		if ((Object)(object)val == (Object)null || (Object)(object)helmet == (Object)null)
		{
			if (!warned)
			{
				warned = true;
				((BaseUnityPlugin)this).Logger.LogWarning((object)"No circlet light or head to attach it to");
			}
			return null;
		}
		GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, helmet);
		val2.transform.localPosition = ((Component)val).transform.localPosition;
		val2.transform.localRotation = ((Component)val).transform.localRotation;
		val2.SetActive(true);
		Light[] componentsInChildren = val2.GetComponentsInChildren<Light>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			((Behaviour)componentsInChildren[i]).enabled = true;
		}
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Added the circlet light to the belt wearer");
		return val2;
	}
}