Decompiled source of RagnarokValheim v0.13.0

plugins/RagnarokValheim.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using RagnarokValheim.Content;
using RagnarokValheim.Core;
using RagnarokValheim.Data;
using RagnarokValheim.Patches;
using RagnarokValheim.UI;
using Splatform;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace RagnarokValheim
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("ragheim.ragnarokvalheim", "RagnarokValheim", "0.13.0")]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "ragheim.ragnarokvalheim";

		public const string ModName = "RagnarokValheim";

		public const string Version = "0.13.0";

		public static Plugin Instance;

		public static ManualLogSource Log;

		private Harmony _harmony;

		private void Awake()
		{
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			RoConfig.Bind(((BaseUnityPlugin)this).Config);
			PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailable;
			Commands.Register();
			((Component)this).gameObject.AddComponent<RoGui>();
			((Component)this).gameObject.AddComponent<RoHud>();
			((Component)this).gameObject.AddComponent<DungeonSystem>();
			((Component)this).gameObject.AddComponent<QualityOfLife>();
			((Component)this).gameObject.AddComponent<PartyHud>();
			((Component)this).gameObject.AddComponent<WorldEvents>();
			((Component)this).gameObject.AddComponent<CampSystem>();
			((Component)this).gameObject.AddComponent<Marker>();
			((Component)this).gameObject.AddComponent<SongAura>();
			((Component)this).gameObject.AddComponent<RefineGlow>();
			((Component)this).gameObject.AddComponent<RewardGui>();
			((Component)this).gameObject.AddComponent<MapCoords>();
			((Component)this).gameObject.AddComponent<Measure>();
			((Component)this).gameObject.AddComponent<RoTicker>();
			_harmony = new Harmony("ragheim.ragnarokvalheim");
			_harmony.PatchAll(typeof(Plugin).Assembly);
			Log.LogInfo((object)"RagnarokValheim 0.13.0 carregado.");
		}

		private void OnVanillaPrefabsAvailable()
		{
			RoItems.Register();
			CardItems.Register();
			Stations.Register();
			SkillStatusEffects.Register();
			EquipItems.Register();
			try
			{
				Log.LogInfo((object)("Wiki do mod salva em: " + WikiExport.Export()));
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Não foi possível salvar a wiki: " + ex.Message));
			}
			PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsAvailable;
		}

		private void OnDestroy()
		{
			if (_harmony != null)
			{
				_harmony.UnpatchSelf();
			}
		}
	}
	public static class RoConfig
	{
		public static ConfigEntry<float> ExpPerHp;

		public static ConfigEntry<float> BossExpMultiplier;

		public static ConfigEntry<float> JobExpRatio;

		public static ConfigEntry<float> ExpRate;

		public static ConfigEntry<float> ShareRange;

		public static ConfigEntry<float> ExpCurveMultiplier;

		public static ConfigEntry<float> ZenyPerExp;

		public static ConfigEntry<float> ZenyRate;

		public static ConfigEntry<bool> ConvertCoins;

		public static ConfigEntry<float> HpPerLevel;

		public static ConfigEntry<float> SpBase;

		public static ConfigEntry<float> SpPerLevel;

		public static ConfigEntry<float> SpPerInt;

		public static ConfigEntry<float> HpRegenPerSec;

		public static ConfigEntry<float> SpRegenPerSec;

		public static ConfigEntry<float> SpRegenPerInt;

		public static ConfigEntry<float> RegenDelay;

		public static ConfigEntry<float> OffenseStatScale;

		public static ConfigEntry<float> DefenseStatScale;

		public static ConfigEntry<float> MaxFlee;

		public static ConfigEntry<float> MaxVitReduction;

		public static ConfigEntry<float> CritMultiplier;

		public static ConfigEntry<float> AspdPerAgi;

		public static ConfigEntry<float> DrawPerAgi;

		public static ConfigEntry<float> MaxAttackSpeed;

		public static ConfigEntry<float> MaxDrawSpeed;

		public static ConfigEntry<float> CardDropChance;

		public static ConfigEntry<float> MvpCardDropChance;

		public static ConfigEntry<float> CardRemovalCostMultiplier;

		public static ConfigEntry<int> WeaponSecondSlotQuality;

		public static ConfigEntry<float> RefineMaterialDropChance;

		public static ConfigEntry<int> RefineZenyBase;

		public static ConfigEntry<string> RefineSuccessRates;

		public static ConfigEntry<float> SupportRange;

		public static ConfigEntry<float> GroupRange;

		public static ConfigEntry<float> GroupHpPerPlayer;

		public static ConfigEntry<float> GroupDmgPerPlayer;

		public static ConfigEntry<float> BossHpPerPlayer;

		public static ConfigEntry<float> PartyExpBonus;

		public static ConfigEntry<bool> ShowPartyHud;

		public static ConfigEntry<string> Difficulty;

		public static ConfigEntry<float> EliteChance;

		public static ConfigEntry<bool> WanderingMvpEnabled;

		public static ConfigEntry<float> WanderingMvpMinutes;

		public static ConfigEntry<float> WanderingMvpDurationMinutes;

		public static ConfigEntry<bool> InvasionsEnabled;

		public static ConfigEntry<float> InvasionChance;

		public static ConfigEntry<float> RiftMinutes;

		public static ConfigEntry<float> RaidCooldownMinutes;

		public static ConfigEntry<string> DungeonCooldowns;

		public static ConfigEntry<float> FoodStartHp;

		public static ConfigEntry<float> FoodStartStamina;

		public static ConfigEntry<float> FoodOtherBiomesFactor;

		public static ConfigEntry<float> FoodInstantRestore;

		public static ConfigEntry<float> FoodEatCooldown;

		public static ConfigEntry<string> FoodExtraAllowed;

		public static ConfigEntry<bool> FreeTeleport;

		public static ConfigEntry<float> KafraTeleportCostPer20m;

		public static ConfigEntry<float> BloodMoonChance;

		public static ConfigEntry<bool> CampsEnabled;

		public static ConfigEntry<KeyboardShortcut> MarkerKey;

		public static ConfigEntry<KeyboardShortcut> HotbarPageKey;

		public static ConfigEntry<bool> ShowQuestTracker;

		public static ConfigEntry<bool> DirectLoot;

		public static ConfigEntry<bool> MapCoords;

		public static ConfigEntry<bool> SplitZeny;

		public static ConfigEntry<bool> CastTimes;

		public static ConfigEntry<float> StackMultiplier;

		public static ConfigEntry<float> CarryWeightMultiplier;

		public static ConfigEntry<float> EquipDropMultiplier;

		public static ConfigEntry<float> DungeonCooldownMinutes;

		public static ConfigEntry<int> DungeonWaveSize;

		public static ConfigEntry<string> BiomeScaling;

		public static ConfigEntry<float> BossHpMultiplier;

		public static ConfigEntry<float> SkillSpCostMultiplier;

		public static ConfigEntry<KeyboardShortcut>[] SkillKeys = new ConfigEntry<KeyboardShortcut>[8];

		public static ConfigEntry<KeyboardShortcut> StatusKey;

		public static ConfigEntry<bool> ShowHud;

		public static ConfigEntry<float> UiScale;

		public static ConfigEntry<float> HudOffsetY;

		public static ConfigEntry<KeyboardShortcut> LightKey;

		public static ConfigEntry<float> LightRange;

		public static ConfigEntry<float> LightIntensity;

		public static ConfigEntry<bool> ShowEnemiesOnMap;

		public static ConfigEntry<float> EnemyMapRange;

		public static ConfigEntry<bool> HarvestToInventory;

		private static int _osFrame = -1;

		private static readonly bool[] _osDown = new bool[5];

		private static readonly bool[] _osPressed = new bool[5];

		private static readonly bool[] _diagDown = new bool[256];

		private static int[] _ratesCache;

		private static string _ratesSrc;

		public static void Bind(ConfigFile cfg)
		{
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0925: Unknown result type (might be due to invalid IL or missing references)
			//IL_094f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a95: Unknown result type (might be due to invalid IL or missing references)
			ExpPerHp = S(cfg, "1 - Experiência", "ExpPorHP", 0.5f, "EXP de base por ponto de HP máximo do monstro.");
			BossExpMultiplier = S(cfg, "1 - Experiência", "MultiplicadorChefe", 5f, "Multiplicador de EXP de chefes.");
			JobExpRatio = S(cfg, "1 - Experiência", "ProporcaoExpClasse", 0.75f, "EXP de classe = EXP de base × este valor.");
			ExpRate = S(cfg, "1 - Experiência", "Rate", 1f, "Rate geral de EXP (como servidores de RO).");
			ShareRange = S(cfg, "1 - Experiência", "AlcanceGrupo", 60f, "Distância (m) para receber EXP/zeny de abates de outros jogadores.");
			ExpCurveMultiplier = S(cfg, "1 - Experiência", "MultiplicadorCurva", 1f, "Multiplica a EXP necessária por nível.");
			ZenyPerExp = S(cfg, "2 - Zeny", "ZenyPorExp", 0.4f, "Zeny por abate = EXP de base × este valor (±20%).");
			ZenyRate = S(cfg, "2 - Zeny", "Rate", 1f, "Rate geral de zeny.");
			ConvertCoins = S(cfg, "2 - Zeny", "ConverterOuro", value: true, "Converte moedas de ouro do Valheim em zeny (1:1).");
			HpPerLevel = S(cfg, "3 - Atributos", "HPPorNivel", 0.7f, "HP extra = nível × fator da classe × este valor × (1 + VIT/100).");
			SpBase = S(cfg, "3 - Atributos", "SPBaseV2", 10f, "SP base de todo personagem (como no RO).");
			SpPerLevel = S(cfg, "3 - Atributos", "SPPorNivelV2", 5f, "SP = (base + nível × fator da classe × este valor) × (1 + INT/100).");
			SpPerInt = S(cfg, "3 - Atributos", "SPPorINTV2", 0f, "SP fixo extra por ponto de INT.");
			HpRegenPerSec = S(cfg, "3 - Atributos", "RegenHPPorSegundoV3", 0.003f, "Regeneração natural de HP por segundo, em fração do HP máximo (0.003 = 0,3%), + VIT × 0,05.");
			SpRegenPerSec = S(cfg, "3 - Atributos", "RegenSPPorSegundoV3", 0.004f, "Regeneração natural de SP por segundo, em fração do SP máximo (0.004 = 0,4%), + INT × RegenSPPorINT.");
			SpRegenPerInt = S(cfg, "3 - Atributos", "RegenSPPorINT", 0.025f, "SP regenerado por segundo para cada ponto de INT.");
			RegenDelay = S(cfg, "3 - Atributos", "AtrasoRegen", 3f, "Segundos sem levar dano (HP) ou sem gastar SP (SP) para a regeneração natural voltar.");
			OffenseStatScale = S(cfg, "3 - Atributos", "EscalaOfensiva", 1f, "Multiplica todos os bônus de dano vindos de atributos.");
			DefenseStatScale = S(cfg, "3 - Atributos", "EscalaDefensiva", 1f, "Multiplica esquiva e redução de dano vindas de atributos.");
			MaxFlee = S(cfg, "3 - Atributos", "EsquivaMaxima", 0.4f, "Chance máxima de esquiva (0-1).");
			MaxVitReduction = S(cfg, "3 - Atributos", "ReducaoVITMaxima", 0.35f, "Redução de dano máxima por VIT (0-1).");
			CritMultiplier = S(cfg, "3 - Atributos", "MultiplicadorCritico", 1.4f, "Multiplicador de dano crítico.");
			AspdPerAgi = S(cfg, "3 - Atributos", "VelocidadeAtaquePorAGI", 0.25f, "% de velocidade de ataque por ponto de AGI (99 AGI = +25%).");
			DrawPerAgi = S(cfg, "3 - Atributos", "VelocidadeArcoPorAGI", 0.4f, "% de velocidade para puxar o arco por ponto de AGI (99 AGI = +40%).");
			MaxAttackSpeed = S(cfg, "3 - Atributos", "VelocidadeAtaqueMaxima", 1.6f, "Velocidade de ataque máxima (1.6 = +60%), somando AGI, habilidades e equipamentos.");
			MaxDrawSpeed = S(cfg, "3 - Atributos", "VelocidadeArcoMaxima", 1.8f, "Velocidade máxima para puxar o arco (1.8 = +80%).");
			CardDropChance = S(cfg, "4 - Cartas", "ChanceCarta", 0.005f, "Chance de carta por abate (0.005 = 0,5%).");
			MvpCardDropChance = S(cfg, "4 - Cartas", "ChanceCartaMVP", 0.25f, "Chance de carta de chefe.");
			CardRemovalCostMultiplier = S(cfg, "4 - Cartas", "CustoRemocao", 1f, "Multiplicador do custo em zeny para remover cartas.");
			WeaponSecondSlotQuality = S(cfg, "4 - Cartas", "QualidadeSegundoSlot", 3, "Qualidade mínima de arma para o 2º slot.");
			RefineMaterialDropChance = S(cfg, "5 - Refino", "ChanceMaterial", 0.02f, "Chance de Oridecon/Elunium por abate.");
			RefineZenyBase = S(cfg, "5 - Refino", "ZenyBase", 500, "Zeny por tentativa = base × (nível alvo + 1).");
			RefineSuccessRates = S(cfg, "5 - Refino", "Chances", "100,100,100,100,90,80,60,40,25,15", "Chance (%) para +1 ... +10.");
			StatusKey = cfg.Bind<KeyboardShortcut>("6 - Interface", "TeclaStatus", new KeyboardShortcut((KeyCode)107, (KeyCode[])(object)new KeyCode[0]), "Abre o inventário direto na aba Ragnarok.");
			ShowHud = cfg.Bind<bool>("6 - Interface", "MostrarHUD", true, "Mostra classe, níveis, EXP, zeny e a barra de habilidades na parte de baixo da tela.");
			UiScale = cfg.Bind<float>("6 - Interface", "Escala", 1f, "Escala do HUD do mod.");
			HudOffsetY = cfg.Bind<float>("6 - Interface", "AlturaHUD", 12f, "Distância do HUD até a borda de baixo da tela (pixels em 1080p).");
			LightKey = cfg.Bind<KeyboardShortcut>("10 - Conveniências", "TeclaLuz", new KeyboardShortcut((KeyCode)113, (KeyCode[])(object)new KeyCode[0]), "Liga/desliga a luz ao redor do personagem (os amigos também veem).");
			LightRange = cfg.Bind<float>("10 - Conveniências", "AlcanceLuz", 16f, "Alcance da luz em metros.");
			LightIntensity = cfg.Bind<float>("10 - Conveniências", "IntensidadeLuz", 1.4f, "Intensidade da luz.");
			ShowEnemiesOnMap = cfg.Bind<bool>("10 - Conveniências", "InimigosNoMapa", true, "Mostra no mapa e no minimapa, em tempo real, os inimigos próximos.");
			EnemyMapRange = cfg.Bind<float>("10 - Conveniências", "AlcanceInimigosNoMapa", 70f, "Distância (m) dos inimigos mostrados no mapa.");
			HarvestToInventory = cfg.Bind<bool>("10 - Conveniências", "ColetaDiretoNoInventario", true, "Itens colhidos (frutas, cogumelos, pedras, galhos...) vão direto ao inventário; se estiver cheio, caem no chão.");
			BiomeScaling = S(cfg, "8 - Inimigos", "MultiplicadoresPorBiomaV2", "Meadows=1.0/1.0,BlackForest=1.4/1.15,Swamp=1.75/1.3,Mountain=2.1/1.45,Ocean=1.75/1.3,Plains=2.5/1.6,Mistlands=3.0/1.75,AshLands=3.5/2.0,DeepNorth=3.5/2.0", "HP/dano dos inimigos por bioma (compensa a força extra dos personagens RO; ver BALANCE.md). Use 1.0/1.0 para desligar.");
			BossHpMultiplier = S(cfg, "8 - Inimigos", "MultiplicadorHPChefesV2", 1.25f, "HP extra dos chefes (aplicado por cima do bioma).");
			SupportRange = S(cfg, "12 - Grupo", "AlcanceSuporte", 15f, "Alcance (m) das curas, buffs e canções de grupo.");
			GroupRange = S(cfg, "12 - Grupo", "AlcanceGrupoInimigos", 60f, "Jogadores a até esta distância contam para o reforço dos inimigos.");
			GroupHpPerPlayer = S(cfg, "12 - Grupo", "HPInimigoPorJogador", 0.15f, "HP extra dos inimigos comuns por jogador além do primeiro (0.15 = +15%).");
			GroupDmgPerPlayer = S(cfg, "12 - Grupo", "DanoInimigoPorJogador", 0.1f, "Dano extra dos inimigos por jogador além do primeiro (0.10 = +10%).");
			BossHpPerPlayer = S(cfg, "12 - Grupo", "HPChefeMVPPorJogador", 0.5f, "HP extra de chefes e MVPs de masmorra por jogador além do primeiro (0.5 = +50%).");
			CastTimes = S(cfg, "7 - Habilidades", "TempoDeConjuracao", value: true, "Magias fortes (Nevasca, Meteoros, Magnus, Judex, Cometa...) têm uma conjuração curta antes de sair (1,2 s, menos com DEX).");
			SplitZeny = S(cfg, "12 - Grupo", "DividirZenyGrupo", value: true, "O zeny dos abates é dividido entre o grupo como a EXP (com o mesmo bônus por membro). Desligado: cada um recebe o valor inteiro.");
			PartyExpBonus = S(cfg, "12 - Grupo", "BonusEXPGrupo", 0.2f, "A EXP é dividida entre o grupo, com +20% por membro extra (3 jogadores: cada um recebe ~47%).");
			ShowPartyHud = cfg.Bind<bool>("12 - Grupo", "MostrarGrupo", true, "Mostra HP e SP dos outros jogadores próximos na tela.");
			Difficulty = S(cfg, "13 - Mundo", "Dificuldade", "Normal", "Normal, Pesadelo ou Valhalla. Pesadelo: inimigos +50% HP/+30% dano, +30% EXP. Valhalla: +120% HP/+60% dano, +60% EXP.");
			EliteChance = S(cfg, "13 - Mundo", "ChanceElite", 0.03f, "Chance de um monstro comum nascer Elite (0.03 = 3%), multiplicada pela dificuldade.");
			WanderingMvpEnabled = S(cfg, "13 - Mundo", "MVPsErrantes", value: true, "MVPs que aparecem de vez em quando no bioma de um jogador, avisados para todos e marcados no mapa.");
			WanderingMvpMinutes = S(cfg, "13 - Mundo", "IntervaloMVPErranteMinutos", 40f, "Tempo médio (min) entre MVPs errantes.");
			WanderingMvpDurationMinutes = S(cfg, "13 - Mundo", "DuracaoMVPErranteMinutos", 20f, "Minutos até o MVP errante ir embora se ninguém derrotá-lo.");
			InvasionsEnabled = S(cfg, "13 - Mundo", "InvasoesNoturnas", value: true, "Ondas de mortos-vivos atacam as bases à noite (depois do Eikthyr).");
			InvasionChance = S(cfg, "13 - Mundo", "ChanceInvasao", 0.3f, "Chance de invasão a cada noite (0.3 = 30%), para cada jogador que estiver em uma base.");
			RiftMinutes = S(cfg, "13 - Mundo", "TempoFendaMinutos", 10f, "Duração da Fenda do Tempo (min).");
			RaidCooldownMinutes = S(cfg, "13 - Mundo", "RecargaRaideMinutos", 60f, "Minutos até poder repetir a raide (por jogador).");
			DungeonCooldowns = S(cfg, "9 - Masmorras e equipamentos", "RecargaPorMasmorra", "meadows=10,blackforest=10,swamp=10,mountain=10,plains=10,mistlands=10,ashlands=10,sewer=10,glacial=10,guild=10,cathedral=10,theater=10,raid=60,rift=10", "Minutos de recarga de cada masmorra (por jogador). Ids: meadows, blackforest, swamp, mountain, plains, mistlands, ashlands, sewer, glacial, guild, cathedral, theater, raid; rift = Fendas do Tempo. A Torre não tem recarga. Masmorra fora da lista usa RecargaMasmorraMinutos.");
			FoodStartHp = S(cfg, "14 - Comida", "HPInicial", 20f, "HP fixo que todo personagem tem (substitui a comida simples do começo).");
			FoodStartStamina = S(cfg, "14 - Comida", "StaminaInicial", 20f, "Stamina fixa que todo personagem tem.");
			FoodOtherBiomesFactor = S(cfg, "14 - Comida", "FatorOutrosBiomas", 0.1f, "O bioma com mais alimentos provados conta inteiro; os outros somam esta fração (0.1 = 10%).");
			FoodInstantRestore = S(cfg, "14 - Comida", "RecuperacaoAoComer", 0.3f, "Ao comer, recupera esta fração do HP e da stamina do alimento na hora (o SP recupera metade disso).");
			FoodEatCooldown = S(cfg, "14 - Comida", "RecargaComerSegundos", 10f, "Segundos entre uma comida e outra.");
			FreeTeleport = S(cfg, "15 - Aventura", "TeleporteSemLimite", value: true, "Portais, Asa de Borboleta, Ressuscitar e Kafra levam qualquer item (minério, metais...).");
			KafraTeleportCostPer20m = S(cfg, "15 - Aventura", "CustoTeleporteKafra", 1f, "Zeny por cada 20 m de distância no teleporte da Kafra (além de 100z fixos).");
			BloodMoonChance = S(cfg, "15 - Aventura", "ChanceLuaDeSangue", 0.12f, "Chance de cada noite ser uma Lua de Sangue (depois do Eikthyr).");
			CampsEnabled = S(cfg, "15 - Aventura", "AcampamentosInimigos", value: true, "Acampamentos inimigos conquistáveis (2 por bioma).");
			DirectLoot = S(cfg, "10 - Conveniências", "SaqueDiretoNoInventario", value: true, "Itens de monstros mortos por um jogador vão direto para o inventário dele (o que não couber cai aos pés).");
			MapCoords = cfg.Bind<bool>("10 - Conveniências", "CoordenadasNoMapa", true, "No mapa grande, mostra a coordenada, o bioma e a distância do ponto sob o cursor.");
			ShowQuestTracker = cfg.Bind<bool>("10 - Conveniências", "MostrarMissoes", true, "Mostra as missões do dia e a missão de classe no canto direito da tela.");
			HotbarPageKey = cfg.Bind<KeyboardShortcut>("7 - Habilidades", "TrocarPaginaBarra", new KeyboardShortcut((KeyCode)122, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Alterna entre as 2 páginas da barra de habilidades.");
			MarkerKey = cfg.Bind<KeyboardShortcut>("15 - Aventura", "TeclaMarcador", new KeyboardShortcut((KeyCode)325, (KeyCode[])(object)new KeyCode[0]), "Marca o ponto (ou o inimigo) para onde você está olhando, no mapa e na tela dos amigos.");
			FoodExtraAllowed = S(cfg, "14 - Comida", "AlimentosDeOutrosMods", "", "Prefabs de alimentos de outros mods aceitos na coleção, separados por vírgula (só depois de validar). Os não listados ficam fora.");
			StackMultiplier = S(cfg, "11 - Inventário", "MultiplicadorPilha", 5f, "Multiplica a quantidade máxima por slot de itens empilháveis (aplica ao abrir o jogo).");
			CarryWeightMultiplier = S(cfg, "11 - Inventário", "MultiplicadorPeso", 5f, "Multiplica o peso máximo que o personagem carrega (inclui bônus de STR, habilidades e Megingjord).");
			StackMultiplier.SettingChanged += delegate
			{
				if ((Object)(object)ObjectDB.instance != (Object)null)
				{
					StackPatches.Apply(ObjectDB.instance);
				}
			};
			EquipDropMultiplier = S(cfg, "9 - Masmorras e equipamentos", "MultiplicadorDropEquipamento", 1f, "Multiplica a chance de equipamentos únicos de monstros.");
			DungeonCooldownMinutes = S(cfg, "9 - Masmorras e equipamentos", "RecargaMasmorraMinutos", 10f, "Minutos até poder repetir uma masmorra (por jogador).");
			DungeonWaveSize = S(cfg, "9 - Masmorras e equipamentos", "MonstrosPorOnda", 4, "Monstros por onda (+2 por jogador extra perto do portal).");
			SkillSpCostMultiplier = S(cfg, "7 - Habilidades", "MultiplicadorCustoSP", 1f, "Multiplica o custo de SP de todas as habilidades.");
			for (int num = 0; num < 8; num++)
			{
				SkillKeys[num] = cfg.Bind<KeyboardShortcut>("7 - Habilidades", "Atalho" + (num + 1), new KeyboardShortcut((KeyCode)(49 + num), (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), "Tecla do slot " + (num + 1) + " da barra de habilidades. Enquanto Alt estiver segurado, os números não usam a barra de itens.");
			}
		}

		private static ConfigEntry<T> S<T>(ConfigFile cfg, string section, string key, T value, string desc)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			string text = desc + " [servidor]";
			object[] array = new object[1];
			ConfigurationManagerAttributes val = new ConfigurationManagerAttributes();
			val.IsAdminOnly = true;
			array[0] = val;
			return cfg.Bind<T>(section, key, value, new ConfigDescription(text, (AcceptableValueBase)null, array));
		}

		public static bool KeyDown(KeyboardShortcut k)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			if ((int)((KeyboardShortcut)(ref k)).MainKey == 0 || !Pressed(((KeyboardShortcut)(ref k)).MainKey))
			{
				return false;
			}
			foreach (KeyCode modifier in ((KeyboardShortcut)(ref k)).Modifiers)
			{
				if (!Input.GetKey(modifier))
				{
					return false;
				}
			}
			return true;
		}

		[DllImport("user32.dll")]
		private static extern short GetAsyncKeyState(int vKey);

		private static void UpdateOsButtons()
		{
			if (_osFrame == Time.frameCount)
			{
				return;
			}
			_osFrame = Time.frameCount;
			int[] array = new int[5] { 4, 5, 6, 166, 167 };
			for (int i = 0; i < 5; i++)
			{
				bool flag = false;
				try
				{
					flag = (GetAsyncKeyState(array[i]) & 0x8000) != 0;
				}
				catch (Exception)
				{
				}
				_osPressed[i] = flag && !_osDown[i];
				_osDown[i] = flag;
			}
		}

		public static void PollMouse()
		{
			UpdateOsButtons();
		}

		public static void LogOsKeys()
		{
			for (int i = 1; i < 255; i++)
			{
				bool flag = false;
				try
				{
					flag = (GetAsyncKeyState(i) & 0x8000) != 0;
				}
				catch (Exception)
				{
					break;
				}
				if (flag && !_diagDown[i])
				{
					Plugin.Log.LogInfo((object)("Windows recebeu o código 0x" + i.ToString("X2")));
				}
				_diagDown[i] = flag;
			}
		}

		public static bool Pressed(KeyCode k)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Invalid comparison between Unknown and I4
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Invalid comparison between Unknown and I4
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Invalid comparison between Unknown and I4
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Invalid comparison between Unknown and I4
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Invalid comparison between Unknown and I4
			if ((int)k >= 325 && (int)k <= 327)
			{
				UpdateOsButtons();
				if (Application.isFocused && _osPressed[k - 325])
				{
					return true;
				}
				if (Application.isFocused && (int)k == 326 && _osPressed[3])
				{
					return true;
				}
				if (Application.isFocused && (int)k == 327 && _osPressed[4])
				{
					return true;
				}
				try
				{
					Mouse current = Mouse.current;
					if (current != null)
					{
						if ((int)k == 325 && current.middleButton.wasPressedThisFrame)
						{
							return true;
						}
						if ((int)k == 326 && current.backButton.wasPressedThisFrame)
						{
							return true;
						}
						if ((int)k == 327 && current.forwardButton.wasPressedThisFrame)
						{
							return true;
						}
					}
				}
				catch (Exception)
				{
				}
			}
			try
			{
				return Input.GetKeyDown(k);
			}
			catch (Exception)
			{
				return false;
			}
		}

		public static string ShortName(KeyboardShortcut k)
		{
			//IL_0016: 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)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_009b: 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_003f: Invalid comparison between Unknown and I4
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Invalid comparison between Unknown and I4
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Invalid comparison between Unknown and I4
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Invalid comparison between Unknown and I4
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string>();
			foreach (KeyCode modifier in ((KeyboardShortcut)(ref k)).Modifiers)
			{
				if ((int)modifier == 308 || (int)modifier == 307)
				{
					list.Add("Alt");
				}
				else if ((int)modifier == 306 || (int)modifier == 305)
				{
					list.Add("Ctrl");
				}
				else if ((int)modifier == 304 || (int)modifier == 303)
				{
					list.Add("Shift");
				}
				else
				{
					list.Add(((object)modifier).ToString());
				}
			}
			list.Add(KeyName(((KeyboardShortcut)(ref k)).MainKey));
			return string.Join("+", list.ToArray());
		}

		public static string KeyName(KeyCode k)
		{
			//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_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0004: Invalid comparison between Unknown and I4
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected I4, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			if ((int)k != 0)
			{
				switch (k - 325)
				{
				case 0:
					return "M3";
				case 1:
					return "M4";
				case 2:
					return "M5";
				case 3:
					return "M6";
				case 4:
					return "M7";
				default:
				{
					string text = ((object)k).ToString();
					if (text.StartsWith("Alpha"))
					{
						return text.Substring(5);
					}
					if (text.StartsWith("Keypad"))
					{
						return "Num" + text.Substring(6);
					}
					return text;
				}
				}
			}
			return "—";
		}

		public static int[] GetRefineRates()
		{
			string value = RefineSuccessRates.Value;
			if (_ratesCache != null && _ratesSrc == value)
			{
				return _ratesCache;
			}
			string[] array = value.Split(',');
			int[] array2 = new int[10];
			for (int i = 0; i < 10; i++)
			{
				int result = 100;
				if (i < array.Length)
				{
					int.TryParse(array[i].Trim(), out result);
				}
				array2[i] = Mathf.Clamp(result, 0, 100);
			}
			_ratesCache = array2;
			_ratesSrc = value;
			return array2;
		}
	}
}
namespace RagnarokValheim.Content
{
	public static class CardItems
	{
		private const string BasePrefab = "Ruby";

		public static void Register()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			foreach (CardDef item in Cards.All)
			{
				string itemName = item.ItemName;
				ItemConfig val = new ItemConfig();
				val.Name = (item.Mvp ? "Carta MVP " : "Carta ") + item.Display;
				val.Description = "Carta de " + item.Display + ".";
				CustomItem val2 = new CustomItem(itemName, "Ruby", val);
				if (!((Object)(object)val2.ItemDrop == (Object)null))
				{
					SharedData shared = val2.ItemDrop.m_itemData.m_shared;
					shared.m_itemType = (ItemType)1;
					shared.m_maxStackSize = 20;
					shared.m_weight = 0.1f;
					shared.m_value = 0;
					shared.m_teleportable = true;
					GameObject prefab = Cache.GetPrefab<GameObject>(item.Trophy);
					ItemDrop val3 = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<ItemDrop>() : null);
					if ((Object)(object)val3 != (Object)null && val3.m_itemData.m_shared.m_icons != null && val3.m_itemData.m_shared.m_icons.Length > 0)
					{
						shared.m_icons = (Sprite[])(object)new Sprite[1] { val3.m_itemData.m_shared.m_icons[0] };
					}
					ItemManager.Instance.AddItem(val2);
					num++;
				}
			}
			Plugin.Log.LogInfo((object)("Cartas registradas: " + num + "/" + Cards.All.Count));
		}
	}
	public static class EquipItems
	{
		public static void Register()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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)
			int num = 0;
			foreach (EquipDef item in Equipment.All)
			{
				string id = item.Id;
				string text = item.Base;
				ItemConfig val = new ItemConfig();
				val.Name = item.Name;
				val.Description = "Equipamento especial. " + item.Source + ".";
				CustomItem val2 = new CustomItem(id, text, val);
				if ((Object)(object)val2.ItemDrop == (Object)null)
				{
					Plugin.Log.LogWarning((object)("Equipamento sem base (" + item.Base + "): " + item.Id));
					continue;
				}
				SharedData shared = val2.ItemDrop.m_itemData.m_shared;
				shared.m_useDurability = false;
				shared.m_maxQuality = 1;
				shared.m_value = 0;
				if (item.StatMult != 1f)
				{
					shared.m_armor *= item.StatMult;
					shared.m_blockPower *= item.StatMult;
					DamageTypes damages = shared.m_damages;
					((DamageTypes)(ref damages)).Modify(item.StatMult);
					shared.m_damages = damages;
				}
				if (item.Base == "BeltStrength")
				{
					shared.m_equipStatusEffect = null;
				}
				ItemManager.Instance.AddItem(val2);
				num++;
			}
			Plugin.Log.LogInfo((object)("Equipamentos especiais registrados: " + num + "/" + Equipment.All.Count));
		}
	}
	public static class RoItems
	{
		public const string Oridecon = "RO_Oridecon";

		public const string Elunium = "RO_Elunium";

		public const string RedPotion = "RO_RedPotion";

		public const string OrangePotion = "RO_OrangePotion";

		public const string YellowPotion = "RO_YellowPotion";

		public const string WhitePotion = "RO_WhitePotion";

		public const string BluePotion = "RO_BluePotion";

		public const string ButterflyWing = "RO_ButterflyWing";

		public const string BattleManual = "RO_BattleManual";

		public const string YggLeaf = "RO_YggLeaf";

		public const string YggSeed = "RO_YggSeed";

		public const string BlueGem = "RO_BlueGem";

		public const string TreasureMap = "RO_TreasureMap";

		public static readonly string[] Feasts = new string[3] { "RO_FeastSmall", "RO_FeastHunter", "RO_FeastRoyal" };

		public static void Register()
		{
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Expected O, but got Unknown
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Expected O, but got Unknown
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Expected O, but got Unknown
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Expected O, but got Unknown
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Expected O, but got Unknown
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Expected O, but got Unknown
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Expected O, but got Unknown
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Expected O, but got Unknown
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Expected O, but got Unknown
			Material("RO_Oridecon", "Iron", "Oridecon", "Metal raro usado para refinar armas no Refinador.");
			Material("RO_Elunium", "Crystal", "Elunium", "Cristal raro usado para refinar armaduras, escudos, elmos, capas e calçados.");
			Potion("RO_RedPotion", "MeadHealthMinor", "Poção Vermelha", 40f, 0f);
			Potion("RO_OrangePotion", "MeadHealthMedium", "Poção Laranja", 90f, 0f);
			Potion("RO_YellowPotion", "MeadHealthMajor", "Poção Amarela", 160f, 0f);
			Potion("RO_WhitePotion", "MeadHealthLingering", "Poção Branca", 260f, 0f);
			Potion("RO_BluePotion", "MeadEitrMinor", "Poção Azul", 0f, 60f);
			Special("RO_ButterflyWing", "MeadStaminaMinor", "Feathers", "Asa de Borboleta", "Leva você instantaneamente até a sua cama (ponto de renascimento). Não funciona carregando minério ou outros itens que não podem passar por portais.");
			Special("RO_BattleManual", "MeadTasty", "AmberPearl", "Manual de Combate", "+50% de EXP de base e de classe por 30 minutos.");
			Special("RO_YggLeaf", "MeadTasty", "Thistle", "Folha de Yggdrasil", "Chama de volta os aliados que morreram nos últimos 6 minutos (como Ressuscitar), com todo o HP. Só é gasta se alguém tiver morrido.");
			Special("RO_YggSeed", "MeadTasty", "Acorn", "Semente de Yggdrasil", "Recupera todo o HP e todo o SP na hora.");
			Material("RO_BlueGem", "Eitr", "Gema Azul", "Componente de magias fortes (Nevasca, Chuva de Meteoros, Magnus Exorcismus, Judex, Cometa...). Se houver uma no inventário, a magia a consome e causa +25% de dano por 4 s. Nunca é obrigatória.");
			Special("RO_TreasureMap", "MeadTasty", "Coins", "Mapa do Tesouro", "Use para marcar no mapa um tesouro enterrado por perto (200–500 m). Chegue ao X para desenterrá-lo; às vezes há guardiões. Um mapa ativo por vez.");
			Feast(Feasts[0], "Banquete Simples", "+15% de regeneração de HP e +15 de stamina para o grupo (15 m) por 30 min.", (RequirementConfig[])(object)new RequirementConfig[3]
			{
				new RequirementConfig("CookedMeat", 3, 0, true),
				new RequirementConfig("Raspberry", 6, 0, true),
				new RequirementConfig("Honey", 3, 0, true)
			});
			Feast(Feasts[1], "Banquete do Caçador", "+5% de HP máx. e +3% de dano para o grupo (15 m) por 30 min.", (RequirementConfig[])(object)new RequirementConfig[3]
			{
				new RequirementConfig("DeerStew", 2, 0, true),
				new RequirementConfig("Sausages", 3, 0, true),
				new RequirementConfig("QueensJam", 2, 0, true)
			});
			Feast(Feasts[2], "Banquete Real", "+8% de HP máx., +5% de dano e +15% de regeneração de SP para o grupo (15 m) por 30 min.", (RequirementConfig[])(object)new RequirementConfig[3]
			{
				new RequirementConfig("LoxPie", 2, 0, true),
				new RequirementConfig("BloodPudding", 2, 0, true),
				new RequirementConfig("FishWraps", 2, 0, true)
			});
			string[] families = ClassGear.Families;
			foreach (string text in families)
			{
				Simple(ClassGear.Essence(text), ClassGear.EssenceIcons[text], ClassGear.EssenceNames[text], "Material de classe. Usada na Forja Ragnarok para fabricar e evoluir os equipamentos de " + Jobs.Get(text).Name + " e na Mesa Rúnica para encantar. Cai de monstros (mais de elites, variantes, mini-chefes e MVPs).", 100);
			}
			Simple("RO_MvpCore", "BlackCore", "Núcleo de MVP", "Núcleo deixado por MVPs de masmorra, MVPs errantes, chefes de instância e da Torre. Necessário para os estágios III e IV da Forja.", 20);
			foreach (RuneDef rune in ClassGear.Runes)
			{
				StringBuilder stringBuilder = new StringBuilder("Runa para a Mesa Rúnica (1 por equipamento):");
				CardEffect[] effects = rune.Effects;
				foreach (CardEffect e in effects)
				{
					stringBuilder.Append("\n• ").Append(Cards.Describe(e));
				}
				Simple(rune.ItemName, rune.Icon, rune.Name, stringBuilder.ToString(), 20);
			}
			Special("RO_ReturnScroll", "MeadTasty", "Thistle", "Pergaminho de Retorno", "Volta para o lugar onde você estava antes da última viagem (Kafra, Salão de Odin ou instância). Leva qualquer item.");
			Special("RO_Ward_Fire", "MeadTasty", "SurtlingCore", "Pedra de Proteção: Fogo", "Use com uma armadura de peito equipada: ela passa a proteger contra fogo (−25% desse dano). Troque quando quiser.");
			Special("RO_Ward_Water", "MeadTasty", "FreezeGland", "Pedra de Proteção: Água", "Use com uma armadura de peito equipada: ela passa a proteger contra gelo (−25% desse dano). Troque quando quiser.");
			Special("RO_Ward_Earth", "MeadTasty", "Obsidian", "Pedra de Proteção: Terra", "Use com uma armadura de peito equipada: ela passa a proteger contra veneno (−25%) e um pouco contra dano físico (−5%).");
			Special("RO_Ward_Wind", "MeadTasty", "Thunderstone", "Pedra de Proteção: Vento", "Use com uma armadura de peito equipada: ela passa a proteger contra raio (−25% desse dano). Troque quando quiser.");
			Special("RO_Stone_Fire", "MeadTasty", "SurtlingCore", "Pedra de Fogo", "Encanta a arma equipada com o elemento Fogo (forte contra Terra). O encanto é permanente até usar outra pedra.");
			Special("RO_Stone_Water", "MeadTasty", "FreezeGland", "Pedra de Água", "Encanta a arma equipada com o elemento Água (forte contra Fogo). O encanto é permanente até usar outra pedra.");
			Special("RO_Stone_Earth", "MeadTasty", "Obsidian", "Pedra de Terra", "Encanta a arma equipada com o elemento Terra (forte contra Vento). O encanto é permanente até usar outra pedra.");
			Special("RO_Stone_Wind", "MeadTasty", "Thunderstone", "Pedra de Vento", "Encanta a arma equipada com o elemento Vento (forte contra Água). O encanto é permanente até usar outra pedra.");
		}

		private static void Special(string name, string basePrefab, string iconPrefab, string display, string desc)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Expected O, but got Unknown
			ItemConfig val = new ItemConfig();
			val.Name = display;
			val.Description = desc;
			CustomItem val2 = new CustomItem(name, basePrefab, val);
			if ((Object)(object)val2.ItemDrop == (Object)null)
			{
				Plugin.Log.LogWarning((object)("Base não encontrada: " + basePrefab));
				return;
			}
			SE_Stats val3 = ScriptableObject.CreateInstance<SE_Stats>();
			((Object)val3).name = "SE_" + name;
			((StatusEffect)val3).m_name = display;
			((StatusEffect)val3).m_tooltip = desc;
			((StatusEffect)val3).m_ttl = 1f;
			((StatusEffect)val3).m_category = "ro_special_" + name;
			SharedData shared = val2.ItemDrop.m_itemData.m_shared;
			GameObject prefab = Cache.GetPrefab<GameObject>(iconPrefab);
			ItemDrop val4 = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<ItemDrop>() : null);
			if ((Object)(object)val4 != (Object)null && val4.m_itemData.m_shared.m_icons != null && val4.m_itemData.m_shared.m_icons.Length > 0)
			{
				shared.m_icons = (Sprite[])(object)new Sprite[1] { val4.m_itemData.m_shared.m_icons[0] };
			}
			if (shared.m_icons != null && shared.m_icons.Length > 0)
			{
				((StatusEffect)val3).m_icon = shared.m_icons[0];
			}
			shared.m_consumeStatusEffect = (StatusEffect)(object)val3;
			shared.m_maxStackSize = 20;
			shared.m_weight = 0.2f;
			shared.m_food = 0f;
			shared.m_foodStamina = 0f;
			shared.m_foodEitr = 0f;
			shared.m_description = desc;
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val3, false));
			ItemManager.Instance.AddItem(val2);
		}

		private static void Feast(string name, string display, string desc, RequirementConfig[] reqs)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			ItemConfig val = new ItemConfig();
			val.Name = display;
			val.Description = desc;
			val.CraftingStation = CraftingStations.Cauldron;
			val.Requirements = reqs;
			val.Amount = 1;
			CustomItem val2 = new CustomItem(name, "MeadTasty", val);
			if (!((Object)(object)val2.ItemDrop == (Object)null))
			{
				SE_Stats val3 = ScriptableObject.CreateInstance<SE_Stats>();
				((Object)val3).name = "SE_" + name;
				((StatusEffect)val3).m_name = display;
				((StatusEffect)val3).m_tooltip = desc;
				((StatusEffect)val3).m_ttl = 1f;
				((StatusEffect)val3).m_category = "ro_feast";
				SharedData shared = val2.ItemDrop.m_itemData.m_shared;
				GameObject prefab = Cache.GetPrefab<GameObject>("MeatPlatter");
				ItemDrop val4 = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<ItemDrop>() : null);
				if ((Object)(object)val4 != (Object)null && val4.m_itemData.m_shared.m_icons != null && val4.m_itemData.m_shared.m_icons.Length > 0)
				{
					shared.m_icons = (Sprite[])(object)new Sprite[1] { val4.m_itemData.m_shared.m_icons[0] };
				}
				if (shared.m_icons != null && shared.m_icons.Length > 0)
				{
					((StatusEffect)val3).m_icon = shared.m_icons[0];
				}
				shared.m_consumeStatusEffect = (StatusEffect)(object)val3;
				shared.m_maxStackSize = 10;
				shared.m_weight = 1f;
				shared.m_food = 0f;
				shared.m_foodStamina = 0f;
				shared.m_foodEitr = 0f;
				shared.m_description = desc;
				ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val3, false));
				ItemManager.Instance.AddItem(val2);
			}
		}

		private static void Simple(string name, string iconPrefab, string display, string desc, int stack)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			ItemConfig val = new ItemConfig();
			val.Name = display;
			val.Description = desc;
			CustomItem val2 = new CustomItem(name, "Ruby", val);
			if (!((Object)(object)val2.ItemDrop == (Object)null))
			{
				SharedData shared = val2.ItemDrop.m_itemData.m_shared;
				shared.m_itemType = (ItemType)1;
				shared.m_maxStackSize = stack;
				shared.m_weight = 0.1f;
				shared.m_value = 0;
				shared.m_teleportable = true;
				shared.m_description = desc;
				GameObject prefab = Cache.GetPrefab<GameObject>(iconPrefab);
				ItemDrop val3 = (((Object)(object)prefab != (Object)null) ? prefab.GetComponent<ItemDrop>() : null);
				if ((Object)(object)val3 != (Object)null && val3.m_itemData.m_shared.m_icons != null && val3.m_itemData.m_shared.m_icons.Length > 0)
				{
					shared.m_icons = (Sprite[])(object)new Sprite[1] { val3.m_itemData.m_shared.m_icons[0] };
				}
				ItemManager.Instance.AddItem(val2);
			}
		}

		private static void Material(string name, string basePrefab, string display, string desc)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			ItemConfig val = new ItemConfig();
			val.Name = display;
			val.Description = desc;
			CustomItem val2 = new CustomItem(name, basePrefab, val);
			if ((Object)(object)val2.ItemDrop == (Object)null)
			{
				Plugin.Log.LogWarning((object)("Base não encontrada: " + basePrefab));
				return;
			}
			SharedData shared = val2.ItemDrop.m_itemData.m_shared;
			shared.m_maxStackSize = 50;
			shared.m_weight = 0.5f;
			shared.m_value = 0;
			shared.m_teleportable = true;
			ItemManager.Instance.AddItem(val2);
		}

		private static void Potion(string name, string basePrefab, string display, float hp, float sp)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			ItemConfig val = new ItemConfig();
			val.Name = display;
			CustomItem val2 = new CustomItem(name, basePrefab, val);
			if ((Object)(object)val2.ItemDrop == (Object)null)
			{
				Plugin.Log.LogWarning((object)("Base não encontrada: " + basePrefab));
				return;
			}
			SE_Stats val3 = ScriptableObject.CreateInstance<SE_Stats>();
			((Object)val3).name = "SE_" + name;
			((StatusEffect)val3).m_name = display;
			((StatusEffect)val3).m_tooltip = display;
			((StatusEffect)val3).m_ttl = 1f;
			((StatusEffect)val3).m_category = "ro_potion";
			val3.m_healthUpFront = hp;
			val3.m_eitrUpFront = sp;
			SharedData shared = val2.ItemDrop.m_itemData.m_shared;
			if (shared.m_icons != null && shared.m_icons.Length > 0)
			{
				((StatusEffect)val3).m_icon = shared.m_icons[0];
			}
			shared.m_consumeStatusEffect = (StatusEffect)(object)val3;
			shared.m_maxStackSize = 100;
			shared.m_weight = 0.3f;
			shared.m_food = 0f;
			shared.m_foodStamina = 0f;
			shared.m_foodEitr = 0f;
			shared.m_description = ((hp > 0f) ? ("Recupera " + hp + " de HP na hora. Recarga de 1 s.") : ("Recupera " + sp + " de SP (Eitr) na hora. Recarga de 1 s."));
			ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val3, false));
			ItemManager.Instance.AddItem(val2);
		}
	}
	public static class SkillStatusEffects
	{
		private static readonly Dictionary<string, StatusEffect> Effects = new Dictionary<string, StatusEffect>();

		public static void Register()
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			foreach (SkillDef item in SkillDefs.All)
			{
				if (item.Kind == SkillKind.Buff)
				{
					SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>();
					((Object)val).name = "SE_RO_" + item.Id;
					((StatusEffect)val).m_name = item.Name;
					((StatusEffect)val).m_tooltip = item.Summary;
					((StatusEffect)val).m_ttl = 60f;
					((StatusEffect)val).m_icon = Icons.ForItem(item.Icon);
					ItemManager.Instance.AddStatusEffect(new CustomStatusEffect((StatusEffect)(object)val, false));
					Effects[item.Id] = (StatusEffect)(object)val;
				}
			}
		}

		public static void Show(string skillId, float duration)
		{
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && Effects.TryGetValue(skillId, out var value))
			{
				value.m_ttl = duration;
				((Character)localPlayer).GetSEMan().AddStatusEffect(value.NameHash(), true, 0, 0f, (short)0);
			}
		}
	}
	public static class Icons
	{
		private static readonly Dictionary<string, Sprite> Cache = new Dictionary<string, Sprite>();

		public static Sprite ForItem(string prefab)
		{
			if (string.IsNullOrEmpty(prefab))
			{
				return null;
			}
			if (Cache.TryGetValue(prefab, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			GameObject val = null;
			if ((Object)(object)ObjectDB.instance != (Object)null)
			{
				val = ObjectDB.instance.GetItemPrefab(prefab);
			}
			if ((Object)(object)val == (Object)null)
			{
				val = Cache.GetPrefab<GameObject>(prefab);
			}
			ItemDrop val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null);
			value = (((Object)(object)val2 != (Object)null && val2.m_itemData.m_shared.m_icons != null && val2.m_itemData.m_shared.m_icons.Length > 0) ? val2.m_itemData.m_shared.m_icons[0] : null);
			if ((Object)(object)value != (Object)null)
			{
				Cache[prefab] = value;
			}
			return value;
		}
	}
	public enum StationType
	{
		Shop,
		Refiner,
		CardAltar,
		Forge,
		RuneTable
	}
	public static class Stations
	{
		private class Entry
		{
			public string Prefab;

			public int Price;

			public int Stack;

			public string Key;

			public Entry(string p, int price, int stack, string key)
			{
				Prefab = p;
				Price = price;
				Stack = stack;
				Key = key;
			}
		}

		public const string ShopPiece = "RO_KafraShop";

		public const string RefinerPiece = "RO_Refiner";

		public const string AltarPiece = "RO_CardAltar";

		public const string ForgePiece = "RO_ClassForge";

		public const string RunePiece = "RO_RuneTable";

		public const string Category = "Ragnarok";

		private static readonly Entry[] Catalog = new Entry[35]
		{
			new Entry("RO_RedPotion", 25, 5, null),
			new Entry("RO_OrangePotion", 90, 5, "defeated_gdking"),
			new Entry("RO_YellowPotion", 280, 5, "defeated_dragon"),
			new Entry("RO_WhitePotion", 700, 5, "defeated_goblinking"),
			new Entry("RO_BluePotion", 900, 5, "defeated_bonemass"),
			new Entry("ArrowWood", 2, 20, null),
			new Entry("ArrowFlint", 4, 20, null),
			new Entry("ArrowBronze", 8, 20, "defeated_eikthyr"),
			new Entry("ArrowIron", 14, 20, "defeated_gdking"),
			new Entry("ArrowSilver", 22, 20, "defeated_bonemass"),
			new Entry("ArrowNeedle", 30, 20, "defeated_dragon"),
			new Entry("ArrowCarapace", 40, 20, "defeated_goblinking"),
			new Entry("BoltBone", 15, 20, "defeated_goblinking"),
			new Entry("MeadHealthMinor", 60, 1, null),
			new Entry("MeadStaminaMinor", 60, 1, null),
			new Entry("MeadPoisonResist", 250, 1, "defeated_gdking"),
			new Entry("MeadFrostResist", 250, 1, "defeated_bonemass"),
			new Entry("MeadEitrMinor", 400, 1, "defeated_dragon"),
			new Entry("Torch", 10, 1, null),
			new Entry("RO_Elunium", 1500, 1, "defeated_gdking"),
			new Entry("RO_Oridecon", 2000, 1, "defeated_gdking"),
			new Entry("RO_ButterflyWing", 1500, 1, null),
			new Entry("RO_BattleManual", 15000, 1, "defeated_gdking"),
			new Entry("RO_BlueGem", 600, 1, "defeated_gdking"),
			new Entry("RO_ReturnScroll", 300, 1, null),
			new Entry("RO_YggLeaf", 8000, 1, "defeated_bonemass"),
			new Entry("RO_YggSeed", 12000, 1, "defeated_dragon"),
			new Entry("RO_Stone_Fire", 3000, 1, "defeated_eikthyr"),
			new Entry("RO_Ward_Fire", 3000, 1, "defeated_eikthyr"),
			new Entry("RO_Ward_Water", 3000, 1, "defeated_eikthyr"),
			new Entry("RO_Ward_Earth", 3000, 1, "defeated_eikthyr"),
			new Entry("RO_Ward_Wind", 3000, 1, "defeated_eikthyr"),
			new Entry("RO_Stone_Water", 3000, 1, "defeated_eikthyr"),
			new Entry("RO_Stone_Earth", 3000, 1, "defeated_eikthyr"),
			new Entry("RO_Stone_Wind", 3000, 1, "defeated_eikthyr")
		};

		public static void Register()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Expected O, but got Unknown
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Expected O, but got Unknown
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Expected O, but got Unknown
			Add("RO_KafraShop", "piece_table", StationType.Shop, "Mercador Kafra", "Loja (só zeny), missões do dia e teleporte para outras Kafras.", (RequirementConfig[])(object)new RequirementConfig[2]
			{
				new RequirementConfig("Wood", 20, 0, true),
				new RequirementConfig("Stone", 10, 0, true)
			});
			Add("RO_Refiner", "forge", StationType.Refiner, "Refinador", "Refina equipamentos de +0 a +10 com Oridecon/Elunium e zeny. Nunca quebra itens.", (RequirementConfig[])(object)new RequirementConfig[3]
			{
				new RequirementConfig("Stone", 20, 0, true),
				new RequirementConfig("Wood", 10, 0, true),
				new RequirementConfig("Flint", 10, 0, true)
			});
			Add("RO_CardAltar", "piece_magetable", StationType.CardAltar, "Altar de Cartas", "Insere e remove cartas de equipamentos.", (RequirementConfig[])(object)new RequirementConfig[3]
			{
				new RequirementConfig("Stone", 10, 0, true),
				new RequirementConfig("Wood", 10, 0, true),
				new RequirementConfig("Resin", 10, 0, true)
			});
			Add("RO_ClassForge", "piece_artisanstation", StationType.Forge, "Forja Ragnarok", "Fabrica e evolui os equipamentos de classe (estágios I a IV) com Essências, materiais do bioma e Núcleos de MVP.", (RequirementConfig[])(object)new RequirementConfig[3]
			{
				new RequirementConfig("Stone", 20, 0, true),
				new RequirementConfig("Wood", 15, 0, true),
				new RequirementConfig("Flint", 10, 0, true)
			});
			Add("RO_RuneTable", "piece_stonecutter", StationType.RuneTable, "Mesa Rúnica", "Coloca runas (1 por equipamento) e faz encantamentos aleatórios com os bônus da sua classe.", (RequirementConfig[])(object)new RequirementConfig[3]
			{
				new RequirementConfig("Stone", 20, 0, true),
				new RequirementConfig("Wood", 10, 0, true),
				new RequirementConfig("Resin", 10, 0, true)
			});
		}

		private static void Add(string name, string basePrefab, StationType type, string display, string desc, RequirementConfig[] reqs)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			PieceConfig val = new PieceConfig();
			val.Name = display;
			val.Description = desc;
			val.PieceTable = PieceTables.Hammer;
			val.Category = "Ragnarok";
			val.CraftingStation = CraftingStations.Workbench;
			val.Requirements = reqs;
			CustomPiece val2 = new CustomPiece(name, basePrefab, val);
			if ((Object)(object)val2.PiecePrefab == (Object)null)
			{
				Plugin.Log.LogWarning((object)("Base de estação não encontrada: " + basePrefab));
				return;
			}
			GameObject piecePrefab = val2.PiecePrefab;
			StripInteractables(piecePrefab);
			RoStation roStation = piecePrefab.AddComponent<RoStation>();
			roStation.Type = type;
			roStation.DisplayName = display;
			if (type == StationType.Shop)
			{
				GameObject val3 = new GameObject("ro_trader");
				val3.transform.SetParent(piecePrefab.transform, false);
				Trader val4 = val3.AddComponent<Trader>();
				((Behaviour)val4).enabled = false;
				val4.m_name = display;
				val4.m_items = new List<TradeItem>();
				roStation.Trader = val4;
			}
			PieceManager.Instance.AddPiece(val2);
		}

		private static void StripInteractables(GameObject root)
		{
			MonoBehaviour[] componentsInChildren = root.GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && !(val is Piece) && !(val is WearNTear) && !(val is ZNetView) && (val is Interactable || val is Hoverable || val is CraftingStation))
				{
					Object.DestroyImmediate((Object)(object)val);
				}
			}
		}

		public static bool IsModTrader(Trader t)
		{
			if ((Object)(object)t != (Object)null)
			{
				return (Object)(object)((Component)t).GetComponentInParent<RoStation>() != (Object)null;
			}
			return false;
		}

		public static void FillCatalog(Trader trader)
		{
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			if (trader.m_items != null && trader.m_items.Count > 0)
			{
				return;
			}
			trader.m_items = new List<TradeItem>();
			Entry[] catalog = Catalog;
			foreach (Entry entry in catalog)
			{
				GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(entry.Prefab) : null);
				ItemDrop val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null);
				if ((Object)(object)val2 == (Object)null)
				{
					Plugin.Log.LogWarning((object)("Kafra: item não encontrado " + entry.Prefab));
					continue;
				}
				List<TradeItem> items = trader.m_items;
				TradeItem val3 = new TradeItem();
				val3.m_prefab = val2;
				val3.m_stack = entry.Stack;
				val3.m_price = entry.Price;
				val3.m_requiredGlobalKey = entry.Key ?? "";
				val3.m_name = "";
				val3.m_tooltip = "";
				val3.m_buyKey = "";
				val3.m_incrementKey = "";
				items.Add(val3);
			}
		}
	}
	public class RoStation : MonoBehaviour, Hoverable, Interactable
	{
		public StationType Type;

		public string DisplayName;

		public Trader Trader;

		private void Awake()
		{
			if ((Object)(object)Trader == (Object)null)
			{
				Trader = ((Component)this).GetComponentInChildren<Trader>(true);
			}
		}

		public string GetHoverText()
		{
			return DisplayName + "\n[<color=yellow><b>$KEY_Use</b></color>] Usar";
		}

		public string GetHoverName()
		{
			return DisplayName;
		}

		public float GetHoverOffset()
		{
			return 0f;
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			if (hold || (Object)(object)user != (Object)(object)Player.m_localPlayer)
			{
				return false;
			}
			switch (Type)
			{
			case StationType.Shop:
				RoPanel.OpenKafra(this);
				return true;
			case StationType.Refiner:
				RoGui.Open(RoGui.Window.Refine, this);
				return true;
			case StationType.CardAltar:
				RoGui.Open(RoGui.Window.Cards, this);
				return true;
			case StationType.Forge:
				RoGui.Open(RoGui.Window.Forge, this);
				return true;
			case StationType.RuneTable:
				RoGui.Open(RoGui.Window.Runes, this);
				return true;
			default:
				return false;
			}
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}
	}
}
namespace RagnarokValheim.Core
{
	public static class Backup
	{
		private static Player _savedFor;

		public static string Folder => Path.GetFullPath(Path.Combine(Paths.BepInExRootPath, Path.Combine("..", "RagnarokValheim_Backups")));

		private static string Safe(string s)
		{
			char[] invalidFileNameChars = Path.GetInvalidFileNameChars();
			foreach (char oldChar in invalidFileNameChars)
			{
				s = s.Replace(oldChar, '_');
			}
			return s;
		}

		public static string Save(string reason)
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || !RoPlayer.Ready)
			{
				return null;
			}
			RoPlayer.Save();
			Directory.CreateDirectory(Folder);
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("# RagnarokValheim 0.13.0 — " + localPlayer.GetPlayerName() + " — " + DateTime.Now.ToString("yyyy-MM-dd HH:mm") + " (" + reason + ")");
			foreach (KeyValuePair<string, string> customDatum in localPlayer.m_customData)
			{
				if (customDatum.Key.StartsWith("ro_"))
				{
					stringBuilder.AppendLine(customDatum.Key + "\t" + customDatum.Value.Replace("\n", " "));
				}
			}
			string text = Path.Combine(Folder, Safe(localPlayer.GetPlayerName()) + "_" + DateTime.Now.ToString("yyyyMMdd_HHmmss") + ".txt");
			File.WriteAllText(text, stringBuilder.ToString(), new UTF8Encoding(encoderShouldEmitUTF8Identifier: false));
			List<string> list = new List<string>(Directory.GetFiles(Folder, Safe(localPlayer.GetPlayerName()) + "_*.txt"));
			list.Sort();
			for (int i = 0; i < list.Count - 15; i++)
			{
				try
				{
					File.Delete(list[i]);
				}
				catch (Exception)
				{
				}
			}
			return text;
		}

		public static List<string> List()
		{
			Player localPlayer = Player.m_localPlayer;
			List<string> list = new List<string>();
			if ((Object)(object)localPlayer == (Object)null || !Directory.Exists(Folder))
			{
				return list;
			}
			list.AddRange(Directory.GetFiles(Folder, Safe(localPlayer.GetPlayerName()) + "_*.txt"));
			list.Sort();
			list.Reverse();
			return list;
		}

		public static string Restore(int index)
		{
			Player localPlayer = Player.m_localPlayer;
			List<string> list = List();
			if ((Object)(object)localPlayer == (Object)null || index < 0 || index >= list.Count)
			{
				return "Backup não encontrado.";
			}
			Save("antes de restaurar");
			list = List();
			string path = list[Mathf.Min(index + 1, list.Count - 1)];
			int num = 0;
			string[] array = File.ReadAllLines(path, Encoding.UTF8);
			foreach (string text in array)
			{
				if (!text.StartsWith("#"))
				{
					int num2 = text.IndexOf('\t');
					if (num2 > 0)
					{
						localPlayer.m_customData[text.Substring(0, num2)] = text.Substring(num2 + 1);
						num++;
					}
				}
			}
			RoPlayer.Reload();
			return "Restaurado: " + Path.GetFileName(path) + " (" + num + " dados).";
		}

		public static void Tick(Player p)
		{
			if ((Object)(object)p == (Object)null || (Object)(object)p == (Object)(object)_savedFor || !RoPlayer.Ready)
			{
				return;
			}
			_savedFor = p;
			if (!p.m_customData.TryGetValue("ro_seenver", out var value) || value != "0.13.0")
			{
				RoPlayer.Center("<color=#ffd780>RagnarokValheim 0.13.0: veja as novidades no painel Ragnarok (K).</color>");
			}
			try
			{
				Save("automático ao entrar");
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Backup: " + ex.Message));
			}
		}
	}
	public class CampSystem : MonoBehaviour
	{
		public class Camp
		{
			public string Id;

			public int Tier;

			public Biome Biome;

			public Vector3 Pos;

			public string Key => "ro_camp_" + Id;

			public bool Conquered => Progression.HasKey(Key);
		}

		[HarmonyPatch(typeof(Game), "Start")]
		private static class GameStartPatch
		{
			private static void Postfix()
			{
				ZRoutedRpc.instance.Register<string>("RO_CampActive", (Action<long, string>)delegate(long s, string id)
				{
					ActiveUntil[id] = Time.time + 600f;
				});
			}
		}

		private const string ActiveRpc = "RO_CampActive";

		public static CampSystem Instance;

		public static readonly List<Camp> Camps = new List<Camp>();

		private static readonly Dictionary<string, float> ActiveUntil = new Dictionary<string, float>();

		private readonly Dictionary<string, GameObject> _visuals = new Dictionary<string, GameObject>();

		private readonly Dictionary<string, PinData> _pins = new Dictionary<string, PinData>();

		private readonly Dictionary<string, string> _pinNames = new Dictionary<string, string>();

		private bool _ready;

		private float _timer;

		private static readonly Biome[] Biomes = (Biome[])(object)new Biome[7]
		{
			(Biome)1,
			(Biome)8,
			(Biome)2,
			(Biome)4,
			(Biome)16,
			(Biome)512,
			(Biome)32
		};

		private void Awake()
		{
			Instance = this;
		}

		private void Update()
		{
			_timer -= Time.deltaTime;
			if (_timer > 0f)
			{
				return;
			}
			_timer = 1f;
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || WorldGenerator.instance == null || (Object)(object)ZoneSystem.instance == (Object)null || (Object)(object)ZNetScene.instance == (Object)null)
			{
				if ((Object)(object)localPlayer == (Object)null)
				{
					Clear();
				}
			}
			else
			{
				if (!RoConfig.CampsEnabled.Value)
				{
					return;
				}
				if (!_ready)
				{
					if ((Object)(object)DungeonSystem.Instance == (Object)null || !DungeonSystem.Instance.HasPosition(Dungeons.All[0]))
					{
						return;
					}
					Compute();
				}
				foreach (Camp camp in Camps)
				{
					UpdateCamp(localPlayer, camp);
				}
			}
		}

		private void Clear()
		{
			foreach (GameObject value in _visuals.Values)
			{
				if ((Object)(object)value != (Object)null)
				{
					Object.Destroy((Object)(object)value);
				}
			}
			_visuals.Clear();
			_pins.Clear();
			_pinNames.Clear();
			Camps.Clear();
			_ready = false;
		}

		private void Compute()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			Camps.Clear();
			WorldGenerator instance = WorldGenerator.instance;
			float waterLevel = ZoneSystem.instance.m_waterLevel;
			List<Vector3> list = new List<Vector3>();
			if ((Object)(object)DungeonSystem.Instance != (Object)null)
			{
				foreach (DungeonDef item in Dungeons.All)
				{
					if (DungeonSystem.Instance.HasPosition(item))
					{
						list.Add(DungeonSystem.Instance.PositionOf(item));
					}
				}
			}
			for (int i = 0; i < Biomes.Length; i++)
			{
				for (int j = 0; j < 2; j++)
				{
					float angle = (float)i * 51f + 25f + (float)j * 180f;
					if (Find(instance, Biomes[i], angle, waterLevel, list, out var result))
					{
						list.Add(result);
						Camps.Add(new Camp
						{
							Id = i + "_" + j,
							Tier = i + 1,
							Biome = Biomes[i],
							Pos = result
						});
					}
				}
			}
			_ready = true;
			Plugin.Log.LogInfo((object)("Acampamentos inimigos posicionados: " + Camps.Count));
		}

		private static bool Find(WorldGenerator wg, Biome biome, float angle, float water, List<Vector3> taken, out Vector3 result)
		{
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			for (float num = 350f; num < 10000f; num += 170f)
			{
				int num2 = Mathf.Max(8, Mathf.CeilToInt((float)Math.PI * 2f * num / 170f));
				for (int i = 0; i < num2; i++)
				{
					int num3 = ((i % 2 == 0) ? 1 : (-1)) * ((i + 1) / 2);
					float num4 = (angle + (float)num3 * 360f / (float)num2) * ((float)Math.PI / 180f);
					float num5 = Mathf.Cos(num4) * num;
					float num6 = Mathf.Sin(num4) * num;
					if (wg.GetBiome(new Vector3(num5, 0f, num6)) != biome)
					{
						continue;
					}
					float height = wg.GetHeight(num5, num6);
					if (height < water + 3f)
					{
						continue;
					}
					float height2 = wg.GetHeight(num5 + 7f, num6);
					float height3 = wg.GetHeight(num5 - 7f, num6);
					float height4 = wg.GetHeight(num5, num6 + 7f);
					float height5 = wg.GetHeight(num5, num6 - 7f);
					if (Mathf.Abs(height2 - height) > 2.5f || Mathf.Abs(height3 - height) > 2.5f || Mathf.Abs(height4 - height) > 2.5f || Mathf.Abs(height5 - height) > 2.5f)
					{
						continue;
					}
					bool flag = false;
					foreach (Vector3 item in taken)
					{
						if (Vector2.Distance(new Vector2(item.x, item.z), new Vector2(num5, num6)) < 300f)
						{
							flag = true;
						}
					}
					if (!flag)
					{
						result = new Vector3(num5, height, num6);
						return true;
					}
				}
			}
			result = Vector3.zero;
			return false;
		}

		private void UpdateCamp(Player p, Camp c)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Expected O, but got Unknown
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Expected O, but got Unknown
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: 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)
			float num = Vector2.Distance(new Vector2(((Component)p).transform.position.x, ((Component)p).transform.position.z), new Vector2(c.Pos.x, c.Pos.z));
			bool conquered = c.Conquered;
			string key = "ro_campseen_" + c.Id;
			if (num < 250f && !p.m_customData.ContainsKey(key))
			{
				p.m_customData[key] = "1";
				if (!conquered)
				{
					RoPlayer.Notify("<color=#ff9060>Você avistou um acampamento inimigo (" + RoPanel.BiomeName(c.Biome) + ")</color>");
				}
			}
			if (p.m_customData.ContainsKey(key) && (Object)(object)Minimap.instance != (Object)null)
			{
				string text = (conquered ? "Posto avançado (Kafra e cama)" : ("Acampamento inimigo — " + RoPanel.BiomeName(c.Biome)));
				if (!_pinNames.TryGetValue(c.Id, out var value) || value != text)
				{
					if (_pins.TryGetValue(c.Id, out var value2) && value2 != null)
					{
						Minimap.instance.RemovePin(value2);
					}
					_pins[c.Id] = Minimap.instance.AddPin(c.Pos, (PinType)(conquered ? 1 : 2), text, false, false, 0L, default(PlatformUserID));
					_pinNames[c.Id] = text;
				}
			}
			_visuals.TryGetValue(c.Id, out var value3);
			if (!conquered && num < 150f && (Object)(object)value3 == (Object)null && ZoneSystem.instance.IsZoneLoaded(c.Pos))
			{
				float y = default(float);
				if (!ZoneSystem.instance.GetGroundHeight(c.Pos, ref y))
				{
					y = c.Pos.y;
				}
				GameObject val = new GameObject("RO_Camp_" + c.Id);
				val.transform.position = new Vector3(c.Pos.x, y, c.Pos.z);
				GameObject val2 = DungeonSystem.LocalCopy("fire_pit", val.transform.position, Quaternion.identity);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.transform.SetParent(val.transform, true);
					Transform[] componentsInChildren = val2.GetComponentsInChildren<Transform>(true);
					foreach (Transform val3 in componentsInChildren)
					{
						if (((Object)val3).name == "_enabled" || ((Object)val3).name == "_enabled_high")
						{
							((Component)val3).gameObject.SetActive(true);
						}
					}
				}
				GameObject val4 = new GameObject("light");
				val4.transform.SetParent(val.transform, false);
				val4.transform.localPosition = Vector3.up * 2f;
				Light val5 = val4.AddComponent<Light>();
				val5.type = (LightType)2;
				val5.color = new Color(1f, 0.45f, 0.2f);
				val5.range = 10f;
				val5.intensity = 2f;
				val5.shadows = (LightShadows)0;
				_visuals[c.Id] = val;
			}
			else if ((conquered || num > 250f) && (Object)(object)value3 != (Object)null)
			{
				Object.Destroy((Object)(object)value3);
				_visuals.Remove(c.Id);
			}
			float value4;
			bool flag = ActiveUntil.TryGetValue(c.Id, out value4) && Time.time < value4;
			if (!conquered && !flag && num < 25f && !((Character)p).IsDead() && DungeonSystem.ActiveRun == null && !WorldEvents.InvasionActive)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(0L, "RO_CampActive", new object[1] { c.Id });
				((MonoBehaviour)this).StartCoroutine(Assault(c));
			}
		}

		private IEnumerator Assault(Camp c)
		{
			DungeonDef dg = Dungeons.ByTier(c.Tier);
			Vector3 center = c.Pos;
			float ground = default(float);
			if (ZoneSystem.instance.GetGroundHeight(center, ref ground))
			{
				center.y = ground;
			}
			WorldEvents.Message(center, 80f, "<color=#ff9060>Os defensores do acampamento atacam!</color>");
			List<Character> alive = new List<Character>();
			bool failed = false;
			for (int wave = 1; wave <= 2; wave++)
			{
				if (failed)
				{
					break;
				}
				int n = 4 + 2 * (EnemyScaling.PlayersNear(center) - 1);
				for (int i = 0; i < n; i++)
				{
					Character m = DungeonSystem.Spawn(dg.Waves[Random.Range(0, dg.Waves.Length)], center, wave + 1, 6f, 14f);
					if ((Object)(object)m != (Object)null)
					{
						MonsterMods.Tag(m, 1f, 1f, 1.2f, null, "camp", 0f);
						alive.Add(m);
					}
					yield return (object)new WaitForSeconds(0.25f);
				}
				float timeout = 180f;
				while (timeout > 0f)
				{
					alive.RemoveAll((Character x) => (Object)(object)x == (Object)null || x.IsDead());
					if (alive.Count == 0)
					{
						break;
					}
					Player p = Player.m_localPlayer;
					if ((Object)(object)p == (Object)null || ((Character)p).IsDead() || Vector3.Distance(((Component)p).transform.position, center) > 90f)
					{
						failed = true;
						break;
					}
					DungeonSystem.RunStatus = "Acampamento: onda " + wave + "/2 — restam " + alive.Count;
					timeout -= 1f;
					yield return (object)new WaitForSeconds(1f);
				}
				if (timeout <= 0f)
				{
					failed = true;
				}
			}
			if (!failed)
			{
				Character chief = DungeonSystem.Spawn(dg.Mvp, center, Mathf.Min(dg.MvpStars + 1, 3), 6f, 10f);
				if ((Object)(object)chief != (Object)null)
				{
					MonsterMods.MakeElite(chief, (EliteAffix)Random.Range(1, 4));
					MonsterMods.Tag(chief, 1.5f * EnemyScaling.MvpExtra(center), 1f, 2f, "Chefe do Acampamento", "camp", 1.2f);
				}
				WorldEvents.Message(center, 80f, "<color=#ff4040>O Chefe do Acampamento apareceu!</color>");
				float timeout2 = 300f;
				while ((Object)(object)chief != (Object)null && !chief.IsDead() && timeout2 > 0f)
				{
					Player p2 = Player.m_localPlayer;
					if ((Object)(object)p2 == (Object)null || ((Character)p2).IsDead() || Vector3.Distance(((Component)p2).transform.position, center) > 90f)
					{
						failed = true;
						break;
					}
					DungeonSystem.RunStatus = "Acampamento: chefe";
					timeout2 -= 1f;
					yield return (object)new WaitForSeconds(1f);
				}
				if (timeout2 <= 0f)
				{
					failed = true;
				}
			}
			DungeonSystem.RunStatus = "";
			if (failed)
			{
				WorldEvents.Message(center, 90f, "<color=#ff6060>O acampamento resistiu.</color> Volte em 10 minutos.");
				yield break;
			}
			ZoneSystem.instance.SetGlobalKey(c.Key);
			WorldEvents.Message(center, 90f, "<color=#ffd700>Acampamento conquistado! Agora é um posto avançado com Kafra e cama.</color>");
			Journal.CountNear(center, 90f, "camp");
			Rewards.Spawn("Coins", 80 * c.Tier, center);
			for (int num = 0; num < 2; num++)
			{
				Rewards.Spawn((Random.value < 0.5f) ? "RO_Oridecon" : "RO_Elunium", 1, center);
			}
			if (Random.value < 0.5f)
			{
				Rewards.Spawn("RO_TreasureMap", 1, center);
			}
			Build("fire_pit", center, 0f);
			Build("RO_KafraShop", center + new Vector3(4f, 0f, 0f), 270f);
			Build("bed", center + new Vector3(-3.5f, 0f, 2f), 90f);
		}

		private static void SetCreator(Piece piece)
		{
			if ((Object)(object)piece == (Object)null || (Object)(object)Game.instance == (Object)null)
			{
				return;
			}
			try
			{
				MethodInfo methodInfo = AccessTools.Method(typeof(Piece), "SetCreator", (Type[])null, (Type[])null);
				if (methodInfo == null)
				{
					return;
				}
				ParameterInfo[] parameters = methodInfo.GetParameters();
				object[] array = new object[parameters.Length];
				array[0] = Game.instance.GetPlayerProfile().GetPlayerID();
				for (int i = 1; i < parameters.Length; i++)
				{
					Type parameterType = parameters[i].ParameterType;
					object obj = (parameterType.IsValueType ? Activator.CreateInstance(parameterType) : null);
					MethodInfo methodInfo2 = AccessTools.Method(typeof(Game), "GetPlatformUserID", (Type[])null, (Type[])null) ?? AccessTools.Method(typeof(PlayerProfile), "GetPlatformUserID", (Type[])null, (Type[])null);
					if (methodInfo2 != null && methodInfo2.ReturnType == parameterType)
					{
						obj = (methodInfo2.IsStatic ? methodInfo2.Invoke(null, null) : methodInfo2.Invoke((methodInfo2.DeclaringType == typeof(Game)) ? ((object?)Game.instance) : ((object?)Game.instance.GetPlayerProfile()), null));
					}
					array[i] = obj;
				}
				methodInfo.Invoke(piece, array);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Dono do posto: " + ex.Message));
			}
		}

		private static void Build(string prefabName, Vector3 pos, float yaw)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			GameObject prefab = ZNetScene.instance.GetPrefab(prefabName);
			if ((Object)(object)prefab == (Object)null)
			{
				Plugin.Log.LogWarning((object)("Peça não encontrada: " + prefabName));
				return;
			}
			float y = default(float);
			if (ZoneSystem.instance.GetGroundHeight(pos, ref y))
			{
				pos.y = y;
			}
			GameObject val = Object.Instantiate<GameObject>(prefab, pos, Quaternion.Euler(0f, yaw, 0f));
			SetCreator(val.GetComponent<Piece>());
		}
	}
	public static class Commands
	{
		private class Cmd : ConsoleCommand
		{
			private readonly string _name;

			private readonly string _help;

			private readonly Action<string[]> _run;

			public override string Name => _name;

			public override string Help => _help;

			public Cmd(string name, string help, Action<string[]> run)
			{
				_name = name;
				_help = help;
				_run = run;
			}

			public override void Run(string[] args)
			{
				if (!RoPlayer.Ready)
				{
					Print("Entre em um mundo primeiro.");
					return;
				}
				try
				{
					_run(args);
				}
				catch (Exception ex)
				{
					Print("Erro: " + ex.Message + " — uso: " + _help);
				}
			}
		}

		public static void Register()
		{
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_status", "Mostra seus dados RO", delegate
			{
				RoData data = RoPlayer.Data;
				RoStats stats = RoPlayer.Stats;
				Print("Classe " + data.Job.Name + " | Base " + data.BaseLevel + " (" + data.BaseExp + "/" + Progression.BaseExpToNext(data.BaseLevel) + ") | Classe " + data.JobLevel + " (" + data.JobExp + "/" + Progression.JobExpToNext(data.Job.Tier, data.JobLevel) + ") | Zeny " + data.Zeny + " | Pontos de atributo " + data.StatPoints + " | Pontos de habilidade " + SkillSystem.FreePoints());
				Print("Tetos atuais: base " + Progression.BaseCap() + ", classe " + Progression.JobCap(data.Job.Tier) + " | +HP " + stats.BonusHp.ToString("0") + " +SP " + stats.BonusSp.ToString("0") + " | Corpo a corpo x" + stats.MeleeMult.ToString("0.00") + " Distância x" + stats.RangedMult.ToString("0.00") + " Magia x" + stats.MagicMult.ToString("0.00") + " | Crítico " + (stats.CritChance * 100f).ToString("0.0") + "% Esquiva " + ((stats.Flee + stats.PerfectDodge) * 100f).ToString("0.0") + "%");
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_addexp", "ro_addexp <base> [classe]   ex.: ro_addexp 5000", delegate(string[] args)
			{
				long num = Num(args, 0, 1000L);
				long jobExp = Num(args, 1, (long)((float)num * RoConfig.JobExpRatio.Value));
				RoData data = RoPlayer.Data;
				int baseLevel = data.BaseLevel;
				int jobLevel = data.JobLevel;
				RoPlayer.GainExp(num, jobExp);
				Print("Base " + baseLevel + " → " + data.BaseLevel + ", classe " + jobLevel + " → " + data.JobLevel + ".");
				if (data.BaseLevel >= Progression.BaseCap() || data.JobLevel >= Progression.JobCap(data.Job.Tier))
				{
					Milestone milestone = Progression.Next();
					Print("Teto atual: base " + Progression.BaseCap() + ", classe " + Progression.JobCap(data.Job.Tier) + ((milestone != null) ? (". Derrote " + milestone.BossName + " (ou use ro_boss) para liberar mais.") : "."));
				}
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_setlevel", "ro_setlevel <base> [classe]   ex.: ro_setlevel 60 30", delegate(string[] args)
			{
				RoData data = RoPlayer.Data;
				if (args.Length == 0)
				{
					Print("Uso: ro_setlevel <base> [classe]   ex.: ro_setlevel 60 30");
				}
				else
				{
					data.BaseLevel = Mathf.Clamp((int)Num(args, 0, 1L), 1, 150);
					if (args.Length > 1)
					{
						data.JobLevel = Mathf.Clamp((int)Num(args, 1, 1L), 1, Progression.MaxJobLevelByTier[data.Job.Tier]);
					}
					data.BaseExp = 0L;
					data.JobExp = 0L;
					SkillSystem.SetTierPointsAsIfMaxed();
					RoPlayer.ResetStats(free: true);
					SkillSystem.ResetSkills();
					Print("Agora: base " + data.BaseLevel + ", classe " + data.JobLevel + ", " + data.StatPoints + " pontos de atributo e " + SkillSystem.FreePoints() + " de habilidade (atributos e habilidades foram redefinidos).");
				}
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_boss", "ro_boss <0-7>: marca chefes como derrotados neste mundo (1=Eikthyr ... 7=Fader)", delegate(string[] args)
			{
				int num = Mathf.Clamp((int)Num(args, 0, 1L), 0, Progression.Milestones.Length - 1);
				for (int i = 1; i <= num; i++)
				{
					ZoneSystem.instance.SetGlobalKey(Progression.Milestones[i].GlobalKey);
				}
				Print("Chefes marcados até " + Progression.Milestones[num].BossName + ". Teto de base: " + Progression.Milestones[num].BaseCap + ".");
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_setjob", "ro_setjob <id>   ex.: ro_setjob Swordman", delegate(string[] args)
			{
				JobDef jobDef = ((args.Length > 0) ? FindJob(args[0]) : null);
				if (jobDef == null)
				{
					Print("Classes: " + string.Join(", ", new List<string>(Jobs.All.Keys).ToArray()));
				}
				else
				{
					RoPlayer.ChangeJob(jobDef, force: true);
					Print("Classe alterada para " + jobDef.Name + ".");
				}
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_addzeny", "ro_addzeny <n>", delegate(string[] args)
			{
				RoPlayer.AddZeny(Num(args, 0, 10000L));
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_card", "ro_card <prefab do monstro>   ex.: ro_card Greydwarf", delegate(string[] args)
			{
				CardDef cardDef = null;
				if (args.Length > 0)
				{
					foreach (KeyValuePair<string, CardDef> item in Cards.ByMonster)
					{
						if (string.Equals(item.Key, args[0].Trim(), StringComparison.OrdinalIgnoreCase))
						{
							cardDef = item.Value;
						}
					}
				}
				if (cardDef == null)
				{
					Print("Monstros com carta: " + string.Join(", ", new List<string>(Cards.ByMonster.Keys).ToArray()));
				}
				else
				{
					((Humanoid)Player.m_localPlayer).GetInventory().AddItem(cardDef.ItemName, 1, 1, 0, 0L, "", false, false);
				}
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_refine", "ro_refine <0-10>: define o refino da arma equipada", delegate(string[] args)
			{
				ItemData currentWeapon = ((Humanoid)Player.m_localPlayer).GetCurrentWeapon();
				if (currentWeapon != null)
				{
					EquipData.SetRefine(currentWeapon, Mathf.Clamp((int)Num(args, 0, 0L), 0, 10));
					RoPlayer.Recalculate();
				}
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_wiki", "Gera a wiki do mod (página HTML) e mostra onde foi salva", delegate
			{
				Print("Wiki salva em: " + WikiExport.Export());
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_dg", "Lista as masmorras: local, distância e status", delegate
			{
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				Player localPlayer = Player.m_localPlayer;
				foreach (DungeonDef item2 in Dungeons.All)
				{
					string text = (((Object)(object)DungeonSystem.Instance != (Object)null && DungeonSystem.Instance.HasPosition(item2)) ? Guide.Direction(((Component)localPlayer).transform.position, DungeonSystem.Instance.PositionOf(item2)) : "sem local");
					string text2 = DungeonSystem.CanStart(item2);
					Print(item2.Id + " — " + item2.Name + ": " + text + " | " + (text2 ?? "disponível"));
				}
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_dgtp", "ro_dgtp <id>: teleporta até o portal da masmorra (teste). Ids: meadows, blackforest, swamp, mountain, plains, mistlands, ashlands, tower, sewer, glacial, raid, guild, cathedral, theater", delegate(string[] args)
			{
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: 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_006e: 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)
				DungeonDef dungeonDef = ((args.Length > 0) ? Dungeons.Get(args[0].Trim().ToLower()) : null);
				if (dungeonDef == null || (Object)(object)DungeonSystem.Instance == (Object)null || !DungeonSystem.Instance.HasPosition(dungeonDef))
				{
					Print("Masmorra desconhecida ou sem local.");
				}
				else
				{
					Vector3 val = DungeonSystem.Instance.PositionOf(dungeonDef) + new Vector3(6f, 2f, 6f);
					((Character)Player.m_localPlayer).TeleportTo(val, ((Component)Player.m_localPlayer).transform.rotation, true);
				}
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_dgreset", "Zera a recarga de todas as masmorras para você", delegate
			{
				foreach (DungeonDef item3 in Dungeons.All)
				{
					Player.m_localPlayer.m_customData.Remove("ro_dg_" + item3.Id);
					Player.m_localPlayer.m_customData.Remove("ro_rf_" + item3.Id);
				}
				Print("Recargas zeradas.");
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_elite", "ro_elite [1-4]: cria um Greydwarf elite (1 Veloz, 2 Blindado, 3 Vampírico, 4 Explosivo) para teste", delegate(string[] args)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				Player localPlayer = Player.m_localPlayer;
				Character val = DungeonSystem.Spawn("Greydwarf", ((Component)localPlayer).transform.position, 1, 6f, 8f);
				if ((Object)(object)val != (Object)null)
				{
					MonsterMods.MakeElite(val, (EliteAffix)Mathf.Clamp((int)Num(args, 0, 1L), 1, 4));
				}
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_backup", "Salva um backup do seu progresso RO (pasta RagnarokValheim_Backups do perfil)", delegate
			{
				string text = Backup.Save("manual");
				Print((text != null) ? ("Backup salvo: " + text) : "Entre no mundo primeiro.");
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_restore", "ro_restore [n]: restaura um backup (sem número lista; 0 = o mais recente)", delegate(string[] args)
			{
				List<string> list = Backup.List();
				if (args.Length == 0)
				{
					for (int i = 0; i < list.Count; i++)
					{
						Print(i + ": " + Path.GetFileName(list[i]));
					}
					if (list.Count == 0)
					{
						Print("Nenhum backup ainda.");
					}
				}
				else
				{
					Print(Backup.Restore((int)Num(args, 0, 0L)));
				}
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_medir", "Liga/desliga a medição de dano, cura e tempo para matar (um resumo por minuto)", delegate
			{
				Measure.Toggle();
				Print("Medição " + (Measure.On ? ("ligada. Arquivo: " + Measure.FilePath) : "desligada."));
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_ess", "ro_ess [qtd]: ganha Essências de todas as famílias, Núcleos de MVP e 1 de cada runa (teste)", delegate(string[] args)
			{
				int num = (int)Num(args, 0, 10L);
				string[] families = ClassGear.Families;
				foreach (string family in families)
				{
					WorldDrops.Give(Player.m_localPlayer, ClassGear.Essence(family), num);
				}
				WorldDrops.Give(Player.m_localPlayer, "RO_MvpCore", Math.Max(1, num / 5));
				foreach (RuneDef rune in ClassGear.Runes)
				{
					WorldDrops.Give(Player.m_localPlayer, rune.ItemName, 1);
				}
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_variant", "ro_variant <id>: cria um monstro variante perto (sem id lista)", delegate(string[] args)
			{
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				if (args.Length == 0)
				{
					foreach (VariantDef item4 in Variants.All)
					{
						Print(item4.Id + " — " + item4.Title);
					}
					return;
				}
				VariantDef variantDef = Variants.Get(args[0]);
				if (variantDef == null)
				{
					Print("Variante desconhecida.");
				}
				else
				{
					Character val = DungeonSystem.Spawn(variantDef.Base, ((Component)Player.m_localPlayer).transform.position, 1, 6f, 8f);
					if ((Object)(object)val != (Object)null)
					{
						Variants.Make(val, variantDef);
					}
				}
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_wmvp", "Faz um MVP errante aparecer perto de você (teste)", delegate
			{
				if ((Object)(object)WorldEvents.Instance != (Object)null)
				{
					WorldEvents.Instance.ForceWandering();
				}
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_invasion", "Começa uma invasão onde você está (teste)", delegate
			{
				if ((Object)(object)WorldEvents.Instance != (Object)null)
				{
					WorldEvents.Instance.ForceInvasion();
				}
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_equip", "ro_equip <id>: ganha um equipamento especial (sem id lista todos)", delegate(string[] args)
			{
				EquipDef value = null;
				if (args.Length > 0)
				{
					Equipment.ById.TryGetValue(args[0].Trim(), out value);
				}
				if (value == null)
				{
					Print("Equipamentos: " + string.Join(", ", new List<string>(Equipment.ById.Keys).ToArray()));
				}
				else
				{
					((Humanoid)Player.m_localPlayer).GetInventory().AddItem(value.Id, 1, 1, 0, 0L, "", false, false);
				}
			}));
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new Cmd("ro_reset", "Apaga todo o progresso RO deste personagem", delegate
			{
				RoPlayer.Wipe();
				Print("Progresso RO apagado: você voltou a ser Aprendiz nível 1.");
			}));
		}

		private static long Num(string[] args, int index, long fallback)
		{
			if (args == null || index >= args.Length)
			{
				return fallback;
			}
			Match match = Regex.Match(args[index], "-?\\d+");
			if (!match.Success || !long.TryParse(match.Value, out var result))
			{
				return fallback;
			}
			return result;
		}

		private static JobDef FindJob(string text)
		{
			text = text.Trim();
			foreach (JobDef item in Jobs.Ordered)
			{
				if (string.Equals(item.Id, text, StringComparison.OrdinalIgnoreCase) || string.Equals(item.Name, text, StringComparison.OrdinalIgnoreCase))
				{
					return item;
				}
			}
			return null;
		}

		private static void Print(string s)
		{
			if ((Object)(object)Console.instance != (Object)null)
			{
				Console.instance.Print(s);
			}
		}
	}
	public static class DirectLoot
	{
		[HarmonyPatch(typeof(Game), "Start")]
		private static class GameStartPatch
		{
			private static void Postfix()
			{
				ZRoutedRpc.instance.Register<ZPackage>("RO_DirectLoot", (Action<long, ZPackage>)OnLoot);
			}
		}

		[HarmonyPatch(typeof(Ragdoll), "SaveLootList")]
		private static class RagdollLootPatch
		{
			private static bool Prefix(Ragdoll __instance, CharacterDrop characterDrop)
			{
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					Character val = (Character)(((Object)(object)characterDrop != (Object)null && DropCharField != null) ? /*isinst with value type is only supported in some contexts*/: null);
					Player val2 = Killer(val);
					if ((Object)(object)val2 == (Object)null)
					{
						return true;
					}
					Send(val2, val.GetCenterPoint(), ToList(characterDrop.GenerateDropList()));
					return false;
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Saque direto (corpo): " + ex.Message));
					return true;
				}
			}
		}

		[HarmonyPatch(typeof(CharacterDrop), "OnDeath")]
		private static class DropOnDeathPatch
		{
			private static bool Prefix(CharacterDrop __instance)
			{
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					if (DropsEnabledField != null && !(bool)DropsEnabledField.GetValue(__instance))
					{
						return true;
					}
					Character val = (Character)((DropCharField != null) ? /*isinst with value type is only supported in some contexts*/: null);
					Player val2 = Killer(val);
					if ((Object)(object)val2 == (Object)null)
					{
						return true;
					}
					Send(val2, val.GetCenterPoint(), ToList(__instance.GenerateDropList()));
					return false;
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Saque direto: " + ex.Message));
					return true;
				}
			}
		}

		private const string Rpc = "RO_DirectLoot";

		private static readonly FieldInfo LastHitField = AccessTools.Field(typeof(Character), "m_lastHit");

		private static readonly FieldInfo DropCharField = AccessTools.Field(typeof(CharacterDrop), "m_character");

		private static readonly FieldInfo DropsEnabledField = AccessTools.Field(typeof(CharacterDrop), "m_dropsEnabled");

		public static List<KeyValuePair<string, int>> Pending;

		public static Player Killer(Character c)
		{
			if ((Object)(object)c == (Object)null || LastHitField == null || !RoConfig.DirectLoot.Value)
			{
				return null;
			}
			object? value = LastHitField.GetValue(c);
			HitData val = (HitData)((value is HitData) ? value : null);
			Character val2 = ((val != null) ? val.GetAttacker() : null);
			return (Player)(object)((val2 is Player) ? val2 : null);
		}

		public static void Send(Player to, Vector3 pos, List<KeyValuePair<string, int>> items)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)to == (Object)null || items == null || items.Count == 0 || ZRoutedRpc.instance == null)
			{
				return;
			}
			ZPackage val = new ZPackage();
			val.Write(pos);
			val.Write(items.Count);
			foreach (KeyValuePair<string, int> item in items)
			{
				val.Write(item.Key);
				val.Write(item.Value);
			}
			ZRoutedRpc.instance.InvokeRoutedRPC(((Character)to).GetOwner(), "RO_DirectLoot", new object[1] { val });
		}

		private static void OnLoot(long sender, ZPackage pkg)
		{
			//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)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			Vector3 pos = pkg.ReadVector3();
			int num = pkg.ReadInt();
			for (int i = 0; i < num; i++)
			{
				string text = pkg.ReadString();
				int num2 = pkg.ReadInt();
				if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead())
				{
					Rewards.SpawnRaw(text, num2, pos);
					continue;
				}
				GameObject val = (((Object)(object)ObjectDB.instance != (Object)null) ? ObjectDB.instance.GetItemPrefab(text) : null);
				ItemDrop val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<ItemDrop>() : null);
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				Inventory inventory = ((Humanoid)localPlayer).GetInventory();
				int num3 = num2;
				int num4 = Mathf.Max(1, val2.m_itemData.m_shared.m_maxStackSize);
				while (num3 > 0)
				{
					int num5 = Mathf.Min(num4, num3);
					if (!inventory.AddItem(val, num5))
					{
						break;
					}
					num3 -= num5;
				}
				if (num2 - num3 > 0)
				{
					((Character)localPlayer).ShowPickupMessage(val2.m_itemData, num2 - num3);
				}
				if (num3 > 0)
				{
					Rewards.SpawnRaw(text, num3, ((Component)localPlayer).transform.position);
				}
			}
		}

		private static List<KeyValuePair<string, int>> ToList(List<KeyValuePair<GameObject, int>> drops)
		{
			List<KeyValuePair<string, int>> list = new List<KeyValuePair<string, int>>();
			if (drops == null)
			{
				return list;
			}
			foreach (KeyValuePair<GameObject, int> drop in drops)
			{
				if ((Object)(object)drop.Key != (Object)null && drop.Value > 0)
				{
					list.Add(new KeyValuePair<string, i