using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
using InControl;
using Microsoft.CodeAnalysis;
using NeedleArts.ArtTools;
using NeedleArts.Managers;
using NeedleArts.Utils;
using Needleforge;
using Needleforge.Data;
using Needleforge.Makers;
using Silksong.FsmUtil;
using Silksong.FsmUtil.Actions;
using TeamCherry.Localization;
using TeamCherry.NestedFadeGroup;
using UnityEngine;
using UnityEngine.SceneManagement;
[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("NeedleArts")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.2.1.0")]
[assembly: AssemblyInformationalVersion("0.2.1+c7cbffd3de1ecfd793367cea30d67aa437fbc171")]
[assembly: AssemblyProduct("NeedleArts")]
[assembly: AssemblyTitle("NeedleArts")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/jadedbay/NeedleArts")]
[assembly: NeutralResourcesLanguage("EN")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.1.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.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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace NeedleArts
{
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("io.github.jadedbay.needlearts", "NeedleArts", "0.2.1")]
public class NeedleArtsPlugin : BaseUnityPlugin
{
private Harmony harmony = new Harmony("io.github.jadedbay.needlearts");
internal static ManualLogSource Log;
public static readonly ColorData NeedleArtsToolType = NeedleforgePlugin.AddToolColor("NeedleArts", new Color(0.966f, 0.6f, 0.29f), true);
public static ConfigEntry<bool> SimpleUnlock;
public static ConfigEntry<bool> UnlockNeedleArts;
public const string Id = "io.github.jadedbay.needlearts";
public NeedleArtManager NeedleArtManager { get; private set; }
public static string Name => "NeedleArts";
public static string Version => "0.2.1";
private void Awake()
{
NeedleArtManager = new NeedleArtManager();
NeedleArts.Managers.NeedleArtManager.Instance = NeedleArtManager;
Log = ((BaseUnityPlugin)this).Logger;
((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin " + Name + " (io.github.jadedbay.needlearts) has loaded!"));
harmony.PatchAll();
InitializeConfig();
InitializeNeedleArtTools();
}
private void OnDestroy()
{
NeedleArts.Managers.NeedleArtManager.Instance = null;
}
private static void InitializeNeedleArtTools()
{
NeedleArtManager instance = NeedleArts.Managers.NeedleArtManager.Instance;
instance.AddNeedleArt(new CrestArt("HunterArt", "FINISHED", "Antic", "Hunter_Anim", 0, null));
instance.AddNeedleArt(new CrestArt("ReaperArt", "REAPER", "Antic Rpr", "Reaper_Anim", 2, "completedMemory_reaper"));
instance.AddNeedleArt(new CrestArt("WandererArt", "WANDERER", "Wanderer Antic", "Wanderer_Anim", 4, "completedMemory_wanderer"));
instance.AddNeedleArt(new CrestArt("BeastArt", "WARRIOR", "Warrior Antic", "Warrior_Anim", 3, "completedMemory_beast"));
instance.AddNeedleArt(new CrestArt("WitchArt", "WITCH", "Antic", "Whip_Anim", 6, "completedMemory_witch"));
instance.AddNeedleArt(new CrestArt("ArchitectArt", "TOOLMASTER", "Antic Drill", "Toolmaster_Anim", 5, "completedMemory_toolmaster"));
instance.AddNeedleArt(new CrestArt("ShamanArt", "SHAMAN", "Antic", "Shaman_Anim", 7, "completedMemory_shaman"));
}
public static ToolItemType ToolType()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
return NeedleArtsToolType.Type;
}
private void InitializeConfig()
{
SimpleUnlock = ((BaseUnityPlugin)this).Config.Bind<bool>("Gameplay", "Simple CrestArt Unlock", false, "True = Unlock when crest unlocked, False = Unlock when all slots of crest unlocked.");
SimpleUnlock.SettingChanged += delegate
{
if (PlayerData.instance == null)
{
return;
}
if (SimpleUnlock.Value)
{
foreach (CrestArt item in NeedleArtManager.GetAllNeedleArts().OfType<CrestArt>())
{
item.AddSimpleUnlockTest();
}
return;
}
foreach (CrestArt item2 in NeedleArtManager.GetAllNeedleArts().OfType<CrestArt>())
{
item2.RemoveSimpleUnlockTest();
}
};
UnlockNeedleArts = ((BaseUnityPlugin)this).Config.Bind<bool>("Cheats/Testing", "Unlock Needle Arts", false, "Instantly unlock Needle Strike and all Needle Arts.");
UnlockNeedleArts.SettingChanged += delegate
{
if (UnlockNeedleArts.Value)
{
PlayerData instance = PlayerData.instance;
if (instance != null)
{
instance.hasChargeSlash = true;
foreach (NeedleArt allNeedleArt in NeedleArtManager.GetAllNeedleArts())
{
allNeedleArt.ToolItem.Unlock((Action)null, (PopupFlags)3);
}
}
UnlockNeedleArts.Value = false;
}
};
}
}
}
namespace NeedleArts.Utils
{
public static class CrestArtUtil
{
private static readonly Dictionary<string, string> CrestToArt = new Dictionary<string, string>
{
{ "Hunter", "HunterArt" },
{ "Reaper", "ReaperArt" },
{ "Wanderer", "WandererArt" },
{ "Warrior", "BeastArt" },
{ "Witch", "WitchArt" },
{ "Toolmaster", "ArchitectArt" },
{ "Spell", "ShamanArt" }
};
private static readonly Dictionary<string, string> ArtToCrest = CrestToArt.ToDictionary<KeyValuePair<string, string>, string, string>((KeyValuePair<string, string> kvp) => kvp.Value, (KeyValuePair<string, string> kvp) => kvp.Key);
public static string GetArtName(string crestName)
{
crestName = (crestName.Contains("Hunter") ? "Hunter" : crestName);
string value;
return CrestToArt.TryGetValue(crestName, out value) ? value : null;
}
public static string GetCrestName(string artName)
{
string value;
return ArtToCrest.TryGetValue(artName, out value) ? value : null;
}
public static NeedleArt GetCrestArt()
{
return NeedleArtManager.Instance.GetNeedleArtByName(GetArtName(PlayerData.instance.CurrentCrestID));
}
}
public static class Util
{
public static Texture2D LoadTextureFromAssembly(string resourceName)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Expected O, but got Unknown
Assembly executingAssembly = Assembly.GetExecutingAssembly();
using Stream stream = executingAssembly.GetManifestResourceStream(resourceName);
if (stream == null)
{
NeedleArtsPlugin.Log.LogError((object)("Resource not found: " + resourceName));
return null;
}
using MemoryStream memoryStream = new MemoryStream();
stream.CopyTo(memoryStream);
byte[] array = memoryStream.ToArray();
Texture2D val = new Texture2D(2, 2);
ImageConversion.LoadImage(val, array);
return val;
}
public static tk2dSpriteAnimationClip CopyClip(tk2dSpriteAnimationClip clip, string newName)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
return new tk2dSpriteAnimationClip
{
name = newName,
frames = clip.frames,
fps = clip.fps,
loopStart = clip.loopStart,
wrapMode = clip.wrapMode
};
}
}
}
namespace NeedleArts.Patches
{
[HarmonyPatch]
public class AddSlot
{
private const float slotPosX = 1.2f;
private const float slotPosY = -3.45f;
private const float bracketOffset = 0.87f;
private static Transform _bracket1;
private static Transform _bracket2;
[HarmonyPatch(typeof(InventoryFloatingToolSlots), "Awake")]
[HarmonyPostfix]
private static void SpawnSlot(InventoryFloatingToolSlots __instance)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0101: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0113: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Expected O, but got Unknown
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Expected O, but got Unknown
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_020a: Unknown result type (might be due to invalid IL or missing references)
//IL_020c: Unknown result type (might be due to invalid IL or missing references)
//IL_021c: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Expected O, but got Unknown
//IL_030d: Unknown result type (might be due to invalid IL or missing references)
//IL_0312: Unknown result type (might be due to invalid IL or missing references)
//IL_033a: Unknown result type (might be due to invalid IL or missing references)
//IL_0341: Expected O, but got Unknown
//IL_0385: Unknown result type (might be due to invalid IL or missing references)
//IL_038a: Unknown result type (might be due to invalid IL or missing references)
//IL_0391: Unknown result type (might be due to invalid IL or missing references)
//IL_0398: Expected O, but got Unknown
//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
//IL_0498: Unknown result type (might be due to invalid IL or missing references)
//IL_049d: Unknown result type (might be due to invalid IL or missing references)
//IL_049f: Unknown result type (might be due to invalid IL or missing references)
//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
GameObject val = Object.Instantiate<GameObject>(((Component)((Component)__instance).transform.Find("Defend Slot")).gameObject, ((Component)__instance).transform);
((Object)val).name = "NeedleArt Slot";
val.SetActive(false);
val.GetComponent<InventoryToolCrestSlot>().slotInfo.Type = NeedleArtsPlugin.ToolType();
GameObject val2 = Object.Instantiate<GameObject>(((Component)((Component)__instance).transform.Find("Cursed Socket Top")).gameObject, ((Component)__instance).transform);
Extensions.SetLocalPosition2D(val2.transform, 1.2f, -3.45f);
Transform val3 = ((Component)__instance).transform.Find("Brackets/1 Slot Brackets/Bottom Bracket");
_bracket1 = Object.Instantiate<Transform>(val3, val3.parent.parent);
Extensions.SetRotation2D(_bracket1, 270f);
((Component)_bracket1).gameObject.SetActive(false);
_bracket2 = Object.Instantiate<Transform>(val3, val3.parent.parent);
Extensions.SetRotation2D(_bracket2, 90f);
((Component)_bracket2).gameObject.SetActive(false);
Slot val4 = new Slot
{
SlotObject = val.GetComponent<InventoryToolCrestSlot>(),
Type = NeedleArtsPlugin.ToolType(),
Id = "NeedleArtsSlot",
CursedSlot = val2
};
Test val5 = default(Test);
val5.FieldName = "hasChargeSlash";
val5.Type = (TestType)0;
val5.BoolValue = true;
Test val6 = val5;
List<Config> list = new List<Config>();
Config[] configs = __instance.configs;
Config val10;
PlayerDataTest val8;
foreach (Config val7 in configs)
{
val8 = new PlayerDataTest();
PlayerDataTest obj = val8;
TestGroup[] array = new TestGroup[1];
TestGroup val9 = default(TestGroup);
Test[] tests = val7.Condition.TestGroups[0].Tests;
int num = 0;
Test[] array2 = (Test[])(object)new Test[1 + tests.Length];
ReadOnlySpan<Test> readOnlySpan = new ReadOnlySpan<Test>(tests);
readOnlySpan.CopyTo(new Span<Test>(array2).Slice(num, readOnlySpan.Length));
num += readOnlySpan.Length;
array2[num] = val6;
num++;
val9.Tests = array2;
array[0] = val9;
obj.TestGroups = (TestGroup[])(object)array;
PlayerDataTest condition = val8;
val10 = new Config();
Config obj2 = val10;
Slot[] slots = val7.Slots;
num = 0;
Slot[] array3 = (Slot[])(object)new Slot[1 + slots.Length];
ReadOnlySpan<Slot> readOnlySpan2 = new ReadOnlySpan<Slot>(slots);
readOnlySpan2.CopyTo(new Span<Slot>(array3).Slice(num, readOnlySpan2.Length));
num += readOnlySpan2.Length;
array3[num] = val4;
num++;
obj2.Slots = array3;
Config obj3 = val10;
GameObject[] brackets = val7.Brackets;
num = 0;
GameObject[] array4 = (GameObject[])(object)new GameObject[2 + brackets.Length];
ReadOnlySpan<GameObject> readOnlySpan3 = new ReadOnlySpan<GameObject>(brackets);
readOnlySpan3.CopyTo(new Span<GameObject>(array4).Slice(num, readOnlySpan3.Length));
num += readOnlySpan3.Length;
array4[num] = ((Component)_bracket1).gameObject;
num++;
array4[num] = ((Component)_bracket2).gameObject;
num++;
obj3.Brackets = array4;
val10.PositionOffset = val7.PositionOffset;
val10.Condition = condition;
list.Add(val10);
}
val10 = new Config();
val10.Slots = (Slot[])(object)new Slot[1] { val4 };
val10.Brackets = (GameObject[])(object)new GameObject[2]
{
((Component)_bracket1).gameObject,
((Component)_bracket2).gameObject
};
val10.PositionOffset = new Vector2(0f, 0f);
Config obj4 = val10;
val8 = new PlayerDataTest();
val8.TestGroups = (TestGroup[])(object)new TestGroup[1]
{
new TestGroup
{
Tests = (Test[])(object)new Test[1] { val6 }
}
};
obj4.Condition = val8;
Config val11 = val10;
Config val12 = val11;
Config[] configs2 = __instance.configs;
List<Config> list2 = list;
int num2 = 0;
Config[] array5 = (Config[])(object)new Config[1 + (configs2.Length + list2.Count)];
array5[num2] = val12;
num2++;
ReadOnlySpan<Config> readOnlySpan4 = new ReadOnlySpan<Config>(configs2);
readOnlySpan4.CopyTo(new Span<Config>(array5).Slice(num2, readOnlySpan4.Length));
num2 += readOnlySpan4.Length;
foreach (Config item in list2)
{
array5[num2] = item;
num2++;
}
__instance.configs = array5;
SlotData data = ((SerializableNamedList<SlotData, NamedData>)(object)PlayerData.instance.ExtraToolEquips).GetData("NeedleArtsSlot");
if (string.IsNullOrEmpty(data.EquippedTool))
{
((SerializableNamedList<SlotData, NamedData>)(object)PlayerData.instance.ExtraToolEquips).SetData("NeedleArtsSlot", default(SlotData));
}
}
[HarmonyPatch(typeof(InventoryFloatingToolSlots), "Evaluate")]
[HarmonyPostfix]
private static void SetAnimator(InventoryFloatingToolSlots __instance)
{
Transform val = ((Component)__instance).transform.Find("NeedleArt Slot");
if (val != null)
{
Transform val2 = ((Component)__instance).transform.Find("Defend Slot");
if (val2 != null)
{
((Component)val.Find("Background Group/Background")).GetComponent<Animator>().runtimeAnimatorController = ((Component)val2.Find("Background Group/Background")).GetComponent<Animator>().runtimeAnimatorController;
}
}
}
[HarmonyPatch(typeof(InventoryItemGrid), "PositionGridItems")]
[HarmonyPostfix]
private static void SetNeedleArtSlotPosition(InventoryItemGrid __instance, List<InventoryItemSelectableDirectional> childItems)
{
if (((Object)((Component)__instance).gameObject).name != "Floating Slots")
{
return;
}
PlayerData instance = PlayerData.instance;
float num = ((instance.UnlockedExtraYellowSlot && !instance.UnlockedExtraBlueSlot) ? 1.73f : 0f);
foreach (InventoryItemSelectableDirectional item in childItems.Where((InventoryItemSelectableDirectional slot) => ((Object)slot).name == "NeedleArt Slot"))
{
Extensions.SetLocalPosition2D(((Component)item).transform, 1.2f, -3.45f + num);
}
Extensions.SetLocalPosition2D(_bracket1, 0.33000004f, -3.45f + num);
Extensions.SetLocalPosition2D(_bracket2, 2.0700002f, -3.45f + num);
}
}
[HarmonyPatch]
internal class ChangeHeader
{
[HarmonyPatch(typeof(InventoryItemToolManager), "Awake")]
[HarmonyPostfix]
private static void ChangeHeaderSprite(InventoryItemToolManager __instance)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
NestedFadeGroupSpriteRenderer val = __instance.listSectionHeaders[NeedleArtsPlugin.ToolType()];
Texture2D val2 = Util.LoadTextureFromAssembly("NeedleArts.Resources.NeedleArtUIHeading.png");
Sprite sprite = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 64f);
val.Sprite = sprite;
}
}
[HarmonyPatch]
internal class CopyAnims
{
private static bool _hasAddedAnims;
[HarmonyPatch(typeof(HeroController), "Awake")]
[HarmonyPostfix]
private static void CopyAnimations(HeroController __instance)
{
if (_hasAddedAnims)
{
return;
}
List<tk2dSpriteAnimationClip> list = new List<tk2dSpriteAnimationClip>();
tk2dSpriteAnimator animator = __instance.AnimCtrl.animator;
list.Add(Util.CopyClip(((IEnumerable<tk2dSpriteAnimationClip>)animator.Library.clips).FirstOrDefault((Func<tk2dSpriteAnimationClip, bool>)((tk2dSpriteAnimationClip c) => c.name == "Slash_Charged")), "Hunter_Anim"));
ConfigGroup[] configs = __instance.configs;
foreach (ConfigGroup val in configs)
{
if ((Object)(object)val.Config.heroAnimOverrideLib == (Object)null)
{
continue;
}
tk2dSpriteAnimationClip val2 = ((IEnumerable<tk2dSpriteAnimationClip>)val.Config.heroAnimOverrideLib.clips).FirstOrDefault((Func<tk2dSpriteAnimationClip, bool>)((tk2dSpriteAnimationClip c) => c.name == "Slash_Charged"));
if (val2 != null)
{
list.Add(Util.CopyClip(val2, ((Object)val.Config).name + "_Anim"));
tk2dSpriteAnimationClip val3 = ((IEnumerable<tk2dSpriteAnimationClip>)val.Config.heroAnimOverrideLib.clips).FirstOrDefault((Func<tk2dSpriteAnimationClip, bool>)((tk2dSpriteAnimationClip c) => c.name == "NeedleArt Dash"));
if (val3 != null)
{
list.Add(Util.CopyClip(val3, "NeedleArt Dash"));
}
tk2dSpriteAnimationClip val4 = ((IEnumerable<tk2dSpriteAnimationClip>)val.Config.heroAnimOverrideLib.clips).FirstOrDefault((Func<tk2dSpriteAnimationClip, bool>)((tk2dSpriteAnimationClip c) => c.name == "Slash_Charged_Loop"));
if (val4 != null)
{
list.Add(Util.CopyClip(val4, "Slash_Charged_Loop"));
}
}
}
tk2dSpriteAnimation library = animator.Library;
tk2dSpriteAnimationClip[] clips = animator.Library.clips;
List<tk2dSpriteAnimationClip> list2 = list;
int num = 0;
tk2dSpriteAnimationClip[] array = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[clips.Length + list2.Count];
ReadOnlySpan<tk2dSpriteAnimationClip> readOnlySpan = new ReadOnlySpan<tk2dSpriteAnimationClip>(clips);
readOnlySpan.CopyTo(new Span<tk2dSpriteAnimationClip>(array).Slice(num, readOnlySpan.Length));
num += readOnlySpan.Length;
foreach (tk2dSpriteAnimationClip item in list2)
{
array[num] = item;
num++;
}
library.clips = array;
ConfigGroup[] configs2 = __instance.configs;
foreach (ConfigGroup val5 in configs2)
{
if ((Object)(object)val5.Config.heroAnimOverrideLib == (Object)null)
{
continue;
}
tk2dSpriteAnimation heroAnimOverrideLib = val5.Config.heroAnimOverrideLib;
tk2dSpriteAnimationClip[] clips2 = val5.Config.heroAnimOverrideLib.clips;
List<tk2dSpriteAnimationClip> list3 = list;
int num2 = 0;
tk2dSpriteAnimationClip[] array2 = (tk2dSpriteAnimationClip[])(object)new tk2dSpriteAnimationClip[clips2.Length + list3.Count];
ReadOnlySpan<tk2dSpriteAnimationClip> readOnlySpan2 = new ReadOnlySpan<tk2dSpriteAnimationClip>(clips2);
readOnlySpan2.CopyTo(new Span<tk2dSpriteAnimationClip>(array2).Slice(num2, readOnlySpan2.Length));
num2 += readOnlySpan2.Length;
foreach (tk2dSpriteAnimationClip item2 in list3)
{
array2[num2] = item2;
num2++;
}
heroAnimOverrideLib.clips = array2;
}
_hasAddedAnims = true;
}
}
[HarmonyPatch]
internal class PatchChargedSlash
{
[HarmonyPatch(typeof(GetHeroAttackObject), "GetGameObject")]
[HarmonyPostfix]
private static void PatchGetGameObject(GetHeroAttackObject __instance, ref GameObject __result)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Invalid comparison between Unknown and I4
if ((int)(AttackObjects)(object)__instance.Attack.Value == 7)
{
NeedleArt activeNeedleArt = NeedleArtManager.Instance.GetActiveNeedleArt();
if (activeNeedleArt != null)
{
__result = activeNeedleArt.GetChargeSlash();
}
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
private static void PatchChargeSlashRecoils(ref bool __result)
{
NeedleArt activeNeedleArt = NeedleArtManager.Instance.GetActiveNeedleArt();
if (activeNeedleArt != null)
{
__result = activeNeedleArt.GetConfig().chargeSlashRecoils;
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
private static void PatchChargeSlashChain(ref int __result)
{
NeedleArt activeNeedleArt = NeedleArtManager.Instance.GetActiveNeedleArt();
if (activeNeedleArt != null)
{
__result = activeNeedleArt.GetConfig().chargeSlashChain;
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
private static void PatchChargeSlashLungeSpeed(ref float __result)
{
NeedleArt activeNeedleArt = NeedleArtManager.Instance.GetActiveNeedleArt();
if (activeNeedleArt != null)
{
__result = activeNeedleArt.GetConfig().chargeSlashLungeSpeed;
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
private static void PatchChargeSlashLungeDeceleration(ref float __result)
{
NeedleArt activeNeedleArt = NeedleArtManager.Instance.GetActiveNeedleArt();
if (activeNeedleArt != null)
{
__result = activeNeedleArt.GetConfig().chargeSlashLungeDeceleration;
}
}
[HarmonyPatch(typeof(PlayMakerFSM), "Start")]
[HarmonyPostfix]
private static void PatchNailArtsFSM(PlayMakerFSM __instance)
{
//IL_010d: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Expected O, but got Unknown
if (__instance == null || !(((Object)__instance).name == "Hero_Hornet(Clone)") || !(__instance.FsmName == "Nail Arts"))
{
return;
}
FsmUtil.AddStringVariable(__instance, "NeedleArtName");
FsmUtil.AddStringVariable(__instance, "ClipName");
FsmState state = FsmUtil.GetState(__instance, "Get Charge Slash");
FsmUtil.InsertAction(state, 0, (FsmStateAction)(object)new DelegateAction<(NamedVariable, NamedVariable, NeedleArtManager)>
{
Arg = ((NamedVariable)(object)FsmUtil.GetStringVariable(__instance, "NeedleArtName"), (NamedVariable)(object)FsmUtil.GetStringVariable(__instance, "ClipName"), NeedleArtManager.Instance),
Method = delegate((NamedVariable needleArtName, NamedVariable clipName, NeedleArtManager manager) args)
{
args.manager.SetActiveNeedleArt();
NeedleArt activeNeedleArt = args.manager.GetActiveNeedleArt();
args.needleArtName.RawValue = activeNeedleArt.Name;
args.clipName.RawValue = activeNeedleArt.AnimName;
}
});
FsmUtil.RemoveActionsOfType<CheckIfCrestEquipped>(FsmUtil.GetState(__instance, "Antic Type"));
foreach (NeedleArt allNeedleArt in NeedleArtManager.Instance.GetAllNeedleArts())
{
allNeedleArt.EditFsm(__instance);
}
FsmUtil.ReplaceAction(FsmUtil.GetState(__instance, "Slash Recoil?"), 0, (FsmStateAction)new StringCompare
{
stringVariable = FsmUtil.GetStringVariable(__instance, "NeedleArtName"),
compareTo = FsmString.op_Implicit("ShamanArt"),
notEqualEvent = FsmEvent.Finished
});
FsmUtil.AddAction(FsmUtil.GetState(__instance, "Regain Full Control"), (FsmStateAction)(object)new DelegateAction<NeedleArtManager>
{
Arg = NeedleArtManager.Instance,
Method = delegate(NeedleArtManager manager)
{
manager.ResetActiveNeedleArt();
}
});
}
}
[HarmonyPatch]
internal class PatchToolMaker
{
[HarmonyPatch(typeof(ToolMaker), "AddCustomTool", new Type[] { typeof(ToolItem) })]
[HarmonyPostfix]
private static void AddToolItem(ToolItem toolItem)
{
NeedleArt needleArtByName = NeedleArtManager.Instance.GetNeedleArtByName(toolItem.name);
needleArtByName.ToolItem = toolItem;
if (NeedleArtsPlugin.SimpleUnlock.Value)
{
(needleArtByName as CrestArt)?.AddSimpleUnlockTest();
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
private static void RemovePercentage(ToolItem __instance, ref bool __result)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if (__instance.Type == NeedleArtsPlugin.ToolType())
{
__result = false;
}
}
}
[HarmonyPatch]
internal class UnlockArt
{
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPrefix]
private static void UnlockNeedleArtPre(InventoryToolCrestSlot __instance, out bool __state)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
__state = __instance.SaveData.IsUnlocked;
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
private static void UnlockNeedleArtPost(InventoryToolCrestSlot __instance, bool __state)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
if (!__state && __instance.SaveData.IsUnlocked && PlayerData.instance.hasChargeSlash && __instance.Crest.GetSlots().All((InventoryToolCrestSlot slot) => !slot.IsLocked))
{
NeedleArt? needleArtByName = NeedleArtManager.Instance.GetNeedleArtByName(CrestArtUtil.GetArtName(((Object)__instance.Crest).name));
if (needleArtByName != null)
{
needleArtByName.ToolItem.Unlock((Action)null, (PopupFlags)3);
}
}
}
[HarmonyPatch(typeof(PlayMakerFSM), "Awake")]
[HarmonyPostfix]
private static void UnlockAtPinstress(PlayMakerFSM __instance)
{
if (__instance == null || !(((Object)__instance).name == "Pinstress Interior Ground Sit") || !(__instance.FsmName == "Behaviour"))
{
return;
}
FsmUtil.InsertAction(FsmUtil.GetState(__instance, "Save"), 4, (FsmStateAction)(object)new DelegateAction<InventoryItemToolManager>
{
Arg = ((IEnumerable<InventoryItemToolManager>)Resources.FindObjectsOfTypeAll<InventoryItemToolManager>()).FirstOrDefault((Func<InventoryItemToolManager, bool>)delegate(InventoryItemToolManager m)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
Scene scene = ((Component)m).gameObject.scene;
return ((Scene)(ref scene)).IsValid();
}),
Method = delegate(InventoryItemToolManager manager)
{
foreach (InventoryToolCrest crest in ((Component)manager).GetComponent<InventoryItemToolManager>().crestList.crests)
{
if (crest.GetSlots().All((InventoryToolCrestSlot slot) => !slot.IsLocked))
{
NeedleArtManager.Instance.GetNeedleArtByName(CrestArtUtil.GetArtName(((Object)crest).name)).ToolItem.Unlock((Action)null, (PopupFlags)3);
}
}
}
});
}
[HarmonyPatch(typeof(ToolItemManager), "AutoEquip", new Type[]
{
typeof(ToolCrest),
typeof(bool),
typeof(bool)
})]
[HarmonyPostfix]
private static void AutoEquipOnUnlock(ToolCrest crest)
{
if (PlayerData.instance.hasChargeSlash)
{
NeedleArtManager.AutoEquipArt(CrestArtUtil.GetCrestArt().ToolItem);
}
}
[HarmonyPatch(typeof(InventoryItemToolManager), "UnequipTool")]
[HarmonyPostfix]
private static void AutoEquip(InventoryItemToolManager __instance, InventoryToolCrestSlot slot)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if (slot.Type == NeedleArtsPlugin.ToolType())
{
NeedleArtManager.AutoEquipArt(CrestArtUtil.GetCrestArt().ToolItem);
}
}
}
}
namespace NeedleArts.Managers
{
public class NeedleArtManager
{
private readonly List<NeedleArt> NeedleArts = new List<NeedleArt>();
private NeedleArt? _activeNeedleArt;
public static NeedleArtManager Instance { get; internal set; }
public void AddNeedleArt(NeedleArt needleArt)
{
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
NeedleArts.Add(needleArt);
Texture2D val = Util.LoadTextureFromAssembly("NeedleArts.Resources." + needleArt.Name + "Icon.png");
Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 260f);
ToolData val3 = NeedleforgePlugin.AddTool(needleArt.Name, NeedleArtsPlugin.ToolType(), new LocalisedString
{
Key = needleArt.Name + "_Tool",
Sheet = "Mods.io.github.jadedbay.needlearts"
}, new LocalisedString
{
Key = needleArt.Name + "_ToolDesc",
Sheet = "Mods.io.github.jadedbay.needlearts"
}, val2);
val3.UnlockedAtStart = false;
}
public List<NeedleArt> GetAllNeedleArts()
{
return NeedleArts;
}
public NeedleArt? GetNeedleArtByName(string name)
{
string name2 = name;
return NeedleArts.FirstOrDefault((NeedleArt art) => art.Name == name2);
}
public void SetActiveNeedleArt()
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
InputHandler inputHandler = HeroController.instance.inputHandler;
SlotInfo[] slots = ToolItemManager.GetCrestByName(PlayerData.instance.CurrentCrestID).Slots;
List<SlotData> slots2 = ((SerializableNamedList<Data, NamedData>)(object)PlayerData.instance.ToolEquips).GetData(PlayerData.instance.CurrentCrestID).Slots;
SlotData data2 = ((SerializableNamedList<SlotData, NamedData>)(object)PlayerData.instance.ExtraToolEquips).GetData("NeedleArtsSlot");
_activeNeedleArt = GetNeedleArtByName(data2.EquippedTool);
List<(SlotInfo, SlotData)> source = (from slot in slots.Zip(slots2, (SlotInfo info, SlotData data) => (info, data))
where slot.info.Type == NeedleArtsPlugin.ToolType()
select slot).ToList();
_activeNeedleArt = (from s in source
where ((int)s.info.AttackBinding == 1 && ((OneAxisInputControl)inputHandler.inputActions.Up).IsPressed) || ((int)s.info.AttackBinding == 2 && ((OneAxisInputControl)inputHandler.inputActions.Down).IsPressed)
select GetNeedleArtByName(s.data.EquippedTool)).FirstOrDefault((NeedleArt art) => art != null) ?? GetNeedleArtByName(data2.EquippedTool) ?? source.Select<(SlotInfo, SlotData), NeedleArt>(((SlotInfo info, SlotData data) slot) => GetNeedleArtByName(slot.data.EquippedTool)).FirstOrDefault((NeedleArt art) => art != null);
}
public NeedleArt? GetActiveNeedleArt()
{
return _activeNeedleArt;
}
public void ResetActiveNeedleArt()
{
_activeNeedleArt = null;
}
public static void AutoEquipArt(ToolItem needleArt)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
InventoryItemToolManager val = ((IEnumerable<InventoryItemToolManager>)Resources.FindObjectsOfTypeAll<InventoryItemToolManager>()).FirstOrDefault((Func<InventoryItemToolManager, bool>)delegate(InventoryItemToolManager m)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
Scene scene = ((Component)m).gameObject.scene;
return ((Scene)(ref scene)).IsValid();
});
foreach (InventoryToolCrestSlot slot in val.extraSlots.GetSlots())
{
if (slot.Type == NeedleArtsPlugin.ToolType())
{
slot.SetEquipped(needleArt, true, true);
}
}
}
}
}
namespace NeedleArts.ArtTools
{
public class CrestArt : NeedleArt
{
public string EventName { get; }
public int ConfigId { get; }
public string AnticName { get; }
public string? CrestDataField { get; }
public CrestArt(string name, string eventName, string anticName, string animName, int configId, string? crestDataField)
{
EventName = eventName;
ConfigId = configId;
AnticName = anticName;
CrestDataField = crestDataField;
base..ctor(name, animName);
}
public override GameObject GetChargeSlash()
{
return HeroController.instance.configs[ConfigId].ChargeSlash;
}
public override HeroControllerConfig GetConfig()
{
return HeroController.instance.configs[ConfigId].Config;
}
public override void EditFsm(PlayMakerFSM fsm)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Expected O, but got Unknown
FsmUtil.AddAction(FsmUtil.GetState(fsm, "Antic Type"), (FsmStateAction)new StringCompare
{
stringVariable = FsmUtil.GetStringVariable(fsm, "NeedleArtName"),
compareTo = FsmString.op_Implicit(base.Name),
equalEvent = FsmEvent.GetFsmEvent(EventName)
});
FsmUtil.GetFirstActionOfType<Tk2dPlayAnimationWithEvents>(FsmUtil.GetState(fsm, AnticName)).clipName = FsmUtil.GetStringVariable(fsm, "ClipName");
}
public void AddSimpleUnlockTest()
{
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0125: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Expected O, but got Unknown
TestGroup[] testGroups = base.ToolItem.alternateUnlockedTest.TestGroups;
int num = 0;
TestGroup[] array = (TestGroup[])(object)new TestGroup[1 + testGroups.Length];
ReadOnlySpan<TestGroup> readOnlySpan = new ReadOnlySpan<TestGroup>(testGroups);
readOnlySpan.CopyTo(new Span<TestGroup>(array).Slice(num, readOnlySpan.Length));
num += readOnlySpan.Length;
int num2 = num;
TestGroup val = default(TestGroup);
Test[] array2 = (Test[])((CrestDataField == null) ? ((Array)Array.Empty<Test>()) : ((Array)new Test[1]
{
new Test
{
Type = (TestType)0,
FieldName = CrestDataField,
BoolValue = true
}
}));
int num3 = 0;
Test[] array3 = (Test[])(object)new Test[1 + array2.Length];
ReadOnlySpan<Test> readOnlySpan2 = new ReadOnlySpan<Test>(array2);
readOnlySpan2.CopyTo(new Span<Test>(array3).Slice(num3, readOnlySpan2.Length));
num3 += readOnlySpan2.Length;
array3[num3] = new Test
{
Type = (TestType)0,
FieldName = "hasChargeSlash",
BoolValue = true
};
num3++;
val.Tests = array3;
array[num2] = val;
num++;
TestGroup[] testGroups2 = array;
base.ToolItem.alternateUnlockedTest = new PlayerDataTest
{
TestGroups = testGroups2
};
}
public void RemoveSimpleUnlockTest()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
base.ToolItem.alternateUnlockedTest = new PlayerDataTest();
}
}
public abstract class NeedleArt
{
public string Name { get; }
public ToolItem ToolItem { get; set; }
public string AnimName { get; }
protected NeedleArt(string name, string animName)
{
Name = name;
AnimName = animName;
base..ctor();
}
public abstract GameObject GetChargeSlash();
public abstract HeroControllerConfig GetConfig();
public abstract void EditFsm(PlayMakerFSM fsm);
}
}