Decompiled source of GorePlus v1.1.5
Mods/GorePlus.dll
Decompiled 17 hours ago
The result has been truncated due to the large size, download it to view full contents!
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 System.Text; using BoneLib.BoneMenu; using GorePlus; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSLZ.Marrow; using Il2CppSLZ.Marrow.AI; using Il2CppSLZ.Marrow.Audio; using Il2CppSLZ.Marrow.Combat; using Il2CppSLZ.Marrow.Data; using Il2CppSLZ.Marrow.Interaction; using Il2CppSLZ.Marrow.Pool; using Il2CppSLZ.Marrow.PuppetMasta; using Il2CppSystem; using Il2CppSystem.Reflection; using LabFusion.Entities; using LabFusion.Network; using LabFusion.Network.Serialization; using LabFusion.SDK.Modules; using MelonLoader; using MelonLoader.Preferences; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: MelonInfo(typeof(Core), "Gore+", "1.1.5", "Zotryx", null)] [assembly: MelonGame("Stress Level Zero", "BONELAB")] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("GorePlus")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("GorePlus")] [assembly: AssemblyTitle("GorePlus")] [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 GorePlus { internal static class Blood { private class Splat { public GameObject go; public MeshRenderer mr; public MaterialPropertyBlock block; public Color color; public float born; public float fadeStart = -1f; public float life = -1f; public float fade = 6f; public bool opaque; public void SetAlpha(float a) { //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_0023: 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_0055: Unknown result type (might be due to invalid IL or missing references) if (!opaque) { Color val = color; val.a = a; block.SetColor("_Color", val); block.SetColor("_BaseColor", val); block.SetColor("_RendererColor", new Color(1f, 1f, 1f, a)); ((Renderer)mr).SetPropertyBlock(block); } } } private static readonly Color BloodColor = new Color(0.38f, 0.01f, 0.01f, 1f); private static readonly Color BloodColorDark = new Color(0.18f, 0f, 0f, 1f); private static Material _particleMat; private static Material _splatMat; private static Mesh _quad; private static bool _setupDone; private static readonly string[] ShaderCandidates = new string[5] { "Universal Render Pipeline/Particles/Unlit", "Universal Render Pipeline/Unlit", "Sprites/Default", "Unlit/Transparent Cutout", "Unlit/Texture" }; private static int _activeBleeders; private static float _burstWindowStart; private static int _burstsThisWindow; private static int _bursts; private static int _splatHits; private static int _splatMisses; private static readonly List<Splat> _splats = new List<Splat>(); private const float FadeSeconds = 6f; private static int MaxBleeders => Settings.MaxBleeders.Value; private static void EnsureSetup() { //IL_009b: 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) if (_setupDone && (Object)(object)_particleMat != (Object)null && (Object)(object)_splatMat != (Object)null) { return; } _setupDone = true; Shader val = null; string[] shaderCandidates = ShaderCandidates; foreach (string text in shaderCandidates) { val = Shader.Find(text); if ((Object)(object)val != (Object)null) { Core.Debug("Blood shader: " + text); break; } } if ((Object)(object)val == (Object)null) { Core.Log.Warning("No usable blood shader found; blood is disabled. Tell Claude what the log says."); return; } Texture2D tex = MakeBlobTexture(64, soft: true); Texture2D tex2 = MakeSplatTexture(128); _particleMat = MakeMaterial(val, tex, BloodColor); _splatMat = MakeMaterial(val, tex2, BloodColorDark); _splatMat.renderQueue = 2460; GameObject obj = GameObject.CreatePrimitive((PrimitiveType)5); _quad = obj.GetComponent<MeshFilter>().sharedMesh; Object.Destroy((Object)(object)obj); } private static Material MakeMaterial(Shader shader, Texture2D tex, Color color) { //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_000f: Expected O, but got Unknown //IL_0017: 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) Material val = new Material(shader) { hideFlags = (HideFlags)32 }; val.mainTexture = (Texture)(object)tex; val.color = color; if (val.HasProperty("_BaseMap")) { val.SetTexture("_BaseMap", (Texture)(object)tex); } if (val.HasProperty("_BaseColor")) { val.SetColor("_BaseColor", color); } if (val.HasProperty("_AlphaClip")) { val.SetFloat("_AlphaClip", 1f); } if (val.HasProperty("_Cutoff")) { val.SetFloat("_Cutoff", 0.4f); } val.EnableKeyword("_ALPHATEST_ON"); if (val.HasProperty("_Cull")) { val.SetFloat("_Cull", 0f); } val.renderQueue = 2450; return val; } private static Texture2D MakeBlobTexture(int size, bool soft) { //IL_0004: 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_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)32 }; float num = (float)size * 0.5f; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num2 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), new Vector2(num, num)) / num; float num3 = (soft ? Mathf.Clamp01(1f - num2 * num2) : ((num2 < 1f) ? 1f : 0f)); val.SetPixel(j, i, new Color(1f, 1f, 1f, num3)); } } val.Apply(); return val; } private static Texture2D MakeSplatTexture(int size) { //IL_0016: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(size, size, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1, hideFlags = (HideFlags)32 }; float[] alpha = new float[size * size]; Random random = new Random(1337); float num = (float)size * 0.5f; Stamp(num, num, (float)size * 0.28f); for (int i = 0; i < 14; i++) { float num2 = (float)(random.NextDouble() * 3.1415927410125732 * 2.0); float num3 = (float)size * (0.15f + (float)random.NextDouble() * 0.3f); Stamp(num + Mathf.Cos(num2) * num3, num + Mathf.Sin(num2) * num3, (float)size * (0.03f + (float)random.NextDouble() * 0.09f)); } for (int j = 0; j < size * size; j++) { val.SetPixel(j % size, j / size, new Color(1f, 1f, 1f, alpha[j])); } val.Apply(); return val; void Stamp(float cx, float cy, float rad) { //IL_0046: 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) int num4 = Mathf.Max(0, (int)(cx - rad)); int num5 = Mathf.Min(size - 1, (int)(cx + rad)); int num6 = Mathf.Max(0, (int)(cy - rad)); int num7 = Mathf.Min(size - 1, (int)(cy + rad)); for (int k = num6; k <= num7; k++) { for (int l = num4; l <= num5; l++) { float num8 = Vector2.Distance(new Vector2((float)l, (float)k), new Vector2(cx, cy)) / rad; if (num8 < 1f) { alpha[k * size + l] = Mathf.Max(alpha[k * size + l], 1f - num8 * num8 * num8); } } } } } private static ParticleSystem MakeSystem(string name, Vector3 pos, Quaternion rot, Transform parent, float speedMin, float speedMax, float sizeMin, float sizeMax, float lifetime, bool loop) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_000d: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Expected O, but got Unknown //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Expected O, but got Unknown //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected O, but got Unknown //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown GameObject val = new GameObject(name); val.transform.SetPositionAndRotation(pos, rot); if ((Object)(object)parent != (Object)null) { val.transform.SetParent(parent, true); } ParticleSystem obj = val.AddComponent<ParticleSystem>(); obj.Stop(true, (ParticleSystemStopBehavior)0); MainModule main = obj.main; main.loop = loop; main.duration = (loop ? 1f : 0.1f); main.playOnAwake = false; main.startLifetime = new MinMaxCurve(lifetime * 0.6f, lifetime); main.startSpeed = new MinMaxCurve(speedMin, speedMax); main.startSize = new MinMaxCurve(sizeMin, sizeMax); main.startColor = new MinMaxGradient(BloodColor, BloodColorDark); main.gravityModifier = new MinMaxCurve(1.1f); main.simulationSpace = (ParticleSystemSimulationSpace)1; main.maxParticles = 600; EmissionModule emission = obj.emission; emission.enabled = loop; emission.rateOverTime = new MinMaxCurve(0f); ShapeModule shape = obj.shape; shape.shapeType = (ParticleSystemShapeType)4; shape.angle = 18f; shape.radius = 0.01f; CollisionModule collision = obj.collision; collision.enabled = true; collision.type = (ParticleSystemCollisionType)1; collision.bounce = new MinMaxCurve(0f); collision.dampen = new MinMaxCurve(0.9f); collision.quality = (ParticleSystemCollisionQuality)2; SizeOverLifetimeModule sizeOverLifetime = obj.sizeOverLifetime; sizeOverLifetime.enabled = true; sizeOverLifetime.size = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 1f, 1f, 0.3f)); ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>(); ((Renderer)component).sharedMaterial = _particleMat; component.renderMode = (ParticleSystemRenderMode)1; component.velocityScale = 0.04f; component.lengthScale = 1.2f; ((Renderer)component).shadowCastingMode = (ShadowCastingMode)0; ((Renderer)component).receiveShadows = false; return obj; } public static void Hit(Vector3 pos, Vector3 attackDir, Vector3 normal, float damage) { //IL_0069: 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_006a: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_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_00c8: 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_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_00e2: 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_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_0202: 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_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: 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_0234: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) EnsureSetup(); if ((Object)(object)_particleMat == (Object)null) { return; } if (Time.time - _burstWindowStart >= 1f) { _burstWindowStart = Time.time; _burstsThisWindow = 0; } if (_burstsThisWindow >= Settings.MaxBurstsPerSecond.Value) { return; } _burstsThisWindow++; Vector3 val = ((((Vector3)(ref normal)).sqrMagnitude > 0.01f) ? normal : (-attackDir)); if (((Vector3)(ref val)).sqrMagnitude < 0.01f) { val = Vector3.up; } Vector3 val2 = Vector3.Slerp(((Vector3)(ref val)).normalized, (((Vector3)(ref attackDir)).sqrMagnitude > 0.01f) ? ((Vector3)(ref attackDir)).normalized : val, 0.35f); float num = Mathf.Clamp(damage, 0.2f, 4f) * Settings.BloodAmount.Value; Vector3 val3 = pos + ((Vector3)(ref val)).normalized * 0.06f; ParticleSystem obj = MakeSystem("GorePlus_Hit", val3, Quaternion.LookRotation(val2), null, 1f, 3.6f, 0.025f, 0.06f, 1.4f, loop: false); obj.Play(); int num2 = Mathf.RoundToInt(Mathf.Lerp(25f, 110f, num / 4f)); obj.Emit(num2); MelonCoroutines.Start(DestroyAfter(((Component)obj).gameObject, 2.5f)); if (num >= 1.5f) { Stains.NearPlayer(pos, num / 6f); } Diag(ref _bursts, $"burst of {num2} drops at {val3} (material shader: {((Object)_particleMat.shader).name})"); if (Settings.BloodSplatters.Value) { Vector3 val4 = ((((Vector3)(ref attackDir)).sqrMagnitude > 0.01f) ? ((Vector3)(ref attackDir)).normalized : (-((Vector3)(ref val)).normalized)); Splatter(pos, val4, 0.22f + num * 0.07f); Vector3 val5 = val4 + Random.insideUnitSphere * 0.35f; Splatter(pos, ((Vector3)(ref val5)).normalized, 0.15f + num * 0.05f); Splatter(pos, Vector3.down, 0.18f + num * 0.06f); int num3 = Mathf.FloorToInt(num); for (int i = 0; i < num3; i++) { val5 = Vector3.down * 0.6f + Random.insideUnitSphere; Splatter(pos, ((Vector3)(ref val5)).normalized, 0.08f + num * 0.03f); } } } public static void Wound(Transform bone, Vector3 pos, Vector3 outward, float damage) { //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) if (Settings.Blood.Value && Settings.WoundBleeding.Value && !((Object)(object)bone == (Object)null) && _activeBleeders < MaxBleeders) { float strength = Mathf.Clamp(damage, 0.15f, 2f) * 0.35f; Stump(bone, pos, outward, strength, Mathf.Lerp(2.5f, 7f, Mathf.Clamp01(damage / 2f))); } } public static void Pool(Transform body, float maxSize) { if (Settings.Blood.Value && Settings.BloodPools.Value && !((Object)(object)body == (Object)null)) { EnsureSetup(); if (!((Object)(object)_splatMat == (Object)null)) { MelonCoroutines.Start(PoolRoutine(body, maxSize)); } } } private static IEnumerator PoolRoutine(Transform body, float maxSize) { yield return (object)new WaitForSeconds(1.2f); if ((Object)(object)body == (Object)null || !FirstWorldHit(body.position + Vector3.up * 0.3f, Vector3.down, 2f, out var result)) { yield break; } GameObject go = new GameObject("GorePlus_Pool"); go.transform.position = ((RaycastHit)(ref result)).point + ((RaycastHit)(ref result)).normal * 0.003f; go.transform.rotation = Quaternion.LookRotation(-((RaycastHit)(ref result)).normal) * Quaternion.Euler(0f, 0f, Random.Range(0f, 360f)); go.transform.localScale = Vector3.one * 0.05f; go.AddComponent<MeshFilter>().sharedMesh = _quad; MeshRenderer val = go.AddComponent<MeshRenderer>(); ((Renderer)val).sharedMaterial = _splatMat; ((Renderer)val).shadowCastingMode = (ShadowCastingMode)0; Splat splat = new Splat { go = go, mr = val, born = Time.time, color = BloodColorDark, block = new MaterialPropertyBlock() }; splat.SetAlpha(1f); _splats.Add(splat); float target = maxSize * Settings.BloodAmount.Value * 0.5f; target = Mathf.Clamp(target, 0.4f, 2.2f); float aspect = Random.Range(0.75f, 1f); for (float t = 0f; t < 1f; t += Time.deltaTime / 14f) { if ((Object)(object)go == (Object)null) { break; } if (splat.fadeStart >= 0f) { break; } float num = Mathf.Lerp(0.05f, target, 1f - (1f - t) * (1f - t)); go.transform.localScale = new Vector3(num, num * aspect, num); yield return null; } } public static void Stump(Transform attachTo, Vector3 pos, Vector3 outward, float strength, float seconds = -1f) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_005d: 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_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) if (!Settings.Blood.Value) { return; } EnsureSetup(); if (!((Object)(object)_particleMat == (Object)null) && !((Object)(object)attachTo == (Object)null)) { if (((Vector3)(ref outward)).sqrMagnitude < 0.01f) { outward = Vector3.up; } if (_activeBleeders < MaxBleeders) { ParticleSystem obj = MakeSystem("GorePlus_Stump", pos + ((Vector3)(ref outward)).normalized * 0.04f, Quaternion.LookRotation(((Vector3)(ref outward)).normalized), attachTo, 1.2f, 2.6f, 0.022f, 0.05f, 1.2f, loop: true); obj.Play(); MelonCoroutines.Start(StumpRoutine(obj, strength * Settings.BloodAmount.Value, (seconds > 0f) ? seconds : Settings.StumpBleedSeconds.Value)); } } } private static IEnumerator StumpRoutine(ParticleSystem ps, float strength, float duration) { _activeBleeders++; IEnumerator loop = StumpLoop(ps, strength, duration); while (loop.MoveNext()) { yield return loop.Current; } _activeBleeders = Mathf.Max(0, _activeBleeders - 1); } private static IEnumerator StumpLoop(ParticleSystem ps, float strength, float duration) { float t = 0f; float nextSplat = 0.4f; while (t < duration) { if ((Object)(object)ps == (Object)null) { yield break; } float num = 1f - t / duration; float num2 = 0.35f + 0.65f * Mathf.Pow(Mathf.Abs(Mathf.Sin(t * 4.2f)), 3f); ps.emission.rateOverTime = new MinMaxCurve(140f * strength * num * num2); ps.main.startSpeed = new MinMaxCurve(0.5f + 1.8f * num * num2, 1f + 3f * num * num2); if (Settings.BloodSplatters.Value && t >= nextSplat) { nextSplat += 0.5f; Vector3 position = ((Component)ps).transform.position; Vector3 val = Vector3.down + Random.insideUnitSphere * 0.4f; Splatter(position, ((Vector3)(ref val)).normalized, (0.1f + 0.2f * num) * Mathf.Sqrt(strength + 0.2f)); } t += Time.deltaTime; yield return null; } if (!((Object)(object)ps == (Object)null)) { ps.emission.enabled = false; yield return (object)new WaitForSeconds(2f); if ((Object)(object)ps != (Object)null) { Object.Destroy((Object)(object)((Component)ps).gameObject); } } } private static IEnumerator DestroyAfter(GameObject go, float seconds) { yield return (object)new WaitForSeconds(seconds); if ((Object)(object)go != (Object)null) { Object.Destroy((Object)(object)go); } } private static bool FirstWorldHit(Vector3 from, Vector3 dir, float maxDist, out RaycastHit result) { //IL_0001: 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_0008: 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_005e: 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) result = default(RaycastHit); Il2CppStructArray<RaycastHit> val = Physics.RaycastAll(from, dir, maxDist, -5, (QueryTriggerInteraction)1); if (val == null) { return false; } float num = float.MaxValue; bool result2 = false; for (int i = 0; i < ((Il2CppArrayBase<RaycastHit>)(object)val).Length; i++) { RaycastHit val2 = ((Il2CppArrayBase<RaycastHit>)(object)val)[i]; if (!((Object)(object)((RaycastHit)(ref val2)).collider == (Object)null) && !((Object)(object)((RaycastHit)(ref val2)).rigidbody != (Object)null) && ((RaycastHit)(ref val2)).distance < num) { num = ((RaycastHit)(ref val2)).distance; result = val2; result2 = true; } } return result2; } private static void Diag(ref int counter, string msg) { counter++; if (counter <= 4) { Core.Debug("[blood] " + msg); } if (counter % 50 == 0) { Core.Debug($"[blood] so far: {_bursts} bursts, {_splatHits} splats placed, {_splatMisses} splats with no surface"); } } public static void Splatter(Vector3 from, Vector3 dir, float size) { //IL_0029: 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_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //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_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_0118: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Expected O, but got Unknown //IL_005c: 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) if (!((Object)(object)_splatMat == (Object)null) && !((Object)(object)_quad == (Object)null) && !(((Vector3)(ref dir)).sqrMagnitude < 0.0001f)) { if (!FirstWorldHit(from, ((Vector3)(ref dir)).normalized, 3f, out var result)) { Diag(ref _splatMisses, $"no wall/floor found from {from} dir {((Vector3)(ref dir)).normalized}"); return; } Diag(ref _splatHits, $"splat on '{((Object)((RaycastHit)(ref result)).collider).name}' at {((RaycastHit)(ref result)).point}"); GameObject val = new GameObject("GorePlus_Splat"); val.transform.position = ((RaycastHit)(ref result)).point + ((RaycastHit)(ref result)).normal * 0.004f; val.transform.rotation = Quaternion.LookRotation(-((RaycastHit)(ref result)).normal) * Quaternion.Euler(0f, 0f, Random.Range(0f, 360f)); float num = size * Random.Range(0.75f, 1.35f); val.transform.localScale = new Vector3(num, num * Random.Range(0.8f, 1.2f), num); val.AddComponent<MeshFilter>().sharedMesh = _quad; MeshRenderer val2 = val.AddComponent<MeshRenderer>(); ((Renderer)val2).sharedMaterial = _splatMat; ((Renderer)val2).shadowCastingMode = (ShadowCastingMode)0; Color color = Color.Lerp(BloodColorDark, BloodColor, Random.Range(0f, 0.6f)); Splat splat = new Splat { go = val, mr = val2, born = Time.time, color = color, block = new MaterialPropertyBlock() }; splat.SetAlpha(1f); _splats.Add(splat); EnforceLimit(); } } private static void EnforceLimit() { int num = 0; for (int num2 = _splats.Count - 1; num2 >= 0; num2--) { if (_splats[num2].fadeStart < 0f && ++num > Settings.MaxSplatters.Value) { _splats[num2].fadeStart = Time.time; } } } public static GameObject Stain(Transform parent, Vector3 pos, Vector3 normal, float size, float lifetime, float fade = 6f, float lift = 0.006f) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: 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_00bf: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_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_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: 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) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Expected O, but got Unknown EnsureSetup(); if ((Object)(object)parent == (Object)null) { return null; } if (((Vector3)(ref normal)).sqrMagnitude < 0.0001f) { normal = Random.onUnitSphere; } ((Vector3)(ref normal)).Normalize(); Material bloodMat = Flesh.BloodMat; Mesh val = (((Object)(object)bloodMat != (Object)null) ? Flesh.Dome : null); if ((Object)(object)bloodMat != (Object)null && (Object)(object)val != (Object)null) { return Blob(parent, pos, normal, size, lifetime, fade, lift, bloodMat, val); } if ((Object)(object)_splatMat == (Object)null || (Object)(object)_quad == (Object)null) { return null; } GameObject val2 = new GameObject("GorePlus_Stain"); val2.transform.SetParent(parent, true); val2.transform.position = pos + normal * 0.006f; val2.transform.rotation = Quaternion.LookRotation(-normal) * Quaternion.Euler(0f, 0f, Random.Range(0f, 360f)); Vector3 lossyScale = parent.lossyScale; float num = 1f / Mathf.Max(0.0001f, (Mathf.Abs(lossyScale.x) + Mathf.Abs(lossyScale.y) + Mathf.Abs(lossyScale.z)) / 3f); float num2 = size * Random.Range(0.75f, 1.3f) * num; val2.transform.localScale = new Vector3(num2, num2 * Random.Range(0.7f, 1.2f), num2); val2.AddComponent<MeshFilter>().sharedMesh = _quad; MeshRenderer val3 = val2.AddComponent<MeshRenderer>(); ((Renderer)val3).sharedMaterial = _splatMat; ((Renderer)val3).shadowCastingMode = (ShadowCastingMode)0; Color color = Color.Lerp(BloodColorDark, BloodColor, Random.Range(0.2f, 0.8f)); Splat splat = new Splat { go = val2, mr = val3, born = Time.time, color = color, block = new MaterialPropertyBlock(), life = lifetime, fade = fade }; splat.SetAlpha(0.95f); _splats.Add(splat); EnforceLimit(); return val2; } private static GameObject Blob(Transform parent, Vector3 pos, Vector3 normal, float size, float lifetime, float fade, float lift, Material mat, Mesh dome) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001e: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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_0038: 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_0066: 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_0076: 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_008d: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Expected O, but got Unknown //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: 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_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("GorePlus_Stain"); val.transform.SetParent(parent, true); val.transform.position = pos + normal * lift; val.transform.rotation = Quaternion.LookRotation(normal) * Quaternion.Euler(0f, 0f, Random.Range(0f, 360f)); Vector3 lossyScale = parent.lossyScale; float num = 1f / Mathf.Max(0.0001f, (Mathf.Abs(lossyScale.x) + Mathf.Abs(lossyScale.y) + Mathf.Abs(lossyScale.z)) / 3f); val.transform.localScale = Vector3.one * num; float num2 = size * 0.32f; int num3 = Random.Range(2, 5); MeshRenderer val2 = null; for (int i = 0; i <= num3; i++) { GameObject val3 = new GameObject("GorePlus_Drop"); val3.transform.SetParent(val.transform, false); float num4 = ((i == 0) ? num2 : (num2 * Random.Range(0.25f, 0.55f))); Vector2 val4; if (i != 0) { Vector2 insideUnitCircle = Random.insideUnitCircle; val4 = ((Vector2)(ref insideUnitCircle)).normalized * num2 * Random.Range(0.9f, 1.8f); } else { val4 = Vector2.zero; } Vector2 val5 = val4; val3.transform.localPosition = new Vector3(val5.x, val5.y, 0f); val3.transform.localRotation = Quaternion.Euler(0f, 0f, Random.Range(0f, 360f)); val3.transform.localScale = new Vector3(num4, num4 * Random.Range(0.6f, 1.1f), num4 * 0.35f); val3.AddComponent<MeshFilter>().sharedMesh = dome; MeshRenderer val6 = val3.AddComponent<MeshRenderer>(); ((Renderer)val6).sharedMaterial = mat; ((Renderer)val6).shadowCastingMode = (ShadowCastingMode)0; if ((Object)(object)val2 == (Object)null) { val2 = val6; } } Splat item = new Splat { go = val, mr = val2, born = Time.time, block = new MaterialPropertyBlock(), life = lifetime, fade = fade, opaque = true }; _splats.Add(item); EnforceLimit(); return val; } public static void Update() { //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) if (_splats.Count == 0) { return; } float time = Time.time; float value = Settings.SplatterLifetime.Value; for (int num = _splats.Count - 1; num >= 0; num--) { Splat splat = _splats[num]; if ((Object)(object)splat.go == (Object)null) { _splats.RemoveAt(num); } else { float num2 = ((splat.life >= 0f) ? splat.life : value); if (splat.fadeStart < 0f && num2 > 0f && time - splat.born > num2) { splat.fadeStart = time; } if (!(splat.fadeStart < 0f)) { float num3 = (time - splat.fadeStart) / splat.fade; if (num3 >= 1f) { Object.Destroy((Object)(object)splat.go); _splats.RemoveAt(num); } else { splat.SetAlpha(1f - num3); Transform transform = splat.go.transform; transform.localScale *= 1f - Time.deltaTime * 0.25f; } } } } } public static void FadeAll() { foreach (Splat splat in _splats) { if (splat.fadeStart < 0f) { splat.fadeStart = Time.time; } } } public static void OnSceneChanged() { _splats.Clear(); _activeBleeders = 0; } } public class Core : MelonMod { internal static Instance Log; private static readonly Dictionary<string, int> _traceCounts = new Dictionary<string, int>(); internal static void Trace(string feature, string msg) { if (Settings.DebugLog != null && Settings.DebugLog.Value) { _traceCounts.TryGetValue(feature, out var value); if (value < 5) { _traceCounts[feature] = value + 1; Log.Msg("[" + feature + "] " + msg); } } } internal static void Debug(string msg) { if (Settings.DebugLog != null && Settings.DebugLog.Value) { Log.Msg(msg); } } public override void OnInitializeMelon() { Log = ((MelonBase)this).LoggerInstance; Settings.Init(); Log.Msg("Gore+ loaded: NPC dismemberment and blood. Settings: BoneMenu > Gore+ or UserData/MelonPreferences.cfg [GorePlus]"); } public override void OnLateInitializeMelon() { Menu.TryBuild(); FusionBridge.Init(); } public override void OnUpdate() { try { Blood.Update(); Stains.Update(); Dismember.Update(); } catch (Exception ex) { Log.Error("Blood.Update failed: " + ex.Message); } } public override void OnSceneWasInitialized(int buildIndex, string sceneName) { Dismember.OnSceneChanged(); Blood.OnSceneChanged(); Stains.OnSceneChanged(); } } [HarmonyPatch(typeof(SubBehaviourHealth), "TakeDamage")] internal static class TakeDamagePatch { private static void Postfix(SubBehaviourHealth __instance, int m, Attack attack) { try { Dismember.OnNpcHit(__instance, m, attack); } catch (Exception value) { Core.Log.Error($"OnNpcHit failed: {value}"); } } } [HarmonyPatch(typeof(Poolee), "OnDespawnEvent")] internal static class PooleeDespawnPatch { private static void Postfix(Poolee __instance) { try { Dismember.OnPooleeDespawn(__instance); } catch (Exception value) { Core.Log.Error($"OnPooleeDespawn failed: {value}"); } } } internal static class Dismember { private static readonly HashSet<IntPtr> _severedMuscles = new HashSet<IntPtr>(); private static readonly HashSet<IntPtr> _dismemberedPoolees = new HashSet<IntPtr>(); private static readonly Dictionary<IntPtr, float> _accumulated = new Dictionary<IntPtr, float>(); private static int _loggedHits; private static readonly Dictionary<IntPtr, BehaviourPuppet> _puppets = new Dictionary<IntPtr, BehaviourPuppet>(); private static bool _litGrabbed; private static readonly HashSet<IntPtr> _limpMuscles = new HashSet<IntPtr>(); private static readonly List<Muscle> _limpList = new List<Muscle>(); private static float _nextLimpRefresh; private static readonly Dictionary<IntPtr, int> _headWounds = new Dictionary<IntPtr, int>(); private static readonly HashSet<IntPtr> _maimed = new HashSet<IntPtr>(); private static readonly HashSet<IntPtr> _crippled = new HashSet<IntPtr>(); private static readonly HashSet<IntPtr> _bledOut = new HashSet<IntPtr>(); public static void OnNpcHit(SubBehaviourHealth health, int muscleIndex, Attack attack) { //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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_00ac: 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_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0127: 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_0227: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0303: Invalid comparison between Unknown and I4 //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Invalid comparison between Unknown and I4 //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Invalid comparison between Unknown and I4 //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_036f: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Invalid comparison between Unknown and I4 //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_032b: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Invalid comparison between Unknown and I4 //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_042e: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Invalid comparison between Unknown and I4 //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0432: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Invalid comparison between Unknown and I4 //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_03a4: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Invalid comparison between Unknown and I4 //IL_0487: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Invalid comparison between Unknown and I4 //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_04c8: Unknown result type (might be due to invalid IL or missing references) //IL_0496: Unknown result type (might be due to invalid IL or missing references) //IL_0458: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Invalid comparison between Unknown and I4 //IL_0504: Unknown result type (might be due to invalid IL or missing references) //IL_0506: Invalid comparison between Unknown and I4 //IL_04d6: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_050e: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_053d: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Unknown result type (might be due to invalid IL or missing references) if (!Settings.Enabled.Value || health == null) { return; } PuppetMaster val = (((Object)(object)((SubBehaviourBase)health).behaviour != (Object)null) ? ((SubBehaviourBase)health).behaviour.puppetMaster : null); if ((Object)(object)val == (Object)null) { return; } Il2CppReferenceArray<Muscle> muscles = val.muscles; if (muscles == null || muscleIndex < 0 || muscleIndex >= ((Il2CppArrayBase<Muscle>)(object)muscles).Length) { return; } Muscle val2 = ((Il2CppArrayBase<Muscle>)(object)muscles)[muscleIndex]; if (val2 == null || (Object)(object)val2.transform == (Object)null) { return; } Group val3 = (Group)((val2.props == null) ? 1 : ((int)val2.props.group)); float damage = attack.damage; AttackType attackType = attack.attackType; Vector3 pos = attack.origin; if (pos == Vector3.zero) { pos = val2.transform.position; } if (Settings.LogHits.Value && _loggedHits < 400) { _loggedHits++; Core.Log.Msg($"hit {val2.name} [{val3}] type={attackType} dmg={damage:0.###} limbHP={health.maxAppendageHp:0.###} maxHP={health.maxHitPoints:0.###} organic={health.isOrganic} dead={val.isDead}"); } bool isOrganic = health.isOrganic; Vector3 direction = attack.direction; SnapToBody(val2.transform, ref pos, out var normal); Vector3 normal2; ? val4; if (!(((Vector3)(ref normal)).sqrMagnitude > 0.01f)) { normal2 = attack.normal; val4 = ((((Vector3)(ref normal2)).sqrMagnitude > 0.01f) ? attack.normal : (-direction)); } else { val4 = normal; } Vector3 val5 = (Vector3)val4; if (!Flesh.HasLit && health.isOrganic) { GrabLitShader(val); } Core.Trace("hit", $"{val2.name} type={attackType} dmg={damage:0.##} origin={attack.origin} snapped={pos} collider={(((Object)(object)attack.collider != (Object)null) ? ((Object)attack.collider).name : "null")}"); bool flag = (int)attackType == 16 || (int)attackType == 32 || (int)attackType == 2; if (isOrganic && damage >= 0.05f) { if (damage >= 0.2f) { Sfx.Squelch(pos, damage / 2f); } Stains.OnBodyHit(val2.transform, pos, val5, damage); if (flag) { Stains.OnMeleeHit(pos, attack.collider, val); } } if (isOrganic && Settings.Blood.Value) { Blood.Hit(pos, direction, attack.normal, damage); if ((int)attackType != 2 && damage >= 0.1f) { normal2 = attack.normal; Vector3 outward = ((((Vector3)(ref normal2)).sqrMagnitude > 0.01f) ? attack.normal : (-direction)); Blood.Wound(val2.transform, pos, outward, damage); } } if (isOrganic) { StartBleedOutIfDead(val); } if (!Settings.Dismemberment.Value) { return; } if ((int)val3 == 1) { if (!Settings.TorsoCuts.Value) { return; } int num = FindWaistIndex(val); if (num >= 0) { Muscle val6 = ((Il2CppArrayBase<Muscle>)(object)muscles)[num]; if (ShouldSeverTorso(health, val, val6, attackType, damage)) { Sever(val, val6, num, direction, isOrganic, explode: false); KillAndBleedOut(health, val, isOrganic); } } return; } bool flag2 = (int)val3 == 3 || (int)val3 == 5; if (Settings.PreciseCuts.Value && flag2 && ((int)attackType == 16 || (int)attackType == 32)) { int num2 = NearChildJoint(val, val2, pos); if (num2 >= 0) { muscleIndex = num2; val2 = ((Il2CppArrayBase<Muscle>)(object)muscles)[num2]; val3 = val2.props.group; } } bool flag3 = (int)val3 == 2; if (ShouldExplode(health, val, val3, attackType, damage)) { if (Sever(val, val2, muscleIndex, direction, isOrganic, explode: true)) { if (flag3) { KillAndBleedOut(health, val, isOrganic); } else { Maim(health, val, val3, isOrganic, 1f); } } } else if (ShouldSever(health, val, val2, val3, attackType, damage)) { if (Sever(val, val2, muscleIndex, direction, isOrganic, explode: false)) { if (flag3) { KillAndBleedOut(health, val, isOrganic); } else { Maim(health, val, val3, isOrganic, 1f); } } } else if ((int)val3 == 2) { if (isOrganic) { TryHeadWound(health, val2, attackType, damage, pos, val5); } } else if (IsCuttable(val3) && ShouldHang(health, val, val2, attackType, damage)) { MakeLimp(val, muscleIndex); if (isOrganic) { Sfx.Crack(pos); Blood.Stump(val2.transform, pos, val5, 0.45f, 8f); Maim(health, val, val3, isOrganic, 1.5f); } } } private static BehaviourPuppet FindPuppet(PuppetMaster pm) { if (_puppets.TryGetValue(((Il2CppObjectBase)pm).Pointer, out var value) && (Object)(object)value != (Object)null) { return value; } BehaviourPuppet val = null; Transform val2 = ((Component)pm).transform; int num = 0; while (num < 3 && (Object)(object)val2 != (Object)null && (Object)(object)val == (Object)null) { val = ((Component)val2).GetComponentInChildren<BehaviourPuppet>(true); num++; val2 = val2.parent; } _puppets[((Il2CppObjectBase)pm).Pointer] = val; Core.Trace("maim", "BehaviourPuppet for " + ((Object)pm).name + ": " + (((Object)(object)val != (Object)null) ? ((Object)val).name : "not found")); return val; } private static void SnapToBody(Transform bone, ref Vector3 pos, out Vector3 normal) { //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_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_00ac: 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_00b5: 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_0053: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: 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_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_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: 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) //IL_00ef: 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_00fb: 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_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0086: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) normal = Vector3.zero; if ((Object)(object)bone == (Object)null) { return; } float num = float.MaxValue; Vector3 val = pos; Collider val2 = null; Vector3 val4; foreach (Collider component in ((Component)bone).GetComponents<Collider>()) { if (!((Object)(object)component == (Object)null) && component.enabled) { Vector3 val3; try { val3 = component.ClosestPoint(pos); } catch { continue; } val4 = val3 - pos; float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; val = val3; val2 = component; } } } if ((Object)(object)val2 == (Object)null) { return; } Bounds bounds = val2.bounds; Vector3 center = ((Bounds)(ref bounds)).center; if (num < 1E-06f) { Vector3 val5 = pos - center; if (!(((Vector3)(ref val5)).sqrMagnitude < 1E-06f)) { Ray val6 = default(Ray); ((Ray)(ref val6))..ctor(center + ((Vector3)(ref val5)).normalized * 0.5f, -((Vector3)(ref val5)).normalized); RaycastHit val7 = default(RaycastHit); if (val2.Raycast(val6, ref val7, 0.6f)) { pos = ((RaycastHit)(ref val7)).point; normal = ((RaycastHit)(ref val7)).normal; } } } else { pos = val; val4 = val - center; normal = ((Vector3)(ref val4)).normalized; } } private static void GrabLitShader(PuppetMaster pm) { if (_litGrabbed) { return; } _litGrabbed = true; try { foreach (var item in CollectSkins(FindNpcRoot(pm))) { var (val, _) = item; if (item.primary && (Object)(object)((Renderer)val).sharedMaterial != (Object)null) { Flesh.TryUseNpcShader(((Renderer)val).sharedMaterial); break; } } } catch (Exception ex) { Core.Debug("Couldn't grab the NPC shader early: " + ex.Message); } } private static int NearChildJoint(PuppetMaster pm, Muscle muscle, Vector3 pos) { //IL_0028: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Invalid comparison between Unknown and I4 //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Invalid comparison between Unknown and I4 //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_00fa: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_010f: 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_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Invalid comparison between Unknown and I4 //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Invalid comparison between Unknown and I4 Il2CppStructArray<int> childIndexes = muscle.childIndexes; if (childIndexes == null || ((Il2CppArrayBase<int>)(object)childIndexes).Length == 0 || (Object)(object)muscle.transform == (Object)null) { return -1; } Vector3 position = muscle.transform.position; int result = -1; float num = float.MaxValue; foreach (int item in (Il2CppArrayBase<int>)(object)childIndexes) { if (item < 0 || item >= ((Il2CppArrayBase<Muscle>)(object)pm.muscles).Length) { continue; } Muscle val = ((Il2CppArrayBase<Muscle>)(object)pm.muscles)[item]; if (val == null || (Object)(object)val.transform == (Object)null || val.props == null || _severedMuscles.Contains(((Il2CppObjectBase)val).Pointer)) { continue; } Group val2 = val.props.group; if ((int)val2 != 3 && (int)val2 != 4 && (int)val2 != 5 && (int)val2 != 6) { continue; } Vector3 position2 = val.transform.position; Vector3 val3 = position2 - position; if (!(((Vector3)(ref val3)).sqrMagnitude < 0.0001f)) { float num2 = Vector3.Dot(pos - position, val3) / ((Vector3)(ref val3)).sqrMagnitude; Vector3 val4 = pos - position2; float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; if (num2 > 0.65f && sqrMagnitude < num) { num = sqrMagnitude; result = item; } } } return result; } private static bool ShouldHang(SubBehaviourHealth health, PuppetMaster pm, Muscle muscle, AttackType type, float damage) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Invalid comparison between Unknown and I4 if (!Settings.HangingLimbs.Value || _limpMuscles.Contains(((Il2CppObjectBase)muscle).Pointer)) { return false; } if ((int)type != 16 && (int)type != 32 && (int)type != 2) { return false; } float num = LimbHp(health); float num2 = damage * (pm.isDead ? Settings.DeadDamageMultiplier.Value : 1f); float num3 = num * (((int)type == 2) ? Settings.BluntSeverFraction.Value : Settings.BladeSeverFraction.Value); _accumulated.TryGetValue(((Il2CppObjectBase)muscle).Pointer, out var value); if (!(num2 >= num3 * 0.65f)) { return value >= num * Settings.CumulativeSeverFraction.Value * 0.6f; } return true; } private static void MakeLimp(PuppetMaster pm, int index) { Il2CppReferenceArray<Muscle> muscles = pm.muscles; if (index < 0 || index >= ((Il2CppArrayBase<Muscle>)(object)muscles).Length) { return; } Muscle val = ((Il2CppArrayBase<Muscle>)(object)muscles)[index]; if (val == null || !_limpMuscles.Add(((Il2CppObjectBase)val).Pointer)) { return; } _limpList.Add(val); ApplyLimp(val); Core.Trace("limp", val.name + " goes limp"); if (val.childIndexes == null) { return; } foreach (int item in (Il2CppArrayBase<int>)(object)val.childIndexes) { MakeLimp(pm, item); } } private static void ApplyLimp(Muscle m) { //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_0048: Unknown result type (might be due to invalid IL or missing references) try { if (m.props != null) { m.props.muscleWeight = 0f; m.props.muscleDamper = 0.15f; } State state = m.state; state.muscleWeightMlp = 0f; state.muscleDamperMlp = 0.15f; m.state = state; } catch { } } public static void Update() { if (_limpList.Count == 0) { return; } for (int num = _limpList.Count - 1; num >= 0; num--) { Muscle val = _limpList[num]; bool flag; try { flag = val == null || (Object)(object)val.transform == (Object)null; } catch { flag = true; } if (flag) { _limpList.RemoveAt(num); } else { ApplyLimp(val); } } } private static void TryHeadWound(SubBehaviourHealth health, Muscle head, AttackType type, float damage, Vector3 pos, Vector3 outward) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Invalid comparison between Unknown and I4 //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 //IL_0090: 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_00b1: 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_00c7: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: 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) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_011a: 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_0128: 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) if (!Settings.HeadWounds.Value || _severedMuscles.Contains(((Il2CppObjectBase)head).Pointer)) { return; } float num = LimbHp(health); float num2 = (((int)type == 1) ? 0.1f : (((int)type == 2) ? 0.5f : 0.25f)); if (!(damage < num * num2)) { _headWounds.TryGetValue(((Il2CppObjectBase)head).Pointer, out var value); if (value < 3) { _headWounds[((Il2CppObjectBase)head).Pointer] = value + 1; Core.Trace("headwound", $"at {pos}"); outward = ((((Vector3)(ref outward)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref outward)).normalized : Vector3.up); Flesh.Cap(head.transform, pos - outward * 0.012f, outward, 0.028f, 0f); Flesh.Gibs(pos, outward, 3, 0.05f); Blood.Stump(head.transform, pos, outward, 0.55f, 7f); Stains.OnBodyHit(head.transform, pos, outward, 2f); Stains.NearPlayer(pos, 0.5f); Sfx.Crack(pos); } } } private static void Maim(SubBehaviourHealth health, PuppetMaster pm, Group group, bool organic, float slower) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Invalid comparison between Unknown and I4 //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 if (!((Object)(object)pm == (Object)null) && !pm.isDead) { if (((int)group == 5 || (int)group == 6) && Settings.CrippledNpcs.Value) { _crippled.Add(((Il2CppObjectBase)pm).Pointer); } bool flag = organic && Settings.BleedOut.Value; if ((flag || _crippled.Contains(((Il2CppObjectBase)pm).Pointer)) && _maimed.Add(((Il2CppObjectBase)pm).Pointer)) { float seconds = (flag ? Mathf.Max(1f, Settings.BleedOutSeconds.Value * slower) : float.PositiveInfinity); Core.Trace("maim", $"{((Object)pm).name}: crippled={_crippled.Contains(((Il2CppObjectBase)pm).Pointer)} bleedOut={(flag ? (seconds.ToString("0") + "s") : "off")}"); MelonCoroutines.Start(Weaken(health, pm, seconds)); } } } private static IEnumerator Weaken(SubBehaviourHealth health, PuppetMaster pm, float seconds) { float start = Time.time; float startWeight = 1f; try { startWeight = pm.muscleWeight; } catch { } while (Time.time - start < seconds) { bool flag; try { flag = (Object)(object)pm == (Object)null || health == null || pm.isDead; } catch { yield break; } if (flag) { yield break; } float num = (float.IsInfinity(seconds) ? 0f : ((Time.time - start) / seconds)); float num2 = startWeight * Mathf.Lerp(1f, 0.3f, num * num); bool flag2 = _crippled.Contains(((Il2CppObjectBase)pm).Pointer); if (flag2) { num2 = Mathf.Min(num2, 0.28f); } try { pm.muscleWeight = num2; } catch { yield break; } BehaviourPuppet val = FindPuppet(pm); if ((Object)(object)val != (Object)null) { try { val.unpinnedMuscleWeightMlp = Mathf.Clamp(num2, 0.15f, 1f); if (flag2 || num > 0.6f) { val.Unpin(); } } catch { } } yield return (object)new WaitForSeconds(0.2f); } bool flag3; try { flag3 = (Object)(object)pm != (Object)null && health != null && !pm.isDead; } catch { flag3 = false; } if (flag3) { KillAndBleedOut(health, pm, organic: true); } } private static void StartBleedOutIfDead(PuppetMaster pm) { if (pm.isDead && _bledOut.Add(((Il2CppObjectBase)pm).Pointer)) { object body; if (pm.muscles == null || ((Il2CppArrayBase<Muscle>)(object)pm.muscles).Length <= 0) { body = null; } else { Muscle obj = ((Il2CppArrayBase<Muscle>)(object)pm.muscles)[0]; body = ((obj != null) ? obj.transform : null); } Blood.Pool((Transform)body, 1.6f); } } private static void KillAndBleedOut(SubBehaviourHealth health, PuppetMaster pm, bool organic) { try { health.Kill(); } catch (Exception ex) { Core.Log.Warning("Couldn't kill NPC: " + ex.Message); } if (organic && _bledOut.Add(((Il2CppObjectBase)pm).Pointer)) { object body; if (pm.muscles == null || ((Il2CppArrayBase<Muscle>)(object)pm.muscles).Length <= 0) { body = null; } else { Muscle obj = ((Il2CppArrayBase<Muscle>)(object)pm.muscles)[0]; body = ((obj != null) ? obj.transform : null); } Blood.Pool((Transform)body, 2.2f); } } private static int FindWaistIndex(PuppetMaster pm) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 Il2CppReferenceArray<Muscle> muscles = pm.muscles; int num = -1; for (int i = 0; i < ((Il2CppArrayBase<Muscle>)(object)muscles).Length; i++) { Muscle val = ((Il2CppArrayBase<Muscle>)(object)muscles)[i]; if (val != null && val.props != null && (int)val.props.group == 1 && !_severedMuscles.Contains(((Il2CppObjectBase)val).Pointer)) { string text = val.name ?? ""; if (text.Equals("Spine_M", StringComparison.OrdinalIgnoreCase)) { return i; } if (num < 0 && text.IndexOf("spine", StringComparison.OrdinalIgnoreCase) >= 0) { num = i; } } } return num; } private static bool ShouldSeverTorso(SubBehaviourHealth health, PuppetMaster pm, Muscle waist, AttackType type, float damage) { //IL_002f: 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_0033: Invalid comparison between Unknown and I4 //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Invalid comparison between Unknown and I4 float num = LimbHp(health); float num2 = damage * (pm.isDead ? Settings.DeadDamageMultiplier.Value : 1f); float num3 = num * Settings.TorsoSeverFraction.Value; if (type - 1 > 1) { if ((int)type != 16 && (int)type != 32) { return false; } if (num2 >= num3) { return true; } } else if (num2 >= num3 * 2f) { return true; } _accumulated.TryGetValue(((Il2CppObjectBase)waist).Pointer, out var value); value += num2; _accumulated[((Il2CppObjectBase)waist).Pointer] = value; return value >= num3 * 2f; } private static bool IsCuttable(Group group) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Invalid comparison between Unknown and I4 //IL_0004: 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_0008: Invalid comparison between Unknown and I4 if ((int)group != 2) { if (group - 3 <= 3) { return true; } return false; } return Settings.AllowHeads.Value; } private static float LimbHp(SubBehaviourHealth health) { float maxAppendageHp = health.maxAppendageHp; if (!(maxAppendageHp > 0f)) { return Mathf.Max(health.maxHitPoints * 0.5f, 0.01f); } return maxAppendageHp; } private static bool ShouldExplode(SubBehaviourHealth health, PuppetMaster pm, Group group, AttackType type, float damage) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Invalid comparison between Unknown and I4 if (!Settings.BulletGore.Value || (int)type != 1 || !IsCuttable(group)) { return false; } float num = damage * (pm.isDead ? Settings.DeadDamageMultiplier.Value : 1f); float num2 = (((int)group == 2) ? Settings.HeadExplodeFraction.Value : Settings.LimbExplodeFraction.Value); return num >= LimbHp(health) * num2; } private static bool ShouldSever(SubBehaviourHealth health, PuppetMaster pm, Muscle muscle, Group group, AttackType type, float damage) { //IL_0000: 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_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Invalid comparison between Unknown and I4 //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Invalid comparison between Unknown and I4 if (!IsCuttable(group)) { return false; } float num = LimbHp(health); float num2 = damage * (pm.isDead ? Settings.DeadDamageMultiplier.Value : 1f); float value; if (type - 1 > 1) { if ((int)type != 16 && (int)type != 32) { return false; } value = Settings.BladeSeverFraction.Value; } else { value = Settings.BluntSeverFraction.Value; } if (num2 >= num * value) { return true; } _accumulated.TryGetValue(((Il2CppObjectBase)muscle).Pointer, out var value2); value2 += num2; _accumulated[((Il2CppObjectBase)muscle).Pointer] = value2; return value2 >= num * Settings.CumulativeSeverFraction.Value; } public static void SeverByName(GameObject entityRoot, string muscleName, Vector3 hitDir, bool explode, bool organic) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)entityRoot == (Object)null) { return; } PuppetMaster componentInChildren = entityRoot.GetComponentInChildren<PuppetMaster>(); if ((Object)(object)componentInChildren == (Object)null || componentInChildren.muscles == null) { return; } Il2CppReferenceArray<Muscle> muscles = componentInChildren.muscles; for (int i = 0; i < ((Il2CppArrayBase<Muscle>)(object)muscles).Length; i++) { Muscle val = ((Il2CppArrayBase<Muscle>)(object)muscles)[i]; if (val != null && val.name == muscleName) { Sever(componentInChildren, val, i, hitDir, organic, explode, fromNetwork: true); break; } } } private static bool Sever(PuppetMaster pm, Muscle muscle, int muscleIndex, Vector3 hitDir, bool organic, bool explode, bool fromNetwork = false) { //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0409: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_0449: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0422: 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_05c6: Unknown result type (might be due to invalid IL or missing references) //IL_05c8: Unknown result type (might be due to invalid IL or missing references) //IL_05ca: Unknown result type (might be due to invalid IL or missing references) //IL_05a9: Unknown result type (might be due to invalid IL or missing references) //IL_05b3: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Unknown result type (might be due to invalid IL or missing references) //IL_0479: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04bf: Unknown result type (might be due to invalid IL or missing references) //IL_04c1: Unknown result type (might be due to invalid IL or missing references) //IL_04c5: Unknown result type (might be due to invalid IL or missing references) //IL_04cf: 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_04d9: Unknown result type (might be due to invalid IL or missing references) //IL_04db: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_05ed: Unknown result type (might be due to invalid IL or missing references) //IL_05ef: Unknown result type (might be due to invalid IL or missing references) //IL_05f1: Unknown result type (might be due to invalid IL or missing references) //IL_0505: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_0515: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_0519: Unknown result type (might be due to invalid IL or missing references) //IL_051e: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_0613: Unknown result type (might be due to invalid IL or missing references) //IL_0614: Unknown result type (might be due to invalid IL or missing references) //IL_068f: Unknown result type (might be due to invalid IL or missing references) //IL_063a: Unknown result type (might be due to invalid IL or missing references) //IL_0640: Invalid comparison between Unknown and I4 //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0540: Unknown result type (might be due to invalid IL or missing references) //IL_0542: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Unknown result type (might be due to invalid IL or missing references) //IL_0551: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_064f: Unknown result type (might be due to invalid IL or missing references) //IL_0651: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0232: 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_023b: Unknown result type (might be due to invalid IL or missing references) //IL_022b: 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_0265: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) if (!_severedMuscles.Add(((Il2CppObjectBase)muscle).Pointer)) { return false; } _accumulated.Remove(((Il2CppObjectBase)muscle).Pointer); Transform target = muscle.target; Transform transform = muscle.transform; if ((Object)(object)target == (Object)null || (Object)(object)transform == (Object)null) { return false; } List<string> list = CollectSeveredBoneNames(pm, muscleIndex); ConfigurableJoint val = null; if ((Object)(object)muscle.marrowJoint != (Object)null) { val = muscle.marrowJoint._configurableJoint; } if ((Object)(object)val == (Object)null) { val = ((Component)transform).GetComponent<ConfigurableJoint>(); } if ((Object)(object)val == (Object)null) { Core.Log.Warning("No joint on " + muscle.name + ", can't sever."); return false; } GameObject val2 = FindNpcRoot(pm); int num = 0; int num2 = 0; List<(SkinnedMeshRenderer, bool)> list2 = CollectSkins(val2); HashSet<string> chain = new HashSet<string>(list); if (organic) { foreach (var item in list2) { var (val3, _) = item; if (item.Item2 && (Object)(object)((Renderer)val3).sharedMaterial != (Object)null) { Flesh.TryUseNpcShader(((Renderer)val3).sharedMaterial); break; } } } Vector3 position = transform.position; HashSet<string> hashSet = new HashSet<string>(); foreach (Muscle item2 in (Il2CppArrayBase<Muscle>)(object)pm.muscles) { if (item2 != null) { if ((Object)(object)item2.target != (Object)null) { hashSet.Add(((Object)item2.target).name); } if ((Object)(object)item2.transform != (Object)null) { hashSet.Add(((Object)item2.transform).name); } } } foreach (var (smr, flag) in list2) { if (SplitSkin(smr, chain, position, transform, hashSet, flag && !explode)) { num2++; if (flag) { num++; } } } Transform val4 = ParentBone(pm, muscleIndex, position) ?? NearestRemainingBone(pm, muscleIndex, position); Vector3 val5 = (((Object)(object)val4 != (Object)null) ? (position - val4.position) : Vector3.zero); if (((Vector3)(ref val5)).sqrMagnitude < 0.0001f) { val5 = ((((Vector3)(ref hitDir)).sqrMagnitude > 0.0001f) ? (-hitDir) : Vector3.up); } ((Vector3)(ref val5)).Normalize(); float num3 = Flesh.RadiusFor(muscle.name); string name = muscle.name; try { pm.RemoveMuscleRecursive(val, false, true, (MuscleRemoveMode)0); } catch (Exception ex) { Core.Log.Warning($"Game detach failed for {muscle.name} ({ex.GetType().Name}); breaking the joint instead."); try { pm.KillJoint(val); } catch { Object.Destroy((Object)(object)val); } } if (num == 0) { Core.Log.Warning($"Couldn't split the mesh for {name}: root={(((Object)(object)val2 != (Object)null) ? ((Object)val2).name : "null")}, skins={list2.Count}, bones in chain=[{string.Join(", ", list)}]" + ((list2.Count > 0) ? (", first skin bones=[" + FirstBones(list2[0].Item1) + "]") : "")); } if (organic) { if (explode) { Sfx.Burst(position); } else { Sfx.Crack(position); Sfx.Squelch(position, 1f); } Stains.MarkBloody(transform); Stains.MarkBloody(val4); Stains.NearPlayer(position, explode ? 1f : 0.7f); } if (organic && (Object)(object)val4 != (Object)null) { Flesh.Cap(val4, position, val5, num3, (num3 >= 0.1f) ? 0.9f : 0.7f, num3 >= 0.1f); Blood.Stump(val4, position, val5, 1f); } if (explode) { ((Component)transform).gameObject.SetActive(false); if (organic) { Vector3 val6 = ((((Vector3)(ref hitDir)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref hitDir)).normalized : val5); Vector3 val7 = position + val5 * num3 * 1.5f; Flesh.Gibs(val7, val6, Settings.GibCount.Value, num3 * 2.2f); if (Settings.Blood.Value) { Blood.Hit(val7, val6, val5, 4f); Blood.Hit(val7, -val6, val5, 4f); if (Settings.BloodSplatters.Value) { for (int i = 0; i < 6; i++) { Vector3 val8 = val6 + Random.insideUnitSphere * 0.8f; Blood.Splatter(val7, ((Vector3)(ref val8)).normalized, 0.25f + Random.value * 0.25f); } } } } } else { Rigidbody component = ((Component)transform).GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null && ((Vector3)(ref hitDir)).sqrMagnitude > 0.0001f) { component.AddForce(((Vector3)(ref hitDir)).normalized * 2.5f, (ForceMode)2); } if (organic) { Flesh.Cap(transform, position, -val5, num3, (num3 >= 0.1f) ? 1.2f : 2.2f, splintered: true); Blood.Stump(transform, position, -val5, 0.6f); if (Settings.Blood.Value) { Blood.Hit(position, hitDir, val5, 3f); } if (Settings.Organs.Value && muscle.props != null && (int)muscle.props.group == 1 && (Object)(object)val4 != (Object)null) { Flesh.Organs(val4, transform, position, val5); } } } Poolee val9 = (((Object)(object)val2 != (Object)null) ? val2.GetComponentInParent<Poolee>() : null); if ((Object)(object)val9 != (Object)null) { _dismemberedPoolees.Add(((Il2CppObjectBase)val9).Pointer); } if (!fromNetwork) { FusionBridge.SendSever(val2, name, hitDir, explode, organic); } Core.Debug($"{(explode ? "Exploded" : "Severed")} {name} ({num} limb piece(s), {num2} skin(s) stumped incl. LODs)" + (fromNetwork ? " [from network]" : "")); return true; } private static Transform ParentBone(PuppetMaster pm, int muscleIndex, Vector3 jointPos) { //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_007b: 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) Il2CppReferenceArray<Muscle> muscles = pm.muscles; Muscle obj = ((Il2CppArrayBase<Muscle>)(object)muscles)[muscleIndex]; Il2CppStructArray<int> val = ((obj != null) ? obj.parentIndexes : null); if (val == null || ((Il2CppArrayBase<int>)(object)val).Length == 0) { return null; } Transform result = null; float num = float.MaxValue; for (int i = 0; i < ((Il2CppArrayBase<int>)(object)val).Length; i++) { int num2 = ((Il2CppArrayBase<int>)(object)val)[i]; if (num2 < 0 || num2 >= ((Il2CppArrayBase<Muscle>)(object)muscles).Length || num2 == muscleIndex) { continue; } Muscle obj2 = ((Il2CppArrayBase<Muscle>)(object)muscles)[num2]; Transform val2 = ((obj2 != null) ? obj2.transform : null); if (!((Object)(object)val2 == (Object)null)) { Vector3 val3 = val2.position - jointPos; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num) { num = sqrMagnitude; result = val2; } } } return result; } private static Transform NearestRemainingBone(PuppetMaster pm, int muscleIndex, Vector3 jointPos) { //IL_00bf: 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_00ca: Unknown result type (might be due to invalid IL or missing references) Il2CppReferenceArray<Muscle> muscles = pm.muscles; HashSet<int> hashSet = new HashSet<int>(); Stack<int> stack = new Stack<int>(); stack.Push(muscleIndex); while (stack.Count > 0) { int num = stack.Pop(); if (num < 0 || num >= ((Il2CppArrayBase<Muscle>)(object)muscles).Length || !hashSet.Add(num)) { continue; } Muscle obj = ((Il2CppArrayBase<Muscle>)(object)muscles)[num]; Il2CppStructArray<int> val = ((obj != null) ? obj.childIndexes : null); if (val != null) { for (int i = 0; i < ((Il2CppArrayBase<int>)(object)val).Length; i++) { stack.Push(((Il2CppArrayBase<int>)(object)val)[i]); } } } Transform result = null; float num2 = float.MaxValue; for (int j = 0; j < ((Il2CppArrayBase<Muscle>)(object)muscles).Length; j++) { if (hashSet.Contains(j)) { continue; } Muscle obj2 = ((Il2CppArrayBase<Muscle>)(object)muscles)[j]; Transform val2 = ((obj2 != null) ? obj2.transform : null); if (!((Object)(object)val2 == (Object)null)) { Vector3 val3 = val2.position - jointPos; float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude; if (sqrMagnitude < num2) { num2 = sqrMagnitude; result = val2; } } } return result; } private static GameObject FindNpcRoot(PuppetMaster pm) { AIBrain componentInParent = ((Component)pm).GetComponentInParent<AIBrain>(); if ((Object)(object)componentInParent != (Object)null) { return ((Component)componentInParent).gameObject; } Poolee componentInParent2 = ((Component)pm).GetComponentInParent<Poolee>(); if ((Object)(object)componentInParent2 != (Object)null) { return ((Component)componentInParent2).gameObject; } if (!((Object)(object)((Component)pm).transform.parent != (Object)null)) { return ((Component)pm).gameObject; } return ((Component)((Component)pm).transform.parent).gameObject; } private static List<(SkinnedMeshRenderer smr, bool primary)> CollectSkins(GameObject root) { List<(SkinnedMeshRenderer, bool)> list = new List<(SkinnedMeshRenderer, bool)>(); if ((Object)(object)root == (Object)null) { return list; } HashSet<IntPtr> hashSet = new HashSet<IntPtr>(); HashSet<IntPtr> hashSet2 = new HashSet<IntPtr>(); foreach (LODGroup componentsInChild in root.GetComponentsInChildren<LODGroup>(true)) { Il2CppReferenceArray<LOD> lODs = componentsInChild.GetLODs(); if (lODs == null) { continue; } for (int i = 0; i < ((Il2CppArrayBase<LOD>)(object)lODs).Length; i++) { Il2CppReferenceArray<Renderer> renderers = ((Il2CppArrayBase<LOD>)(object)lODs)[i].renderers; if (renderers == null) { continue; } foreach (Renderer item2 in (Il2CppArrayBase<Renderer>)(object)renderers) { if (!((Object)(object)item2 == (Object)null)) { hashSet2.Add(((Il2CppObjectBase)item2).Pointer); if (i == 0) { hashSet.Add(((Il2CppObjectBase)item2).Pointer); } } } } } foreach (SkinnedMeshRenderer componentsInChild2 in root.GetComponentsInChildren<SkinnedMeshRenderer>(true)) { if (!((Object)(object)componentsInChild2 == (Object)null) && !((Object)(object)componentsInChild2.sharedMesh == (Object)null) && !((Object)((Component)componentsInChild2).gameObject).name.StartsWith("GorePlus_")) { bool item = (hashSet.Contains(((Il2CppObjectBase)componentsInChild2).Pointer) || !hashSet2.Contains(((Il2CppObjectBase)componentsInChild2).Pointer)) && ((Component)componentsInChild2).gameObject.activeInHierarchy && ((Renderer)componentsInChild2).enabled; list.Add((componentsInChild2, item)); } } return list; } private static List<string> CollectSeveredBoneNames(PuppetMaster pm, int muscleIndex) { HashSet<string> names = new HashSet<string>(); Il2CppReferenceArray<Muscle> muscles = pm.muscles; HashSet<int> hashSet = new HashSet<int>(); Stack<int> stack = new Stack<int>(); stack.Push(muscleIndex); while (stack.Count > 0) { int num = stack.Pop(); if (num < 0 || num >= ((Il2CppArrayBase<Muscle>)(object)muscles).Length || !hashSet.Add(num)) { continue; } Muscle val = ((Il2CppArrayBase<Muscle>)(object)muscles)[num]; if (val == null) { continue; } AddTree(val.target); AddTree(val.transform); Il2CppStructArray<int> childIndexes = val.childIndexes; if (childIndexes != null) { for (int i = 0; i < ((Il2CppArrayBase<int>)(object)childIndexes).Length; i++) { stack.Push(((Il2CppArrayBase<int>)(object)childIndexes)[i]); } } } names.RemoveWhere((string n) => n.StartsWith("GorePlus_")); return new List<string>(names); void AddTree(Transform t) { if ((Object)(object)t == (Object)null) { return; } foreach (Transform componentsInChild in ((Component)t).GetComponentsInChildren<Transform>(true)) { if ((Object)(object)componentsInChild != (Object)null) { names.Add(((Object)componentsInChild).name); } } } } private static string FirstBones(SkinnedMeshRenderer smr) { Il2CppReferenceArray<Transform> bones = smr.bones; if (bones == null) { return "none"; } List<string> list = new List<string>(); for (int i = 0; i < ((Il2CppArrayBase<Transform>)(object)bones).Length && i < 40; i++) { list.Add(((Object)(object)((Il2CppArrayBase<Transform>)(object)bones)[i] != (Object)null) ? ((Object)((Il2CppArrayBase<Transform>)(object)bones)[i]).name : "null"); } return string.Join(", ", list); } private static bool SplitSkin(SkinnedMeshRenderer smr, HashSet<string> chain, Vector3 jointPos, Transform physicsBone, HashSet<string> muscleNames, bool makeLimb) { //IL_0065: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_0167: 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) Il2CppReferenceArray<Transform> bones = smr.bones; if (bones == null || ((Il2CppArrayBase<Transform>)(object)bones).Length == 0) { return false; } int length = ((Il2CppArrayBase<Transform>)(object)bones).Length; bool[] array = new bool[length]; bool flag = false; for (int i = 0; i < length; i++) { Transform val = ((Il2CppArrayBase<Transform>)(object)bones)[i]; if ((Object)(object)val != (Object)null && chain.Contains(((Object)val).name)) { array[i] = true; flag = true; } } if (!flag) { return false; } List<string> list = AdoptLimbHelpers(bones, array, jointPos, muscleNames); if (makeLimb && list.Count > 0) { Core.Debug("Also cut helper bones on '" + ((Object)smr).name + "': " + string.Join(", ", list)); } bool flag2 = false; bool flag3 = false; Transform val2 = null; Transform val3 = null; float num = float.MaxValue; float num2 = float.MaxValue; for (int j = 0; j < length; j++) { Transform val4 = ((Il2CppArrayBase<Transform>)(object)bones)[j]; if ((Object)(object)val4 == (Object)null) { continue; } Vector3 val5 = val4.position - jointPos; float sqrMagnitude = ((Vector3)(ref val5)).sqrMagnitude; if (array[j]) { flag2 = true; if (sqrMagnitude < num2) { num2 = sqrMagnitude; val3 = val4; } } else { flag3 = true; if (sqrMagnitude < num) { num = sqrMagnitude; val2 = val4; } } } if (!flag2) { return false; } if ((Object)(object)val3 == (Object)null) { val3 = physicsBone; } if ((Object)(object)val2 == (Object)null) { val2 = (((Object)(object)smr.rootBone != (Object)null) ? smr.rootBone : ((Component)smr).transform); } if (makeLimb) { MakeLimbCopy(smr, bones, array, val3, jointPos, physicsBone, val2); } if (flag3) { Transform val6 = MakeProxy(val2, jointPos); Il2CppReferenceArray<Transform> val7 = new Il2CppReferenceArray<Transform>((long)length); for (int k = 0; k < length; k++) { ((Il2CppArrayBase<Transform>)(object)val7)[k] = (array[k] ? val6 : ((Il2CppArrayBase<Transform>)(object)bones)[k]); } smr.bones = val7; MelonCoroutines.Start(StretchGuard(smr, val6, val2, physicsBone, makeLimb)); }