Please disclose if your mod was created primarily using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ValkreamPlus v1.0.6
ValkreamPlus.dll
Decompiled 2 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using HarmonyLib; using Jewelcrafting; using Jotunn; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using SimpleJson; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("ValkreamPlus")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ValkreamPlus")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")] [assembly: AssemblyFileVersion("1.0.5")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.5.0")] [module: UnverifiableCode] namespace ValkreamPlus; public class FireWaveChargeComponent : MonoBehaviour { public const int MaxCharge = 100; private float _chargeFloat; public float decayPerSecond = 2.8f; public float decayDelay = 3f; private float _timeSinceLastHit; private Player _player; public int Charge => Mathf.Clamp(Mathf.RoundToInt(_chargeFloat), 0, 100); public bool IsReady => Charge >= 100; private void Awake() { _player = ((Component)this).GetComponent<Player>(); } private void ApplyChargeToHud() { int charge = Charge; FireWaveHud.Instance?.UpdateBar(charge, 100, IsReady); } public void AddRandomChargeFromHit() { if (!((Object)(object)_player == (Object)null) && ((Character)_player).IsOwner()) { int num = Random.Range(2, 9); _chargeFloat = Mathf.Clamp(_chargeFloat + (float)num, 0f, 100f); _timeSinceLastHit = 0f; ApplyChargeToHud(); } } public void ResetCharge() { _chargeFloat = 0f; _timeSinceLastHit = 0f; ApplyChargeToHud(); } private void Update() { if ((Object)(object)_player == (Object)null || !((Character)_player).IsOwner()) { return; } if (IsReady) { _timeSinceLastHit = 0f; ApplyChargeToHud(); return; } _timeSinceLastHit += Time.deltaTime; if (!(decayPerSecond <= 0f) && !(_chargeFloat <= 0f) && !(_timeSinceLastHit < decayDelay)) { _chargeFloat = Mathf.MoveTowards(_chargeFloat, 0f, decayPerSecond * Time.deltaTime); ApplyChargeToHud(); } } public static void OnHit(Player player) { if (!((Object)(object)player == (Object)null)) { FireWaveChargeComponent component = ((Component)player).GetComponent<FireWaveChargeComponent>(); if (!((Object)(object)component == (Object)null)) { component.AddRandomChargeFromHit(); } } } } public class FireWaveHud { private static FireWaveHud _instance; private GameObject _root; private RectTransform _rootRt; private CanvasGroup _canvasGroup; private RectTransform _trackRt; private Image _fillImage; private RectTransform _fillRt; private Text _text; private RectTransform _staminaRoot; private Vector2 _offsetFromStamina = new Vector2(0f, 22f); private bool _isReady; private bool _visibleTarget; private float _pulseTimer; private const float FadeSpeed = 5f; private readonly Color _baseColor = new Color(0.6f, 0.05f, 0.05f, 1f); private readonly Color _pulseColor = new Color(1f, 0.18f, 0.18f, 1f); public static FireWaveHud Instance => _instance; public static void Init(Hud hud) { if (_instance == null) { _instance = new FireWaveHud(); _instance.CreateUi(hud); } } private void CreateUi(Hud hud) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: 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_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Expected O, but got Unknown //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: 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_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Expected O, but got Unknown //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0376: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Expected O, but got Unknown //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Expected O, but got Unknown //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_04ce: Unknown result type (might be due to invalid IL or missing references) //IL_04da: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) _staminaRoot = hud.m_staminaBar2Root; if ((Object)(object)_staminaRoot == (Object)null) { Logger.LogWarning((object)"[ValkreamPlus] FireWaveHud: m_staminaBar2Root is null"); return; } Sprite val = null; Material val2 = null; try { GuiBar staminaBar2Slow = hud.m_staminaBar2Slow; if ((Object)(object)staminaBar2Slow != (Object)null) { Type type = ((object)staminaBar2Slow).GetType(); BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic; FieldInfo field = type.GetField("m_bar", bindingAttr); if (field != null) { object? value = field.GetValue(staminaBar2Slow); Image val3 = (Image)((value is Image) ? value : null); if ((Object)(object)val3 != (Object)null) { val = val3.sprite; val2 = ((Graphic)val3).material; } } } } catch { } _root = new GameObject("FireWaveChargeBarRoot"); _root.transform.SetParent(((Transform)_staminaRoot).parent, false); _rootRt = _root.AddComponent<RectTransform>(); _rootRt.anchorMin = _staminaRoot.anchorMin; _rootRt.anchorMax = _staminaRoot.anchorMax; _rootRt.pivot = _staminaRoot.pivot; _rootRt.anchoredPosition = _staminaRoot.anchoredPosition + _offsetFromStamina; _rootRt.sizeDelta = _staminaRoot.sizeDelta; Vector2 sizeDelta = _rootRt.sizeDelta; sizeDelta.x *= 1.6f; sizeDelta.y *= 0.4f; _rootRt.sizeDelta = sizeDelta; _canvasGroup = _root.AddComponent<CanvasGroup>(); _canvasGroup.alpha = 0f; GameObject val4 = new GameObject("BG"); val4.transform.SetParent(_root.transform, false); RectTransform val5 = val4.AddComponent<RectTransform>(); val5.anchorMin = new Vector2(0f, 0f); val5.anchorMax = new Vector2(1f, 1f); val5.offsetMin = Vector2.zero; val5.offsetMax = Vector2.zero; Image val6 = val4.AddComponent<Image>(); if ((Object)(object)val != (Object)null) { val6.sprite = val; val6.type = (Type)1; } if ((Object)(object)val2 != (Object)null) { ((Graphic)val6).material = val2; } ((Graphic)val6).color = new Color(0f, 0f, 0f, 0.8f); GameObject val7 = new GameObject("Track"); val7.transform.SetParent(_root.transform, false); _trackRt = val7.AddComponent<RectTransform>(); _trackRt.anchorMin = new Vector2(0f, 0.5f); _trackRt.anchorMax = new Vector2(1f, 0.5f); _trackRt.pivot = new Vector2(0.5f, 0.5f); _trackRt.anchoredPosition = Vector2.zero; float num = _rootRt.sizeDelta.y * 0.7f; _trackRt.sizeDelta = new Vector2(0f, num); Image val8 = val7.AddComponent<Image>(); if ((Object)(object)val != (Object)null) { val8.sprite = val; val8.type = (Type)1; } if ((Object)(object)val2 != (Object)null) { ((Graphic)val8).material = val2; } ((Graphic)val8).color = new Color(0.35f, 0.1f, 0.02f, 1f); GameObject val9 = new GameObject("Fill"); val9.transform.SetParent((Transform)(object)_trackRt, false); _fillRt = val9.AddComponent<RectTransform>(); _fillRt.anchorMin = new Vector2(0f, 0f); _fillRt.anchorMax = new Vector2(0f, 1f); _fillRt.pivot = new Vector2(0f, 0.5f); _fillRt.anchoredPosition = Vector2.zero; _fillRt.sizeDelta = new Vector2(0f, 0f); _fillImage = val9.AddComponent<Image>(); if ((Object)(object)val != (Object)null) { _fillImage.sprite = val; _fillImage.type = (Type)1; } if ((Object)(object)val2 != (Object)null) { ((Graphic)_fillImage).material = val2; } ((Graphic)_fillImage).color = _baseColor; GameObject val10 = new GameObject("FireWaveText"); val10.transform.SetParent(_root.transform, false); RectTransform val11 = val10.AddComponent<RectTransform>(); val11.anchorMin = new Vector2(0.5f, 0.5f); val11.anchorMax = new Vector2(0.5f, 0.5f); val11.pivot = new Vector2(0.5f, 0.5f); val11.anchoredPosition = Vector2.zero; val11.sizeDelta = _rootRt.sizeDelta; _text = val10.AddComponent<Text>(); _text.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); _text.fontSize = 14; _text.fontStyle = (FontStyle)1; _text.alignment = (TextAnchor)4; ((Graphic)_text).color = Color.white; _text.text = "0"; _visibleTarget = false; } public void SetVisible(bool visible) { _visibleTarget = visible; } public void UpdateBar(int current, int max, bool isReady) { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_fillImage == (Object)null) && !((Object)(object)_fillRt == (Object)null) && !((Object)(object)_trackRt == (Object)null)) { float num = ((max > 0) ? ((float)current / (float)max) : 0f); num = Mathf.Clamp01(num); Rect rect = _trackRt.rect; float width = ((Rect)(ref rect)).width; float num2 = width * num; _fillRt.SetSizeWithCurrentAnchors((Axis)0, num2); if ((Object)(object)_text != (Object)null) { _text.text = current.ToString(); } if (!isReady) { _isReady = false; _pulseTimer = 0f; ((Graphic)_fillImage).color = _baseColor; } else { _isReady = true; } } } public void Tick(float dt) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)_root == (Object)null) && !((Object)(object)_canvasGroup == (Object)null)) { if ((Object)(object)_staminaRoot != (Object)null && (Object)(object)_rootRt != (Object)null) { _rootRt.anchoredPosition = _staminaRoot.anchoredPosition + _offsetFromStamina; } float num = (_visibleTarget ? 1f : 0f); _canvasGroup.alpha = Mathf.MoveTowards(_canvasGroup.alpha, num, 5f * dt); if (_isReady && (Object)(object)_fillImage != (Object)null) { _pulseTimer += dt; float num2 = (Mathf.Sin(_pulseTimer * 6f) + 1f) * 0.5f; ((Graphic)_fillImage).color = Color.Lerp(_baseColor, _pulseColor, num2); } } } } internal class LagPatch { internal static class NeckCache { private static readonly Dictionary<VisEquipment, ItemData> Cache = new Dictionary<VisEquipment, ItemData>(); private static readonly HashSet<VisEquipment> Dirty = new HashSet<VisEquipment>(); public static void MarkDirty(VisEquipment vis) { if (Object.op_Implicit((Object)(object)vis)) { Dirty.Add(vis); } } public static bool TryGet(Player p, out ItemData neck) { neck = null; if (!Ready || (Object)(object)p == (Object)null) { return false; } VisEquipment visEquipment = ((Humanoid)p).m_visEquipment; if (!Object.op_Implicit((Object)(object)visEquipment)) { return false; } if (!Dirty.Contains(visEquipment) && Cache.TryGetValue(visEquipment, out neck) && neck != null) { return true; } object[] array = new object[2] { visEquipment, null }; if ((bool)MI_TryGetValue.Invoke(VisualsDict, array) && array[1] != null) { object obj = array[1]; object? value = FI_EquippedNeckItem.GetValue(obj); neck = (ItemData)((value is ItemData) ? value : null); Cache[visEquipment] = neck; } else { Cache.Remove(visEquipment); neck = null; } Dirty.Remove(visEquipment); return neck != null; } } [HarmonyPatch(typeof(Humanoid), "EquipItem")] private static class Humanoid_Equip_Patch { private static void Postfix(Humanoid __instance) { NeckCache.MarkDirty(__instance?.m_visEquipment); } } [HarmonyPatch(typeof(Humanoid), "UnequipItem")] private static class Humanoid_Unequip_Patch { private static void Postfix(Humanoid __instance) { NeckCache.MarkDirty(__instance?.m_visEquipment); } } public static bool Ready; public static object VisualsDict; public static MethodInfo MI_TryGetValue; public static FieldInfo FI_EquippedNeckItem; public static void Init() { try { if (!Chainloader.PluginInfos.TryGetValue("org.bepinex.plugins.jewelcrafting", out var value)) { Ready = false; return; } Assembly assembly = ((object)value.Instance).GetType().Assembly; Type type = assembly.GetType("Jewelcrafting.Visual"); if (type == null) { Ready = false; return; } FieldInfo fieldInfo = AccessTools.Field(type, "visuals"); if (fieldInfo == null) { Ready = false; return; } VisualsDict = fieldInfo.GetValue(null); if (VisualsDict == null) { Ready = false; return; } MI_TryGetValue = VisualsDict.GetType().GetMethod("TryGetValue"); if (MI_TryGetValue == null) { Ready = false; return; } Type parameterType = MI_TryGetValue.GetParameters()[1].ParameterType; Type type2 = (parameterType.IsByRef ? parameterType.GetElementType() : parameterType); FI_EquippedNeckItem = AccessTools.Field(type2, "equippedNeckItem"); Ready = FI_EquippedNeckItem != null; } catch { Ready = false; } } } [BepInPlugin("com.jotunn.ValkreamPlus", "ValkreamPlus", "1.0.5")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] internal class ValkreamPlus : BaseUnityPlugin { public class SE_CollierValkream : StatusEffect { public float m_eitr; public float m_skillup; public float m_regenModifier; public void SetEitr(float eitr) { m_eitr = eitr; } public void SetSkill(float skill) { m_skillup = skill; } public void SetRegenModifier(float regenModifier) { m_regenModifier = regenModifier; } public override void ModifyEitrRegen(ref float regen) { regen *= m_regenModifier; } public override void ModifySkillLevel(SkillType skill, ref float value) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)skill == 10 || (int)skill == 9) { value += m_skillup; } } } [HarmonyPatch(typeof(Player), "GetTotalFoodValue")] public static class EitrFromItemsPatch { [HarmonyPostfix] private static void Postfix(Player __instance, ref float eitr) { if (((Character)(__instance?)).m_seman == null) { return; } foreach (StatusEffect statusEffect in ((Character)__instance).m_seman.m_statusEffects) { if (statusEffect is SE_CollierValkream sE_CollierValkream && sE_CollierValkream.m_eitr != 0f) { eitr += sE_CollierValkream.m_eitr; } } } } [HarmonyPatch] public static class Patch_IsNeckItem { private static MethodBase TargetMethod() { if (!Chainloader.PluginInfos.TryGetValue("org.bepinex.plugins.jewelcrafting", out var value)) { return null; } Assembly assembly = ((object)value.Instance).GetType().Assembly; Type type = assembly.GetType("Jewelcrafting.Visual"); if (type == null) { return null; } return AccessTools.Method(type, "IsNeckItem", (Type[])null, (Type[])null); } private static void Postfix(ItemData item, ref bool __result) { object obj; if (item == null) { obj = null; } else { GameObject dropPrefab = item.m_dropPrefab; obj = ((dropPrefab != null) ? ((Object)dropPrefab).name : null); } if ((string?)obj == "JC_Necklace_Valkream") { __result = true; } } } [HarmonyPatch(typeof(Player), "GetBodyArmor")] public static class AddNecklaceArmorPatch { public static void Postfix(Player __instance, ref float __result) { if (!((Object)(object)__instance == (Object)null) && LagPatch.Ready && LagPatch.NeckCache.TryGet(__instance, out var neck) && (Object)(object)neck?.m_dropPrefab != (Object)null && ((Object)neck.m_dropPrefab).name == "JC_Necklace_Valkream") { SharedData shared = neck.m_shared; int num = Mathf.Max(1, neck.m_quality); __result += shared.m_armor + shared.m_armorPerLevel * (float)(num - 1); } } } [HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[] { typeof(ItemData), typeof(int), typeof(bool), typeof(float), typeof(int) })] public static class NecklaceArmorTooltipPatch { [HarmonyPostfix] public static void Postfix(ItemData item, int qualityLevel, float worldLevel, ref string __result) { if ((Object)(object)item?.m_dropPrefab == (Object)null || ((Object)item.m_dropPrefab).name != "JC_Necklace_Valkream") { return; } string text = Localization.instance.Localize("$item_armor"); string value = Localization.instance.Localize("$item_quality"); if (__result.IndexOf(text, StringComparison.OrdinalIgnoreCase) >= 0) { return; } float num = item.m_shared.m_armor + item.m_shared.m_armorPerLevel * (float)Mathf.Max(0, qualityLevel - 1); string text2 = $"\n{text}: <color=orange>{num:0}</color>"; int num2 = __result.IndexOf(value, StringComparison.OrdinalIgnoreCase); if (num2 >= 0) { int num3 = __result.IndexOf('\n', num2); if (num3 < 0) { num3 = __result.Length; } __result = __result.Insert(num3, text2); } else { __result = text2 + "\n" + __result; } } } [HarmonyPatch(typeof(Character), "RPC_Damage")] public static class Character_RPC_Damage_FireWaveCharge_Patch { private static void Prefix(Character __instance, HitData hit) { if ((Object)(object)__instance == (Object)null || __instance.IsDead()) { return; } Character attacker = hit.GetAttacker(); Player val = (Player)(object)((attacker is Player) ? attacker : null); if (val == null) { return; } Humanoid val2 = (Humanoid)(object)val; if (!((Object)(object)val2 == (Object)null)) { ItemData rightItem = val2.m_rightItem; if (rightItem != null && !((Object)(object)rightItem.m_dropPrefab == (Object)null) && !(((Object)rightItem.m_dropPrefab).name != "HelBlade")) { FireWaveChargeComponent.OnHit(val); } } } } [HarmonyPatch(typeof(Hud), "Awake")] public static class Hud_Awake_FireWaveBar { private static void Postfix(Hud __instance) { FireWaveHud.Init(__instance); } } [HarmonyPatch(typeof(Hud), "Update")] public static class Hud_Update_FireWaveBar { private static bool _lastHasHelBlade; private static bool _initialized; private static void Postfix(Hud __instance) { if (FireWaveHud.Instance == null) { return; } Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || !((Character)localPlayer).IsOwner()) { FireWaveHud.Instance.SetVisible(visible: false); FireWaveHud.Instance.Tick(Time.deltaTime); _lastHasHelBlade = false; _initialized = false; return; } FireWaveChargeComponent component = ((Component)localPlayer).GetComponent<FireWaveChargeComponent>(); if ((Object)(object)component == (Object)null) { FireWaveHud.Instance.SetVisible(visible: false); FireWaveHud.Instance.Tick(Time.deltaTime); _lastHasHelBlade = false; _initialized = false; return; } ItemData currentWeapon = ((Humanoid)localPlayer).GetCurrentWeapon(); bool flag = currentWeapon != null && (Object)(object)currentWeapon.m_dropPrefab != (Object)null && ((Object)currentWeapon.m_dropPrefab).name == "HelBlade"; if (_initialized && _lastHasHelBlade && !flag) { component.ResetCharge(); } _lastHasHelBlade = flag; _initialized = true; bool visible = flag && component.Charge > 0; FireWaveHud.Instance.SetVisible(visible); if (flag) { FireWaveHud.Instance.UpdateBar(component.Charge, 100, component.IsReady); } FireWaveHud.Instance.Tick(Time.deltaTime); } } public static class FireWaveInputHandler { public static KeyCode FireWaveKey = (KeyCode)103; public static void Update() { //IL_0061: Unknown result type (might be due to invalid IL or missing references) Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || !((Character)localPlayer).IsOwner()) { return; } FireWaveChargeComponent component = ((Component)localPlayer).GetComponent<FireWaveChargeComponent>(); if (!((Object)(object)component == (Object)null) && component.IsReady) { ItemData currentWeapon = ((Humanoid)localPlayer).GetCurrentWeapon(); if (currentWeapon != null && !((Object)(object)currentWeapon.m_dropPrefab == (Object)null) && !(((Object)currentWeapon.m_dropPrefab).name != "HelBlade") && Input.GetKeyDown(FireWaveKey)) { Logger.LogInfo((object)"[ValkreamPlus] FireWave key pressed, triggering skill."); FireWaveSkill.Trigger(localPlayer, component); } } } } public static class FireWaveSkill { public static float Radius = 6f; public static float FireDamage = 1200f; public static float StaminaCost = 50f; public static void Trigger(Player player, FireWaveChargeComponent comp) { if (!((Object)(object)player == (Object)null) && !((Object)(object)comp == (Object)null) && (!(StaminaCost > 0f) || ((Character)player).HaveStamina(StaminaCost))) { if (StaminaCost > 0f) { ((Character)player).UseStamina(StaminaCost); } comp.ResetCharge(); Animator animator = ((Character)player).m_animator; if ((Object)(object)animator != (Object)null) { animator.SetTrigger("emote_roar"); } SpawnFireVFX(player); DoFireWaveDamage(player); } } private static void SpawnFireVFX(Player player) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = ZNetScene.instance.GetPrefab("vfx_FireballHit"); if (!((Object)(object)prefab == (Object)null)) { Object.Instantiate<GameObject>(prefab, ((Component)player).transform.position, Quaternion.identity); } } private static void DoFireWaveDamage(Player player) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)player).transform.position; Collider[] array = Physics.OverlapSphere(position, Radius, LayerMask.GetMask(new string[1] { "character" })); Collider[] array2 = array; foreach (Collider val in array2) { Character componentInParent = ((Component)val).GetComponentInParent<Character>(); if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)componentInParent == (Object)(object)player) && BaseAI.IsEnemy((Character)(object)player, componentInParent)) { HitData val2 = new HitData(); val2.m_attacker = ((Character)player).GetZDOID(); val2.m_skill = (SkillType)9; val2.m_point = componentInParent.GetCenterPoint(); Vector3 val3 = ((Component)componentInParent).transform.position - position; val2.m_dir = ((Vector3)(ref val3)).normalized; val2.m_damage = new DamageTypes { m_fire = FireDamage }; componentInParent.Damage(val2); } } } } [HarmonyPatch(typeof(Player), "Update")] public static class Player_Update_FireWaveInput { private static void Postfix(Player __instance) { if (((Character)__instance).IsOwner()) { FireWaveInputHandler.Update(); } } } [HarmonyPatch(typeof(Player), "OnSpawned")] public static class Player_OnSpawned_FireWaveCharge_Patch { private static void Postfix(Player __instance) { FireWaveChargeComponent fireWaveChargeComponent = default(FireWaveChargeComponent); if (!((Component)__instance).TryGetComponent<FireWaveChargeComponent>(ref fireWaveChargeComponent)) { ((Component)__instance).gameObject.AddComponent<FireWaveChargeComponent>(); } } } [HarmonyPatch(typeof(CharacterAnimEvent), "CustomFixedUpdate")] private static class AttackSpeedSystem { private static readonly Dictionary<string, float> _data_Main = new Dictionary<string, float>(); private static readonly Dictionary<string, float> _data_Secondary = new Dictionary<string, float>(); public static void RegisterMainAttacks(GameObject item, float speed) { _data_Main[((Object)item).name] = speed; } public static void RegisterSecondaryAttacks(GameObject item, float speed) { _data_Secondary[((Object)item).name] = speed; } private static void Prefix(CharacterAnimEvent __instance) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer != (Object)(object)__instance.m_character) && ((Character)localPlayer).InAttack()) { GameObject val = ((Humanoid)localPlayer).GetCurrentWeapon()?.m_dropPrefab; float value = 0f; if (Object.op_Implicit((Object)(object)val) && _data_Main.TryGetValue(((Object)val).name, out value) && !((Humanoid)localPlayer).m_currentAttackIsSecondary) { __instance.m_animator.speed = value; } else if (Object.op_Implicit((Object)(object)val) && _data_Secondary.TryGetValue(((Object)val).name, out value) && ((Humanoid)localPlayer).m_currentAttackIsSecondary) { __instance.m_animator.speed = value; } } } } public const string PluginGUID = "com.jotunn.ValkreamPlus"; public const string PluginName = "ValkreamPlus"; public const string PluginVersion = "1.0.5"; public static CustomLocalization Localization = LocalizationManager.Instance.GetLocalization(); public static AssetBundle ValkreamPlusBundle; private GameObject helBladePrefab; private void Awake() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) AddLocalizations(); LoadAssets(); PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsReady; PrefabManager.OnVanillaPrefabsAvailable += OnVanillaItemsReady; PrefabManager.OnVanillaPrefabsAvailable += AddCollierValkream; new Harmony("com.jotunn.ValkreamPlus").PatchAll(); } private void OnVanillaPrefabsReady() { AddJetonsValkream(); RegisterHelBlade(); } private void OnVanillaItemsReady() { PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaPrefabsReady; PrefabManager.OnVanillaPrefabsAvailable -= OnVanillaItemsReady; } private void LoadAssets() { ValkreamPlusBundle = AssetUtils.LoadAssetBundleFromResources("customcoins"); } public static Sprite LoadEmbeddedSprite(string resourcePath) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) Assembly assembly = typeof(ValkreamPlus).Assembly; using Stream stream = assembly.GetManifestResourceStream(resourcePath); if (stream == null) { Logger.LogWarning((object)("Embedded resource '" + resourcePath + "' not found.")); return null; } byte[] array; using (MemoryStream memoryStream = new MemoryStream()) { stream.CopyTo(memoryStream); array = memoryStream.ToArray(); } Texture2D val = new Texture2D(2, 2); if (!ImageConversion.LoadImage(val, array)) { Logger.LogWarning((object)"Failed to load texture from embedded resource."); return null; } Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height); return Sprite.Create(val, val2, new Vector2(0.5f, 0.5f)); } private void AddCollierValkream() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown PrefabManager.OnVanillaPrefabsAvailable -= AddCollierValkream; GameObject val = API.CreateNecklaceFromTemplate("Red", Color.red); API.MarkJewelry(val); ((Object)val).name = "JC_Necklace_Valkream"; ItemConfig collierValkreamConfig = new ItemConfig(); collierValkreamConfig.Name = "$item_colliervalkream"; collierValkreamConfig.Description = "$item_colliervalkream_desc"; Sprite val2 = LoadEmbeddedSprite("ValkreamPlus.Assets.CollierValkreamIcon6.png"); collierValkreamConfig.Icon = val2; collierValkreamConfig.AddRequirement("ValkreamCoinsV2", 20, 10); collierValkreamConfig.CraftingStation = "piece_workbench"; collierValkreamConfig.RepairStation = "piece_workbench"; SharedData shared = val.GetComponent<ItemDrop>().m_itemData.m_shared; shared.m_icons = (Sprite[])(object)new Sprite[1] { val2 }; shared.m_armor = 1f; shared.m_armorPerLevel = 1f; RegisterAsUpgradeableJewelry(shared.m_name); SE_CollierValkream sE_CollierValkream = ScriptableObject.CreateInstance<SE_CollierValkream>(); ((Object)sE_CollierValkream).name = "SE_CollierValkream"; ((StatusEffect)sE_CollierValkream).m_name = "Collier Valkream"; ((StatusEffect)sE_CollierValkream).m_icon = shared.m_icons[0]; ((StatusEffect)sE_CollierValkream).m_tooltip = "Le pouvoir des dieux de Valkream vous imprègne. Cela vous offre +10 aux skills de magie, +30% de regen d'eitr et +50 d'eitr maximal."; sE_CollierValkream.SetEitr(50f); sE_CollierValkream.SetSkill(11f); sE_CollierValkream.SetRegenModifier(1.3f); shared.m_equipStatusEffect = (StatusEffect)(object)sE_CollierValkream; CustomItem val3 = new CustomItem(val, false, collierValkreamConfig); ItemManager.Instance.AddItem(val3); ItemManager.OnItemsRegistered += delegate { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("JC_Necklace_Valkream"); ItemDrop val4 = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null); if ((Object)(object)val4 != (Object)null) { val4.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { collierValkreamConfig.Icon }; } }; } private static void RegisterAsUpgradeableJewelry(string sharedName) { try { if (!Chainloader.PluginInfos.TryGetValue("org.bepinex.plugins.jewelcrafting", out var value)) { Logger.LogWarning((object)"Jewelcrafting not found; skip jewelry registration."); return; } Assembly assembly = ((object)value.Instance).GetType().Assembly; Type[] types = assembly.GetTypes(); foreach (Type type in types) { FieldInfo field = type.GetField("upgradeableJewelry", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (field != null && typeof(HashSet<string>).IsAssignableFrom(field.FieldType)) { HashSet<string> hashSet = (HashSet<string>)field.GetValue(null); if (hashSet.Add(sharedName)) { Logger.LogInfo((object)("[ValkreamPlus] Registered '" + sharedName + "' as upgradeable jewelry via " + type.FullName + ".upgradeableJewelry")); } return; } } Logger.LogWarning((object)"Could not find 'upgradeableJewelry' field in Jewelcrafting assembly."); } catch (Exception arg) { Logger.LogError((object)$"Failed to register upgradeable jewelry: {arg}"); } } private void RegisterHelBlade() { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown helBladePrefab = ValkreamPlusBundle.LoadAsset<GameObject>("assets/custombb/helblade/helblade.prefab"); ItemConfig val = new ItemConfig(); val.CraftingStation = "blackforge"; val.AddRequirement("AdminCoinsV2", 1, 0); val.AddRequirement("LordsCoinsV2", 0, 20); AttackSpeedSystem.RegisterMainAttacks(helBladePrefab, 1.5f); CustomItem val2 = new CustomItem(helBladePrefab, true, val); ItemManager.Instance.AddItem(val2); } private void AddJetonsValkream() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location); GameObject val = ValkreamPlusBundle.LoadAsset<GameObject>("assets/custombb/admincoinsv2.prefab"); GameObject val2 = ValkreamPlusBundle.LoadAsset<GameObject>("assets/custombb/lordscoinsv2.prefab"); GameObject val3 = ValkreamPlusBundle.LoadAsset<GameObject>("assets/custombb/valkreamcoinsv2.prefab"); CustomItem val4 = new CustomItem(val, true); ItemManager.Instance.AddItem(val4); CustomItem val5 = new CustomItem(val2, true); ItemManager.Instance.AddItem(val5); CustomItem val6 = new CustomItem(val3, true); ItemManager.Instance.AddItem(val6); } private void AddLocalizations() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string configPath = Paths.ConfigPath; if (!Directory.Exists(configPath)) { Logger.LogWarning((object)("Config path not found: " + configPath)); return; } List<string> list = (from x in (from dir in Directory.EnumerateDirectories(configPath, "*", SearchOption.AllDirectories) where string.Equals(Path.GetFileName(dir), "ValkreamPlus", StringComparison.OrdinalIgnoreCase) select new { Path = dir, Depth = dir.TrimEnd(Path.DirectorySeparatorChar).Count((char c) => c == Path.DirectorySeparatorChar) } into x orderby x.Depth select x).ThenBy(x => x.Path, StringComparer.OrdinalIgnoreCase) select x.Path).ToList(); if (list.Count == 0) { Logger.LogWarning((object)("No 'ValkreamPlus' directory for translations found anywhere under: " + configPath)); return; } HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase); foreach (string item in list) { foreach (string item2 in Directory.EnumerateFiles(item, "*.json", SearchOption.AllDirectories).OrderBy<string, string>((string f) => f, StringComparer.OrdinalIgnoreCase)) { if (!hashSet.Add(item2)) { continue; } string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(item2); try { string text = File.ReadAllText(item2); Dictionary<string, string> dictionary = SimpleJson.DeserializeObject<Dictionary<string, string>>(text); if (dictionary == null) { Logger.LogWarning((object)("Empty or invalid JSON in " + item2)); continue; } int num = 0; foreach (KeyValuePair<string, string> item3 in dictionary) { try { string key = item3.Key; localization.AddTranslation(ref fileNameWithoutExtension, ref key, item3.Value); num++; } catch (Exception ex) { Logger.LogWarning((object)("Could not add key '" + item3.Key + "' from " + item2 + ": " + ex.Message)); } } } catch (Exception ex2) { Logger.LogError((object)("Failed to load localization from " + item2 + ": " + ex2.Message)); } } } } }