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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Obeliskial_Content;
using Obeliskial_Essentials;
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.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.shazixnar.MagicArcherTraits")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Magic Archer Traits, made by Shazixnar")]
[assembly: AssemblyFileVersion("2.0.5.0")]
[assembly: AssemblyInformationalVersion("2.0.5")]
[assembly: AssemblyProduct("Magic Archer Sylvie")]
[assembly: AssemblyTitle("com.shazixnar.MagicArcherTraits")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.5.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 TraitMod
{
[HarmonyPatch]
internal class Traits
{
public static string[] myTraitList = new string[3] { "sylviearchersintuition", "sylvieelementlock", "sylviearrowwithhawk" };
[HarmonyPostfix]
[HarmonyPatch(typeof(Hero), "AssignTrait")]
public static void AssignTraitPostfix(ref string traitName, ref Hero __instance)
{
if (traitName == "sylviearrowwithhawk")
{
((Character)__instance).Pet = "harleyrare";
}
}
public static void myDoTrait(string _trait, ref Trait __instance)
{
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
EventActivation value = Traverse.Create((object)__instance).Field("theEvent").GetValue<EventActivation>();
Character value2 = Traverse.Create((object)__instance).Field("character").GetValue<Character>();
Character value3 = Traverse.Create((object)__instance).Field("target").GetValue<Character>();
int value4 = Traverse.Create((object)__instance).Field("auxInt").GetValue<int>();
string value5 = Traverse.Create((object)__instance).Field("auxString").GetValue<string>();
CardData value6 = Traverse.Create((object)__instance).Field("castedCard").GetValue<CardData>();
Traverse.Create((object)__instance).Field("character").SetValue((object)value2);
Traverse.Create((object)__instance).Field("target").SetValue((object)value3);
Traverse.Create((object)__instance).Field("theEvent").SetValue((object)value);
Traverse.Create((object)__instance).Field("auxInt").SetValue((object)value4);
Traverse.Create((object)__instance).Field("auxString").SetValue((object)value5);
Traverse.Create((object)__instance).Field("castedCard").SetValue((object)value6);
TraitData traitData = Globals.Instance.GetTraitData(_trait);
List<CardData> list = new List<CardData>();
List<string> heroHand = MatchManager.Instance.GetHeroHand(value2.HeroIndex);
Hero[] teamHero = MatchManager.Instance.GetTeamHero();
NPC[] teamNPC = MatchManager.Instance.GetTeamNPC();
switch (_trait)
{
case "sylviearchersintuition":
{
if (!((Object)(object)MatchManager.Instance != (Object)null) || !((Object)(object)value6 != (Object)null) || (MatchManager.Instance.activatedTraits != null && MatchManager.Instance.activatedTraits.ContainsKey(_trait) && MatchManager.Instance.activatedTraits[_trait] > traitData.TimesPerTurn - 1) || !value6.GetCardTypes().Contains((CardType)2) || !((Object)(object)value2.HeroData != (Object)null))
{
break;
}
if (!MatchManager.Instance.activatedTraits.ContainsKey("sylviearchersintuition"))
{
MatchManager.Instance.activatedTraits.Add("sylviearchersintuition", 1);
}
else
{
MatchManager.Instance.activatedTraits["sylviearchersintuition"]++;
}
MatchManager.Instance.SetTraitInfoText();
value2.ModifyEnergy(1, true);
if ((Object)(object)value2.HeroItem != (Object)null)
{
((CharacterItem)value2.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_Archer's Intuition", "") + TextChargesLeft(MatchManager.Instance.activatedTraits["sylviearchersintuition"], traitData.TimesPerTurn), (CombatScrollEffectType)7);
EffectsManager.Instance.PlayEffectAC("energy", true, ((CharacterItem)value2.HeroItem).CharImageT, false, 0f);
}
NPC[] teamNPC2 = MatchManager.Instance.GetTeamNPC();
for (int i = 0; i < teamNPC2.Length; i++)
{
if (teamNPC2[i] != null && ((Character)teamNPC2[i]).Alive)
{
((Character)teamNPC2[i]).SetAuraTrait(value2, "sight", 5);
}
}
break;
}
case "sylvieelementlock":
if (value3 != null && value3.Alive && (Object)(object)MatchManager.Instance != (Object)null && (value5 == "burn" || value5 == "chill" || value5 == "spark"))
{
if (value5 == "burn")
{
value3.SetAuraTrait(value3, "sight", Functions.FuncRoundToInt((float)value4));
((CharacterItem)value2.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_Indomitable", ""), (CombatScrollEffectType)7);
}
if (value5 == "chill")
{
value3.SetAuraTrait(value3, "sight", Functions.FuncRoundToInt((float)value4));
((CharacterItem)value2.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_Indomitable", ""), (CombatScrollEffectType)7);
}
if (value5 == "spark")
{
value3.SetAuraTrait(value3, "sight", Functions.FuncRoundToInt((float)value4));
((CharacterItem)value2.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_Indomitable", ""), (CombatScrollEffectType)7);
}
}
break;
case "sylviearrowwithhawk":
if (!((Object)(object)MatchManager.Instance != (Object)null) || !((Object)(object)value6 != (Object)null) || (MatchManager.Instance.activatedTraits != null && MatchManager.Instance.activatedTraits.ContainsKey("sylviearrowwithhawk") && MatchManager.Instance.activatedTraits["sylviearrowwithhawk"] > traitData.TimesPerTurn - 1))
{
break;
}
if (MatchManager.Instance.CountHeroHand(-1) == 10)
{
Debug.Log((object)"[TRAIT EXECUTION] Broke because player at max cards");
}
else if (value6.GetCardTypes().Contains((CardType)2) && (Object)(object)value2.HeroData != (Object)null)
{
if (!MatchManager.Instance.activatedTraits.ContainsKey("sylviearrowwithhawk"))
{
MatchManager.Instance.activatedTraits.Add("sylviearrowwithhawk", 1);
}
else
{
MatchManager.Instance.activatedTraits["sylviearrowwithhawk"]++;
}
MatchManager.Instance.SetTraitInfoText();
int randomIntRange = MatchManager.Instance.GetRandomIntRange(0, 100, "trait", "");
int randomIntRange2 = MatchManager.Instance.GetRandomIntRange(0, Globals.Instance.CardListByType[(CardType)2].Count, "trait", "");
string text = Globals.Instance.CardListByType[(CardType)2][randomIntRange2];
text = Functions.GetCardByRarity(randomIntRange, Globals.Instance.GetCardData(text, false), false);
string text2 = MatchManager.Instance.CreateCardInDictionary(text, "", false);
CardData cardData = MatchManager.Instance.GetCardData(text2);
cardData.Vanish = true;
cardData.EnergyReductionToZeroPermanent = true;
MatchManager.Instance.GenerateNewCard(1, text2, false, (CardPlace)5, (CardData)null, (CardData)null, -1, true, 0);
((CharacterItem)value2.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_Arrow with Hawk", "") + TextChargesLeft(MatchManager.Instance.activatedTraits["sylviearrowwithhawk"], traitData.TimesPerTurn), (CombatScrollEffectType)7);
MatchManager.Instance.ItemTraitActivated(true);
MatchManager.Instance.CreateLogCardModification(cardData.InternalId, MatchManager.Instance.GetHero(value2.HeroIndex));
}
break;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(Trait), "DoTrait")]
public static bool DoTrait(EventActivation _theEvent, string _trait, Character _character, Character _target, int _auxInt, string _auxString, CardData _castedCard, ref Trait __instance)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)MatchManager.Instance == (Object)null)
{
return false;
}
Traverse.Create((object)__instance).Field("character").SetValue((object)_character);
Traverse.Create((object)__instance).Field("target").SetValue((object)_target);
Traverse.Create((object)__instance).Field("theEvent").SetValue((object)_theEvent);
Traverse.Create((object)__instance).Field("auxInt").SetValue((object)_auxInt);
Traverse.Create((object)__instance).Field("auxString").SetValue((object)_auxString);
Traverse.Create((object)__instance).Field("castedCard").SetValue((object)_castedCard);
if (Content.medsCustomTraitsSource.Contains(_trait) && myTraitList.Contains(_trait))
{
myDoTrait(_trait, ref __instance);
return false;
}
return true;
}
public static string TextChargesLeft(int currentCharges, int chargesTotal)
{
int num = currentCharges;
int num2 = chargesTotal;
return "<br><color=#FFF>" + num + "/" + num2 + "</color>";
}
[HarmonyPostfix]
[HarmonyPatch(typeof(AtOManager), "GlobalAuraCurseModificationByTraitsAndItems")]
public static void GlobalAuraCurseModificationByTraitsAndItemsPostfix(ref AtOManager __instance, ref AuraCurseData __result, string _type, string _acId, Character _characterCaster, Character _characterTarget)
{
bool flag = false;
bool flag2 = false;
if (_characterCaster != null && _characterCaster.IsHero)
{
flag = _characterCaster.IsHero;
}
if (_characterTarget != null && _characterTarget.IsHero)
{
flag2 = true;
}
if (_acId == "burn" && _type == "set" && !flag2 && __instance.TeamHaveTrait("sylviepowerfulenchantment"))
{
__result.ResistModifiedPercentagePerStack = -0.7f;
__result.ResistModified3 = (DamageType)3;
__result.ResistModifiedPercentagePerStack3 = -0.3f;
}
if (_acId == "chill" && _type == "set" && !flag2 && __instance.TeamHaveTrait("sylviepowerfulenchantment"))
{
__result.IncreasedDamageReceivedType = (DamageType)3;
__result.IncreasedDirectDamageChargesMultiplierNeededForOne = 5;
__result.IncreasedDirectDamageReceivedPerStack = 1;
__result.IncreasedDamageReceivedType2 = (DamageType)5;
__result.IncreasedDirectDamageChargesMultiplierNeededForOne2 = 5;
__result.IncreasedDirectDamageReceivedPerStack2 = 1;
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(Character), "SetEvent")]
public static void SetEventPrefix(ref Character __instance, ref EventActivation theEvent, Character target = null)
{
if ((int)theEvent == 9 && !__instance.IsHero && target != null && target.IsHero && target.HaveTrait("sylviepowerfulenchantment") && __instance.HasEffect("spark"))
{
__instance.IndirectDamage((DamageType)6, Functions.FuncRoundToInt((float)__instance.GetAuraCharges("spark") * 0.15f), (AudioClip)null, "", "", "");
}
}
}
}
namespace MagicArcherSylvie
{
[BepInPlugin("com.shazixnar.MagicArcherTraits", "Magic Archer Sylvie", "2.0.5")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("AcrossTheObelisk.exe")]
public class Plugin : BaseUnityPlugin
{
internal const int ModDate = 20231217;
private readonly Harmony harmony = new Harmony("com.shazixnar.MagicArcherTraits");
internal static ManualLogSource Log;
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"com.shazixnar.MagicArcherTraits 2.0.5 has loaded!");
Essentials.RegisterMod("Magic Archer Sylvie", "Shazixnar", "Redo two enchantments for Sylvie to make her arrows deal magic damage. Redo ranged attack cards and Sylvie's initial cards and traits to make them more fitting.", "2.0.5", 20231217, "https://across-the-obelisk.thunderstore.io/package/Shazixnar/Magic_Archer_Sylvie/", (string[])null, "Magic Archer Sylvie", 100, new string[4] { "content", "hero", "trait", "card" }, "", true);
harmony.PatchAll();
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "com.shazixnar.MagicArcherTraits";
public const string PLUGIN_NAME = "Magic Archer Sylvie";
public const string PLUGIN_VERSION = "2.0.5";
}
}