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.binbin.TheWiseWolf")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Ulfvitr, The Wise Wolf")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3+43af387d5c189c702264f5ca73e4df722162fca6")]
[assembly: AssemblyProduct("The Wise Wolf")]
[assembly: AssemblyTitle("com.binbin.TheWiseWolf")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.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 TheWiseWolf
{
[BepInPlugin("com.binbin.TheWiseWolf", "The Wise Wolf", "1.0.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInProcess("AcrossTheObelisk.exe")]
public class Plugin : BaseUnityPlugin
{
internal const int ModDate = 20240916;
private readonly Harmony harmony = new Harmony("com.binbin.TheWiseWolf");
internal static ManualLogSource Log;
public static string characterName = "Ulfvitr";
public static string subclassName = "stormshaman";
private void Awake()
{
Log = ((BaseUnityPlugin)this).Logger;
Log.LogInfo((object)"com.binbin.TheWiseWolf 1.0.3 has loaded!");
Essentials.RegisterMod("The Wise Wolf", "binbin", "Ulfvitr, The Wise Wolf.", "1.0.3", 20240916, "https://github.com/binbinmods/ulfvitrwisewolf", (string[])null, characterName, 100, new string[3] { "content", "hero", "trait" }, "", true);
harmony.PatchAll();
}
}
[HarmonyPatch]
internal class Traits
{
public static string[] myTraitList = new string[5] { "ulfvitrcalltherain", "ulfvitrmagnet", "ulfvitrregenerator", "ulfvitrconductor", "ulfvitrlifebloom" };
public static void DoCustomTrait(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 _character = Traverse.Create((object)__instance).Field("character").GetValue<Character>();
Character _target = Traverse.Create((object)__instance).Field("target").GetValue<Character>();
int value2 = Traverse.Create((object)__instance).Field("auxInt").GetValue<int>();
string value3 = Traverse.Create((object)__instance).Field("auxString").GetValue<string>();
CardData value4 = Traverse.Create((object)__instance).Field("castedCard").GetValue<CardData>();
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)value);
Traverse.Create((object)__instance).Field("auxInt").SetValue((object)value2);
Traverse.Create((object)__instance).Field("auxString").SetValue((object)value3);
Traverse.Create((object)__instance).Field("castedCard").SetValue((object)value4);
TraitData traitData = Globals.Instance.GetTraitData(_trait);
List<CardData> list = new List<CardData>();
List<string> heroHand = MatchManager.Instance.GetHeroHand(_character.HeroIndex);
Hero[] teamHeroes = MatchManager.Instance.GetTeamHero();
NPC[] teamNpc = MatchManager.Instance.GetTeamNPC();
switch (_trait)
{
case "ulfvitrcalltherain":
{
string text2 = "Call the Rain";
if (_character.HeroData != null)
{
bool allHeroFlag = true;
bool allNpcFlag = true;
bool randomNpcFlag = false;
bool randomHeroFlag = false;
ApplyAuraCurseTo("wet", 1, allHeroFlag, allNpcFlag, randomHeroFlag, randomNpcFlag, ref _character, ref teamHeroes, ref teamNpc, text2, "drink");
if (_character.HeroItem != null)
{
((CharacterItem)_character.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_" + text2, ""), (CombatScrollEffectType)7);
}
}
break;
}
case "ulfvitrmagnet":
{
string text = "Magnet";
if ((Object)(object)MatchManager.Instance != (Object)null && (Object)(object)value4 != (Object)null && (MatchManager.Instance.activatedTraits == null || !MatchManager.Instance.activatedTraits.ContainsKey(_trait) || MatchManager.Instance.activatedTraits[_trait] <= traitData.TimesPerTurn - 1) && value4.GetCardTypes().Contains((CardType)7) && (Object)(object)_character.HeroData != (Object)null)
{
if (!MatchManager.Instance.activatedTraits.ContainsKey("ulfvitrmagnet"))
{
MatchManager.Instance.activatedTraits.Add("ulfvitrmagnet", 1);
}
else
{
MatchManager.Instance.activatedTraits["ulfvitrmagnet"]++;
}
MatchManager.Instance.SetTraitInfoText();
_character.ModifyEnergy(1, true);
if ((Object)(object)_character.HeroItem != (Object)null)
{
((CharacterItem)_character.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_" + text, "") + TextChargesLeft(MatchManager.Instance.activatedTraits["ulfvitrmagnet"], traitData.TimesPerTurn), (CombatScrollEffectType)7);
EffectsManager.Instance.PlayEffectAC("energy", true, ((CharacterItem)_character.HeroItem).CharImageT, false, 0f);
}
NPC val = teamNpc[MatchManager.Instance.GetRandomIntRange(0, 3, "default", "")];
if (val != null && ((Character)val).Alive)
{
((Character)val).SetAuraTrait(_character, "spark", 1);
}
}
break;
}
case "ulfvitrregenerator":
if (value3 == "regeneration" && _target != null && _target.IsHero && _target.HasEffect("wet"))
{
int num = _target.EffectCharges("wet");
int healAmount2 = Functions.FuncRoundToInt((float)num * 1f);
TraitHeal(ref _character, ref _target, healAmount2, _trait);
}
break;
case "ulfvitrconductor":
if (_character.HeroData != null && value3 == "wet" && !_target.IsHero && _target.HasEffect("spark"))
{
_target.IndirectDamage((DamageType)6, Functions.FuncRoundToInt((float)_target.GetAuraCharges("spark") * 0.5f), (AudioClip)null, "", "", "");
}
break;
case "ulfvitrlifebloom":
{
Plugin.Log.LogDebug((object)"Lifebloom Start:");
if (!((Object)(object)_character.HeroData != (Object)null))
{
break;
}
for (int i = 0; i < teamHeroes.Length; i++)
{
if (teamHeroes[i] != null && ((Character)teamHeroes[i]).Alive)
{
int healAmount = Functions.FuncRoundToInt((float)((Character)teamHeroes[i]).GetAuraCharges("wet") * 0.7f);
Plugin.Log.LogDebug((object)("Lifebloom Heal Amount: " + healAmount));
TraitHealHero(ref _character, ref teamHeroes[i], healAmount, _trait);
}
}
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))
{
DoCustomTrait(_trait, ref __instance);
return false;
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch(typeof(Character), "SetEvent")]
public static void SetEventPrefix(ref Character __instance, ref EventActivation theEvent, Character target = null)
{
}
public static void TraitHeal(ref Character _character, ref Character _target, int healAmount, string traitName)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
int num = healAmount;
if (_target.GetHpLeftForMax() < healAmount)
{
num = _target.GetHpLeftForMax();
}
if (num > 0)
{
_target.ModifyHp(num, true, true);
CastResolutionForCombatText val = new CastResolutionForCombatText();
val.heal = num;
if (_target.HeroItem != null)
{
((CharacterItem)_target.HeroItem).ScrollCombatTextDamageNew(val);
EffectsManager.Instance.PlayEffectAC("healimpactsmall", true, ((CharacterItem)_target.HeroItem).CharImageT, false, 0f);
}
else
{
((CharacterItem)_target.NPCItem).ScrollCombatTextDamageNew(val);
EffectsManager.Instance.PlayEffectAC("healimpactsmall", true, ((CharacterItem)_target.NPCItem).CharImageT, false, 0f);
}
_target.SetEvent((EventActivation)15, (Character)null, 0, "");
_character.SetEvent((EventActivation)14, _target, 0, "");
((CharacterItem)_character.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_" + traitName, ""), (CombatScrollEffectType)7);
}
}
public static void TraitHealHero(ref Character _character, ref Hero _target, int healAmount, string traitName)
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Expected O, but got Unknown
int num = healAmount;
if (((Character)_target).GetHpLeftForMax() < healAmount)
{
num = ((Character)_target).GetHpLeftForMax();
}
if (num > 0)
{
((Character)_target).ModifyHp(num, true, true);
CastResolutionForCombatText val = new CastResolutionForCombatText();
val.heal = num;
if (((Character)_target).HeroItem != null)
{
((CharacterItem)((Character)_target).HeroItem).ScrollCombatTextDamageNew(val);
EffectsManager.Instance.PlayEffectAC("healimpactsmall", true, ((CharacterItem)((Character)_target).HeroItem).CharImageT, false, 0f);
}
else
{
((CharacterItem)((Character)_target).NPCItem).ScrollCombatTextDamageNew(val);
EffectsManager.Instance.PlayEffectAC("healimpactsmall", true, ((CharacterItem)((Character)_target).NPCItem).CharImageT, false, 0f);
}
((Character)_target).SetEvent((EventActivation)15, (Character)null, 0, "");
_character.SetEvent((EventActivation)14, (Character)(object)_target, 0, "");
((CharacterItem)_character.HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_" + traitName, ""), (CombatScrollEffectType)7);
}
}
public static void WhenYouPlayXRefund1Energy(CardType cardType, ref Character _character, string traitName, string traitID)
{
}
public static void ApplyAuraCurseTo(string auraCurse, int amount, bool allHeroFlag, bool allNpcFlag, bool randomHeroFlag, bool randomNpcFlag, ref Character _character, ref Hero[] teamHeroes, ref NPC[] teamNpc, string traitName, string soundEffect)
{
if (allNpcFlag)
{
for (int i = 0; i < teamNpc.Length; i++)
{
if (teamNpc[i] != null && ((Character)teamNpc[i]).Alive)
{
((Character)teamNpc[i]).SetAuraTrait(_character, auraCurse, amount);
if (((Character)teamNpc[i]).NPCItem != null)
{
((CharacterItem)((Character)teamNpc[i]).NPCItem).ScrollCombatText(Texts.Instance.GetText("traits_" + traitName, ""), (CombatScrollEffectType)7);
EffectsManager.Instance.PlayEffectAC(soundEffect, true, ((CharacterItem)((Character)teamNpc[i]).NPCItem).CharImageT, false, 0f);
}
}
}
}
if (!allHeroFlag)
{
return;
}
for (int j = 0; j < teamHeroes.Length; j++)
{
if (teamHeroes[j] != null && ((Character)teamHeroes[j]).Alive)
{
((Character)teamHeroes[j]).SetAuraTrait(_character, auraCurse, amount);
if (((Character)teamHeroes[j]).NPCItem != null)
{
((CharacterItem)((Character)teamHeroes[j]).HeroItem).ScrollCombatText(Texts.Instance.GetText("traits_" + traitName, ""), (CombatScrollEffectType)7);
EffectsManager.Instance.PlayEffectAC(soundEffect, true, ((CharacterItem)((Character)teamHeroes[j]).NPCItem).CharImageT, false, 0f);
}
}
}
}
public static string TextChargesLeft(int currentCharges, int chargesTotal)
{
int num = currentCharges;
int num2 = chargesTotal;
return "<br><color=#FFF>" + num + "/" + num2 + "</color>";
}
}
public static class PluginInfo
{
public const string PLUGIN_GUID = "com.binbin.TheWiseWolf";
public const string PLUGIN_NAME = "The Wise Wolf";
public const string PLUGIN_VERSION = "1.0.3";
}
}