Decompiled source of CajadoDeOdin v1.3.0

CajadoDeOdin.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;
using UnityEngine.Audio;

[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace CajadoDeOdin;

public enum SoundTrigger
{
	Golpe,
	Acerto
}
internal enum Kind
{
	Cajado,
	MeiaBomba,
	Escudo
}
internal class ModelSettings
{
	public ConfigEntry<float> PosX;

	public ConfigEntry<float> PosY;

	public ConfigEntry<float> PosZ;

	public ConfigEntry<float> RotX;

	public ConfigEntry<float> RotY;

	public ConfigEntry<float> RotZ;

	public ConfigEntry<float> Scale;

	public static ModelSettings Bind(ConfigFile config, string section)
	{
		ModelSettings modelSettings = new ModelSettings();
		modelSettings.PosX = config.Bind<float>(section, "Posição X", 0f, "Ajuste fino da posição na mão (metros).");
		modelSettings.PosY = config.Bind<float>(section, "Posição Y", 0f, "Ajuste fino da posição na mão (metros).");
		modelSettings.PosZ = config.Bind<float>(section, "Posição Z", 0f, "Ajuste fino da posição na mão (metros).");
		modelSettings.RotX = config.Bind<float>(section, "Rotação X", 0f, "Rotação do modelo em graus.");
		modelSettings.RotY = config.Bind<float>(section, "Rotação Y", 0f, "Rotação do modelo em graus.");
		modelSettings.RotZ = config.Bind<float>(section, "Rotação Z", 0f, "Rotação do modelo em graus.");
		modelSettings.Scale = config.Bind<float>(section, "Escala", 1f, "Tamanho do modelo (1 = tamanho original).");
		return modelSettings;
	}
}
[BepInPlugin("skiter.cajadodeodin", "Cajado de Odin", "1.3.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[SynchronizationMode(/*Could not decode attribute arguments.*/)]
public class OdinPlugin : BaseUnityPlugin
{
	public const string PluginGuid = "skiter.cajadodeodin";

	public const string PluginName = "Cajado de Odin";

	public const string PluginVersion = "1.3.0";

	internal const string CajadoPrefab = "CajadoDeOdin";

	internal const string MeiaBombaPrefab = "CajadoMeiaBombaDeOdin";

	internal const string EscudoPrefab = "SacoDeOdin";

	private const string RpcHitSound = "CajadoDeOdin_Sound";

	private const string RpcParrySound = "CajadoDeOdin_Parry";

	private const string RpcHearts = "CajadoDeOdin_Hearts";

	internal const float StaffHeight = 0.567f;

	internal static ManualLogSource Log;

	internal static ConfigEntry<string> CajadoName;

	internal static ConfigEntry<string> MeiaBombaName;

	internal static ConfigEntry<string> EscudoName;

	internal static ConfigEntry<float> CajadoDamage;

	internal static ConfigEntry<float> CajadoPerLevel;

	internal static ConfigEntry<float> MeiaBombaDamage;

	internal static ConfigEntry<float> MeiaBombaPerLevel;

	internal static ConfigEntry<int> MaxQuality;

	internal static ConfigEntry<SoundTrigger> PlaySoundOn;

	internal static ConfigEntry<float> Volume;

	internal static ConfigEntry<float> SoundRange;

	internal static ConfigEntry<bool> Hearts;

	internal static ConfigEntry<bool> ParrySound;

	internal static ConfigEntry<string> ColorHex;

	internal static ConfigEntry<float> Stiffness;

	internal static ConfigEntry<float> Wobble;

	internal static ConfigEntry<float> Droop;

	internal static readonly Dictionary<string, ModelSettings> Models = new Dictionary<string, ModelSettings>();

	private static AudioClip _hitClip;

	private static AudioClip _parryClip;

	private static AudioMixerGroup _mixer;

	private static Mesh _staffMesh;

	private static readonly List<Material> StaffMaterials = new List<Material>();

	private static EffectList _heartEffects;

	private static bool _heartsAreNetworked;

	private static readonly Dictionary<SharedData, Kind> SharedKinds = new Dictionary<SharedData, Kind>();

	private static FieldInfo _fAttackCharacter;

	private static FieldInfo _fAttackWeapon;

	private static MethodInfo _mCurrentBlocker;

	private Harmony _harmony;

	private static int _lastHitSoundTick = int.MinValue;

	private static readonly Random Rng = new Random();

	private void Awake()
	{
		//IL_0359: Unknown result type (might be due to invalid IL or missing references)
		//IL_0363: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		CajadoName = AdminBind("Cajado", "Nome", "Cajado de Odin", "Nome mostrado no jogo.");
		CajadoDamage = AdminBind("Cajado", "Dano contundente", 55f, "Dano contundente base (maça de ferro = 55).");
		CajadoPerLevel = AdminBind("Cajado", "Dano por nível", 6f, "Dano a mais por nível de qualidade.");
		MeiaBombaName = AdminBind("Meia-bomba", "Nome", "Cajado meia-bomba de Odin", "Nome mostrado no jogo.");
		MeiaBombaDamage = AdminBind("Meia-bomba", "Dano contundente", 30f, "Dano contundente base. Mole bate menos.");
		MeiaBombaPerLevel = AdminBind("Meia-bomba", "Dano por nível", 4f, "Dano a mais por nível de qualidade.");
		EscudoName = AdminBind("Escudo", "Nome", "Saco de Odin", "Nome mostrado no jogo.");
		MaxQuality = AdminBind("Geral", "Qualidade máxima", 4, "Nível máximo de melhoria na forja (todos os itens).");
		PlaySoundOn = ((BaseUnityPlugin)this).Config.Bind<SoundTrigger>("Som", "Quando tocar", SoundTrigger.Acerto, "Acerto: o som dos cajados toca só quando o golpe acerta uma criatura; errando, fica o som normal. Golpe: toca a cada golpe dado.");
		Volume = ((BaseUnityPlugin)this).Config.Bind<float>("Som", "Volume", 1f, "Volume dos sons do mod (0 a 1). Também segue o volume de efeitos do jogo.");
		SoundRange = ((BaseUnityPlugin)this).Config.Bind<float>("Som", "Alcance", 30f, "Distância máxima em metros em que os outros ouvem.");
		ParrySound = ((BaseUnityPlugin)this).Config.Bind<bool>("Som", "Som de parry do escudo", true, "Toca o som especial quando o escudo dá parry. Bloqueio comum usa o som normal.");
		Hearts = ((BaseUnityPlugin)this).Config.Bind<bool>("Efeito", "Corações no acerto", true, "Corações cor-de-rosa quando o cajado acerta.");
		ColorHex = ((BaseUnityPlugin)this).Config.Bind<string>("Efeito", "Cor dos cajados", "FF5FAF", "Cor dos dois cajados em hexadecimal (RRGGBB).");
		Stiffness = ((BaseUnityPlugin)this).Config.Bind<float>("Meia-bomba", "Firmeza", 45f, "Quanto o cajado meia-bomba tenta voltar para o lugar. Menor = mais mole.");
		Wobble = ((BaseUnityPlugin)this).Config.Bind<float>("Meia-bomba", "Amortecimento", 3.5f, "Quanto o balanço some rápido. Menor = balança mais tempo.");
		Droop = ((BaseUnityPlugin)this).Config.Bind<float>("Meia-bomba", "Caimento", 1f, "Peso que puxa a ponta para baixo. 0 = não cai parado, 2 = bem caído.");
		Models["CajadoDeOdin"] = ModelSettings.Bind(((BaseUnityPlugin)this).Config, "Modelo - Cajado");
		Models["CajadoMeiaBombaDeOdin"] = ModelSettings.Bind(((BaseUnityPlugin)this).Config, "Modelo - Meia-bomba");
		Models["SacoDeOdin"] = ModelSettings.Bind(((BaseUnityPlugin)this).Config, "Modelo - Escudo");
		((BaseUnityPlugin)this).Config.SettingChanged += OnSettingChanged;
		SynchronizationManager.OnConfigurationSynchronized += delegate
		{
			ApplyAllStats();
		};
		_fAttackCharacter = AccessTools.Field(typeof(Attack), "m_character");
		_fAttackWeapon = AccessTools.Field(typeof(Attack), "m_weapon");
		_mCurrentBlocker = AccessTools.Method(typeof(Humanoid), "GetCurrentBlocker", (Type[])null, (Type[])null);
		_hitClip = Assets.LoadClip("sfx.wav", "CajadoDeOdin_Hit");
		_parryClip = Assets.LoadClip("parry.wav", "CajadoDeOdin_Parry");
		PrefabManager.OnVanillaPrefabsAvailable += CreateItems;
		_harmony = new Harmony("skiter.cajadodeodin");
		_harmony.PatchAll(typeof(Patches));
	}

	private ConfigEntry<T> AdminBind<T>(string section, string key, T value, string description)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Expected O, but got Unknown
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		ConfigFile config = ((BaseUnityPlugin)this).Config;
		string text = description + " [Sincronizado com o servidor]";
		object[] array = new object[1];
		ConfigurationManagerAttributes val = new ConfigurationManagerAttributes();
		val.IsAdminOnly = true;
		array[0] = val;
		return config.Bind<T>(section, key, value, new ConfigDescription(text, (AcceptableValueBase)null, array));
	}

	private void OnDestroy()
	{
		if (_harmony != null)
		{
			_harmony.UnpatchSelf();
		}
	}

	private void OnSettingChanged(object sender, SettingChangedEventArgs args)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		ApplyAllStats();
		Color color = Assets.ParseColor(ColorHex.Value);
		foreach (Material staffMaterial in StaffMaterials)
		{
			Assets.Tint(staffMaterial, color);
		}
		ModelFitter.RefreshAll();
	}

	private void CreateItems()
	{
		PrefabManager.OnVanillaPrefabsAvailable -= CreateItems;
		_staffMesh = Assets.BuildStaffMesh();
		CreateItem("CajadoDeOdin", "Club", Kind.Cajado, "Forjado por Odin nas noites mais solitárias de Valhalla. Os inimigos nunca esquecem.", "icon.png");
		CreateItem("CajadoMeiaBombaDeOdin", "Club", Kind.MeiaBomba, "O mesmo cajado, mas num dia ruim. Balança, cai, não se firma. Bate mais fraco, humilha mais.", "icon_meiabomba.png");
		CreateItem("SacoDeOdin", "ShieldIronBuckler", Kind.Escudo, "Peludo, enrugado e surpreendentemente resistente. Um parry bem dado é inesquecível.", "icon_escudo.png");
	}

	private static void CreateItem(string prefabName, string basePrefab, Kind kind, string description, string icon)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		try
		{
			CustomItem val = new CustomItem(prefabName, basePrefab);
			if ((Object)(object)val.ItemPrefab == (Object)null || (Object)(object)val.ItemDrop == (Object)null)
			{
				Log.LogError((object)("Não foi possível clonar " + basePrefab + " para " + prefabName + "."));
				return;
			}
			SharedData shared = val.ItemDrop.m_itemData.m_shared;
			SharedKinds[shared] = kind;
			shared.m_description = description;
			shared.m_teleportable = true;
			shared.m_value = 0;
			Sprite val2 = Assets.LoadIcon(icon);
			if (Object.op_Implicit((Object)(object)val2))
			{
				shared.m_icons = (Sprite[])(object)new Sprite[1] { val2 };
			}
			ApplyStats(shared, kind);
			if ((Object)(object)_mixer == (Object)null)
			{
				_mixer = Assets.FindMixerGroup(shared);
			}
			if (kind == Kind.Escudo)
			{
				BuildShieldModel(val.ItemPrefab, prefabName);
			}
			else
			{
				BuildStaffModel(val.ItemPrefab, prefabName, kind == Kind.MeiaBomba);
			}
			ItemManager.Instance.AddItem(val);
			Log.LogInfo((object)(prefabName + " registrado. Use: spawn " + prefabName));
		}
		catch (Exception ex)
		{
			Log.LogError((object)("Falha ao criar " + prefabName + ": " + ex));
		}
	}

	private static void ApplyAllStats()
	{
		foreach (KeyValuePair<SharedData, Kind> sharedKind in SharedKinds)
		{
			ApplyStats(sharedKind.Key, sharedKind.Value);
		}
	}

	private static void ApplyStats(SharedData shared, Kind kind)
	{
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
		//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)
		shared.m_maxQuality = Math.Max(1, MaxQuality.Value);
		if (kind == Kind.Escudo)
		{
			shared.m_name = EscudoName.Value;
			return;
		}
		bool flag = kind == Kind.MeiaBomba;
		shared.m_name = ((!flag) ? CajadoName.Value : MeiaBombaName.Value);
		DamageTypes damages = shared.m_damages;
		damages.m_blunt = ((!flag) ? CajadoDamage.Value : MeiaBombaDamage.Value);
		damages.m_slash = 0f;
		damages.m_pierce = 0f;
		shared.m_damages = damages;
		DamageTypes damagesPerLevel = shared.m_damagesPerLevel;
		damagesPerLevel.m_blunt = ((!flag) ? CajadoPerLevel.Value : MeiaBombaPerLevel.Value);
		shared.m_damagesPerLevel = damagesPerLevel;
	}

	internal static bool IsKind(ItemData item, Kind kind)
	{
		Kind value;
		return item != null && item.m_shared != null && SharedKinds.TryGetValue(item.m_shared, out value) && value == kind;
	}

	internal static bool IsStaff(ItemData item)
	{
		return IsKind(item, Kind.Cajado) || IsKind(item, Kind.MeiaBomba);
	}

	private static Transform PrepareVisuals(GameObject prefab, out Material baseMaterial)
	{
		baseMaterial = null;
		Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true);
		Renderer[] array = componentsInChildren;
		foreach (Renderer val in array)
		{
			if ((Object)(object)baseMaterial == (Object)null && Object.op_Implicit((Object)(object)val.sharedMaterial))
			{
				baseMaterial = val.sharedMaterial;
			}
		}
		if ((Object)(object)baseMaterial == (Object)null)
		{
			Log.LogError((object)("Material base não encontrado em " + ((Object)prefab).name + "; mantendo o visual original."));
			return null;
		}
		Renderer[] array2 = componentsInChildren;
		foreach (Renderer val2 in array2)
		{
			val2.enabled = false;
		}
		Transform val3 = prefab.transform.Find("attach");
		return (!Object.op_Implicit((Object)(object)val3)) ? prefab.transform : val3;
	}

	private static GameObject AddModelObject(Transform parent, string name, Mesh mesh, Material material)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		GameObject val = new GameObject(name);
		val.layer = ((Component)parent).gameObject.layer;
		val.transform.SetParent(parent, false);
		val.AddComponent<MeshFilter>().sharedMesh = mesh;
		((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = material;
		return val;
	}

	private static void BuildStaffModel(GameObject prefab, string prefabName, bool floppy)
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		Material baseMaterial;
		Transform val = PrepareVisuals(prefab, out baseMaterial);
		if (!((Object)(object)val == (Object)null))
		{
			Material val2 = Assets.CopyMaterial(baseMaterial, prefabName + "_Material");
			Assets.Tint(val2, Assets.ParseColor(ColorHex.Value));
			StaffMaterials.Add(val2);
			GameObject val3 = AddModelObject(val, prefabName + "_Model", _staffMesh, val2);
			ModelFitter modelFitter = val3.AddComponent<ModelFitter>();
			modelFitter.settingsKey = prefabName;
			ModelFitter.Apply(val3.transform, prefabName);
			if (floppy)
			{
				val3.AddComponent<FloppyBender>();
			}
		}
	}

	private static void BuildShieldModel(GameObject prefab, string prefabName)
	{
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Expected O, but got Unknown
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		Material baseMaterial;
		Transform val = PrepareVisuals(prefab, out baseMaterial);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		Mesh val2 = Assets.LoadMesh("shield_body.bin", "SacoDeOdin_Body");
		Mesh val3 = Assets.LoadMesh("shield_hair.bin", "SacoDeOdin_Hair");
		if ((Object)(object)val2 == (Object)null)
		{
			Log.LogError((object)"Malha do escudo não encontrada no mod.");
			return;
		}
		GameObject val4 = new GameObject(prefabName + "_Model");
		val4.layer = ((Component)val).gameObject.layer;
		val4.transform.SetParent(val, false);
		ModelFitter modelFitter = val4.AddComponent<ModelFitter>();
		modelFitter.settingsKey = prefabName;
		ModelFitter.Apply(val4.transform, prefabName);
		Material val5 = Assets.CopyMaterial(baseMaterial, "SacoDeOdin_Skin");
		Texture2D val6 = Assets.LoadTexture("shield_skin.png");
		if (Object.op_Implicit((Object)(object)val6))
		{
			val5.mainTexture = (Texture)(object)val6;
			if (val5.HasProperty("_Color"))
			{
				val5.color = new Color(1f, 1f, 1f, 1f);
			}
		}
		else
		{
			Assets.Tint(val5, new Color(0.91f, 0.69f, 0.63f, 1f));
		}
		AddModelObject(val4.transform, "SacoDeOdin_Body", val2, val5);
		if ((Object)(object)val3 != (Object)null)
		{
			Material val7 = Assets.CopyMaterial(baseMaterial, "SacoDeOdin_HairMaterial");
			Assets.Tint(val7, new Color(0.17f, 0.1f, 0.07f, 1f));
			if (val7.HasProperty("_Glossiness"))
			{
				val7.SetFloat("_Glossiness", 0.2f);
			}
			AddModelObject(val4.transform, "SacoDeOdin_Hair", val3, val7);
		}
	}

	internal static void RegisterRpcs()
	{
		if (ZRoutedRpc.instance != null)
		{
			ZRoutedRpc.instance.Register<Vector3>("CajadoDeOdin_Sound", (Action<long, Vector3>)delegate(long s, Vector3 p)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				PlayClip(_hitClip, p);
			});
			ZRoutedRpc.instance.Register<Vector3>("CajadoDeOdin_Parry", (Action<long, Vector3>)delegate(long s, Vector3 p)
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				PlayClip(_parryClip, p);
			});
			ZRoutedRpc.instance.Register<Vector3>("CajadoDeOdin_Hearts", (Action<long, Vector3>)RPC_Hearts);
		}
	}

	internal static void BroadcastHitSound(Vector3 position)
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		int tickCount = Environment.TickCount;
		if (_lastHitSoundTick == int.MinValue || tickCount - _lastHitSoundTick >= 300)
		{
			_lastHitSoundTick = tickCount;
			Broadcast("CajadoDeOdin_Sound", position);
		}
	}

	internal static void BroadcastParrySound(Vector3 position)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		if (ParrySound.Value)
		{
			Broadcast("CajadoDeOdin_Parry", position);
		}
	}

	private static void Broadcast(string rpc, Vector3 position)
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		if (ZRoutedRpc.instance != null)
		{
			ZRoutedRpc.instance.InvokeRoutedRPC(0L, rpc, new object[1] { position });
		}
	}

	internal static void BroadcastHearts(Vector3 position)
	{
		//IL_003a: 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)
		if (!Hearts.Value)
		{
			return;
		}
		ResolveHeartEffects();
		if (_heartEffects != null)
		{
			if (_heartsAreNetworked)
			{
				SpawnHearts(position);
			}
			else
			{
				Broadcast("CajadoDeOdin_Hearts", position);
			}
		}
	}

	private static void PlayClip(AudioClip clip, Vector3 position)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)clip == (Object)null) && !IsDedicated())
		{
			GameObject val = new GameObject("CajadoDeOdin_SfxPlayer");
			val.transform.position = position;
			AudioSource val2 = val.AddComponent<AudioSource>();
			val2.playOnAwake = false;
			val2.clip = clip;
			float value = Volume.Value;
			val2.volume = ((value < 0f) ? 0f : ((!(value > 1f)) ? value : 1f));
			val2.pitch = 0.95f + (float)Rng.NextDouble() * 0.1f;
			val2.spatialBlend = 1f;
			val2.minDistance = 3f;
			val2.maxDistance = Math.Max(5f, SoundRange.Value);
			if (Object.op_Implicit((Object)(object)_mixer))
			{
				val2.outputAudioMixerGroup = _mixer;
			}
			val2.Play();
			Object.Destroy((Object)(object)val, clip.length + 0.5f);
		}
	}

	private static void RPC_Hearts(long sender, Vector3 position)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		if (!IsDedicated() && Hearts.Value)
		{
			SpawnHearts(position);
		}
	}

	private static void SpawnHearts(Vector3 position)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: 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)
		try
		{
			ResolveHeartEffects();
			if (_heartEffects != null)
			{
				_heartEffects.Create(position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
			}
		}
		catch (Exception ex)
		{
			Log.LogWarning((object)("Efeito de corações falhou: " + ex.Message));
			Hearts.Value = false;
		}
	}

	private static void ResolveHeartEffects()
	{
		if (_heartEffects != null || (Object)(object)ZNetScene.instance == (Object)null)
		{
			return;
		}
		string[] array = new string[4] { "Boar", "Wolf", "Lox", "Chicken" };
		string[] array2 = array;
		foreach (string text in array2)
		{
			GameObject prefab = ZNetScene.instance.GetPrefab(text);
			Procreation val = ((!Object.op_Implicit((Object)(object)prefab)) ? null : prefab.GetComponent<Procreation>());
			if ((Object)(object)val == (Object)null || val.m_loveEffects == null || val.m_loveEffects.m_effectPrefabs == null || val.m_loveEffects.m_effectPrefabs.Length == 0)
			{
				continue;
			}
			_heartEffects = val.m_loveEffects;
			EffectData[] effectPrefabs = _heartEffects.m_effectPrefabs;
			foreach (EffectData val2 in effectPrefabs)
			{
				if (val2 != null && Object.op_Implicit((Object)(object)val2.m_prefab) && Object.op_Implicit((Object)(object)val2.m_prefab.GetComponent<ZNetView>()))
				{
					_heartsAreNetworked = true;
				}
			}
			break;
		}
	}

	internal static bool IsDedicated()
	{
		return Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsDedicated();
	}

	internal static Humanoid AttackCharacter(Attack attack)
	{
		return (Humanoid)((!(_fAttackCharacter == null)) ? /*isinst with value type is only supported in some contexts*/: null);
	}

	internal static ItemData AttackWeapon(Attack attack)
	{
		return (ItemData)((!(_fAttackWeapon == null)) ? /*isinst with value type is only supported in some contexts*/: null);
	}

	internal static ItemData CurrentBlocker(Humanoid humanoid)
	{
		return (ItemData)((!(_mCurrentBlocker == null)) ? /*isinst with value type is only supported in some contexts*/: null);
	}
}
internal static class Assets
{
	private static byte[] Read(string suffix)
	{
		Assembly assembly = typeof(OdinPlugin).Assembly;
		string[] manifestResourceNames = assembly.GetManifestResourceNames();
		foreach (string text in manifestResourceNames)
		{
			if (!text.EndsWith("." + suffix, StringComparison.OrdinalIgnoreCase))
			{
				continue;
			}
			using Stream stream = assembly.GetManifestResourceStream(text);
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			return memoryStream.ToArray();
		}
		return null;
	}

	internal static Texture2D LoadTexture(string file)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		try
		{
			byte[] array = Read(file);
			if (array == null)
			{
				return null;
			}
			Texture2D val = new Texture2D(2, 2);
			return (!ImageConversion.LoadImage(val, array)) ? null : val;
		}
		catch (Exception ex)
		{
			OdinPlugin.Log.LogWarning((object)("Textura " + file + " não carregada: " + ex.Message));
			return null;
		}
	}

	internal static Sprite LoadIcon(string file)
	{
		//IL_0027: 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)
		Texture2D val = LoadTexture(file);
		return (!Object.op_Implicit((Object)(object)val)) ? null : Sprite.Create(val, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f));
	}

	internal static AudioClip LoadClip(string file, string clipName)
	{
		try
		{
			byte[] array = Read(file);
			if (array == null || array.Length < 44)
			{
				OdinPlugin.Log.LogWarning((object)("Som " + file + " não encontrado no mod."));
				return null;
			}
			int num = 1;
			int num2 = 44100;
			int num3 = 16;
			int num4 = -1;
			int num5 = 0;
			int num6;
			for (int i = 12; i + 8 <= array.Length; i += 8 + num6 + (num6 & 1))
			{
				string text = Encoding.ASCII.GetString(array, i, 4);
				num6 = BitConverter.ToInt32(array, i + 4);
				if (text == "fmt ")
				{
					num = BitConverter.ToInt16(array, i + 10);
					num2 = BitConverter.ToInt32(array, i + 12);
					num3 = BitConverter.ToInt16(array, i + 22);
				}
				else if (text == "data")
				{
					num4 = i + 8;
					num5 = Math.Min(num6, array.Length - num4);
					break;
				}
			}
			if (num4 < 0 || num3 != 16)
			{
				OdinPlugin.Log.LogWarning((object)("Som " + file + " em formato não suportado (precisa ser WAV 16-bit)."));
				return null;
			}
			int num7 = num5 / 2;
			float[] array2 = new float[num7];
			for (int j = 0; j < num7; j++)
			{
				array2[j] = (float)BitConverter.ToInt16(array, num4 + j * 2) / 32768f;
			}
			AudioClip val = AudioClip.Create(clipName, num7 / num, num, num2, false);
			val.SetData(array2, 0);
			return val;
		}
		catch (Exception ex)
		{
			OdinPlugin.Log.LogWarning((object)("Som " + file + " não carregado: " + ex.Message));
			return null;
		}
	}

	internal static Mesh LoadMesh(string file, string meshName)
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Expected O, but got Unknown
		byte[] array = Read(file);
		if (array == null)
		{
			return null;
		}
		int num = BitConverter.ToInt32(array, 0);
		int num2 = 4;
		Vector3[] array2 = (Vector3[])(object)new Vector3[num];
		int num3 = 0;
		while (num3 < num)
		{
			ref Vector3 reference = ref array2[num3];
			reference = new Vector3(BitConverter.ToSingle(array, num2), BitConverter.ToSingle(array, num2 + 4), BitConverter.ToSingle(array, num2 + 8));
			num3++;
			num2 += 12;
		}
		Vector2[] array3 = (Vector2[])(object)new Vector2[num];
		int num4 = 0;
		while (num4 < num)
		{
			ref Vector2 reference2 = ref array3[num4];
			reference2 = new Vector2(BitConverter.ToSingle(array, num2), BitConverter.ToSingle(array, num2 + 4));
			num4++;
			num2 += 8;
		}
		int num5 = BitConverter.ToInt32(array, num2);
		num2 += 4;
		int[] array4 = new int[num5];
		int num6 = 0;
		while (num6 < num5)
		{
			array4[num6] = BitConverter.ToInt32(array, num2);
			num6++;
			num2 += 4;
		}
		Mesh val = new Mesh();
		((Object)val).name = meshName;
		val.vertices = array2;
		val.uv = array3;
		val.triangles = array4;
		val.RecalculateNormals();
		val.RecalculateBounds();
		return val;
	}

	private static List<Vector2> StaffProfile()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: 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)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		List<Vector2> list = new List<Vector2>();
		list.Add(new Vector2(0f, 0f));
		list.Add(new Vector2(0f, 0.075f));
		list.Add(new Vector2(0.012f, 0.078f));
		list.Add(new Vector2(0.024f, 0.07f));
		list.Add(new Vector2(0.034f, 0.048f));
		list.Add(new Vector2(0.045f, 0.04f));
		List<Vector2> list2 = list;
		for (int i = 1; i < 15; i++)
		{
			float num = (float)i / 15f;
			list2.Add(new Vector2(0.045f + num * 0.4f, 0.04f + 0.004f * (float)Math.Sin((double)num * Math.PI)));
		}
		list2.Add(new Vector2(0.452f, 0.041f));
		list2.Add(new Vector2(0.462f, 0.052f));
		list2.Add(new Vector2(0.472f, 0.055f));
		list2.Add(new Vector2(0.482f, 0.053f));
		for (int j = 1; j <= 12; j++)
		{
			double num2 = (double)j / 12.0 * Math.PI / 2.0;
			list2.Add(new Vector2(0.482f + 0.085f * (float)Math.Sin(num2), 0.05f * (float)Math.Cos(num2)));
		}
		return list2;
	}

	internal static Mesh BuildStaffMesh()
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: 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_0043: 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_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Expected O, but got Unknown
		List<Vector2> list = StaffProfile();
		int count = list.Count;
		Vector3[] array = (Vector3[])(object)new Vector3[count * 33];
		Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
		for (int i = 0; i < count; i++)
		{
			float x = list[i].x;
			float y = list[i].y;
			for (int j = 0; j <= 32; j++)
			{
				double num = Math.PI * 2.0 * (double)j / 32.0;
				int num2 = i * 33 + j;
				ref Vector3 reference = ref array[num2];
				reference = new Vector3(y * (float)Math.Cos(num), x, y * (float)Math.Sin(num));
				ref Vector2 reference2 = ref array2[num2];
				reference2 = new Vector2((float)j / 32f, x / 0.567f);
			}
		}
		int[] array3 = new int[(count - 1) * 32 * 6];
		int num3 = 0;
		for (int k = 0; k < count - 1; k++)
		{
			for (int l = 0; l < 32; l++)
			{
				int num4 = k * 33 + l;
				int num5 = num4 + 1;
				int num6 = num4 + 32 + 1;
				int num7 = num6 + 1;
				array3[num3++] = num4;
				array3[num3++] = num6;
				array3[num3++] = num7;
				array3[num3++] = num4;
				array3[num3++] = num7;
				array3[num3++] = num5;
			}
		}
		Mesh val = new Mesh();
		((Object)val).name = "CajadoDeOdin_Mesh";
		val.vertices = array;
		val.uv = array2;
		val.triangles = array3;
		val.RecalculateNormals();
		val.RecalculateBounds();
		return val;
	}

	internal static Material CopyMaterial(Material source, string name)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		Material val = new Material(source);
		((Object)val).name = name;
		if (val.HasProperty("_BumpMap"))
		{
			val.SetTexture("_BumpMap", (Texture)null);
		}
		if (val.HasProperty("_Glossiness"))
		{
			val.SetFloat("_Glossiness", 0.6f);
		}
		if (val.HasProperty("_Metallic"))
		{
			val.SetFloat("_Metallic", 0f);
		}
		return val;
	}

	internal static void Tint(Material material, Color color)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(2, 2);
		for (int i = 0; i < 2; i++)
		{
			for (int j = 0; j < 2; j++)
			{
				val.SetPixel(i, j, color);
			}
		}
		val.Apply();
		material.mainTexture = (Texture)(object)val;
		if (material.HasProperty("_Color"))
		{
			material.color = new Color(1f, 1f, 1f, 1f);
		}
	}

	internal static Color ParseColor(string hex)
	{
		//IL_00a1: 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_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			hex = (hex ?? string.Empty).Trim().TrimStart(new char[1] { '#' });
			if (hex.Length >= 6)
			{
				return new Color((float)Convert.ToInt32(hex.Substring(0, 2), 16) / 255f, (float)Convert.ToInt32(hex.Substring(2, 2), 16) / 255f, (float)Convert.ToInt32(hex.Substring(4, 2), 16) / 255f, 1f);
			}
		}
		catch (Exception)
		{
		}
		return new Color(1f, 0.373f, 0.686f, 1f);
	}

	internal static AudioMixerGroup FindMixerGroup(SharedData shared)
	{
		EffectList[] array = (EffectList[])(object)new EffectList[4] { shared.m_triggerEffect, shared.m_startEffect, shared.m_hitEffect, shared.m_blockEffect };
		EffectList[] array2 = array;
		foreach (EffectList val in array2)
		{
			if (val == null || val.m_effectPrefabs == null)
			{
				continue;
			}
			EffectData[] effectPrefabs = val.m_effectPrefabs;
			foreach (EffectData val2 in effectPrefabs)
			{
				if (val2 != null && Object.op_Implicit((Object)(object)val2.m_prefab))
				{
					AudioSource componentInChildren = val2.m_prefab.GetComponentInChildren<AudioSource>(true);
					if (Object.op_Implicit((Object)(object)componentInChildren) && Object.op_Implicit((Object)(object)componentInChildren.outputAudioMixerGroup))
					{
						return componentInChildren.outputAudioMixerGroup;
					}
				}
			}
		}
		return null;
	}
}
public class ModelFitter : MonoBehaviour
{
	public string settingsKey;

	private static readonly HashSet<ModelFitter> Live = new HashSet<ModelFitter>();

	private void OnEnable()
	{
		Live.Add(this);
		Apply(((Component)this).transform, settingsKey);
	}

	private void OnDisable()
	{
		Live.Remove(this);
	}

	internal static void RefreshAll()
	{
		foreach (ModelFitter item in Live)
		{
			if (Object.op_Implicit((Object)(object)item))
			{
				Apply(((Component)item).transform, item.settingsKey);
			}
		}
	}

	internal static void Apply(Transform t, string key)
	{
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		if (key != null && OdinPlugin.Models.TryGetValue(key, out var value))
		{
			float num = ((!(value.Scale.Value <= 0f)) ? value.Scale.Value : 1f);
			t.localPosition = new Vector3(value.PosX.Value, value.PosY.Value, value.PosZ.Value);
			t.localRotation = Quaternion.Euler(value.RotX.Value, value.RotY.Value, value.RotZ.Value);
			t.localScale = new Vector3(num, num, num);
		}
	}
}
public class FloppyBender : MonoBehaviour
{
	private MeshFilter _filter;

	private Mesh _mesh;

	private Vector3[] _rest;

	private Vector3[] _work;

	private Vector3 _tip;

	private Vector3 _velocity;

	private bool _started;

	private float _lastOx = float.NaN;

	private float _lastOz = float.NaN;

	private void Awake()
	{
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Expected O, but got Unknown
		_filter = ((Component)this).GetComponent<MeshFilter>();
		if (Object.op_Implicit((Object)(object)_filter) && Object.op_Implicit((Object)(object)_filter.sharedMesh))
		{
			_mesh = (Mesh)Object.Instantiate((Object)(object)_filter.sharedMesh);
			_filter.sharedMesh = _mesh;
			_rest = _mesh.vertices;
			_work = (Vector3[])(object)new Vector3[_rest.Length];
		}
	}

	private void OnEnable()
	{
		_started = false;
	}

	private void OnDestroy()
	{
		if (Object.op_Implicit((Object)(object)_mesh))
		{
			Object.Destroy((Object)(object)_mesh);
		}
	}

	private void LateUpdate()
	{
		//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)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: 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_00e6: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: 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_0112: 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_011a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: 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_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: 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_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: 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_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: 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_0076: 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_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: 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_02af: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0396: Unknown result type (might be due to invalid IL or missing references)
		//IL_039b: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_mesh == (Object)null || _rest == null)
		{
			return;
		}
		float num = Time.deltaTime;
		if (num <= 0f)
		{
			return;
		}
		if (num > 0.05f)
		{
			num = 0.05f;
		}
		float num2 = 0.567f;
		Vector3 position = ((Component)this).transform.position;
		Vector3 val = ((Component)this).transform.TransformPoint(0f, num2, 0f);
		if (!_started)
		{
			_tip = val;
			_velocity = new Vector3(0f, 0f, 0f);
			_started = true;
		}
		float num3 = Math.Max(1f, OdinPlugin.Stiffness.Value);
		float num4 = Math.Max(0f, OdinPlugin.Wobble.Value);
		float num5 = 9.81f * Math.Max(0f, OdinPlugin.Droop.Value);
		Vector3 val2 = (val - _tip) * num3 + new Vector3(0f, 0f - num5, 0f);
		_velocity += val2 * num;
		_velocity *= (float)Math.Exp((0f - num4) * num);
		_tip += _velocity * num;
		Vector3 val3 = _tip - position;
		float magnitude = ((Vector3)(ref val3)).magnitude;
		Vector3 val4 = val - position;
		float magnitude2 = ((Vector3)(ref val4)).magnitude;
		if (magnitude > 1E-05f && magnitude2 > 1E-05f)
		{
			_tip = position + val3 * (magnitude2 / magnitude);
		}
		Vector3 val5 = ((Component)this).transform.InverseTransformPoint(_tip);
		float num6 = val5.x;
		float num7 = val5.z;
		float num8 = (float)Math.Sqrt(num6 * num6 + num7 * num7);
		float num9 = 0.8f * num2;
		if (num8 > num9)
		{
			num6 *= num9 / num8;
			num7 *= num9 / num8;
			num8 = num9;
		}
		if (Math.Abs(num6 - _lastOx) < 0.0005f && Math.Abs(num7 - _lastOz) < 0.0005f)
		{
			return;
		}
		_lastOx = num6;
		_lastOz = num7;
		float num10 = ((!(num8 > 1E-05f)) ? 1f : (num6 / num8));
		float num11 = ((!(num8 > 1E-05f)) ? 0f : (num7 / num8));
		for (int i = 0; i < _rest.Length; i++)
		{
			Vector3 val6 = _rest[i];
			float num12 = val6.y / num2;
			if (num12 < 0f)
			{
				num12 = 0f;
			}
			if (num12 > 1f)
			{
				num12 = 1f;
			}
			float num13 = num8 * num12 * num12;
			double num14 = Math.Atan(2.0 * (double)num8 * (double)num12 / (double)num2);
			float num15 = (float)Math.Cos(num14);
			float num16 = (float)Math.Sin(num14);
			float num17 = val6.x * num10 + val6.z * num11;
			float num18 = num13 + num17 * (num15 - 1f);
			float num19 = num17 * num16 + num8 * num8 * num12 * num12 * num12 / (2f * num2);
			ref Vector3 reference = ref _work[i];
			reference = new Vector3(val6.x + num10 * num18, val6.y - num19, val6.z + num11 * num18);
		}
		_mesh.vertices = _work;
		_mesh.RecalculateNormals();
		_mesh.RecalculateBounds();
	}
}
[HarmonyPatch]
internal static class Patches
{
	private static Humanoid _blocking;

	private static bool _parried;

	[HarmonyPatch(typeof(Game), "Start")]
	[HarmonyPostfix]
	private static void GameStart()
	{
		OdinPlugin.RegisterRpcs();
	}

	[HarmonyPatch(typeof(Attack), "OnAttackTrigger")]
	[HarmonyPostfix]
	private static void OnAttackTrigger(Attack __instance)
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		if (OdinPlugin.PlaySoundOn.Value == SoundTrigger.Golpe)
		{
			Humanoid val = OdinPlugin.AttackCharacter(__instance);
			if (Object.op_Implicit((Object)(object)val) && (Object)(object)val == (Object)(object)Player.m_localPlayer && OdinPlugin.IsStaff(OdinPlugin.AttackWeapon(__instance)))
			{
				OdinPlugin.BroadcastHitSound(((Component)val).transform.position);
			}
		}
	}

	[HarmonyPatch(typeof(Character), "Damage")]
	[HarmonyPrefix]
	private static void OnDamage(HitData hit)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Invalid comparison between Unknown and I4
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		Player localPlayer = Player.m_localPlayer;
		if (hit == null || !Object.op_Implicit((Object)(object)localPlayer) || (int)hit.m_skill != 3)
		{
			return;
		}
		Character attacker = hit.GetAttacker();
		if (Object.op_Implicit((Object)(object)attacker) && !((Object)(object)attacker != (Object)(object)localPlayer) && OdinPlugin.IsStaff(((Humanoid)localPlayer).GetCurrentWeapon()))
		{
			OdinPlugin.BroadcastHearts(hit.m_point);
			if (OdinPlugin.PlaySoundOn.Value == SoundTrigger.Acerto)
			{
				OdinPlugin.BroadcastHitSound(hit.m_point);
			}
		}
	}

	[HarmonyPatch(typeof(Humanoid), "BlockAttack")]
	[HarmonyPrefix]
	private static void BlockAttackPrefix(Humanoid __instance)
	{
		_blocking = __instance;
		_parried = false;
	}

	[HarmonyPatch(typeof(Humanoid), "BlockAttack")]
	[HarmonyPostfix]
	private static void BlockAttackPostfix(Humanoid __instance)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (_parried && Object.op_Implicit((Object)(object)__instance) && (Object)(object)__instance == (Object)(object)Player.m_localPlayer && OdinPlugin.IsKind(OdinPlugin.CurrentBlocker(__instance), Kind.Escudo))
			{
				OdinPlugin.BroadcastParrySound(((Component)__instance).transform.position);
			}
		}
		finally
		{
			_blocking = null;
			_parried = false;
		}
	}

	[HarmonyPatch(typeof(EffectList), "Create")]
	[HarmonyPrefix]
	private static void EffectCreatePrefix(EffectList __instance)
	{
		if ((Object)(object)_blocking != (Object)null && object.ReferenceEquals(__instance, _blocking.m_perfectBlockEffect))
		{
			_parried = true;
		}
	}
}