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 Eremite.Controller;
using Eremite.Services;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MoreTownNames;
using TownNamesMod;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("MoreTownNames")]
[assembly: AssemblyConfiguration("release")]
[assembly: AssemblyDescription("Adds custom town names to Against the Storm's random town name pool during embarkation")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+eb7d2ae31641d75f148e1f2777e7787ebbd0ef49")]
[assembly: AssemblyProduct("MoreTownNames")]
[assembly: AssemblyTitle("MoreTownNames")]
[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 MoreTownNames
{
[BepInPlugin("MoreTownNames", "MoreTownNames", "1.0.0")]
public class TownNamesPlugin : BaseUnityPlugin
{
public static TownNamesPlugin Instance;
internal static ConfigEntry<string> CustomNames;
private Harmony harmony;
private void Awake()
{
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Expected O, but got Unknown
((BaseUnityPlugin)this).Logger.LogInfo((object)"### MORE TOWN NAMES LOADED ###");
Instance = this;
string text = "Emberwatch,Stonehaven,Dunhold,Ashenvale,Ironholm,Mistwood,Crescent Bay,Northmark,Shadowpeak,Goldleaf,Ravenfort,Silvermere,Eversong";
CustomNames = ((BaseUnityPlugin)this).Config.Bind<string>("General", "CustomTownNames", text, "Comma-separated list of town names to add to the pool.");
((BaseUnityPlugin)this).Logger.LogInfo((object)("Loaded config names: " + CustomNames.Value));
harmony = new Harmony("MoreTownNames");
harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin MoreTownNames patching complete.");
}
[HarmonyPatch(typeof(MainController), "OnServicesReady")]
[HarmonyPostfix]
private static void HookMainControllerSetup()
{
((BaseUnityPlugin)Instance).Logger.LogInfo((object)"Performing game initialization on behalf of MoreTownNames.");
((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"The game has loaded {MainController.Instance.Settings.effects.Length} effects.");
}
[HarmonyPatch(typeof(GameController), "StartGame")]
[HarmonyPostfix]
private static void HookEveryGameStart()
{
object arg = AccessTools.Method(typeof(GameService), "IsNewGame", (Type[])null, (Type[])null).Invoke(null, null);
((BaseUnityPlugin)Instance).Logger.LogInfo((object)$"Entered a game. Is this a new game: {arg}.");
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "MoreTownNames";
public const string PLUGIN_NAME = "MoreTownNames";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace MoreTownNames.Patches
{
[HarmonyPatch(typeof(WorldStateService), "GetCitiesNamesKeys")]
public class WorldStateServicePatch
{
[HarmonyPostfix]
public static void GetCitiesNamesKeysPostfix(ref string[] __result)
{
List<string> customNames = NameProvider.GetCustomNames();
if (customNames != null && customNames.Count != 0)
{
List<string> list = __result?.ToList() ?? new List<string>();
list.AddRange(customNames);
list = list.Distinct().ToList();
ListShuffler.Shuffle<string>(list, (Random)null);
__result = list.ToArray();
}
}
}
}
namespace TownNamesMod
{
public static class NameProvider
{
public static List<string> GetCustomNames()
{
return (from n in TownNamesPlugin.CustomNames.Value.Split(new char[1] { ',' })
select n.Trim() into n
where !string.IsNullOrEmpty(n)
select n).ToList();
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}