using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using BubbetsItems;
using On.RoR2;
using On.RoR2.UI;
using R2API;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Hologram;
using RoR2.Navigation;
using RoR2.UI;
using ShrineOfRepair.Modules.Interactables;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ShrineOfRepair")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ShrineOfRepair")]
[assembly: AssemblyTitle("ShrineOfRepair")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ShrineOfRepair.Modules
{
public static class BubbetItemsCompat
{
private static bool? _enabled;
public static bool enabled
{
get
{
if (!_enabled.HasValue)
{
_enabled = Chainloader.PluginInfos.ContainsKey("bubbet.bubbetsitems");
}
return _enabled.Value;
}
}
public static bool IsVoidLunar(ItemTier tier)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
return tier == BubbetsItemsPlugin.VoidLunarTier.tier;
}
}
public class ModExtension
{
public delegate void DictionaryFillItemsDelegate();
public delegate void DictionaryFillEquipmentDelegate();
private struct RepairableItemsNew
{
public ItemIndex brokenItem;
public ItemIndex repairedItem;
public string modName;
}
private struct RepairableEquipment
{
public EquipmentIndex brokenEquipment;
public EquipmentIndex repairedEquipment;
public string modName;
}
[Obsolete("Depricated, please use RepairableItemsNew")]
public class RepairableItems
{
public ItemIndex brokenItem;
public ItemIndex repairedItem;
}
[Obsolete("Deprecated, plese use DictionaryFillItemsDelegate or DictionaryFillEquipmentDelegate")]
public delegate void DictionaryFillDelegate(ref List<RepairableItems> list);
private static DictionaryFillItemsDelegate fillItemsDictionaryHandler;
private static DictionaryFillEquipmentDelegate fillEquipmentDictionaryHandler;
private static List<RepairableItemsNew> ModdedItemsListNew = new List<RepairableItemsNew>();
private static List<RepairableEquipment> ModdedEquipmentList = new List<RepairableEquipment>();
[Obsolete("Depricated, please use fillItemsDictionaryHandler or fillEquipmentDictionaryHandler")]
public static DictionaryFillDelegate fillDictionaryHandler;
[Obsolete("Depricated, please use ModdedItemsListNew or ModdedEquipmentList")]
private static List<RepairableItems> ModdedItemsList = new List<RepairableItems>();
public static void AddItemsListener(DictionaryFillItemsDelegate callback)
{
fillItemsDictionaryHandler = (DictionaryFillItemsDelegate)Delegate.Combine(fillItemsDictionaryHandler, callback);
ShrineOfRepairPlugin.MyLogger.LogMessage((object)$"Added {callback.Method} to fillItemsDictionaryHandler");
}
public static void AddItemsToList(ItemIndex brokentItem, ItemIndex repairedItem, string modName)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
ModdedItemsListNew.Add(new RepairableItemsNew
{
brokenItem = brokentItem,
repairedItem = repairedItem,
modName = modName
});
}
public static void AddEquipmentListener(DictionaryFillEquipmentDelegate callback)
{
fillEquipmentDictionaryHandler = (DictionaryFillEquipmentDelegate)Delegate.Combine(fillEquipmentDictionaryHandler, callback);
ShrineOfRepairPlugin.MyLogger.LogMessage((object)$"Added {callback.Method} to fillEquipmentDictionaryHandler");
}
public static void AddEquipmentToList(EquipmentIndex brokenEquipment, EquipmentIndex repairedEquipment, string modName)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
ModdedEquipmentList.Add(new RepairableEquipment
{
brokenEquipment = brokenEquipment,
repairedEquipment = repairedEquipment,
modName = modName
});
}
internal static Dictionary<ItemIndex, ItemIndex> FillItemDictionaryFromMods(Dictionary<ItemIndex, ItemIndex> dictionary)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
if (ModdedItemsListNew.Count == 0)
{
fillItemsDictionaryHandler?.Invoke();
}
foreach (RepairableItemsNew item in ModdedItemsListNew)
{
if (!dictionary.ContainsKey(item.brokenItem))
{
dictionary.Add(item.brokenItem, item.repairedItem);
ManualLogSource myLogger = ShrineOfRepairPlugin.MyLogger;
ItemDef itemDef = ItemCatalog.GetItemDef(item.brokenItem);
string arg = ((itemDef != null) ? ((Object)itemDef).name : null);
ItemDef itemDef2 = ItemCatalog.GetItemDef(item.repairedItem);
myLogger.LogMessage((object)$"Added item repairs from {arg} to {((itemDef2 != null) ? ((Object)itemDef2).name : null)} from mod {item.modName}.");
}
}
return dictionary;
}
internal static Dictionary<EquipmentIndex, EquipmentIndex> FillEquipmentDictionaryFromMods(Dictionary<EquipmentIndex, EquipmentIndex> dictionary)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
if (ModdedEquipmentList.Count == 0)
{
fillEquipmentDictionaryHandler?.Invoke();
}
foreach (RepairableEquipment moddedEquipment in ModdedEquipmentList)
{
if (!dictionary.ContainsKey(moddedEquipment.brokenEquipment))
{
dictionary.Add(moddedEquipment.brokenEquipment, moddedEquipment.repairedEquipment);
ManualLogSource myLogger = ShrineOfRepairPlugin.MyLogger;
EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(moddedEquipment.brokenEquipment);
string arg = ((equipmentDef != null) ? ((Object)equipmentDef).name : null);
EquipmentDef equipmentDef2 = EquipmentCatalog.GetEquipmentDef(moddedEquipment.repairedEquipment);
myLogger.LogMessage((object)$"Added equipment repairs from {arg} to {((equipmentDef2 != null) ? ((Object)equipmentDef2).name : null)} from mod {moddedEquipment.modName}.");
}
}
return dictionary;
}
[Obsolete("Depricated, please use AddItemsListener or AddEquipmentListener")]
public static void AddListener(DictionaryFillDelegate callback)
{
fillDictionaryHandler = (DictionaryFillDelegate)Delegate.Combine(fillDictionaryHandler, callback);
ShrineOfRepairPlugin.MyLogger.LogMessage((object)$"Added {callback.Method} to dictionaryFillHandler");
}
[Obsolete("Deprecated, only used for compatability with older versions.")]
public static Dictionary<ItemIndex, ItemIndex> FillDictionaryFromMods(Dictionary<ItemIndex, ItemIndex> dictionary)
{
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
if (ModdedItemsList.Count == 0)
{
fillDictionaryHandler?.Invoke(ref ModdedItemsList);
}
foreach (RepairableItems moddedItems in ModdedItemsList)
{
if (!dictionary.ContainsKey(moddedItems.brokenItem))
{
dictionary.Add(moddedItems.brokenItem, moddedItems.repairedItem);
ManualLogSource myLogger = ShrineOfRepairPlugin.MyLogger;
ItemDef itemDef = ItemCatalog.GetItemDef(moddedItems.brokenItem);
myLogger.LogMessage((object)$"Added repairs from {((itemDef != null) ? ((Object)itemDef).name : null)} to {((Object)ItemCatalog.GetItemDef(moddedItems.repairedItem)).name} from a mod.");
}
}
return dictionary;
}
}
public static class RiskOfOptionsCompat
{
private static bool? _enabled;
public static bool enabled
{
get
{
if (!_enabled.HasValue)
{
_enabled = Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");
}
return _enabled.Value;
}
}
public static void SetDescription()
{
ModSettingsManager.SetModDescription("Shrine to repair your broken items.", "com.Viliger.ShrineOfRepair", "ShrineOfRepair");
}
public static void SetIcon()
{
ModSettingsManager.SetModIcon(ShrineofRepairAssets.MainBundle.LoadAsset<Sprite>("texRiskOfOptionsIcon.png"), "com.Viliger.ShrineOfRepair", "ShrineOfRepair");
}
public static void CreateNewOption(ConfigEntry<float> entry)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new StepSliderOption(entry, new StepSliderConfig
{
min = 0f,
max = 5f,
increment = 0.01f
}));
}
public static void CreateNewOption(ConfigEntry<bool> entry)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry));
}
public static void CreateNewOption(ConfigEntry<int> entry, int min = 0, int max = 200)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Expected O, but got Unknown
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Expected O, but got Unknown
ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig
{
min = min,
max = max
}));
}
}
public class ShrineofRepairAssets
{
public static AssetBundle MainBundle;
public const string BundleName = "shrinerepair";
public const string BundleFolder = "Assets";
public static string AssetBundlePath => Path.Combine(Path.GetDirectoryName(ShrineOfRepairPlugin.PInfo.Location), "Assets", "shrinerepair");
public void Init()
{
MainBundle = AssetBundle.LoadFromFile(AssetBundlePath);
}
}
public class ShrineOfRepairConfigManager
{
public static ConfigEntry<int> DirectorCost;
public static ConfigEntry<int> DirectorWeight;
public static ConfigEntry<InteractableCategory> DirectorCategory;
public static ConfigEntry<bool> UseBadModel;
public static ConfigEntry<string> RepairList;
public static ConfigEntry<bool> UsePickupPickerPanel;
public static ConfigEntry<bool> SpawnInBazaar;
public static ConfigEntry<bool> SpawnInMoon;
public static ConfigEntry<bool> UseLunarInMoon;
public static ConfigEntry<int> MaxUses;
public static ConfigEntry<Vector3> BazaarPosition;
public static ConfigEntry<Vector3> BazaarAngle;
public static ConfigEntry<Vector3> MoonPosition;
public static ConfigEntry<Vector3> MoonAngle;
public static ConfigEntry<Vector3> Moon2Position;
public static ConfigEntry<Vector3> Moon2Angle;
public static ConfigEntry<ShrineOfRepairPurchase.CostTypes> PurchaseInteractionCurrencyType;
public static ConfigEntry<int> PurchaseInteractionLunarCoinCost;
public static ConfigEntry<int> PurchaseInteractionVoidCoinCost;
public static ConfigEntry<int> PurchaseInteractionGoldBaseCost;
public static ConfigEntry<bool> PurchaseInteractionGoldUseDefaultScaling;
public static ConfigEntry<float> PurchaseInteractionGoldScalingModifier;
public static ConfigEntry<int> PickerPanelGoldTier1Cost;
public static ConfigEntry<int> PickerPanelGoldTier2Cost;
public static ConfigEntry<int> PickerPanelGoldTier3Cost;
public static ConfigEntry<int> PickerPanelGoldBossCost;
public static ConfigEntry<int> PickerPanelGoldLunarCost;
public static ConfigEntry<int> PickerPanelGoldEquipCost;
public static ConfigEntry<bool> BazaarUseLunar;
public static ConfigEntry<float> BazaarLunarMultiplier;
public static ConfigEntry<bool> PickerUseLunarByDefault;
public static ConfigEntry<bool> PickerShowFree;
public void Init(string configPath)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: 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_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: 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_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: 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_0248: 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_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_0299: Unknown result type (might be due to invalid IL or missing references)
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
//IL_0337: Unknown result type (might be due to invalid IL or missing references)
//IL_0356: Unknown result type (might be due to invalid IL or missing references)
//IL_0372: Unknown result type (might be due to invalid IL or missing references)
//IL_038e: Unknown result type (might be due to invalid IL or missing references)
//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
ConfigFile val = new ConfigFile(Path.Combine(configPath, "viliger-ShrineOfRepair-General.cfg"), true);
UseBadModel = val.Bind<bool>("Model", "Use Shitty Model", false, "Use shitty model that I made myself. If you want to see what bad modeling by bad programmer looks like - be my guest. I made it, so might as well put it here.");
DirectorCost = val.Bind<int>("Director", "Director Cost", 20, "Cost of the shrine in director credits. By defeult equal to the cost of most shrines.");
DirectorWeight = val.Bind<int>("Director", "Director Weight", 1, "Weight of the shrine for director. The lower the value, the more rare the shrine is. By default has the same weight as Shrine of Order, the only difference is that it can spawn anywhere.");
DirectorCategory = val.Bind<InteractableCategory>("Director", "Director Category", (InteractableCategory)4, "Category of interactable. If you change this, then you should also change Director Cost and Director Weight, as default values for those are balanced around it being spawned as a shrine.");
RepairList = val.Bind<string>("RepairList", "Repair List", "ExtraLifeConsumed - ExtraLife, ExtraLifeVoidConsumed - ExtraLifeVoid, FragileDamageBonusConsumed - FragileDamageBonus, HealingPotionConsumed - HealingPotion, RegeneratingScrapConsumed - RegeneratingScrap, BossHunterConsumed - BossHunter, LowerPricedChestsConsumed - LowerPricedChests", "Main Repair List, by default filled with pairs of breakable-original vanilla items, can be used to create custom pairs of brokenItem - repairedItem, including those from mods. Syntax: (broken) - (new), delimiter: ','");
UsePickupPickerPanel = val.Bind<bool>("Interactable Type", "Use Scrapper-like variation", true, "Use scrapper-like variant, with separate cost for each broken item and ability to select what you want to repair. Scrapper-like variant only works with gold. Setting this to false will return the mod to its pre 1.2.0 function. Each variant has its own config file, AllInOne for pre-1.2.0 version and PerItem for newer.");
MaxUses = val.Bind<int>("General", "Max Uses", 1, "Amount of times a single shrine can repair before deactivating. Set to 0 for infinite.");
UseLunarInMoon = val.Bind<bool>("General", "Use Lunar Coins in Moon", false, "Make the Commencement shrine act like Bazaar shrine.");
SpawnInBazaar = val.Bind<bool>("Bazaar", "Spawn Shrine in Bazaar", false, "Spawn the shrine in the Bazaar Between Time.");
BazaarPosition = val.Bind<Vector3>("Bazaar", "Shrine Position in Bazaar", new Vector3(-139.5f, -25.5f, -19.9f), "Position of the shrine in the Bazaar Between Time");
BazaarAngle = val.Bind<Vector3>("Bazaar", "Shrine Angle in Bazaar", new Vector3(0f, 0f, 0f), "Angle (rotation) of the shrine in the Bazaar Between Time");
SpawnInMoon = val.Bind<bool>("Commencement", "Spawn Shrine in Moon", true, "Spawn the shrine in Commencement.");
MoonPosition = val.Bind<Vector3>("Commencement", "Shrine Position in Commencement (pre-Aniversary)", new Vector3(749.4f, 253f, -244.3f), "Position of the shrine in Commencement (pre-Aniversary)");
MoonAngle = val.Bind<Vector3>("Commencement", "Shrine Angle in Commencement (pre-Aniversary)", new Vector3(0f, 143.2f, 0f), "Angle (rotation) of the shrine in Commencement (pre-Aniversary)");
Moon2Position = val.Bind<Vector3>("Commencement", "Shrine Position in Commencement", new Vector3(-3.9f, -150.6f, -331.2f), "Position of the shrine in Commencement");
Moon2Angle = val.Bind<Vector3>("Commencement", "Shrine Angle in Commencement", new Vector3(-70f, 164f, 0f), "Angle (rotation) of the shrine in Commencement");
ConfigFile val2 = new ConfigFile(Path.Combine(configPath, "viliger-ShrineOfRepair-AllInOne.cfg"), true);
PurchaseInteractionCurrencyType = val2.Bind<ShrineOfRepairPurchase.CostTypes>("Currency", "Currency Type", ShrineOfRepairPurchase.CostTypes.Gold, "Type of currency used to purchase shrine. Using anything other than \"Gold\" disables price scaling over time. Each currency has its own options.");
PurchaseInteractionLunarCoinCost = val2.Bind<int>("Lunar Coins", "Shrine Base Cost", 2, "Base cost of the interactable in lunar coins. Does not scale with time. Can be used with EphemeralCoins.");
PurchaseInteractionVoidCoinCost = val2.Bind<int>("Void Coins", "Shrine Base Cost", 2, "Base cost of the interactable in void coins. Does not scale with time. To be used with ReleasedFromTheVoid.");
PurchaseInteractionGoldBaseCost = val2.Bind<int>("Gold", "Shrine Base Cost", 12, "Base cost of the interactable in gold that is used for scaling. Will spawn with this cost at the start of the run.");
PurchaseInteractionGoldUseDefaultScaling = val2.Bind<bool>("Gold", "Use Default Scaling", false, "Use default scaling formula instead of custom scaling formula for the shrine. Custom formula is diffCoef^customsScalingModifier * BaseCost, default formula is diffCoef^1.25 * BaseCost * ScalingModifier");
PurchaseInteractionGoldScalingModifier = val2.Bind<float>("Gold", "Scaling Modifier", 1.35f, "Used for defining how cost of shrine scales throughout the run for both default and custom scaling formulas.");
ConfigFile val3 = new ConfigFile(Path.Combine(configPath, "viliger-ShrineOfRepair-PerItem.cfg"), true);
PickerPanelGoldTier1Cost = val3.Bind<int>("Per Item Repairs", "Tier 1 cost", 12, "Base cost of tier 1 (white) item repair. By default the cost is equal to the half of normal chest price, rounded down.");
PickerPanelGoldTier2Cost = val3.Bind<int>("Per Item Repairs", "Tier 2 cost", 25, "Base cost of tier 2 (green) item repair. By default the cost is equal to the half of large chest price.");
PickerPanelGoldTier3Cost = val3.Bind<int>("Per Item Repairs", "Tier 3 cost", 200, "Base cost of tier 3 (red) item repair. By default the cost is equal to the half of legendary chest price.");
PickerPanelGoldBossCost = val3.Bind<int>("Per Item Repairs", "Boss cost", 50, "Base cost of boss (yellow) item repair. By default the cost is equal to double tier 2 repair price.");
PickerPanelGoldLunarCost = val3.Bind<int>("Per Item Repairs", "Lunar cost", 25, "Base cost of lunar (blue) item repair. By default the cost is equal to the half of large chest price.");
PickerPanelGoldEquipCost = val3.Bind<int>("Per Item Repairs", "Equipment cost", 50, "Base cost of equipments (orange) repair. By default the cost is equal to double tier 2 repair price.");
BazaarUseLunar = val3.Bind<bool>("Bazaar Shrines", "Use Lunar Coins in Bazaar", true, "Shrine spawned in Bazaar uses lunar coins. If disabled it will use gold instead.");
BazaarLunarMultiplier = val3.Bind<float>("Bazaar Shrines", "Bazaar Lunar Coin Multiplier", 0.04f, "Lunar Coin cost multiplier for Bazaar shrines. Disabled if currency type is not gold. 25 gold per 1 coin by default. set to 0 for free.");
PickerUseLunarByDefault = val3.Bind<bool>("Bazaar Shrines", "Use Lunar Coins by Default", false, "Set to true to make every shrine act like Bazaar's shrines.");
PickerShowFree = val3.Bind<bool>("Display", "Display Cost for Free", false, "Set to true to display $0 for free entries.");
if (RiskOfOptionsCompat.enabled)
{
RiskOfOptionsCompat.SetDescription();
RiskOfOptionsCompat.SetIcon();
RiskOfOptionsCompat.CreateNewOption(PickerPanelGoldTier1Cost);
RiskOfOptionsCompat.CreateNewOption(PickerPanelGoldTier2Cost);
RiskOfOptionsCompat.CreateNewOption(PickerPanelGoldTier3Cost, 0, 400);
RiskOfOptionsCompat.CreateNewOption(PickerPanelGoldBossCost);
RiskOfOptionsCompat.CreateNewOption(PickerPanelGoldLunarCost);
RiskOfOptionsCompat.CreateNewOption(PickerPanelGoldEquipCost);
RiskOfOptionsCompat.CreateNewOption(BazaarLunarMultiplier);
RiskOfOptionsCompat.CreateNewOption(PickerUseLunarByDefault);
RiskOfOptionsCompat.CreateNewOption(PickerShowFree);
RiskOfOptionsCompat.CreateNewOption(MaxUses, 0, 50);
RiskOfOptionsCompat.CreateNewOption(SpawnInBazaar);
RiskOfOptionsCompat.CreateNewOption(SpawnInMoon);
RiskOfOptionsCompat.CreateNewOption(BazaarUseLunar);
}
}
}
public class ShrineOfRepairLanguages
{
public const string LanguageFileName = "ShrineOfRepair.language";
public const string LanguageFileFolder = "Languages";
public void Init()
{
LanguageAPI.AddPath(Path.Combine(Path.GetDirectoryName(ShrineOfRepairPlugin.PInfo.Location), "Languages", "ShrineOfRepair.language"));
}
}
[BepInPlugin("com.Viliger.ShrineOfRepair", "ShrineOfRepair", "1.4.4")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class ShrineOfRepairPlugin : BaseUnityPlugin
{
internal static ManualLogSource MyLogger;
public static PluginInfo PInfo { get; private set; }
private void Awake()
{
PInfo = ((BaseUnityPlugin)this).Info;
MyLogger = ((BaseUnityPlugin)this).Logger;
new ShrineofRepairAssets().Init();
new ShrineOfRepairLanguages().Init();
new ShrineOfRepairConfigManager().Init(Paths.ConfigPath);
foreach (Type item in from type in Assembly.GetExecutingAssembly().GetTypes()
where !type.IsAbstract && type.IsSubclassOf(typeof(InteractableBase))
select type)
{
InteractableBase interactableBase = (InteractableBase)Activator.CreateInstance(item);
interactableBase.Init();
MyLogger.LogInfo((object)("Interactable: " + interactableBase.InteractableLangToken + " loaded."));
}
}
}
}
namespace ShrineOfRepair.Modules.Interactables
{
public abstract class InteractableBase<T> : InteractableBase where T : InteractableBase<T>
{
public static T instance { get; private set; }
public InteractableBase()
{
if (instance != null)
{
throw new InvalidOperationException("Singleton class \"" + typeof(T).FullName + "\" inhereting InteractableBase was instanced twice");
}
instance = this as T;
}
}
public abstract class InteractableBase
{
public abstract string InteractableLangToken { get; }
public abstract void Init();
}
public abstract class ShrineOfRepairBase<T> : InteractableBase<T> where T : ShrineOfRepairBase<T>
{
public static Dictionary<ItemIndex, ItemIndex> RepairItemsDictionary = new Dictionary<ItemIndex, ItemIndex>();
public static Dictionary<EquipmentIndex, EquipmentIndex> RepairEquipmentsDictionary = new Dictionary<EquipmentIndex, EquipmentIndex>();
public static InteractableSpawnCard shrineSpawnCard;
public override string InteractableLangToken => "SHRINE_REPAIR";
internal abstract GameObject CreateInteractable(GameObject InteractableModel);
public static void FillRepairItemsDictionary()
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Invalid comparison between Unknown and I4
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Invalid comparison between Unknown and I4
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Invalid comparison between Unknown and I4
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Invalid comparison between Unknown and I4
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
if (RepairItemsDictionary.Count != 0 || RepairEquipmentsDictionary.Count != 0)
{
return;
}
string[] array = ShrineOfRepairConfigManager.RepairList.Value.Split(',');
for (int i = 0; i < array.Length; i++)
{
string[] array2 = array[i].Split('-');
if (array2.Length != 2)
{
continue;
}
ItemIndex val = ItemCatalog.FindItemIndex(array2[0].Trim());
ItemIndex val2 = ItemCatalog.FindItemIndex(array2[1].Trim());
if ((int)val != -1 && (int)val2 != -1)
{
RepairItemsDictionary.Add(val, val2);
continue;
}
EquipmentIndex val3 = EquipmentCatalog.FindEquipmentIndex(array2[0].Trim());
EquipmentIndex val4 = EquipmentCatalog.FindEquipmentIndex(array2[1].Trim());
if ((int)val3 != -1 && (int)val4 != -1)
{
RepairEquipmentsDictionary.Add(val3, val4);
}
}
RepairItemsDictionary = ModExtension.FillItemDictionaryFromMods(RepairItemsDictionary);
RepairItemsDictionary = ModExtension.FillDictionaryFromMods(RepairItemsDictionary);
RepairEquipmentsDictionary = ModExtension.FillEquipmentDictionaryFromMods(RepairEquipmentsDictionary);
ShrineOfRepairPlugin.MyLogger.LogDebug((object)"Items");
foreach (KeyValuePair<ItemIndex, ItemIndex> item in RepairItemsDictionary)
{
ShrineOfRepairPlugin.MyLogger.LogDebug((object)(((Object)ItemCatalog.GetItemDef(item.Key)).name + " -> " + ((Object)ItemCatalog.GetItemDef(item.Value)).name));
}
ShrineOfRepairPlugin.MyLogger.LogDebug((object)"Equipments");
foreach (KeyValuePair<EquipmentIndex, EquipmentIndex> item2 in RepairEquipmentsDictionary)
{
ShrineOfRepairPlugin.MyLogger.LogDebug((object)(((Object)EquipmentCatalog.GetEquipmentDef(item2.Key)).name + " -> " + ((Object)EquipmentCatalog.GetEquipmentDef(item2.Value)).name));
}
}
internal void CreateInteractables()
{
GameObject interactableModel = CreateInteractable(ShrineOfRepairConfigManager.UseBadModel.Value ? ShrineofRepairAssets.MainBundle.LoadAsset<GameObject>("ShrineRepair.prefab") : ShrineofRepairAssets.MainBundle.LoadAsset<GameObject>("ShrineRepairGood.prefab"));
GameObject interactableModel2 = CreateInteractable(ShrineOfRepairConfigManager.UseBadModel.Value ? ShrineofRepairAssets.MainBundle.LoadAsset<GameObject>("ShrineRepair.prefab") : ShrineofRepairAssets.MainBundle.LoadAsset<GameObject>("ShrineRepairGood_sandy.prefab"));
GameObject interactableModel3 = CreateInteractable(ShrineOfRepairConfigManager.UseBadModel.Value ? ShrineofRepairAssets.MainBundle.LoadAsset<GameObject>("ShrineRepair.prefab") : ShrineofRepairAssets.MainBundle.LoadAsset<GameObject>("ShrineRepairGood_snowy.prefab"));
shrineSpawnCard = CreateInteractableSpawnCard(interactableModel, "iscShrineRepair", GetNormalStageList());
CreateInteractableSpawnCard(interactableModel2, "iscShrineRepairSandy", GetSandyStageList());
CreateInteractableSpawnCard(interactableModel3, "iscShrineRepairSnowy", GetSnowyStageList());
}
private InteractableSpawnCard CreateInteractableSpawnCard(GameObject InteractableModel, string name, List<Stage> stageList)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
InteractableSpawnCard val = ScriptableObject.CreateInstance<InteractableSpawnCard>();
((Object)val).name = name;
((SpawnCard)val).prefab = InteractableModel;
((SpawnCard)val).sendOverNetwork = true;
((SpawnCard)val).hullSize = (HullClassification)1;
((SpawnCard)val).nodeGraphType = (GraphType)0;
((SpawnCard)val).requiredFlags = (NodeFlags)0;
((SpawnCard)val).forbiddenFlags = (NodeFlags)16;
((SpawnCard)val).directorCreditCost = ShrineOfRepairConfigManager.DirectorCost.Value;
((SpawnCard)val).occupyPosition = true;
val.orientToFloor = false;
val.skipSpawnWhenSacrificeArtifactEnabled = false;
DirectorCard val2 = new DirectorCard
{
selectionWeight = ShrineOfRepairConfigManager.DirectorWeight.Value,
spawnCard = (SpawnCard)(object)val
};
foreach (Stage stage in stageList)
{
Helpers.AddNewInteractableToStage(val2, ShrineOfRepairConfigManager.DirectorCategory.Value, stage, "");
}
return val;
}
private List<Stage> GetNormalStageList()
{
return new List<Stage>
{
(Stage)4,
(Stage)128,
(Stage)2,
(Stage)131072,
(Stage)256,
(Stage)16384,
(Stage)134217728,
(Stage)64,
(Stage)262144,
(Stage)1048576,
(Stage)4194304,
(Stage)33554432,
(Stage)524288
};
}
private List<Stage> GetSnowyStageList()
{
return new List<Stage>
{
(Stage)67108864,
(Stage)32,
(Stage)2097152
};
}
private List<Stage> GetSandyStageList()
{
return new List<Stage>
{
(Stage)16,
(Stage)8388608
};
}
protected void SpawnShrine(Vector3 position, Vector3 angle)
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Expected O, but got Unknown
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
if (NetworkServer.active)
{
DirectorPlacementRule val = new DirectorPlacementRule();
val.placementMode = (PlacementMode)0;
GameObject spawnedInstance = ((SpawnCard)shrineSpawnCard).DoSpawn(position, Quaternion.identity, new DirectorSpawnRequest((SpawnCard)(object)shrineSpawnCard, val, Run.instance.runRNG)).spawnedInstance;
spawnedInstance.transform.eulerAngles = angle;
NetworkServer.Spawn(spawnedInstance);
}
}
protected virtual void Hooks()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Expected O, but got Unknown
BazaarController.Awake += (hook_Awake)delegate(orig_Awake orig, BazaarController self)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self);
if (ShrineOfRepairConfigManager.SpawnInBazaar.Value)
{
SpawnShrine(ShrineOfRepairConfigManager.BazaarPosition.Value, ShrineOfRepairConfigManager.BazaarAngle.Value);
}
};
SceneDirector.onPostPopulateSceneServer += SceneDirector_onPostPopulateSceneServer;
ScrapperInfoPanelHelper.ShowInfo += new hook_ShowInfo(ScrapperInfoPanelHelper_ShowInfo);
}
private void ScrapperInfoPanelHelper_ShowInfo(orig_ShowInfo orig, ScrapperInfoPanelHelper self, MPButton button, PickupDef pickupDef)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_0081: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, button, pickupDef);
Transform val = ((Component)self).gameObject.transform;
if (!((Object)val).name.Contains("ShrineRepair"))
{
while (Object.op_Implicit((Object)(object)val.parent))
{
val = val.parent;
if (((Object)val).name.Contains("ShrineRepair"))
{
break;
}
}
}
if (!((Object)val).name.Contains("ShrineRepair"))
{
return;
}
ItemDef itemDef = ItemCatalog.GetItemDef(pickupDef.itemIndex);
if ((Object)(object)itemDef != (Object)null)
{
if (RepairItemsDictionary.TryGetValue(itemDef.itemIndex, out var value))
{
ItemDef itemDef2 = ItemCatalog.GetItemDef(value);
if ((Object)(object)itemDef2 != (Object)null)
{
self.correspondingScrapImage.sprite = itemDef2.pickupIconSprite;
}
}
return;
}
EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex);
if ((Object)(object)equipmentDef != (Object)null && RepairEquipmentsDictionary.TryGetValue(equipmentDef.equipmentIndex, out var value2))
{
EquipmentDef equipmentDef2 = EquipmentCatalog.GetEquipmentDef(value2);
if ((Object)(object)equipmentDef2 != (Object)null)
{
self.correspondingScrapImage.sprite = equipmentDef2.pickupIconSprite;
}
}
}
private void SceneDirector_onPostPopulateSceneServer(SceneDirector obj)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: 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)
if (ShrineOfRepairConfigManager.SpawnInMoon.Value)
{
if ((Object)(object)SceneCatalog.GetSceneDefForCurrentScene() == (Object)(object)SceneCatalog.GetSceneDefFromSceneName("moon"))
{
SpawnShrine(ShrineOfRepairConfigManager.MoonPosition.Value, ShrineOfRepairConfigManager.MoonAngle.Value);
}
else if ((Object)(object)SceneCatalog.GetSceneDefForCurrentScene() == (Object)(object)SceneCatalog.GetSceneDefFromSceneName("moon2"))
{
SpawnShrine(ShrineOfRepairConfigManager.Moon2Position.Value, ShrineOfRepairConfigManager.Moon2Angle.Value);
}
}
}
}
public class ShrineOfRepairPicker : ShrineOfRepairBase<ShrineOfRepairPicker>
{
public class ShrineRepairManager : NetworkBehaviour
{
public PickupPickerController pickupPickerController;
public Transform iconTransform;
[SyncVar]
public float coefficient;
private int uses;
private bool useLunarCoins;
private Interactor interactor;
private static int kRpcHandleInteractionClient;
private static int kRpcHandleDeactivateClient;
public void Start()
{
//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Expected O, but got Unknown
((UnityEvent<int>)(object)pickupPickerController.onPickupSelected).AddListener((UnityAction<int>)HandleSelection);
((UnityEvent<Interactor>)(object)pickupPickerController.onServerInteractionBegin).AddListener((UnityAction<Interactor>)HandleInteraction);
coefficient = Mathf.Pow(Run.instance.compensatedDifficultyCoefficient, 1.25f);
uses = 0;
SceneDef sceneDefForCurrentScene = SceneCatalog.GetSceneDefForCurrentScene();
useLunarCoins = ShrineOfRepairConfigManager.PickerUseLunarByDefault.Value || (ShrineOfRepairConfigManager.BazaarUseLunar.Value && (Object)(object)sceneDefForCurrentScene == (Object)(object)SceneCatalog.GetSceneDefFromSceneName("bazaar")) || (ShrineOfRepairConfigManager.UseLunarInMoon.Value && ((Object)(object)sceneDefForCurrentScene == (Object)(object)SceneCatalog.GetSceneDefFromSceneName("moon") || (Object)(object)sceneDefForCurrentScene == (Object)(object)SceneCatalog.GetSceneDefFromSceneName("moon2")));
PickupPickerPanel.OnCreateButton += (hook_OnCreateButton)delegate(orig_OnCreateButton orig, PickupPickerPanel self, int index, MPButton button)
{
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: 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_0164: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_019d: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: 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_024a: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, index, button);
if (((Object)self).name.Contains("ShrineRepair") && (Object)(object)self == (Object)(object)pickupPickerController.panelInstanceController)
{
CharacterBody component = ((Component)interactor).GetComponent<CharacterBody>();
CharacterMaster obj = (Object.op_Implicit((Object)(object)interactor) ? component.master : LocalUserManager.GetFirstLocalUser().cachedMasterController.master);
bool flag = component.GetBuffCount(Buffs.FreeUnlocks) > 0;
PickupDef pickupDef = PickupCatalog.GetPickupDef(self.pickerController.options[index].pickupIndex);
ShrineOfRepairBase<ShrineOfRepairPicker>.FillRepairItemsDictionary();
ItemIndex value;
bool flag2 = ShrineOfRepairBase<ShrineOfRepairPicker>.RepairItemsDictionary.TryGetValue(pickupDef.itemIndex, out value);
int itemCount = obj.inventory.GetItemCount(pickupDef.itemIndex);
ItemTier tier = ItemCatalog.GetItemDef(value).tier;
if (flag2 || ShrineOfRepairBase<ShrineOfRepairPicker>.RepairEquipmentsDictionary.ContainsKey(pickupDef.equipmentIndex))
{
ShrineOfRepairPlugin.MyLogger.LogMessage((object)$"Price for {pickupDef.nameToken}x{itemCount} is {(flag2 ? GetTotalStackCost(tier, itemCount) : GetEquipmentCost())}");
if (ShrineOfRepairConfigManager.PickerShowFree.Value || (flag2 ? GetTotalStackCost(tier, itemCount) : GetEquipmentCost()) != 0)
{
GameObject val = new GameObject("CostText");
val.transform.SetParent(((Component)button).transform);
val.layer = 5;
RectTransform val2 = val.AddComponent<RectTransform>();
HGTextMeshProUGUI val3 = val.AddComponent<HGTextMeshProUGUI>();
((TMP_Text)val3).enableWordWrapping = false;
((TMP_Text)val3).alignment = (TextAlignmentOptions)1026;
((TMP_Text)val3).fontSize = 20f;
((TMP_Text)val3).faceColor = Color32.op_Implicit(useLunarCoins ? Color.white : Color.yellow);
((TMP_Text)val3).outlineWidth = 0.2f;
if (flag)
{
((TMP_Text)val3).text = "FREE";
}
else
{
((TMP_Text)val3).text = (useLunarCoins ? "<sprite name=\"LunarCoin\" tint=1>" : "$") + (flag2 ? GetTotalStackCost(tier, itemCount) : GetEquipmentCost());
}
((Transform)val2).localPosition = Vector3.zero;
val2.anchorMin = Vector2.zero;
val2.anchorMax = Vector2.one;
((Transform)val2).localScale = Vector3.one;
val2.sizeDelta = new Vector2(-10f, -4f);
val2.anchoredPosition = Vector2.zero;
}
}
}
};
}
public void OnDestroy()
{
((UnityEvent<int>)(object)pickupPickerController.onPickupSelected).RemoveListener((UnityAction<int>)HandleSelection);
((UnityEvent<Interactor>)(object)pickupPickerController.onServerInteractionBegin).RemoveListener((UnityAction<Interactor>)HandleInteraction);
}
[Server]
public void HandleSelection(int selection)
{
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
//IL_01dc: 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_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: Unknown result type (might be due to invalid IL or missing references)
//IL_0213: Unknown result type (might be due to invalid IL or missing references)
//IL_0220: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0164: 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_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0187: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0304: Unknown result type (might be due to invalid IL or missing references)
//IL_0310: Unknown result type (might be due to invalid IL or missing references)
//IL_031a: Unknown result type (might be due to invalid IL or missing references)
//IL_031b: Unknown result type (might be due to invalid IL or missing references)
//IL_0320: Unknown result type (might be due to invalid IL or missing references)
//IL_0325: Unknown result type (might be due to invalid IL or missing references)
//IL_0330: Unknown result type (might be due to invalid IL or missing references)
//IL_0331: Unknown result type (might be due to invalid IL or missing references)
//IL_0336: Unknown result type (might be due to invalid IL or missing references)
//IL_033b: Unknown result type (might be due to invalid IL or missing references)
//IL_0346: Expected O, but got Unknown
//IL_0346: Unknown result type (might be due to invalid IL or missing references)
//IL_034d: Expected O, but got Unknown
CallRpcHandleInteractionClient();
if (!NetworkServer.active)
{
ShrineOfRepairPlugin.MyLogger.LogWarning((object)"[Server] function 'ShrineOfRepair.Interactables.ShrineOfRepairManager::HandleSelection(int)' called on client");
return;
}
ShrineOfRepairPlugin.MyLogger.LogMessage((object)("Selected " + selection));
if (!Object.op_Implicit((Object)(object)interactor))
{
return;
}
PickupDef pickupDef = PickupCatalog.GetPickupDef(new PickupIndex(selection));
CharacterBody component = ((Component)interactor).GetComponent<CharacterBody>();
bool flag = component.GetBuffCount(Buffs.FreeUnlocks) > 0;
int itemCount = component.inventory.GetItemCount(pickupDef.itemIndex);
ShrineOfRepairBase<ShrineOfRepairPicker>.FillRepairItemsDictionary();
ItemIndex value;
bool flag2 = ShrineOfRepairBase<ShrineOfRepairPicker>.RepairItemsDictionary.TryGetValue(pickupDef.itemIndex, out value);
ItemTier tier = ItemCatalog.GetItemDef(value).tier;
if (!flag2 && !ShrineOfRepairBase<ShrineOfRepairPicker>.RepairEquipmentsDictionary.ContainsKey(pickupDef.equipmentIndex))
{
return;
}
uint num = (flag2 ? GetTotalStackCost(tier, itemCount) : GetEquipmentCost());
if (num > (useLunarCoins ? component.master.playerCharacterMasterController.networkUser.lunarCoins : component.master.money) && !flag)
{
ShrineOfRepairPlugin.MyLogger.LogWarning((object)$"Somehow player {component.GetUserName()} ({((Object)component).name}) has less currency than price of {pickupDef.nameToken}x{itemCount}, yet it was available at the start of interaction. Doing nothing...");
return;
}
string colorHexString;
string @string;
string text;
if (flag2)
{
component.inventory.RemoveItem(pickupDef.itemIndex, itemCount);
component.inventory.GiveItem(value, itemCount);
CharacterMasterNotificationQueue.SendTransformNotification(component.master, pickupDef.itemIndex, value, (TransformationType)0);
colorHexString = ColorCatalog.GetColorHexString(ItemTierCatalog.GetItemTierDef(tier).colorIndex);
@string = Language.GetString(ItemCatalog.GetItemDef(value).nameToken);
text = ((itemCount == 1) ? "" : ("<style=\"cEvent\">(" + itemCount + ")</style>"));
}
else
{
component.inventory.SetEquipmentIndex(ShrineOfRepairBase<ShrineOfRepairPicker>.RepairEquipmentsDictionary[pickupDef.equipmentIndex]);
CharacterMasterNotificationQueue.PushEquipmentTransformNotification(component.master, pickupDef.equipmentIndex, ShrineOfRepairBase<ShrineOfRepairPicker>.RepairEquipmentsDictionary[pickupDef.equipmentIndex], (TransformationType)0);
colorHexString = ColorCatalog.GetColorHexString(EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex).colorIndex);
@string = Language.GetString(EquipmentCatalog.GetEquipmentDef(pickupDef.equipmentIndex).nameToken);
text = "";
}
if (flag)
{
component.RemoveBuff(Buffs.FreeUnlocks);
Util.PlaySound("Play_item_proc_onLevelUpFreeUnlock_activate", ((Component)this).gameObject);
}
else
{
if (useLunarCoins)
{
component.master.playerCharacterMasterController.networkUser.DeductLunarCoins(num);
}
else
{
CharacterMaster master = component.master;
master.money -= num;
}
ShrineOfRepairPlugin.MyLogger.LogMessage((object)string.Format("Player {0} ({1}) paid {2} {3} to repair {4}x{5}", component.GetUserName(), ((Object)component).name, num, useLunarCoins ? "lunar coins" : "money", pickupDef.nameToken, itemCount));
}
EffectManager.SpawnEffect(Resources.Load<GameObject>("Prefabs/Effects/ShrineUseEffect"), new EffectData
{
origin = ((Component)this).gameObject.transform.position,
rotation = Quaternion.identity,
scale = 1f,
color = Color32.op_Implicit(Color.red)
}, true);
SubjectFormatChatMessage val = new SubjectFormatChatMessage();
((SubjectChatMessage)val).subjectAsCharacterBody = component;
((SubjectChatMessage)val).baseToken = "INTERACTABLE_SHRINE_REPAIR_INTERACT_PICKER";
val.paramTokens = new string[2]
{
"<color=#" + colorHexString + ">" + @string + "</color>",
text
};
Chat.SendBroadcastChat((ChatMessageBase)(object)val);
Object.Destroy((Object)(object)pickupPickerController.panelInstance);
uses++;
if (uses == ShrineOfRepairConfigManager.MaxUses.Value)
{
CallRpcHandleDeactivateClient();
pickupPickerController.SetAvailable(false);
((Component)iconTransform).gameObject.SetActive(false);
}
}
[Server]
public void HandleInteraction(Interactor interactor)
{
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: 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_0165: Unknown result type (might be due to invalid IL or missing references)
if (!NetworkServer.active)
{
ShrineOfRepairPlugin.MyLogger.LogWarning((object)"[Server] function 'ShrineOfRepair.Interactables.ShrineOfRepairManager::HandleInteraction(RoR2.Interactor)' called on client");
return;
}
this.interactor = interactor;
List<Option> list = new List<Option>();
CharacterBody component = ((Component)interactor).GetComponent<CharacterBody>();
bool flag = component.GetBuffCount(Buffs.FreeUnlocks) > 0;
if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.master))
{
return;
}
uint num = (useLunarCoins ? component.master.playerCharacterMasterController.networkUser.lunarCoins : component.master.money);
ShrineOfRepairBase<ShrineOfRepairPicker>.FillRepairItemsDictionary();
foreach (KeyValuePair<ItemIndex, ItemIndex> item in ShrineOfRepairBase<ShrineOfRepairPicker>.RepairItemsDictionary)
{
int itemCount = component.inventory.GetItemCount(item.Key);
if (itemCount > 0)
{
list.Add(new Option
{
available = (num >= GetTotalStackCost(ItemCatalog.GetItemDef(item.Value).tier, itemCount) || flag),
pickupIndex = PickupCatalog.FindPickupIndex(item.Key)
});
}
}
if (ShrineOfRepairBase<ShrineOfRepairPicker>.RepairEquipmentsDictionary.ContainsKey(component.equipmentSlot.equipmentIndex))
{
list.Add(new Option
{
available = (num >= GetEquipmentCost() || flag),
pickupIndex = PickupCatalog.FindPickupIndex(component.equipmentSlot.equipmentIndex)
});
}
pickupPickerController.SetOptionsServer(list.ToArray());
}
private int GetCostFromItemTier(ItemTier tier)
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Expected I4, but got Unknown
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if (BubbetItemsCompat.enabled && BubbetItemsCompat.IsVoidLunar(tier))
{
return ShrineOfRepairConfigManager.PickerPanelGoldLunarCost.Value;
}
switch ((int)tier)
{
case 0:
case 6:
return ShrineOfRepairConfigManager.PickerPanelGoldTier1Cost.Value;
default:
return ShrineOfRepairConfigManager.PickerPanelGoldTier2Cost.Value;
case 2:
case 8:
return ShrineOfRepairConfigManager.PickerPanelGoldTier3Cost.Value;
case 4:
case 9:
return ShrineOfRepairConfigManager.PickerPanelGoldBossCost.Value;
case 3:
return ShrineOfRepairConfigManager.PickerPanelGoldLunarCost.Value;
}
}
private uint GetTotalStackCost(ItemTier tier, int numberOfItems)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
if (GetCostFromItemTier(tier) <= 0)
{
return 0u;
}
uint num = (uint)((float)(GetCostFromItemTier(tier) * numberOfItems) * (useLunarCoins ? ShrineOfRepairConfigManager.BazaarLunarMultiplier.Value : coefficient));
if (num == 0)
{
return 1u;
}
return num;
}
private uint GetEquipmentCost()
{
if (ShrineOfRepairConfigManager.PickerPanelGoldEquipCost.Value <= 0)
{
return 0u;
}
uint num = (uint)((float)ShrineOfRepairConfigManager.PickerPanelGoldEquipCost.Value * (useLunarCoins ? ShrineOfRepairConfigManager.BazaarLunarMultiplier.Value : coefficient));
if (num == 0)
{
return 1u;
}
return num;
}
private void CallRpcHandleInteractionClient()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
if (!NetworkServer.active)
{
ShrineOfRepairPlugin.MyLogger.LogWarning((object)"RPC Function CallRpcHandleInteractionClient called on client.");
return;
}
ShrineOfRepairPlugin.MyLogger.LogMessage((object)"RPC Function CallRpcHandleInteractionClient, sending message to clients");
NetworkWriter val = new NetworkWriter();
val.Write((short)0);
val.Write((short)2);
val.WritePackedUInt32((uint)kRpcHandleInteractionClient);
val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
((NetworkBehaviour)this).SendRPCInternal(val, 0, "RpcHandleInteractionClient");
}
private void CallRpcHandleDeactivateClient()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
if (!NetworkServer.active)
{
ShrineOfRepairPlugin.MyLogger.LogWarning((object)"RPC Function CallRpcHandleDeactivateClient called on client.");
return;
}
ShrineOfRepairPlugin.MyLogger.LogMessage((object)"RPC Function CallRpcHandleDeactivateClient, sending message to clients");
NetworkWriter val = new NetworkWriter();
val.Write((short)0);
val.Write((short)2);
val.WritePackedUInt32((uint)kRpcHandleDeactivateClient);
val.Write(((Component)this).GetComponent<NetworkIdentity>().netId);
((NetworkBehaviour)this).SendRPCInternal(val, 0, "RpcHandleDeactivateClient");
}
protected static void InvokeRpcHandleInteractionClient(NetworkBehaviour obj, NetworkReader reader)
{
if (!NetworkClient.active)
{
ShrineOfRepairPlugin.MyLogger.LogWarning((object)"RPC RpcHandleInteractionClient called on server.");
}
else
{
((ShrineRepairManager)(object)obj).RpcHandleInteactionClient();
}
}
protected static void InvokeRpcHandleDeactivateClient(NetworkBehaviour obj, NetworkReader reader)
{
if (!NetworkClient.active)
{
ShrineOfRepairPlugin.MyLogger.LogWarning((object)"RPC RpcHandleDeactivateClient called on server.");
}
else
{
((ShrineRepairManager)(object)obj).RpcHandleDeactivateClient();
}
}
[ClientRpc]
public void RpcHandleInteactionClient()
{
ShrineOfRepairPlugin.MyLogger.LogMessage((object)"RPC RpcHandleInteactionClient message recieved");
if (Object.op_Implicit((Object)(object)pickupPickerController) && Object.op_Implicit((Object)(object)pickupPickerController.panelInstance))
{
Object.Destroy((Object)(object)pickupPickerController.panelInstance);
}
}
[ClientRpc]
public void RpcHandleDeactivateClient()
{
ShrineOfRepairPlugin.MyLogger.LogMessage((object)"RPC RpcHandleDeactivateClient message recieved");
if (Object.op_Implicit((Object)(object)iconTransform))
{
((Component)iconTransform).gameObject.SetActive(false);
}
if (Object.op_Implicit((Object)(object)pickupPickerController))
{
pickupPickerController.available = false;
}
}
static ShrineRepairManager()
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Expected O, but got Unknown
kRpcHandleInteractionClient = 1268743049;
NetworkBehaviour.RegisterRpcDelegate(typeof(ShrineRepairManager), kRpcHandleInteractionClient, new CmdDelegate(InvokeRpcHandleInteractionClient));
kRpcHandleDeactivateClient = 1631732147;
NetworkBehaviour.RegisterRpcDelegate(typeof(ShrineRepairManager), kRpcHandleDeactivateClient, new CmdDelegate(InvokeRpcHandleDeactivateClient));
NetworkCRC.RegisterBehaviour("ShrineRepairManager", 0);
}
}
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static Func<MeshRenderer, bool> <>9__1_0;
public static hook_Awake <>9__2_0;
public static hook_GetInteractability <>9__2_1;
internal bool <CreateInteractable>b__1_0(MeshRenderer x)
{
return ((Object)((Component)x).gameObject).name.Contains("mdlRepairShrine");
}
internal void <Hooks>b__2_0(orig_Awake orig, PickupPickerPanel self)
{
orig.Invoke(self);
if (!((Object)self).name.Contains("ShrineRepair"))
{
return;
}
Transform val = ((Component)self).transform.Find("MainPanel");
if (!((Object)(object)val != (Object)null))
{
return;
}
Transform val2 = ((Component)val).transform.Find("Juice");
if (!((Object)(object)val2 != (Object)null))
{
return;
}
Transform val3 = ((Component)val2).transform.Find("Label");
if ((Object)(object)val3 != (Object)null)
{
LanguageTextMeshController component = ((Component)val3).GetComponent<LanguageTextMeshController>();
if ((Object)(object)component != (Object)null)
{
component.token = "INTERACTABLE_SHRINE_REPAIR_PICKERPANEL_HEADER";
component.ResolveString();
}
}
}
internal Interactability <Hooks>b__2_1(orig_GetInteractability orig, PickupPickerController self, Interactor activator)
{
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
if (((Object)self).name.Contains("ShrineRepair") && Object.op_Implicit((Object)(object)activator))
{
CharacterBody component = ((Component)activator).GetComponent<CharacterBody>();
if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.master))
{
bool flag = false;
ShrineOfRepairBase<ShrineOfRepairPicker>.FillRepairItemsDictionary();
foreach (KeyValuePair<ItemIndex, ItemIndex> item in ShrineOfRepairBase<ShrineOfRepairPicker>.RepairItemsDictionary)
{
if (component.inventory.GetItemCount(item.Key) > 0)
{
flag = true;
}
}
foreach (KeyValuePair<EquipmentIndex, EquipmentIndex> item2 in ShrineOfRepairBase<ShrineOfRepairPicker>.RepairEquipmentsDictionary)
{
if (component.equipmentSlot.equipmentIndex == item2.Key)
{
flag = true;
}
}
if (!flag)
{
return (Interactability)1;
}
}
}
return orig.Invoke(self, activator);
}
}
public override void Init()
{
if (ShrineOfRepairConfigManager.UsePickupPickerPanel.Value)
{
CreateInteractables();
Hooks();
}
}
internal override GameObject CreateInteractable(GameObject InteractableModel)
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Expected O, but got Unknown
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
InteractableModel.AddComponent<NetworkIdentity>();
PickupPickerController val = InteractableModel.AddComponent<PickupPickerController>();
val.contextString = "INTERACTABLE_" + InteractableLangToken + "_CONTEXT";
GameObject val2 = PrefabAPI.InstantiateClone(Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Scrapper/ScrapperPickerPanel.prefab").WaitForCompletion(), "ShrineRepairPickerPanel");
val2.AddComponent<NetworkIdentity>();
val.panelPrefab = val2;
val.cutoffDistance = 10f;
InteractableModel.AddComponent<PingInfoProvider>().pingIconOverride = ShrineofRepairAssets.MainBundle.LoadAsset<Sprite>("Assets/RoR2/Base/Common/MiscIcons/texShrineIconOutlined.png");
InteractableModel.AddComponent<GenericDisplayNameProvider>().displayToken = "INTERACTABLE_" + InteractableLangToken + "_NAME";
((Component)InteractableModel.GetComponentInChildren<MeshCollider>()).gameObject.AddComponent<EntityLocator>().entity = InteractableModel;
ModelLocator obj = InteractableModel.AddComponent<ModelLocator>();
obj.modelTransform = InteractableModel.transform.Find("mdlRepairShrine");
obj.modelBaseTransform = InteractableModel.transform.Find("Base");
obj.dontDetatchFromParent = true;
obj.autoUpdateModelTransform = true;
Highlight obj2 = InteractableModel.AddComponent<Highlight>();
obj2.targetRenderer = (Renderer)(object)(from x in InteractableModel.GetComponentsInChildren<MeshRenderer>()
where ((Object)((Component)x).gameObject).name.Contains("mdlRepairShrine")
select x).First();
obj2.strength = 1f;
obj2.highlightColor = (HighlightColor)0;
Transform val3 = InteractableModel.transform.Find("Icon");
((Component)val3).gameObject.AddComponent<Billboard>();
Material material = ((Renderer)((Component)LegacyResourcesAPI.Load<SpawnCard>("spawncards/interactablespawncard/iscShrineBoss").prefab.transform.Find("Symbol")).GetComponent<MeshRenderer>()).material;
SpriteRenderer component = ((Component)val3).GetComponent<SpriteRenderer>();
Texture mainTexture = ((Renderer)component).material.mainTexture;
Color color = component.color;
((Renderer)component).material = new Material(material.shader);
((Renderer)component).material.CopyPropertiesFromMaterial(material);
((Renderer)component).material.mainTexture = mainTexture;
((Renderer)component).material.SetColor("_TintColor", color);
ShrineRepairManager shrineRepairManager = InteractableModel.AddComponent<ShrineRepairManager>();
shrineRepairManager.pickupPickerController = val;
shrineRepairManager.iconTransform = val3;
PrefabAPI.RegisterNetworkPrefab(InteractableModel);
return InteractableModel;
}
protected override void Hooks()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
//IL_003e: 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_0049: Expected O, but got Unknown
base.Hooks();
object obj = <>c.<>9__2_0;
if (obj == null)
{
hook_Awake val = delegate(orig_Awake orig, PickupPickerPanel self)
{
orig.Invoke(self);
if (((Object)self).name.Contains("ShrineRepair"))
{
Transform val3 = ((Component)self).transform.Find("MainPanel");
if ((Object)(object)val3 != (Object)null)
{
Transform val4 = ((Component)val3).transform.Find("Juice");
if ((Object)(object)val4 != (Object)null)
{
Transform val5 = ((Component)val4).transform.Find("Label");
if ((Object)(object)val5 != (Object)null)
{
LanguageTextMeshController component2 = ((Component)val5).GetComponent<LanguageTextMeshController>();
if ((Object)(object)component2 != (Object)null)
{
component2.token = "INTERACTABLE_SHRINE_REPAIR_PICKERPANEL_HEADER";
component2.ResolveString();
}
}
}
}
}
};
<>c.<>9__2_0 = val;
obj = (object)val;
}
PickupPickerPanel.Awake += (hook_Awake)obj;
object obj2 = <>c.<>9__2_1;
if (obj2 == null)
{
hook_GetInteractability val2 = delegate(orig_GetInteractability orig, PickupPickerController self, Interactor activator)
{
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
if (((Object)self).name.Contains("ShrineRepair") && Object.op_Implicit((Object)(object)activator))
{
CharacterBody component = ((Component)activator).GetComponent<CharacterBody>();
if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.master))
{
bool flag = false;
ShrineOfRepairBase<ShrineOfRepairPicker>.FillRepairItemsDictionary();
foreach (KeyValuePair<ItemIndex, ItemIndex> item in ShrineOfRepairBase<ShrineOfRepairPicker>.RepairItemsDictionary)
{
if (component.inventory.GetItemCount(item.Key) > 0)
{
flag = true;
}
}
foreach (KeyValuePair<EquipmentIndex, EquipmentIndex> item2 in ShrineOfRepairBase<ShrineOfRepairPicker>.RepairEquipmentsDictionary)
{
if (component.equipmentSlot.equipmentIndex == item2.Key)
{
flag = true;
}
}
if (!flag)
{
return (Interactability)1;
}
}
}
return orig.Invoke(self, activator);
};
<>c.<>9__2_1 = val2;
obj2 = (object)val2;
}
PickupPickerController.GetInteractability += (hook_GetInteractability)obj2;
}
}
public class ShrineOfRepairPurchase : ShrineOfRepairBase<ShrineOfRepairPurchase>
{
public enum CostTypes
{
Gold,
VoidCoin,
LunarCoin
}
public class RepairShrineManager : NetworkBehaviour
{
public PurchaseInteraction PurchaseInteraction;
public float ScalingModifier;
public bool UseDefaultScaling;
[SyncVar]
public int BaseCostDetermination;
public int uses;
public void Start()
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Invalid comparison between Unknown and I4
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
if (NetworkServer.active && Object.op_Implicit((Object)(object)Run.instance))
{
PurchaseInteraction.SetAvailable(true);
}
((UnityEvent<Interactor>)(object)PurchaseInteraction.onPurchase).AddListener((UnityAction<Interactor>)RepairPurchaseAttempt);
if ((int)PurchaseInteraction.costType == 1)
{
SceneDef sceneDefForCurrentScene = SceneCatalog.GetSceneDefForCurrentScene();
if ((Object)(object)sceneDefForCurrentScene == (Object)(object)SceneCatalog.GetSceneDefFromSceneName("bazaar") || (ShrineOfRepairConfigManager.UseLunarInMoon.Value && ((Object)(object)sceneDefForCurrentScene == (Object)(object)SceneCatalog.GetSceneDefFromSceneName("moon") || (Object)(object)sceneDefForCurrentScene == (Object)(object)SceneCatalog.GetSceneDefFromSceneName("moon2"))))
{
PurchaseInteraction.costType = (CostTypeIndex)3;
PurchaseInteraction.automaticallyScaleCostWithDifficulty = false;
BaseCostDetermination = ShrineOfRepairConfigManager.PurchaseInteractionLunarCoinCost.Value;
PurchaseInteraction.cost = BaseCostDetermination;
}
else
{
BaseCostDetermination = (UseDefaultScaling ? ((int)((float)PurchaseInteraction.cost * ScalingModifier)) : ((int)(Mathf.Pow(Run.instance.compensatedDifficultyCoefficient, ScalingModifier) * (float)PurchaseInteraction.cost)));
PurchaseInteraction.cost = BaseCostDetermination;
}
}
else
{
BaseCostDetermination = PurchaseInteraction.cost;
PurchaseInteraction.cost = BaseCostDetermination;
}
uses = 0;
}
[Server]
public void RepairPurchaseAttempt(Interactor interactor)
{
//IL_0066: 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_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0135: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//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_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_0162: 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_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Expected O, but got Unknown
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_00f0: 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_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Expected O, but got Unknown
if (!NetworkServer.active)
{
ShrineOfRepairPlugin.MyLogger.LogWarning((object)"[Server] function 'ShrineOfRepair.Interactables.ShrineOfRepair::RepairPurchaseAttempt(RoR2.Interactor)' called on client");
}
else
{
if (!Object.op_Implicit((Object)(object)interactor))
{
return;
}
CharacterBody component = ((Component)interactor).GetComponent<CharacterBody>();
if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.master))
{
return;
}
Inventory inventory = component.inventory;
ShrineOfRepairBase<ShrineOfRepairPurchase>.FillRepairItemsDictionary();
foreach (KeyValuePair<ItemIndex, ItemIndex> item in ShrineOfRepairBase<ShrineOfRepairPurchase>.RepairItemsDictionary)
{
int itemCount = inventory.GetItemCount(item.Key);
if (itemCount > 0)
{
inventory.RemoveItem(item.Key, itemCount);
inventory.GiveItem(item.Value, itemCount);
CharacterMasterNotificationQueue.SendTransformNotification(component.master, item.Key, item.Value, (TransformationType)0);
}
}
if (ShrineOfRepairBase<ShrineOfRepairPurchase>.RepairEquipmentsDictionary.ContainsKey(component.equipmentSlot.equipmentIndex))
{
inventory.SetEquipmentIndex(ShrineOfRepairBase<ShrineOfRepairPurchase>.RepairEquipmentsDictionary[component.equipmentSlot.equipmentIndex]);
CharacterMasterNotificationQueue.PushEquipmentTransformNotification(component.master, component.equipmentSlot.equipmentIndex, ShrineOfRepairBase<ShrineOfRepairPurchase>.RepairEquipmentsDictionary[component.equipmentSlot.equipmentIndex], (TransformationType)0);
}
EffectManager.SpawnEffect(Resources.Load<GameObject>("Prefabs/Effects/ShrineUseEffect"), new EffectData
{
origin = ((Component)this).gameObject.transform.position,
rotation = Quaternion.identity,
scale = 1f,
color = Color32.op_Implicit(Color.red)
}, true);
uses++;
if (uses == ShrineOfRepairConfigManager.MaxUses.Value)
{
((Component)((Component)this).gameObject.transform.Find("Icon")).gameObject.SetActive(false);
}
Chat.SendBroadcastChat((ChatMessageBase)new SubjectFormatChatMessage
{
subjectAsCharacterBody = ((Component)interactor).GetComponent<CharacterBody>(),
baseToken = "INTERACTABLE_SHRINE_REPAIR_INTERACT"
});
if (NetworkServer.active && uses == ShrineOfRepairConfigManager.MaxUses.Value)
{
PurchaseInteraction.SetAvailable(false);
}
}
}
}
public override void Init()
{
if (!ShrineOfRepairConfigManager.UsePickupPickerPanel.Value)
{
CreateInteractables();
Hooks();
}
}
internal override GameObject CreateInteractable(GameObject InteractableModel)
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: 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_024d: Expected O, but got Unknown
//IL_026f: Unknown result type (might be due to invalid IL or missing references)
InteractableModel.AddComponent<NetworkIdentity>();
PurchaseInteraction val = InteractableModel.AddComponent<PurchaseInteraction>();
val.displayNameToken = "INTERACTABLE_" + InteractableLangToken + "_NAME";
val.contextToken = "INTERACTABLE_" + InteractableLangToken + "_CONTEXT";
val.costType = GetCostTypeFromConfig(ShrineOfRepairConfigManager.PurchaseInteractionCurrencyType.Value);
val.automaticallyScaleCostWithDifficulty = ShrineOfRepairConfigManager.PurchaseInteractionCurrencyType.Value == CostTypes.Gold && ShrineOfRepairConfigManager.PurchaseInteractionGoldUseDefaultScaling.Value;
val.cost = GetCostValueFromConfig(ShrineOfRepairConfigManager.PurchaseInteractionCurrencyType.Value);
val.available = true;
val.setUnavailableOnTeleporterActivated = false;
val.isShrine = true;
val.isGoldShrine = false;
InteractableModel.AddComponent<PingInfoProvider>().pingIconOverride = ShrineofRepairAssets.MainBundle.LoadAsset<Sprite>("Assets/RoR2/Base/Common/MiscIcons/texShrineIconOutlined.png");
InteractableModel.AddComponent<GenericDisplayNameProvider>().displayToken = "INTERACTABLE_" + InteractableLangToken + "_NAME";
RepairShrineManager repairShrineManager = InteractableModel.AddComponent<RepairShrineManager>();
repairShrineManager.PurchaseInteraction = val;
repairShrineManager.ScalingModifier = ShrineOfRepairConfigManager.PurchaseInteractionGoldScalingModifier.Value;
repairShrineManager.UseDefaultScaling = ShrineOfRepairConfigManager.PurchaseInteractionGoldUseDefaultScaling.Value;
((Component)InteractableModel.GetComponentInChildren<MeshCollider>()).gameObject.AddComponent<EntityLocator>().entity = InteractableModel;
ModelLocator obj = InteractableModel.AddComponent<ModelLocator>();
obj.modelTransform = InteractableModel.transform.Find("mdlRepairShrine");
obj.modelBaseTransform = InteractableModel.transform.Find("Base");
obj.dontDetatchFromParent = true;
obj.autoUpdateModelTransform = true;
HologramProjector obj2 = InteractableModel.AddComponent<HologramProjector>();
obj2.hologramPivot = InteractableModel.transform.Find("HologramPivot");
obj2.displayDistance = 10f;
obj2.disableHologramRotation = false;
Highlight component = InteractableModel.GetComponent<Highlight>();
component.targetRenderer = (Renderer)(object)(from x in InteractableModel.GetComponentsInChildren<MeshRenderer>()
where ((Object)((Component)x).gameObject).name.Contains("mdlRepairShrine")
select x).First();
component.strength = 1f;
component.highlightColor = (HighlightColor)0;
Transform obj3 = InteractableModel.transform.Find("Icon");
((Component)obj3).gameObject.AddComponent<Billboard>();
Material material = ((Renderer)((Component)LegacyResourcesAPI.Load<SpawnCard>("spawncards/interactablespawncard/iscShrineBoss").prefab.transform.Find("Symbol")).GetComponent<MeshRenderer>()).material;
SpriteRenderer component2 = ((Component)obj3).GetComponent<SpriteRenderer>();
Texture mainTexture = ((Renderer)component2).material.mainTexture;
Color color = component2.color;
((Renderer)component2).material = new Material(material.shader);
((Renderer)component2).material.CopyPropertiesFromMaterial(material);
((Renderer)component2).material.mainTexture = mainTexture;
((Renderer)component2).material.SetColor("_TintColor", color);
PrefabAPI.RegisterNetworkPrefab(InteractableModel);
return InteractableModel;
}
private CostTypeIndex GetCostTypeFromConfig(CostTypes currency)
{
switch (currency)
{
case CostTypes.LunarCoin:
if (ShrineOfRepairConfigManager.PurchaseInteractionLunarCoinCost.Value != 0)
{
return (CostTypeIndex)3;
}
return (CostTypeIndex)0;
case CostTypes.VoidCoin:
if (ShrineOfRepairConfigManager.PurchaseInteractionVoidCoinCost.Value != 0)
{
return (CostTypeIndex)14;
}
return (CostTypeIndex)0;
default:
if (ShrineOfRepairConfigManager.PurchaseInteractionGoldBaseCost.Value != 0)
{
return (CostTypeIndex)1;
}
return (CostTypeIndex)0;
}
}
private int GetCostValueFromConfig(CostTypes currency)
{
return currency switch
{
CostTypes.LunarCoin => ShrineOfRepairConfigManager.PurchaseInteractionLunarCoinCost.Value,
CostTypes.VoidCoin => ShrineOfRepairConfigManager.PurchaseInteractionVoidCoinCost.Value,
_ => ShrineOfRepairConfigManager.PurchaseInteractionGoldBaseCost.Value,
};
}
protected override void Hooks()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
base.Hooks();
PurchaseInteraction.GetInteractability += (hook_GetInteractability)delegate(orig_GetInteractability orig, PurchaseInteraction self, Interactor activator)
{
//IL_00b9: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
if (self.displayNameToken == "INTERACTABLE_" + InteractableLangToken + "_NAME" && Object.op_Implicit((Object)(object)activator))
{
CharacterBody component = ((Component)activator).GetComponent<CharacterBody>();
if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.master))
{
bool flag = false;
ShrineOfRepairBase<ShrineOfRepairPurchase>.FillRepairItemsDictionary();
foreach (KeyValuePair<ItemIndex, ItemIndex> item in ShrineOfRepairBase<ShrineOfRepairPurchase>.RepairItemsDictionary)
{
if (component.inventory.GetItemCount(item.Key) > 0)
{
flag = true;
}
}
if (ShrineOfRepairBase<ShrineOfRepairPurchase>.RepairEquipmentsDictionary.ContainsKey(component.equipmentSlot.equipmentIndex))
{
flag = true;
}
if (!flag)
{
return (Interactability)1;
}
}
}
return orig.Invoke(self, activator);
};
}
}
}