Decompiled source of SmallTweak Borne v1.1.0

plugins/SmallTweak_Borne.dll

Decompiled 3 weeks ago
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 BepInEx.Logging;
using DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Card;
using Microsoft.CodeAnalysis;
using SmallTweak_Borne.PATCHES;
using SmallTweak_Hydra.Configuration;
using UnityEngine;

[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: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: AssemblyCompany("SmallTweak_Borne")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Bornes should attack cards bearing the same borne durrrr.")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+8858c9d252f172abde74edb247547f4a38bfbec2")]
[assembly: AssemblyProduct("SmallTweak_Borne")]
[assembly: AssemblyTitle("SmallTweak_Borne")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.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 SmallTweak_Borne
{
	[BepInPlugin("creator.SmallTweak.Borne", "Smalltweak Borne", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SmallTweak_Borne : BaseUnityPlugin
	{
		public const string PluginGuid = "creator.SmallTweak.Borne";

		public const string PluginName = "Smalltweak Borne";

		public const string PluginVersion = "1.1.0";

		public const string PluginPrefix = "Smalltweak_Borne";

		public static ManualLogSource Log = new ManualLogSource("Smalltweak Borne");

		public static Harmony harmony = new Harmony("creator.SmallTweak.Borne");

		public void Awake()
		{
			InitConfig.Config = ((BaseUnityPlugin)this).Config;
			InitConfig.Init();
			harmony.PatchAll(typeof(PlayablePatches));
			harmony.PatchAll(typeof(BorneRulebookPatches));
			((BaseUnityPlugin)this).Logger.LogMessage((object)"creator.SmallTweak.Borne: Loaded Mod: Smalltweak Borne - 1.1.0");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SmallTweak_Borne";

		public const string PLUGIN_NAME = "SmallTweak_Borne";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}
namespace SmallTweak_Borne.PATCHES
{
	[HarmonyPatch(typeof(RuleBookInfo))]
	internal static class BorneRulebookPatches
	{
		[HarmonyAfter(new string[] { "cyantist.inscryption.api" })]
		[HarmonyPostfix]
		[HarmonyPatch("ConstructPageData", new Type[] { typeof(AbilityMetaCategory) })]
		public static void PostfixUpdateHydraEggRulebook(AbilityMetaCategory metaCategory)
		{
			if (InitConfig.AirborneAttackAirborne.Value)
			{
				AbilityInfo val = ((IEnumerable<AbilityInfo>)AbilityManager.AllAbilityInfos).FirstOrDefault((Func<AbilityInfo, bool>)((AbilityInfo i) => (int)i.ability == 19));
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				val.rulebookDescription = "[creature] will strike an opponent directly, even if there is a creature opposing it, unless the creature has this sigil.";
			}
			if (!InitConfig.WaterborneAttackWaterborne.Value)
			{
				return;
			}
			AbilityInfo val2 = ((IEnumerable<AbilityInfo>)AbilityManager.AllAbilityInfos).FirstOrDefault((Func<AbilityInfo, bool>)((AbilityInfo i) => (int)i.ability == 13));
			if (!((Object)(object)val2 == (Object)null))
			{
				val2.rulebookDescription = "[creature] submerges itself during its opponent's turn. While submerged, opposing creatures attack its owner directly, unless that creature has this sigil.";
				AbilityInfo val3 = ((IEnumerable<AbilityInfo>)AbilityManager.AllAbilityInfos).FirstOrDefault((Func<AbilityInfo, bool>)((AbilityInfo i) => (int)i.ability == 89));
				if (!((Object)(object)val3 == (Object)null))
				{
					val3.rulebookDescription = "[creature] submerges itself during its opponent's turn. While submerged, opposing creatures attack its owner directly, unless that creature has this sigil.";
				}
			}
		}
	}
	[HarmonyPatch]
	internal static class PlayablePatches
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(PlayableCard), "CanAttackDirectly")]
		public static bool PrefixCanAttackDirectly(CardSlot opposingSlot, ref bool __result, PlayableCard __instance)
		{
			bool flag;
			if (InitConfig.WaterborneAttackWaterborne.Value && InitConfig.AirborneAttackAirborne.Value)
			{
				flag = (Object)(object)opposingSlot.Card == (Object)null || (__instance.HasAbility((Ability)19) && !opposingSlot.Card.HasAbility((Ability)23) && !opposingSlot.Card.HasAbility((Ability)19)) || (((Card)opposingSlot.Card).FaceDown && !__instance.HasAbility((Ability)13));
				if ((Object)(object)opposingSlot.Card != (Object)null && ((Card)opposingSlot.Card).FaceDown && __instance.HasAbility((Ability)13))
				{
					((Card)opposingSlot.Card).SetFaceDown(false, false);
				}
			}
			else if (!InitConfig.WaterborneAttackWaterborne.Value)
			{
				flag = ((!InitConfig.AirborneAttackAirborne.Value) ? ((Object)(object)opposingSlot.Card == (Object)null || (__instance.HasAbility((Ability)19) && !opposingSlot.Card.HasAbility((Ability)23)) || ((Card)opposingSlot.Card).FaceDown) : ((Object)(object)opposingSlot.Card == (Object)null || (__instance.HasAbility((Ability)19) && !opposingSlot.Card.HasAbility((Ability)23) && !opposingSlot.Card.HasAbility((Ability)19)) || ((Card)opposingSlot.Card).FaceDown));
			}
			else
			{
				flag = (Object)(object)opposingSlot.Card == (Object)null || (__instance.HasAbility((Ability)19) && !opposingSlot.Card.HasAbility((Ability)23)) || (((Card)opposingSlot.Card).FaceDown && !__instance.HasAbility((Ability)13));
				if ((Object)(object)opposingSlot.Card != (Object)null && ((Card)opposingSlot.Card).FaceDown && __instance.HasAbility((Ability)13))
				{
					((Card)opposingSlot.Card).SetFaceDown(false, false);
				}
			}
			__result = flag;
			return false;
		}
	}
}
namespace SmallTweak_Hydra.Configuration
{
	public class InitConfig
	{
		public static ConfigFile Config;

		public static ConfigEntry<bool> AirborneAttackAirborne;

		public static ConfigEntry<bool> WaterborneAttackWaterborne;

		public static void Init()
		{
			AirborneAttackAirborne = Config.Bind<bool>("Configs", "Should Airbornes attack Airbornes?", true, "Essentially a toggle for whether or not Airbornes should attack other Airbornes.");
			WaterborneAttackWaterborne = Config.Bind<bool>("Configs", "Should Waterbornes attack Waterbornes?", true, "Essentially a toggle for whether or not Waterbornes should attack other Waterbornes.");
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}