Decompiled source of Wolfborn v1.0.4

Wolfborn (by LoupWave).dll

Decompiled 9 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;
using UnityEngine.UI;
using Wolfborn.Configuration;
using Wolfborn.Network;
using Wolfborn.Utils;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Wolfborn (by LoupWave)")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Wolfborn (by LoupWave)")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("10c3c687-ace4-4d44-9c84-5f7eaa45ac7d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Wolfborn
{
	public static class WolfbornZDOManager
	{
		public static readonly int Hash_IsCompanion = StringExtensionMethods.GetStableHashCode("WB_IsCompanion");

		public static readonly int Hash_VariantID = StringExtensionMethods.GetStableHashCode("WB_VariantID");

		public static readonly int Hash_WolfLevel = StringExtensionMethods.GetStableHashCode("WB_WolfLevel");

		public static readonly int Hash_CurrentXP = StringExtensionMethods.GetStableHashCode("WB_CurrentXP");

		public static readonly int Hash_IsUnconscious = StringExtensionMethods.GetStableHashCode("WB_IsUnconscious");

		public static readonly int Hash_Unconscious = Hash_IsUnconscious;

		public static readonly int Hash_Evaluated = StringExtensionMethods.GetStableHashCode("WB_Evaluated");

		public static readonly int Hash_FollowTarget = StringExtensionMethods.GetStableHashCode("WB_FollowTarget");

		public static readonly int Hash_TotemActive = StringExtensionMethods.GetStableHashCode("WB_TotemActive");

		public static readonly int Hash_TotemMode = StringExtensionMethods.GetStableHashCode("WB_TotemMode");

		public static void LoadCompanionData(WolfbornCompanion companion, ZNetView nview)
		{
			if (!((Object)(object)nview == (Object)null) && nview.IsValid() && nview.GetZDO() != null)
			{
				ZDO zDO = nview.GetZDO();
				companion.variantID = zDO.GetInt(Hash_VariantID, companion.variantID);
				companion.wolfLevel = Mathf.Clamp(zDO.GetInt(Hash_WolfLevel, companion.wolfLevel), 1, 10);
				companion.currentXP = zDO.GetFloat(Hash_CurrentXP, companion.currentXP);
				companion.isUnconscious = zDO.GetBool(Hash_IsUnconscious, companion.isUnconscious);
				if (nview.IsOwner())
				{
					zDO.Set(Hash_VariantID, companion.variantID, false);
					zDO.Set(Hash_WolfLevel, companion.wolfLevel, false);
				}
				companion.RecalculateStats();
				companion.ApplyVisuals();
				companion.m_initialized = true;
			}
		}

		public static void SyncFromZDO(WolfbornCompanion companion, ZNetView nview)
		{
			if (!((Object)(object)companion == (Object)null) && !((Object)(object)nview == (Object)null) && nview.IsValid() && nview.GetZDO() != null)
			{
				ZDO zDO = nview.GetZDO();
				companion.variantID = zDO.GetInt(Hash_VariantID, companion.variantID);
				companion.wolfLevel = Mathf.Clamp(zDO.GetInt(Hash_WolfLevel, companion.wolfLevel), 1, 10);
				companion.currentXP = zDO.GetFloat(Hash_CurrentXP, companion.currentXP);
				companion.isUnconscious = zDO.GetBool(Hash_IsUnconscious, companion.isUnconscious);
				companion.RecalculateStats();
				companion.ApplyVisuals();
			}
		}

		public static void SaveCompanionData(WolfbornCompanion companion, ZNetView nview)
		{
			if (!((Object)(object)nview == (Object)null) && nview.IsValid() && nview.IsOwner())
			{
				ZDO zDO = nview.GetZDO();
				if (zDO != null)
				{
					zDO.Set(Hash_WolfLevel, companion.wolfLevel, false);
					zDO.Set(Hash_CurrentXP, companion.currentXP);
					zDO.Set(Hash_IsUnconscious, companion.isUnconscious);
				}
			}
		}
	}
	[BepInPlugin("com.loupwave.wolfborn", "Wolfborn", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class WolfbornPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.loupwave.wolfborn";

		public const string PluginName = "Wolfborn";

		public const string PluginVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("com.loupwave.wolfborn");

		private void Awake()
		{
			WolfbornConfig.Init(((BaseUnityPlugin)this).Config);
			WolfRegistry.Initialize();
			WolfbornPrefabManager.RegisterPrefabs();
			WolfbornPieceManager.RegisterPieces();
			WolfbornLocalizationManager.LoadEmbeddedLocalizations();
			harmony.PatchAll();
			Logger.LogInfo((object)"Modifier [Wolfborn] by LoupWave initialized successfully!");
		}

		private void OnDestroy()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			WolfbornAssetManager.Unload();
		}
	}
	public class WolfbornCompanion : MonoBehaviour
	{
		private Character m_character;

		private ZNetView m_nview;

		private static readonly MaterialPropertyBlock mpb = new MaterialPropertyBlock();

		public bool m_initialized;

		public static readonly List<WolfbornCompanion> m_instances = new List<WolfbornCompanion>();

		public int variantID = 1;

		public int wolfLevel = 1;

		public float currentXP;

		public float xpToNextLevel = 150f;

		public float extraMaxHp;

		public float damageMultiplier = 1f;

		public float unconsciousTimer;

		private const float UNCONSCIOUS_DURATION = 60f;

		public float postWakeInvincibleTimer;

		public bool isBeingSacrificed;

		private Vector3 lastPosition;

		private GameObject savedFollowTarget;

		private GameObject activeShieldVFX;

		private Light activeShieldLight;

		private GameObject activeOrbitShieldVFX;

		private float shieldOrbitAngle;

		public bool isUnconscious
		{
			get
			{
				if ((Object)(object)m_nview != (Object)null && m_nview.GetZDO() != null)
				{
					return m_nview.GetZDO().GetBool(WolfbornZDOManager.Hash_IsUnconscious, false);
				}
				return false;
			}
			set
			{
				if ((Object)(object)m_nview != (Object)null && m_nview.IsValid())
				{
					if (!m_nview.IsOwner())
					{
						m_nview.ClaimOwnership();
					}
					m_nview.GetZDO().Set(WolfbornZDOManager.Hash_IsUnconscious, value);
				}
			}
		}

		private void Awake()
		{
			if (!m_instances.Contains(this))
			{
				m_instances.Add(this);
			}
			m_nview = ((Component)this).GetComponent<ZNetView>();
			m_character = ((Component)this).GetComponent<Character>();
			DisableValheimNativeScaling();
		}

		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)
			lastPosition = ((Component)this).transform.position;
		}

		private int GetCorrectStarLevel()
		{
			switch (variantID)
			{
			case 3:
			case 4:
				return 1;
			case 5:
			case 6:
				return 2;
			default:
				return 0;
			}
		}

		private float GetNativeValheimScale()
		{
			return 1f;
		}

		private void DisableValheimNativeScaling()
		{
			if ((Object)(object)m_character == (Object)null)
			{
				m_character = ((Component)this).GetComponent<Character>();
			}
			if ((Object)(object)m_character != (Object)null)
			{
				FieldInfo field = typeof(Character).GetField("m_scaleByLevel", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.FlattenHierarchy);
				if (field != null)
				{
					field.SetValue(m_character, false);
				}
			}
		}

		private void RegisterRPCs()
		{
			if ((Object)(object)m_nview != (Object)null && m_nview.IsValid())
			{
				m_nview.Register<string, int>("RPC_WolfbornLevelUp", (Action<long, string, int>)RPC_WolfbornLevelUp);
			}
		}

		public void TriggerLevelUpNotification()
		{
			if ((Object)(object)m_nview != (Object)null && m_nview.IsValid())
			{
				Character component = ((Component)this).GetComponent<Character>();
				string text = (((Object)(object)component != (Object)null) ? component.GetHoverName() : "$wb_default_wolf_name");
				if (string.IsNullOrEmpty(text))
				{
					text = "$wb_default_wolf_name";
				}
				m_nview.InvokeRPC(ZNetView.Everybody, "RPC_WolfbornLevelUp", new object[2] { text, wolfLevel });
			}
		}

		private void Update()
		{
			if (!m_initialized)
			{
				WolfbornZDOManager.LoadCompanionData(this, m_nview);
			}
		}

		private void LateUpdate()
		{
			//IL_01bd: 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_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			if (!m_initialized)
			{
				return;
			}
			if (postWakeInvincibleTimer > 0f)
			{
				postWakeInvincibleTimer -= Time.deltaTime;
			}
			UpdateFollowTargetZDO();
			if (isUnconscious)
			{
				if (isBeingSacrificed)
				{
					return;
				}
				MonsterAI component = ((Component)this).GetComponent<MonsterAI>();
				if ((Object)(object)component != (Object)null && ((Behaviour)component).enabled)
				{
					savedFollowTarget = component.GetFollowTarget();
					((BaseAI)component).StopMoving();
					((Behaviour)component).enabled = false;
				}
				if ((Object)(object)activeShieldVFX == (Object)null)
				{
					SpawnShieldEffect();
				}
				if ((Object)(object)m_nview != (Object)null && m_nview.IsOwner())
				{
					unconsciousTimer -= Time.deltaTime;
				}
				UpdateWolfShieldOrbit();
				Character component2 = ((Component)this).GetComponent<Character>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.SetHealth(1f);
					SEMan sEMan = component2.GetSEMan();
					if (sEMan != null)
					{
						sEMan.RemoveAllStatusEffects(false);
					}
				}
				if (unconsciousTimer <= 0f && (Object)(object)m_nview != (Object)null && m_nview.IsOwner())
				{
					WakeUp();
				}
				return;
			}
			if ((Object)(object)activeShieldVFX != (Object)null)
			{
				RemoveShieldEffect();
			}
			MonsterAI component3 = ((Component)this).GetComponent<MonsterAI>();
			if ((Object)(object)component3 != (Object)null && !((Behaviour)component3).enabled)
			{
				((Behaviour)component3).enabled = true;
				if ((Object)(object)savedFollowTarget != (Object)null)
				{
					component3.SetFollowTarget(savedFollowTarget);
				}
			}
			if (wolfLevel >= 10 || !((Object)(object)m_nview != (Object)null) || !m_nview.IsOwner())
			{
				return;
			}
			Character component4 = ((Component)this).GetComponent<Character>();
			if (!((Object)(object)component4 != (Object)null) || component4.IsDead() || !component4.IsTamed())
			{
				return;
			}
			float num = Vector3.Distance(((Component)this).transform.position, lastPosition);
			if (num >= 25f)
			{
				MonsterAI component5 = ((Component)this).GetComponent<MonsterAI>();
				if ((Object)(object)component5 != (Object)null && (Object)(object)component5.GetFollowTarget() != (Object)null && (Object)(object)component5.GetFollowTarget().GetComponent<Player>() != (Object)null)
				{
					AddXP(0.2f * (num / 25f));
				}
				lastPosition = ((Component)this).transform.position;
			}
		}

		private void UpdateFollowTargetZDO()
		{
			//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)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid())
			{
				return;
			}
			MonsterAI component = ((Component)this).GetComponent<MonsterAI>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			GameObject followTarget = component.GetFollowTarget();
			ZDOID val = ZDOID.None;
			if ((Object)(object)followTarget != (Object)null)
			{
				Player component2 = followTarget.GetComponent<Player>();
				if ((Object)(object)component2 != (Object)null && ((Character)component2).GetZDOID() != ZDOID.None)
				{
					val = ((Character)component2).GetZDOID();
				}
			}
			ZDO zDO = m_nview.GetZDO();
			if (zDO == null)
			{
				return;
			}
			zDO.Set("WB_IsCompanion", true);
			if (zDO.GetZDOID("WB_FollowTarget") != val)
			{
				if (!m_nview.IsOwner())
				{
					m_nview.ClaimOwnership();
				}
				zDO.Set("WB_FollowTarget", val);
			}
		}

		public void TeleportTo(Vector3 position)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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)
			Character component = ((Component)this).GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				component.TeleportTo(position, ((Component)this).transform.rotation, true);
			}
			else
			{
				((Component)this).transform.position = position;
			}
			if ((Object)(object)m_nview != (Object)null && m_nview.IsValid())
			{
				m_nview.GetZDO().SetPosition(position);
			}
		}

		public string GetLevelText()
		{
			string text = ((wolfLevel >= 10) ? "$wb_level_max" : "$wb_level");
			return string.Format(Localization.instance.Localize(text), wolfLevel);
		}

		public void RecalculateStats()
		{
			int num = WolfRegistry.GetDefinition(variantID)?.StarLevel ?? 0;
			float num2 = 80f * (float)(num + 1);
			float num3 = 600f;
			if (num == 1)
			{
				num3 = 700f;
			}
			else if (num >= 2)
			{
				num3 = 800f;
			}
			float num4 = num3 - num2;
			extraMaxHp = Mathf.Round(num4 * ((float)(wolfLevel - 1) / 9f));
			damageMultiplier = 1f + (float)(wolfLevel - 1) * 0.05556f;
			xpToNextLevel = Mathf.Round(150f * Mathf.Pow(1.4542f, (float)(wolfLevel - 1)));
		}

		private void RPC_WolfbornLevelUp(long sender, string wolfName, int level)
		{
			//IL_0014: 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)
			if (!((Object)(object)Player.m_localPlayer == (Object)null) && Vector3.Distance(((Component)this).transform.position, ((Component)Player.m_localPlayer).transform.position) <= 50f && (Object)(object)MessageHud.instance != (Object)null)
			{
				MessageHud.instance.ShowMessage((MessageType)2, Localization.instance.Localize("$wb_msg_levelup", new string[2]
				{
					wolfName,
					level.ToString()
				}), 0, (Sprite)null, false, true);
			}
		}

		public void ApplyVisuals()
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			WolfDefinition definition = WolfRegistry.GetDefinition(variantID);
			if (definition == null)
			{
				return;
			}
			if ((Object)(object)m_character == (Object)null)
			{
				m_character = ((Component)this).GetComponent<Character>();
			}
			DisableValheimNativeScaling();
			if ((Object)(object)m_character != (Object)null)
			{
				int num = GetCorrectStarLevel() + 1;
				if (m_character.GetLevel() != num)
				{
					m_character.SetLevel(num);
					DisableValheimNativeScaling();
				}
			}
			float nativeValheimScale = GetNativeValheimScale();
			float num2 = Mathf.Clamp01((float)(wolfLevel - 1) / 9f);
			float num3 = Mathf.Lerp(1f, 1.2f, num2);
			float num4 = nativeValheimScale * num3;
			((Component)this).transform.localScale = new Vector3(num4, num4, num4);
			Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true);
			if (componentsInChildren == null)
			{
				return;
			}
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				if (!((Object)(object)val == (Object)null))
				{
					val.GetPropertyBlock(mpb);
					mpb.SetColor("_Color", definition.FurColor);
					mpb.SetColor("_TintColor", definition.FurColor);
					val.SetPropertyBlock(mpb);
				}
			}
		}

		public void AddXP(float amount)
		{
			if ((Object)(object)m_nview == (Object)null || !m_nview.IsOwner() || wolfLevel >= 10)
			{
				return;
			}
			currentXP += amount;
			bool flag = false;
			while (wolfLevel < 10)
			{
				float requiredXPForLevel = GetRequiredXPForLevel(wolfLevel);
				if (!(currentXP >= requiredXPForLevel))
				{
					break;
				}
				currentXP -= requiredXPForLevel;
				wolfLevel++;
				flag = true;
			}
			if (wolfLevel >= 10)
			{
				currentXP = 0f;
			}
			RecalculateStats();
			ApplyVisuals();
			WolfbornZDOManager.SaveCompanionData(this, m_nview);
			WolfbornRPCManager.BroadcastStatsUpdate(this);
			if (flag)
			{
				OnLevelUpEffect();
			}
		}

		private float GetRequiredXPForLevel(int level)
		{
			return (float)level * 100f;
		}

		private void OnLevelUpEffect()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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)
			if (!((Object)(object)ZNetScene.instance == (Object)null))
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("vfx_create_tamed_animal");
				if ((Object)(object)prefab != (Object)null)
				{
					Object.Instantiate<GameObject>(prefab, ((Component)this).transform.position + Vector3.up * 0.5f, Quaternion.identity);
				}
			}
		}

		public void SetUnconscious()
		{
			isUnconscious = true;
			unconsciousTimer = 60f;
			Character component = ((Component)this).GetComponent<Character>();
			MonsterAI component2 = ((Component)this).GetComponent<MonsterAI>();
			if ((Object)(object)component != (Object)null)
			{
				component.SetHealth(1f);
				SEMan sEMan = component.GetSEMan();
				if (sEMan != null)
				{
					sEMan.RemoveAllStatusEffects(false);
				}
			}
			if ((Object)(object)component2 != (Object)null)
			{
				savedFollowTarget = component2.GetFollowTarget();
				((BaseAI)component2).StopMoving();
				((Behaviour)component2).enabled = false;
			}
			SpawnShieldEffect();
			WolfbornZDOManager.SaveCompanionData(this, m_nview);
		}

		public void WakeUp()
		{
			isUnconscious = false;
			postWakeInvincibleTimer = 5f;
			Character component = ((Component)this).GetComponent<Character>();
			MonsterAI component2 = ((Component)this).GetComponent<MonsterAI>();
			if ((Object)(object)component != (Object)null)
			{
				component.SetHealth(component.GetMaxHealth() * 0.2f);
				SEMan sEMan = component.GetSEMan();
				if (sEMan != null)
				{
					sEMan.RemoveAllStatusEffects(false);
				}
			}
			if ((Object)(object)component2 != (Object)null)
			{
				((Behaviour)component2).enabled = true;
				if ((Object)(object)savedFollowTarget != (Object)null)
				{
					component2.SetFollowTarget(savedFollowTarget);
				}
			}
			RemoveShieldEffect();
			WolfbornZDOManager.SaveCompanionData(this, m_nview);
		}

		private void SpawnShieldEffect()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Expected O, but got Unknown
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Expected O, but got Unknown
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			if ((int)SystemInfo.graphicsDeviceType == 4)
			{
				return;
			}
			Component[] components;
			if ((Object)(object)activeShieldVFX == (Object)null)
			{
				activeShieldVFX = GameObject.CreatePrimitive((PrimitiveType)0);
				components = activeShieldVFX.GetComponents<Component>();
				foreach (Component val in components)
				{
					if (!(val is Transform) && !(val is MeshFilter) && !(val is MeshRenderer))
					{
						Object.Destroy((Object)(object)val);
					}
				}
				activeShieldVFX.transform.SetParent(((Component)this).transform);
				activeShieldVFX.transform.localPosition = new Vector3(0f, 0.55f, 1f);
				activeShieldVFX.transform.localScale = Vector3.one * 0.25f;
				Renderer component = activeShieldVFX.GetComponent<Renderer>();
				if ((Object)(object)component != (Object)null)
				{
					Material val2 = new Material(Shader.Find("Particles/Standard Unlit") ?? Shader.Find("UI/Default"));
					val2.color = new Color(0.95f, 0.65f, 0.15f, 1f);
					component.material = val2;
				}
				activeShieldLight = activeShieldVFX.AddComponent<Light>();
				activeShieldLight.type = (LightType)2;
				activeShieldLight.color = new Color(0.95f, 0.65f, 0.15f, 1f);
				activeShieldLight.intensity = 1.8f;
				activeShieldLight.range = 6f;
			}
			if (!((Object)(object)activeOrbitShieldVFX == (Object)null))
			{
				return;
			}
			activeOrbitShieldVFX = GameObject.CreatePrimitive((PrimitiveType)0);
			components = activeOrbitShieldVFX.GetComponents<Component>();
			foreach (Component val3 in components)
			{
				if (!(val3 is Transform) && !(val3 is MeshFilter) && !(val3 is MeshRenderer))
				{
					Object.Destroy((Object)(object)val3);
				}
			}
			activeOrbitShieldVFX.transform.localScale = Vector3.one * 0.15f;
			Renderer component2 = activeOrbitShieldVFX.GetComponent<Renderer>();
			if ((Object)(object)component2 != (Object)null)
			{
				Material val4 = new Material(Shader.Find("Particles/Standard Unlit") ?? Shader.Find("UI/Default"));
				val4.color = new Color(0.95f, 0.65f, 0.15f, 1f);
				component2.material = val4;
			}
			Light obj = activeOrbitShieldVFX.AddComponent<Light>();
			obj.type = (LightType)2;
			obj.color = new Color(0.95f, 0.65f, 0.15f, 1f);
			obj.intensity = 1.2f;
			obj.range = 3f;
		}

		private void UpdateWolfShieldOrbit()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: 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_0079: 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_00ae: 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)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)activeOrbitShieldVFX == (Object)null))
			{
				activeOrbitShieldVFX.SetActive(true);
				shieldOrbitAngle += 120f * Time.deltaTime;
				if (shieldOrbitAngle >= 360f)
				{
					shieldOrbitAngle -= 360f;
				}
				float num = shieldOrbitAngle * ((float)Math.PI / 180f);
				Vector3 val = ((Component)this).transform.position + Vector3.up * 0.5f;
				Vector3 val2 = default(Vector3);
				((Vector3)(ref val2))..ctor(Mathf.Cos(num) * 1.5f, 0f, Mathf.Sin(num) * 1.5f);
				activeOrbitShieldVFX.transform.position = val + val2;
			}
		}

		private void RemoveShieldEffect()
		{
			if ((Object)(object)activeShieldVFX != (Object)null)
			{
				Object.Destroy((Object)(object)activeShieldVFX);
				activeShieldVFX = null;
			}
			if ((Object)(object)activeOrbitShieldVFX != (Object)null)
			{
				Object.Destroy((Object)(object)activeOrbitShieldVFX);
				activeOrbitShieldVFX = null;
			}
		}

		private void OnDestroy()
		{
			m_instances.Remove(this);
		}

		public bool IsFollowingPlayer(Player player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return false;
			}
			MonsterAI component = ((Component)this).GetComponent<MonsterAI>();
			if ((Object)(object)component != (Object)null)
			{
				GameObject followTarget = component.GetFollowTarget();
				if ((Object)(object)followTarget != (Object)null && (Object)(object)followTarget.GetComponent<Player>() == (Object)(object)player)
				{
					return true;
				}
			}
			return false;
		}
	}
	public class WolfbornTotem : MonoBehaviour, Hoverable, Interactable
	{
		private ZNetView m_nview;

		private Camera cachedCamera;

		private float distanceCheckTimer;

		private const float DISTANCE_CHECK_INTERVAL = 0.25f;

		private bool isVisibleByDistance = true;

		private GameObject activeOrbitShieldVFX;

		private static Material sharedOrbitMaterial;

		private float shieldOrbitAngle;

		private void Awake()
		{
			m_nview = ((Component)this).GetComponent<ZNetView>();
			RegisterRPCs();
		}

		private void Start()
		{
			EnsureAlwaysActiveVisuals();
			SpawnVerticalOrbitShield();
		}

		private void RegisterRPCs()
		{
			if ((Object)(object)m_nview != (Object)null && m_nview.IsValid())
			{
				m_nview.Register<bool>("RPC_WolfbornTotemToggle", (Action<long, bool>)RPC_WolfbornTotemToggle);
			}
		}

		private void Update()
		{
			//IL_0058: 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_006d: 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)
			if ((Object)(object)cachedCamera == (Object)null)
			{
				cachedCamera = Camera.main;
				if ((Object)(object)cachedCamera == (Object)null)
				{
					return;
				}
			}
			distanceCheckTimer += Time.deltaTime;
			if (distanceCheckTimer >= 0.25f)
			{
				distanceCheckTimer = 0f;
				Vector3 val = ((Component)this).transform.position - ((Component)cachedCamera).transform.position;
				float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
				isVisibleByDistance = sqrMagnitude <= 1225f;
				if ((Object)(object)activeOrbitShieldVFX != (Object)null && activeOrbitShieldVFX.activeSelf != isVisibleByDistance)
				{
					activeOrbitShieldVFX.SetActive(isVisibleByDistance);
				}
			}
			if (isVisibleByDistance)
			{
				UpdateVerticalOrbitAnimation();
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)activeOrbitShieldVFX != (Object)null)
			{
				Object.Destroy((Object)(object)activeOrbitShieldVFX);
			}
		}

		public string GetHoverName()
		{
			return Localization.instance.Localize("$wb_totem_name");
		}

		public string GetHoverText()
		{
			return Localization.instance.Localize("$wb_totem_hover_text").Replace("$KEY_Use", "E");
		}

		public float GetHoverOffset()
		{
			return 0f;
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			//IL_0042: 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_004e: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			if (hold)
			{
				return false;
			}
			Player val = (Player)(object)((user is Player) ? user : null);
			if ((Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)Player.m_localPlayer)
			{
				return false;
			}
			if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid())
			{
				return false;
			}
			ZDOID zDOID = ((Character)val).GetZDOID();
			Vector3 position = ((Component)this).transform.position;
			if (ZRoutedRpc.instance != null)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(0L, "Wolfborn_RequestTotemTeleport", new object[2] { zDOID, position });
				if ((Object)(object)m_nview != (Object)null && m_nview.IsValid())
				{
					m_nview.InvokeRPC(ZNetView.Everybody, "RPC_WolfbornTotemToggle", new object[1] { true });
				}
				return true;
			}
			return false;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}

		private void RPC_WolfbornTotemToggle(long sender, bool active)
		{
		}

		private void EnsureAlwaysActiveVisuals()
		{
			ParticleSystem[] componentsInChildren = ((Component)this).GetComponentsInChildren<ParticleSystem>(true);
			foreach (ParticleSystem val in componentsInChildren)
			{
				if (!val.isPlaying)
				{
					val.Play();
				}
			}
		}

		private void SpawnVerticalOrbitShield()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_004c: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			if ((int)SystemInfo.graphicsDeviceType == 4 || !((Object)(object)activeOrbitShieldVFX == (Object)null))
			{
				return;
			}
			activeOrbitShieldVFX = GameObject.CreatePrimitive((PrimitiveType)0);
			Collider component = activeOrbitShieldVFX.GetComponent<Collider>();
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			activeOrbitShieldVFX.transform.localScale = Vector3.one * 0.13f;
			Renderer component2 = activeOrbitShieldVFX.GetComponent<Renderer>();
			if ((Object)(object)component2 != (Object)null)
			{
				if ((Object)(object)sharedOrbitMaterial == (Object)null)
				{
					sharedOrbitMaterial = new Material(Shader.Find("Particles/Standard Unlit") ?? Shader.Find("UI/Default"));
					sharedOrbitMaterial.color = new Color(0.95f, 0.65f, 0.15f, 1f);
				}
				component2.sharedMaterial = sharedOrbitMaterial;
			}
		}

		private void UpdateVerticalOrbitAnimation()
		{
			//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_008d: 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)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)activeOrbitShieldVFX == (Object)null))
			{
				float num = 50f;
				float num2 = 0.7f;
				float num3 = 0f;
				float num4 = 0.6f;
				float num5 = 1.1f;
				float num6 = 0f;
				shieldOrbitAngle += num * Time.deltaTime;
				if (shieldOrbitAngle >= 360f)
				{
					shieldOrbitAngle -= 360f;
				}
				float num7 = shieldOrbitAngle * ((float)Math.PI / 180f);
				Vector3 val = ((Component)this).transform.position + ((Component)this).transform.forward * num4 + Vector3.up * num5 + ((Component)this).transform.right * num3;
				Vector3 val2 = ((Component)this).transform.right * Mathf.Cos(num7) * num2 + ((Component)this).transform.up * Mathf.Sin(num7) * num2;
				if (num6 != 0f)
				{
					val2 = Quaternion.AngleAxis(num6, ((Component)this).transform.forward) * val2;
				}
				activeOrbitShieldVFX.transform.position = val + val2;
			}
		}
	}
	public static class WolfbornPieceManager
	{
		public static float TotemScale = 1f;

		public static void RegisterPieces()
		{
			PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailable;
		}

		private static void OnVanillaPrefabsAvailable()
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Expected O, but got Unknown
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Expected O, but got Unknown
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Expected O, but got Unknown
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailable;
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("Wolfborn_Totem", "guard_stone");
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"[Wolfborn] Falha ao clonar o prefab 'guard_stone'.");
				return;
			}
			Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val2 in componentsInChildren)
			{
				if (!((Object)(object)val2 != (Object)null) || val2.sharedMaterials == null)
				{
					continue;
				}
				Material[] array = (Material[])(object)new Material[val2.sharedMaterials.Length];
				for (int j = 0; j < val2.sharedMaterials.Length; j++)
				{
					if ((Object)(object)val2.sharedMaterials[j] != (Object)null)
					{
						array[j] = Object.Instantiate<Material>(val2.sharedMaterials[j]);
					}
				}
				val2.materials = array;
			}
			val.transform.localScale = Vector3.one * TotemScale;
			PrivateArea component = val.GetComponent<PrivateArea>();
			if ((Object)(object)component != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component);
			}
			CircleProjector[] componentsInChildren2 = val.GetComponentsInChildren<CircleProjector>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				Object.DestroyImmediate((Object)(object)componentsInChildren2[i]);
			}
			Transform[] componentsInChildren3 = val.GetComponentsInChildren<Transform>(true);
			foreach (Transform val3 in componentsInChildren3)
			{
				if ((Object)(object)val3 != (Object)null && (Object)(object)val3 != (Object)(object)val.transform && (((Object)val3).name.ToLower().Contains("area") || ((Object)val3).name.ToLower().Contains("marker") || ((Object)val3).name.ToLower().Contains("projector")))
				{
					Object.DestroyImmediate((Object)(object)((Component)val3).gameObject);
				}
			}
			val.AddComponent<WolfbornTotem>();
			PieceManager.Instance.AddPieceCategory("Wolfborn");
			Piece component2 = val.GetComponent<Piece>();
			if ((Object)(object)component2 != (Object)null)
			{
				component2.m_name = "$wb_totem_name";
				component2.m_description = "$wb_totem_description";
				component2.m_enabled = true;
				component2.m_craftingStation = null;
				component2.m_allowedInDungeons = true;
				component2.m_category = PieceManager.Instance.GetPieceCategory("Wolfborn").Value;
			}
			PieceConfig val4 = new PieceConfig();
			val4.Name = "$wb_totem_name";
			val4.Description = "$wb_totem_description";
			val4.PieceTable = "Hammer";
			val4.Category = "Wolfborn";
			val4.CraftingStation = "";
			val4.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig("Wood", 1, 0, true)
			};
			PieceConfig val5 = val4;
			CustomPiece val6 = new CustomPiece(val, false, val5);
			PieceManager.Instance.AddPiece(val6);
			Logger.LogInfo((object)"[Wolfborn] 'Wolfborn Totem' configurado com sucesso e 100% isolado do guard_stone vanilla.");
		}
	}
	public static class WolfbornPrefabManager
	{
		public static void RegisterPrefabs()
		{
			PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailable;
		}

		private static void OnVanillaPrefabsAvailable()
		{
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailable;
			foreach (WolfDefinition allWolf in WolfRegistry.GetAllWolves())
			{
				GameObject val = PrefabManager.Instance.CreateClonedPrefab(allWolf.PrefabName, "Wolf");
				if (!((Object)(object)val == (Object)null))
				{
					WolfbornCompanion wolfbornCompanion = val.GetComponent<WolfbornCompanion>();
					if ((Object)(object)wolfbornCompanion == (Object)null)
					{
						wolfbornCompanion = val.AddComponent<WolfbornCompanion>();
					}
					wolfbornCompanion.variantID = allWolf.ID;
					CustomPrefab val2 = new CustomPrefab(val, false);
					PrefabManager.Instance.AddPrefab(val2);
				}
			}
		}
	}
	[HarmonyPatch]
	public static class WolfbornProtectionPatches
	{
		private static readonly FieldRef<EnemyHud, IDictionary> m_hudsRef = AccessTools.FieldRefAccess<EnemyHud, IDictionary>("m_huds");

		private static readonly Type hudDataType = typeof(EnemyHud).GetNestedType("HudData", BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldRef<object, GameObject> m_guiRef = AccessTools.FieldRefAccess<object, GameObject>(AccessTools.Field(hudDataType, "m_gui"));

		private static readonly FieldRef<object, GuiBar> m_healthFastRef = AccessTools.FieldRefAccess<object, GuiBar>(AccessTools.Field(hudDataType, "m_healthFast"));

		[HarmonyPatch(typeof(Character), "GetHoverName")]
		[HarmonyPostfix]
		private static void ModifyHoverName(Character __instance, ref string __result)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			WolfbornCompanion component = ((Component)__instance).GetComponent<WolfbornCompanion>();
			if ((Object)(object)component != (Object)null && component.m_initialized)
			{
				Tameable component2 = ((Component)__instance).GetComponent<Tameable>();
				string text = (((Object)(object)component2 != (Object)null) ? component2.GetText() : string.Empty);
				if (!string.IsNullOrEmpty(text))
				{
					__result = text;
				}
				else
				{
					__result = Localization.instance.Localize("<color=#FFD700>$wb_default_name</color>");
				}
			}
		}

		[HarmonyPatch(typeof(EnemyHud), "UpdateHuds")]
		[HarmonyPostfix]
		private static void UpdateWolfbornHudIcons(EnemyHud __instance)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//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_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: 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)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: 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_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			if ((int)SystemInfo.graphicsDeviceType == 4 || (Object)(object)__instance == (Object)null)
			{
				return;
			}
			WolfbornAssetManager.EnsureLoaded();
			float num = 20f;
			float num2 = -14f;
			float num3 = 34f;
			IDictionary dictionary = m_hudsRef.Invoke(__instance);
			if (dictionary == null)
			{
				return;
			}
			foreach (DictionaryEntry item in dictionary)
			{
				object key = item.Key;
				Character val = (Character)((key is Character) ? key : null);
				object value = item.Value;
				if ((Object)(object)val == (Object)null || value == null)
				{
					continue;
				}
				GameObject val2 = m_guiRef.Invoke(value);
				GuiBar val3 = m_healthFastRef.Invoke(value);
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				Transform val4 = val2.transform.Find("WolfbornHUDIcon");
				WolfbornCompanion component = ((Component)val).GetComponent<WolfbornCompanion>();
				if ((Object)(object)component != (Object)null && component.m_initialized)
				{
					Image val5 = null;
					if ((Object)(object)val4 == (Object)null)
					{
						GameObject val6 = new GameObject("WolfbornHUDIcon", new Type[2]
						{
							typeof(RectTransform),
							typeof(Image)
						});
						val6.transform.SetParent(val2.transform, false);
						val5 = val6.GetComponent<Image>();
						val5.preserveAspect = true;
						val4 = val6.transform;
					}
					else
					{
						val5 = ((Component)val4).GetComponent<Image>();
					}
					RectTransform component2 = ((Component)val4).GetComponent<RectTransform>();
					component2.sizeDelta = new Vector2(num, num);
					if ((Object)(object)val5 != (Object)null && (Object)(object)WolfbornAssetManager.WolfIconSprite != (Object)null)
					{
						val5.sprite = WolfbornAssetManager.WolfIconSprite;
						((Graphic)val5).color = Color.white;
					}
					Vector3 val7 = Vector3.zero;
					float num4 = 40f;
					if ((Object)(object)val3 != (Object)null)
					{
						val7 = ((Component)val3).transform.localPosition;
						RectTransform component3 = ((Component)val3).GetComponent<RectTransform>();
						if ((Object)(object)component3 != (Object)null)
						{
							Rect rect = component3.rect;
							if (((Rect)(ref rect)).width > 0f)
							{
								rect = component3.rect;
								num4 = ((Rect)(ref rect)).width / 2f;
							}
						}
					}
					float num5 = val7.x - num4 + num2;
					float num6 = val7.y + num3;
					((Transform)component2).localPosition = new Vector3(num5, num6, val7.z);
					((Component)val4).gameObject.SetActive(true);
				}
				else if ((Object)(object)val4 != (Object)null)
				{
					((Component)val4).gameObject.SetActive(false);
				}
			}
		}

		[HarmonyPatch(typeof(Tameable), "GetHoverText")]
		[HarmonyPostfix]
		private static void RenderHoverUI(Tameable __instance, ref string __result)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			WolfbornCompanion component = ((Component)__instance).GetComponent<WolfbornCompanion>();
			if ((Object)(object)component != (Object)null && component.m_initialized)
			{
				if (component.isUnconscious)
				{
					int num = Mathf.CeilToInt(component.unconsciousTimer);
					string arg = Localization.instance.Localize("$wb_status_unconscious");
					__result += $"\n<color=red><b>[ {arg} ] ({num}s)</b></color>";
				}
				else if (__instance.IsTamed())
				{
					Character component2 = ((Component)__instance).GetComponent<Character>();
					float num2 = Mathf.Ceil(component2.GetHealth());
					float num3 = Mathf.Ceil(component2.GetMaxHealth());
					int num4 = Mathf.RoundToInt((component.damageMultiplier - 1f) * 100f);
					string text = Localization.instance.Localize("$wb_damage_base");
					string text2 = ((num4 > 0) ? $"+{num4}%" : text);
					bool num5 = component.wolfLevel >= 10;
					string text3 = (num5 ? string.Format(Localization.instance.Localize("$wb_level_max"), component.wolfLevel) : string.Format(Localization.instance.Localize("$wb_level"), component.wolfLevel));
					string text4 = (num5 ? ("<color=#FFD700><b>" + text3 + "</b></color>") : ("<color=yellow><b>" + text3 + "</b></color>"));
					string text5 = (num5 ? "" : $"\n<color=orange>XP:</color> {component.currentXP:F0}/{component.xpToNextLevel:F0}");
					string text6 = Localization.instance.Localize("$wb_label_bonus_damage");
					__result = __result + "\n" + text4 + text5 + $"\n<color=green>HP:</color> {num2}/{num3}" + "\n<color=red>" + text6 + ":</color> " + text2;
				}
			}
		}

		[HarmonyPatch(typeof(Character), "SetLevel")]
		[HarmonyPostfix]
		private static void UpdateCompanionScale(Character __instance)
		{
			WolfbornCompanion wolfbornCompanion = ((__instance != null) ? ((Component)__instance).GetComponent<WolfbornCompanion>() : null);
			if ((Object)(object)wolfbornCompanion != (Object)null && wolfbornCompanion.m_initialized)
			{
				wolfbornCompanion.ApplyVisuals();
			}
		}

		[HarmonyPatch(typeof(Character), "OnDeath")]
		[HarmonyPrefix]
		private static bool PreventDeath(Character __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			if (!__instance.IsTamed())
			{
				return true;
			}
			WolfbornCompanion component = ((Component)__instance).GetComponent<WolfbornCompanion>();
			if ((Object)(object)component != (Object)null && component.m_initialized)
			{
				if (component.isBeingSacrificed)
				{
					return true;
				}
				if (!component.isUnconscious)
				{
					component.SetUnconscious();
				}
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(Character), "Damage")]
		[HarmonyPrefix]
		private static bool HandleDamage(Character __instance, HitData hit)
		{
			if ((Object)(object)__instance == (Object)null || hit == null)
			{
				return true;
			}
			Character attacker = hit.GetAttacker();
			if ((Object)(object)attacker != (Object)null)
			{
				WolfbornCompanion component = ((Component)attacker).GetComponent<WolfbornCompanion>();
				if ((Object)(object)component != (Object)null && component.m_initialized)
				{
					if (component.isUnconscious)
					{
						return false;
					}
					((DamageTypes)(ref hit.m_damage)).Modify(component.damageMultiplier);
					if (hit.GetTotalDamage() >= __instance.GetHealth())
					{
						component.AddXP(15f);
					}
				}
			}
			WolfbornCompanion component2 = ((Component)__instance).GetComponent<WolfbornCompanion>();
			if ((Object)(object)component2 != (Object)null && component2.m_initialized)
			{
				if (!__instance.IsTamed())
				{
					return true;
				}
				if (IsButcherKnife(hit))
				{
					component2.isBeingSacrificed = true;
					return true;
				}
				if (component2.isUnconscious || component2.postWakeInvincibleTimer > 0f)
				{
					return false;
				}
				if (hit.GetTotalDamage() >= __instance.GetHealth())
				{
					component2.SetUnconscious();
					return false;
				}
			}
			return true;
		}

		private static bool IsButcherKnife(HitData hit)
		{
			if (hit == null)
			{
				return false;
			}
			Character attacker = hit.GetAttacker();
			if ((Object)(object)attacker != (Object)null && attacker.IsPlayer())
			{
				Character obj = ((attacker is Player) ? attacker : null);
				ItemData val = ((obj != null) ? ((Humanoid)obj).GetCurrentWeapon() : null);
				if (val?.m_shared != null)
				{
					string text = val.m_shared.m_name.ToLower();
					if (text.Contains("butcher") || text.Contains("açougueiro") || text.Contains("knife_butcher"))
					{
						return true;
					}
				}
			}
			return false;
		}

		[HarmonyPatch(typeof(Character), "GetMaxHealth")]
		[HarmonyPostfix]
		private static void ApplyBonusMaxHealth(Character __instance, ref float __result)
		{
			WolfbornCompanion wolfbornCompanion = ((__instance != null) ? ((Component)__instance).GetComponent<WolfbornCompanion>() : null);
			if ((Object)(object)wolfbornCompanion != (Object)null && wolfbornCompanion.m_initialized)
			{
				__result += wolfbornCompanion.extraMaxHp;
			}
		}

		[HarmonyPatch(typeof(BaseAI), "CanSeeTarget", new Type[] { typeof(Character) })]
		[HarmonyPostfix]
		private static void IgnoreUnconsciousTarget(BaseAI __instance, Character target, ref bool __result)
		{
			WolfbornCompanion wolfbornCompanion = ((target != null) ? ((Component)target).GetComponent<WolfbornCompanion>() : null);
			if ((Object)(object)wolfbornCompanion != (Object)null && wolfbornCompanion.isUnconscious)
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch]
	public static class WolfbornSpawnManager
	{
		[HarmonyPatch(typeof(MonsterAI), "Start")]
		[HarmonyPostfix]
		private static void InterceptWolfSpawn(MonsterAI __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			Character component = ((Component)__instance).GetComponent<Character>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			ZNetView component2 = ((Component)__instance).GetComponent<ZNetView>();
			if ((Object)(object)component2 == (Object)null || !component2.IsValid() || ((Object)((Component)component).gameObject).name.Replace("(Clone)", "").Trim() != "Wolf")
			{
				return;
			}
			ZDO zDO = component2.GetZDO();
			if (zDO == null)
			{
				return;
			}
			if (zDO.GetBool(WolfbornZDOManager.Hash_IsCompanion, false))
			{
				WolfbornCompanion wolfbornCompanion = ((Component)component).GetComponent<WolfbornCompanion>();
				if ((Object)(object)wolfbornCompanion == (Object)null)
				{
					wolfbornCompanion = ((Component)component).gameObject.AddComponent<WolfbornCompanion>();
				}
				wolfbornCompanion.variantID = zDO.GetInt(WolfbornZDOManager.Hash_VariantID, 1);
				wolfbornCompanion.wolfLevel = zDO.GetInt(WolfbornZDOManager.Hash_WolfLevel, 1);
				wolfbornCompanion.ApplyVisuals();
			}
			else
			{
				if (zDO.GetBool(WolfbornZDOManager.Hash_Evaluated, false) || !component2.IsOwner())
				{
					return;
				}
				zDO.Set(WolfbornZDOManager.Hash_Evaluated, true);
				if (Random.value <= 0.2f)
				{
					int num = zDO.GetInt(StringExtensionMethods.GetStableHashCode("level"), component.GetLevel());
					int num2 = SorteiaVariante(num);
					zDO.Set(WolfbornZDOManager.Hash_IsCompanion, true);
					zDO.Set(WolfbornZDOManager.Hash_VariantID, num2, false);
					zDO.Set(WolfbornZDOManager.Hash_WolfLevel, 1, false);
					WolfbornCompanion wolfbornCompanion2 = ((Component)component).GetComponent<WolfbornCompanion>();
					if ((Object)(object)wolfbornCompanion2 == (Object)null)
					{
						wolfbornCompanion2 = ((Component)component).gameObject.AddComponent<WolfbornCompanion>();
					}
					wolfbornCompanion2.variantID = num2;
					wolfbornCompanion2.wolfLevel = 1;
					wolfbornCompanion2.ApplyVisuals();
					if (WolfbornConfig.IsDebugMode)
					{
						Logger.LogInfo((object)$"[Wolfborn] Novo Wolfborn (Variante {num2}, Nível Nativo {num}) gerado com sucesso!");
					}
				}
			}
		}

		private static int SorteiaVariante(int nativeLevel)
		{
			switch (nativeLevel)
			{
			case 2:
				if (!(Random.value > 0.5f))
				{
					return 4;
				}
				return 3;
			case 3:
				if (!(Random.value > 0.5f))
				{
					return 6;
				}
				return 5;
			default:
				if (!(Random.value > 0.5f))
				{
					return 2;
				}
				return 1;
			}
		}
	}
	public class WolfDefinition
	{
		public int ID { get; set; }

		public string Name { get; set; }

		public string PrefabName { get; set; }

		public int StarLevel { get; set; }

		public Color FurColor { get; set; }

		public float BaseScale { get; set; }

		public WolfDefinition(int id, string name, string prefabName, int starLevel, Color furColor, float baseScale)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			ID = id;
			Name = name;
			PrefabName = prefabName;
			StarLevel = starLevel;
			FurColor = furColor;
			BaseScale = baseScale;
		}
	}
	public static class WolfRegistry
	{
		public static Dictionary<int, WolfDefinition> Variants { get; private set; } = new Dictionary<int, WolfDefinition>();

		public static void Initialize()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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_0152: Unknown result type (might be due to invalid IL or missing references)
			Variants.Clear();
			Variants.Add(1, new WolfDefinition(1, "$wb_wolf_variant_1", "Wolfborn1", 0, new Color(1f, 1f, 1f, 1f), 1f));
			Variants.Add(2, new WolfDefinition(2, "$wb_wolf_variant_2", "Wolfborn2", 0, new Color(0.46f, 0.46f, 0.48f, 1f), 1f));
			Variants.Add(3, new WolfDefinition(3, "$wb_wolf_variant_3", "Wolfborn3", 1, new Color(1f, 1f, 1f, 1f), 1f));
			Variants.Add(4, new WolfDefinition(4, "$wb_wolf_variant_4", "Wolfborn4", 1, new Color(0.46f, 0.46f, 0.48f, 1f), 1f));
			Variants.Add(5, new WolfDefinition(5, "$wb_wolf_variant_5", "Wolfborn5", 2, new Color(1f, 1f, 1f, 1f), 1f));
			Variants.Add(6, new WolfDefinition(6, "$wb_wolf_variant_6", "Wolfborn6", 2, new Color(0.55f, 0.55f, 0.52f, 1f), 1f));
		}

		public static WolfDefinition GetDefinition(int id)
		{
			if (!Variants.TryGetValue(id, out var value))
			{
				return null;
			}
			return value;
		}

		public static IEnumerable<WolfDefinition> GetAllWolves()
		{
			return Variants.Values;
		}
	}
}
namespace Wolfborn.Wolves
{
	public enum WolfType
	{
		None,
		Companion_Standard_0Star,
		Companion_Gray_0Star,
		Companion_Standard_1Star,
		Companion_Gray_1Star,
		Companion_Standard_2Star,
		Companion_Gray_2Star
	}
}
namespace Wolfborn.Utils
{
	public static class WolfbornLocalizationManager
	{
		public static void LoadEmbeddedLocalizations()
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
			foreach (string text in manifestResourceNames)
			{
				if (!text.EndsWith(".json", StringComparison.OrdinalIgnoreCase))
				{
					continue;
				}
				using Stream stream = executingAssembly.GetManifestResourceStream(text);
				if (stream != null)
				{
					using StreamReader streamReader = new StreamReader(stream);
					string text2 = streamReader.ReadToEnd();
					string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text);
					string text3 = (fileNameWithoutExtension.Contains(".") ? fileNameWithoutExtension.Substring(fileNameWithoutExtension.LastIndexOf('.') + 1) : fileNameWithoutExtension);
					LocalizationManager.Instance.GetLocalization().AddJsonFile(text3, text2);
					Logger.LogInfo((object)("[Wolfborn] Embedded translation '" + text3 + "' loaded successfully!"));
				}
			}
		}
	}
	public static class WolfbornAssetManager
	{
		public static Sprite WolfIconSprite { get; private set; }

		public static void EnsureLoaded()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			if ((int)SystemInfo.graphicsDeviceType != 4 && (Object)(object)WolfIconSprite == (Object)null)
			{
				LoadCustomIcon();
			}
		}

		public static void LoadAssetBundle()
		{
			EnsureLoaded();
		}

		private static void LoadCustomIcon()
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_00c7: 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)
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string text = null;
			string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
			foreach (string text2 in manifestResourceNames)
			{
				if (text2.EndsWith("wolf_icon.png", StringComparison.OrdinalIgnoreCase))
				{
					text = text2;
					break;
				}
			}
			if (string.IsNullOrEmpty(text))
			{
				Logger.LogError((object)"[Wolfborn] O ficheiro 'wolf_icon.png' não foi encontrado nos Recursos Embutidos (Embedded Resources).");
				return;
			}
			using Stream stream = executingAssembly.GetManifestResourceStream(text);
			if (stream != null)
			{
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				if (LoadImageToTexture(val, array))
				{
					((Object)val).name = "wolf_icon_texture";
					((Texture)val).filterMode = (FilterMode)1;
					((Texture)val).wrapMode = (TextureWrapMode)1;
					WolfIconSprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
					Logger.LogInfo((object)"[Wolfborn] Ícone 'wolf_icon.png' carregado com sucesso!");
				}
				else
				{
					Logger.LogError((object)"[Wolfborn] Falha ao converter os bytes de 'wolf_icon.png' em Texture2D.");
				}
			}
		}

		private static bool LoadImageToTexture(Texture2D texture, byte[] buffer)
		{
			try
			{
				Type type = Type.GetType("UnityEngine.ImageConversion, UnityEngine.ImageConversionModule") ?? Type.GetType("UnityEngine.ImageConversion, UnityEngine");
				if (type != null)
				{
					MethodInfo method = type.GetMethod("LoadImage", new Type[2]
					{
						typeof(Texture2D),
						typeof(byte[])
					});
					if (method != null)
					{
						return (bool)method.Invoke(null, new object[2] { texture, buffer });
					}
				}
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("[Wolfborn] Erro na conversão da imagem: " + ex.Message));
			}
			return false;
		}

		public static void Unload()
		{
			if ((Object)(object)WolfIconSprite != (Object)null)
			{
				if ((Object)(object)WolfIconSprite.texture != (Object)null)
				{
					Object.Destroy((Object)(object)WolfIconSprite.texture);
				}
				Object.Destroy((Object)(object)WolfIconSprite);
				WolfIconSprite = null;
			}
		}
	}
}
namespace Wolfborn.Network
{
	[HarmonyPatch]
	public static class WolfbornRPCManager
	{
		[HarmonyPatch(typeof(Game), "Start")]
		[HarmonyPostfix]
		private static void RegisterRPCs()
		{
			if (ZRoutedRpc.instance != null)
			{
				ZRoutedRpc.instance.Register<ZDOID, Vector3>("Wolfborn_RequestTotemTeleport", (Action<long, ZDOID, Vector3>)RPC_RequestTotemTeleport);
				ZRoutedRpc.instance.Register<Vector3>("Wolfborn_TotemTeleportVFX", (Action<long, Vector3>)RPC_TotemTeleportVFX);
				ZRoutedRpc.instance.Register<ZDOID, int, float, bool>("Wolfborn_SyncCompanionStats", (Method<ZDOID, int, float, bool>)RPC_SyncCompanionStats);
				Logger.LogInfo((object)"[Wolfborn] RPCs customizados registrados com sucesso.");
			}
		}

		public static void BroadcastStatsUpdate(WolfbornCompanion companion)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)companion == (Object)null))
			{
				ZNetView component = ((Component)companion).GetComponent<ZNetView>();
				if ((Object)(object)component != (Object)null && component.IsValid() && ZRoutedRpc.instance != null)
				{
					ZRoutedRpc.instance.InvokeRoutedRPC(0L, "Wolfborn_SyncCompanionStats", new object[4]
					{
						component.GetZDO().m_uid,
						companion.wolfLevel,
						companion.currentXP,
						companion.isUnconscious
					});
				}
			}
		}

		private static void RPC_SyncCompanionStats(long sender, ZDOID companionID, int level, float xp, bool isUnconscious)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			GameObject val = ZNetScene.instance.FindInstance(companionID);
			if ((Object)(object)val != (Object)null)
			{
				WolfbornCompanion component = val.GetComponent<WolfbornCompanion>();
				if ((Object)(object)component != (Object)null)
				{
					component.wolfLevel = level;
					component.currentXP = xp;
					component.isUnconscious = isUnconscious;
					component.RecalculateStats();
					component.ApplyVisuals();
				}
			}
		}

		private static void RPC_RequestTotemTeleport(long sender, ZDOID playerID, Vector3 totemPos)
		{
			//IL_0008: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			if (ZDOMan.instance == null)
			{
				return;
			}
			Player playerByZDOID = GetPlayerByZDOID(playerID);
			int num = 0;
			float num2 = 2.5f;
			HashSet<ZDOID> hashSet = new HashSet<ZDOID>();
			Vector3 val = default(Vector3);
			foreach (WolfbornCompanion instance in WolfbornCompanion.m_instances)
			{
				if ((Object)(object)instance == (Object)null)
				{
					continue;
				}
				bool flag = false;
				if ((Object)(object)playerByZDOID != (Object)null)
				{
					flag = instance.IsFollowingPlayer(playerByZDOID);
				}
				if (flag)
				{
					num++;
					float num3 = (float)num * 45f * ((float)Math.PI / 180f);
					((Vector3)(ref val))..ctor(Mathf.Sin(num3) * num2, 0.5f, Mathf.Cos(num3) * num2);
					Vector3 position = totemPos + val;
					instance.TeleportTo(position);
					ZNetView component = ((Component)instance).GetComponent<ZNetView>();
					if ((Object)(object)component != (Object)null && component.GetZDO() != null)
					{
						hashSet.Add(component.GetZDO().m_uid);
					}
				}
			}
			Vector3 val2 = default(Vector3);
			foreach (ZDO allZDO in GetAllZDOs())
			{
				if (allZDO != null && allZDO.IsValid() && !hashSet.Contains(allZDO.m_uid) && (allZDO.GetBool("WB_IsCompanion", false) || allZDO.GetBool(WolfbornZDOManager.Hash_IsCompanion, false)))
				{
					ZDOID zDOID = allZDO.GetZDOID("WB_FollowTarget");
					if (zDOID != ZDOID.None && zDOID == playerID)
					{
						num++;
						float num4 = (float)num * 45f * ((float)Math.PI / 180f);
						((Vector3)(ref val2))..ctor(Mathf.Sin(num4) * num2, 0.5f, Mathf.Cos(num4) * num2);
						Vector3 position2 = totemPos + val2;
						allZDO.SetPosition(position2);
						hashSet.Add(allZDO.m_uid);
					}
				}
			}
			if ((Object)(object)playerByZDOID != (Object)null)
			{
				if (num > 0)
				{
					((Character)playerByZDOID).Message((MessageType)2, "$wb_msg_teleport_success", 0, (Sprite)null, false);
					ZRoutedRpc.instance.InvokeRoutedRPC(0L, "Wolfborn_TotemTeleportVFX", new object[1] { totemPos });
				}
				else
				{
					((Character)playerByZDOID).Message((MessageType)2, "$wb_msg_no_followers", 0, (Sprite)null, false);
				}
			}
		}

		private static Player GetPlayerByZDOID(ZDOID id)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (id == ZDOID.None)
			{
				return null;
			}
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				if ((Object)(object)allPlayer != (Object)null && ((Character)allPlayer).GetZDOID() == id)
				{
					return allPlayer;
				}
			}
			return null;
		}

		private static IEnumerable<ZDO> GetAllZDOs()
		{
			if (ZDOMan.instance == null || !(typeof(ZDOMan).GetField("m_objectsByID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(ZDOMan.instance) is IDictionary dictionary))
			{
				yield break;
			}
			foreach (DictionaryEntry item in dictionary)
			{
				object? value = item.Value;
				ZDO val = (ZDO)((value is ZDO) ? value : null);
				if (val != null)
				{
					yield return val;
				}
			}
		}

		private static void RPC_TotemTeleportVFX(long sender, Vector3 position)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = ZNetScene.instance.GetPrefab("vfx_create_tamed_animal");
			if ((Object)(object)prefab != (Object)null)
			{
				Object.Instantiate<GameObject>(prefab, position, Quaternion.identity);
			}
		}
	}
}
namespace Wolfborn.Configuration
{
	public static class WolfbornConfig
	{
		public static ConfigEntry<bool> ModEnabled { get; private set; }

		public static ConfigEntry<bool> DebugMode { get; private set; }

		public static bool IsModEnabled
		{
			get
			{
				if (ModEnabled != null)
				{
					return ModEnabled.Value;
				}
				return false;
			}
		}

		public static bool IsDebugMode
		{
			get
			{
				if (DebugMode != null)
				{
					return DebugMode.Value;
				}
				return false;
			}
		}

		public static void Init(ConfigFile config)
		{
			//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_0027: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			ModEnabled = config.Bind<bool>("1 - General", "EnableMod", true, new ConfigDescription("$wb_config_mod_enabled_desc", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			DebugMode = config.Bind<bool>("1 - General", "EnableDebug", false, new ConfigDescription("$wb_config_debug_mode_desc", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
		}
	}
}