using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using Backpacks;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using ItemDataManager;
using ItemManager;
using JetBrains.Annotations;
using LocalizationManager;
using MagicRevamp.Functions;
using MagicRevamp.Patches;
using MagicRevamp.SE;
using Microsoft.CodeAnalysis;
using PieceManager;
using ServerSync;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("blacks7ar")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.4.9")]
[assembly: AssemblyInformationalVersion("1.0.0+9b35241fc12915930593b06a1e99cc33b84fac31")]
[assembly: AssemblyProduct("MagicRevamp")]
[assembly: AssemblyTitle("MagicRevamp")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.9.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 MagicRevamp
{
[BepInPlugin("blacks7ar.MagicRevamp", "MagicRevamp", "1.4.9")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BaseUnityPlugin
{
private const string modGUID = "blacks7ar.MagicRevamp";
public const string modName = "MagicRevamp";
public const string modAuthor = "blacks7ar";
public const string modVersion = "1.4.9";
public const string modLink = "https://thunderstore.io/c/valheim/p/blacks7ar/MagicRevamp/";
private static readonly Harmony _harmony = new Harmony("blacks7ar.MagicRevamp");
private static readonly ConfigSync _configSync = new ConfigSync("blacks7ar.MagicRevamp")
{
DisplayName = "MagicRevamp",
CurrentVersion = "1.4.9",
MinimumRequiredVersion = "1.4.9",
ModRequired = true
};
private static ConfigEntry<MagicRevamp.Functions.Toggle> _serverConfigLocked;
private static ConfigEntry<KeyCode> _cycleSpell;
public static ConfigEntry<Color> _spellCrosshairColor;
public static ConfigEntry<Color> _spellTextColor;
public static ConfigEntry<MagicRevamp.Functions.Toggle> _enableSpellHud;
public static ConfigEntry<int> _scrollsStackSize;
public static ConfigEntry<int> _essencesStackSize;
public static ConfigEntry<int> _paperStackSize;
public static ConfigEntry<MagicRevamp.Functions.Toggle> _restrictStaves;
public static ConfigEntry<MagicRevamp.Functions.Toggle> _enablePickup;
public static ConfigEntry<MagicRevamp.Functions.Toggle> _enableRestrictedItemCheck;
public static ConfigEntry<MagicRevamp.Functions.Toggle> _enableWeightCheck;
public static ConfigEntry<KeyboardShortcut> _unSummonKey;
public static ConfigEntry<int> _maxSummon;
public static ConfigEntry<float> _spellHudDuration;
public static bool _hasMagicPluginMod;
public static Plugin _instance;
public ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description, bool _synchronizedConfig = true)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
ConfigDescription val = new ConfigDescription(description.Description + (_synchronizedConfig ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags);
ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val);
_configSync.AddConfigEntry<T>(val2).SynchronizedConfig = _synchronizedConfig;
return val2;
}
public void Awake()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Expected O, but got Unknown
//IL_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Expected O, but got Unknown
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00b0: Expected O, but got Unknown
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ef: Expected O, but got Unknown
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Expected O, but got Unknown
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Expected O, but got Unknown
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Expected O, but got Unknown
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Expected O, but got Unknown
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01d3: Expected O, but got Unknown
//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Expected O, but got Unknown
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_022a: Unknown result type (might be due to invalid IL or missing references)
//IL_0235: Expected O, but got Unknown
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Expected O, but got Unknown
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_0295: Expected O, but got Unknown
//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
//IL_02bc: Expected O, but got Unknown
//IL_02df: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Expected O, but got Unknown
_instance = this;
((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
Localizer.Load();
_serverConfigLocked = config("1- ServerSync", "Lock Configuration", MagicRevamp.Functions.Toggle.On, new ConfigDescription("If On, the configuration is locked and can be changed by server admins only.", (AcceptableValueBase)null, Array.Empty<object>()));
_configSync.AddLockingConfigEntry<MagicRevamp.Functions.Toggle>(_serverConfigLocked);
_cycleSpell = config<KeyCode>("2- General", "Cycle Spell", (KeyCode)103, new ConfigDescription("Hotkey to press to cycle through spells in inventory.", (AcceptableValueBase)null, Array.Empty<object>()));
_spellCrosshairColor = config<Color>("2- General", "Spell Crosshair Color", new Color(255f, 255f, 255f, 1f), new ConfigDescription("Use to modify the custom crosshairs color.", (AcceptableValueBase)null, Array.Empty<object>()));
_spellTextColor = config<Color>("2- General", "Spell Name Color", new Color(255f, 255f, 255f, 1f), new ConfigDescription("Use to modify the spells name color.", (AcceptableValueBase)null, Array.Empty<object>()));
_enableSpellHud = config("2- General", "Spell Hud", MagicRevamp.Functions.Toggle.On, new ConfigDescription("Enable/Disables custom spell hud (spell crosshair and spell names).", (AcceptableValueBase)null, Array.Empty<object>()));
_essencesStackSize = config("2- General", "Essence Max Stack Size", 100, new ConfigDescription("Essences max stack size (ie. fire essence, ice essence.. etc).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 999), Array.Empty<object>()));
_paperStackSize = config("2- General", "Papers Max Stack Size", 100, new ConfigDescription("Papers max stack size.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 999), Array.Empty<object>()));
_scrollsStackSize = config("2- General", "Spells Max Stack Size", 100, new ConfigDescription("Spells max stack size (ie. Fire Spell.. etc).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 999), Array.Empty<object>()));
_restrictStaves = config("2- General", "Equip Restriction", MagicRevamp.Functions.Toggle.On, new ConfigDescription("If On, restrict equipping of staves/wands to require magic armors.", (AcceptableValueBase)null, Array.Empty<object>()));
_enablePickup = config("2- General", "Pickup", MagicRevamp.Functions.Toggle.On, new ConfigDescription("If Off, essences and spells drop by creatures wont be auto-pickup.", (AcceptableValueBase)null, Array.Empty<object>()), _synchronizedConfig: false);
_unSummonKey = config<KeyboardShortcut>("2- General", "Unsummon Key", new KeyboardShortcut((KeyCode)102, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 }), new ConfigDescription("Hotkey combination to unsummon summons.", (AcceptableValueBase)null, Array.Empty<object>()), _synchronizedConfig: false);
_spellHudDuration = config("2- General", "Spell Hud Duration", 2f, new ConfigDescription("How long does the spell hud stays visible in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 25f), Array.Empty<object>()));
_enableRestrictedItemCheck = config("3- Portal Restriction", "Restricted Items Check", MagicRevamp.Functions.Toggle.Off, new ConfigDescription("If On, teleportation using portal spell will be restricted,\nIt will check if you have non teleportable items in your inventory.", (AcceptableValueBase)null, Array.Empty<object>()));
_enableWeightCheck = config("3- Portal Restriction", "Weight Check", MagicRevamp.Functions.Toggle.Off, new ConfigDescription("If On, teleportation using portal spell will be restricted,\nIt will check if you are over capacity or encumbered.", (AcceptableValueBase)null, Array.Empty<object>()));
_maxSummon = config("2- General", "Max Summon", 5, new ConfigDescription("Max amount of summoned creature a player can have.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>()));
_hasMagicPluginMod = Helper.CheckMagicPluginMod();
SummonHelper.CloneContainer();
ConfigSetup.Init();
PrefabSetups.Init();
Assembly executingAssembly = Assembly.GetExecutingAssembly();
_harmony.PatchAll(executingAssembly);
((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
((BaseUnityPlugin)this).Config.Save();
}
private void OnDestroy()
{
((BaseUnityPlugin)this).Config.Save();
}
private void Update()
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name != "main" || ZInput.instance == null || ZNet.instance.InPasswordDialog() || _cycleSpell == null)
{
return;
}
Player localPlayer = Player.m_localPlayer;
if (!Object.op_Implicit((Object)(object)localPlayer))
{
return;
}
foreach (Tameable item in Enumerable.Select(Enumerable.Where(Enumerable.Where(Character.GetAllCharacters(), (Character summon) => ((Object)((Component)summon).gameObject).name.StartsWith("BMR_") && summon.m_nview.IsValid() && summon.m_nview.IsOwner()), (Func<Character, bool>)delegate
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
KeyboardShortcut value = _unSummonKey.Value;
return ((KeyboardShortcut)(ref value)).IsDown();
}), (Character summon) => ((Component)summon).GetComponent<Tameable>()))
{
item.UnSummon();
}
if (Input.GetKeyDown(_cycleSpell.Value) && ((Character)localPlayer).TakeInput())
{
CycleSpells.CycleSpell();
}
}
}
}
namespace MagicRevamp.SE
{
public class AddEitr : StatusEffect
{
public float m_eitr;
public void Awake()
{
base.m_name = "";
base.m_tooltip = $"Boost wearer's <color=orange>Eitr</color> by <color=orange>+{m_eitr}</color>.";
base.m_icon = null;
}
public void SetEitr(float eitr)
{
m_eitr = eitr;
base.m_tooltip = $"Boost wearer's <color=orange>Eitr</color> by <color=orange>+{m_eitr}</color>.";
}
}
public class ComfortSpell : SE_Stats
{
public override void Setup(Character character)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
((StatusEffect)this).m_startEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
{
new EffectData
{
m_prefab = ZNetScene.instance.GetPrefab("fx_GP_Stone"),
m_enabled = true,
m_variant = -1
}
};
((SE_Stats)this).Setup(character);
}
}
public class DemisterSpell : StatusEffect
{
public GameObject m_ballPrefab;
public Vector3 m_offset = new Vector3(0.1f, 3.5f, 0.1f);
public Vector3 m_offsetInterior = new Vector3(0.5f, 2.1f, 0f);
public float m_maxDistance = 6f;
public float m_ballAcceleration = 7f;
public float m_ballMaxSpeed = 80f;
public float m_ballFriction = 0.03f;
public float m_noiseDistance = 1.5f;
public float m_noiseDistanceInterior = 0.2f;
public float m_noiseDistanceYScale = 0.4f;
public float m_noiseSpeed = 0.5f;
public float m_characterVelocityFactor = 3f;
public float m_rotationSpeed = 8f;
public int m_coverRayMask;
public GameObject m_ballInstance;
public Vector3 m_ballVel = new Vector3(0f, 0f, 0f);
public float m_demisterRange;
public void Awake()
{
((Object)this).name = "BMR_Demister";
base.m_name = "$item_demister";
base.m_tooltip = "$item_demister_description";
}
public override void Setup(Character character)
{
((StatusEffect)this).Setup(character);
if (m_coverRayMask == 0)
{
m_coverRayMask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "terrain" });
}
m_ballPrefab = ZNetScene.instance.GetPrefab("demister_ball");
GameObject ballPrefab = m_ballPrefab;
((ballPrefab != null) ? ballPrefab.GetComponentInChildren<ParticleSystemForceField>() : null).endRange = m_demisterRange;
}
public void SetDemisterRange(float range)
{
m_demisterRange = range;
}
private bool IsUnderRoof()
{
//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)
RaycastHit val = default(RaycastHit);
return Physics.Raycast(base.m_character.GetCenterPoint(), Vector3.up, ref val, 4f, m_coverRayMask);
}
public override void UpdateStatusEffect(float dt)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: 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_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: 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_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
((StatusEffect)this).UpdateStatusEffect(dt);
if (!Object.op_Implicit((Object)(object)m_ballInstance))
{
Vector3 val = base.m_character.GetCenterPoint() + ((Component)base.m_character).transform.forward * 0.5f;
m_ballInstance = Object.Instantiate<GameObject>(m_ballPrefab, val, Quaternion.identity);
return;
}
_ = base.m_character;
bool num = IsUnderRoof();
Vector3 position = ((Component)base.m_character).transform.position;
Vector3 val2 = m_ballInstance.transform.position;
Vector3 val3 = (num ? m_offsetInterior : m_offset);
float num2 = (num ? m_noiseDistanceInterior : m_noiseDistance);
Vector3 val4 = position + ((Component)base.m_character).transform.TransformVector(val3);
float num3 = Time.time * m_noiseSpeed;
val4 += new Vector3(Mathf.Sin(num3 * 4f), Mathf.Sin(num3 * 2f) * m_noiseDistanceYScale, Mathf.Cos(num3 * 5f)) * num2;
float num4 = Vector3.Distance(val4, val2);
Vector3 val5;
if (num4 > m_maxDistance * 2f)
{
val2 = val4;
}
else if (num4 > m_maxDistance)
{
val5 = val2 - val4;
Vector3 normalized = ((Vector3)(ref val5)).normalized;
val2 = val4 + normalized * m_maxDistance;
}
val5 = val4 - val2;
Vector3 normalized2 = ((Vector3)(ref val5)).normalized;
m_ballVel += normalized2 * m_ballAcceleration * dt;
if (((Vector3)(ref m_ballVel)).magnitude > m_ballMaxSpeed)
{
m_ballVel = ((Vector3)(ref m_ballVel)).normalized * m_ballMaxSpeed;
}
if (!num)
{
Vector3 velocity = base.m_character.GetVelocity();
m_ballVel += velocity * m_characterVelocityFactor * dt;
}
m_ballVel -= m_ballVel * m_ballFriction;
Vector3 position2 = val2 + m_ballVel * dt;
m_ballInstance.transform.position = position2;
Quaternion rotation = m_ballInstance.transform.rotation;
rotation *= Quaternion.Euler(m_rotationSpeed, 0f, m_rotationSpeed * 0.5321f);
m_ballInstance.transform.rotation = rotation;
}
public void RemoveEffects()
{
if (!((Object)(object)m_ballInstance == (Object)null))
{
ZNetView component = m_ballInstance.GetComponent<ZNetView>();
if (component.IsValid())
{
component.ClaimOwnership();
component.Destroy();
}
}
}
public override void OnApplicationQuit()
{
((StatusEffect)this).OnApplicationQuit();
m_ballInstance = null;
}
public override void Stop()
{
((StatusEffect)this).Stop();
RemoveEffects();
}
public override void OnDestroy()
{
((StatusEffect)this).OnDestroy();
RemoveEffects();
}
}
public class FireWisp : StatusEffect
{
public GameObject m_wispPrefab;
public Vector3 m_offset = new Vector3(0.1f, 3.5f, 0.1f);
public Vector3 m_offsetInterior = new Vector3(0.5f, 2.1f, 0f);
public float m_maxDistance = 6f;
public float m_wispAcceleration = 6f;
public float m_wispMaxSpeed = 80f;
public float m_wispFriction = 0.03f;
public float m_noiseDistance = 1.5f;
public float m_noiseDistanceInterior = 0.2f;
public float m_noiseDistanceYScale = 0.4f;
public float m_noiseSpeed = 0.5f;
public float m_characterVelocityFactor = 3f;
public float m_rotationSpeed = 7f;
public int m_coverRayMask;
public GameObject m_wispInstance;
public Vector3 m_wispVel = new Vector3(0f, 0f, 0f);
public void Awake()
{
((Object)this).name = "BMR_FireWisp";
base.m_name = "$bmr_firewisp_se";
base.m_tooltip = "$bmr_firewisp_tooltip";
m_wispPrefab = PrefabSetups._magicBundle.LoadAsset<GameObject>("bmr_firewisp");
}
public override void Setup(Character character)
{
((StatusEffect)this).Setup(character);
if (m_coverRayMask == 0)
{
m_coverRayMask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "terrain" });
}
}
private bool IsUnderRoof()
{
//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)
RaycastHit val = default(RaycastHit);
return Physics.Raycast(base.m_character.GetCenterPoint(), Vector3.up, ref val, 4f, m_coverRayMask);
}
public override void UpdateStatusEffect(float dt)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: 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_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0099: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
//IL_00be: 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)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010e: 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_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_0169: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0172: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_013f: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
//IL_0160: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
//IL_0201: Unknown result type (might be due to invalid IL or missing references)
//IL_0207: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: 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_0221: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0229: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_0252: Unknown result type (might be due to invalid IL or missing references)
//IL_0257: Unknown result type (might be due to invalid IL or missing references)
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Unknown result type (might be due to invalid IL or missing references)
//IL_027c: Unknown result type (might be due to invalid IL or missing references)
//IL_0289: Unknown result type (might be due to invalid IL or missing references)
//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
((StatusEffect)this).UpdateStatusEffect(dt);
if (!Object.op_Implicit((Object)(object)m_wispInstance))
{
Vector3 val = base.m_character.GetCenterPoint() + ((Component)base.m_character).transform.forward * 0.5f;
m_wispInstance = Object.Instantiate<GameObject>(m_wispPrefab, val, Quaternion.identity);
return;
}
_ = base.m_character;
bool num = IsUnderRoof();
Vector3 position = ((Component)base.m_character).transform.position;
Vector3 val2 = m_wispInstance.transform.position;
Vector3 val3 = (num ? m_offsetInterior : m_offset);
float num2 = (num ? m_noiseDistanceInterior : m_noiseDistance);
Vector3 val4 = position + ((Component)base.m_character).transform.TransformVector(val3);
float num3 = Time.time * m_noiseSpeed;
val4 += new Vector3(Mathf.Sin(num3 * 4f), Mathf.Sin(num3 * 2f) * m_noiseDistanceYScale, Mathf.Cos(num3 * 5f)) * num2;
float num4 = Vector3.Distance(val4, val2);
Vector3 val5;
if (num4 > m_maxDistance * 2f)
{
val2 = val4;
}
else if (num4 > m_maxDistance)
{
val5 = val2 - val4;
Vector3 normalized = ((Vector3)(ref val5)).normalized;
val2 = val4 + normalized * m_maxDistance;
}
val5 = val4 - val2;
Vector3 normalized2 = ((Vector3)(ref val5)).normalized;
m_wispVel += normalized2 * m_wispAcceleration * dt;
if (((Vector3)(ref m_wispVel)).magnitude > m_wispMaxSpeed)
{
m_wispVel = ((Vector3)(ref m_wispVel)).normalized * m_wispMaxSpeed;
}
if (!num)
{
Vector3 velocity = base.m_character.GetVelocity();
m_wispVel += velocity * m_characterVelocityFactor * dt;
}
m_wispVel -= m_wispVel * m_wispFriction;
Vector3 position2 = val2 + m_wispVel * dt;
m_wispInstance.transform.position = position2;
Quaternion rotation = m_wispInstance.transform.rotation;
rotation *= Quaternion.Euler(m_rotationSpeed, 0f, m_rotationSpeed * 0.5321f);
m_wispInstance.transform.rotation = rotation;
}
public void RemoveEffects()
{
if (!((Object)(object)m_wispInstance == (Object)null))
{
ZNetView component = m_wispInstance.GetComponent<ZNetView>();
if (component.IsValid())
{
component.ClaimOwnership();
component.Destroy();
}
}
}
public override void OnApplicationQuit()
{
((StatusEffect)this).OnApplicationQuit();
m_wispInstance = null;
}
public override void Stop()
{
((StatusEffect)this).Stop();
RemoveEffects();
}
public override void OnDestroy()
{
((StatusEffect)this).OnDestroy();
RemoveEffects();
}
}
public class HealSpell : StatusEffect
{
public float m_healthOverTime = 100f;
public float m_healthOverTimeInterval = 0.5f;
public float m_healthOverTimeDuration = 4f;
public float m_healthOverTimeTimer;
public float m_healthOverTimeTicks;
public float m_healthOverTimeTickHP;
public void Awake()
{
base.m_name = "Heal Spell";
base.m_tooltip = $"Heal Amount: <color=orange>{Mathf.FloorToInt(m_healthOverTime / (m_healthOverTimeDuration / m_healthOverTimeInterval))}</color>" + $"\nDuration: <color=orange>{m_healthOverTimeDuration}m/s</color>" + $"\nInterval: <color=orange>{m_healthOverTimeInterval}</color>";
}
public void SetHealthOverTime(float value)
{
m_healthOverTime = value;
base.m_tooltip = $"Heal Amount: <color=orange>{Mathf.FloorToInt(m_healthOverTime / (m_healthOverTimeDuration / m_healthOverTimeInterval))}</color>" + $"\nDuration: <color=orange>{m_healthOverTimeDuration}m/s</color>" + $"\nInterval: <color=orange>{m_healthOverTimeInterval}</color>";
}
public void SetDuration(float value)
{
m_healthOverTimeDuration = value;
base.m_tooltip = $"Heal Amount: <color=orange>{Mathf.FloorToInt(m_healthOverTime / (m_healthOverTimeDuration / m_healthOverTimeInterval))}</color>" + $"\nDuration: <color=orange>{m_healthOverTimeDuration}m/s</color>" + $"\nInterval: <color=orange>{m_healthOverTimeInterval}</color>";
}
public void SetInterval(float value)
{
m_healthOverTimeInterval = value;
base.m_tooltip = $"Heal Amount: <color=orange>{Mathf.FloorToInt(m_healthOverTime / (m_healthOverTimeDuration / m_healthOverTimeInterval))}</color>" + $"\nDuration: <color=orange>{m_healthOverTimeDuration}m/s</color>" + $"\nInterval: <color=orange>{m_healthOverTimeInterval}</color>";
}
public override void Setup(Character character)
{
((StatusEffect)this).Setup(character);
if (m_healthOverTime > 0f && m_healthOverTimeInterval > 0f)
{
if (m_healthOverTimeDuration <= 0f)
{
m_healthOverTimeDuration = base.m_ttl;
}
m_healthOverTimeTicks = m_healthOverTimeDuration / m_healthOverTimeInterval;
m_healthOverTimeTickHP = m_healthOverTime / m_healthOverTimeTicks;
}
}
public override void UpdateStatusEffect(float dt)
{
((StatusEffect)this).UpdateStatusEffect(dt);
if (m_healthOverTimeTicks > 0f)
{
m_healthOverTimeTimer += dt;
if (m_healthOverTimeTimer > m_healthOverTimeInterval)
{
m_healthOverTimeTimer = 0f;
m_healthOverTimeTicks -= 1f;
base.m_character.Heal(m_healthOverTimeTickHP, true);
}
}
}
}
public class RepairSpell : SE_Stats
{
public override void Setup(Character character)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
((StatusEffect)this).m_startEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
{
new EffectData
{
m_prefab = ZNetScene.instance.GetPrefab("fx_GP_Stone"),
m_enabled = true,
m_variant = -1,
m_attach = true
}
};
((SE_Stats)this).Setup(character);
}
public override void UpdateStatusEffect(float dt)
{
((SE_Stats)this).UpdateStatusEffect(dt);
InventoryGui.instance.m_tempWornItems.Clear();
Character character = ((StatusEffect)this).m_character;
Player val = (Player)(object)((character is Player) ? character : null);
((Humanoid)val).GetInventory().GetWornItems(InventoryGui.instance.m_tempWornItems);
foreach (ItemData tempWornItem in InventoryGui.instance.m_tempWornItems)
{
if (tempWornItem == null)
{
break;
}
if (CanRepair(tempWornItem))
{
tempWornItem.m_durability = tempWornItem.GetMaxDurability();
((Character)val).Message((MessageType)2, "$bmr_allequipment_repaired.", 0, (Sprite)null);
break;
}
}
}
private static bool CanRepair(ItemData item)
{
if (item.m_shared.m_canBeReparied)
{
return !Player.m_localPlayer.NoCostCheat();
}
return false;
}
}
public class ShieldSpell : StatusEffect
{
public float m_absorbDamage = 100f;
public float m_absorbDamageWorldLevel = 100f;
public SkillType m_levelUpSkillOnBreak;
public float m_absorbDamagePerSkillLevel;
public EffectList m_breakEffects = new EffectList();
public EffectList m_hitEffects = new EffectList();
public float m_totalAbsorbDamage;
public float m_damage;
public float m_duration = 60f;
public void Awake()
{
base.m_name = "$se_shield";
((Object)this).name = "BMR_ShieldSpell";
base.m_tooltip = "$se_shield_description";
}
public override void Setup(Character character)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
base.m_startEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
{
new EffectData
{
m_prefab = ZNetScene.instance.GetPrefab("vfx_StaffShield"),
m_enabled = true,
m_variant = -1,
m_attach = true,
m_scale = true
}
};
m_levelUpSkillOnBreak = (SkillType)10;
((StatusEffect)this).Setup(character);
}
public void SetAbsorbDamage(float damage)
{
m_absorbDamage = damage;
}
public void SetDuration(float duration)
{
m_duration = duration;
}
public void SetWoldAbsorbDamage(float damage)
{
m_absorbDamageWorldLevel = damage;
}
public override bool IsDone()
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
m_breakEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
{
new EffectData
{
m_prefab = ZNetScene.instance.GetPrefab("fx_StaffShield_Break"),
m_enabled = true,
m_variant = -1,
m_scale = true
}
};
if (!(m_damage > m_totalAbsorbDamage))
{
return ((StatusEffect)this).IsDone();
}
m_breakEffects.Create(base.m_character.GetCenterPoint(), ((Component)base.m_character).transform.rotation, ((Component)base.m_character).transform, base.m_character.GetRadius() * 2f, -1);
if ((int)m_levelUpSkillOnBreak == 0)
{
return true;
}
Skills skills = base.m_character.GetSkills();
if ((Object)(object)skills == (Object)null || !Object.op_Implicit((Object)(object)skills))
{
return true;
}
skills.RaiseSkill(m_levelUpSkillOnBreak, 1f);
Terminal.Log((object)$"{base.m_name} is leveling up {m_levelUpSkillOnBreak} at factor 1");
return true;
}
public override void OnDamaged(HitData hit, Character attacker)
{
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Expected O, but got Unknown
//IL_0063: 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_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
m_hitEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1]
{
new EffectData
{
m_prefab = ZNetScene.instance.GetPrefab("fx_StaffShield_Hit"),
m_enabled = true,
m_variant = -1
}
};
float totalDamage = hit.GetTotalDamage();
m_damage += totalDamage;
hit.ApplyModifier(0f);
m_hitEffects.Create(hit.m_point, Quaternion.LookRotation(-hit.m_dir), ((Component)base.m_character).transform, 1f, -1);
}
public override void SetLevel(int itemLevel, float skillLevel)
{
base.m_ttl = m_duration * (float)itemLevel;
m_totalAbsorbDamage = m_absorbDamage + m_absorbDamagePerSkillLevel * skillLevel;
if (Game.m_worldLevel > 0)
{
m_totalAbsorbDamage += m_absorbDamageWorldLevel * (float)Game.m_worldLevel;
}
Terminal.Log((object)$"Shield setting skilllevel: {skillLevel} = absorb: {m_totalAbsorbDamage}");
((StatusEffect)this).SetLevel(itemLevel, skillLevel);
}
public override string GetTooltipString()
{
return ((StatusEffect)this).GetTooltipString() + "\n$se_shield_ttl <color=orange>" + base.m_ttl.ToString("0") + "</color>\n$se_shield_damage <color=orange>" + m_totalAbsorbDamage.ToString("0") + "</color>";
}
}
public class SlowFallAndEitr : StatusEffect
{
public float m_eitr;
public float m_maxFallSpeed = 5f;
public float m_fallDamageModifier = -1f;
public void Awake()
{
base.m_name = "Slow Fall";
base.m_tooltip = "$bmr_featherfall_tooltip" + $"\nLimit fall speed: <color=orange>{m_maxFallSpeed}m/s</color>" + $"\nFall damage: <color=orange>{m_fallDamageModifier}%</color>" + $"\nEitr: <color=orange>+{m_eitr}</color>";
base.m_icon = Enumerable.FirstOrDefault((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>(), (Func<Sprite, bool>)((Sprite x) => ((Object)x).name == "SlowFall"));
}
public void SetEitr(float eitr)
{
m_eitr = eitr;
base.m_tooltip = "$bmr_featherfall_tooltip" + $"\nLimit fall speed: <color=orange>{m_maxFallSpeed}m/s</color>" + $"\nFall damage: <color=orange>{m_fallDamageModifier}%</color>" + $"\nEitr: <color=orange>+{m_eitr}</color>";
}
public override void ModifyWalkVelocity(ref Vector3 vel)
{
if (m_maxFallSpeed > 0f && vel.y < 0f - m_maxFallSpeed)
{
vel.y = 0f - m_maxFallSpeed;
}
}
public override void ModifyFallDamage(float baseDamage, ref float damage)
{
damage += baseDamage * m_fallDamageModifier;
if (damage < 0f)
{
damage = 0f;
}
}
}
}
namespace MagicRevamp.Patches
{
[HarmonyPatch]
public class AttackPatch
{
private static FieldInfo _field_m_attackEitr = AccessTools.Field(typeof(Attack), "m_attackEitr");
private static MethodInfo _method_GetAttackEitr = AccessTools.Method(typeof(AttackPatch), "GetAttackEitr", (Type[])null, (Type[])null);
[HarmonyTranspiler]
[HarmonyPatch(typeof(Attack), "GetAttackEitr")]
private static IEnumerable<CodeInstruction> EitrTranspiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> source = Enumerable.ToList(instructions);
foreach (CodeInstruction item in Enumerable.Where(source, (CodeInstruction t) => CodeInstructionExtensions.LoadsField(t, _field_m_attackEitr, false)))
{
item.opcode = OpCodes.Call;
item.operand = _method_GetAttackEitr;
}
return Enumerable.AsEnumerable(source);
}
private static float GetAttackEitr(Attack __instance)
{
Humanoid character = __instance.m_character;
Player val = (Player)(object)((character is Player) ? character : null);
if (val != null && ((Humanoid)val).GetCurrentWeapon().m_shared.m_ammoType.Contains("ammo_spells") && ((Humanoid)val).GetAmmoItem() != null)
{
__instance.m_attackEitr = ((Humanoid)val).GetAmmoItem().m_shared.m_attack.m_attackEitr;
}
return __instance.m_attackEitr;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Attack), "Start")]
private static void Start_Postfix(Attack __instance, ref bool __result)
{
Humanoid character = __instance.m_character;
Player val = (Player)(object)((character is Player) ? character : null);
if (val != null && !((Humanoid)val).GetCurrentWeapon().m_shared.m_name.StartsWith("$bmp_") && ((Humanoid)val).GetCurrentWeapon() != ((Humanoid)val).m_unarmedWeapon.m_itemData && ((Humanoid)val).GetCurrentWeapon().m_shared.m_ammoType.Contains("ammo_spells") && ((Humanoid)val).GetAmmoItem() != null && !((Object)(object)((Humanoid)val).GetAmmoItem().m_shared.m_attackStatusEffect == (Object)null))
{
if (((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Demister")) && ((Humanoid)val).GetAmmoItem().m_shared.m_attackStatusEffect.m_name.Contains("firewisp"))
{
((Character)val).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Demister"), false);
}
if (((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_FireWisp")) && ((Humanoid)val).GetAmmoItem().m_shared.m_attackStatusEffect.m_name.Contains("demister"))
{
((Character)val).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_FireWisp"), false);
}
if ((((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort1_SE")) || ((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort2_SE")) || ((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort3_SE")) || ((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort4_SE")) || ((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort5_SE")) || ((Character)val).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort6_SE"))) && ((Humanoid)val).GetAmmoItem().m_shared.m_attackStatusEffect.m_name.Contains("scroll_comfort"))
{
((Character)val).Message((MessageType)2, "$bmr_cantuse_rightnow", 0, (Sprite)null);
__result = false;
}
if (!HaveRepairableItems() && ((Humanoid)val).GetAmmoItem().m_shared.m_attackStatusEffect.m_name.Contains("scroll_repair"))
{
((Character)val).Message((MessageType)2, "$bmr_norepairable_items", 0, (Sprite)null);
__result = false;
}
}
}
private static bool HaveRepairableItems()
{
InventoryGui.instance.m_tempWornItems.Clear();
((Humanoid)Player.m_localPlayer).GetInventory().GetWornItems(InventoryGui.instance.m_tempWornItems);
return Enumerable.Any(InventoryGui.instance.m_tempWornItems, CanRepair);
}
private static bool CanRepair(ItemData item)
{
if (item.m_shared.m_canBeReparied)
{
return !Player.m_localPlayer.NoCostCheat();
}
return false;
}
}
[HarmonyPatch]
public class CharacterPatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(Character), "RPC_Damage")]
private static bool RpcDamage_Prefix(Character __instance, HitData hit)
{
Character attacker = hit.GetAttacker();
Player val = (Player)(object)((attacker is Player) ? attacker : null);
if (val == null || ((Humanoid)val).GetCurrentWeapon() == null || !((Humanoid)val).GetCurrentWeapon().m_shared.m_ammoType.Contains("ammo_spells") || ((Humanoid)val).GetCurrentWeapon() == ((Humanoid)val).m_unarmedWeapon.m_itemData || (Object)(object)__instance == (Object)null)
{
return true;
}
if (((Humanoid)val).GetAmmoItem() != null && (((Humanoid)val).GetAmmoItem().m_shared.m_name.Contains("scroll_mining") || ((Humanoid)val).GetAmmoItem().m_shared.m_name.Contains("scroll_woodcutting")))
{
return false;
}
return true;
}
}
[HarmonyPatch]
public class DestructiblePatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(Destructible), "RPC_Damage")]
private static bool RpcDamage_Prefix(Destructible __instance, HitData hit)
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Invalid comparison between Unknown and I4
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Invalid comparison between Unknown and I4
//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Invalid comparison between Unknown and I4
Character attacker = hit.GetAttacker();
Player val = (Player)(object)((attacker is Player) ? attacker : null);
if (val == null || ((Humanoid)val).GetCurrentWeapon() == null || !((Humanoid)val).GetCurrentWeapon().m_shared.m_ammoType.Contains("ammo_spells") || ((Humanoid)val).GetCurrentWeapon() == ((Humanoid)val).m_unarmedWeapon.m_itemData)
{
return true;
}
if (((Humanoid)val).GetAmmoItem() != null && ((Humanoid)val).GetAmmoItem().m_shared.m_name.Contains("scroll_woodcutting") && (int)__instance.m_destructibleType == 2 && hit.m_damage.m_chop > 0f && __instance.m_nview.IsValid() && __instance.m_nview.IsOwner())
{
hit.m_toolTier = (short)((Humanoid)val).GetAmmoItem().m_shared.m_toolTier;
((Character)val).RaiseSkill((SkillType)13, 0.2f);
return true;
}
if (((Humanoid)val).GetAmmoItem() != null && ((Humanoid)val).GetAmmoItem().m_shared.m_name.Contains("scroll_mining") && (int)__instance.m_damages.m_pickaxe != 3 && (int)__instance.m_destructibleType != 2 && hit.m_damage.m_pickaxe > 0f && __instance.m_nview.IsValid() && __instance.m_nview.IsOwner())
{
hit.m_toolTier = (short)((Humanoid)val).GetAmmoItem().m_shared.m_toolTier;
((Character)val).RaiseSkill((SkillType)12, 0.2f);
return true;
}
return true;
}
}
[HarmonyPatch]
public class HudPatch
{
[CompilerGenerated]
private sealed class <PulseText>d__19 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public TMP_Text text;
public float scaleUp;
public float duration;
private RectTransform <rect>5__2;
private Vector3 <targetScale>5__3;
private float <time>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PulseText>d__19(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<rect>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: 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_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: 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_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<rect>5__2 = text.rectTransform;
((Transform)<rect>5__2).localScale = _baseScale;
<targetScale>5__3 = _baseScale * scaleUp;
<time>5__4 = 0f;
goto IL_00b7;
case 1:
<>1__state = -1;
goto IL_00b7;
case 2:
{
<>1__state = -1;
break;
}
IL_00b7:
if (<time>5__4 < duration)
{
<time>5__4 += Time.deltaTime;
((Transform)<rect>5__2).localScale = Vector3.Lerp(_baseScale, <targetScale>5__3, <time>5__4 / duration);
<>2__current = null;
<>1__state = 1;
return true;
}
<time>5__4 = 0f;
break;
}
if (<time>5__4 < duration)
{
<time>5__4 += Time.deltaTime;
((Transform)<rect>5__2).localScale = Vector3.Lerp(<targetScale>5__3, _baseScale, <time>5__4 / duration);
<>2__current = null;
<>1__state = 2;
return true;
}
((Transform)<rect>5__2).localScale = _baseScale;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <ShowAndFadeHud>d__20 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public TMP_Text text;
public float fadeTime;
private CanvasGroup <group>5__2;
private float <start>5__3;
private float <time>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <ShowAndFadeHud>d__20(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<group>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
{
<>1__state = -1;
float value = Plugin._spellHudDuration.Value;
<group>5__2 = ((Component)text).GetComponent<CanvasGroup>();
if ((Object)(object)<group>5__2 == (Object)null)
{
return false;
}
<group>5__2.alpha = 1f;
((Component)<group>5__2).gameObject.SetActive(true);
<>2__current = (object)new WaitForSeconds(value);
<>1__state = 1;
return true;
}
case 1:
<>1__state = -1;
<start>5__3 = <group>5__2.alpha;
<time>5__4 = 0f;
break;
case 2:
<>1__state = -1;
break;
}
if (<time>5__4 < fadeTime)
{
<time>5__4 += Time.deltaTime;
<group>5__2.alpha = Mathf.Lerp(<start>5__3, 0f, <time>5__4 / fadeTime);
<>2__current = null;
<>1__state = 2;
return true;
}
<group>5__2.alpha = 0f;
((Component)<group>5__2).gameObject.SetActive(false);
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <UpdateSpellHud>d__18 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <UpdateSpellHud>d__18(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0027: Expected O, but got Unknown
//IL_0055: 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)
int num = <>1__state;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -1;
Player localPlayer = Player.m_localPlayer;
if (!((Object)(object)localPlayer == (Object)null))
{
CycleSpells.ShowSpellEquipped();
((Graphic)_spellHudText).color = Plugin._spellTextColor.Value;
((Graphic)_spellCrosshair).color = Plugin._spellCrosshairColor.Value;
(int currentStack, string currentSpell, int nextStack, string nextSpell, int prevStack, string prevSpell) spellHudNames = CycleSpells.GetSpellHudNames(localPlayer);
int item = spellHudNames.currentStack;
string item2 = spellHudNames.currentSpell;
int item3 = spellHudNames.nextStack;
string item4 = spellHudNames.nextSpell;
int item5 = spellHudNames.prevStack;
string item6 = spellHudNames.prevSpell;
string text = Localization.instance.Localize(item2);
if (!string.IsNullOrEmpty(text) && _lastSpellEquipped != text)
{
_lastSpellEquipped = text;
_spellHudText.text = $" x{item} {text}";
if (_pulseCoroutine != null)
{
((MonoBehaviour)Hud.instance).StopCoroutine(_pulseCoroutine);
}
_pulseCoroutine = ((MonoBehaviour)Hud.instance).StartCoroutine(PulseText(_spellHudText));
if (_currentSpellRoutine != null)
{
((MonoBehaviour)Hud.instance).StopCoroutine(_currentSpellRoutine);
}
_currentSpellRoutine = ((MonoBehaviour)Hud.instance).StartCoroutine(ShowAndFadeHud(_spellHudText));
}
if (!string.IsNullOrEmpty(item4) && item4 != item2)
{
if (item4 != _lastNextSpell)
{
_lastNextSpell = item4;
_nextSpellHudText.text = $"<color=#AAAAAA> x{item3} {Localization.instance.Localize(item4)}</color>";
if (_nextSpellRoutine != null)
{
((MonoBehaviour)Hud.instance).StopCoroutine(_nextSpellRoutine);
}
_nextSpellRoutine = ((MonoBehaviour)Hud.instance).StartCoroutine(ShowAndFadeHud(_nextSpellHudText));
}
}
else
{
_lastNextSpell = "";
}
if (!string.IsNullOrEmpty(item6) && item6 != item2)
{
if (item6 != _lastPrevSpell)
{
_lastPrevSpell = item6;
_prevSpellHudText.text = $"<color=#AAAAAA> x{item5} {Localization.instance.Localize(item6)}</color>";
if (_prevSpellRoutine != null)
{
((MonoBehaviour)Hud.instance).StopCoroutine(_prevSpellRoutine);
}
_prevSpellRoutine = ((MonoBehaviour)Hud.instance).StartCoroutine(ShowAndFadeHud(_prevSpellHudText));
}
}
else
{
_lastPrevSpell = "";
}
}
}
else
{
<>1__state = -1;
}
<>2__current = (object)new WaitForSeconds(0.1f);
<>1__state = 1;
return true;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static GameObject _SpellHud;
public static TMP_Text _spellHudText;
public static TMP_Text _nextSpellHudText;
public static TMP_Text _prevSpellHudText;
public static GameObject _SpellPanel;
private static Image _spellCrosshair;
private static RectTransform _spellHudRectTransform;
private static RectTransform _SpellPanelRectTransform;
private static string _lastSpellEquipped = "";
private static Coroutine _pulseCoroutine;
private static readonly Vector3 _baseScale = Vector3.one;
private static Coroutine _currentSpellRoutine;
private static Coroutine _nextSpellRoutine;
private static Coroutine _prevSpellRoutine;
private static string _lastNextSpell = "";
private static string _lastPrevSpell = "";
[HarmonyPostfix]
[HarmonyPatch(typeof(Hud), "Awake")]
private static void Awake_Postfix(Hud __instance)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
//IL_0060: 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_0091: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0244: Unknown result type (might be due to invalid IL or missing references)
//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
//IL_02d4: Expected O, but got Unknown
//IL_0325: 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_0350: Unknown result type (might be due to invalid IL or missing references)
//IL_0362: Unknown result type (might be due to invalid IL or missing references)
_SpellHud = new GameObject("SpellNameHud");
_SpellHud.transform.SetParent(__instance.m_rootObject.transform);
_spellHudRectTransform = _SpellHud.AddComponent<RectTransform>();
((Component)_spellHudRectTransform).transform.SetParent(_SpellHud.transform);
_spellHudRectTransform.sizeDelta = new Vector2(320f, 64f);
float num = ((Component)__instance.m_crosshair).transform.localPosition.x + 216f;
float y = ((Component)__instance.m_crosshair).transform.localPosition.y;
_spellHudRectTransform.anchoredPosition = new Vector2(num, y);
GameObject obj = Object.Instantiate<GameObject>(((Component)__instance.m_actionName).gameObject, _SpellHud.transform);
((Object)obj).name = "CurrentSpellText";
obj.GetComponent<RectTransform>().anchoredPosition = Vector2.zero;
_spellHudText = (TMP_Text)(object)obj.GetComponent<TextMeshProUGUI>();
_spellHudText.text = "";
_spellHudText.fontSize = 18f;
_spellHudText.enableAutoSizing = false;
_spellHudText.alignment = (TextAlignmentOptions)4097;
_spellHudText.fontStyle = (FontStyles)1;
CanvasGroup obj2 = obj.AddComponent<CanvasGroup>();
obj2.alpha = 0f;
obj2.interactable = false;
obj2.blocksRaycasts = false;
((Component)obj2).gameObject.SetActive(false);
GameObject obj3 = Object.Instantiate<GameObject>(((Component)__instance.m_actionName).gameObject, _SpellHud.transform);
((Object)obj3).name = "NextSpellText";
obj3.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, 24f);
_nextSpellHudText = (TMP_Text)(object)obj3.GetComponent<TextMeshProUGUI>();
_nextSpellHudText.text = "";
_nextSpellHudText.fontSize = 14f;
_nextSpellHudText.enableAutoSizing = false;
_nextSpellHudText.alignment = (TextAlignmentOptions)4097;
_nextSpellHudText.fontStyle = (FontStyles)2;
CanvasGroup obj4 = obj3.AddComponent<CanvasGroup>();
obj4.alpha = 0f;
obj4.interactable = false;
obj4.blocksRaycasts = false;
((Component)obj4).gameObject.SetActive(false);
GameObject obj5 = Object.Instantiate<GameObject>(((Component)__instance.m_actionName).gameObject, _SpellHud.transform);
((Object)obj5).name = "PreviousSpellText";
obj5.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, -24f);
_prevSpellHudText = (TMP_Text)(object)obj5.GetComponent<TextMeshProUGUI>();
_prevSpellHudText.text = "";
_prevSpellHudText.fontSize = 14f;
_prevSpellHudText.enableAutoSizing = false;
_prevSpellHudText.alignment = (TextAlignmentOptions)4097;
_prevSpellHudText.fontStyle = (FontStyles)2;
CanvasGroup obj6 = obj5.AddComponent<CanvasGroup>();
obj6.alpha = 0f;
obj6.interactable = false;
obj6.blocksRaycasts = false;
((Component)obj6).gameObject.SetActive(false);
_SpellPanel = new GameObject("SpellPanel");
_SpellPanel.transform.SetParent(__instance.m_rootObject.transform);
_SpellPanelRectTransform = _SpellPanel.AddComponent<RectTransform>();
((Component)_SpellPanelRectTransform).transform.SetParent(_SpellPanel.transform);
_SpellPanelRectTransform.sizeDelta = new Vector2(96f, 96f);
float x = ((Component)__instance.m_crosshair).transform.localPosition.x;
float y2 = ((Component)__instance.m_crosshair).transform.localPosition.y;
_SpellPanelRectTransform.anchoredPosition = new Vector2(x, y2);
_spellCrosshair = _SpellPanel.AddComponent<Image>();
_spellCrosshair.sprite = PrefabSetups._magicBundle.LoadAsset<Sprite>("bmr_magic_crosshair");
_spellCrosshair.fillCenter = true;
_spellCrosshair.fillMethod = (FillMethod)0;
((MonoBehaviour)__instance).StartCoroutine(UpdateSpellHud());
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Hud), "UpdateCrosshair")]
private static void UpdateCrosshair_Postfix(Hud __instance, Player player)
{
//IL_003b: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)player != (Object)(object)Player.m_localPlayer) && !((Object)(object)__instance.m_crosshair == (Object)null))
{
((Graphic)__instance.m_crosshair).color = ((Plugin._enableSpellHud.Value == MagicRevamp.Functions.Toggle.On) ? Plugin._spellCrosshairColor.Value : Color.white);
}
}
[IteratorStateMachine(typeof(<UpdateSpellHud>d__18))]
private static IEnumerator UpdateSpellHud()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <UpdateSpellHud>d__18(0);
}
[IteratorStateMachine(typeof(<PulseText>d__19))]
private static IEnumerator PulseText(TMP_Text text, float scaleUp = 1.2f, float duration = 0.2f)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PulseText>d__19(0)
{
text = text,
scaleUp = scaleUp,
duration = duration
};
}
[IteratorStateMachine(typeof(<ShowAndFadeHud>d__20))]
private static IEnumerator ShowAndFadeHud(TMP_Text text, float fadeTime = 0.5f)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <ShowAndFadeHud>d__20(0)
{
text = text,
fadeTime = fadeTime
};
}
}
[HarmonyPatch]
public class HumanoidPatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(Humanoid), "EquipItem")]
private static bool EquipItem_Prefix(Humanoid __instance, ItemData item, ref bool __result)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Invalid comparison between Unknown and I4
Scene activeScene = SceneManager.GetActiveScene();
if (((Scene)(ref activeScene)).name != "main")
{
return true;
}
if ((Object)(object)__instance == (Object)null || !((Character)__instance).IsPlayer() || item == null || (int)item.m_shared.m_itemType == 9 || !item.m_shared.m_ammoType.Contains("ammo_spells") || Plugin._restrictStaves.Value == MagicRevamp.Functions.Toggle.Off)
{
return true;
}
bool flag = __instance.m_helmetItem != null && __instance.m_helmetItem.m_shared.m_eitrRegenModifier > 0f && __instance.m_chestItem != null && __instance.m_chestItem.m_shared.m_eitrRegenModifier > 0f;
bool flag2 = __instance.m_legItem != null && __instance.m_legItem.m_shared.m_eitrRegenModifier > 0f && __instance.m_shoulderItem != null && __instance.m_shoulderItem.m_shared.m_eitrRegenModifier > 0f;
if (item.m_shared.m_toolTier == 0 && !flag2)
{
((Character)__instance).Message((MessageType)2, "$bmr_cantequip_item", 0, (Sprite)null);
__result = false;
return false;
}
if (item.m_shared.m_toolTier >= 1 && (!flag || !flag2))
{
((Character)__instance).Message((MessageType)2, "$bmr_cantequip_item", 0, (Sprite)null);
__result = false;
return false;
}
return true;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Humanoid), "UpdateEquipment")]
private static void UpdateEquipment_Postfix(Humanoid __instance)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (!(((Scene)(ref activeScene)).name != "main") && ((Character)__instance).IsPlayer() && __instance.GetCurrentWeapon() != __instance.m_unarmedWeapon.m_itemData && __instance.GetCurrentWeapon().m_shared.m_ammoType.Contains("ammo_spells") && Plugin._restrictStaves.Value != 0)
{
bool flag = __instance.m_helmetItem != null && __instance.m_helmetItem.m_shared.m_eitrRegenModifier > 0f && __instance.m_chestItem != null && __instance.m_chestItem.m_shared.m_eitrRegenModifier > 0f;
bool flag2 = __instance.m_legItem != null && __instance.m_legItem.m_shared.m_eitrRegenModifier > 0f && __instance.m_shoulderItem != null && __instance.m_shoulderItem.m_shared.m_eitrRegenModifier > 0f;
if (__instance.GetCurrentWeapon().m_shared.m_toolTier == 0 && !flag2)
{
__instance.UnequipItem(__instance.GetCurrentWeapon(), true);
}
if (__instance.GetCurrentWeapon().m_shared.m_toolTier >= 1 && (!flag || !flag2))
{
__instance.UnequipItem(__instance.GetCurrentWeapon(), true);
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Humanoid), "UseItem")]
private static void UseItem_Postfix(Humanoid __instance, Inventory inventory, ItemData item, bool fromInventoryGui)
{
if (inventory == null)
{
inventory = __instance.m_inventory;
}
if (inventory.ContainsItem(item) && fromInventoryGui && item.m_shared.m_name.StartsWith("$bmr_scroll_"))
{
CycleSpells.ShowSpellEquipped();
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Humanoid), "UpdateEquipment")]
private static void UpdateEquipment_Postfix(ref Humanoid __instance)
{
if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && !(__instance.GetCurrentWeapon().m_shared.m_ammoType != "$ammo_spells") && HaveAmmo(__instance, __instance.GetCurrentWeapon()) && CycleSpells.CountSpellStacks() > 0)
{
EquipAmmoItem(__instance, __instance.GetCurrentWeapon());
}
}
private static bool HaveAmmo(Humanoid humanoid, ItemData weapon)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Invalid comparison between Unknown and I4
if (string.IsNullOrEmpty(weapon.m_shared.m_ammoType))
{
return true;
}
ItemData val = humanoid.GetAmmoItem();
if (val != null && (!humanoid.GetInventory().ContainsItem(val) || val.m_shared.m_ammoType != weapon.m_shared.m_ammoType))
{
val = null;
}
if (val == null)
{
val = humanoid.GetInventory().GetAmmoItem(weapon.m_shared.m_ammoType, (string)null);
}
if (val == null)
{
return false;
}
if ((int)val.m_shared.m_itemType == 2)
{
return humanoid.CanConsumeItem(val, false);
}
return true;
}
private static bool EquipAmmoItem(Humanoid humanoid, ItemData weapon)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Invalid comparison between Unknown and I4
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Invalid comparison between Unknown and I4
FindAmmo(humanoid, weapon);
if (string.IsNullOrEmpty(weapon.m_shared.m_ammoType))
{
return true;
}
ItemData ammoItem = humanoid.GetAmmoItem();
if (ammoItem != null && humanoid.GetInventory().ContainsItem(ammoItem) && ammoItem.m_shared.m_ammoType == weapon.m_shared.m_ammoType)
{
return true;
}
ItemData ammoItem2 = humanoid.GetInventory().GetAmmoItem(weapon.m_shared.m_ammoType, (string)null);
ItemType itemType = ammoItem2.m_shared.m_itemType;
if (((int)itemType == 9 || (int)itemType == 23) ? true : false)
{
return humanoid.EquipItem(ammoItem2, true);
}
return true;
}
private static ItemData FindAmmo(Humanoid humanoid, ItemData weapon)
{
if (string.IsNullOrEmpty(weapon.m_shared.m_ammoType))
{
return null;
}
ItemData val = humanoid.GetAmmoItem();
if (val != null && (!humanoid.GetInventory().ContainsItem(val) || val.m_shared.m_ammoType != weapon.m_shared.m_ammoType))
{
val = null;
}
return val ?? (val = humanoid.GetInventory().GetAmmoItem(weapon.m_shared.m_ammoType, (string)null));
}
}
[HarmonyPatch]
public class InventoryPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(Inventory), "ContainsItem")]
private static void ContainsItem_Postfix(Inventory __instance, ItemData item, ref bool __result)
{
Player localPlayer = Player.m_localPlayer;
if (!((Object)(object)localPlayer == (Object)null) && localPlayer.SpellBookContainer() != null && !(((Humanoid)localPlayer).GetCurrentWeapon().m_shared.m_ammoType != "$ammo_spells") && !Enumerable.All(localPlayer.SpellBookContainer().m_inventory, (ItemData item2) => item2 != item))
{
__result = true;
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Inventory), "GetAmmoItem")]
private static void GetAmmoItem_Postfix(Inventory __instance, ref ItemData __result, string ammoName, string matchPrefabName = null)
{
//IL_005e: 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_0065: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Invalid comparison between Unknown and I4
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Invalid comparison between Unknown and I4
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: Invalid comparison between Unknown and I4
Player localPlayer = Player.m_localPlayer;
if ((Object)(object)localPlayer == (Object)null || localPlayer.SpellBookContainer() == null || ((Humanoid)localPlayer).GetCurrentWeapon().m_shared.m_ammoType != "$ammo_spells")
{
return;
}
int num = 0;
ItemData val = null;
foreach (ItemData item in localPlayer.SpellBookContainer().m_inventory)
{
ItemType itemType = item.m_shared.m_itemType;
bool flag = (((int)itemType == 2 || (int)itemType == 9 || (int)itemType == 23) ? true : false);
if (flag && !(item.m_shared.m_ammoType != ammoName) && (matchPrefabName == null || !(((Object)item.m_dropPrefab).name != matchPrefabName)))
{
int num2 = item.m_gridPos.y * localPlayer.SpellBookContainer().m_width + item.m_gridPos.x;
if (num2 < num || val == null)
{
num = num2;
val = item;
}
}
}
__result = val;
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Inventory), "RemoveItem", new Type[]
{
typeof(ItemData),
typeof(int)
})]
private static void RemoveItem_Postfix(Inventory __instance, ItemData item, int amount, ref bool __result)
{
Player localPlayer = Player.m_localPlayer;
if (!((Object)(object)localPlayer == (Object)null) && localPlayer.SpellBookContainer() != null && !(((Humanoid)localPlayer).GetCurrentWeapon().m_shared.m_ammoType != "$ammo_spells"))
{
amount = Mathf.Min(item.m_stack, amount);
if (amount == item.m_stack)
{
__instance.RemoveItem(item);
}
if (localPlayer.SpellBookContainer().m_inventory.Contains(item))
{
item.m_stack -= amount;
__instance.Changed();
__result = true;
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Inventory), "AddItem", new Type[]
{
typeof(string),
typeof(int),
typeof(int),
typeof(int),
typeof(long),
typeof(string),
typeof(Vector2i),
typeof(bool)
})]
private static void AddItem_Postfix(Inventory __instance, string name, ref ItemData __result)
{
Player localPlayer = Player.m_localPlayer;
if (!((Object)(object)localPlayer == (Object)null) && localPlayer.SpellBookContainer() != null && (name.StartsWith("BMR_") || name.Contains("Scroll")) && __result != null && __result.m_shared.m_name.StartsWith("$bmr_scroll_") && localPlayer.SpellBookContainer().HaveEmptySlot())
{
if (localPlayer.SpellBookContainer().AddItem(__result.m_dropPrefab, __result.m_stack))
{
((Humanoid)localPlayer).GetInventory().RemoveItem(__result);
}
((Humanoid)localPlayer).GetInventory().Changed();
localPlayer.SpellBookContainer().Changed();
}
}
}
[HarmonyPatch]
public class ItemDataPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(ItemData), "GetTooltip", new Type[]
{
typeof(ItemData),
typeof(int),
typeof(bool),
typeof(float),
typeof(int)
})]
private static void GetTooltip_Postfix(ref string __result, ItemData item, int qualityLevel, bool crafting, float worldLevel)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Invalid comparison between Unknown and I4
if ((int)item.m_shared.m_itemType == 9 && item.m_shared.m_name.StartsWith("$bmr_scroll_"))
{
string text = $"\n$item_attackEitr: <color=orange>{item.m_shared.m_attack.m_attackEitr}</color>";
__result += text;
}
}
}
[HarmonyPatch(typeof(ItemDrop), "Awake")]
public class ItemDropPatch
{
private static void Postfix(ItemDrop __instance)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
Scene activeScene = SceneManager.GetActiveScene();
if (!(((Scene)(ref activeScene)).name != "main") && !((Object)(object)__instance == (Object)null))
{
switch (__instance.m_itemData.m_shared.m_name)
{
case "$bmr_scroll_fire1":
StatsSetup.FireScroll1(__instance);
break;
case "$bmr_scroll_fire2":
StatsSetup.FireScroll2(__instance);
break;
case "$bmr_scroll_fire3":
StatsSetup.FireScroll3(__instance);
break;
case "$bmr_scroll_fire4":
StatsSetup.FireScroll4(__instance);
break;
case "$bmr_scroll_fire5":
StatsSetup.FireScroll5(__instance);
break;
case "$bmr_scroll_fire6":
StatsSetup.FireScroll6(__instance);
break;
case "$bmr_scroll_ice1":
StatsSetup.IceScroll1(__instance);
break;
case "$bmr_scroll_ice2":
StatsSetup.IceScroll2(__instance);
break;
case "$bmr_scroll_ice3":
StatsSetup.IceScroll3(__instance);
break;
case "$bmr_scroll_ice4":
StatsSetup.IceScroll4(__instance);
break;
case "$bmr_scroll_ice5":
StatsSetup.IceScroll5(__instance);
break;
case "$bmr_scroll_ice6":
StatsSetup.IceScroll6(__instance);
break;
case "$bmr_scroll_lightning1":
StatsSetup.LightningScroll1(__instance);
break;
case "$bmr_scroll_lightning2":
StatsSetup.LightningScroll2(__instance);
break;
case "$bmr_scroll_lightning3":
StatsSetup.LightningScroll3(__instance);
break;
case "$bmr_scroll_lightning4":
StatsSetup.LightningScroll4(__instance);
break;
case "$bmr_scroll_lightning5":
StatsSetup.LightningScroll5(__instance);
break;
case "$bmr_scroll_lightning6":
StatsSetup.LightningScroll6(__instance);
break;
case "$bmr_scroll_poison1":
StatsSetup.PoisonScroll1(__instance);
break;
case "$bmr_scroll_poison2":
StatsSetup.PoisonScroll2(__instance);
break;
case "$bmr_scroll_poison3":
StatsSetup.PoisonScroll3(__instance);
break;
case "$bmr_scroll_poison4":
StatsSetup.PoisonScroll4(__instance);
break;
case "$bmr_scroll_poison5":
StatsSetup.PoisonScroll5(__instance);
break;
case "$bmr_scroll_poison6":
StatsSetup.PoisonScroll6(__instance);
break;
case "$bmr_scroll_frostspike":
StatsSetup.FrostSpike(__instance.m_itemData);
break;
case "$bmr_scroll_lightningstorm":
StatsSetup.LightningStorm(__instance.m_itemData);
break;
case "$bmr_scroll_meteor":
StatsSetup.Meteor(__instance.m_itemData);
break;
case "$bmr_scroll_poisonmist":
StatsSetup.PoisonMist(__instance.m_itemData);
break;
case "$bmr_scroll_clusterbomb":
StatsSetup.ClusterBomb(__instance.m_itemData);
break;
case "$bmr_scroll_frostbomb":
StatsSetup.FrostBomb(__instance.m_itemData);
break;
}
string name = __instance.m_itemData.m_shared.m_name;
if (name.Contains("$bmr_paper_"))
{
StatsSetup.SetPaperMaxStackSize(__instance.m_itemData);
}
if (name.Contains("$bmr_scroll_"))
{
StatsSetup.SetScrollsMaxStackSize(__instance);
}
if (name.Contains("$bmr_essence_"))
{
StatsSetup.SetEssencesMaxStackSize(__instance);
}
}
}
}
[HarmonyPatch]
public class MineRock5Patch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(MineRock5), "RPC_Damage")]
private static void RpcDamage_Prefix(MineRock5 __instance, HitData hit)
{
Character attacker = hit.GetAttacker();
Player val = (Player)(object)((attacker is Player) ? attacker : null);
if (val != null && ((Humanoid)val).GetCurrentWeapon() != null && ((Humanoid)val).GetCurrentWeapon().m_shared.m_ammoType.Contains("ammo_spells") && ((Humanoid)val).GetCurrentWeapon() != ((Humanoid)val).m_unarmedWeapon.m_itemData && ((Humanoid)val).GetAmmoItem() != null && ((Humanoid)val).GetAmmoItem().m_shared.m_name.Contains("scroll_mining") && hit.m_damage.m_pickaxe > 0f && __instance.m_nview.IsValid() && __instance.m_nview.IsOwner())
{
hit.m_toolTier = (short)((Humanoid)val).GetAmmoItem().m_shared.m_toolTier;
((Character)val).RaiseSkill((SkillType)12, 0.2f);
}
}
[HarmonyPrefix]
[HarmonyPatch(typeof(MineRock5), "DamageArea")]
private static void DamageArea_Prefix(MineRock5 __instance, HitData hit)
{
Character attacker = hit.GetAttacker();
Player val = (Player)(object)((attacker is Player) ? attacker : null);
if (val != null && ((Humanoid)val).GetCurrentWeapon() != null && ((Humanoid)val).GetCurrentWeapon().m_shared.m_ammoType.Contains("ammo_spells") && ((Humanoid)val).GetCurrentWeapon() != ((Humanoid)val).m_unarmedWeapon.m_itemData && ((Humanoid)val).GetAmmoItem() != null && ((Humanoid)val).GetAmmoItem().m_shared.m_name.Contains("scroll_mining") && hit.m_damage.m_pickaxe > 0f && __instance.m_nview.IsValid() && __instance.m_nview.IsOwner())
{
hit.m_toolTier = (short)((Humanoid)val).GetAmmoItem().m_shared.m_toolTier;
((Character)val).RaiseSkill((SkillType)12, 0.2f);
}
}
}
[HarmonyPatch]
public class MineRockPatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(MineRock), "RPC_Hit")]
private static void Prefix(MineRock __instance, HitData hit)
{
Character attacker = hit.GetAttacker();
Player val = (Player)(object)((attacker is Player) ? attacker : null);
if (val != null && ((Humanoid)val).GetCurrentWeapon() != null && ((Humanoid)val).GetCurrentWeapon().m_shared.m_ammoType.Contains("ammo_spells") && ((Humanoid)val).GetCurrentWeapon() != ((Humanoid)val).m_unarmedWeapon.m_itemData && ((Humanoid)val).GetAmmoItem() != null && ((Humanoid)val).GetAmmoItem().m_shared.m_name.Contains("scroll_mining") && hit.m_damage.m_pickaxe > 0f && __instance.m_nview.IsValid() && __instance.m_nview.IsOwner())
{
hit.m_toolTier = (short)((Humanoid)val).GetAmmoItem().m_shared.m_toolTier;
((Character)val).RaiseSkill((SkillType)12, 0.2f);
}
}
}
[HarmonyPatch(typeof(MonsterAI), "UpdateAI")]
public class MonsterAIPatch
{
private static void Postfix(MonsterAI __instance)
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
Player localPlayer = Player.m_localPlayer;
if (((BaseAI)__instance).m_character.IsTamed() && ((Object)((Component)__instance).gameObject).name.Contains("SummonUlv") && !((BaseAI)__instance).IsSleeping() && Object.op_Implicit((Object)(object)localPlayer) && ((Character)localPlayer).IsSitting() && Vector3.Distance(((Component)localPlayer).transform.position, ((Component)__instance).transform.position) < 20f)
{
((MonoBehaviour)__instance).StopAllCoroutines();
((BaseAI)__instance).m_animator.SetTrigger("sleeping");
((BaseAI)__instance).m_animator.SetBool("sleeping", true);
((BaseAI)__instance).m_nview.GetZDO().Set(ZDOVars.s_sleeping, true);
__instance.m_sleeping = true;
Debug.Log((object)((Object)((Component)__instance).gameObject).name);
}
}
}
[HarmonyPatch]
public class PlayerPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(Player), "UpdateStats", new Type[] { typeof(float) })]
private static void UpdateStats_Postfix(Player __instance)
{
if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Cleanse1_SE")))
{
((Character)__instance).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("Wet"), false);
}
else if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Cleanse2_SE")))
{
foreach (string item in new List<string> { "Wet", "Smoked", "Burning" })
{
((Character)__instance).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode(item), false);
}
}
else if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Cleanse3_SE")))
{
foreach (string item2 in new List<string> { "Wet", "Smoked", "Burning", "Poison" })
{
((Character)__instance).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode(item2), false);
}
}
else if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Cleanse4_SE")))
{
foreach (string item3 in new List<string> { "Wet", "Smoked", "Burning", "Poison", "Frost" })
{
((Character)__instance).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode(item3), false);
}
}
else if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Cleanse5_SE")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Cleanse6_SE")))
{
foreach (string item4 in new List<string> { "Wet", "Smoked", "Burning", "Poison", "Frost", "Tared" })
{
((Character)__instance).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode(item4), false);
}
}
if ((((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort1_SE")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort2_SE")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort3_SE")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort4_SE")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort5_SE")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort6_SE"))) && !((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("Rested")))
{
((Character)__instance).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("Rested"), false, 0, 0f);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Player), "UpdateBaseValue")]
private static void UpdateBaseValue_Postfix(Player __instance)
{
if (!((Object)(object)__instance == (Object)null) && !((Character)__instance).IsDead() && !__instance.InShelter())
{
if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort1_SE")) && !((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("Rested")))
{
__instance.m_comfortLevel += ConfigSetup._comfortSpell1Comfort.Value;
}
else if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort2_SE")) && !((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("Rested")))
{
__instance.m_comfortLevel += ConfigSetup._comfortSpell2Comfort.Value;
}
else if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort3_SE")) && !((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("Rested")))
{
__instance.m_comfortLevel += ConfigSetup._comfortSpell3Comfort.Value;
}
else if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort4_SE")) && !((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("Rested")))
{
__instance.m_comfortLevel += ConfigSetup._comfortSpell4Comfort.Value;
}
else if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort5_SE")) && !((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("Rested")))
{
__instance.m_comfortLevel += ConfigSetup._comfortSpell5Comfort.Value;
}
else if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort6_SE")) && !((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("Rested")))
{
__instance.m_comfortLevel += ConfigSetup._comfortSpell6Comfort.Value;
}
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
private static void GetTotalFoodValue_Postfix(ref Player __instance, ref float eitr)
{
if (!((Object)(object)__instance == (Object)null) && !Plugin._hasMagicPluginMod)
{
SetEitr(__instance, "bmr_tatteredcape", ConfigSetup._tatteredCapeEitr.Value, ref eitr);
SetEitr(__instance, "bmr_tatteredchest", ConfigSetup._tatteredChestEitr.Value, ref eitr);
SetEitr(__instance, "bmr_tatteredhelm", ConfigSetup._tatteredHelmEitr.Value, ref eitr);
SetEitr(__instance, "bmr_tatteredlegs", ConfigSetup._tatteredLegsEitr.Value, ref eitr);
SetEitr(__instance, "bmr_sorcererscape", ConfigSetup._sorcerersCapeEitr.Value, ref eitr);
SetEitr(__instance, "bmr_sorcerershat", ConfigSetup._sorcerersHatEitr.Value, ref eitr);
SetEitr(__instance, "bmr_sorcererstrousers", ConfigSetup._sorcerersTrousersEitr.Value, ref eitr);
SetEitr(__instance, "bmr_sorcererstunic", ConfigSetup._sorcerersTunicEitr.Value, ref eitr);
SetEitr(__instance, "bmr_warlockscape", ConfigSetup._warlocksCapeEitr.Value, ref eitr);
SetEitr(__instance, "bmr_warlockshood", ConfigSetup._warlocksHoodEitr.Value, ref eitr);
SetEitr(__instance, "bmr_warlockspants", ConfigSetup._warlocksPantsEitr.Value, ref eitr);
SetEitr(__instance, "bmr_warlocksvest", ConfigSetup._warlocksVestEitr.Value, ref eitr);
SetEitr(__instance, "bmr_polarwolfcape", ConfigSetup._polarWolfCapeEitr.Value, ref eitr);
SetEitr(__instance, "bmr_polarwolfchest", ConfigSetup._polarWolfChestEitr.Value, ref eitr);
SetEitr(__instance, "bmr_polarwolfhood", ConfigSetup._polarWolfHoodEitr.Value, ref eitr);
SetEitr(__instance, "bmr_polarwolflegs", ConfigSetup._polarWolfLegEitr.Value, ref eitr);
SetEitr(__instance, "bmr_seekercape", ConfigSetup._seekerCapeEitr.Value, ref eitr);
SetEitr(__instance, "bmr_seekerchest", ConfigSetup._seekerChestEitr.Value, ref eitr);
SetEitr(__instance, "bmr_seekerhat", ConfigSetup._seekerHatEitr.Value, ref eitr);
SetEitr(__instance, "bmr_seekerlegs", ConfigSetup._seekerLegsEitr.Value, ref eitr);
SetEitr(__instance, "bmr_crimsoncape", ConfigSetup._crimsonCapeEitr.Value, ref eitr);
SetEitr(__instance, "bmr_crimsonchest", ConfigSetup._crimsonChestEitr.Value, ref eitr);
SetEitr(__instance, "bmr_crimsonhood", ConfigSetup._crimsonHoodEitr.Value, ref eitr);
SetEitr(__instance, "bmr_crimsonlegs", ConfigSetup._crimsonLegsEitr.Value, ref eitr);
}
}
[HarmonyPostfix]
[HarmonyPatch(typeof(Player), "TeleportTo")]
private static void TeleportTo_Postfix(Player __instance, ref Vector3 pos, ref Quaternion rot)
{
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance == (Object)null)
{
return;
}
foreach (Character item in Enumerable.Select(Enumerable.Where(Enumerable.Select(Character.GetAllCharacters(), (Character character) => new
{
character = character,
tamable = ((Component)character).GetComponent<Tameable>()
}), <>h__TransparentIdentifier0 => (Object)(object)<>h__TransparentIdentifier0.character != (Object)null && <>h__TransparentIdentifier0.character.m_nview.IsValid() && <>h__TransparentIdentifier0.character.IsTamed() && (Object)(object)<>h__TransparentIdentifier0.tamable != (Object)null && (Object)(object)<>h__TransparentIdentifier0.tamable.m_monsterAI.GetFollowTarget() != (Object)null && (Object)(object)<>h__TransparentIdentifier0.tamable.m_monsterAI.GetFollowTarget() == (Object)(object)((Component)__instance).gameObject && ((Object)((Component)<>h__TransparentIdentifier0.character).gameObject).name.StartsWith("BMR_")), <>h__TransparentIdentifier0 => <>h__TransparentIdentifier0.character))
{
((Component)item).transform.position = pos + ((Component)__instance).transform.forward;
((Component)item).transform.rotation = rot;
}
}
private static void SetEitr(Player player, string statEffect, float amount, ref float eitr)
{
if (((Character)player).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode(statEffect)))
{
eitr += amount;
}
}
}
[HarmonyPatch]
public class SEManPatch
{
[HarmonyPrefix]
[HarmonyPatch(typeof(SEMan), "Internal_AddStatusEffect")]
private static bool AddStatusEffect_Prefix(SEMan __instance, ref int nameHash)
{
if (!__instance.m_character.IsPlayer() && (nameHash == StringExtensionMethods.GetStableHashCode("BMR_Demister") || nameHash == StringExtensionMethods.GetStableHashCode("BMR_FireWisp") || nameHash == StringExtensionMethods.GetStableHashCode("BMR_Repair_SE") || nameHash == StringExtensionMethods.GetStableHashCode("BMR_Sailing_SE")))
{
return false;
}
if (__instance.HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Cleanse6_SE")) && (nameHash == StringExtensionMethods.GetStableHashCode("Wet") || nameHash == StringExtensionMethods.GetStableHashCode("Smoked") || nameHash == StringExtensionMethods.GetStableHashCode("Burning") || nameHash == StringExtensionMethods.GetStableHashCode("Tared")))
{
return false;
}
return true;
}
}
[HarmonyPatch]
public class SE_RestedPatch
{
[HarmonyPostfix]
[HarmonyPatch(typeof(SE_Rested), "CalculateComfortLevel", new Type[]
{
typeof(bool),
typeof(Vector3)
})]
private static void CalculateComfortLevel_Postfix(ref int __result)
{
Player localPlayer = Player.m_localPlayer;
if (!((Object)(object)localPlayer == (Object)null))
{
if (((Character)localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort1_SE")))
{
__result += ConfigSetup._comfortSpell1Comfort.Value;
}
else if (((Character)localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort2_SE")))
{
__result += ConfigSetup._comfortSpell2Comfort.Value;
}
else if (((Character)localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort3_SE")))
{
__result += ConfigSetup._comfortSpell3Comfort.Value;
}
else if (((Character)localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort4_SE")))
{
__result += ConfigSetup._comfortSpell4Comfort.Value;
}
else if (((Character)localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BMR_Comfort5_SE")))
{
__result += ConfigSetup._comfortSpell5Comfort.Value;
}
else if