Decompiled source of CultOfSpikedrivers v1.0.0

plugins/CultOfSpikedrivers.Plugin.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Microsoft.Extensions.Configuration;
using SimpleInjector;
using TrainworksReloaded.Base;
using TrainworksReloaded.Base.Character;
using TrainworksReloaded.Base.Extensions;
using TrainworksReloaded.Core;
using TrainworksReloaded.Core.Extensions;
using TrainworksReloaded.Core.Interfaces;
using UnityEngine.AddressableAssets;

[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("CultOfSpikedrivers.Plugin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+0823deaa500bc2762784aecc58fc39481bc39f54")]
[assembly: AssemblyProduct("CultOfSpikedrivers.Plugin")]
[assembly: AssemblyTitle("CultOfSpikedrivers.Plugin")]
[assembly: AssemblyVersion("1.0.0.0")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 CultOfSpikedrivers.Plugin
{
	internal class ConfigDescriptionBuilder
	{
		public string English { get; set; } = "";


		public string French { get; set; } = "";


		public string German { get; set; } = "";


		public string Russian { get; set; } = "";


		public string Portuguese { get; set; } = "";


		public string Chinese { get; set; } = "";


		public string Spanish { get; set; } = "";


		public string ChineseTraditional { get; set; } = "";


		public string Korean { get; set; } = "";


		public string Japanese { get; set; } = "";


		public override string ToString()
		{
			StringBuilder stringBuilder = new StringBuilder();
			if (!string.IsNullOrEmpty(English))
			{
				stringBuilder.AppendLine(English);
			}
			if (!string.IsNullOrEmpty(French))
			{
				stringBuilder.AppendLine(French);
			}
			if (!string.IsNullOrEmpty(German))
			{
				stringBuilder.AppendLine(German);
			}
			if (!string.IsNullOrEmpty(Russian))
			{
				stringBuilder.AppendLine(Russian);
			}
			if (!string.IsNullOrEmpty(Portuguese))
			{
				stringBuilder.AppendLine(Portuguese);
			}
			if (!string.IsNullOrEmpty(Chinese))
			{
				stringBuilder.AppendLine(Chinese);
			}
			if (!string.IsNullOrEmpty(Spanish))
			{
				stringBuilder.AppendLine(Spanish);
			}
			if (!string.IsNullOrEmpty(ChineseTraditional))
			{
				stringBuilder.AppendLine(ChineseTraditional);
			}
			if (!string.IsNullOrEmpty(Korean))
			{
				stringBuilder.AppendLine(Korean);
			}
			if (!string.IsNullOrEmpty(Japanese))
			{
				stringBuilder.AppendLine(Japanese);
			}
			return stringBuilder.ToString().TrimEnd();
		}
	}
	[BepInPlugin("CultOfSpikedrivers.Plugin", "CultOfSpikedrivers.Plugin", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger = new ManualLogSource("CultOfSpikedrivers.Plugin");

		public void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			List<string> files = new List<string>(2) { "json/localizations.json", "json/spikedriver.json" };
			Railhead.GetBuilder().Configure("CultOfSpikedrivers.Plugin", (Action<IConfigurationBuilder>)delegate(IConfigurationBuilder c)
			{
				ConfigurationExtensions.AddMergedJsonFile(c, files);
			});
			Railend.ConfigurePostAction((Action<Container>)delegate(Container c)
			{
				PostInitialize(c);
			});
			Logger.LogInfo((object)"Plugin CultOfSpikedrivers.Plugin is loaded!");
		}

		private void PostInitialize(Container c)
		{
			FieldInfo fieldInfo = AccessTools.Field(typeof(CharacterData), "characterPrefabVariantRef");
			SaveManager val = default(SaveManager);
			if (!c.GetInstance<GameDataClient>().TryGetProvider<SaveManager>(ref val))
			{
				Logger.LogError((object)"Could not initialize");
				return;
			}
			IRegister<AssetReferenceGameObject> instance = c.GetInstance<IRegister<AssetReferenceGameObject>>();
			AllGameData allGameData = val.GetAllGameData();
			CharacterData obj = allGameData.FindCharacterData("e8b1f88f-8628-48ea-84fd-0191ce2e88a0");
			AssetReferenceGameObject value = default(AssetReferenceGameObject);
			bool? flag = default(bool?);
			if (!RegisterExtensions.TryLookupName<AssetReferenceGameObject>(instance, StringExtensions.GetId("CultOfSpikedrivers.Plugin", "GameObject", "SpikedriverColonyCharacterArt"), ref value, ref flag, (IConfigurationSection)null))
			{
				Logger.LogError((object)"Did not find spikedriver colony character art");
				return;
			}
			fieldInfo.SetValue(obj, value);
			if (((BaseUnityPlugin)this).Config.Bind<bool>("Options", "Enable Classic Spikedriver Colony", false, new ConfigDescriptionBuilder
			{
				English = "Spikedriver Colony retains its original effect from MT1 (Multistrike 1 and Extinguish: Add a permanent copy of this card to the discard pile.). Warning enabling this makes the mod non-cosmetic, do not play daily challenges with this enabled."
			}.ToString()).Value)
			{
				CardEffectData obj2 = allGameData.FindCardData("3d32e031-9796-4eaf-84c3-a30b48db22d4").GetEffects()[0];
				CharacterData value2 = default(CharacterData);
				if (!RegisterExtensions.TryLookupName<CharacterData>((IRegister<CharacterData>)(object)c.GetInstance<CharacterDataRegister>(), StringExtensions.GetId("CultOfSpikedrivers.Plugin", "Character", "SpikedriverColonyCharacter"), ref value2, ref flag, (IConfigurationSection)null))
				{
					Logger.LogError((object)"Did not find spikedriver colony character");
				}
				else
				{
					AccessTools.Field(typeof(CardEffectData), "paramCharacterData").SetValue(obj2, value2);
				}
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "CultOfSpikedrivers.Plugin";

		public const string PLUGIN_NAME = "CultOfSpikedrivers.Plugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}