using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using R2API;
using RoR2;
using UnityEngine;
[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("TheBetterAdlibs")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TheBetterAdlibs")]
[assembly: AssemblyTitle("TheBetterAdlibs")]
[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 ExamplePlugin
{
internal class Data : MonoBehaviour
{
public enum DataCategory
{
Item,
Equipment,
Shrine,
Lunar,
Newt,
Bazaar,
Moon,
Portal,
Other
}
public enum DataSuffix
{
Name,
Pickup,
Desc,
Lore,
Context,
Message,
Coin,
Other
}
public static Dictionary<DataCategory, List<ConfigEntry<string>>> allData = new Dictionary<DataCategory, List<ConfigEntry<string>>>();
public static void PopulateItemCatalogues(ConfigFile config)
{
Dictionary<DataCategory, List<string>> dictionary = new Dictionary<DataCategory, List<string>>();
foreach (KeyValuePair<string, string> item in Language.currentLanguage.stringsByToken)
{
string[] array = item.Key.Split(new char[1] { '_' });
DataCategory dataCategory = CastDataCategory(array[0]);
DataSuffix dataSuffix = CastDataSuffix(array[^1]);
if (dataCategory != DataCategory.Other && dataSuffix != DataSuffix.Other)
{
if (!dictionary.ContainsKey(dataCategory))
{
dictionary.Add(dataCategory, new List<string>());
}
dictionary[dataCategory].Add(item.Key);
}
}
foreach (KeyValuePair<DataCategory, List<string>> item2 in dictionary)
{
item2.Value.Sort();
allData.Add(item2.Key, new List<ConfigEntry<string>>());
foreach (string item3 in item2.Value)
{
string text = Language.currentLanguage.stringsByToken[item3];
string key = StripSuffix(item3) + "_NAME";
if (Language.currentLanguage.stringsByToken.ContainsKey(key))
{
string name = Language.currentLanguage.stringsByToken[key];
string text2 = item2.Key.ToString() + " :: " + SanitizeName(name);
allData[item2.Key].Add(config.Bind<string>(text2, item3, text, (ConfigDescription)null));
}
else
{
allData[item2.Key].Add(config.Bind<string>(item2.Key.ToString(), item3, text, (ConfigDescription)null));
}
}
}
}
public static void OverrideItemNames()
{
foreach (KeyValuePair<DataCategory, List<ConfigEntry<string>>> allDatum in allData)
{
foreach (ConfigEntry<string> item in allDatum.Value)
{
LanguageAPI.Add(((ConfigEntryBase)item).Definition.Key, item.Value);
}
}
}
protected static string StripSuffix(string name)
{
foreach (object value in Enum.GetValues(typeof(DataSuffix)))
{
string text = "_" + value.ToString().ToUpper();
if (name.Contains(text))
{
return name.Replace(text, "");
}
}
return name;
}
protected static string SanitizeName(string name)
{
string text = name.Trim().Replace("'", "");
if (!text.Contains("<"))
{
return text;
}
int num = text.IndexOf(">") + 1;
int num2 = text.IndexOf("<", num);
return text.Substring(num, num2 - num);
}
protected static DataCategory CastDataCategory(string category)
{
switch (category)
{
case "BAZAAR":
return DataCategory.Bazaar;
case "EQUIPMENT":
return DataCategory.Equipment;
case "ITEM":
return DataCategory.Item;
case "LUNAR":
case "PICKUP":
return DataCategory.Lunar;
case "MOON":
return DataCategory.Moon;
case "NEWT":
return DataCategory.Newt;
case "PORTAL":
return DataCategory.Portal;
case "SHRINE":
return DataCategory.Shrine;
default:
return DataCategory.Other;
}
}
protected static DataSuffix CastDataSuffix(string suffix)
{
return suffix switch
{
"COIN" => DataSuffix.Coin,
"CONTEXT" => DataSuffix.Context,
"DESC" => DataSuffix.Desc,
"LORE" => DataSuffix.Lore,
"MESSAGE" => DataSuffix.Message,
"NAME" => DataSuffix.Name,
"PICKUP" => DataSuffix.Pickup,
_ => DataSuffix.Other,
};
}
}
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("slimslam.thebetteradlibs", "thebetteradlibs", "1.1.2")]
public class TheBetterAdlibs : BaseUnityPlugin
{
public const string PluginGUID = "slimslam.thebetteradlibs";
public const string PluginAuthor = "slimslam";
public const string PluginName = "thebetteradlibs";
public const string PluginVersion = "1.1.2";
public void Awake()
{
Log.Init(((BaseUnityPlugin)this).Logger);
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
{
Data.PopulateItemCatalogues(((BaseUnityPlugin)this).Config);
});
RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(Data.OverrideItemNames));
}
}
}