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.1")]
[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.1";
internal static AssetBundle EmbeddedResourceBundle;
private CustomLocalization _localization;
private void Awake()
{
RunesTeleportGodesConfig.Initialize(((BaseUnityPlugin)this).Config);
LoadAssets();
AddLocalizations();
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_0169: 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_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: 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_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
if (grid.m_inventory != ((Humanoid)(Player.m_localPlayer?)).m_inventory)
{
return true;
}
if (item == null)
{
return true;
}
GameObject dropPrefab = item.m_dropPrefab;
string text = ((dropPrefab != null) ? ((Object)dropPrefab).name : null);
if (string.IsNullOrEmpty(text))
{
return true;
}
if (!_allRunas.ContainsKey(text))
{
return true;
}
RunaData runaData = _allRunas[text];
if (DateTime.Now < _globalNextUse)
{
double totalSeconds = (_globalNextUse - DateTime.Now).TotalSeconds;
MessageHud.instance.ShowMessage((MessageType)2, $"Aún en cooldown. Espera {totalSeconds:0.0}s", 0, (Sprite)null);
return false;
}
if (!CheckTeleportable(runaData.AllowedItems))
{
MessageHud.instance.ShowMessage((MessageType)2, "¡No puedes teletransportarte con algún ítem no permitido!", 0, (Sprite)null);
return false;
}
_globalNextUse = DateTime.Now.AddSeconds(runaData.CooldownSec);
grid.m_inventory.RemoveOneItem(item);
if (_runaVFXPrefabs.TryGetValue(runaData.Id, out var value) && (Object)(object)value != (Object)null)
{
Vector3 val = ((Component)Player.m_localPlayer).transform.position + Vector3.up;
Object.Instantiate<GameObject>(value, val, Quaternion.identity);
}
if (_runaSFXPrefabs.TryGetValue(runaData.Id, out var value2) && (Object)(object)value2 != (Object)null)
{
Vector3 val2 = ((Component)Player.m_localPlayer).transform.position + Vector3.up;
Object.Instantiate<GameObject>(value2, 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;
}
}
private 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 List<string> AllowedItems;
public string IconFileName;
}
private static Dictionary<string, RunaData> _allRunas = new Dictionary<string, RunaData>();
private static Dictionary<string, GameObject> _runaPrefabs = new Dictionary<string, GameObject>();
private static Dictionary<string, GameObject> _runaVFXPrefabs = new Dictionary<string, GameObject>();
private static Dictionary<string, GameObject> _runaSFXPrefabs = new Dictionary<string, GameObject>();
private static Dictionary<string, Sprite> _runaIcons = new Dictionary<string, Sprite>();
private static DateTime _globalNextUse = DateTime.MinValue;
public RunesTeleportGodesItems(AssetBundle assetBundle)
{
//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
//IL_06d4: Expected O, but got Unknown
RunaData data = 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"
};
RegisterRuna(assetBundle, data);
RunaData data2 = 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"
};
RegisterRuna(assetBundle, data2);
RunaData data3 = 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"
};
RegisterRuna(assetBundle, data3);
RunaData data4 = 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"
};
RegisterRuna(assetBundle, data4);
RunaData data5 = 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"
};
RegisterRuna(assetBundle, data5);
RunaData data6 = 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"
};
RegisterRuna(assetBundle, data6);
RunaData data7 = 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"
};
RegisterRuna(assetBundle, data7);
Harmony val = new Harmony("Azathoth18.RunesTeleportGodes");
val.PatchAll(typeof(Player_ConsumeRune_Patch));
PrefabManager.OnVanillaPrefabsAvailable += AddExtraBossDrops;
}
private void RegisterRuna(AssetBundle bundle, RunaData data)
{
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_025a: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_0222: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_0293: Unknown result type (might be due to invalid IL or missing references)
//IL_029d: Expected O, but got Unknown
//IL_0300: Unknown result type (might be due to invalid IL or missing references)
//IL_0307: Expected O, but got Unknown
//IL_031d: Unknown result type (might be due to invalid IL or missing references)
//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
//IL_02df: Expected O, but got Unknown
GameObject val = bundle.LoadAsset<GameObject>(data.PrefabName);
if (!Object.op_Implicit((Object)(object)val))
{
Logger.LogWarning((object)("No se encontró prefab '" + data.PrefabName + "'."));
return;
}
GameObject val2 = null;
if (!string.IsNullOrEmpty(data.VfxName))
{
string text = data.VfxName + ".prefab";
val2 = bundle.LoadAsset<GameObject>(text);
if (Object.op_Implicit((Object)(object)val2) && (Object)(object)PrefabManager.Instance.GetPrefab(data.VfxName) == (Object)null)
{
PrefabManager.Instance.AddPrefab(val2);
}
}
GameObject val3 = null;
if (!string.IsNullOrEmpty(data.SfxName))
{
string text2 = data.SfxName + ".prefab";
val3 = bundle.LoadAsset<GameObject>(text2);
if (Object.op_Implicit((Object)(object)val3) && (Object)(object)PrefabManager.Instance.GetPrefab(data.SfxName) == (Object)null)
{
PrefabManager.Instance.AddPrefab(val3);
}
}
List<string> allowedItems = new List<string>();
if (!string.IsNullOrEmpty(data.AllowedItemsCSV))
{
allowedItems = (from x in data.AllowedItemsCSV.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries)
select x.Trim()).ToList();
}
data.AllowedItems = allowedItems;
List<(string, int)> list = ParseRecipeString(data.RecipeString);
if (!Object.op_Implicit((Object)(object)val.GetComponent<ItemDrop>()))
{
Logger.LogError((object)("El prefab '" + data.PrefabName + "' no tiene ItemDrop. Se aborta registro."));
return;
}
string text3 = "items_" + data.PrefabName + "_name";
string text4 = "items_" + data.PrefabName + "_desc";
Sprite val4 = LoadIcon(bundle, data.IconFileName);
if ((Object)(object)val4 == (Object)null)
{
Logger.LogWarning((object)("No se encontró el ícono para la runa '" + data.Id + "'. Usando ícono por defecto."));
val4 = RenderManager.Instance.Render(val, RenderManager.IsometricRotation);
}
ItemConfig val5 = new ItemConfig
{
Name = "$" + text3,
Description = "$" + text4,
Icon = val4,
CraftingStation = (data.CraftEnabled ? data.CraftStation : null),
MinStationLevel = (data.CraftEnabled ? data.MinStationLevel : 0),
Amount = 1
};
if (data.CraftEnabled)
{
foreach (var (text5, num) in list)
{
val5.AddRequirement(new RequirementConfig(text5, num, 0, false));
}
}
CustomItem val6 = new CustomItem(val, false, val5);
ItemDrop itemDrop = val6.ItemDrop;
itemDrop.m_itemData.m_shared.m_itemType = (ItemType)2;
itemDrop.m_itemData.m_shared.m_weight = data.Weight;
ItemManager.Instance.AddItem(val6);
Logger.LogInfo((object)$"Registrada runa {data.Id}, craft={data.CraftEnabled}, bossDrop={data.BossDropEnabled}");
_runaPrefabs[data.Id] = val;
_runaVFXPrefabs[data.Id] = val2;
_runaSFXPrefabs[data.Id] = val3;
_allRunas[data.Id] = data;
}
private Sprite LoadIcon(AssetBundle bundle, string iconFileName)
{
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
if (_runaIcons.TryGetValue(iconFileName, out var value))
{
return value;
}
Texture2D val = bundle.LoadAsset<Texture2D>(iconFileName);
if ((Object)(object)val == (Object)null)
{
Logger.LogWarning((object)("No se encontró el PNG '" + iconFileName + "' para la runa. Usando ícono por defecto."));
return null;
}
Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
if ((Object)(object)val2 == (Object)null)
{
Logger.LogWarning((object)("No se pudo crear el Sprite para el ícono '" + iconFileName + "'. Usando ícono por defecto."));
return null;
}
_runaIcons[iconFileName] = val2;
Logger.LogInfo((object)("Ícono personalizado cargado para el archivo '" + iconFileName + "'."));
return val2;
}
private void AddExtraBossDrops()
{
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0149: Expected O, but got Unknown
foreach (RunaData value2 in _allRunas.Values)
{
if (!value2.BossDropEnabled)
{
continue;
}
GameObject prefab = PrefabManager.Instance.GetPrefab(value2.BossPrefabName);
if (!Object.op_Implicit((Object)(object)prefab))
{
Logger.LogWarning((object)("No se encontró prefab boss '" + value2.BossPrefabName + "' para la runa " + value2.Id + "."));
continue;
}
CharacterDrop component = prefab.GetComponent<CharacterDrop>();
if (!Object.op_Implicit((Object)(object)component))
{
Logger.LogWarning((object)("El boss '" + value2.BossPrefabName + "' no tiene CharacterDrop. No se añade drop."));
continue;
}
if (!_runaPrefabs.TryGetValue(value2.Id, out var value) || (Object)(object)value == (Object)null)
{
Logger.LogWarning((object)("No se encontró el prefab de la runa '" + value2.Id + "'."));
continue;
}
Drop item = new Drop
{
m_prefab = value,
m_amountMin = value2.BossDropAmount,
m_amountMax = value2.BossDropAmount,
m_chance = value2.BossDropChance,
m_levelMultiplier = false
};
component.m_drops.Add(item);
Logger.LogInfo((object)$"Agregado drop de {value2.Id} al boss {value2.BossPrefabName}, chance={value2.BossDropChance}");
}
}
private List<(string, int)> 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);
string[] array2 = array;
foreach (string text in array2)
{
string[] array3 = text.Split(new char[1] { ':' }, StringSplitOptions.RemoveEmptyEntries);
if (array3.Length == 2)
{
string item = array3[0].Trim();
if (int.TryParse(array3[1].Trim(), out var result))
{
list.Add((item, result));
}
}
}
return list;
}
}
public 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;
}
}
}