using System;
using System.Collections.Generic;
using System.Diagnostics;
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.Configuration;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API.Utils;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GotSaleStarred")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("GotSaleStarred")]
[assembly: AssemblyTitle("GotSaleStarred")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace GotSaleStarred
{
[BepInPlugin("GiGaGon.GotSaleStarred", "GotSaleStarred", "1.0.0")]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class GotSaleStarred : BaseUnityPlugin
{
internal class ModConfig
{
public static ConfigEntry<bool> toggleMod;
public static ConfigEntry<string> saleStaredMessage;
public static ConfigEntry<string> guaranteedLegendaryStages;
public static ConfigEntry<string> smallChestList;
public static ConfigEntry<string> largeChestList;
public static ConfigEntry<string> legendaryChestList;
public static string[] split_guaranteed_legendary_stages;
public static string[] split_small_chest_list;
public static string[] split_large_chest_list;
public static string[] split_legendary_chest_list;
public static void InitConfig(ConfigFile config)
{
toggleMod = config.Bind<bool>("General", "Toggle Mod", true, "Set to false to disable all mod functionality");
saleStaredMessage = config.Bind<string>("General", "Sale Stared Message", "<color=#ffff00>{player_name}</color> got <color=#00ff00>Sale Star</color>'d", "Message that gets sent in chat when a person gets Sale Stared. {player_name} is replaced with the name of the player");
guaranteedLegendaryStages = config.Bind<string>("General", "Guaranteed Legendary Stages", "rootjungle,dampcavesimple", "Comma seperated, no spaces list of all the stages with guaranteed legendary chests");
smallChestList = config.Bind<string>("General", "Small Chest List", "CategoryChestDamage,CategoryChestHealing,CategoryChestUtility,Chest1,Chest1Stealthed,EquipmentBarrel", "Comma seperated, no spaces list of all the small chest names that trigger the message");
largeChestList = config.Bind<string>("General", "Large Chest List", "CategoryChest2Damage,CategoryChest2Healing,CategoryChest2Utility,Chest2,CasinoChest", "Comma seperated, no spaces list of all the large chest names that trigger the message");
legendaryChestList = config.Bind<string>("General", "Legendary Chest List", "GoldChest", "Comma seperated, no spaces list of all the legendary chest names that trigger the message");
}
public static void Reload()
{
((BaseUnityPlugin)instance).Config.Reload();
split_guaranteed_legendary_stages = guaranteedLegendaryStages.Value.Split(',');
split_small_chest_list = smallChestList.Value.Split(',');
split_large_chest_list = largeChestList.Value.Split(',');
split_legendary_chest_list = legendaryChestList.Value.Split(',');
}
}
public static GotSaleStarred instance;
public const string PluginGUID = "GiGaGon.GotSaleStarred";
public const string PluginAuthor = "GiGaGon";
public const string PluginName = "GotSaleStarred";
public const string PluginVersion = "1.0.0";
public static bool legendaryOpened;
public void Awake()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Expected O, but got Unknown
instance = this;
ModConfig.InitConfig(((BaseUnityPlugin)this).Config);
PurchaseInteraction.OnInteractionBegin += new hook_OnInteractionBegin(HookOnInteractionBegin);
Run.OnServerSceneChanged += new hook_OnServerSceneChanged(HookOnServerSceneChanged);
}
public void OnDestroy()
{
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Expected O, but got Unknown
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
PurchaseInteraction.OnInteractionBegin -= new hook_OnInteractionBegin(HookOnInteractionBegin);
Run.OnServerSceneChanged -= new hook_OnServerSceneChanged(HookOnServerSceneChanged);
}
internal void HookOnServerSceneChanged(orig_OnServerSceneChanged orig, Run self, string sceneName)
{
legendaryOpened = false;
orig.Invoke(self, sceneName);
}
internal void HookOnInteractionBegin(orig_OnInteractionBegin orig, PurchaseInteraction self, Interactor activator)
{
//IL_015b: 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_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: 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)
ModConfig.Reload();
if (!ModConfig.toggleMod.Value)
{
orig.Invoke(self, activator);
return;
}
if (!NetworkServer.active)
{
orig.Invoke(self, activator);
return;
}
if (!self.CanBeAffordedByInteractor(activator))
{
orig.Invoke(self, activator);
return;
}
string name = ((Object)self).name;
if (name == null)
{
orig.Invoke(self, activator);
return;
}
name = name.Replace("(Clone)", "");
if (!legendaryOpened && ModConfig.split_legendary_chest_list.Contains(name))
{
legendaryOpened = true;
orig.Invoke(self, activator);
return;
}
CharacterBody component = ((Component)activator).GetComponent<CharacterBody>();
if ((Object)(object)component == (Object)null)
{
orig.Invoke(self, activator);
return;
}
if ((Object)(object)component.inventory == (Object)null || component.inventory.GetItemCount(Items.LowerPricedChests) < 1 || (Object)(object)self == (Object)null || !self.saleStarCompatible)
{
orig.Invoke(self, activator);
return;
}
string userName = component.GetUserName();
if (userName == null)
{
orig.Invoke(self, activator);
return;
}
if (!legendaryOpened)
{
SceneManager.GetActiveScene();
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name != null)
{
string[] split_guaranteed_legendary_stages = ModConfig.split_guaranteed_legendary_stages;
activeScene = SceneManager.GetActiveScene();
if (split_guaranteed_legendary_stages.Contains(((Scene)(ref activeScene)).name) && !ModConfig.split_legendary_chest_list.Contains(name))
{
SaleStared(userName);
orig.Invoke(self, activator);
return;
}
}
}
List<string> list = (from x in Object.FindObjectsOfType<PurchaseInteraction>()
where (Object)(object)x != (Object)null && x.available
select ((Object)x).name.Replace("(Clone)", "")).ToList();
if (component.inventory.GetItemCount(Items.TreasureCache) > 0 && ModConfig.split_small_chest_list.Contains(name) && list.Contains("Lockbox"))
{
SaleStared(userName);
orig.Invoke(self, activator);
}
else if (ModConfig.split_small_chest_list.Contains(name) && list.Any((string x) => ModConfig.split_large_chest_list.Contains(x)))
{
SaleStared(userName);
orig.Invoke(self, activator);
}
else
{
orig.Invoke(self, activator);
}
}
internal void SaleStared(string player_name)
{
//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_0026: Expected O, but got Unknown
Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
{
baseToken = ModConfig.saleStaredMessage.Value.Replace("{player_name}", player_name)
});
}
}
}