using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn;
using Jotunn.Entities;
using Jotunn.Extensions;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using MonsterModifiers.Custom_Components;
using MonsterModifiers.Modifiers;
using MonsterModifiers.StatusEffects;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;
[assembly: AssemblyFileVersion("1.2.3")]
[assembly: Guid("E0E2F92E-557C-4A05-9D89-AA92A0BD75C4")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyProduct("MonsterModifiers")]
[assembly: AssemblyCompany("warpalicious")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("MonsterModifiers")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.2.3.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
[Microsoft.CodeAnalysis.Embedded]
[CompilerGenerated]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace MonsterModifiers
{
[BepInPlugin("warpalicious.MonsterModifiers", "MonsterModifiers", "1.2.3")]
public class MonsterModifiersPlugin : BaseUnityPlugin
{
public enum Toggle
{
On = 1,
Off = 0
}
internal const string ModName = "MonsterModifiers";
internal const string ModVersion = "1.2.3";
internal const string Author = "warpalicious";
private const string ModGUID = "warpalicious.MonsterModifiers";
private static string ConfigFileName = "warpalicious.MonsterModifiers.cfg";
private static string ConfigFileFullPath;
internal static string ConnectionError;
private readonly Harmony _harmony = new Harmony("warpalicious.MonsterModifiers");
public static readonly ManualLogSource MonsterModifiersLogger;
public Texture2D tex = null;
public static ConfigEntry<int> Configurations_MaxModifiers;
public void Awake()
{
bool saveOnConfigSet = ((BaseUnityPlugin)this).Config.SaveOnConfigSet;
((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
Assembly executingAssembly = Assembly.GetExecutingAssembly();
_harmony.PatchAll(executingAssembly);
SetupWatcher();
if (saveOnConfigSet)
{
((BaseUnityPlugin)this).Config.SaveOnConfigSet = saveOnConfigSet;
((BaseUnityPlugin)this).Config.Save();
}
YamlUtils.ParseDefaultYamls();
TranslationUtils.AddLocalizations();
ModifierAssetUtils.Setup();
ModifierAssetUtils.LoadAllIcons();
Configurations_MaxModifiers = ConfigFileExtensions.BindConfig<int>(((BaseUnityPlugin)this).Config, "Balance", "Max Modifiers", 5, "The maximum amount of modifiers a creature can have.", true, (int?)null, (AcceptableValueBase)null, (Action<ConfigEntryBase>)null, (ConfigurationManagerAttributes)null);
CompatibilityUtils.RunCompatibiltyChecks();
StatusEffectUtils.CreateCustomStatusEffects();
PrefabManager.OnVanillaPrefabsAvailable += PrefabUtils.CreateCustomPrefabs;
}
private void OnDestroy()
{
((BaseUnityPlugin)this).Config.Save();
}
private void SetupWatcher()
{
FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName);
fileSystemWatcher.Changed += ReadConfigValues;
fileSystemWatcher.Created += ReadConfigValues;
fileSystemWatcher.Renamed += ReadConfigValues;
fileSystemWatcher.IncludeSubdirectories = true;
fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
fileSystemWatcher.EnableRaisingEvents = true;
}
private void ReadConfigValues(object sender, FileSystemEventArgs e)
{
if (!File.Exists(ConfigFileFullPath))
{
return;
}
try
{
MonsterModifiersLogger.LogDebug((object)"ReadConfigValues called");
((BaseUnityPlugin)this).Config.Reload();
}
catch
{
MonsterModifiersLogger.LogError((object)("There was an issue loading your " + ConfigFileName));
MonsterModifiersLogger.LogError((object)"Please check your config entries for spelling and format!");
}
}
static MonsterModifiersPlugin()
{
string configPath = Paths.ConfigPath;
char directorySeparatorChar = Path.DirectorySeparatorChar;
ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName;
ConnectionError = "";
MonsterModifiersLogger = Logger.CreateLogSource("MonsterModifiers");
}
}
public static class KeyboardExtensions
{
public static bool IsKeyDown(this KeyboardShortcut shortcut)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
return (int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey) && ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey);
}
public static bool IsKeyHeld(this KeyboardShortcut shortcut)
{
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
return (int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKey(((KeyboardShortcut)(ref shortcut)).MainKey) && ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey);
}
}
public class CompatibilityUtils
{
public static bool isStarLevelsExpandedInstalled;
public static void RunCompatibiltyChecks()
{
if (Chainloader.PluginInfos.ContainsKey("CreatureLevelControl"))
{
MonsterModifiersPlugin.MonsterModifiersLogger.LogWarning((object)"CreatureLevelandLootControl plugin is installed. Please ensure special effects and infusions are disabled in CLLC configuration.");
}
if (Chainloader.PluginInfos.ContainsKey("MidnightsFX.StarLevelSystem"))
{
MonsterModifiersPlugin.MonsterModifiersLogger.LogWarning((object)"StarLevelSystem plugin is installed. Please ensure max modifiers config is set.");
isStarLevelsExpandedInstalled = true;
}
}
}
public class DamageUtils
{
public static float TryCurrentWeapon(Humanoid humanoid)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: 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)
ItemData currentWeapon = humanoid.GetCurrentWeapon();
if (currentWeapon == null)
{
return 10f;
}
DamageTypes damage = currentWeapon.GetDamage();
if (((DamageTypes)(ref damage)).HaveDamage())
{
return 10f;
}
float totalDamage = ((DamageTypes)(ref damage)).GetTotalDamage();
if (totalDamage == 0f)
{
return 10f;
}
DamageTypes damage2 = humanoid.GetCurrentWeapon().GetDamage();
return ((DamageTypes)(ref damage2)).GetTotalDamage();
}
public static float TryWeaponList(GameObject[] weaponArray)
{
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
float num = 10f;
List<GameObject> list = weaponArray.ToList();
if (list.Count > 0)
{
foreach (GameObject item in list)
{
ItemData itemData = item.GetComponent<ItemDrop>().m_itemData;
if (itemData != null)
{
DamageTypes damage = itemData.GetDamage();
float totalDamage = ((DamageTypes)(ref damage)).GetTotalDamage();
if (totalDamage > num)
{
num = totalDamage;
}
}
}
}
if (num > 0f)
{
}
return num;
}
public static float CalculateDamage(Character character, float percentTotal)
{
Humanoid val = (Humanoid)(object)((character is Humanoid) ? character : null);
if ((Object)(object)val == (Object)null)
{
return 10f;
}
if (character.IsPlayer())
{
return 10f;
}
float num = 10f;
float num2 = TryCurrentWeapon(val);
if (num2 > 0f && num2 > num)
{
num = num2;
}
float num3 = TryWeaponList(val.m_defaultItems);
if (num3 > 0f && num3 > num)
{
num = num3;
}
float num4 = TryWeaponList(val.m_randomWeapon);
if (num4 > 0f && num4 > num)
{
num = num4;
}
return num * percentTotal;
}
}
public class ModifierAssetUtils
{
public static AssetBundle ashlandsAssetBundle;
public static AssetBundle statusEffectBundle;
public static AssetBundle modiferIconsBundle;
public static Sprite swordIcon;
public static Sprite shieldIcon;
public static Sprite plusSquareIcon;
public static Sprite circleIcon;
public static Sprite soulIcon;
public static Sprite skullIcon;
public static Sprite appleIcon;
public static Sprite shieldBrokenIcon;
public static Sprite shieldSpearIcon;
public static Sprite shieldMaceIcon;
public static Sprite shieldSwordIcon;
public static Sprite potionIcon;
public static Sprite bloodIcon;
public static Sprite bloodIconRed;
public static Sprite heartIcon;
public static Sprite earIcon;
public static void Setup()
{
statusEffectBundle = AssetUtils.LoadAssetBundleFromResources("statusicon", Assembly.GetExecutingAssembly());
modiferIconsBundle = AssetUtils.LoadAssetBundleFromResources("modifiericons", Assembly.GetExecutingAssembly());
}
public static void LoadAllIcons()
{
swordIcon = modiferIconsBundle.LoadAsset<Sprite>("Assets/WarpProjects/Modifiers/NewModifierIcons/Sword.png");
shieldIcon = modiferIconsBundle.LoadAsset<Sprite>("Assets/WarpProjects/Modifiers/NewModifierIcons/Shield.png");
plusSquareIcon = modiferIconsBundle.LoadAsset<Sprite>("Assets/WarpProjects/Modifiers/NewModifierIcons/PlusBox.png");
circleIcon = modiferIconsBundle.LoadAsset<Sprite>("Assets/WarpProjects/Modifiers/NewModifierIcons/Circle.png");
soulIcon = modiferIconsBundle.LoadAsset<Sprite>("Assets/WarpProjects/Modifiers/NewModifierIcons/SoulEater.png");
skullIcon = modiferIconsBundle.LoadAsset<Sprite>("Assets/WarpProjects/Modifiers/NewModifierIcons/Skull.png");
appleIcon = modiferIconsBundle.LoadAsset<Sprite>("Assets/WarpProjects/Modifiers/NewModifierIcons/Apple.png");
shieldBrokenIcon = modiferIconsBundle.LoadAsset<Sprite>("Assets/WarpProjects/Modifiers/NewModifierIcons/ShieldBroken.png");
shieldSpearIcon = modiferIconsBundle.LoadAsset<Sprite>("Assets/WarpProjects/Modifiers/NewModifierIcons/ShieldSpear.png");
shieldMaceIcon = modiferIconsBundle.LoadAsset<Sprite>("Assets/WarpProjects/Modifiers/NewModifierIcons/ShieldMace.png");
shieldSwordIcon = modiferIconsBundle.LoadAsset<Sprite>("Assets/WarpProjects/Modifiers/NewModifierIcons/ShieldSword.png");
potionIcon = modiferIconsBundle.LoadAsset<Sprite>("Assets/WarpProjects/Modifiers/NewModifierIcons/Potion.png");
heartIcon = modiferIconsBundle.LoadAsset<Sprite>("Assets/WarpProjects/Modifiers/NewModifierIcons/heartIcon.png");
bloodIcon = statusEffectBundle.LoadAsset<Sprite>("Assets/WarpProjects/Modifiers/NewModifierIcons/bloodIcon.png");
bloodIconRed = statusEffectBundle.LoadAsset<Sprite>("Assets/WarpProjects/Modifiers/NewModifierIcons/bloodIconRed.png");
earIcon = modiferIconsBundle.LoadAsset<Sprite>("Assets/WarpProjects/Modifiers/NewModifierIcons/Ear.png");
}
}
public enum MonsterModifierTypes
{
StaminaSiphon,
EitrSiphon,
ShieldBreaker,
FoodDrain,
IgnoreArmor,
PoisonDeath,
FrostDeath,
FireDeath,
HealDeath,
StaggerDeath,
TarDeath,
PersonalShield,
ShieldDome,
SoulEater,
RemoveStatusEffect,
StaggerImmune,
FireInfused,
PoisonInfused,
FrostInfused,
LightningInfused,
ElementalImmunity,
PierceImmunity,
BluntImmunity,
SlashImmunity,
FastMovement,
FastAttackSpeed,
DistantDetection,
BloodLoss,
Absorption,
Vampiric,
Forceful,
Wet,
Quiet
}
public class ModifierData
{
public int weight { get; set; }
public List<float> color { get; set; }
}
public class ModifierUtils
{
public static Dictionary<MonsterModifierTypes, ModifierData> modifiers;
public static Color GetModifierColor(MonsterModifierTypes modifier)
{
//IL_0035: 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_0039: Unknown result type (might be due to invalid IL or missing references)
List<float> color = modifiers[modifier].color;
Color result = default(Color);
((Color)(ref result))..ctor(color[0], color[1], color[2], color[3]);
return result;
}
public static Sprite GetModifierIcon(MonsterModifierTypes modifier)
{
if (modifier == MonsterModifierTypes.FireInfused || modifier == MonsterModifierTypes.FrostInfused || modifier == MonsterModifierTypes.PoisonInfused || modifier == MonsterModifierTypes.LightningInfused || modifier == MonsterModifierTypes.RemoveStatusEffect)
{
return ModifierAssetUtils.swordIcon;
}
if (modifier == MonsterModifierTypes.ShieldBreaker || modifier == MonsterModifierTypes.IgnoreArmor)
{
return ModifierAssetUtils.shieldBrokenIcon;
}
if (modifier == MonsterModifierTypes.StaminaSiphon || modifier == MonsterModifierTypes.EitrSiphon)
{
return ModifierAssetUtils.potionIcon;
}
switch (modifier)
{
case MonsterModifierTypes.FoodDrain:
return ModifierAssetUtils.appleIcon;
default:
if (modifier != MonsterModifierTypes.TarDeath)
{
if (modifier == MonsterModifierTypes.ElementalImmunity || modifier == MonsterModifierTypes.StaggerImmune)
{
return ModifierAssetUtils.shieldIcon;
}
if (modifier == MonsterModifierTypes.PersonalShield || modifier == MonsterModifierTypes.ShieldDome)
{
return ModifierAssetUtils.circleIcon;
}
switch (modifier)
{
case MonsterModifierTypes.SoulEater:
return ModifierAssetUtils.soulIcon;
case MonsterModifierTypes.PierceImmunity:
return ModifierAssetUtils.shieldSpearIcon;
case MonsterModifierTypes.SlashImmunity:
return ModifierAssetUtils.shieldSwordIcon;
case MonsterModifierTypes.BluntImmunity:
return ModifierAssetUtils.shieldMaceIcon;
default:
if (modifier != MonsterModifierTypes.Forceful)
{
if (modifier == MonsterModifierTypes.BloodLoss || modifier == MonsterModifierTypes.Wet)
{
return ModifierAssetUtils.bloodIcon;
}
if (modifier == MonsterModifierTypes.Absorption || modifier == MonsterModifierTypes.Vampiric)
{
return ModifierAssetUtils.heartIcon;
}
if (modifier == MonsterModifierTypes.Quiet)
{
return ModifierAssetUtils.earIcon;
}
Debug.Log((object)"Could not find icon for modifier");
return ModifierAssetUtils.plusSquareIcon;
}
goto case MonsterModifierTypes.FastMovement;
case MonsterModifierTypes.FastMovement:
case MonsterModifierTypes.FastAttackSpeed:
case MonsterModifierTypes.DistantDetection:
return ModifierAssetUtils.plusSquareIcon;
}
}
goto case MonsterModifierTypes.PoisonDeath;
case MonsterModifierTypes.PoisonDeath:
case MonsterModifierTypes.FrostDeath:
case MonsterModifierTypes.FireDeath:
case MonsterModifierTypes.HealDeath:
case MonsterModifierTypes.StaggerDeath:
return ModifierAssetUtils.skullIcon;
}
}
public static int GetModifierWeight(MonsterModifierTypes modifier)
{
return modifiers[modifier].weight;
}
public static List<MonsterModifierTypes> RollRandomModifiers(int numModifiers)
{
List<MonsterModifierTypes> list = new List<MonsterModifierTypes>();
Dictionary<MonsterModifierTypes, ModifierData> dictionary = new Dictionary<MonsterModifierTypes, ModifierData>(modifiers);
for (int i = 0; i < numModifiers; i++)
{
int num = 0;
foreach (ModifierData value in dictionary.Values)
{
num += value.weight;
}
int num2 = Random.Range(0, num);
int num3 = 0;
MonsterModifierTypes monsterModifierTypes = MonsterModifierTypes.StaminaSiphon;
foreach (KeyValuePair<MonsterModifierTypes, ModifierData> item in dictionary)
{
num3 += item.Value.weight;
if (num2 < num3)
{
monsterModifierTypes = item.Key;
break;
}
}
list.Add(monsterModifierTypes);
dictionary.Remove(monsterModifierTypes);
}
return list;
}
public static void RunBiomeChecks()
{
}
public static bool RunRPCDamageChecks(Character character, HitData hit)
{
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Invalid comparison between Unknown and I4
if (hit == null || (Object)(object)character == (Object)null)
{
return false;
}
if (((DamageTypes)(ref hit.m_damage)).GetTotalDamage() == 0f)
{
return false;
}
if ((int)hit.m_hitType != 1)
{
return false;
}
return true;
}
public static bool RunRPCDamageChecks(Character character, HitData hit, bool isMonsterAttackingPlayer)
{
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Invalid comparison between Unknown and I4
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Invalid comparison between Unknown and I4
if (hit == null || (Object)(object)character == (Object)null)
{
Debug.Log((object)"Hit or character is null");
return true;
}
if (((DamageTypes)(ref hit.m_damage)).GetTotalDamage() == 0f)
{
Debug.Log((object)"Total damage is 0");
return true;
}
if (isMonsterAttackingPlayer)
{
if ((int)hit.m_hitType != 1)
{
Debug.Log((object)"hit type is not enemy hit");
return true;
}
}
else if ((int)hit.m_hitType != 2)
{
Debug.Log((object)"hit type is not player hit");
return true;
}
return true;
}
public static bool RunHitChecks(HitData hit, bool isMonsterAttackingPlayer)
{
Character attacker = hit.GetAttacker();
if ((Object)(object)attacker == (Object)null)
{
return false;
}
if (isMonsterAttackingPlayer && attacker.IsPlayer())
{
return false;
}
if (!isMonsterAttackingPlayer && attacker.IsPlayer())
{
return true;
}
return true;
}
}
public class PrefabUtils
{
public static GameObject leechDeathVFX;
public static GameObject leechDeathSFX;
public static void CreateCustomPrefabs()
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: Expected O, but got Unknown
//IL_0100: Unknown result type (might be due to invalid IL or missing references)
//IL_0107: Expected O, but got Unknown
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
GameObject prefab = PrefabManager.Instance.GetPrefab("shaman_heal_aoe");
GameObject val = PrefabManager.Instance.CreateClonedPrefab("healCustomPrefab", prefab);
CustomPrefab val2 = new CustomPrefab(val, false);
Aoe component = val2.Prefab.GetComponent<Aoe>();
component.m_statusEffect = "";
GameObject prefab2 = PrefabManager.Instance.GetPrefab("Mistile");
GameObject val3 = PrefabManager.Instance.CreateClonedPrefab("mistleCustomPrefab", prefab2);
CustomPrefab val4 = new CustomPrefab(val3, false);
Character component2 = (Character)(object)val4.Prefab.GetComponent<Humanoid>();
component2.m_speed = 0f;
component2.m_flyFastSpeed = 0f;
component2.m_flySlowSpeed = 0f;
component2.m_name = "$modifier_mistile";
val4.Prefab.GetComponent<CharacterTimedDestruction>().m_timeoutMin = 2f;
val4.Prefab.GetComponent<CharacterTimedDestruction>().m_timeoutMax = 4f;
GameObject prefab3 = PrefabManager.Instance.GetPrefab("fx_DvergerMage_Mistile_attack");
GameObject val5 = PrefabManager.Instance.CreateClonedPrefab("staggerDeathNovaCustomPrefab", prefab3);
CustomPrefab val6 = new CustomPrefab(val5, false);
GameObject gameObject = ((Component)ExposedGameObjectExtension.FindDeepChild(val6.Prefab, "shockwave (1)", (IterativeSearchType)1)).gameObject;
ParticleSystem component3 = gameObject.GetComponent<ParticleSystem>();
MainModule main = component3.main;
((MainModule)(ref main)).startRotationX = new MinMaxCurve((float)Math.PI / 2f);
((MainModule)(ref main)).startRotationY = new MinMaxCurve(0f);
((MainModule)(ref main)).startRotationZ = new MinMaxCurve(0f);
PrefabManager.Instance.AddPrefab(val2);
PrefabManager.Instance.AddPrefab(val4);
PrefabManager.Instance.AddPrefab(val6);
leechDeathVFX = PrefabManager.Instance.GetPrefab("vfx_leech_death");
leechDeathSFX = PrefabManager.Instance.GetPrefab("sfx_leech_death");
PrefabManager.OnVanillaPrefabsAvailable -= CreateCustomPrefabs;
}
}
public static class SpawnCommands
{
[HarmonyPatch(typeof(Terminal), "InitTerminal")]
private static class Patch_Terminal_InitTerminal
{
[Serializable]
[CompilerGenerated]
private sealed class <>c
{
public static readonly <>c <>9 = new <>c();
public static ConsoleEvent <>9__1_0;
internal void <Postfix>b__1_0(ConsoleEventArgs args)
{
if (args.Length > 2)
{
string creatureName = args[1];
string modifierName = args[2];
SpawnModifier(creatureName, modifierName);
}
else
{
args.Context.AddString("Usage: modifier [creature] [modifier]");
}
}
}
[HarmonyPriority(800)]
private static void Prefix(out bool __state)
{
__state = Terminal.m_terminalInitialized;
}
private static void Postfix(bool __state)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Expected O, but got Unknown
if (__state)
{
return;
}
MonsterModifiersPlugin.MonsterModifiersLogger.LogInfo((object)"Adding Terminal Commands for monster modifier spawning.");
object obj = <>c.<>9__1_0;
if (obj == null)
{
ConsoleEvent val = delegate(ConsoleEventArgs args)
{
if (args.Length > 2)
{
string creatureName = args[1];
string modifierName = args[2];
SpawnModifier(creatureName, modifierName);
}
else
{
args.Context.AddString("Usage: modifier [creature] [modifier]");
}
};
<>c.<>9__1_0 = val;
obj = (object)val;
}
new ConsoleCommand("modifier", "[creature] [modifier]", (ConsoleEvent)obj, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
}
}
public static void SpawnModifier(string creatureName, string modifierName)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_005a: 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_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: 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_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
GameObject prefab = ZNetScene.instance.GetPrefab(creatureName);
MonsterModifierTypes result;
if ((Object)(object)prefab == (Object)null)
{
((Character)Player.m_localPlayer).Message((MessageType)1, "Missing object " + creatureName, 0, (Sprite)null);
}
else if (Enum.TryParse<MonsterModifierTypes>(modifierName, ignoreCase: true, out result))
{
Vector3 insideUnitSphere = Random.insideUnitSphere;
GameObject val = Object.Instantiate<GameObject>(prefab, ((Component)Player.m_localPlayer).transform.position + ((Component)Player.m_localPlayer).transform.forward * 2f + Vector3.up + insideUnitSphere, Quaternion.identity);
Character component = val.GetComponent<Character>();
if (component.m_nview.GetZDO().IsOwner())
{
component.SetLevel(2);
string text = string.Join(",", modifierName);
component.m_nview.GetZDO().Set("modifiers", text);
}
}
else
{
((Character)Player.m_localPlayer).Message((MessageType)1, "Invalid modifier name: " + modifierName, 0, (Sprite)null);
}
}
}
public class StatusEffectUtils
{
public static void CreateCustomStatusEffects()
{
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Expected O, but got Unknown
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Expected O, but got Unknown
BloodLoss_SE bloodLoss_SE = ScriptableObject.CreateInstance<BloodLoss_SE>();
((Object)bloodLoss_SE).name = "BloodLossStatusEffect";
((StatusEffect)bloodLoss_SE).m_name = "$se_bloodLoss";
((StatusEffect)bloodLoss_SE).m_icon = ModifierAssetUtils.bloodIconRed;
CustomStatusEffect val = new CustomStatusEffect((StatusEffect)(object)bloodLoss_SE, false);
HealDeath_SE healDeath_SE = ScriptableObject.CreateInstance<HealDeath_SE>();
((Object)healDeath_SE).name = "HealDeathStatusEffect";
((StatusEffect)healDeath_SE).m_name = "$se_healDeath";
((StatusEffect)healDeath_SE).m_ttl = 5f;
((SE_Stats)healDeath_SE).m_tickInterval = 1f;
((SE_Stats)healDeath_SE).m_healthOverTimeDuration = 5f;
((SE_Stats)healDeath_SE).m_healthOverTimeInterval = 0.5f;
((SE_Stats)healDeath_SE).m_healthOverTimeTicks = 10f;
((SE_Stats)healDeath_SE).m_healthOverTime = 0f;
CustomStatusEffect val2 = new CustomStatusEffect((StatusEffect)(object)healDeath_SE, false);
ItemManager.Instance.AddStatusEffect(val);
ItemManager.Instance.AddStatusEffect(val2);
}
}
public class TranslationUtils
{
public static CustomLocalization Localization;
public static void AddLocalizations()
{
Localization = LocalizationManager.Instance.GetLocalization();
CustomLocalization localization = Localization;
string text = "English";
localization.AddTranslation(ref text, new Dictionary<string, string>
{
{ "$se_bloodLoss", "Blood Loss" },
{ "$modifier_mistile", "Stagger Bomb" }
});
}
}
public class WorldUtils
{
public static List<Character> GetAllCharacter(Vector3 position, float range)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
Collider[] array = Physics.OverlapBox(position, Vector3.one * range, Quaternion.identity);
List<Character> list = new List<Character>();
Collider[] array2 = array;
foreach (Collider val in array2)
{
Character componentInChildren = ((Component)((Component)val).transform.root).gameObject.GetComponentInChildren<Character>();
if ((Object)(object)componentInChildren != (Object)null)
{
list.Add(componentInChildren);
}
}
return list;
}
}
public class YamlUtils
{
public static string defaultModifierValues;
public static void ParseDefaultYamls()
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Expected O, but got Unknown
defaultModifierValues = AssetUtils.LoadTextFromResources("modifierValues.yml");
IDeserializer val = ((BuilderSkeleton<DeserializerBuilder>)new DeserializerBuilder()).WithNamingConvention(CamelCaseNamingConvention.Instance).Build();
ModifierUtils.modifiers = val.Deserialize<Dictionary<MonsterModifierTypes, ModifierData>>((TextReader)new StringReader(defaultModifierValues));
}
}
[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
public static class RegisterAndCheckVersion
{
private static void Prefix(ZNetPeer peer, ref ZNet __instance)
{
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Expected O, but got Unknown
MonsterModifiersPlugin.MonsterModifiersLogger.LogDebug((object)"Registering version RPC handler");
peer.m_rpc.Register<ZPackage>("MonsterModifiers_VersionCheck", (Action<ZRpc, ZPackage>)RpcHandlers.RPC_MonsterModifiers_Version);
MonsterModifiersPlugin.MonsterModifiersLogger.LogDebug((object)"Invoking version check");
ZPackage val = new ZPackage();
val.Write("1.2.3");
peer.m_rpc.Invoke("MonsterModifiers_VersionCheck", new object[1] { val });
}
}
[HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")]
public static class VerifyClient
{
private static bool Prefix(ZRpc rpc, ZPackage pkg, ref ZNet __instance)
{
if (!__instance.IsServer() || RpcHandlers.ValidatedPeers.Contains(rpc))
{
return true;
}
MonsterModifiersPlugin.MonsterModifiersLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") never sent version or couldn't due to previous disconnect, disconnecting"));
rpc.Invoke("Error", new object[1] { 3 });
return false;
}
private static void Postfix(ZNet __instance)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Expected O, but got Unknown
ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "MonsterModifiersRequestAdminSync", new object[1] { (object)new ZPackage() });
}
}
[HarmonyPatch(typeof(FejdStartup), "ShowConnectError")]
public class ShowConnectionError
{
private static void Postfix(FejdStartup __instance)
{
if (__instance.m_connectionFailedPanel.activeSelf)
{
__instance.m_connectionFailedError.fontSizeMax = 25f;
__instance.m_connectionFailedError.fontSizeMin = 15f;
TMP_Text connectionFailedError = __instance.m_connectionFailedError;
connectionFailedError.text = connectionFailedError.text + "\n" + MonsterModifiersPlugin.ConnectionError;
}
}
}
[HarmonyPatch(typeof(ZNet), "Disconnect")]
public static class RemoveDisconnectedPeerFromVerified
{
private static void Prefix(ZNetPeer peer, ref ZNet __instance)
{
if (__instance.IsServer())
{
MonsterModifiersPlugin.MonsterModifiersLogger.LogInfo((object)("Peer (" + peer.m_rpc.m_socket.GetHostName() + ") disconnected, removing from validated list"));
RpcHandlers.ValidatedPeers.Remove(peer.m_rpc);
}
}
}
public static class RpcHandlers
{
public static readonly List<ZRpc> ValidatedPeers = new List<ZRpc>();
public static void RPC_MonsterModifiers_Version(ZRpc rpc, ZPackage pkg)
{
string text = pkg.ReadString();
MonsterModifiersPlugin.MonsterModifiersLogger.LogInfo((object)("Version check, local: 1.2.3, remote: " + text));
if (text != "1.2.3")
{
MonsterModifiersPlugin.ConnectionError = "MonsterModifiers Installed: 1.2.3\n Needed: " + text;
if (ZNet.instance.IsServer())
{
MonsterModifiersPlugin.MonsterModifiersLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") has incompatible version, disconnecting..."));
rpc.Invoke("Error", new object[1] { 3 });
}
}
else if (!ZNet.instance.IsServer())
{
MonsterModifiersPlugin.MonsterModifiersLogger.LogInfo((object)"Received same version from server!");
}
else
{
MonsterModifiersPlugin.MonsterModifiersLogger.LogInfo((object)("Adding peer (" + rpc.m_socket.GetHostName() + ") to validated list"));
ValidatedPeers.Add(rpc);
}
}
}
}
namespace MonsterModifiers.StatusEffects
{
public class BloodLoss_SE : StatusEffect
{
public int bloodLossAmount = 0;
public int bloodLossCap;
private float reductionTimer = 0f;
private bool shouldRemove = false;
public override void Setup(Character character)
{
((StatusEffect)this).Setup(character);
bloodLossCap = Mathf.FloorToInt(character.GetMaxHealth());
}
public override void UpdateStatusEffect(float dt)
{
//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_008b: Expected O, but got Unknown
//IL_00a8: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
reductionTimer += dt;
if (reductionTimer >= 60f)
{
bloodLossAmount = Mathf.Max(0, bloodLossAmount - 10);
shouldRemove = true;
reductionTimer = 0f;
}
if (bloodLossAmount > bloodLossCap)
{
bloodLossAmount = 0;
HitData val = new HitData
{
m_damage =
{
m_slash = base.m_character.GetMaxHealth() * 0.3f
}
};
base.m_character.Damage(val);
Object.Instantiate<GameObject>(PrefabUtils.leechDeathSFX, ((Component)base.m_character).transform.position, ((Component)base.m_character).transform.rotation);
Object.Instantiate<GameObject>(PrefabUtils.leechDeathVFX, ((Component)base.m_character).transform.position, ((Component)base.m_character).transform.rotation);
shouldRemove = true;
}
}
public override string GetIconText()
{
return bloodLossAmount.ToString();
}
public override void OnDamaged(HitData hit, Character attacker)
{
if (ModifierUtils.RunRPCDamageChecks(attacker, hit) && ModifierUtils.RunHitChecks(hit, isMonsterAttackingPlayer: true))
{
MonsterModifier component = ((Component)attacker).GetComponent<MonsterModifier>();
if (!((Object)(object)component == (Object)null) && component.Modifiers.Contains(MonsterModifierTypes.BloodLoss))
{
bloodLossAmount += Mathf.FloorToInt(hit.GetTotalDamage());
}
}
}
public override bool IsDone()
{
return shouldRemove || ((StatusEffect)this).IsDone();
}
}
public class HealDeath_SE : SE_Stats
{
public override void SetLevel(int itemLevel, float skillLevel)
{
base.m_healthPerTick = skillLevel / 10f;
}
}
}
namespace MonsterModifiers.Patches
{
[HarmonyPatch(typeof(EnemyHud), "ShowHud")]
public static class EnemyHud_ShowHud_Patch
{
private static void Postfix(EnemyHud __instance, Character c, bool isMount)
{
if (!(c.IsPlayer() || isMount))
{
MonsterModifier component = ((Component)c).GetComponent<MonsterModifier>();
if (!((Object)(object)component == (Object)null))
{
ChangeEnemyStars(c, component.Modifiers);
}
}
}
public static void ChangeEnemyStars(Character character, List<MonsterModifierTypes> modifiers)
{
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
if (character.GetLevel() <= 1 || character.IsBoss() || !EnemyHud.instance.m_huds.TryGetValue(character, out var value))
{
return;
}
GameObject gui = value.m_gui;
int num = 0;
int num2 = 7;
if (CompatibilityUtils.isStarLevelsExpandedInstalled && character.GetLevel() > num2)
{
num = 2;
}
for (int i = num; i < gui.transform.childCount; i++)
{
Transform child = gui.transform.GetChild(i);
if (!((Object)child).name.StartsWith("level_" + (modifiers.Count + 1)) && (!((Object)child).name.StartsWith("level_n") || !((Component)child).gameObject.activeSelf))
{
continue;
}
for (int j = 0; j < ((Component)child).transform.childCount; j++)
{
Transform child2 = ((Component)child).transform.GetChild(j);
if (((Object)child2).name.StartsWith("star") && ((Component)child2).gameObject.activeSelf)
{
((Component)child2).GetComponent<Image>().sprite = ModifierUtils.GetModifierIcon(modifiers[Mathf.Min(j, character.GetLevel() - 2)]);
((Graphic)((Component)child2).GetComponent<Image>()).color = ModifierUtils.GetModifierColor(modifiers[Mathf.Min(j, character.GetLevel() - 2)]);
((Component)child2.GetChild(0)).gameObject.SetActive(false);
}
}
}
}
}
}
namespace MonsterModifiers.Modifiers
{
public class Absorption
{
[HarmonyPatch(typeof(Character), "RPC_Damage")]
public class Absorption_Character_RPC_Damage_Patch
{
public static void Prefix(Character __instance, HitData hit)
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: 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)
//IL_0087: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_0102: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_0132: Unknown result type (might be due to invalid IL or missing references)
if (hit != null && !((Object)(object)__instance == (Object)null))
{
MonsterModifier component = ((Component)__instance).GetComponent<MonsterModifier>();
if (!((Object)(object)component == (Object)null) && component.Modifiers.Contains(MonsterModifierTypes.Absorption) && ((DamageTypes)(ref hit.m_damage)).GetTotalDamage() != 0f)
{
DamageModifiers damageModifiers = __instance.GetDamageModifiers((WeakSpot)null);
HealIfImmune(__instance, damageModifiers, (DamageType)1, hit.m_damage.m_blunt);
HealIfImmune(__instance, damageModifiers, (DamageType)2, hit.m_damage.m_slash);
HealIfImmune(__instance, damageModifiers, (DamageType)4, hit.m_damage.m_pierce);
HealIfImmune(__instance, damageModifiers, (DamageType)8, hit.m_damage.m_chop);
HealIfImmune(__instance, damageModifiers, (DamageType)16, hit.m_damage.m_pickaxe);
HealIfImmune(__instance, damageModifiers, (DamageType)32, hit.m_damage.m_fire);
HealIfImmune(__instance, damageModifiers, (DamageType)64, hit.m_damage.m_frost);
HealIfImmune(__instance, damageModifiers, (DamageType)128, hit.m_damage.m_lightning);
HealIfImmune(__instance, damageModifiers, (DamageType)256, hit.m_damage.m_poison);
HealIfImmune(__instance, damageModifiers, (DamageType)512, hit.m_damage.m_spirit);
}
}
}
public static void HealIfImmune(Character character, DamageModifiers modifiers, DamageType type, float damage)
{
//IL_0009: 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)
if (damage > 0f && IsDamageTypeImmune(modifiers, type))
{
character.Heal(damage, true);
}
}
public static bool IsDamageTypeImmune(DamageModifiers modifiers, DamageType type)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0048: Invalid comparison between Unknown and I4
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Invalid comparison between Unknown and I4
//IL_005e: Unknown result type (might be due to invalid IL or missing references)
//IL_0064: Invalid comparison between Unknown and I4
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Invalid comparison between Unknown and I4
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Invalid comparison between Unknown and I4
//IL_000e: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected I4, but got Unknown
//IL_00d2: 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_00d9: Invalid comparison between Unknown and I4
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Invalid comparison between Unknown and I4
//IL_00a2: 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_00a9: Invalid comparison between Unknown and I4
//IL_0072: 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)
//IL_0079: Invalid comparison between Unknown and I4
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Invalid comparison between Unknown and I4
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Invalid comparison between Unknown and I4
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Invalid comparison between Unknown and I4
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Invalid comparison between Unknown and I4
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: Invalid comparison between Unknown and I4
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Invalid comparison between Unknown and I4
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Invalid comparison between Unknown and I4
//IL_00c6: 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_00cd: Invalid comparison between Unknown and I4
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Invalid comparison between Unknown and I4
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_0097: Unknown result type (might be due to invalid IL or missing references)
//IL_009d: Invalid comparison between Unknown and I4
if (1 == 0)
{
}
bool result;
if ((int)type <= 32)
{
if ((int)type <= 8)
{
switch (type - 1)
{
case 0:
goto IL_0072;
case 1:
goto IL_007e;
case 3:
goto IL_008a;
case 2:
goto IL_00ea;
}
if ((int)type != 8)
{
goto IL_00ea;
}
result = (int)modifiers.m_chop == 3;
}
else if ((int)type != 16)
{
if ((int)type != 32)
{
goto IL_00ea;
}
result = (int)modifiers.m_fire == 3;
}
else
{
result = (int)modifiers.m_pickaxe == 3;
}
}
else if ((int)type <= 128)
{
if ((int)type != 64)
{
if ((int)type != 128)
{
goto IL_00ea;
}
result = (int)modifiers.m_lightning == 3;
}
else
{
result = (int)modifiers.m_frost == 3;
}
}
else if ((int)type != 256)
{
if ((int)type != 512)
{
goto IL_00ea;
}
result = (int)modifiers.m_spirit == 3;
}
else
{
result = (int)modifiers.m_poison == 3;
}
goto IL_00ee;
IL_008a:
result = (int)modifiers.m_pierce == 3;
goto IL_00ee;
IL_007e:
result = (int)modifiers.m_slash == 3;
goto IL_00ee;
IL_0072:
result = (int)modifiers.m_blunt == 3;
goto IL_00ee;
IL_00ee:
if (1 == 0)
{
}
return result;
IL_00ea:
result = false;
goto IL_00ee;
}
}
}
public class BloodLoss
{
[HarmonyPatch(typeof(Character), "RPC_Damage")]
public class RemoveMead_Character_RPC_Damage_Patch
{
public static void Postfix(Character __instance, HitData hit)
{
if (ModifierUtils.RunRPCDamageChecks(__instance, hit) && ModifierUtils.RunHitChecks(hit, isMonsterAttackingPlayer: true))
{
Character attacker = hit.GetAttacker();
MonsterModifier component = ((Component)attacker).GetComponent<MonsterModifier>();
if (!((Object)(object)component == (Object)null) && component.Modifiers.Contains(MonsterModifierTypes.BloodLoss) && !__instance.IsBlocking() && !__instance.GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BloodLossStatusEffect")))
{
__instance.GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("BloodLossStatusEffect"), false, 0, 0f);
}
}
}
}
}
public class DistantDetection
{
public static void AddDistantDetection(Character character)
{
BaseAI baseAI = character.m_baseAI;
if ((Object)(object)baseAI != (Object)null)
{
baseAI.m_hearRange *= 2f;
baseAI.m_viewRange *= 2f;
}
}
public static void RemoveDistantDetection(Character character)
{
BaseAI baseAI = character.m_baseAI;
if ((Object)(object)baseAI != (Object)null)
{
baseAI.m_hearRange /= 2f;
baseAI.m_viewRange /= 2f;
}
}
}
public class EitrSiphon
{
[HarmonyPatch(typeof(Character), "RPC_Damage")]
public class EitrSiphon_Character_RPC_Damage_Patch
{
public static void Postfix(Character __instance, HitData hit)
{
if (ModifierUtils.RunRPCDamageChecks(__instance, hit) && ModifierUtils.RunHitChecks(hit, isMonsterAttackingPlayer: true) && !__instance.IsBlocking())
{
Character attacker = hit.GetAttacker();
MonsterModifier component = ((Component)attacker).GetComponent<MonsterModifier>();
if (!((Object)(object)component == (Object)null) && component.Modifiers.Contains(MonsterModifierTypes.EitrSiphon))
{
__instance.UseEitr(hit.GetTotalDamage());
}
}
}
}
}
public class FastAttackSpeed
{
[HarmonyPatch(typeof(CharacterAnimEvent), "CustomFixedUpdate")]
public static class FastAttackSpeed_CharacterAnimEvent_CustomFixedUpdate_Patch
{
public static void Prefix(Character ___m_character, ref Animator ___m_animator)
{
if (!___m_character.InAttack() || ___m_character.IsPlayer())
{
return;
}
MonsterModifier component = ((Component)___m_character).GetComponent<MonsterModifier>();
if (!((Object)(object)component == (Object)null) && component.Modifiers.Contains(MonsterModifierTypes.FastAttackSpeed))
{
double num = (double)___m_animator.speed * 10000000.0 % 100.0;
float num2 = 0.5f;
if ((!(num < 30.0) || !(num > 10.0)) && !(___m_animator.speed <= 0.001f))
{
___m_animator.speed = ___m_animator.speed * (1f + num2) + 1.9E-06f;
}
}
}
}
[HarmonyPatch(typeof(Attack), "Start")]
public static class FastAttackSpeed_Attack_Start_Patch
{
private static void Postfix(Humanoid character, ItemData weapon, bool __result)
{
if (((Character)character).InAttack() && !((Character)character).IsPlayer())
{
MonsterModifier component = ((Component)character).GetComponent<MonsterModifier>();
if (!((Object)(object)component == (Object)null) && component.Modifiers.Contains(MonsterModifierTypes.FastAttackSpeed) && !((Character)character).IsPlayer() && __result && !((Character)character).IsBoss())
{
float num = 0.5f;
weapon.m_lastAttackTime -= weapon.m_shared.m_aiAttackInterval * Mathf.Max(0f, num);
}
}
}
}
}
public class FastMovement
{
public static void AddFastMovement(Character character)
{
character.m_speed *= 1.5f;
character.m_runSpeed *= 1.5f;
character.m_walkSpeed *= 1.5f;
}
public static void RemoveFastMovement(Character character)
{
character.m_speed /= 1.5f;
character.m_runSpeed /= 1.5f;
character.m_walkSpeed /= 1.5f;
}
}
public class FoodDrain
{
[HarmonyPatch(typeof(Character), "RPC_Damage")]
public class FoodDrain_Character_RPC_Damage_Patch
{
public static void Postfix(Character __instance, HitData hit)
{
if (!ModifierUtils.RunRPCDamageChecks(__instance, hit) || !ModifierUtils.RunHitChecks(hit, isMonsterAttackingPlayer: true) || __instance.IsBlocking())
{
return;
}
Character attacker = hit.GetAttacker();
MonsterModifier component = ((Component)attacker).GetComponent<MonsterModifier>();
if ((Object)(object)component == (Object)null || !component.Modifiers.Contains(MonsterModifierTypes.FoodDrain))
{
return;
}
Player val = (Player)(object)((__instance is Player) ? __instance : null);
if ((Object)(object)val != (Object)null)
{
List<Food> foods = val.GetFoods();
int count = foods.Count;
if (count > 0)
{
int index = Random.Range(0, count);
Food obj = foods[index];
obj.m_time *= 0.5f;
}
}
}
}
}
public class ElementalInfusions
{
[HarmonyPatch(typeof(Character), "RPC_Damage")]
public class ElementalInfusions_Character_RPC_Damage_Patch
{
public static void Prefix(Character __instance, HitData hit)
{
if (!ModifierUtils.RunRPCDamageChecks(__instance, hit) || !ModifierUtils.RunHitChecks(hit, isMonsterAttackingPlayer: true) || __instance.IsBlocking())
{
return;
}
Character attacker = hit.GetAttacker();
MonsterModifier component = ((Component)attacker).GetComponent<MonsterModifier>();
if (!((Object)(object)component == (Object)null))
{
float num = hit.GetTotalDamage() * 0.5f;
float num2 = hit.m_damage.m_chop + hit.m_damage.m_pickaxe + hit.m_damage.m_spirit;
float num3 = num - num2;
if (component.Modifiers.Contains(MonsterModifierTypes.PoisonInfused))
{
hit.m_damage.m_poison += num3;
}
if (component.Modifiers.Contains(MonsterModifierTypes.FireInfused))
{
hit.m_damage.m_fire += num3;
}
if (component.Modifiers.Contains(MonsterModifierTypes.LightningInfused))
{
hit.m_damage.m_lightning += num3;
}
if (component.Modifiers.Contains(MonsterModifierTypes.FrostInfused))
{
hit.m_damage.m_frost += num3;
}
}
}
}
}
public class Forceful
{
[HarmonyPatch(typeof(Character), "RPC_Damage")]
public class Forceful_Character_RPC_Damage_Patch
{
public static void Prefix(Character __instance, HitData hit)
{
if (ModifierUtils.RunRPCDamageChecks(__instance, hit) && ModifierUtils.RunHitChecks(hit, isMonsterAttackingPlayer: true) && !__instance.IsBlocking())
{
Character attacker = hit.GetAttacker();
MonsterModifier component = ((Component)attacker).GetComponent<MonsterModifier>();
if (!((Object)(object)component == (Object)null) && component.Modifiers.Contains(MonsterModifierTypes.Forceful))
{
hit.m_pushForce *= 5f;
}
}
}
}
}
public class IgnoreArmor
{
[HarmonyPatch(typeof(Character), "RPC_Damage")]
public class IgnoreArmor_Character_RPC_Damage_Patch
{
public static void Prefix(Character __instance, HitData hit)
{
if (ModifierUtils.RunRPCDamageChecks(__instance, hit) && ModifierUtils.RunHitChecks(hit, isMonsterAttackingPlayer: true))
{
Character attacker = hit.GetAttacker();
MonsterModifier component = ((Component)attacker).GetComponent<MonsterModifier>();
if (!((Object)(object)component == (Object)null) && component.Modifiers.Contains(MonsterModifierTypes.IgnoreArmor))
{
shouldIgnoreArmor = true;
}
}
}
}
[HarmonyPatch(typeof(Player), "GetBodyArmor")]
public class IgnoreArmor_Player_GetBodyArmor_Patch
{
public static void Postfix(ref float __result)
{
if (shouldIgnoreArmor)
{
__result *= 0.5f;
shouldIgnoreArmor = false;
}
}
}
public static bool shouldIgnoreArmor;
}
public class Quiet
{
public static void AddQuiet(Character character)
{
BaseAI baseAI = character.m_baseAI;
if (!((Object)(object)baseAI != (Object)null))
{
return;
}
if (baseAI.m_alertedEffects.HasEffects())
{
EffectData[] effectPrefabs = baseAI.m_alertedEffects.m_effectPrefabs;
foreach (EffectData val in effectPrefabs)
{
val.m_enabled = false;
}
}
if (baseAI.m_idleSound.HasEffects())
{
EffectData[] effectPrefabs2 = baseAI.m_idleSound.m_effectPrefabs;
foreach (EffectData val2 in effectPrefabs2)
{
val2.m_enabled = false;
}
}
}
}
public class StaggerDeath
{
[HarmonyPatch(typeof(Character), "OnDeath")]
public class StaggerDeath_Character_OnDeath_Patch
{
public static void Prefix(Character __instance)
{
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Unknown result type (might be due to invalid IL or missing references)
//IL_008d: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: 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_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance == (Object)null || __instance.IsPlayer() || (Object)(object)__instance.m_nview == (Object)null || !(((Object)((Component)__instance).gameObject).name == "mistleCustomPrefab(Clone)"))
{
return;
}
Vector3 position = ((Component)__instance).transform.position;
GameObject prefab = PrefabManager.Instance.GetPrefab("staggerDeathNovaCustomPrefab");
if (!((Object)(object)prefab != (Object)null))
{
return;
}
Object.Instantiate<GameObject>(prefab, new Vector3(((Component)__instance).transform.position.x, ((Component)__instance).transform.position.y - 1f, ((Component)__instance).transform.position.z), ((Component)__instance).transform.rotation);
List<Character> allCharacter = WorldUtils.GetAllCharacter(((Component)__instance).transform.position, 5f);
foreach (Character item in allCharacter)
{
if (!((Object)(object)item == (Object)(object)__instance) && !((Object)(object)item == (Object)null) && !((Object)(object)item.m_nview == (Object)null) && !item.IsPlayer())
{
item.Stagger(position);
}
}
List<Player> list = new List<Player>();
Player.GetPlayersInRange(((Component)__instance).transform.position, 5f, list);
foreach (Player item2 in list)
{
if (!((Object)(object)item2 == (Object)null) && !((Object)(object)((Character)item2).m_nview == (Object)null))
{
((Character)item2).Stagger(position);
}
}
}
}
}
public class StaggerImmune
{
[HarmonyPatch(typeof(Character), "Stagger")]
public class StaminaSiphon_Character_RPC_Damage_Patch
{
public static bool Prefix(Character __instance)
{
if ((Object)(object)__instance == (Object)null)
{
return true;
}
MonsterModifier component = ((Component)__instance).GetComponent<MonsterModifier>();
if ((Object)(object)component == (Object)null)
{
return true;
}
if (component.Modifiers.Contains(MonsterModifierTypes.StaggerImmune))
{
return false;
}
return true;
}
}
public static void AddStaggerImmune(Character character)
{
character.m_staggerWhenBlocked = false;
}
public static void RemoveStaggerImmune(Character character)
{
character.m_staggerWhenBlocked = true;
}
}
public class DamageModifiers
{
[HarmonyPatch(typeof(Character), "RPC_Damage")]
public class ModiferDamageModifiers_Character_RPC_Damage_Patch
{
public static void Prefix(Character __instance, HitData hit)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: 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)
//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
if (hit == null || (Object)(object)__instance == (Object)null || ((DamageTypes)(ref hit.m_damage)).GetTotalDamage() == 0f)
{
return;
}
MonsterModifier component = ((Component)__instance).GetComponent<MonsterModifier>();
if (!((Object)(object)component == (Object)null))
{
if (component.Modifiers.Contains(MonsterModifierTypes.PierceImmunity))
{
__instance.m_damageModifiers.m_pierce = (DamageModifier)3;
}
if (component.Modifiers.Contains(MonsterModifierTypes.SlashImmunity))
{
__instance.m_damageModifiers.m_slash = (DamageModifier)3;
}
if (component.Modifiers.Contains(MonsterModifierTypes.BluntImmunity))
{
__instance.m_damageModifiers.m_blunt = (DamageModifier)3;
}
if (component.Modifiers.Contains(MonsterModifierTypes.ElementalImmunity))
{
__instance.m_damageModifiers.m_fire = (DamageModifier)3;
__instance.m_damageModifiers.m_frost = (DamageModifier)3;
__instance.m_damageModifiers.m_lightning = (DamageModifier)3;
__instance.m_damageModifiers.m_poison = (DamageModifier)3;
__instance.m_damageModifiers.m_spirit = (DamageModifier)3;
}
}
}
}
}
public class RemoveStatusEffect
{
[HarmonyPatch(typeof(Character), "RPC_Damage")]
public class RemoveMead_Character_RPC_Damage_Patch
{
public static void Postfix(Character __instance, HitData hit)
{
if (!ModifierUtils.RunRPCDamageChecks(__instance, hit) || !ModifierUtils.RunHitChecks(hit, isMonsterAttackingPlayer: true) || __instance.IsBlocking())
{
return;
}
Character attacker = hit.GetAttacker();
MonsterModifier component = ((Component)attacker).GetComponent<MonsterModifier>();
if (!((Object)(object)component == (Object)null) && component.Modifiers.Contains(MonsterModifierTypes.RemoveStatusEffect))
{
List<StatusEffect> statusEffects = __instance.GetSEMan().GetStatusEffects();
if (statusEffects.Count > 1)
{
int index = Random.Range(0, statusEffects.Count);
__instance.GetSEMan().RemoveStatusEffect(statusEffects[index], false);
}
}
}
}
}
public class ShieldBreaker
{
[HarmonyPatch(typeof(Humanoid), "BlockAttack")]
public class ShieldBreaker_Humanoid_BlockAttack_Patch
{
public static void Postfix(Humanoid __instance, HitData hit, Character attacker)
{
if (hit == null || (Object)(object)__instance == (Object)null || (Object)(object)attacker == (Object)null || attacker.IsPlayer())
{
return;
}
MonsterModifier component = ((Component)attacker).GetComponent<MonsterModifier>();
if (!((Object)(object)component == (Object)null) && component.Modifiers.Contains(MonsterModifierTypes.ShieldBreaker))
{
ItemData currentBlocker = __instance.GetCurrentBlocker();
if (currentBlocker != null && (double)currentBlocker.m_durability > (double)currentBlocker.GetMaxDurability() * 0.1)
{
currentBlocker.m_durability *= 0.5f;
}
}
}
}
}
public class ShieldDome : MonoBehaviour
{
public static CustomPrefab ShieldGenereatorBubbleCustomPrefab;
public static EffectData shieldDomeBubbleSFX;
public GameObject shieldGenereatorBubble;
public Character m_character;
public ShieldGenerator m_shieldGenerator;
public ShieldDomeImageEffect m_shieldDomeImageEffect;
public ZNetView m_nview;
public static void LoadShieldDome()
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Expected O, but got Unknown
ShieldGenereatorBubbleCustomPrefab = new CustomPrefab(ModifierAssetUtils.ashlandsAssetBundle, "ShieldDome_Bubble", true);
PrefabManager.Instance.AddPrefab(ShieldGenereatorBubbleCustomPrefab);
}
public void AddShieldDome(Character character)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
((Component)character).gameObject.AddComponent<ShieldDome>();
shieldGenereatorBubble = Object.Instantiate<GameObject>(ShieldGenereatorBubbleCustomPrefab.Prefab, ((Component)character).transform.position, ((Component)character).transform.rotation);
m_character = character;
m_shieldGenerator = shieldGenereatorBubble.GetComponent<ShieldGenerator>();
m_nview = shieldGenereatorBubble.GetComponent<ZNetView>();
m_shieldGenerator.m_nview = m_nview;
m_shieldGenerator.m_defaultFuel = 999;
m_shieldGenerator.m_radius = 10f;
m_shieldGenerator.m_maxShieldRadius = 10f;
m_shieldGenerator.m_minShieldRadius = 10f;
m_shieldDomeImageEffect = Object.FindFirstObjectByType<ShieldDomeImageEffect>();
if ((Object)(object)m_nview != (Object)null)
{
m_nview.Register("RPC_DestroyShieldDome", (Action<long>)RPC_DestroyShieldDome);
}
}
public void Update()
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)m_character != (Object)null && (Object)(object)shieldGenereatorBubble != (Object)null)
{
m_shieldGenerator.m_shieldDome.transform.position = ((Component)m_character).transform.position;
m_shieldGenerator.m_shieldDome.transform.rotation = ((Component)m_character).transform.rotation;
m_shieldDomeImageEffect.SetShieldData(m_shieldGenerator, ((Component)m_character).transform.position, 10f, m_shieldGenerator.m_lastFuel, m_shieldGenerator.m_lastHitTime);
}
}
public void OnDestroy()
{
if ((Object)(object)m_nview != (Object)null && m_nview.IsValid() && m_nview.IsOwner())
{
m_nview.InvokeRPC(ZNetView.Everybody, "RPC_DestroyShieldDome", Array.Empty<object>());
}
}
private void RPC_DestroyShieldDome(long sender)
{
DestroyShieldDome();
}
private void DestroyShieldDome()
{
if ((Object)(object)m_shieldGenerator != (Object)null)
{
m_shieldDomeImageEffect.RemoveShield(m_shieldGenerator);
}
if ((Object)(object)shieldGenereatorBubble != (Object)null)
{
ZNetScene.instance.Destroy(shieldGenereatorBubble);
}
if ((Object)(object)m_shieldGenerator.m_shieldDome != (Object)null)
{
ZNetScene.instance.Destroy(m_shieldGenerator.m_shieldDome);
}
}
}
public class PersonalShield
{
public static void AddPersonalShield(Character character)
{
int stableHashCode = StringExtensionMethods.GetStableHashCode("GoblinShaman_shield");
character.GetSEMan().AddStatusEffect(stableHashCode, true, 10, 2f);
}
public static void RemovePersonalShield(Character character)
{
int stableHashCode = StringExtensionMethods.GetStableHashCode("GoblinShaman_shield");
character.GetSEMan().RemoveStatusEffect(stableHashCode, false);
}
}
public class DeathSpawns
{
[HarmonyPatch(typeof(Character), "OnDeath")]
public class DeathSpawns_Character_OnDeath_Patch
{
public static void Prefix(Character __instance)
{
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: 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_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Expected O, but got Unknown
//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_0332: Unknown result type (might be due to invalid IL or missing references)
//IL_0342: Unknown result type (might be due to invalid IL or missing references)
//IL_0358: 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)
//IL_036d: 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_0179: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: Unknown result type (might be due to invalid IL or missing references)
//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Expected O, but got Unknown
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0401: Unknown result type (might be due to invalid IL or missing references)
//IL_0287: Unknown result type (might be due to invalid IL or missing references)
//IL_0297: Unknown result type (might be due to invalid IL or missing references)
//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
//IL_02e1: Expected O, but got Unknown
//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
//IL_0593: Unknown result type (might be due to invalid IL or missing references)
//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
//IL_05ce: Unknown result type (might be due to invalid IL or missing references)
//IL_0427: Unknown result type (might be due to invalid IL or missing references)
//IL_05f4: Unknown result type (might be due to invalid IL or missing references)
//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
//IL_06a1: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)__instance == (Object)null || __instance.IsPlayer())
{
return;
}
MonsterModifier component = ((Component)__instance).GetComponent<MonsterModifier>();
if ((Object)(object)component == (Object)null)
{
return;
}
if (component.Modifiers.Contains(MonsterModifierTypes.PoisonDeath))
{
float poison = DamageUtils.CalculateDamage(__instance, 0.5f);
GameObject prefab = ZNetScene.instance.GetPrefab("blob_aoe");
if ((Object)(object)prefab != (Object)null)
{
Object.Instantiate<GameObject>(prefab, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
HitData hit = new HitData
{
m_damage =
{
m_poison = poison
}
};
ApplyDamageToNearbyPlayers(((Component)__instance).transform.position, hit);
}
}
if (component.Modifiers.Contains(MonsterModifierTypes.FireDeath))
{
float fire = DamageUtils.CalculateDamage(__instance, 0.5f);
GameObject prefab2 = ZNetScene.instance.GetPrefab("fx_fireskeleton_nova");
ParticleSystem[] componentsInChildren = prefab2.GetComponentsInChildren<ParticleSystem>();
ParticleSystem[] array = componentsInChildren;
foreach (ParticleSystem val in array)
{
val.startDelay = 0f;
}
ZSFX componentInChildren = prefab2.GetComponentInChildren<ZSFX>();
componentInChildren.m_delay = 0f;
componentInChildren.m_minDelay = 0f;
componentInChildren.m_maxDelay = 0f;
if ((Object)(object)prefab2 != (Object)null)
{
Object.Instantiate<GameObject>(prefab2, new Vector3(((Component)__instance).transform.position.x, ((Component)__instance).transform.position.y + 1.25f, ((Component)__instance).transform.position.z), ((Component)__instance).transform.rotation);
HitData hit2 = new HitData
{
m_damage =
{
m_fire = fire
}
};
ApplyDamageToNearbyPlayers(((Component)__instance).transform.position, hit2);
}
}
if (component.Modifiers.Contains(MonsterModifierTypes.FrostDeath))
{
float frost = DamageUtils.CalculateDamage(__instance, 0.5f);
GameObject prefab3 = ZNetScene.instance.GetPrefab("fx_DvergerMage_Nova_ring");
ParticleSystem[] componentsInChildren2 = prefab3.GetComponentsInChildren<ParticleSystem>();
ParticleSystem[] array2 = componentsInChildren2;
foreach (ParticleSystem val2 in array2)
{
val2.startDelay = 0f;
}
ZSFX componentInChildren2 = prefab3.GetComponentInChildren<ZSFX>();
componentInChildren2.m_delay = 0f;
componentInChildren2.m_minDelay = 0f;
componentInChildren2.m_maxDelay = 0f;
if ((Object)(object)prefab3 != (Object)null)
{
Object.Instantiate<GameObject>(prefab3, new Vector3(((Component)__instance).transform.position.x, ((Component)__instance).transform.position.y + 1f, ((Component)__instance).transform.position.z), ((Component)__instance).transform.rotation);
HitData hit3 = new HitData
{
m_damage =
{
m_frost = frost
}
};
ApplyDamageToNearbyPlayers(((Component)__instance).transform.position, hit3);
}
}
if (component.Modifiers.Contains(MonsterModifierTypes.StaggerDeath))
{
GameObject prefab4 = PrefabManager.Instance.GetPrefab("mistleCustomPrefab");
if ((Object)(object)prefab4 != (Object)null)
{
Object.Instantiate<GameObject>(prefab4, new Vector3(((Component)__instance).transform.position.x, ((Component)__instance).transform.position.y + 1f, ((Component)__instance).transform.position.z), ((Component)__instance).transform.rotation);
}
}
if (component.Modifiers.Contains(MonsterModifierTypes.HealDeath))
{
GameObject prefab5 = PrefabManager.Instance.GetPrefab("healCustomPrefab");
float num = __instance.GetMaxHealth() * 0.75f;
if ((Object)(object)prefab5 != (Object)null)
{
Object.Instantiate<GameObject>(prefab5, new Vector3(((Component)__instance).transform.position.x, ((Component)__instance).transform.position.y + 1f, ((Component)__instance).transform.position.z), ((Component)__instance).transform.rotation);
}
if (((Character)Player.m_localPlayer).IsOwner())
{
List<Character> allCharacter = WorldUtils.GetAllCharacter(((Component)__instance).transform.position, 15f);
foreach (Character item in allCharacter)
{
if (!((Object)(object)item == (Object)(object)__instance) && !((Object)(object)item == (Object)null) && !((Object)(object)item.m_nview == (Object)null) && !item.IsPlayer())
{
item.GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("HealDeathStatusEffect"), false, 0, num);
}
}
List<Player> list = new List<Player>();
Player.GetPlayersInRange(((Component)__instance).transform.position, 15f, list);
foreach (Player item2 in list)
{
if (!((Object)(object)item2 == (Object)null) && !((Object)(object)((Character)item2).m_nview == (Object)null))
{
((Character)item2).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("HealDeathStatusEffect"), true, 0, num);
}
}
}
}
if (!component.Modifiers.Contains(MonsterModifierTypes.TarDeath))
{
return;
}
GameObject prefab6 = ZNetScene.instance.GetPrefab("blobtar_projectile_tarball");
if ((Object)(object)prefab6 != (Object)null)
{
Object.Instantiate<GameObject>(prefab6, new Vector3(((Component)__instance).transform.position.x, ((Component)__instance).transform.position.y + 1f, ((Component)__instance).transform.position.z), ((Component)__instance).transform.rotation);
}
if (!((Character)Player.m_localPlayer).IsOwner())
{
return;
}
List<Character> allCharacter2 = WorldUtils.GetAllCharacter(((Component)__instance).transform.position, 5f);
foreach (Character item3 in allCharacter2)
{
if (!((Object)(object)item3 == (Object)(object)__instance) && !((Object)(object)item3 == (Object)null) && !((Object)(object)item3.m_nview == (Object)null) && !item3.IsPlayer())
{
item3.GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("Tared"), false, 0, 0f);
}
}
List<Player> list2 = new List<Player>();
Player.GetPlayersInRange(((Component)__instance).transform.position, 5f, list2);
foreach (Player item4 in list2)
{
if (!((Object)(object)item4 == (Object)null) && !((Object)(object)((Character)item4).m_nview == (Object)null))
{
((Character)item4).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("Tared"), false, 0, 0f);
}
}
}
}
public static void ApplyDamageToNearbyPlayers(Vector3 position, HitData hit)
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
List<Player> list = new List<Player>();
Player.GetPlayersInRange(position, 5f, list);
foreach (Player item in list)
{
((Character)item).Damage(hit);
}
}
}
public class SoulEater : MonoBehaviour
{
[HarmonyPatch(typeof(Character), "OnDeath")]
public class SoulEater_Character_OnDeath_Patch
{
public static void Prefix(Character __instance)
{
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
MonsterModifier monsterModifier = default(MonsterModifier);
if ((Object)(object)__instance == (Object)null || __instance.IsPlayer() || (((Component)__instance).TryGetComponent<MonsterModifier>(ref monsterModifier) && monsterModifier.Modifiers.Contains(MonsterModifierTypes.SoulEater)))
{
return;
}
List<Character> allCharacter = WorldUtils.GetAllCharacter(((Component)__instance).transform.position, 5f);
foreach (Character item in allCharacter)
{
if (!((Object)(object)item == (Object)null) && !((Object)(object)item.m_nview == (Object)null) && item.m_nview.GetZDO() != null && item.m_nview.GetZDO().IsOwner())
{
MonsterModifier component = ((Component)item).GetComponent<MonsterModifier>();
if ((Object)(object)component != (Object)null && component.Modifiers.Contains(MonsterModifierTypes.SoulEater) && item.m_nview.GetZDO().GetInt("MM_soulEaterCount", 0) < 3)
{
int num = item.m_nview.GetZDO().GetInt("MM_soulEaterCount", 0) + 1;
item.m_nview.GetZDO().Set("MM_soulEaterCount", num);
Transform transform = ((Component)item).transform;
transform.localScale *= 1.1f;
Physics.SyncTransforms();
item.m_health *= 1.1f;
}
}
}
}
}
[HarmonyPatch(typeof(Character), "RPC_Damage")]
public class SoulEater_Character_RPC_Damage_Patch
{
public static void Prefix(Character __instance, HitData hit)
{
if (!ModifierUtils.RunRPCDamageChecks(__instance, hit) || !ModifierUtils.RunHitChecks(hit, isMonsterAttackingPlayer: true))
{
return;
}
Character attacker = hit.GetAttacker();
MonsterModifier component = ((Component)attacker).GetComponent<MonsterModifier>();
if (!((Object)(object)component == (Object)null) && component.Modifiers.Contains(MonsterModifierTypes.SoulEater) && attacker.m_nview.GetZDO().GetInt("MM_soulEaterCount", 0) > 0)
{
int @int = attacker.m_nview.GetZDO().GetInt("MM_soulEaterCount", 0);
float totalDamage = hit.GetTotalDamage();
float num = totalDamage;
switch (@int)
{
case 1:
hit.ApplyModifier(1.1f);
num = totalDamage * 1.1f;
break;
case 2:
hit.ApplyModifier(1.2f);
num = totalDamage * 1.2f;
break;
case 3:
hit.ApplyModifier(1.3f);
num = totalDamage * 1.3f;
break;
default:
hit.ApplyModifier(1f);
num = totalDamage * 1f;
break;
}
}
}
}
}
public class StaminaSiphon
{
[HarmonyPatch(typeof(Character), "RPC_Damage")]
public class StaminaSiphon_Character_RPC_Damage_Patch
{
public static void Postfix(Character __instance, HitData hit)
{
if (ModifierUtils.RunRPCDamageChecks(__instance, hit) && ModifierUtils.RunHitChecks(hit, isMonsterAttackingPlayer: true))
{
Character attacker = hit.GetAttacker();
MonsterModifier component = ((Component)attacker).GetComponent<MonsterModifier>();
if (!((Object)(object)component == (Object)null) && component.Modifiers.Contains(MonsterModifierTypes.StaminaSiphon) && !__instance.IsBlocking())
{
__instance.UseStamina(hit.GetTotalDamage());
}
}
}
}
}
public class Vampiric
{
[HarmonyPatch(typeof(Character), "RPC_Damage")]
public class Vampiric_Character_RPC_Damage_Patch
{
public static void Prefix(Character __instance, HitData hit)
{
if (!ModifierUtils.RunRPCDamageChecks(__instance, hit) || !ModifierUtils.RunHitChecks(hit, isMonsterAttackingPlayer: true) || __instance.IsBlocking())
{
return;
}
Character attacker = hit.GetAttacker();
MonsterModifier component = ((Component)attacker).GetComponent<MonsterModifier>();
if (!((Object)(object)component == (Object)null))
{
float num = hit.GetTotalDamage() * 0.5f;
float num2 = hit.m_damage.m_chop + hit.m_damage.m_pickaxe + hit.m_damage.m_spirit;
float num3 = num - num2;
if (component.Modifiers.Contains(MonsterModifierTypes.Vampiric))
{
attacker.Heal(num3, true);
}
}
}
}
}
public class Wet
{
[HarmonyPatch(typeof(Character), "RPC_Damage")]
public class Wet_Character_RPC_Damage_Patch
{
public static void Postfix(Character __instance, HitData hit)
{
if (ModifierUtils.RunRPCDamageChecks(__instance, hit) && ModifierUtils.RunHitChecks(hit, isMonsterAttackingPlayer: true) && !__instance.IsBlocking())
{
Character attacker = hit.GetAttacker();
MonsterModifier component = ((Component)attacker).GetComponent<MonsterModifier>();
if (!((Object)(object)component == (Object)null) && component.Modifiers.Contains(MonsterModifierTypes.Wet))
{
__instance.GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("Wet"), false, 0, 0f);
}
}
}
}
}
}
namespace MonsterModifiers.Custom_Components
{
public class MonsterModifier : MonoBehaviour
{
public List<MonsterModifierTypes> Modifiers = new List<MonsterModifierTypes>();
public Character character;
public int level;
private void Start()
{
character = ((Component)this).GetComponent<Character>();
level = character.GetLevel();
if ((Object)(object)character.m_nview != (Object)null && character.m_nview.GetZDO().GetString("BountyID", "") != string.Empty)
{
Object.Destroy((Object)(object)this);
}
else
{
if (level <= 1)
{
return;
}
string @string = character.m_nview.GetZDO().GetString("modifiers", string.Empty);
if (string.IsNullOrEmpty(@string))
{
int numModifiers = Mathf.Min(level - 1, MonsterModifiersPlugin.Configurations_MaxModifiers.Value);
foreach (MonsterModifierTypes item in ModifierUtils.RollRandomModifiers(numModifiers))
{
Modifiers.Add(item);
}
if (character.m_nview.GetZDO().IsOwner())
{
string text = string.Join(",", Modifiers);
character.m_nview.GetZDO().Set("modifiers", text);
}
}
else
{
Modifiers = new List<MonsterModifierTypes>(Array.ConvertAll(@string.Split(new char[1] { ',' }), (string str) => (MonsterModifierTypes)Enum.Parse(typeof(MonsterModifierTypes), str)));
}
ApplyStartModifiers();
}
}
public void ChangeModifiers(List<MonsterModifierTypes> modifierTypesList, int numModifiers)
{
if (level <= 1)
{
return;
}
foreach (MonsterModifierTypes modifierTypes in modifierTypesList)
{
Modifiers.Add(modifierTypes);
Debug.Log((object)("Monster with name " + ((Object)character).name + " has has changed modifiers. New modifier: " + modifierTypes));
}
if (character.m_nview.GetZDO().IsOwner())
{
string text = string.Join(",", Modifiers);
character.m_nview.GetZDO().Set("modifiers", text);
}
}
public void ApplyStartModifiers()
{
if (Modifiers.Contains(MonsterModifierTypes.PersonalShield))
{
PersonalShield.AddPersonalShield(character);
}
if (Modifiers.Contains(MonsterModifierTypes.ShieldDome))
{
ShieldDome shieldDome = ((Component)character).gameObject.AddComponent<ShieldDome>();
shieldDome.AddShieldDome(character);
}
if (Modifiers.Contains(MonsterModifierTypes.StaggerImmune))
{
StaggerImmune.AddStaggerImmune(character);
}
if (Modifiers.Contains(MonsterModifierTypes.FastMovement))
{
FastMovement.AddFastMovement(character);
}
if (Modifiers.Contains(MonsterModifierTypes.DistantDetection))
{
DistantDetection.AddDistantDetection(character);
}
if (Modifiers.Contains(MonsterModifierTypes.Quiet))
{
Quiet.AddQuiet(character);
}
}
}
public class AddMonsterModifiersToCharacter
{
[HarmonyPriority(800)]
[HarmonyPatch(typeof(Character), "Awake")]
public static class Character_Awake_Patch
{
private static void Postfix(Character __instance)
{
if (!__instance.IsPlayer() && !__instance.IsBoss())
{
((Component)__instance).gameObject.AddComponent<MonsterModifier>();
}
}
}
}
}
namespace LocalizationManager
{
[PublicAPI]
public class Localizer
{
private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors;
private static readonly Dictionary<string, Dictionary<string, string>> loadedTexts;
private static readonly ConditionalWeakTable<Localization, string> localizationLanguage;
private static readonly List<WeakReference<Localization>> localizationObjects;
private static BaseUnityPlugin? _plugin;
private static readonly List<string> fileExtensions;
private static BaseUnityPlugin plugin
{
get
{
//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Expected O, but got Unknown
if (_plugin == null)
{
IEnumerable<TypeInfo> source;
try
{
source = Assembly.GetExecutingAssembly().DefinedTypes.ToList();
}
catch (ReflectionTypeLoadException ex)
{
source = from t in ex.Types
where t != null
select t.GetTypeInfo();
}
_plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First((TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
}
return _plugin;
}
}
private static void UpdatePlaceholderText(Localization localization, string key)
{
localizationLanguage.TryGetValue(localization, out string value);
string text = loadedTexts[value][key];
if (PlaceholderProcessors.TryGetValue(key, out Dictionary<string, Func<string>> value2))
{
text = value2.Aggregate(text, (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value()));
}
localization.AddWord(key, text);
}
public static void AddPlaceholder<T>(string key, string placeholder, ConfigEntry<T> config, Func<T, string>? convertConfigValue = null) where T : notnull
{
string key2 = key;
string placeholder2 = placeholder;
Func<T, string> convertConfigValue2 = convertConfigValue;
ConfigEntry<T> config2 = config;
if (convertConfigValue2 == null)
{
convertConfigValue2 = (T val) => val.ToString();
}
if (!PlaceholderProcessors.ContainsKey(key2))
{
PlaceholderProcessors[key2] = new Dictionary<string, Func<string>>();
}
config2.SettingChanged += delegate
{
UpdatePlaceholder();
};
if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage()))
{
UpdatePlaceholder();
}
void UpdatePlaceholder()
{
PlaceholderProcessors[key2][placeholder2] = () => convertConfigValue2(config2.Value);
UpdatePlaceholderText(Localization.instance, key2);
}
}
public static void AddText(string key, string text)
{
List<WeakReference<Localization>> list = new List<WeakReference<Localization>>();
foreach (WeakReference<Localization> localizationObject in localizationObjects)
{
if (localizationObject.TryGetTarget(out var target))
{
Dictionary<string, string> dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)];
if (!target.m_translations.ContainsKey(key))
{
dictionary[key] = text;
target.AddWord(key, text);
}
}
else
{
list.Add(localizationObject);
}
}
foreach (WeakReference<Localization> item in list)
{
localizationObjects.Remove(item);
}
}
public static void Load()
{
LoadLocalization(Localization.instance, Localization.instance.GetSelectedLanguage());
}
private static void LoadLocalization(Localization __instance, string language)
{
//IL_018e: Unknown result type (might be due to invalid IL or missing references)
//IL_0198: Expected O, but got Unknown
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_0277: Expected O, but got Unknown
if (!localizationLanguage.Remove(__instance))
{
localizationObjects.Add(new WeakReference<Localization>(__instance));
}
localizationLanguage.Add(__instance, language);
Dictionary<string, string> dictionary = new Dictionary<string, string>();
foreach (string item in from f in Directory.GetFiles(Path.GetDirectoryName(Paths.PluginPath), plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories)
where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0
select f)
{
string text = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' })[1];
if (dictionary.ContainsKey(text))
{
Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped."));
}
else
{
dictionary[text] = item;
}
}
byte[] array = LoadTranslationFromAssembly("English");
if (array == null)
{
throw new Exception("Found no English localizations in mod " + plugin.Info.Metadata.Name + ". Expected an embedded resource translations/English.json or translations/English.yml.");
}
Dictionary<string, string> dictionary2 = ((BuilderSkeleton<DeserializerBuilder>)new DeserializerBuilder()).IgnoreFields().Build().Deserialize<Dictionary<string, string>>(Encoding.UTF8.GetString(array));
if (dictionary2 == null)
{
throw new Exception("Localization for mod " + plugin.Info.Metadata.Name + " failed: Localization file was empty.");
}
string text2 = null;
if (language != "English")
{
if (dictionary.ContainsKey(language))
{
text2 = File.ReadAllText(dictionary[language]);
}
else
{
byte[] array2 = LoadTranslationFromAssembly(language);
if (array2 != null)
{
text2 = Encoding.UTF8.GetString(array2);
}
}
}
if (text2 == null && dictionary.ContainsKey("English"))
{
text2 = File.ReadAllText(dictionary["English"]);
}
if (text2 != null)
{
foreach (KeyValuePair<string, string> item2 in ((BuilderSkeleton<DeserializerBuilder>)new DeserializerBuilder()).IgnoreFields().Build().Deserialize<Dictionary<string, string>>(text2) ?? new Dictionary<string, string>())
{
dictionary2[item2.Key] = item2.Value;
}
}
loadedTexts[language] = dictionary2;
foreach (KeyValuePair<string, string> item3 in dictionary2)
{
UpdatePlaceholderText(__instance, item3.Key);
}
}
static Localizer()
{
//IL_0050: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: Expected O, but got Unknown
PlaceholderProcessors = new Dictionary<string, Dictionary<string, Func<string>>>();
loadedTexts = new Dictionary<string, Dictionary<string, string>>();
localizationLanguage = new ConditionalWeakTable<Localization, string>();
localizationObjects = new List<WeakReference<Localization>>();
fileExtensions = new List<string> { ".json", ".yml" };
Harmony val = new Harmony("org.bepinex.helpers.LocalizationManager");
val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
}
private static byte[]? LoadTranslationFromAssembly(string language)
{
foreach (string fileExtension in fileExtensions)
{
byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension);
if (array != null)
{
return array;
}
}
return null;
}
public static byte[]? ReadEmbeddedFileBytes(string resourceFileName, Assembly? containingAssembly = null)
{
string resourceFileName2 = resourceFileName;
using MemoryStream memoryStream = new MemoryStream();
if ((object)containingAssembly == null)
{
containingAssembly = Assembly.GetCallingAssembly();
}
string text = containingAssembly.GetManifestResourceNames().FirstOrDefault((string str) => str.EndsWith(resourceFileName2, StringComparison.Ordinal));
if (text != null)
{
containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream);
}
return (memoryStream.Length == 0L) ? null : memoryStream.ToArray();
}
}
}