using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("RunesTeleportGodes")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("RunesTeleportGodes")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
public class SE_TeleportStun : SE_Stats
{
private float _origWalkSpeed;
private float _origRunSpeed;
private float _origSpeed;
private float _origAcceleration;
private float _origJumpStaminaUsage;
public SE_TeleportStun()
{
((StatusEffect)this).m_name = "TeleportStun";
((StatusEffect)this).m_tooltip = "You are frozen by teleport magic!";
((StatusEffect)this).m_ttl = 0f;
}
public override void Setup(Character character)
{
((SE_Stats)this).Setup(character);
if (!((Object)(object)((StatusEffect)this).m_character == (Object)null))
{
_origWalkSpeed = ((StatusEffect)this).m_character.m_walkSpeed;
_origRunSpeed = ((StatusEffect)this).m_character.m_runSpeed;
_origSpeed = ((StatusEffect)this).m_character.m_speed;
_origAcceleration = ((StatusEffect)this).m_character.m_acceleration;
_origJumpStaminaUsage = ((StatusEffect)this).m_character.m_jumpStaminaUsage;
}
}
public override void UpdateStatusEffect(float dt)
{
((SE_Stats)this).UpdateStatusEffect(dt);
if (!((Object)(object)((StatusEffect)this).m_character == (Object)null))
{
((StatusEffect)this).m_character.m_walkSpeed = 0f;
((StatusEffect)this).m_character.m_runSpeed = 0f;
((StatusEffect)this).m_character.m_speed = 0f;
((StatusEffect)this).m_character.m_acceleration = 0f;
((StatusEffect)this).m_character.m_jumpStaminaUsage = 9999f;
}
}
public void RestoreSpeedValues()
{
if (!((Object)(object)((StatusEffect)this).m_character == (Object)null))
{
((StatusEffect)this).m_character.m_walkSpeed = _origWalkSpeed;
((StatusEffect)this).m_character.m_runSpeed = _origRunSpeed;
((StatusEffect)this).m_character.m_speed = _origSpeed;
((StatusEffect)this).m_character.m_acceleration = _origAcceleration;
((StatusEffect)this).m_character.m_jumpStaminaUsage = _origJumpStaminaUsage;
}
}
}
namespace RunesTeleportGodes;
public static class RunesTeleportGodesConfig
{
private static ConfigFile _config;
public static ConfigEntry<bool> EnableDebugMode;
public static ConfigEntry<bool> RunaT1_CraftEnabled;
public static ConfigEntry<bool> RunaT1_BossDropEnabled;
public static ConfigEntry<string> RunaT1_BossPrefab;
public static ConfigEntry<float> RunaT1_BossDropChance;
public static ConfigEntry<int> RunaT1_BossDropAmount;
public static ConfigEntry<float> RunaT1_Cooldown;
public static ConfigEntry<float> RunaT1_Weight;
public static ConfigEntry<string> RunaT1_CraftStation;
public static ConfigEntry<int> RunaT1_MinStationLevel;
public static ConfigEntry<string> RunaT1_RecipeString;
public static ConfigEntry<string> RunaT1_AllowedItemsCSV;
public static ConfigEntry<bool> RunaT2_CraftEnabled;
public static ConfigEntry<bool> RunaT2_BossDropEnabled;
public static ConfigEntry<string> RunaT2_BossPrefab;
public static ConfigEntry<float> RunaT2_BossDropChance;
public static ConfigEntry<int> RunaT2_BossDropAmount;
public static ConfigEntry<float> RunaT2_Cooldown;
public static ConfigEntry<float> RunaT2_Weight;
public static ConfigEntry<string> RunaT2_CraftStation;
public static ConfigEntry<int> RunaT2_MinStationLevel;
public static ConfigEntry<string> RunaT2_RecipeString;
public static ConfigEntry<string> RunaT2_AllowedItemsCSV;
public static ConfigEntry<bool> RunaT3_CraftEnabled;
public static ConfigEntry<bool> RunaT3_BossDropEnabled;
public static ConfigEntry<string> RunaT3_BossPrefab;
public static ConfigEntry<float> RunaT3_BossDropChance;
public static ConfigEntry<int> RunaT3_BossDropAmount;
public static ConfigEntry<float> RunaT3_Cooldown;
public static ConfigEntry<float> RunaT3_Weight;
public static ConfigEntry<string> RunaT3_CraftStation;
public static ConfigEntry<int> RunaT3_MinStationLevel;
public static ConfigEntry<string> RunaT3_RecipeString;
public static ConfigEntry<string> RunaT3_AllowedItemsCSV;
public static ConfigEntry<bool> RunaT4_CraftEnabled;
public static ConfigEntry<bool> RunaT4_BossDropEnabled;
public static ConfigEntry<string> RunaT4_BossPrefab;
public static ConfigEntry<float> RunaT4_BossDropChance;
public static ConfigEntry<int> RunaT4_BossDropAmount;
public static ConfigEntry<float> RunaT4_Cooldown;
public static ConfigEntry<float> RunaT4_Weight;
public static ConfigEntry<string> RunaT4_CraftStation;
public static ConfigEntry<int> RunaT4_MinStationLevel;
public static ConfigEntry<string> RunaT4_RecipeString;
public static ConfigEntry<string> RunaT4_AllowedItemsCSV;
public static ConfigEntry<bool> RunaT5_CraftEnabled;
public static ConfigEntry<bool> RunaT5_BossDropEnabled;
public static ConfigEntry<string> RunaT5_BossPrefab;
public static ConfigEntry<float> RunaT5_BossDropChance;
public static ConfigEntry<int> RunaT5_BossDropAmount;
public static ConfigEntry<float> RunaT5_Cooldown;
public static ConfigEntry<float> RunaT5_Weight;
public static ConfigEntry<string> RunaT5_CraftStation;
public static ConfigEntry<int> RunaT5_MinStationLevel;
public static ConfigEntry<string> RunaT5_RecipeString;
public static ConfigEntry<string> RunaT5_AllowedItemsCSV;
public static ConfigEntry<bool> RunaT6_CraftEnabled;
public static ConfigEntry<bool> RunaT6_BossDropEnabled;
public static ConfigEntry<string> RunaT6_BossPrefab;
public static ConfigEntry<float> RunaT6_BossDropChance;
public static ConfigEntry<int> RunaT6_BossDropAmount;
public static ConfigEntry<float> RunaT6_Cooldown;
public static ConfigEntry<float> RunaT6_Weight;
public static ConfigEntry<string> RunaT6_CraftStation;
public static ConfigEntry<int> RunaT6_MinStationLevel;
public static ConfigEntry<string> RunaT6_RecipeString;
public static ConfigEntry<string> RunaT6_AllowedItemsCSV;
public static ConfigEntry<bool> RunaT7_CraftEnabled;
public static ConfigEntry<bool> RunaT7_BossDropEnabled;
public static ConfigEntry<string> RunaT7_BossPrefab;
public static ConfigEntry<float> RunaT7_BossDropChance;
public static ConfigEntry<int> RunaT7_BossDropAmount;
public static ConfigEntry<float> RunaT7_Cooldown;
public static ConfigEntry<float> RunaT7_Weight;
public static ConfigEntry<string> RunaT7_CraftStation;
public static ConfigEntry<int> RunaT7_MinStationLevel;
public static ConfigEntry<string> RunaT7_RecipeString;
public static ConfigEntry<string> RunaT7_AllowedItemsCSV;
public static void Initialize(ConfigFile config)
{
_config = config;
_config.SaveOnConfigSet = true;
CreateConfigValues();
}
private static void CreateConfigValues()
{
EnableDebugMode = _config.Bind<bool>("General", "EnableDebugMode", false, "Habilita el registro de depuración para RunesTeleportGodes.");
RunaT1_CraftEnabled = _config.Bind<bool>("RunaT1", "CraftEnabled", true, "¿Se craftea la runa T1?");
RunaT1_BossDropEnabled = _config.Bind<bool>("RunaT1", "BossDropEnabled", false, "¿La runa T1 la suelta un boss?");
RunaT1_BossPrefab = _config.Bind<string>("RunaT1", "BossPrefab", "Eikthyr", "Boss que suelta RunaT1.");
RunaT1_BossDropChance = _config.Bind<float>("RunaT1", "BossDropChance", 1f, "Prob (0..1) de dropear T1.");
RunaT1_BossDropAmount = _config.Bind<int>("RunaT1", "BossDropAmount", 1, "Cantidad de RunaT1 que suelta el boss.");
RunaT1_Cooldown = _config.Bind<float>("RunaT1", "CooldownSeconds", 180f, "Cooldown (seg) de la runa T1.");
RunaT1_Weight = _config.Bind<float>("RunaT1", "Weight", 0.5f, "Peso de la runa T1.");
RunaT1_CraftStation = _config.Bind<string>("RunaT1", "CraftStation", "piece_workbench", "Estación de crafteo p/T1.");
RunaT1_MinStationLevel = _config.Bind<int>("RunaT1", "MinStationLevel", 1, "Nivel mínimo estación p/T1.");
RunaT1_RecipeString = _config.Bind<string>("RunaT1", "RecipeString", "Wood:100,Resin:100", "Receta T1, formato 'Mat:Qty,Mat2:Qty'");
RunaT1_AllowedItemsCSV = _config.Bind<string>("RunaT1", "AllowedItemsCSV", "", "Ítems no teleporteables permitidos en T1.");
RunaT2_CraftEnabled = _config.Bind<bool>("RunaT2", "CraftEnabled", true, "¿Se craftea la runa T2?");
RunaT2_BossDropEnabled = _config.Bind<bool>("RunaT2", "BossDropEnabled", false, "¿La runa T2 la suelta un boss?");
RunaT2_BossPrefab = _config.Bind<string>("RunaT2", "BossPrefab", "Eikthyr", "Boss que suelta RunaT2.");
RunaT2_BossDropChance = _config.Bind<float>("RunaT2", "BossDropChance", 1f, "Prob (0..1) de dropear T2.");
RunaT2_BossDropAmount = _config.Bind<int>("RunaT2", "BossDropAmount", 1, "Cantidad de RunaT2 que suelta el boss.");
RunaT2_Cooldown = _config.Bind<float>("RunaT2", "CooldownSeconds", 300f, "Cooldown (seg) de la runa T2.");
RunaT2_Weight = _config.Bind<float>("RunaT2", "Weight", 0.7f, "Peso de la runa T2.");
RunaT2_CraftStation = _config.Bind<string>("RunaT2", "CraftStation", "forge", "Estación de crafteo p/T2.");
RunaT2_MinStationLevel = _config.Bind<int>("RunaT2", "MinStationLevel", 1, "Nivel mínimo estación p/T2.");
RunaT2_RecipeString = _config.Bind<string>("RunaT2", "RecipeString", "TrophyEikthyr:5,Bronze:20", "Receta T2, formato 'Mat:Qty,Mat2:Qty'");
RunaT2_AllowedItemsCSV = _config.Bind<string>("RunaT2", "AllowedItemsCSV", "TinOre,Tin,CopperOre,CopperScrap,chest_hildir1,Copper,Bronze", "Ítems no teleporteables permitidos en T2.");
RunaT3_CraftEnabled = _config.Bind<bool>("RunaT3", "CraftEnabled", true, "¿Se craftea la runa T3?");
RunaT3_BossDropEnabled = _config.Bind<bool>("RunaT3", "BossDropEnabled", false, "¿La runa T3 la suelta un boss?");
RunaT3_BossPrefab = _config.Bind<string>("RunaT3", "BossPrefab", "gd_king", "Boss que suelta RunaT3.");
RunaT3_BossDropChance = _config.Bind<float>("RunaT3", "BossDropChance", 1f, "Prob (0..1) de dropear T3.");
RunaT3_BossDropAmount = _config.Bind<int>("RunaT3", "BossDropAmount", 1, "Cantidad de RunaT3 que suelta el boss.");
RunaT3_Cooldown = _config.Bind<float>("RunaT3", "CooldownSeconds", 480f, "Cooldown (seg) de la runa T3.");
RunaT3_Weight = _config.Bind<float>("RunaT3", "Weight", 0.7f, "Peso de la runa T3.");
RunaT3_CraftStation = _config.Bind<string>("RunaT3", "CraftStation", "forge", "Estación de crafteo p/T3.");
RunaT3_MinStationLevel = _config.Bind<int>("RunaT3", "MinStationLevel", 3, "Nivel mínimo estación p/T3.");
RunaT3_RecipeString = _config.Bind<string>("RunaT3", "RecipeString", "TrophyTheElder:5,Iron:20", "Receta T3, formato 'Mat:Qty,Mat2:Qty'");
RunaT3_AllowedItemsCSV = _config.Bind<string>("RunaT3", "AllowedItemsCSV", "TinOre,Tin,CopperOre,CopperScrap,chest_hildir1,Copper,Bronze,Ironpit,IronOre,IronScrap,Iron", "Ítems no teleporteables permitidos en T3.");
RunaT4_CraftEnabled = _config.Bind<bool>("RunaT4", "CraftEnabled", true, "¿Se craftea la runa T4?");
RunaT4_BossDropEnabled = _config.Bind<bool>("RunaT4", "BossDropEnabled", false, "¿La runa T4 la suelta un boss?");
RunaT4_BossPrefab = _config.Bind<string>("RunaT4", "BossPrefab", "Bonemass", "Boss que suelta RunaT4.");
RunaT4_BossDropChance = _config.Bind<float>("RunaT4", "BossDropChance", 1f, "Prob (0..1) de dropear T4.");
RunaT4_BossDropAmount = _config.Bind<int>("RunaT4", "BossDropAmount", 1, "Cantidad de RunaT4 que suelta el boss.");
RunaT4_Cooldown = _config.Bind<float>("RunaT4", "CooldownSeconds", 600f, "Cooldown (seg) de la runa T4.");
RunaT4_Weight = _config.Bind<float>("RunaT4", "Weight", 0.7f, "Peso de la runa T4.");
RunaT4_CraftStation = _config.Bind<string>("RunaT4", "CraftStation", "forge", "Estación de crafteo p/T4.");
RunaT4_MinStationLevel = _config.Bind<int>("RunaT4", "MinStationLevel", 4, "Nivel mínimo estación p/T4.");
RunaT4_RecipeString = _config.Bind<string>("RunaT4", "RecipeString", "TrophyBonemass:5,Guck:30", "Receta T4, formato 'Mat:Qty,Mat2:Qty'");
RunaT4_AllowedItemsCSV = _config.Bind<string>("RunaT4", "AllowedItemsCSV", "TinOre,Tin,CopperOre,CopperScrap,chest_hildir1,Copper,Bronze,Ironpit,IronOre,IronScrap,Iron,Silver,SilverOre,DragonEgg,chest_hildir2", "Ítems no teleporteables permitidos en T4.");
RunaT5_CraftEnabled = _config.Bind<bool>("RunaT5", "CraftEnabled", true, "¿Se craftea la runa T5?");
RunaT5_BossDropEnabled = _config.Bind<bool>("RunaT5", "BossDropEnabled", false, "¿La runa T5 la suelta un boss?");
RunaT5_BossPrefab = _config.Bind<string>("RunaT5", "BossPrefab", "Dragon", "Boss que suelta RunaT5.");
RunaT5_BossDropChance = _config.Bind<float>("RunaT5", "BossDropChance", 1f, "Prob (0..1) de dropear T5.");
RunaT5_BossDropAmount = _config.Bind<int>("RunaT5", "BossDropAmount", 1, "Cantidad de RunaT5 que suelta el boss.");
RunaT5_Cooldown = _config.Bind<float>("RunaT5", "CooldownSeconds", 780f, "Cooldown (seg) de la runa T5.");
RunaT5_Weight = _config.Bind<float>("RunaT5", "Weight", 0.7f, "Peso de la runa T5.");
RunaT5_CraftStation = _config.Bind<string>("RunaT5", "CraftStation", "piece_artisanstation", "Estación de crafteo p/T5.");
RunaT5_MinStationLevel = _config.Bind<int>("RunaT5", "MinStationLevel", 1, "Nivel mínimo estación p/T5.");
RunaT5_RecipeString = _config.Bind<string>("RunaT5", "RecipeString", "TrophyDragonQueen:5,DragonEgg:5", "Receta T5, formato 'Mat:Qty,Mat2:Qty'");
RunaT5_AllowedItemsCSV = _config.Bind<string>("RunaT5", "AllowedItemsCSV", "TinOre,Tin,CopperOre,CopperScrap,chest_hildir1,Copper,Bronze,Ironpit,IronOre,IronScrap,Iron,Silver,SilverOre,DragonEgg,chest_hildir2,BlackMetalScrap,BlackMetal,chest_hildir3", "Ítems no teleporteables permitidos en T5.");
RunaT6_CraftEnabled = _config.Bind<bool>("RunaT6", "CraftEnabled", true, "¿Se craftea la runa T6?");
RunaT6_BossDropEnabled = _config.Bind<bool>("RunaT6", "BossDropEnabled", false, "¿La runa T6 la suelta un boss?");
RunaT6_BossPrefab = _config.Bind<string>("RunaT6", "BossPrefab", "GoblinKing", "Boss que suelta RunaT6.");
RunaT6_BossDropChance = _config.Bind<float>("RunaT6", "BossDropChance", 1f, "Prob (0..1) de dropear T6.");
RunaT6_BossDropAmount = _config.Bind<int>("RunaT6", "BossDropAmount", 1, "Cantidad de RunaT6 que suelta el boss.");
RunaT6_Cooldown = _config.Bind<float>("RunaT6", "CooldownSeconds", 900f, "Cooldown (seg) de la runa T6.");
RunaT6_Weight = _config.Bind<float>("RunaT6", "Weight", 0.7f, "Peso de la runa T6.");
RunaT6_CraftStation = _config.Bind<string>("RunaT6", "CraftStation", "blackforge", "Estación de crafteo p/T6.");
RunaT6_MinStationLevel = _config.Bind<int>("RunaT6", "MinStationLevel", 1, "Nivel mínimo estación p/T6.");
RunaT6_RecipeString = _config.Bind<string>("RunaT6", "RecipeString", "TrophyGoblinKing:5,BlackMetal:20", "Receta T6, formato 'Mat:Qty,Mat2:Qty'");
RunaT6_AllowedItemsCSV = _config.Bind<string>("RunaT6", "AllowedItemsCSV", "TinOre,Tin,CopperOre,CopperScrap,chest_hildir1,Copper,Bronze,Ironpit,IronOre,IronScrap,Iron,Silver,SilverOre,DragonEgg,chest_hildir2,BlackMetalScrap,BlackMetal,chest_hildir3,DvergrNeedle,CharredCogwheel,Ironpit,MechanicalSpring", "Ítems no teleporteables permitidos en T6.");
RunaT7_CraftEnabled = _config.Bind<bool>("RunaT7", "CraftEnabled", true, "¿Se craftea la runa T7?");
RunaT7_BossDropEnabled = _config.Bind<bool>("RunaT7", "BossDropEnabled", false, "¿La runa T7 la suelta un boss?");
RunaT7_BossPrefab = _config.Bind<string>("RunaT7", "BossPrefab", "SeekerQueen", "Boss que suelta RunaT7.");
RunaT7_BossDropChance = _config.Bind<float>("RunaT7", "BossDropChance", 1f, "Prob (0..1) de dropear T7.");
RunaT7_BossDropAmount = _config.Bind<int>("RunaT7", "BossDropAmount", 1, "Cantidad de RunaT7 que suelta el boss.");
RunaT7_Cooldown = _config.Bind<float>("RunaT7", "CooldownSeconds", 1200f, "Cooldown (seg) de la runa T7.");
RunaT7_Weight = _config.Bind<float>("RunaT7", "Weight", 0.7f, "Peso de la runa T7.");
RunaT7_CraftStation = _config.Bind<string>("RunaT7", "CraftStation", "blackforge", "Estación de crafteo p/T7.");
RunaT7_MinStationLevel = _config.Bind<int>("RunaT7", "MinStationLevel", 2, "Nivel mínimo estación p/T7.");
RunaT7_RecipeString = _config.Bind<string>("RunaT7", "RecipeString", "TrophySeekerQueen:5,BlackMarble:20", "Receta T7, formato 'Mat:Qty,Mat2:Qty'");
RunaT7_AllowedItemsCSV = _config.Bind<string>("RunaT7", "AllowedItemsCSV", "TinOre,Tin,CopperOre,CopperScrap,chest_hildir1,Copper,Bronze,Ironpit,IronOre,IronScrap,Iron,Silver,SilverOre,DragonEgg,chest_hildir2,BlackMetalScrap,BlackMetal,chest_hildir3,DvergrNeedle,CharredCogwheel,Ironpit,MechanicalSpring,FlametalNew,FlametalOreNew", "Ítems no teleporteables permitidos en T7.");
}
}
[BepInPlugin("Azathoth18.RunesTeleportGodes", "RunesTeleportGodes", "0.0.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class RunesTeleportGodes : BaseUnityPlugin
{
public const string PluginGUID = "Azathoth18.RunesTeleportGodes";
public const string PluginName = "RunesTeleportGodes";
public const string PluginVersion = "0.0.2";
internal static AssetBundle EmbeddedResourceBundle;
private CustomLocalization _localization;
private void Awake()
{
RunesTeleportGodesConfig.Initialize(((BaseUnityPlugin)this).Config);
LoadAssets();
AddLocalizations();
RunesTeleportGodesItems runesTeleportGodesItems = new RunesTeleportGodesItems(EmbeddedResourceBundle);
}
private void LoadAssets()
{
EmbeddedResourceBundle = AssetUtils.LoadAssetBundleFromResources("RunesTeleportGodes.AssetsEmbedded.runesteleportgodes", typeof(RunesTeleportGodes).Assembly);
if ((Object)(object)EmbeddedResourceBundle == (Object)null)
{
((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load the main AssetBundle: runesteleportgodes");
}
else if (RunesTeleportGodesConfig.EnableDebugMode.Value)
{
((BaseUnityPlugin)this).Logger.LogInfo((object)("Main Asset Names: " + string.Join(",", EmbeddedResourceBundle.GetAllAssetNames())));
}
}
private void AddLocalizations()
{
_localization = LocalizationManager.Instance.GetLocalization();
string[] manifestResourceNames = typeof(RunesTeleportGodes).Assembly.GetManifestResourceNames();
foreach (string text in manifestResourceNames)
{
if (text.Contains("localizations"))
{
((BaseUnityPlugin)this).Logger.LogInfo((object)("Loading localization: " + text));
string text2 = ReadEmbeddedResourceFile(text);
if (string.IsNullOrWhiteSpace(text2))
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("Localization file " + text + " is empty or could not be read."));
continue;
}
string text3 = Regex.Replace(text2, "\\/\\/.*", "");
string text4 = text.Split(new char[1] { '.' })[^2];
((BaseUnityPlugin)this).Logger.LogInfo((object)("Adding localization for language: '" + text4 + "'"));
_localization.AddJsonFile(text4, text3);
}
}
}
private string ReadEmbeddedResourceFile(string filename)
{
using Stream stream = typeof(RunesTeleportGodes).Assembly.GetManifestResourceStream(filename);
if (stream == null)
{
((BaseUnityPlugin)this).Logger.LogWarning((object)("No se encontró recurso incrustado: " + filename));
return "";
}
using StreamReader streamReader = new StreamReader(stream);
return streamReader.ReadToEnd();
}
private void OnDestroy()
{
if ((Object)(object)EmbeddedResourceBundle != (Object)null)
{
EmbeddedResourceBundle.Unload(false);
EmbeddedResourceBundle = null;
}
}
}
internal class RunesTeleportGodesItems
{
[HarmonyPatch(typeof(InventoryGui), "OnRightClickItem")]
private static class Player_ConsumeRune_Patch
{
private static bool Prefix(InventoryGrid grid, ItemData item)
{
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01de: Unknown result type (might be due to invalid IL or missing references)
//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01e8: 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_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
if (grid.m_inventory != ((Humanoid)(Player.m_localPlayer?)).m_inventory || item == null)
{
return true;
}
GameObject dropPrefab = item.m_dropPrefab;
string text = ((dropPrefab != null) ? ((Object)dropPrefab).name : null);
if (string.IsNullOrEmpty(text) || !_runaConfigs.TryGetValue(text, out var value))
{
return true;
}
if (DateTime.Now < _globalNextUse)
{
double totalSeconds = (_globalNextUse - DateTime.Now).TotalSeconds;
string text2 = string.Format(Localization.instance.Localize("$cooldown_message"), totalSeconds);
MessageHud.instance.ShowMessage((MessageType)2, text2, 0, (Sprite)null, false);
return false;
}
List<string> allowed = (from x in value.AllowedItemsCSVCE.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries)
select x.Trim()).ToList();
if (!CheckTeleportable(allowed))
{
string text3 = Localization.instance.Localize("$item_not_permitted");
MessageHud.instance.ShowMessage((MessageType)2, text3, 0, (Sprite)null, false);
return false;
}
float value2 = value.CooldownCE.Value;
_globalNextUse = DateTime.Now.AddSeconds(value2);
grid.m_inventory.RemoveOneItem(item);
if ((Object)(object)value.VfxPrefab != (Object)null)
{
Vector3 val = ((Component)Player.m_localPlayer).transform.position + Vector3.up;
Object.Instantiate<GameObject>(value.VfxPrefab, val, Quaternion.identity);
}
if ((Object)(object)value.SfxPrefab != (Object)null)
{
Vector3 val2 = ((Component)Player.m_localPlayer).transform.position + Vector3.up;
Object.Instantiate<GameObject>(value.SfxPrefab, val2, Quaternion.identity);
}
((MonoBehaviour)PlayerTeleportation.Instance).StartCoroutine(TeleportSequence(3f, 6f));
return false;
}
private static IEnumerator TeleportSequence(float sfxDuration, float vfxDuration)
{
yield return (object)new WaitForSeconds(sfxDuration);
float extraTime = vfxDuration - sfxDuration;
if (extraTime > 0f)
{
yield return (object)new WaitForSeconds(extraTime);
}
PlayerProfile profile = Game.instance.GetPlayerProfile();
if (profile != null && profile.HaveCustomSpawnPoint())
{
Vector3 bedPos = profile.GetCustomSpawnPoint();
((Character)Player.m_localPlayer).TeleportTo(bedPos, ((Component)Player.m_localPlayer).transform.rotation, true);
}
else
{
Game.instance.RequestRespawn(2f, false);
}
}
private static bool CheckTeleportable(List<string> allowed)
{
Inventory inventory = ((Humanoid)Player.m_localPlayer).m_inventory;
foreach (ItemData allItem in inventory.GetAllItems())
{
if (!allItem.m_shared.m_teleportable)
{
GameObject dropPrefab = allItem.m_dropPrefab;
string item = ((dropPrefab != null) ? ((Object)dropPrefab).name : null) ?? "";
if (!allowed.Contains(item))
{
return false;
}
}
}
return true;
}
}
internal class RunaItemConfig
{
public string Id;
public string PrefabName;
public ConfigEntry<float> CooldownCE;
public ConfigEntry<float> WeightCE;
public ConfigEntry<bool> CraftEnabledCE;
public ConfigEntry<bool> BossDropEnabledCE;
public ConfigEntry<string> BossPrefabCE;
public ConfigEntry<float> BossDropChanceCE;
public ConfigEntry<int> BossDropAmountCE;
public ConfigEntry<string> CraftStationCE;
public ConfigEntry<int> MinStationLevelCE;
public ConfigEntry<string> RecipeStringCE;
public ConfigEntry<string> AllowedItemsCSVCE;
public string IconFileName;
public string VfxName;
public string SfxName;
public GameObject VfxPrefab;
public GameObject SfxPrefab;
public string NameCode;
public string DescriptionCode;
public RunaItemConfig(string id, string prefabName)
{
Id = id;
PrefabName = prefabName;
}
}
internal static Dictionary<string, RunaItemConfig> _runaConfigs = new Dictionary<string, RunaItemConfig>();
internal static DateTime _globalNextUse = DateTime.MinValue;
public RunesTeleportGodesItems(AssetBundle assetBundle)
{
//IL_0a19: Unknown result type (might be due to invalid IL or missing references)
RunaData runaData = new RunaData
{
Id = "RunaT1",
PrefabName = "RunaT1",
VfxName = "vfx_Celestial_heavy",
SfxName = "sfx_runateleportsound",
CooldownSec = RunesTeleportGodesConfig.RunaT1_Cooldown.Value,
Weight = RunesTeleportGodesConfig.RunaT1_Weight.Value,
CraftEnabled = RunesTeleportGodesConfig.RunaT1_CraftEnabled.Value,
BossDropEnabled = RunesTeleportGodesConfig.RunaT1_BossDropEnabled.Value,
BossPrefabName = RunesTeleportGodesConfig.RunaT1_BossPrefab.Value,
BossDropChance = RunesTeleportGodesConfig.RunaT1_BossDropChance.Value,
BossDropAmount = RunesTeleportGodesConfig.RunaT1_BossDropAmount.Value,
CraftStation = RunesTeleportGodesConfig.RunaT1_CraftStation.Value,
MinStationLevel = RunesTeleportGodesConfig.RunaT1_MinStationLevel.Value,
RecipeString = RunesTeleportGodesConfig.RunaT1_RecipeString.Value,
AllowedItemsCSV = RunesTeleportGodesConfig.RunaT1_AllowedItemsCSV.Value,
IconFileName = "Runa_T1.png",
NameCode = "RunaT1_name",
DescriptionCode = "RunaT1_desc"
};
RegisterRuna(assetBundle, runaData.Id, RunesTeleportGodesConfig.RunaT1_Cooldown, RunesTeleportGodesConfig.RunaT1_Weight, RunesTeleportGodesConfig.RunaT1_CraftEnabled, RunesTeleportGodesConfig.RunaT1_BossDropEnabled, RunesTeleportGodesConfig.RunaT1_BossPrefab, RunesTeleportGodesConfig.RunaT1_BossDropChance, RunesTeleportGodesConfig.RunaT1_BossDropAmount, RunesTeleportGodesConfig.RunaT1_CraftStation, RunesTeleportGodesConfig.RunaT1_MinStationLevel, RunesTeleportGodesConfig.RunaT1_RecipeString, RunesTeleportGodesConfig.RunaT1_AllowedItemsCSV, runaData.PrefabName, runaData.IconFileName, runaData.VfxName, runaData.SfxName, runaData.NameCode, runaData.DescriptionCode);
RunaData runaData2 = new RunaData
{
Id = "RunaT2",
PrefabName = "RunaT2",
VfxName = "vfx_Celestial_heavy",
SfxName = "sfx_runateleportsound",
CooldownSec = RunesTeleportGodesConfig.RunaT2_Cooldown.Value,
Weight = RunesTeleportGodesConfig.RunaT2_Weight.Value,
CraftEnabled = RunesTeleportGodesConfig.RunaT2_CraftEnabled.Value,
BossDropEnabled = RunesTeleportGodesConfig.RunaT2_BossDropEnabled.Value,
BossPrefabName = RunesTeleportGodesConfig.RunaT2_BossPrefab.Value,
BossDropChance = RunesTeleportGodesConfig.RunaT2_BossDropChance.Value,
BossDropAmount = RunesTeleportGodesConfig.RunaT2_BossDropAmount.Value,
CraftStation = RunesTeleportGodesConfig.RunaT2_CraftStation.Value,
MinStationLevel = RunesTeleportGodesConfig.RunaT2_MinStationLevel.Value,
RecipeString = RunesTeleportGodesConfig.RunaT2_RecipeString.Value,
AllowedItemsCSV = RunesTeleportGodesConfig.RunaT2_AllowedItemsCSV.Value,
IconFileName = "Runa_T2.png",
NameCode = "RunaT2_name",
DescriptionCode = "RunaT2_desc"
};
RegisterRuna(assetBundle, runaData2.Id, RunesTeleportGodesConfig.RunaT2_Cooldown, RunesTeleportGodesConfig.RunaT2_Weight, RunesTeleportGodesConfig.RunaT2_CraftEnabled, RunesTeleportGodesConfig.RunaT2_BossDropEnabled, RunesTeleportGodesConfig.RunaT2_BossPrefab, RunesTeleportGodesConfig.RunaT2_BossDropChance, RunesTeleportGodesConfig.RunaT2_BossDropAmount, RunesTeleportGodesConfig.RunaT2_CraftStation, RunesTeleportGodesConfig.RunaT2_MinStationLevel, RunesTeleportGodesConfig.RunaT2_RecipeString, RunesTeleportGodesConfig.RunaT2_AllowedItemsCSV, runaData2.PrefabName, runaData2.IconFileName, runaData2.VfxName, runaData2.SfxName, runaData2.NameCode, runaData2.DescriptionCode);
RunaData runaData3 = new RunaData
{
Id = "RunaT3",
PrefabName = "RunaT3",
VfxName = "vfx_Celestial_heavy",
SfxName = "sfx_runateleportsound",
CooldownSec = RunesTeleportGodesConfig.RunaT3_Cooldown.Value,
Weight = RunesTeleportGodesConfig.RunaT3_Weight.Value,
CraftEnabled = RunesTeleportGodesConfig.RunaT3_CraftEnabled.Value,
BossDropEnabled = RunesTeleportGodesConfig.RunaT3_BossDropEnabled.Value,
BossPrefabName = RunesTeleportGodesConfig.RunaT3_BossPrefab.Value,
BossDropChance = RunesTeleportGodesConfig.RunaT3_BossDropChance.Value,
BossDropAmount = RunesTeleportGodesConfig.RunaT3_BossDropAmount.Value,
CraftStation = RunesTeleportGodesConfig.RunaT3_CraftStation.Value,
MinStationLevel = RunesTeleportGodesConfig.RunaT3_MinStationLevel.Value,
RecipeString = RunesTeleportGodesConfig.RunaT3_RecipeString.Value,
AllowedItemsCSV = RunesTeleportGodesConfig.RunaT3_AllowedItemsCSV.Value,
IconFileName = "Runa_T3.png",
NameCode = "RunaT3_name",
DescriptionCode = "RunaT3_desc"
};
RegisterRuna(assetBundle, runaData3.Id, RunesTeleportGodesConfig.RunaT3_Cooldown, RunesTeleportGodesConfig.RunaT3_Weight, RunesTeleportGodesConfig.RunaT3_CraftEnabled, RunesTeleportGodesConfig.RunaT3_BossDropEnabled, RunesTeleportGodesConfig.RunaT3_BossPrefab, RunesTeleportGodesConfig.RunaT3_BossDropChance, RunesTeleportGodesConfig.RunaT3_BossDropAmount, RunesTeleportGodesConfig.RunaT3_CraftStation, RunesTeleportGodesConfig.RunaT3_MinStationLevel, RunesTeleportGodesConfig.RunaT3_RecipeString, RunesTeleportGodesConfig.RunaT3_AllowedItemsCSV, runaData3.PrefabName, runaData3.IconFileName, runaData3.VfxName, runaData3.SfxName, runaData3.NameCode, runaData3.DescriptionCode);
RunaData runaData4 = new RunaData
{
Id = "RunaT4",
PrefabName = "RunaT4",
VfxName = "vfx_Celestial_heavy",
SfxName = "sfx_runateleportsound",
CooldownSec = RunesTeleportGodesConfig.RunaT4_Cooldown.Value,
Weight = RunesTeleportGodesConfig.RunaT4_Weight.Value,
CraftEnabled = RunesTeleportGodesConfig.RunaT4_CraftEnabled.Value,
BossDropEnabled = RunesTeleportGodesConfig.RunaT4_BossDropEnabled.Value,
BossPrefabName = RunesTeleportGodesConfig.RunaT4_BossPrefab.Value,
BossDropChance = RunesTeleportGodesConfig.RunaT4_BossDropChance.Value,
BossDropAmount = RunesTeleportGodesConfig.RunaT4_BossDropAmount.Value,
CraftStation = RunesTeleportGodesConfig.RunaT4_CraftStation.Value,
MinStationLevel = RunesTeleportGodesConfig.RunaT4_MinStationLevel.Value,
RecipeString = RunesTeleportGodesConfig.RunaT4_RecipeString.Value,
AllowedItemsCSV = RunesTeleportGodesConfig.RunaT4_AllowedItemsCSV.Value,
IconFileName = "Runa_T4.png",
NameCode = "RunaT4_name",
DescriptionCode = "RunaT4_desc"
};
RegisterRuna(assetBundle, runaData4.Id, RunesTeleportGodesConfig.RunaT4_Cooldown, RunesTeleportGodesConfig.RunaT4_Weight, RunesTeleportGodesConfig.RunaT4_CraftEnabled, RunesTeleportGodesConfig.RunaT4_BossDropEnabled, RunesTeleportGodesConfig.RunaT4_BossPrefab, RunesTeleportGodesConfig.RunaT4_BossDropChance, RunesTeleportGodesConfig.RunaT4_BossDropAmount, RunesTeleportGodesConfig.RunaT4_CraftStation, RunesTeleportGodesConfig.RunaT4_MinStationLevel, RunesTeleportGodesConfig.RunaT4_RecipeString, RunesTeleportGodesConfig.RunaT4_AllowedItemsCSV, runaData4.PrefabName, runaData4.IconFileName, runaData4.VfxName, runaData4.SfxName, runaData4.NameCode, runaData4.DescriptionCode);
RunaData runaData5 = new RunaData
{
Id = "RunaT5",
PrefabName = "RunaT5",
VfxName = "vfx_Celestial_heavy",
SfxName = "sfx_runateleportsound",
CooldownSec = RunesTeleportGodesConfig.RunaT5_Cooldown.Value,
Weight = RunesTeleportGodesConfig.RunaT5_Weight.Value,
CraftEnabled = RunesTeleportGodesConfig.RunaT5_CraftEnabled.Value,
BossDropEnabled = RunesTeleportGodesConfig.RunaT5_BossDropEnabled.Value,
BossPrefabName = RunesTeleportGodesConfig.RunaT5_BossPrefab.Value,
BossDropChance = RunesTeleportGodesConfig.RunaT5_BossDropChance.Value,
BossDropAmount = RunesTeleportGodesConfig.RunaT5_BossDropAmount.Value,
CraftStation = RunesTeleportGodesConfig.RunaT5_CraftStation.Value,
MinStationLevel = RunesTeleportGodesConfig.RunaT5_MinStationLevel.Value,
RecipeString = RunesTeleportGodesConfig.RunaT5_RecipeString.Value,
AllowedItemsCSV = RunesTeleportGodesConfig.RunaT5_AllowedItemsCSV.Value,
IconFileName = "Runa_T5.png",
NameCode = "RunaT5_name",
DescriptionCode = "RunaT5_desc"
};
RegisterRuna(assetBundle, runaData5.Id, RunesTeleportGodesConfig.RunaT5_Cooldown, RunesTeleportGodesConfig.RunaT5_Weight, RunesTeleportGodesConfig.RunaT5_CraftEnabled, RunesTeleportGodesConfig.RunaT5_BossDropEnabled, RunesTeleportGodesConfig.RunaT5_BossPrefab, RunesTeleportGodesConfig.RunaT5_BossDropChance, RunesTeleportGodesConfig.RunaT5_BossDropAmount, RunesTeleportGodesConfig.RunaT5_CraftStation, RunesTeleportGodesConfig.RunaT5_MinStationLevel, RunesTeleportGodesConfig.RunaT5_RecipeString, RunesTeleportGodesConfig.RunaT5_AllowedItemsCSV, runaData5.PrefabName, runaData5.IconFileName, runaData5.VfxName, runaData5.SfxName, runaData5.NameCode, runaData5.DescriptionCode);
RunaData runaData6 = new RunaData
{
Id = "RunaT6",
PrefabName = "RunaT6",
VfxName = "vfx_Celestial_heavy",
SfxName = "sfx_runateleportsound",
CooldownSec = RunesTeleportGodesConfig.RunaT6_Cooldown.Value,
Weight = RunesTeleportGodesConfig.RunaT6_Weight.Value,
CraftEnabled = RunesTeleportGodesConfig.RunaT6_CraftEnabled.Value,
BossDropEnabled = RunesTeleportGodesConfig.RunaT6_BossDropEnabled.Value,
BossPrefabName = RunesTeleportGodesConfig.RunaT6_BossPrefab.Value,
BossDropChance = RunesTeleportGodesConfig.RunaT6_BossDropChance.Value,
BossDropAmount = RunesTeleportGodesConfig.RunaT6_BossDropAmount.Value,
CraftStation = RunesTeleportGodesConfig.RunaT6_CraftStation.Value,
MinStationLevel = RunesTeleportGodesConfig.RunaT6_MinStationLevel.Value,
RecipeString = RunesTeleportGodesConfig.RunaT6_RecipeString.Value,
AllowedItemsCSV = RunesTeleportGodesConfig.RunaT6_AllowedItemsCSV.Value,
IconFileName = "Runa_T6.png",
NameCode = "RunaT6_name",
DescriptionCode = "RunaT6_desc"
};
RegisterRuna(assetBundle, runaData6.Id, RunesTeleportGodesConfig.RunaT6_Cooldown, RunesTeleportGodesConfig.RunaT6_Weight, RunesTeleportGodesConfig.RunaT6_CraftEnabled, RunesTeleportGodesConfig.RunaT6_BossDropEnabled, RunesTeleportGodesConfig.RunaT6_BossPrefab, RunesTeleportGodesConfig.RunaT6_BossDropChance, RunesTeleportGodesConfig.RunaT6_BossDropAmount, RunesTeleportGodesConfig.RunaT6_CraftStation, RunesTeleportGodesConfig.RunaT6_MinStationLevel, RunesTeleportGodesConfig.RunaT6_RecipeString, RunesTeleportGodesConfig.RunaT6_AllowedItemsCSV, runaData6.PrefabName, runaData6.IconFileName, runaData6.VfxName, runaData6.SfxName, runaData6.NameCode, runaData6.DescriptionCode);
RunaData runaData7 = new RunaData
{
Id = "RunaT7",
PrefabName = "RunaT7",
VfxName = "vfx_Celestial_heavy",
SfxName = "sfx_runateleportsound",
CooldownSec = RunesTeleportGodesConfig.RunaT7_Cooldown.Value,
Weight = RunesTeleportGodesConfig.RunaT7_Weight.Value,
CraftEnabled = RunesTeleportGodesConfig.RunaT7_CraftEnabled.Value,
BossDropEnabled = RunesTeleportGodesConfig.RunaT7_BossDropEnabled.Value,
BossPrefabName = RunesTeleportGodesConfig.RunaT7_BossPrefab.Value,
BossDropChance = RunesTeleportGodesConfig.RunaT7_BossDropChance.Value,
BossDropAmount = RunesTeleportGodesConfig.RunaT7_BossDropAmount.Value,
CraftStation = RunesTeleportGodesConfig.RunaT7_CraftStation.Value,
MinStationLevel = RunesTeleportGodesConfig.RunaT7_MinStationLevel.Value,
RecipeString = RunesTeleportGodesConfig.RunaT7_RecipeString.Value,
AllowedItemsCSV = RunesTeleportGodesConfig.RunaT7_AllowedItemsCSV.Value,
IconFileName = "Runa_T7.png",
NameCode = "RunaT7_name",
DescriptionCode = "RunaT7_desc"
};
RegisterRuna(assetBundle, runaData7.Id, RunesTeleportGodesConfig.RunaT7_Cooldown, RunesTeleportGodesConfig.RunaT7_Weight, RunesTeleportGodesConfig.RunaT7_CraftEnabled, RunesTeleportGodesConfig.RunaT7_BossDropEnabled, RunesTeleportGodesConfig.RunaT7_BossPrefab, RunesTeleportGodesConfig.RunaT7_BossDropChance, RunesTeleportGodesConfig.RunaT7_BossDropAmount, RunesTeleportGodesConfig.RunaT7_CraftStation, RunesTeleportGodesConfig.RunaT7_MinStationLevel, RunesTeleportGodesConfig.RunaT7_RecipeString, RunesTeleportGodesConfig.RunaT7_AllowedItemsCSV, runaData7.PrefabName, runaData7.IconFileName, runaData7.VfxName, runaData7.SfxName, runaData7.NameCode, runaData7.DescriptionCode);
new Harmony("Azathoth18.RunesTeleportGodes").PatchAll(typeof(Player_ConsumeRune_Patch));
PrefabManager.OnVanillaPrefabsAvailable += AddExtraBossDrops;
}
private void RegisterRuna(AssetBundle assetBundle, string runaId, ConfigEntry<float> cooldownCE, ConfigEntry<float> weightCE, ConfigEntry<bool> craftEnabledCE, ConfigEntry<bool> bossDropEnabledCE, ConfigEntry<string> bossPrefabCE, ConfigEntry<float> bossDropChanceCE, ConfigEntry<int> bossDropAmountCE, ConfigEntry<string> craftStationCE, ConfigEntry<int> minStationLevelCE, ConfigEntry<string> recipeStringCE, ConfigEntry<string> allowedItemsCSVCE, string prefabName, string iconFile, string vfxName, string sfxName, string nameCode, string descriptionCode)
{
//IL_033b: Unknown result type (might be due to invalid IL or missing references)
//IL_0340: Unknown result type (might be due to invalid IL or missing references)
//IL_0358: Unknown result type (might be due to invalid IL or missing references)
//IL_0370: Unknown result type (might be due to invalid IL or missing references)
//IL_0379: Unknown result type (might be due to invalid IL or missing references)
//IL_031f: Unknown result type (might be due to invalid IL or missing references)
//IL_0393: Unknown result type (might be due to invalid IL or missing references)
//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
//IL_03b7: Expected O, but got Unknown
//IL_041b: Unknown result type (might be due to invalid IL or missing references)
//IL_0420: Unknown result type (might be due to invalid IL or missing references)
//IL_043c: Unknown result type (might be due to invalid IL or missing references)
//IL_044d: Unknown result type (might be due to invalid IL or missing references)
//IL_0454: Expected O, but got Unknown
//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
//IL_03fa: Expected O, but got Unknown
GameObject val = assetBundle.LoadAsset<GameObject>(prefabName);
if ((Object)(object)val == (Object)null)
{
Logger.LogWarning((object)("No se encontró prefab '" + prefabName + "' para la runa " + runaId + "."));
return;
}
if ((Object)(object)val.GetComponent<ItemDrop>() == (Object)null)
{
Logger.LogError((object)("El prefab '" + prefabName + "' no tiene ItemDrop. Se aborta registro de " + runaId + "."));
return;
}
GameObject val2 = null;
if (!string.IsNullOrEmpty(vfxName))
{
val2 = assetBundle.LoadAsset<GameObject>(vfxName + ".prefab");
if ((Object)(object)val2 != (Object)null && (Object)(object)PrefabManager.Instance.GetPrefab(vfxName) == (Object)null)
{
PrefabManager.Instance.AddPrefab(val2);
}
}
GameObject val3 = null;
if (!string.IsNullOrEmpty(sfxName))
{
val3 = assetBundle.LoadAsset<GameObject>(sfxName + ".prefab");
if ((Object)(object)val3 != (Object)null && (Object)(object)PrefabManager.Instance.GetPrefab(sfxName) == (Object)null)
{
PrefabManager.Instance.AddPrefab(val3);
}
}
RunaItemConfig runaItemConfig = new RunaItemConfig(runaId, prefabName)
{
CooldownCE = cooldownCE,
WeightCE = weightCE,
CraftEnabledCE = craftEnabledCE,
BossDropEnabledCE = bossDropEnabledCE,
BossPrefabCE = bossPrefabCE,
BossDropChanceCE = bossDropChanceCE,
BossDropAmountCE = bossDropAmountCE,
CraftStationCE = craftStationCE,
MinStationLevelCE = minStationLevelCE,
RecipeStringCE = recipeStringCE,
AllowedItemsCSVCE = allowedItemsCSVCE,
IconFileName = iconFile,
VfxName = vfxName,
SfxName = sfxName,
VfxPrefab = val2,
SfxPrefab = val3,
NameCode = nameCode,
DescriptionCode = descriptionCode
};
cooldownCE.SettingChanged += delegate
{
ReapplyRune(runaId);
};
weightCE.SettingChanged += delegate
{
ReapplyRune(runaId);
};
craftEnabledCE.SettingChanged += delegate
{
ReapplyRune(runaId);
};
bossDropEnabledCE.SettingChanged += delegate
{
ReapplyRune(runaId);
};
bossDropChanceCE.SettingChanged += delegate
{
ReapplyRune(runaId);
};
bossDropAmountCE.SettingChanged += delegate
{
ReapplyRune(runaId);
};
craftStationCE.SettingChanged += delegate
{
ReapplyRune(runaId);
};
minStationLevelCE.SettingChanged += delegate
{
ReapplyRune(runaId);
};
recipeStringCE.SettingChanged += delegate
{
ReapplyRune(runaId);
};
allowedItemsCSVCE.SettingChanged += delegate
{
ReapplyRune(runaId);
};
Sprite val4 = LoadIcon(assetBundle, iconFile);
if ((Object)(object)val4 == (Object)null)
{
Logger.LogWarning((object)("No se encontró ícono '" + iconFile + "' para runa " + runaId + ". Usando ícono por defecto."));
val4 = RenderManager.Instance.Render(val, RenderManager.IsometricRotation);
}
List<(string, int)> list = ParseRecipeString(recipeStringCE.Value);
ItemConfig val5 = new ItemConfig
{
Name = "$" + runaItemConfig.NameCode,
Description = "$" + runaItemConfig.DescriptionCode,
Icon = val4,
CraftingStation = (craftEnabledCE.Value ? craftStationCE.Value : null),
MinStationLevel = (craftEnabledCE.Value ? minStationLevelCE.Value : 0),
Amount = 1
};
if (craftEnabledCE.Value)
{
foreach (var (text, num) in list)
{
val5.AddRequirement(new RequirementConfig(text, num, 0, false));
}
}
CustomItem val6 = new CustomItem(val, false, val5);
val6.ItemDrop.m_itemData.m_shared.m_weight = weightCE.Value;
val6.ItemDrop.m_itemData.m_shared.m_itemType = (ItemType)2;
CustomItem val7 = val6;
ItemManager.Instance.AddItem(val7);
_runaConfigs[runaId] = runaItemConfig;
Logger.LogInfo((object)$"Registrada runa {runaId} (prefab '{prefabName}'), craft={craftEnabledCE.Value}, bossDrop={bossDropEnabledCE.Value}");
}
private void ReapplyRune(string runeId)
{
//IL_023e: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_025f: Unknown result type (might be due to invalid IL or missing references)
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_027a: Unknown result type (might be due to invalid IL or missing references)
//IL_0285: Expected O, but got Unknown
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Expected O, but got Unknown
//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
//IL_02df: Expected O, but got Unknown
if (!_runaConfigs.TryGetValue(runeId, out var config))
{
return;
}
Logger.LogInfo((object)("[ReapplyRune] Re-aplicando valores en caliente para " + runeId + "..."));
float value = config.WeightCE.Value;
bool value2 = config.CraftEnabledCE.Value;
string value3 = config.RecipeStringCE.Value;
string craftingStation = (value2 ? config.CraftStationCE.Value : null);
int minStationLevel = (value2 ? config.MinStationLevelCE.Value : 0);
foreach (GameObject item in from o in Resources.FindObjectsOfTypeAll<GameObject>()
where ((Object)o).name == config.PrefabName || ((Object)o).name.StartsWith(config.PrefabName + "(Clone)", StringComparison.OrdinalIgnoreCase)
select o)
{
ItemDrop component = item.GetComponent<ItemDrop>();
if ((Object)(object)component != (Object)null)
{
component.m_itemData.m_shared.m_weight = value;
Logger.LogInfo((object)$" => {((Object)item).name}: Nuevo peso = {value}");
}
}
HashSet<CustomRecipe> hashSet = AccessTools.Field(typeof(ItemManager), "Recipes").GetValue(ItemManager.Instance) as HashSet<CustomRecipe>;
List<CustomRecipe> list = hashSet.Where((CustomRecipe r) => (Object)(object)((r != null) ? r.Recipe : null) != (Object)null && (Object)(object)r.Recipe.m_item != (Object)null && ((Object)r.Recipe.m_item).name == config.PrefabName).ToList();
foreach (CustomRecipe item2 in list)
{
Logger.LogInfo((object)("[ReapplyRune] Eliminando receta previa '" + ((Object)item2.Recipe).name + "'."));
hashSet.Remove(item2);
if ((Object)(object)ObjectDB.instance != (Object)null)
{
ObjectDB.instance.m_recipes.Remove(item2.Recipe);
}
}
if (!value2)
{
Logger.LogInfo((object)(" => Craft deshabilitado para " + runeId + "; no se registra receta nueva."));
ReapplyBossDrop(config);
return;
}
List<(string, int)> list2 = ParseRecipeString(value3);
RecipeConfig val = new RecipeConfig
{
Name = "Recipe_" + config.PrefabName,
Item = config.PrefabName,
CraftingStation = craftingStation,
MinStationLevel = minStationLevel
};
foreach (var (text, num) in list2)
{
val.AddRequirement(new RequirementConfig(text, num, 0, false));
}
CustomRecipe val2 = new CustomRecipe(val);
if ((Object)(object)ObjectDB.instance != (Object)null)
{
hashSet.Add(val2);
ObjectDB.instance.m_recipes.Add(val2.Recipe);
int num2 = ObjectDB.instance.m_recipes.IndexOf(val2.Recipe);
if (num2 != -1)
{
Recipe val3 = ObjectDB.instance.m_recipes[num2];
Requirement[] resources = val3.m_resources;
foreach (Requirement val4 in resources)
{
GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(((Object)val4.m_resItem).name.Replace("JVLmock_", ""));
if ((Object)(object)itemPrefab != (Object)null)
{
val4.m_resItem = itemPrefab.GetComponent<ItemDrop>();
}
}
try
{
GameObject prefab = PrefabManager.Instance.GetPrefab(((Object)val3.m_craftingStation).name.Replace("JVLmock_", ""));
val3.m_repairStation = (val3.m_craftingStation = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<CraftingStation>() : null));
GameObject prefab2 = PrefabManager.Instance.GetPrefab(config.PrefabName);
val3.m_item = ((prefab2 != null) ? prefab2.GetComponent<ItemDrop>() : null);
}
catch
{
}
}
Logger.LogInfo((object)$"[ReapplyRune] Receta nueva para {config.PrefabName} añadida con {list2.Count} requisitos.");
}
else
{
Logger.LogWarning((object)"[ReapplyRune] ObjectDB.instance es null; no se pudo agregar receta.");
}
ReapplyBossDrop(config);
Logger.LogInfo((object)("[ReapplyRune] " + runeId + " reaplicado con éxito."));
}
private void ReapplyBossDrop(RunaItemConfig config)
{
//IL_014c: 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_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Expected O, but got Unknown
bool value = config.BossDropEnabledCE.Value;
float value2 = config.BossDropChanceCE.Value;
int value3 = config.BossDropAmountCE.Value;
string value4 = config.BossPrefabCE.Value;
if (string.IsNullOrEmpty(value4))
{
return;
}
GameObject prefab = PrefabManager.Instance.GetPrefab(value4);
if ((Object)(object)prefab == (Object)null)
{
Logger.LogWarning((object)("[ReapplyBossDrop] No se encontró boss prefab '" + value4 + "' para " + config.Id));
return;
}
CharacterDrop component = prefab.GetComponent<CharacterDrop>();
if ((Object)(object)component == (Object)null)
{
Logger.LogWarning((object)("El boss '" + value4 + "' no tiene CharacterDrop. No se añade/quita drop."));
return;
}
component.m_drops.RemoveAll((Drop d) => (Object)(object)d.m_prefab != (Object)null && ((Object)d.m_prefab).name == config.PrefabName);
if (value)
{
GameObject prefab2 = PrefabManager.Instance.GetPrefab(config.PrefabName);
if ((Object)(object)prefab2 == (Object)null)
{
Logger.LogWarning((object)("No se encontró prefab runa '" + config.PrefabName + "' para re-aplicar bossDrop."));
return;
}
Drop item = new Drop
{
m_prefab = prefab2,
m_amountMin = value3,
m_amountMax = value3,
m_chance = value2,
m_levelMultiplier = false
};
component.m_drops.Add(item);
Logger.LogInfo((object)$" => BossDrop re-aplicado: {value4} dropea {config.PrefabName} x{value3} chance={value2}");
}
else
{
Logger.LogInfo((object)(" => BossDrop deshabilitado para " + config.Id + "."));
}
}
private void AddExtraBossDrops()
{
foreach (KeyValuePair<string, RunaItemConfig> runaConfig in _runaConfigs)
{
ReapplyBossDrop(runaConfig.Value);
}
}
private Sprite LoadIcon(AssetBundle bundle, string iconFileName)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
if (string.IsNullOrEmpty(iconFileName))
{
return null;
}
Texture2D val = bundle.LoadAsset<Texture2D>(iconFileName);
return Object.op_Implicit((Object)(object)val) ? Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)) : null;
}
private List<(string mat, int amt)> ParseRecipeString(string recipeStr)
{
List<(string, int)> list = new List<(string, int)>();
if (string.IsNullOrEmpty(recipeStr))
{
return list;
}
string[] array = recipeStr.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries);
foreach (string text in array)
{
string[] array2 = text.Split(new char[1] { ':' }, StringSplitOptions.RemoveEmptyEntries);
if (array2.Length == 2)
{
string item = array2[0].Trim();
if (int.TryParse(array2[1].Trim(), out var result))
{
list.Add((item, result));
}
}
}
return list;
}
}
internal class PlayerTeleportation : MonoBehaviour
{
private static PlayerTeleportation _instance;
public static PlayerTeleportation Instance
{
get
{
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
if ((Object)(object)_instance == (Object)null)
{
GameObject val = new GameObject("PlayerTeleportation");
_instance = val.AddComponent<PlayerTeleportation>();
Object.DontDestroyOnLoad((Object)(object)val);
}
return _instance;
}
}
}
internal class RunaData
{
public string Id;
public string PrefabName;
public string VfxName;
public string SfxName;
public float CooldownSec;
public float Weight;
public bool CraftEnabled;
public bool BossDropEnabled;
public string BossPrefabName;
public float BossDropChance;
public int BossDropAmount;
public string CraftStation;
public int MinStationLevel;
public string RecipeString;
public string AllowedItemsCSV;
public string IconFileName;
public string NameCode;
public string DescriptionCode;
}