using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; using RepoValuableParry.Attacks; using RepoValuableParry.Attacks.EnemySpecific; using RepoValuableParry.Core; using RepoValuableParry.DebugTools; using RepoValuableParry.Destruction; using RepoValuableParry.Detection; using RepoValuableParry.Effects; using RepoValuableParry.Input; using RepoValuableParry.Networking; using RepoValuableParry.Physics; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("RepoValuableParry")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Valuable Parry")] [assembly: AssemblyTitle("RepoValuableParry")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace RepoValuableParry { internal static class ParryConfig { public static ConfigEntry Enabled; public static ConfigEntry UseVanillaInteract; public static ConfigEntry FallbackParryKey; public static ConfigEntry ParryWindow; public static ConfigEntry PlayerKnockbackMultiplier; public static ConfigEntry EnemyKnockbackMultiplier; public static ConfigEntry EffectsIntensity; public static ConfigEntry CameraShake; public static ConfigEntry DebugOverlay; public static ConfigEntry DebugGizmos; public static ConfigEntry VerboseLogs; public static ConfigEntry DamageWeight; public static ConfigEntry ForceWeight; public static ConfigEntry TumbleWeight; public static ConfigEntry SizeWeight; public static ConfigEntry MassWeight; public static ConfigEntry SizeMultiplier; public static ConfigEntry MassMultiplier; public static ConfigEntry MinimumCoverage; public static ConfigEntry MinimumArea; public static ConfigEntry CoverageForgiveness; public static ConfigEntry FreezeDuration; public static ConfigEntry AbsorptionDuration; public static ConfigEntry OverloadDuration; public static ConfigEntry MinExplosionForce; public static ConfigEntry MaxExplosionForce; public static ConfigEntry MinExplosionRadius; public static ConfigEntry MaxExplosionRadius; public static ConfigEntry MinAttackEnergy; public static ConfigEntry MaxAttackEnergy; public static ConfigEntry PlayerTumbleTime; public static ConfigEntry EnemyDirectDamage; public static void Bind(ConfigFile config) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Expected O, but got Unknown //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Expected O, but got Unknown //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Expected O, but got Unknown Enabled = config.Bind("User", "Enable Mod", true, "Master switch for Valuable Parry."); UseVanillaInteract = config.Bind("User", "Use Vanilla Interact", true, "If true, parry uses the vanilla Interact action (E by default, respects rebinds/controllers). If false, uses Fallback Parry Key."); FallbackParryKey = config.Bind("User", "Fallback Parry Key", (KeyCode)101, "Used only when Use Vanilla Interact is false."); ParryWindow = config.Bind("User", "Parry Window", 0.35f, new ConfigDescription("How long ParryIntent stays armed after pressing E, in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange(0.05f, 0.8f), Array.Empty())); PlayerKnockbackMultiplier = config.Bind("User", "Player Knockback Multiplier", 1f, new ConfigDescription("Scales knockback applied to the parrying player.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 3f), Array.Empty())); EnemyKnockbackMultiplier = config.Bind("User", "Enemy Knockback Multiplier", 1f, new ConfigDescription("Scales knockback applied to the attacking enemy.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 3f), Array.Empty())); EffectsIntensity = config.Bind("User", "Effects Intensity", 1f, new ConfigDescription("Scales VFX and audio intensity.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 2f), Array.Empty())); CameraShake = config.Bind("User", "Camera Shake", 1f, new ConfigDescription("Scales camera shake on detonation.", (AcceptableValueBase)(object)new AcceptableValueRange(0f, 2f), Array.Empty())); DebugOverlay = config.Bind("Debug", "Debug Overlay", false, "Shows live parry numbers. Off in a normal playthrough."); DebugGizmos = config.Bind("Debug", "Debug Gizmos", false, "Draws attack line, valuable bounds, contact point and knockback vectors."); VerboseLogs = config.Bind("Debug", "Verbose Logs", true, "Logs every reject reason and successful capture."); DamageWeight = config.Bind("Balance", "Damage Weight", 1f, "AttackEnergy contribution from HurtCollider.playerDamage."); ForceWeight = config.Bind("Balance", "Force Weight", 3f, "AttackEnergy contribution from HurtCollider.physHitForce / playerHitForce."); TumbleWeight = config.Bind("Balance", "Tumble Weight", 4f, "AttackEnergy contribution from HurtCollider.playerTumbleForce."); SizeWeight = config.Bind("Balance", "Size Weight", 0.7f, "Share of ParryCapacity that comes from projected area."); MassWeight = config.Bind("Balance", "Mass Weight", 0.3f, "Share of ParryCapacity that comes from mass."); SizeMultiplier = config.Bind("Balance", "Size Multiplier", 40f, "Projected area is multiplied by this before weighting."); MassMultiplier = config.Bind("Balance", "Mass Multiplier", 15f, "sqrt(mass) is multiplied by this before weighting."); MinimumCoverage = config.Bind("Balance", "Minimum Coverage", 0.25f, new ConfigDescription("Minimum fraction of the player torso that the valuable must cover.", (AcceptableValueBase)(object)new AcceptableValueRange(0.05f, 0.9f), Array.Empty())); MinimumArea = config.Bind("Balance", "Minimum Area", 0.06f, "Hard minimum projected area in square metres."); CoverageForgiveness = config.Bind("Balance", "Coverage Forgiveness", 0.4f, "Bounds padding in metres. Extra slack so a held valuable counts as covering a laser/melee line."); FreezeDuration = config.Bind("Balance", "Freeze Duration", 0.18f, new ConfigDescription("How long the captured attack stays frozen, in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange(0.08f, 0.4f), Array.Empty())); AbsorptionDuration = config.Bind("Balance", "Absorption Duration", 0.14f, "Energy-in visual window after freeze starts."); OverloadDuration = config.Bind("Balance", "Overload Duration", 0.03f, "Short flash before detonation."); MinExplosionForce = config.Bind("Balance", "Min Explosion Force", 8f, "Knockback force at the weakest parryable hit."); MaxExplosionForce = config.Bind("Balance", "Max Explosion Force", 28f, "Knockback force at the strongest parryable hit."); MinExplosionRadius = config.Bind("Balance", "Min Explosion Radius", 1.4f, "Shockwave radius at the weakest parryable hit."); MaxExplosionRadius = config.Bind("Balance", "Max Explosion Radius", 4.5f, "Shockwave radius at the strongest parryable hit."); MinAttackEnergy = config.Bind("Balance", "Min Attack Energy", 8f, "Maps to min explosion scale."); MaxAttackEnergy = config.Bind("Balance", "Max Attack Energy", 80f, "Maps to max explosion scale."); PlayerTumbleTime = config.Bind("Balance", "Player Tumble Time", 1.35f, "How long the player stays tumbling after detonation."); EnemyDirectDamage = config.Bind("Balance", "Enemy Direct Damage", 0, "Direct HP damage to the attacker. Keep at 0 so parry is not an offensive weapon."); } } [BepInPlugin("valuableparry.repovaluableparry", "Valuable Parry", "1.0.0")] public class Plugin : BaseUnityPlugin { private static ManualLogSource _log; private Harmony _harmony; internal static Plugin Instance { get; private set; } private void Awake() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown Instance = this; _log = ((BaseUnityPlugin)this).Logger; ParryConfig.Bind(((BaseUnityPlugin)this).Config); ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; ParryManager.Ensure(); GameObject gameObject = ((Component)ParryManager.Instance).gameObject; if ((Object)(object)gameObject.GetComponent() == (Object)null) { gameObject.AddComponent(); } if ((Object)(object)gameObject.GetComponent() == (Object)null) { gameObject.AddComponent(); } _harmony = new Harmony("valuableparry.repovaluableparry"); _harmony.PatchAll(); Log("Valuable Parry v1.0.0 loaded."); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } internal static void Log(string message) { ManualLogSource log = _log; if (log != null) { log.LogInfo((object)message); } } internal static void LogWarning(string message) { ManualLogSource log = _log; if (log != null) { log.LogWarning((object)message); } } internal static void LogError(string message) { ManualLogSource log = _log; if (log != null) { log.LogError((object)message); } } internal static void LogVerbose(string message) { if (ParryConfig.VerboseLogs != null && ParryConfig.VerboseLogs.Value) { ManualLogSource log = _log; if (log != null) { log.LogInfo((object)("[VERBOSE] " + message)); } } } } internal static class PluginInfo { public const string PLUGIN_GUID = "valuableparry.repovaluableparry"; public const string PLUGIN_NAME = "Valuable Parry"; public const string PLUGIN_VERSION = "1.0.0"; } public static class MyPluginInfo { public const string PLUGIN_GUID = "RepoValuableParry"; public const string PLUGIN_NAME = "Valuable Parry"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace RepoValuableParry.Physics { internal static class AttackEnergyCalculator { public static float Compute(HurtCollider collider) { if ((Object)(object)collider == (Object)null) { return 0f; } GetRaw(collider, out var damage, out var force, out var tumble); return damage * ParryConfig.DamageWeight.Value + Mathf.Sqrt(force) * ParryConfig.ForceWeight.Value + Mathf.Sqrt(tumble) * ParryConfig.TumbleWeight.Value; } public static void GetRaw(HurtCollider collider, out float damage, out float force, out float tumble) { damage = (((Object)(object)collider != (Object)null) ? ((float)collider.playerDamage) : 0f); force = (((Object)(object)collider != (Object)null) ? Mathf.Max(0f, Mathf.Max(collider.physHitForce, collider.playerHitForce)) : 0f); tumble = (((Object)(object)collider != (Object)null) ? Mathf.Max(0f, collider.playerTumbleForce) : 0f); } public static void ScaleExplosion(float energy, out float force, out float radius) { float value = ParryConfig.MinAttackEnergy.Value; float num = Mathf.Max(value + 0.01f, ParryConfig.MaxAttackEnergy.Value); float num2 = Mathf.Sqrt(Mathf.Clamp01((energy - value) / (num - value))); force = Mathf.Lerp(ParryConfig.MinExplosionForce.Value, ParryConfig.MaxExplosionForce.Value, num2); radius = Mathf.Lerp(ParryConfig.MinExplosionRadius.Value, ParryConfig.MaxExplosionRadius.Value, num2); } } internal static class KnockbackCalculator { private const float UpBias = 0.35f; public static Vector3 DirectionFrom(Vector3 from, Vector3 to) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //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_0035: Unknown result type (might be due to invalid IL or missing references) Vector3 val = to - from; val.y += 0.35f; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = Vector3.up + Vector3.back; } return ((Vector3)(ref val)).normalized; } public static Vector3 PlayerForce(Vector3 detonationPoint, Vector3 playerPosition, float explosionForce) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_0017: Unknown result type (might be due to invalid IL or missing references) return DirectionFrom(detonationPoint, playerPosition) * explosionForce * ParryConfig.PlayerKnockbackMultiplier.Value; } public static Vector3 EnemyForce(Vector3 detonationPoint, Vector3 enemyPosition, float explosionForce) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_0017: Unknown result type (might be due to invalid IL or missing references) return DirectionFrom(detonationPoint, enemyPosition) * explosionForce * ParryConfig.EnemyKnockbackMultiplier.Value; } } internal static class ParryCapacityCalculator { public static ValuableStats Evaluate(ValuableObject valuable, PhysGrabObject phys, Vector3 attackDirection) { //IL_0072: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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) ValuableStats result = new ValuableStats { Name = (((Object)(object)valuable != (Object)null) ? StripClone(((Object)((Component)valuable).gameObject).name) : "none"), DollarValue = GameAccess.GetDollarValue(valuable), Mass = GetMass(phys, valuable) }; result.Bounds = CombineColliderBounds(((Object)(object)phys != (Object)null) ? ((Component)phys).gameObject : (((Object)(object)valuable != (Object)null) ? ((Component)valuable).gameObject : null)); Vector3 dir = ((((Vector3)(ref attackDirection)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref attackDirection)).normalized : Vector3.forward); result.ProjectedArea = ProjectedArea(((Bounds)(ref result.Bounds)).size, dir); result.MeetsMinimumSize = result.ProjectedArea >= ParryConfig.MinimumArea.Value; float num = result.ProjectedArea * ParryConfig.SizeMultiplier.Value; float num2 = Mathf.Sqrt(Mathf.Max(result.Mass, 0f)) * ParryConfig.MassMultiplier.Value; result.Capacity = num * ParryConfig.SizeWeight.Value + num2 * ParryConfig.MassWeight.Value; return result; } public static float GetMass(PhysGrabObject phys, ValuableObject valuable) { if ((Object)(object)phys != (Object)null && phys.massOriginal > 0f) { return phys.massOriginal; } if ((Object)(object)phys != (Object)null && (Object)(object)phys.rb != (Object)null) { return phys.rb.mass; } if ((Object)(object)valuable != (Object)null && (Object)(object)valuable.physAttributePreset != (Object)null) { return valuable.physAttributePreset.mass; } return 1f; } public static float ProjectedArea(Vector3 size, Vector3 dir) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0049: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) ((Vector3)(ref dir))..ctor(Mathf.Abs(dir.x), Mathf.Abs(dir.y), Mathf.Abs(dir.z)); float num = size.x * size.y; float num2 = size.x * size.z; float num3 = size.y * size.z; return num * dir.z + num2 * dir.y + num3 * dir.x; } public static Bounds CombineColliderBounds(GameObject go) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_006e: 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) if ((Object)(object)go == (Object)null) { return new Bounds(Vector3.zero, Vector3.one * 0.1f); } Collider[] componentsInChildren = go.GetComponentsInChildren(); bool flag = false; Bounds result = default(Bounds); Collider[] array = componentsInChildren; foreach (Collider val in array) { if (!((Object)(object)val == (Object)null) && val.enabled && !val.isTrigger) { if (!flag) { result = val.bounds; flag = true; } else { ((Bounds)(ref result)).Encapsulate(val.bounds); } } } if (!flag) { ((Bounds)(ref result))..ctor(go.transform.position, go.transform.lossyScale); } float value = ParryConfig.CoverageForgiveness.Value; ((Bounds)(ref result)).Expand(value * 2f); return result; } private static string StripClone(string name) { if (string.IsNullOrEmpty(name)) { return "Valuable"; } return name.Replace("(Clone)", "").Trim(); } } } namespace RepoValuableParry.Patches { [HarmonyPatch(typeof(HurtCollider), "PlayerHurt")] internal static class HurtColliderPatch { private static bool Prefix(HurtCollider __instance, PlayerAvatar _player) { if (!ParryConfig.Enabled.Value) { return true; } if ((Object)(object)ParryManager.Instance == (Object)null) { return true; } if ((Object)(object)_player == (Object)null) { return true; } if (ParryManager.Instance.IsAttackConsumed(__instance)) { Plugin.LogVerbose("Skipping consumed HurtCollider hit."); return false; } if (ParryManager.Instance.TryInterceptAttack(__instance, _player)) { return false; } return true; } } [HarmonyPatch(typeof(PlayerAvatar), "Awake")] internal static class PlayerAvatarAwakePatch { private static void Postfix(PlayerAvatar __instance) { ParryNetworkManager.EnsureOnPlayer(__instance); } } [HarmonyPatch] internal static class ValuablePatch { [HarmonyPatch(typeof(ValuableObject), "Start")] [HarmonyPostfix] private static void StartPostfix(ValuableObject __instance) { } } } namespace RepoValuableParry.Networking { internal sealed class ParryNetworkBehaviour : MonoBehaviourPun { public PlayerAvatar Player; [PunRPC] public void VP_ParryStart(int sequenceId, int playerViewId, int enemyViewId, int valuableViewId, float energy, Vector3 contact, int seed, PhotonMessageInfo info) { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ParryManager.Instance == (Object)null)) { ParryManager.Instance.ReceiveRemoteParryStart(new ParryEvent { SequenceId = sequenceId, PlayerViewId = playerViewId, EnemyViewId = enemyViewId, ValuableViewId = valuableViewId, AttackEnergy = energy, ContactPoint = contact, EffectSeed = seed }); } } [PunRPC] public void VP_ParryCommit(int playerViewId, int enemyViewId, int valuableViewId, float energy, Vector3 contact, int seed, PhotonMessageInfo info) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)ParryManager.Instance == (Object)null) && SemiFunc.IsMasterClient()) { ParryManager.Instance.HostCommitParry(playerViewId, enemyViewId, valuableViewId, energy, contact, seed); } } } internal static class ParryNetworkManager { public static void EnsureOnPlayer(PlayerAvatar player) { if (!((Object)(object)player == (Object)null) && (Object)(object)((Component)player).GetComponent() == (Object)null) { ((Component)player).gameObject.AddComponent().Player = player; } } public static int ViewId(Component component) { if ((Object)(object)component == (Object)null) { return 0; } PhotonView val = component.GetComponent(); if ((Object)(object)val == (Object)null) { val = component.GetComponentInParent(); } if (!((Object)(object)val != (Object)null)) { return 0; } return val.ViewID; } public static void BroadcastParryStart(ParryContext context) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMultiplayer() && SemiFunc.IsMasterClient()) { ParryNetworkBehaviour parryNetworkBehaviour = RpcHost(); if (!((Object)(object)parryNetworkBehaviour == (Object)null) && !((Object)(object)((MonoBehaviourPun)parryNetworkBehaviour).photonView == (Object)null)) { ((MonoBehaviourPun)parryNetworkBehaviour).photonView.RPC("VP_ParryStart", (RpcTarget)1, new object[7] { context.SequenceId, ViewId((Component)(object)context.Player), ((Object)(object)context.Enemy != (Object)null) ? ((MonoBehaviourPun)context.Enemy).photonView.ViewID : 0, ViewId((Component)(object)context.PhysObject), context.AttackEnergy, context.ContactPoint, context.EffectSeed }); } } } public static void SendCommitToHost(ParryContext context) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.IsMultiplayer() && !SemiFunc.IsMasterClient()) { ParryNetworkBehaviour parryNetworkBehaviour = (((Object)(object)context.Player != (Object)null) ? ((Component)context.Player).GetComponent() : null); if (!((Object)(object)parryNetworkBehaviour == (Object)null) && !((Object)(object)((MonoBehaviourPun)parryNetworkBehaviour).photonView == (Object)null)) { ((MonoBehaviourPun)parryNetworkBehaviour).photonView.RPC("VP_ParryCommit", (RpcTarget)2, new object[6] { ViewId((Component)(object)context.Player), ((Object)(object)context.Enemy != (Object)null) ? ((MonoBehaviourPun)context.Enemy).photonView.ViewID : 0, ViewId((Component)(object)context.PhysObject), context.AttackEnergy, context.ContactPoint, context.EffectSeed }); } } } private static ParryNetworkBehaviour RpcHost() { PlayerAvatar val = SemiFunc.PlayerGetLocal(); if (!((Object)(object)val != (Object)null)) { return null; } return ((Component)val).GetComponent(); } } public struct ParryRequest { public int PlayerViewId; public int ValuableViewId; public int InputSequence; public float ClientTime; } public struct ParryEvent { public int SequenceId; public int PlayerViewId; public int EnemyViewId; public int ValuableViewId; public float AttackEnergy; public Vector3 ContactPoint; public int EffectSeed; } } namespace RepoValuableParry.Input { internal static class ParryInput { private static readonly FieldRef ChatActive = AccessTools.FieldRefAccess("chatActive"); public static bool WasParryPressed() { //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (IsChatOpen()) { return false; } if (ParryConfig.UseVanillaInteract.Value) { if ((Object)(object)InputManager.instance == (Object)null) { return Input.GetKeyDown((KeyCode)101); } return SemiFunc.InputDown((InputKey)2); } return Input.GetKeyDown(ParryConfig.FallbackParryKey.Value); } private static bool IsChatOpen() { if ((Object)(object)ChatManager.instance == (Object)null) { return false; } try { return ChatActive.Invoke(ChatManager.instance); } catch { return false; } } } } namespace RepoValuableParry.Effects { internal static class AbsorptionEffect { private class AbsorptionDriver : MonoBehaviour { private Vector3 _contact; private Transform _valuable; private Light _light; private float _duration; private float _intensity; private float _age; private LineRenderer[] _arcs; public void Init(Vector3 contact, Transform valuable, Light light, float duration, float intensity) { //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_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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) _contact = contact; _valuable = valuable; _light = light; _duration = duration; _intensity = intensity; _arcs = (LineRenderer[])(object)new LineRenderer[3]; for (int i = 0; i < _arcs.Length; i++) { GameObject val = new GameObject("Arc" + i); val.transform.SetParent(((Component)this).transform, false); LineRenderer val2 = val.AddComponent(); val2.positionCount = 6; val2.widthMultiplier = 0.08f * intensity; val2.useWorldSpace = true; Material val3 = ParryShaders.Make(new Color(0.55f, 0.95f, 1f, 1f)); if ((Object)(object)val3 != (Object)null) { ((Renderer)val2).material = val3; } val2.startColor = new Color(1f, 1f, 1f, 1f); val2.endColor = new Color(0.3f, 0.8f, 1f, 0.4f); _arcs[i] = val2; } } private void Update() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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) //IL_00bb: 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_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: 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_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: 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_0163: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: 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_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) _age += Time.deltaTime; Vector3 val = (((Object)(object)_valuable != (Object)null) ? _valuable.position : _contact); float num = Mathf.Clamp01(_age / Mathf.Max(0.01f, _duration)); if ((Object)(object)_light != (Object)null) { ((Component)_light).transform.position = val; _light.intensity = Mathf.Lerp(6f, 18f * _intensity, num); _light.color = Color.Lerp(new Color(0.55f, 0.85f, 1f), new Color(1f, 0.95f, 0.7f), num); } for (int i = 0; i < _arcs.Length; i++) { if ((Object)(object)_arcs[i] == (Object)null) { continue; } for (int j = 0; j < 6; j++) { float num2 = (float)j / 5f; Vector3 val2 = Vector3.Lerp(_contact, val, num2); float num3 = Mathf.Sin(Time.time * (8f + (float)i * 3f) + (float)j) * 0.08f * (1f - Mathf.Abs(num2 * 2f - 1f)); Vector3 val3 = val - _contact; Vector3 val4 = Vector3.Cross(((Vector3)(ref val3)).normalized, Vector3.up); if (((Vector3)(ref val4)).sqrMagnitude < 0.01f) { val4 = Vector3.right; } val2 += ((Vector3)(ref val4)).normalized * num3 + Vector3.up * num3 * 0.4f; _arcs[i].SetPosition(j, val2); } _arcs[i].widthMultiplier = Mathf.Lerp(0.05f, 0.14f, num) * _intensity; } } } public static GameObject Spawn(Vector3 contact, Transform valuable, float intensity, float duration) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown //IL_006c: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0158: 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) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("ValuableParryAbsorption"); val.transform.position = contact; GameObject val2 = new GameObject("Glow"); val2.transform.SetParent(val.transform, false); if ((Object)(object)valuable != (Object)null) { val2.transform.position = valuable.position; } Light val3 = val2.AddComponent(); val3.type = (LightType)2; val3.color = new Color(0.45f, 0.9f, 1f); val3.range = 8f + intensity * 4f; val3.intensity = 8f * intensity; GameObject val4 = new GameObject("PullParticles"); val4.transform.SetParent(val.transform, false); val4.transform.position = contact; ParticleSystem obj = val4.AddComponent(); MainModule main = obj.main; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(Mathf.Max(0.08f, duration)); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0.2f); ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.05f * intensity); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.7f, 0.95f, 1f, 0.85f)); ((MainModule)(ref main)).maxParticles = 64; ((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1; EmissionModule emission = obj.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(80f * intensity); ShapeModule shape = obj.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = 0.12f; TrailModule trails = obj.trails; ((TrailModule)(ref trails)).enabled = true; ((TrailModule)(ref trails)).lifetime = MinMaxCurve.op_Implicit(0.15f); ParticleSystemRenderer component = val4.GetComponent(); component.renderMode = (ParticleSystemRenderMode)0; Material val5 = ParryShaders.Make(new Color(0.7f, 0.95f, 1f, 0.9f)); if ((Object)(object)val5 != (Object)null) { ((Renderer)component).material = val5; } val.AddComponent().Init(contact, valuable, val3, duration, intensity); Object.Destroy((Object)(object)val, duration + 0.4f); return val; } } internal static class CameraEffects { public static void ShakeDetonation(Vector3 position, float intensity) { //IL_0020: 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) float num = Mathf.Max(0f, intensity) * ParryConfig.CameraShake.Value; if (!(num <= 0.01f)) { SemiFunc.CameraShakeImpactDistance(position, 5.5f * num, 0.4f, 0.5f, 16f); SemiFunc.CameraShakeDistance(position, 3.2f * num, 0.5f, 1f, 18f); } } } internal static class DetonationEffect { private class DetonationDriver : MonoBehaviour { private Light _light; private Transform _ring; private float _radius; private float _intensity; private float _age; public void Init(Light light, Transform ring, float radius, float intensity) { _light = light; _ring = ring; _radius = radius; _intensity = intensity; } private void Update() { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: 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) _age += Time.deltaTime; float num = Mathf.Clamp01(_age / 0.35f); if ((Object)(object)_light != (Object)null) { _light.intensity = Mathf.Lerp(22f * _intensity, 0f, num); } if ((Object)(object)_ring != (Object)null) { float num2 = Mathf.Lerp(0.35f, Mathf.Max(3f, _radius * 3.2f), Mathf.Sqrt(num)); _ring.localScale = Vector3.one * num2; MeshRenderer component = ((Component)_ring).GetComponent(); if ((Object)(object)component != (Object)null && (Object)(object)((Renderer)component).material != (Object)null) { Color color = ((Renderer)component).material.color; color.a = Mathf.Lerp(0.35f, 0f, num); ((Renderer)component).material.color = color; } } } } public static void Spawn(Vector3 position, float radius, float intensity) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Expected O, but got Unknown GameObject val = new GameObject("ValuableParryDetonation"); val.transform.position = position; GameObject val2 = new GameObject("Flash"); val2.transform.SetParent(val.transform, false); Light val3 = val2.AddComponent(); val3.type = (LightType)2; val3.color = new Color(1f, 0.95f, 0.75f); val3.range = Mathf.Max(10f, radius * 3f); val3.intensity = 22f * intensity; GameObject val4 = new GameObject("Burst"); val4.transform.SetParent(val.transform, false); ParticleSystem val5 = val4.AddComponent(); MainModule main = val5.main; ((MainModule)(ref main)).duration = 0.4f; ((MainModule)(ref main)).loop = false; ((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0.35f); ((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(4f * intensity); ((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.08f * intensity); ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.85f, 0.95f, 1f, 1f)); ((MainModule)(ref main)).maxParticles = 80; ((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0.2f); EmissionModule emission = val5.emission; ((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f); ((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1] { new Burst(0f, (short)Mathf.RoundToInt(40f * intensity)) }); ShapeModule shape = val5.shape; ((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0; ((ShapeModule)(ref shape)).radius = 0.15f; ParticleSystemRenderer component = val4.GetComponent(); Material val6 = ParryShaders.Make(Color.white); if ((Object)(object)val6 != (Object)null) { ((Renderer)component).material = val6; } GameObject val7 = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)val7).name = "Shockwave"; val7.transform.SetParent(val.transform, false); val7.transform.localScale = Vector3.one * 0.2f; Object.Destroy((Object)(object)val7.GetComponent()); MeshRenderer component2 = val7.GetComponent(); Material val8 = ParryShaders.Make(new Color(0.75f, 0.95f, 1f, 0.55f)); if ((Object)(object)val8 == (Object)null) { val8 = new Material(Shader.Find("Sprites/Default")); } val8.color = new Color(0.75f, 0.95f, 1f, 0.55f); ((Renderer)component2).material = val8; ((Renderer)component2).shadowCastingMode = (ShadowCastingMode)0; val.AddComponent().Init(val3, val7.transform, radius, intensity); Object.Destroy((Object)(object)val, 0.7f); } } internal static class ParryAudio { private static AudioClip _thump; private static AudioClip _hum; private static AudioClip _overload; private static AudioClip _boom; private static bool _built; public static void PlayThump(Vector3 position, float intensity) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) EnsureClips(); Play(_thump, position, 0.85f * intensity, 0.7f); } public static void PlayHum(Vector3 position, float intensity) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) EnsureClips(); Play(_hum, position, 0.55f * intensity, 1f); } public static void PlayOverload(Vector3 position, float intensity) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) EnsureClips(); Play(_overload, position, 0.7f * intensity, 1.2f); } public static void PlayDetonation(Vector3 position, float intensity) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) EnsureClips(); Play(_boom, position, 1.1f * intensity, 0.55f + intensity * 0.15f); } private static void Play(AudioClip clip, Vector3 position, float volume, float pitch) { //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_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Expected O, but got Unknown if (!((Object)(object)clip == (Object)null)) { GameObject val = new GameObject("ValuableParryAudio"); val.transform.position = position; AudioSource obj = val.AddComponent(); obj.clip = clip; obj.spatialBlend = 1f; obj.rolloffMode = (AudioRolloffMode)1; obj.minDistance = 1.5f; obj.maxDistance = 22f; obj.volume = Mathf.Clamp01(volume); obj.pitch = Mathf.Clamp(pitch, 0.4f, 1.8f); obj.Play(); Object.Destroy((Object)val, clip.length + 0.1f); } } private static void EnsureClips() { if (!_built) { _built = true; _thump = Build("parry-thump", 0.18f, delegate(float t, float n) { float num = Mathf.Exp((0f - t) * 18f); return (Mathf.Sin(t * 90f * MathF.PI * 2f) * 0.7f + n * 0.3f) * num; }); _hum = Build("parry-hum", 0.16f, delegate(float t, float n) { float num = Mathf.Sin(Mathf.Clamp01(t / 0.16f) * MathF.PI); float num2 = Mathf.Lerp(180f, 420f, t / 0.16f); return (Mathf.Sin(t * num2 * MathF.PI * 2f) + n * 0.08f) * num * 0.5f; }); _overload = Build("parry-overload", 0.08f, delegate(float t, float n) { float num = t / 0.08f; float num2 = Mathf.Lerp(400f, 1400f, num); return (Mathf.Sin(t * num2 * MathF.PI * 2f) + n * 0.15f) * num; }); _boom = Build("parry-boom", 0.42f, delegate(float t, float n) { float num = Mathf.Exp((0f - t) * 7f); float num2 = Mathf.Sin(t * 55f * MathF.PI * 2f); float num3 = Mathf.Sin(t * 110f * MathF.PI * 2f) * 0.4f; return (num2 + num3 + n * 0.45f) * num; }); } } private static AudioClip Build(string name, float duration, Func sample) { int num = Mathf.CeilToInt(duration * 22050f); float[] array = new float[num]; Random random = new Random(name.GetHashCode()); for (int i = 0; i < num; i++) { float arg = (float)i / 22050f; float arg2 = (float)(random.NextDouble() * 2.0 - 1.0); array[i] = Mathf.Clamp(sample(arg, arg2), -1f, 1f); } AudioClip obj = AudioClip.Create(name, num, 1, 22050, false); obj.SetData(array, 0); return obj; } } internal static class ParryEffectController { public static void PlayCapture(Vector3 contact, float intensity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) ParryAudio.PlayThump(contact, intensity); } public static GameObject PlayAbsorption(Vector3 contact, Transform valuable, float intensity, float duration) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) ParryAudio.PlayHum(contact, intensity); return AbsorptionEffect.Spawn(contact, valuable, intensity, duration); } public static void PlayOverload(Vector3 position, float intensity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) ParryAudio.PlayOverload(position, intensity); } public static void PlayDetonation(Vector3 position, float radius, float intensity) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) ParryAudio.PlayDetonation(position, intensity); DetonationEffect.Spawn(position, radius, intensity); CameraEffects.ShakeDetonation(position, intensity); } } internal static class ParryShaders { private static Shader _cached; private static bool _searched; public static Shader Unlit { get { if (_searched) { return _cached; } _searched = true; string[] array = new string[8] { "Universal Render Pipeline/Unlit", "Universal Render Pipeline/Particles/Unlit", "Sprites/Default", "UI/Default", "Unlit/Color", "Unlit/Transparent", "Particles/Standard Unlit", "Hidden/InternalErrorShader" }; foreach (string text in array) { Shader val = Shader.Find(text); if ((Object)(object)val != (Object)null) { _cached = val; Plugin.LogVerbose("Parry VFX shader: " + text); return _cached; } } return null; } } public static Material Make(Color color) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) Shader unlit = Unlit; if ((Object)(object)unlit == (Object)null) { return null; } Material val = new Material(unlit) { color = color }; if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", color); } if (val.HasProperty("_Color")) { val.SetColor("_Color", color); } return val; } } } namespace RepoValuableParry.Detection { internal static class AttackDetector { private static readonly List Adapters = new List { new BeamerAdapter(), new ReaperAdapter(), new TrudgeAdapter(), new GenericMeleeAdapter() }; public static IParryAttackAdapter FindAdapter(HurtCollider collider) { foreach (IParryAttackAdapter adapter in Adapters) { if (adapter.CanHandle(collider)) { return adapter; } } return null; } } internal static class HeldValuableDetector { public static bool TryGetHeldValuable(PlayerAvatar player, out PhysGrabObject phys, out ValuableObject valuable, out ParryRejectReason reject) { phys = null; valuable = null; reject = ParryRejectReason.NoHeldObject; if ((Object)(object)player == (Object)null) { return false; } PhysGrabber physGrabber = player.physGrabber; if ((Object)(object)physGrabber == (Object)null || !physGrabber.grabbed) { return false; } phys = GameAccess.GetGrabbed(physGrabber); if ((Object)(object)phys == (Object)null) { return false; } valuable = ((Component)phys).GetComponent(); if ((Object)(object)valuable == (Object)null) { reject = ParryRejectReason.NotValuable; return false; } reject = ParryRejectReason.None; return true; } public static bool TryGetLocalHeldValuable(out PhysGrabObject phys, out ValuableObject valuable, out ParryRejectReason reject) { phys = null; valuable = null; reject = ParryRejectReason.NoHeldObject; if (!SemiFunc.PhysGrabberLocalIsGrabbing()) { return false; } phys = SemiFunc.PhysGrabberLocalGetGrabbedPhysGrabObject(); if ((Object)(object)phys == (Object)null) { return false; } valuable = ((Component)phys).GetComponent(); if ((Object)(object)valuable == (Object)null) { reject = ParryRejectReason.NotValuable; return false; } reject = ParryRejectReason.None; return true; } } internal static class ValuableCoverageDetector { public static bool CoversPlayer(Bounds valuableBounds, Vector3 attackOrigin, Vector3 playerBodyPoint, out float coverage, out Vector3 contactPoint) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_0032: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_007d: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) coverage = 0f; contactPoint = ((Bounds)(ref valuableBounds)).ClosestPoint(playerBodyPoint); Vector3 val = playerBodyPoint - attackOrigin; float magnitude = ((Vector3)(ref val)).magnitude; if (magnitude < 0.05f) { return false; } Vector3 val2 = val / magnitude; float num = Vector3.Dot(((Bounds)(ref valuableBounds)).center - attackOrigin, val2); if (num < -0.25f) { return false; } Vector3 val3 = attackOrigin + val2 * Mathf.Clamp(num, 0f, magnitude); Vector3 val4 = ((Bounds)(ref valuableBounds)).ClosestPoint(val3); float num2 = Vector3.Distance(val3, val4); Vector3 extents = ((Bounds)(ref valuableBounds)).extents; float num3 = ((Vector3)(ref extents)).magnitude * 0.5f + ParryConfig.CoverageForgiveness.Value + 0.25f; bool flag = num2 <= num3; float num4 = default(float); if (((Bounds)(ref valuableBounds)).IntersectRay(new Ray(attackOrigin, val2), ref num4) && num4 <= magnitude + 0.5f) { flag = true; contactPoint = attackOrigin + val2 * num4; } else { contactPoint = val4; } coverage = TorsoCoverage(valuableBounds, playerBodyPoint, val2); if (flag && coverage < ParryConfig.MinimumCoverage.Value) { coverage = ParryConfig.MinimumCoverage.Value; } return flag; } public static bool CoversBeam(HurtCollider beamCollider, Bounds valuableBounds, Vector3 beamOrigin, Vector3 playerBodyPoint, out float coverage, out Vector3 contactPoint) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_0138: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: 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_0080: 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_008d: 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_0096: 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_00aa: 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_00b4: 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_00bd: 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_00c8: 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_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: 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_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: 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_01ba: 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) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: 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_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) coverage = 0f; contactPoint = ((Bounds)(ref valuableBounds)).ClosestPoint(playerBodyPoint); Collider val = (((Object)(object)beamCollider != (Object)null) ? ((Component)beamCollider).GetComponent() : null); Vector3 val2 = beamOrigin; Vector3 val3 = playerBodyPoint - val2; float num = ((Vector3)(ref val3)).magnitude; if (num > 0.05f) { val3 /= num; } Vector3 val4; if ((Object)(object)val != (Object)null) { Vector3 forward = ((Component)val).transform.forward; if (((Vector3)(ref forward)).sqrMagnitude > 0.001f) { Bounds bounds = val.bounds; Vector3 center = ((Bounds)(ref bounds)).center; Vector3 normalized = ((Vector3)(ref forward)).normalized; bounds = val.bounds; val4 = ((Bounds)(ref bounds)).size; val2 = center - normalized * (((Vector3)(ref val4)).magnitude * 0.5f); Vector3 val5 = val.ClosestPoint(((Bounds)(ref valuableBounds)).center); contactPoint = ((Bounds)(ref valuableBounds)).ClosestPoint(val5); float num2 = Vector3.Distance(val5, contactPoint); float num3 = ParryConfig.CoverageForgiveness.Value + 0.35f; if (num2 <= num3) { coverage = 1f; return true; } val3 = ((Vector3)(ref forward)).normalized; num = Mathf.Max(num, ((Component)val).transform.lossyScale.z); val2 = ((Component)val).transform.position; } } Ray val6 = default(Ray); ((Ray)(ref val6))..ctor(val2, val3); float num4 = default(float); if (((Bounds)(ref valuableBounds)).IntersectRay(val6, ref num4) && num4 >= -0.5f && num4 <= num + 0.5f) { contactPoint = val2 + val3 * Mathf.Max(0f, num4); coverage = 1f; return true; } float num5 = Vector3.Dot(((Bounds)(ref valuableBounds)).center - val2, val3); if (num5 < -0.25f || num5 > num + 0.75f) { return CoversPlayer(valuableBounds, beamOrigin, playerBodyPoint, out coverage, out contactPoint); } Vector3 val7 = val2 + val3 * num5; contactPoint = ((Bounds)(ref valuableBounds)).ClosestPoint(val7); float num6 = Vector3.Distance(val7, contactPoint); val4 = ((Bounds)(ref valuableBounds)).extents; float num7 = ((Vector3)(ref val4)).magnitude * 0.35f + ParryConfig.CoverageForgiveness.Value + 0.35f; bool num8 = num6 <= num7; if (num8) { coverage = 1f; } return num8; } public static bool CoversContact(Bounds valuableBounds, Vector3 enemyPosition, Vector3 playerBodyPoint, out float coverage, out Vector3 contactPoint) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //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_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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00e8: 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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0116: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_0138: 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) coverage = 0f; contactPoint = ((Bounds)(ref valuableBounds)).ClosestPoint(playerBodyPoint); Vector3 center = ((Bounds)(ref valuableBounds)).center; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(enemyPosition.x, enemyPosition.z); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(playerBodyPoint.x, playerBodyPoint.z); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(center.x, center.z); Vector2 val4 = val2 - val; float magnitude = ((Vector2)(ref val4)).magnitude; float num = ParryConfig.CoverageForgiveness.Value + 0.7f; Vector3 extents = ((Bounds)(ref valuableBounds)).extents; float num2 = ((Vector3)(ref extents)).magnitude + num; if (magnitude < 1.6f) { float num3 = Vector2.Distance(val3, val); float num4 = Vector2.Distance(val3, val2); if (num3 <= 2.4f || num4 <= 2.2f) { coverage = 1f; contactPoint = ((Bounds)(ref valuableBounds)).ClosestPoint(enemyPosition); return true; } } if (magnitude < 0.05f) { return false; } Vector2 val5 = val4 / magnitude; float num5 = Vector2.Dot(val3 - val, val5); if (num5 < -0.4f || num5 > magnitude + 0.6f) { return false; } if (Vector2.Distance(val + val5 * num5, val3) <= num2) { coverage = 1f; contactPoint = center; return true; } return false; } private static float TorsoCoverage(Bounds valuableBounds, Vector3 playerBodyPoint, Vector3 attackDir) { //IL_0000: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: 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_0064: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_00da: Unknown result type (might be due to invalid IL or missing references) Bounds bounds = new Bounds(playerBodyPoint, new Vector3(0.7f, 0.9f, 0.6f)); Vector3 val = Vector3.Cross(attackDir, Vector3.up); if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = Vector3.Cross(attackDir, Vector3.right); } ((Vector3)(ref val)).Normalize(); Vector3 val2 = Vector3.Cross(attackDir, val); Vector3 normalized = ((Vector3)(ref val2)).normalized; ProjectAabb(bounds, val, normalized, out var min, out var max); ProjectAabb(valuableBounds, val, normalized, out var min2, out var max2); Vector2 val3 = Vector2.Max(min, min2); Vector2 val4 = Vector2.Min(max, max2) - val3; if (val4.x <= 0f || val4.y <= 0f) { return 0f; } float num = Mathf.Max(0.0001f, (max.x - min.x) * (max.y - min.y)); return Mathf.Clamp01(val4.x * val4.y / num); } private static void ProjectAabb(Bounds bounds, Vector3 axisA, Vector3 axisB, out Vector2 min, out Vector2 max) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_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_0035: 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_003d: 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_0049: 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_0055: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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_006f: 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_007a: 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_0086: 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_008d: 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_009b: 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) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: 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_00d1: 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_00d9: 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_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_00f0: 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_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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_017d: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0194: 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_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) Vector3 center = ((Bounds)(ref bounds)).center; Vector3 extents = ((Bounds)(ref bounds)).extents; Vector3[] obj = new Vector3[8] { center + new Vector3(extents.x, extents.y, extents.z), center + new Vector3(extents.x, extents.y, 0f - extents.z), center + new Vector3(extents.x, 0f - extents.y, extents.z), center + new Vector3(extents.x, 0f - extents.y, 0f - extents.z), center + new Vector3(0f - extents.x, extents.y, extents.z), center + new Vector3(0f - extents.x, extents.y, 0f - extents.z), center + new Vector3(0f - extents.x, 0f - extents.y, extents.z), center + new Vector3(0f - extents.x, 0f - extents.y, 0f - extents.z) }; min = new Vector2(float.PositiveInfinity, float.PositiveInfinity); max = new Vector2(float.NegativeInfinity, float.NegativeInfinity); Vector3[] array = (Vector3[])(object)obj; Vector2 val2 = default(Vector2); foreach (Vector3 val in array) { ((Vector2)(ref val2))..ctor(Vector3.Dot(val, axisA), Vector3.Dot(val, axisB)); min = Vector2.Min(min, val2); max = Vector2.Max(max, val2); } } } } namespace RepoValuableParry.Destruction { internal static class ValuableSacrifice { public static SacrificedValuableData Capture(ValuableObject valuable, PhysGrabObject phys) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_009f: 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_00a4: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00e8: Unknown result type (might be due to invalid IL or missing references) GameObject val = (((Object)(object)valuable != (Object)null) ? ((Component)valuable).gameObject : (((Object)(object)phys != (Object)null) ? ((Component)phys).gameObject : null)); Bounds bounds = ParryCapacityCalculator.CombineColliderBounds(val); return new SacrificedValuableData { Name = (((Object)(object)val != (Object)null) ? ((Object)val).name.Replace("(Clone)", "").Trim() : "Valuable"), DollarValue = GameAccess.GetDollarValue(valuable), Mass = ParryCapacityCalculator.GetMass(phys, valuable), Bounds = bounds, Position = (((Object)(object)val != (Object)null) ? val.transform.position : Vector3.zero), Rotation = (((Object)(object)val != (Object)null) ? val.transform.rotation : Quaternion.identity), Scale = (((Object)(object)val != (Object)null) ? val.transform.lossyScale : Vector3.one) }; } public static void DestroyVanilla(ValuableObject valuable, PhysGrabObject phys) { if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } PhysGrabObjectImpactDetector val = (((Object)(object)phys != (Object)null) ? ((Component)phys).GetComponent() : (((Object)(object)valuable != (Object)null) ? ((Component)valuable).GetComponent() : null)); if ((Object)(object)val == (Object)null) { if ((Object)(object)phys != (Object)null) { Object.Destroy((Object)(object)((Component)phys).gameObject); } else if ((Object)(object)valuable != (Object)null) { Object.Destroy((Object)(object)((Component)valuable).gameObject); } Plugin.LogWarning("Valuable had no PhysGrabObjectImpactDetector; used fallback destroy."); } else { val.destroyDisable = false; val.DestroyObject(true); } } } } namespace RepoValuableParry.DebugTools { internal sealed class DebugCommands : MonoBehaviour { } internal sealed class DebugGizmos : MonoBehaviour { private LineRenderer _attack; private LineRenderer _knockEnemy; private LineRenderer _knockPlayer; private GameObject _boundsBox; private GameObject _contact; private void Awake() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Expected O, but got Unknown //IL_01c5: Unknown result type (might be due to invalid IL or missing references) _attack = MakeLine("AttackLine", new Color(1f, 0.15f, 0.15f, 0.95f), 0.02f); _knockEnemy = MakeLine("EnemyKnock", new Color(0.25f, 0.45f, 1f, 0.95f), 0.025f); _knockPlayer = MakeLine("PlayerKnock", new Color(0.25f, 0.45f, 1f, 0.95f), 0.025f); _boundsBox = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)_boundsBox).name = "ValuableBounds"; _boundsBox.transform.SetParent(((Component)this).transform, false); Object.Destroy((Object)(object)_boundsBox.GetComponent()); MeshRenderer component = _boundsBox.GetComponent(); Material val = new Material(Shader.Find("Sprites/Default") ?? Shader.Find("Hidden/InternalErrorShader")); val.color = new Color(0.15f, 1f, 0.25f, 0.18f); ((Renderer)component).material = val; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; _contact = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)_contact).name = "Contact"; _contact.transform.SetParent(((Component)this).transform, false); _contact.transform.localScale = Vector3.one * 0.12f; Object.Destroy((Object)(object)_contact.GetComponent()); MeshRenderer component2 = _contact.GetComponent(); Material val2 = new Material(Shader.Find("Sprites/Default") ?? Shader.Find("Hidden/InternalErrorShader")); val2.color = new Color(1f, 0.92f, 0.15f, 0.9f); ((Renderer)component2).material = val2; SetVisible(visible: false); } private void LateUpdate() { //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) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00c9: 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_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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_0118: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: 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_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) if ((!ParryConfig.DebugGizmos.Value && !ParryConfig.DebugOverlay.Value) || (Object)(object)ParryManager.Instance == (Object)null) { SetVisible(visible: false); return; } ParryContext lastContext = ParryManager.Instance.LastContext; AttackData lastAttack = ParryManager.Instance.LastAttack; ValuableStats lastStats = ParryManager.Instance.LastStats; if (!((Object)(object)lastAttack.Collider != (Object)null) && !(lastAttack.Origin != Vector3.zero) && lastContext == null) { SetVisible(visible: false); return; } SetVisible(visible: true); Vector3 val = lastContext?.AttackOrigin ?? lastAttack.Origin; Vector3 val2 = lastContext?.ContactPoint ?? lastAttack.ContactPoint; Vector3 b = ((lastContext != null && (Object)(object)lastContext.Player != (Object)null) ? ((Component)lastContext.Player).transform.position : (((Object)(object)SemiFunc.PlayerGetLocal() != (Object)null) ? ((Component)SemiFunc.PlayerGetLocal()).transform.position : val)); Vector3 b2 = ((lastContext != null && (Object)(object)lastContext.Enemy != (Object)null) ? ((Component)lastContext.Enemy).transform.position : (val - Vector3.forward)); SetLine(_attack, val, b); Vector3 size = ((Bounds)(ref lastStats.Bounds)).size; if (((Vector3)(ref size)).sqrMagnitude > 0.0001f) { _boundsBox.transform.position = ((Bounds)(ref lastStats.Bounds)).center; _boundsBox.transform.rotation = Quaternion.identity; _boundsBox.transform.localScale = ((Bounds)(ref lastStats.Bounds)).size; } _contact.transform.position = ((val2 == Vector3.zero) ? ((Bounds)(ref lastStats.Bounds)).center : val2); if (lastContext != null) { SetLine(_knockEnemy, lastContext.ContactPoint, b2); SetLine(_knockPlayer, lastContext.ContactPoint, b); } } private void SetVisible(bool visible) { if ((Object)(object)_attack != (Object)null) { ((Renderer)_attack).enabled = visible; } if ((Object)(object)_knockEnemy != (Object)null) { ((Renderer)_knockEnemy).enabled = visible; } if ((Object)(object)_knockPlayer != (Object)null) { ((Renderer)_knockPlayer).enabled = visible; } if ((Object)(object)_boundsBox != (Object)null) { _boundsBox.SetActive(visible); } if ((Object)(object)_contact != (Object)null) { _contact.SetActive(visible); } } private static void SetLine(LineRenderer lr, Vector3 a, Vector3 b) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)lr == (Object)null)) { lr.positionCount = 2; lr.SetPosition(0, a); lr.SetPosition(1, b); } } private LineRenderer MakeLine(string name, Color color, float width) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(((Component)this).transform, false); LineRenderer obj = val.AddComponent(); obj.useWorldSpace = true; obj.positionCount = 2; obj.widthMultiplier = width; Material val2 = new Material(Shader.Find("Sprites/Default") ?? Shader.Find("Hidden/InternalErrorShader")); val2.color = color; ((Renderer)obj).material = val2; obj.startColor = color; obj.endColor = color; return obj; } } internal sealed class ParryDebugOverlay : MonoBehaviour { private GUIStyle _box; private GUIStyle _label; private GUIStyle _title; private void OnGUI() { //IL_004f: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_02ef: Unknown result type (might be due to invalid IL or missing references) if (ParryConfig.DebugOverlay != null && ParryConfig.DebugOverlay.Value && !((Object)(object)ParryManager.Instance == (Object)null)) { EnsureStyles(); ParryManager instance = ParryManager.Instance; ValuableStats lastStats = instance.LastStats; AttackData lastAttack = instance.LastAttack; GUI.Box(new Rect(16f, 16f, 340f, 280f), GUIContent.none, _box); float num = 24f; GUI.Label(new Rect(28f, num, 300f, 22f), "VALUABLE PARRY", _title); num += 26f; GUI.Label(new Rect(28f, num, 300f, 20f), "Valuable: " + (string.IsNullOrEmpty(lastStats.Name) ? "-" : lastStats.Name), _label); num += 18f; GUI.Label(new Rect(28f, num, 300f, 20f), $"Mass: {lastStats.Mass:0.00} Area: {lastStats.ProjectedArea:0.00}", _label); num += 18f; GUI.Label(new Rect(28f, num, 300f, 20f), $"Coverage: {lastStats.Coverage:P0} Capacity: {lastStats.Capacity:0.0}", _label); num += 18f; GUI.Label(new Rect(28f, num, 300f, 20f), $"Dollar value (not used): {lastStats.DollarValue:0}", _label); num += 26f; GUI.Label(new Rect(28f, num, 300f, 20f), "Enemy: " + instance.LastEnemyName, _label); num += 18f; GUI.Label(new Rect(28f, num, 300f, 20f), $"Damage: {lastAttack.PlayerDamage} Hit Force: {lastAttack.PhysHitForce:0.00}", _label); num += 18f; GUI.Label(new Rect(28f, num, 300f, 20f), $"Tumble Force: {lastAttack.PlayerTumbleForce:0.00}", _label); num += 18f; GUI.Label(new Rect(28f, num, 300f, 20f), $"Attack Energy: {lastAttack.Energy:0.0}", _label); num += 26f; string text = (instance.LastWouldParry ? "PARRY POSSIBLE / CAPTURED" : ("NO PARRY (" + instance.LastReject.ToString() + ")")); GUI.Label(new Rect(28f, num, 300f, 22f), text, _title); } } private void EnsureStyles() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0029: 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) //IL_003b: Expected O, but got Unknown //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown if (_box == null) { _box = new GUIStyle(GUI.skin.box); _label = new GUIStyle(GUI.skin.label) { fontSize = 13 }; _title = new GUIStyle(GUI.skin.label) { fontSize = 14, fontStyle = (FontStyle)1 }; } } } } namespace RepoValuableParry.Core { internal static class GameAccess { private static readonly FieldRef DollarValueCurrent = AccessTools.FieldRefAccess("dollarValueCurrent"); private static readonly FieldRef Tumble = AccessTools.FieldRefAccess("tumble"); private static readonly FieldRef IsLocal = AccessTools.FieldRefAccess("isLocal"); private static readonly FieldRef GrabbedPhys = AccessTools.FieldRefAccess("grabbedPhysGrabObject"); private static readonly FieldRef EnemyRb = AccessTools.FieldRefAccess("Rigidbody"); private static readonly FieldRef HasRb = AccessTools.FieldRefAccess("HasRigidbody"); private static readonly FieldRef Health = AccessTools.FieldRefAccess("Health"); private static readonly FieldRef HasHealth = AccessTools.FieldRefAccess("HasHealth"); private static readonly FieldRef Stunned = AccessTools.FieldRefAccess("StateStunned"); private static readonly FieldRef HasStunned = AccessTools.FieldRefAccess("HasStateStunned"); private static readonly FieldRef ErbRb = AccessTools.FieldRefAccess("rb"); private static readonly FieldRef DetectorValuable = AccessTools.FieldRefAccess("valuableObject"); private static readonly FieldRef HealthCurrent = AccessTools.FieldRefAccess("health"); public static float GetDollarValue(ValuableObject valuable) { if ((Object)(object)valuable == (Object)null) { return 0f; } try { return DollarValueCurrent.Invoke(valuable); } catch { return 0f; } } public static PlayerTumble GetTumble(PlayerAvatar player) { if ((Object)(object)player == (Object)null) { return null; } try { PlayerTumble val = Tumble.Invoke(player); if ((Object)(object)val != (Object)null) { return val; } } catch { } return ((Component)player).GetComponentInChildren(); } public static bool IsLocalPlayer(PlayerAvatar player) { if ((Object)(object)player == (Object)null) { return false; } PlayerAvatar val = SemiFunc.PlayerGetLocal(); if ((Object)(object)val != (Object)null) { return (Object)(object)player == (Object)(object)val; } try { return IsLocal.Invoke(player); } catch { return false; } } public static PhysGrabObject GetGrabbed(PhysGrabber grabber) { if ((Object)(object)grabber == (Object)null) { return null; } PhysGrabObject val = SemiFunc.PhysGrabberGetGrabbedPhysGrabObject(grabber); if ((Object)(object)val != (Object)null) { return val; } try { return GrabbedPhys.Invoke(grabber); } catch { return null; } } public static bool EnemyHasRigidbody(Enemy enemy) { if ((Object)(object)enemy == (Object)null) { return false; } try { return HasRb.Invoke(enemy) && (Object)(object)EnemyRb.Invoke(enemy) != (Object)null; } catch { return (Object)(object)((Component)enemy).GetComponentInChildren() != (Object)null; } } public static EnemyRigidbody GetEnemyRigidbody(Enemy enemy) { if ((Object)(object)enemy == (Object)null) { return null; } try { EnemyRigidbody val = EnemyRb.Invoke(enemy); if ((Object)(object)val != (Object)null) { return val; } } catch { } return ((Component)enemy).GetComponentInChildren(); } public static Rigidbody GetRigidbody(EnemyRigidbody enemyRb) { if ((Object)(object)enemyRb == (Object)null) { return null; } try { Rigidbody val = ErbRb.Invoke(enemyRb); if ((Object)(object)val != (Object)null) { return val; } } catch { } return ((Component)enemyRb).GetComponent(); } public static EnemyHealth GetHealth(Enemy enemy) { if ((Object)(object)enemy == (Object)null) { return null; } try { if (!HasHealth.Invoke(enemy)) { return null; } return Health.Invoke(enemy); } catch { return ((Component)enemy).GetComponent(); } } public static void TryStun(Enemy enemy, float duration) { if ((Object)(object)enemy == (Object)null) { return; } try { if (HasStunned.Invoke(enemy)) { EnemyStateStunned val = Stunned.Invoke(enemy); if (!((Object)(object)val == (Object)null)) { AccessTools.Method(typeof(EnemyStateStunned), "Set", new Type[1] { typeof(float) }, (Type[])null)?.Invoke(val, new object[1] { duration }); } } } catch { } } public static int GetPlayerHealth(PlayerAvatar player) { if ((Object)(object)player == (Object)null || (Object)(object)player.playerHealth == (Object)null) { return 0; } try { return HealthCurrent.Invoke(player.playerHealth); } catch { return 1; } } public static ValuableObject GetValuableFromDetector(PhysGrabObjectImpactDetector detector) { if ((Object)(object)detector == (Object)null) { return null; } try { return DetectorValuable.Invoke(detector); } catch { return ((Component)detector).GetComponent(); } } } public sealed class ParryContext { public PlayerAvatar Player; public PhysGrabObject PhysObject; public ValuableObject Valuable; public HurtCollider AttackCollider; public Enemy Enemy; public Vector3 AttackOrigin; public Vector3 AttackDirection; public Vector3 ContactPoint; public float AttackEnergy; public float ValuableCapacity; public float ExplosionForce; public float ExplosionRadius; public int SequenceId; public int EffectSeed; public ValuableStats Stats; public AttackData Attack; public SacrificedValuableData Sacrificed; public bool Captured; public bool ValuableLocked; public IParryAttackAdapter Adapter; } public sealed class ParryIntent { public PlayerAvatar Player; public PhysGrabObject PhysObject; public ValuableObject Valuable; public float CreatedAt; public float ExpiresAt; public int SequenceHint; public bool IsExpired => Time.time > ExpiresAt; public bool StillHoldsSameObject() { if ((Object)(object)Player == (Object)null || (Object)(object)PhysObject == (Object)null || PhysObject.dead) { return false; } PhysGrabber physGrabber = Player.physGrabber; if ((Object)(object)physGrabber == (Object)null || !physGrabber.grabbed) { return false; } return (Object)(object)GameAccess.GetGrabbed(physGrabber) == (Object)(object)PhysObject; } } public sealed class ParryManager : MonoBehaviour { private readonly Dictionary _intents = new Dictionary(); private readonly Dictionary _consumedUntil = new Dictionary(); private readonly HashSet _lockedValuables = new HashSet(); private readonly List _scratchIds = new List(); private float _nextSustainScan; private int _nextSequence = 1; public static ParryManager Instance { get; private set; } public ParryRejectReason LastReject { get; private set; } public ParryContext LastContext { get; private set; } public ValuableStats LastStats { get; private set; } public AttackData LastAttack { get; private set; } public string LastEnemyName { get; private set; } = "-"; public bool LastWouldParry { get; private set; } public static void Ensure() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Instance != (Object)null)) { GameObject val = new GameObject("ValuableParryManager"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; Instance = val.AddComponent(); } } private void Update() { if (ParryConfig.Enabled.Value) { ExpireConsumed(); SustainIntentWhileTouching(); ExpireIntents(); if (ParryInput.WasParryPressed()) { TryCreateLocalIntent(); } } } private void SustainIntentWhileTouching() { //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) if (_intents.Count == 0) { return; } PlayerAvatar val = SemiFunc.PlayerGetLocal(); if ((Object)(object)val == (Object)null || !_intents.TryGetValue(val, out var value) || value == null || !value.StillHoldsSameObject() || Time.time < _nextSustainScan) { return; } _nextSustainScan = Time.time + 0.08f; Vector3 playerBodyPoint = GenericMeleeAdapter.GetPlayerBodyPoint(val); HurtCollider[] array = Object.FindObjectsOfType(); foreach (HurtCollider val2 in array) { if ((Object)(object)val2 == (Object)null || !((Behaviour)val2).isActiveAndEnabled || AttackDetector.FindAdapter(val2) == null) { continue; } Collider component = ((Component)val2).GetComponent(); if (!((Object)(object)component == (Object)null)) { Bounds bounds = component.bounds; if (!(((Bounds)(ref bounds)).SqrDistance(playerBodyPoint) > 6.25f)) { value.ExpiresAt = Mathf.Max(value.ExpiresAt, Time.time + 0.2f); break; } } } } private void TryCreateLocalIntent() { PlayerAvatar val = SemiFunc.PlayerGetLocal(); if ((Object)(object)val == (Object)null) { Reject(ParryRejectReason.WrongPlayer, null); return; } if (!HeldValuableDetector.TryGetHeldValuable(val, out var phys, out var valuable, out var reject)) { Reject(reject, null); Plugin.LogVerbose("Parry intent rejected: " + reject); return; } ParryIntent value = new ParryIntent { Player = val, PhysObject = phys, Valuable = valuable, CreatedAt = Time.time, ExpiresAt = Time.time + ParryConfig.ParryWindow.Value, SequenceHint = _nextSequence }; _intents[val] = value; LastReject = ParryRejectReason.None; Plugin.Log("Parry intent created valuable=" + ((Object)((Component)phys).gameObject).name.Replace("(Clone)", "").Trim()); TryInterceptNearbyAttacks(val); } private void TryInterceptNearbyAttacks(PlayerAvatar player) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0052: Unknown result type (might be due to invalid IL or missing references) HurtCollider[] array = Object.FindObjectsOfType(); Vector3 playerBodyPoint = GenericMeleeAdapter.GetPlayerBodyPoint(player); HurtCollider[] array2 = array; foreach (HurtCollider val in array2) { if (!((Object)(object)val == (Object)null) && ((Behaviour)val).isActiveAndEnabled) { IParryAttackAdapter parryAttackAdapter = AttackDetector.FindAdapter(val); if (parryAttackAdapter != null && (!(Vector3.Distance(parryAttackAdapter.GetAttackOrigin(val), playerBodyPoint) > 18f) || !(Vector3.Distance(((Component)val).transform.position, playerBodyPoint) > 8f)) && TryInterceptAttack(val, player)) { break; } } } } public bool IsAttackConsumed(HurtCollider collider) { if ((Object)(object)collider == (Object)null) { return false; } int instanceID = ((Object)collider).GetInstanceID(); if (_consumedUntil.TryGetValue(instanceID, out var value)) { return Time.time < value; } return false; } public bool TryInterceptAttack(HurtCollider collider, PlayerAvatar player) { //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_019f: 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_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0164: 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_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f6: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0276: 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_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0322: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_044d: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_0455: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_045d: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_04d7: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) LastWouldParry = false; if (!ParryConfig.Enabled.Value) { return false; } if ((Object)(object)player == (Object)null || (Object)(object)collider == (Object)null) { return false; } if (!GameAccess.IsLocalPlayer(player)) { return false; } if (GameAccess.GetPlayerHealth(player) <= 0) { Reject(ParryRejectReason.PlayerDead, null); return false; } if (IsAttackConsumed(collider)) { Reject(ParryRejectReason.AttackAlreadyConsumed, null); return false; } if (!_intents.TryGetValue(player, out var value) || value == null) { Reject(ParryRejectReason.NoIntent, null); return false; } if (value.IsExpired) { _intents.Remove(player); Reject(ParryRejectReason.IntentExpired, null); return false; } if (!value.StillHoldsSameObject()) { Reject(((Object)(object)value.PhysObject == (Object)null) ? ParryRejectReason.NoHeldObject : ParryRejectReason.HeldObjectChanged, null); _intents.Remove(player); return false; } IParryAttackAdapter parryAttackAdapter = AttackDetector.FindAdapter(collider); if (parryAttackAdapter == null || !parryAttackAdapter.IsAttackActive(collider)) { Reject(ParryRejectReason.UnsupportedAttack, SnapshotAttack(collider, parryAttackAdapter, player)); return false; } Enemy enemy = parryAttackAdapter.GetEnemy(collider); if ((Object)(object)enemy == (Object)null) { Reject(ParryRejectReason.NoEnemySource, SnapshotAttack(collider, parryAttackAdapter, player)); return false; } Vector3 attackOrigin = parryAttackAdapter.GetAttackOrigin(collider); Vector3 attackDirection = parryAttackAdapter.GetAttackDirection(collider, player); Vector3 playerBodyPoint = GenericMeleeAdapter.GetPlayerBodyPoint(player); ValuableStats valuableStats = (LastStats = ParryCapacityCalculator.Evaluate(value.Valuable, value.PhysObject, attackDirection)); LastEnemyName = EnemyDisplayName(enemy); if (_lockedValuables.Contains(((Object)value.PhysObject).GetInstanceID())) { Reject(ParryRejectReason.AttackAlreadyConsumed, SnapshotAttack(collider, parryAttackAdapter, player)); return false; } if (!((parryAttackAdapter is GenericMeleeAdapter genericMeleeAdapter) ? genericMeleeAdapter.IsValuableBlocking(collider, valuableStats.Bounds, player, out var coverage, out var contactPoint) : ValuableCoverageDetector.CoversPlayer(valuableStats.Bounds, attackOrigin, playerBodyPoint, out coverage, out contactPoint))) { valuableStats.Coverage = coverage; LastStats = valuableStats; Reject(ParryRejectReason.NotCoveringPlayer, SnapshotAttack(collider, parryAttackAdapter, player, attackOrigin, attackDirection, contactPoint)); Plugin.LogVerbose($"NotCovering enemy={LastEnemyName} type={parryAttackAdapter.GetAttackType(collider)} " + $"origin={attackOrigin} body={playerBodyPoint} valuable={((Bounds)(ref valuableStats.Bounds)).center} " + $"size={((Bounds)(ref valuableStats.Bounds)).size} coverage={coverage:P0}"); return false; } valuableStats.Coverage = coverage; LastStats = valuableStats; if (!valuableStats.MeetsMinimumSize) { Reject(ParryRejectReason.TooSmall, SnapshotAttack(collider, parryAttackAdapter, player, attackOrigin, attackDirection, contactPoint)); Plugin.LogVerbose($"TooSmall area={valuableStats.ProjectedArea:0.000} min={ParryConfig.MinimumArea.Value:0.000}"); return false; } float attackEnergy = parryAttackAdapter.GetAttackEnergy(collider); AttackEnergyCalculator.GetRaw(collider, out var damage, out var force, out var tumble); if (valuableStats.Capacity < attackEnergy) { Reject(ParryRejectReason.InsufficientCapacity, SnapshotAttack(collider, parryAttackAdapter, player, attackOrigin, attackDirection, contactPoint, attackEnergy)); Plugin.LogVerbose($"Capacity {valuableStats.Capacity:0.0} < energy {attackEnergy:0.0} " + $"(dmg={damage:0} force={force:0.0} tumble={tumble:0.0} " + $"area={valuableStats.ProjectedArea:0.00} mass={valuableStats.Mass:0.00})"); return false; } AttackEnergyCalculator.ScaleExplosion(attackEnergy, out var force2, out var radius); ParryContext parryContext = new ParryContext { Player = player, PhysObject = value.PhysObject, Valuable = value.Valuable, AttackCollider = collider, Enemy = enemy, AttackOrigin = attackOrigin, AttackDirection = attackDirection, ContactPoint = contactPoint, AttackEnergy = attackEnergy, ValuableCapacity = valuableStats.Capacity, ExplosionForce = force2, ExplosionRadius = radius, SequenceId = _nextSequence++, EffectSeed = Random.Range(1, int.MaxValue), Stats = valuableStats, Adapter = parryAttackAdapter, Captured = true, ValuableLocked = true, Attack = SnapshotAttack(collider, parryAttackAdapter, player, attackOrigin, attackDirection, contactPoint, attackEnergy) }; LastAttack = parryContext.Attack; LastContext = parryContext; LastReject = ParryRejectReason.None; LastWouldParry = true; _intents.Remove(player); BeginParry(parryContext); return true; } public void ReceiveRemoteParryStart(ParryEvent evt) { //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_0071: Unknown result type (might be due to invalid IL or missing references) if (LastContext == null || LastContext.SequenceId != evt.SequenceId) { Vector3 contactPoint = evt.ContactPoint; float num = Mathf.Clamp01(evt.AttackEnergy / Mathf.Max(1f, ParryConfig.MaxAttackEnergy.Value)); num = Mathf.Lerp(0.6f, 1.4f, num) * ParryConfig.EffectsIntensity.Value; AttackEnergyCalculator.ScaleExplosion(evt.AttackEnergy, out var _, out var radius); ((MonoBehaviour)this).StartCoroutine(PlayRemoteVisuals(contactPoint, radius, num)); } } private IEnumerator PlayRemoteVisuals(Vector3 pos, float radius, float intensity) { //IL_0007: 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) ParryEffectController.PlayCapture(pos, intensity); GameObject fx = ParryEffectController.PlayAbsorption(pos, null, intensity, ParryConfig.AbsorptionDuration.Value); yield return (object)new WaitForSeconds(ParryConfig.FreezeDuration.Value); ParryEffectController.PlayOverload(pos, intensity); yield return (object)new WaitForSeconds(ParryConfig.OverloadDuration.Value); ParryEffectController.PlayDetonation(pos, radius, intensity); if ((Object)(object)fx != (Object)null) { Object.Destroy((Object)(object)fx); } } private void BeginParry(ParryContext context) { MarkConsumed(context.AttackCollider); if ((Object)(object)context.PhysObject != (Object)null) { _lockedValuables.Add(((Object)context.PhysObject).GetInstanceID()); } context.Adapter?.ConsumeAttack(context.AttackCollider); Plugin.Log($"PARRY captured enemy={LastEnemyName} dmg={context.Attack.PlayerDamage} " + $"force={context.Attack.PhysHitForce:0.00} tumble={context.Attack.PlayerTumbleForce:0.00} " + $"energy={context.AttackEnergy:0.0} valuable={context.Stats.Name} " + $"mass={context.Stats.Mass:0.00} area={context.Stats.ProjectedArea:0.00} " + $"coverage={context.Stats.Coverage:P0} capacity={context.Stats.Capacity:0.0}"); if (SemiFunc.IsMasterClientOrSingleplayer()) { ParryNetworkManager.BroadcastParryStart(context); } else { ParryNetworkManager.SendCommitToHost(context); } ((MonoBehaviour)this).StartCoroutine(RunSequence(context, SemiFunc.IsMasterClientOrSingleplayer())); } public void HostCommitParry(int playerViewId, int enemyViewId, int valuableViewId, float energy, Vector3 contact, int seed) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar player = FindPlayer(playerViewId); Enemy val = FindEnemy(enemyViewId); PhysGrabObject val2 = FindPhys(valuableViewId); ValuableObject valuable = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent() : null); AttackEnergyCalculator.ScaleExplosion(energy, out var force, out var radius); ParryContext context = new ParryContext { Player = player, PhysObject = val2, Valuable = valuable, Enemy = val, ContactPoint = contact, AttackEnergy = energy, ExplosionForce = force, ExplosionRadius = radius, SequenceId = _nextSequence++, EffectSeed = seed, Adapter = new GenericMeleeAdapter() }; if ((Object)(object)val2 != (Object)null) { _lockedValuables.Add(((Object)val2).GetInstanceID()); } if ((Object)(object)val != (Object)null) { HurtCollider componentInChildren = ((Component)val).GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { MarkConsumed(componentInChildren); ((Behaviour)componentInChildren).enabled = false; } } ParryNetworkManager.BroadcastParryStart(context); ((MonoBehaviour)this).StartCoroutine(RunSequence(context, applyWorldState: true, playLocalFx: false)); } private IEnumerator RunSequence(ParryContext context, bool applyWorldState, bool playLocalFx = true) { float intensity = ExplosionIntensity(context.AttackEnergy); Transform valuableTransform = (((Object)(object)context.PhysObject != (Object)null) ? ((Component)context.PhysObject).transform : null); if (applyWorldState) { FreezeParticipants(context); } GameObject absorption = null; if (playLocalFx) { ParryEffectController.PlayCapture(context.ContactPoint, intensity); yield return (object)new WaitForSeconds(0.02f); absorption = ParryEffectController.PlayAbsorption(context.ContactPoint, valuableTransform, intensity, ParryConfig.AbsorptionDuration.Value); } yield return (object)new WaitForSeconds(Mathf.Max(0.02f, ParryConfig.FreezeDuration.Value - 0.05f)); if (playLocalFx) { ParryEffectController.PlayOverload(context.ContactPoint, intensity); yield return (object)new WaitForSeconds(ParryConfig.OverloadDuration.Value); } else { yield return (object)new WaitForSeconds(ParryConfig.OverloadDuration.Value); } Vector3 val = (((Object)(object)context.PhysObject != (Object)null) ? context.PhysObject.centerPoint : context.ContactPoint); if (applyWorldState) { context.Sacrificed = ValuableSacrifice.Capture(context.Valuable, context.PhysObject); ValuableSacrifice.DestroyVanilla(context.Valuable, context.PhysObject); } if (playLocalFx) { ParryEffectController.PlayDetonation(val, context.ExplosionRadius, intensity); } ApplyKnockback(context, val, applyWorldState); if (applyWorldState) { context.Adapter?.ApplyPostParryReaction(context.Enemy); } if ((Object)(object)absorption != (Object)null) { Object.Destroy((Object)(object)absorption, 0.2f); } if ((Object)(object)context.PhysObject != (Object)null) { _lockedValuables.Remove(((Object)context.PhysObject).GetInstanceID()); } } private void FreezeParticipants(ParryContext context) { //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) float num = ParryConfig.FreezeDuration.Value + ParryConfig.OverloadDuration.Value; context.Adapter?.FreezeAttack(context.AttackCollider, context.Enemy, num); if ((Object)(object)context.PhysObject != (Object)null) { context.PhysObject.FreezeForces(num, Vector3.zero, Vector3.zero); } } private void ApplyKnockback(ParryContext context, Vector3 detonation, bool applyEnemy) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)context.Player != (Object)null && GameAccess.IsLocalPlayer(context.Player)) { PlayerTumble tumble = GameAccess.GetTumble(context.Player); if ((Object)(object)tumble != (Object)null) { tumble.TumbleRequest(true, false); tumble.TumbleOverrideTime(ParryConfig.PlayerTumbleTime.Value); Vector3 position = ((Component)context.Player).transform.position; tumble.TumbleForce(KnockbackCalculator.PlayerForce(detonation, position, context.ExplosionForce)); } } if (!applyEnemy || (Object)(object)context.Enemy == (Object)null || !GameAccess.EnemyHasRigidbody(context.Enemy)) { return; } EnemyRigidbody enemyRigidbody = GameAccess.GetEnemyRigidbody(context.Enemy); Vector3 enemyPosition = (((Object)(object)enemyRigidbody != (Object)null) ? ((Component)enemyRigidbody).transform.position : ((Component)context.Enemy).transform.position); Vector3 val = KnockbackCalculator.EnemyForce(detonation, enemyPosition, context.ExplosionForce) * 2.2f; Vector3 val2 = Vector3.Cross(((Vector3)(ref val)).normalized, Vector3.up) * context.ExplosionForce * 0.6f; AccessTools.Field(typeof(Enemy), "FreezeTimer")?.SetValue(context.Enemy, 0f); if ((Object)(object)enemyRigidbody != (Object)null) { enemyRigidbody.FreezeForces(val, val2); } Rigidbody rigidbody = GameAccess.GetRigidbody(enemyRigidbody); if ((Object)(object)rigidbody != (Object)null && !rigidbody.isKinematic) { rigidbody.velocity = Vector3.zero; rigidbody.AddForce(val, (ForceMode)1); rigidbody.AddTorque(val2, (ForceMode)1); } int value = ParryConfig.EnemyDirectDamage.Value; if (value > 0) { EnemyHealth health = GameAccess.GetHealth(context.Enemy); if (health != null) { health.Hurt(value, ((Vector3)(ref val)).normalized); } } } private static string EnemyDisplayName(Enemy enemy) { if ((Object)(object)enemy == (Object)null) { return "-"; } EnemyParent componentInParent = ((Component)enemy).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && !string.IsNullOrEmpty(componentInParent.enemyName)) { return componentInParent.enemyName; } return ((Object)((Component)enemy).gameObject).name.Replace("(Clone)", "").Trim(); } private static PlayerAvatar FindPlayer(int viewId) { if (viewId == 0) { return null; } PhotonView val = PhotonView.Find(viewId); if (!((Object)(object)val != (Object)null)) { return null; } return ((Component)val).GetComponent(); } private static Enemy FindEnemy(int viewId) { if (viewId == 0) { return null; } PhotonView val = PhotonView.Find(viewId); if (!((Object)(object)val != (Object)null)) { return null; } return ((Component)val).GetComponent(); } private static PhysGrabObject FindPhys(int viewId) { if (viewId == 0) { return null; } PhotonView val = PhotonView.Find(viewId); if (!((Object)(object)val != (Object)null)) { return null; } return ((Component)val).GetComponent(); } private AttackData SnapshotAttack(HurtCollider collider, IParryAttackAdapter adapter, PlayerAvatar player, Vector3 origin = default(Vector3), Vector3 direction = default(Vector3), Vector3 contact = default(Vector3), float energy = -1f) { //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0076: 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_0066: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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) if ((Object)(object)collider == (Object)null) { return default(AttackData); } return LastAttack = new AttackData { ColliderId = ((Object)collider).GetInstanceID(), Collider = collider, Enemy = ((adapter != null) ? adapter.GetEnemy(collider) : collider.enemyHost), Origin = ((origin == default(Vector3) && adapter != null) ? adapter.GetAttackOrigin(collider) : origin), Direction = ((direction == default(Vector3) && adapter != null) ? adapter.GetAttackDirection(collider, player) : direction), ContactPoint = contact, Energy = ((energy >= 0f) ? energy : (adapter?.GetAttackEnergy(collider) ?? AttackEnergyCalculator.Compute(collider))), PlayerDamage = collider.playerDamage, PhysHitForce = Mathf.Max(collider.physHitForce, collider.playerHitForce), PlayerTumbleForce = collider.playerTumbleForce, AttackType = (adapter?.GetAttackType(collider) ?? ParryAttackType.Melee) }; } private void MarkConsumed(HurtCollider collider) { if (!((Object)(object)collider == (Object)null)) { _consumedUntil[((Object)collider).GetInstanceID()] = Time.time + 1.6f; } } private void ExpireConsumed() { if (_consumedUntil.Count == 0) { return; } _scratchIds.Clear(); foreach (KeyValuePair item in _consumedUntil) { if (Time.time >= item.Value) { _scratchIds.Add(item.Key); } } foreach (int scratchId in _scratchIds) { _consumedUntil.Remove(scratchId); } } private void ExpireIntents() { if (_intents.Count == 0) { return; } _scratchIds.Clear(); PlayerAvatar val = null; foreach (KeyValuePair intent in _intents) { if (intent.Value == null || intent.Value.IsExpired) { val = intent.Key; break; } } if ((Object)(object)val != (Object)null) { _intents.Remove(val); } } private void Reject(ParryRejectReason reason, AttackData? attack) { LastReject = reason; LastWouldParry = false; if (attack.HasValue) { LastAttack = attack.Value; } if (ParryConfig.VerboseLogs.Value && reason != ParryRejectReason.NoIntent) { Plugin.LogVerbose("Parry rejected: " + reason); } } private static float ExplosionIntensity(float energy) { float value = ParryConfig.MinAttackEnergy.Value; float num = Mathf.Max(value + 0.01f, ParryConfig.MaxAttackEnergy.Value); float num2 = Mathf.Clamp01((energy - value) / (num - value)); return Mathf.Lerp(0.65f, 1.45f, Mathf.Sqrt(num2)) * ParryConfig.EffectsIntensity.Value; } } public enum ParryRejectReason { None, NoIntent, IntentExpired, NoHeldObject, HeldObjectChanged, NotValuable, UnsupportedAttack, NoEnemySource, NotCoveringPlayer, TooSmall, InsufficientCapacity, AttackAlreadyConsumed, NetworkAuthority, ModDisabled, PlayerDead, WrongPlayer } public enum ParryAttackType { Melee, Charge, Bite, BodySlam, Grab, Projectile, Explosion, Environmental, Special } public struct ValuableStats { public string Name; public float Mass; public float DollarValue; public Bounds Bounds; public float ProjectedArea; public float Coverage; public float Capacity; public bool MeetsMinimumSize; } public struct SacrificedValuableData { public string Name; public float DollarValue; public float Mass; public Bounds Bounds; public Vector3 Position; public Quaternion Rotation; public Vector3 Scale; } public struct AttackData { public int ColliderId; public Enemy Enemy; public HurtCollider Collider; public Vector3 Origin; public Vector3 Direction; public Vector3 ContactPoint; public float Energy; public int PlayerDamage; public float PhysHitForce; public float PlayerTumbleForce; public ParryAttackType AttackType; } } namespace RepoValuableParry.Attacks { internal class GenericMeleeAdapter : IParryAttackAdapter { public virtual bool CanHandle(HurtCollider collider) { if ((Object)(object)collider == (Object)null) { return false; } if (!collider.playerLogic) { return false; } if (collider.deathPit) { return false; } if (collider.playerKill) { return false; } if ((Object)(object)collider.enemyHost == (Object)null) { return false; } if (collider.playerDamage <= 0 && collider.playerHitForce <= 0f && collider.playerTumbleForce <= 0f) { return false; } if (LooksLikeProjectile(collider)) { return false; } return true; } public virtual bool IsAttackActive(HurtCollider collider) { if ((Object)(object)collider != (Object)null && ((Behaviour)collider).isActiveAndEnabled) { return ((Component)collider).gameObject.activeInHierarchy; } return false; } public virtual Enemy GetEnemy(HurtCollider collider) { if ((Object)(object)collider == (Object)null) { return null; } if ((Object)(object)collider.enemyHost != (Object)null) { return collider.enemyHost; } return ((Component)collider).GetComponentInParent(); } public virtual Vector3 GetAttackOrigin(HurtCollider collider) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Enemy enemy = GetEnemy(collider); if ((Object)(object)enemy != (Object)null) { if ((Object)(object)enemy.CenterTransform != (Object)null) { return enemy.CenterTransform.position; } return ((Component)enemy).transform.position; } Collider component = ((Component)collider).GetComponent(); if ((Object)(object)component != (Object)null) { Bounds bounds = component.bounds; return ((Bounds)(ref bounds)).center; } return ((Component)collider).transform.position; } public virtual Vector3 GetAttackDirection(HurtCollider collider, PlayerAvatar target) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //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_0031: 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) //IL_002e: Unknown result type (might be due to invalid IL or missing references) Vector3 attackOrigin = GetAttackOrigin(collider); Vector3 val = GetPlayerBodyPoint(target) - attackOrigin; if (((Vector3)(ref val)).sqrMagnitude < 0.0001f) { val = ((Component)collider).transform.forward; } return ((Vector3)(ref val)).normalized; } public virtual bool IsValuableBlocking(HurtCollider collider, Bounds valuableBounds, PlayerAvatar player, out float coverage, out Vector3 contactPoint) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Vector3 attackOrigin = GetAttackOrigin(collider); Vector3 playerBodyPoint = GetPlayerBodyPoint(player); if (ValuableCoverageDetector.CoversPlayer(valuableBounds, attackOrigin, playerBodyPoint, out coverage, out contactPoint)) { return true; } if (Vector3.Distance(attackOrigin, ((Object)(object)player != (Object)null) ? ((Component)player).transform.position : playerBodyPoint) <= 3.8f) { return ValuableCoverageDetector.CoversContact(valuableBounds, attackOrigin, playerBodyPoint, out coverage, out contactPoint); } return false; } public virtual float GetAttackEnergy(HurtCollider collider) { return AttackEnergyCalculator.Compute(collider); } public virtual ParryAttackType GetAttackType(HurtCollider collider) { return ParryAttackType.Melee; } public virtual void FreezeAttack(HurtCollider collider, Enemy enemy, float duration) { if ((Object)(object)enemy != (Object)null) { enemy.Freeze(duration); } } public virtual void ConsumeAttack(HurtCollider collider) { if (!((Object)(object)collider == (Object)null)) { ((Behaviour)collider).enabled = false; } } public virtual void ApplyPostParryReaction(Enemy enemy) { GameAccess.TryStun(enemy, 0.45f); } public static Vector3 GetPlayerBodyPoint(PlayerAvatar player) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: 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) if ((Object)(object)player == (Object)null) { return Vector3.zero; } if ((Object)(object)player.PlayerVisionTarget != (Object)null && (Object)(object)player.PlayerVisionTarget.VisionTransform != (Object)null) { return player.PlayerVisionTarget.VisionTransform.position; } return ((Component)player).transform.position + Vector3.up * 1.1f; } private static bool LooksLikeProjectile(HurtCollider collider) { if (collider.hasTimer && collider.destroyOnTimerEnd) { return true; } if ((Object)(object)((Component)collider).GetComponentInParent() != (Object)null) { return true; } if ((Object)(object)((Component)collider).GetComponentInParent() != (Object)null) { return true; } return false; } } public interface IParryAttackAdapter { bool CanHandle(HurtCollider collider); bool IsAttackActive(HurtCollider collider); Enemy GetEnemy(HurtCollider collider); Vector3 GetAttackOrigin(HurtCollider collider); Vector3 GetAttackDirection(HurtCollider collider, PlayerAvatar target); float GetAttackEnergy(HurtCollider collider); ParryAttackType GetAttackType(HurtCollider collider); void FreezeAttack(HurtCollider collider, Enemy enemy, float duration); void ConsumeAttack(HurtCollider collider); void ApplyPostParryReaction(Enemy enemy); } } namespace RepoValuableParry.Attacks.EnemySpecific { internal sealed class BeamerAdapter : GenericMeleeAdapter { public override bool CanHandle(HurtCollider collider) { if ((Object)(object)collider == (Object)null || !collider.playerLogic || collider.deathPit || collider.playerKill) { return false; } return (Object)(object)FindBeamer(collider) != (Object)null; } public override ParryAttackType GetAttackType(HurtCollider collider) { return ParryAttackType.Projectile; } public override Vector3 GetAttackOrigin(HurtCollider collider) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) EnemyBeamer val = FindBeamer(collider); if ((Object)(object)val != (Object)null && (Object)(object)val.laserStartTransform != (Object)null) { return val.laserStartTransform.position; } return base.GetAttackOrigin(collider); } public override bool IsValuableBlocking(HurtCollider collider, Bounds valuableBounds, PlayerAvatar player, out float coverage, out Vector3 contactPoint) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: 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) return ValuableCoverageDetector.CoversBeam(collider, valuableBounds, GetAttackOrigin(collider), GenericMeleeAdapter.GetPlayerBodyPoint(player), out coverage, out contactPoint); } public override void ConsumeAttack(HurtCollider collider) { EnemyBeamer val = FindBeamer(collider); if ((Object)(object)val != (Object)null) { AccessTools.Method(typeof(EnemyBeamer), "UpdateState", new Type[1] { typeof(State) }, (Type[])null)?.Invoke(val, new object[1] { (object)(State)11 }); HurtCollider[] componentsInChildren = ((Component)val).GetComponentsInChildren(true); foreach (HurtCollider val2 in componentsInChildren) { if (!((Object)(object)val2 == (Object)null)) { ((Behaviour)val2).enabled = false; ((Component)val2).gameObject.SetActive(false); } } } if ((Object)(object)collider != (Object)null) { ((Behaviour)collider).enabled = false; ((Component)collider).gameObject.SetActive(false); } } public override void FreezeAttack(HurtCollider collider, Enemy enemy, float duration) { base.FreezeAttack(collider, enemy, duration); ConsumeAttack(collider); } public static EnemyBeamer FindBeamer(HurtCollider collider) { if ((Object)(object)collider == (Object)null) { return null; } EnemyBeamer componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null) { return componentInParent; } if ((Object)(object)collider.enemyHost != (Object)null) { return ((Component)collider.enemyHost).GetComponent() ?? ((Component)collider.enemyHost).GetComponentInParent() ?? ((Component)collider.enemyHost).GetComponentInChildren(); } return null; } } internal sealed class ReaperAdapter : GenericMeleeAdapter { public override bool CanHandle(HurtCollider collider) { if (!base.CanHandle(collider)) { return false; } return (Object)(object)((Component)collider).GetComponentInParent() != (Object)null; } public override ParryAttackType GetAttackType(HurtCollider collider) { return ParryAttackType.Melee; } public override Vector3 GetAttackOrigin(HurtCollider collider) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) EnemyRunner componentInParent = ((Component)collider).GetComponentInParent(); if ((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.hurtCollider != (Object)null) { Collider component = ((Component)componentInParent.hurtCollider).GetComponent(); if ((Object)(object)component != (Object)null) { Bounds bounds = component.bounds; return ((Bounds)(ref bounds)).center; } } return base.GetAttackOrigin(collider); } } internal sealed class TrudgeAdapter : GenericMeleeAdapter { public override bool CanHandle(HurtCollider collider) { if (!base.CanHandle(collider)) { return false; } return (Object)(object)((Component)collider).GetComponentInParent() != (Object)null; } public override ParryAttackType GetAttackType(HurtCollider collider) { if (!(collider.playerTumbleForce > 8f) && collider.playerDamage < 30) { return ParryAttackType.BodySlam; } return ParryAttackType.Charge; } } }