Decompiled source of GladiatorManager v0.2.0
plugins/GladiatorManager.dll
Decompiled 3 weeks 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.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Logging; using DM; using GladiatorManager.Arena; using GladiatorManager.Cinematic; using GladiatorManager.City; using GladiatorManager.Core; using GladiatorManager.Domain; using GladiatorManager.Injury; using GladiatorManager.Persistence; using GladiatorManager.Services; using GladiatorManager.TabsBridge; using GladiatorManager.UI; using HarmonyLib; using InControl; using Landfall.TABS; using Landfall.TABS.AI; using Landfall.TABS.AI.Components.Modifiers; using Landfall.TABS.AI.Systems; using Landfall.TABS.GameMode; using Landfall.TABS.GameState; using Landfall.TABS.RuntimeCleanup; using Landfall.TABS.Services; using Landfall.TABS.UnitPlacement; using Landfall.TABS.WinConditions; using Landfall.TABS.Workshop; using Landfall.TABS_Input; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using TFBGames; using TMPro; using Unity.Entities; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Rendering; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Gladiator Manager")] [assembly: AssemblyDescription("Gladiator school manager mode for Totally Accurate Battle Simulator (BepInEx plugin)")] [assembly: AssemblyCompany("lilzalupa")] [assembly: AssemblyProduct("GladiatorManager")] [assembly: AssemblyCopyright("lilzalupa")] [assembly: ComVisible(false)] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: AssemblyInformationalVersion("0.2.0-alpha")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.2.0.0")] namespace GladiatorManager { [BepInPlugin("gladiatormanager.core", "Gladiator Manager", "0.2.0")] public class Plugin : BaseUnityPlugin { private class Runner : MonoBehaviour { private void Update() { MainMenuIntegration.Tick(); DiscordInvite.Tick(); ArenaController.Tick(Time.unscaledDeltaTime); CityController.Tick(Time.unscaledDeltaTime); SelfTest.Tick(Time.unscaledDeltaTime); } } public const string Guid = "gladiatormanager.core"; public const string Version = "0.2.0"; private void Awake() { //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_00ae: Expected O, but got Unknown //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) Log.Init(((BaseUnityPlugin)this).Logger); SelfTest.Init(); Formulas.WeaponDpsProvider = ContentLookup.WeaponDps; try { Mod.Init(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), SelfTest.Enabled); } catch (Exception ex) { Log.Error("Gladiator Manager failed to initialise its school", ex); return; } try { new Harmony("gladiatormanager.core").PatchAll(typeof(Plugin).Assembly); } catch (Exception ex2) { Log.Error("Harmony patching failed", ex2); } SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode mode) { ArenaController.OnSceneLoaded(((Scene)(ref scene)).name); CityController.OnSceneLoaded(((Scene)(ref scene)).name); }; GameObject val = new GameObject("GladiatorManagerRunner"); Object.DontDestroyOnLoad((Object)val); ((Object)val).hideFlags = (HideFlags)61; val.AddComponent<Runner>(); Log.Info("Gladiator Manager 0.2.0 loaded."); } } } namespace GladiatorManager.Injury { internal class HitContext { public CollisionWeapon Weapon; public Rigidbody Body; public Collider Collider; public Vector3 Point; public Vector3 Direction; public float Impulse; public DamageKind? Kind; public bool Heavy; } internal class RegionInfo { public int Wound; public int Bone; public bool Severed; public bool Destroyed; public float Total; public float CutBleed; public int Hits; public InjuryState State { get { if (Destroyed) { return InjuryState.Destroyed; } if (Severed) { return InjuryState.Severed; } if (Bone == 3) { return InjuryState.Crushed; } if (Bone == 2) { return InjuryState.Fractured; } if (Wound == 2) { return InjuryState.DeepWound; } if (Wound == 1) { return InjuryState.Cut; } if (Bone == 1) { return InjuryState.Bruised; } return InjuryState.Healthy; } } } internal class InjuryEvent { public GladiatorAnatomy Victim; public Unit Attacker; public BodyRegion Region; public DamageKind Kind; public float Severity; public float HpDamage; public bool Covered; public bool Penetrated; public bool WasBlade; public string ArmorContent; public InjuryState Before; public InjuryState After; public Organ? OrganHit; public float OrganDamage; public bool Fatal; public Vector3 Point; public Vector3 Direction; } internal class GladiatorAnatomy : MonoBehaviour { public Unit Unit; public GladiatorRuntime Runtime; public float Blood = 1f; public float BleedRate; public bool Unconscious; public bool Frozen; public string FatalCause; private int _fatalSeq; private static int _fatalCounter; private static readonly List<GladiatorAnatomy> Pending = new List<GladiatorAnatomy>(); public bool Disarmed; public readonly Dictionary<BodyRegion, RegionInfo> Regions = new Dictionary<BodyRegion, RegionInfo>(); public readonly Dictionary<Organ, float> Organs = new Dictionary<Organ, float>(); public readonly List<InjuryEvent> Events = new List<InjuryEvent>(); public Rigidbody Head; public Rigidbody Torso; public Rigidbody Hip; public Rigidbody ArmL; public Rigidbody ElbowL; public Rigidbody ArmR; public Rigidbody ElbowR; public Rigidbody LegL; public Rigidbody KneeL; public Rigidbody LegR; public Rigidbody KneeR; public Transform MHandL; public Transform MHandR; public Transform MFootL; public Transform MFootR; public Transform MNeck; public SphereCollider Skull; public readonly Dictionary<string, Transform> MeshBones = new Dictionary<string, Transform>(); private readonly Dictionary<EquipmentSlot, float> _integrity = new Dictionary<EquipmentSlot, float>(); private readonly Dictionary<CollisionWeapon, float> _lastHit = new Dictionary<CollisionWeapon, float>(); private Unit _lastAttacker; private float _limpTimer; private float _funcTimer; private MovementHandler _movement; private Vector3 _torsoLocalFwd; private bool _hasLocalFwd; private static readonly Dictionary<BodyRegion, BodyRegion[]> Distal = new Dictionary<BodyRegion, BodyRegion[]> { { BodyRegion.UpperArmL, new BodyRegion[2] { BodyRegion.ForearmL, BodyRegion.HandL } }, { BodyRegion.ForearmL, new BodyRegion[1] { BodyRegion.HandL } }, { BodyRegion.UpperArmR, new BodyRegion[2] { BodyRegion.ForearmR, BodyRegion.HandR } }, { BodyRegion.ForearmR, new BodyRegion[1] { BodyRegion.HandR } }, { BodyRegion.ThighL, new BodyRegion[2] { BodyRegion.ShinL, BodyRegion.FootL } }, { BodyRegion.ShinL, new BodyRegion[1] { BodyRegion.FootL } }, { BodyRegion.ThighR, new BodyRegion[2] { BodyRegion.ShinR, BodyRegion.FootR } }, { BodyRegion.ShinR, new BodyRegion[1] { BodyRegion.FootR } }, { BodyRegion.Neck, new BodyRegion[1] } }; private bool _inHit; private string _knockOutPending; private bool _rightDropRolled; private bool _leftDropRolled; public bool RigOk { get; private set; } private static InjuryConfig Cfg => Mod.Injury; public static bool Active { get { if (Cfg.Enabled) { return ArenaController.Phase == ArenaPhase.Fighting; } return false; } } public Vector3 SkullCenter { get { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Skull != (Object)null)) { return Head.position + Up * 0.25f; } return ((Component)Skull).transform.TransformPoint(Skull.center); } } public float SkullRadius { get { //IL_002a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Skull != (Object)null)) { return 0.15f; } return Skull.radius * Mathf.Abs(((Component)Skull).transform.lossyScale.x); } } public Vector3 Up { get { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Head.position - Torso.position; if (!(((Vector3)(ref val)).sqrMagnitude > 1E-06f)) { return Vector3.up; } return ((Vector3)(ref val)).normalized; } } public float TorsoLength { get { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Head.position - Torso.position; return Mathf.Max(0.1f, ((Vector3)(ref val)).magnitude); } } public Vector3 Forward { get { //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0164: 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_016b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0078: 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) //IL_0084: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_00e5: Unknown result type (might be due to invalid IL or missing references) if (!_hasLocalFwd && (Object)(object)Torso != (Object)null && (Object)(object)Head != (Object)null) { Transform val = ((Component)Head).transform.Find("SpawnEyes"); Renderer[] array = (Renderer[])(((Object)(object)val != (Object)null) ? ((Array)((Component)val).GetComponentsInChildren<Renderer>(false)) : ((Array)new Renderer[0])); if (array.Length != 0) { Vector3 val2 = Vector3.zero; Renderer[] array2 = array; foreach (Renderer val3 in array2) { Vector3 val4 = val2; Bounds bounds = val3.bounds; val2 = val4 + ((Bounds)(ref bounds)).center; } Vector3 val5 = Vector3.ProjectOnPlane(val2 / (float)array.Length - SkullCenter, Up); if (((Vector3)(ref val5)).sqrMagnitude > 1E-06f) { _torsoLocalFwd = ((Component)Torso).transform.InverseTransformDirection(((Vector3)(ref val5)).normalized); _hasLocalFwd = true; } } } Vector3 val6 = (_hasLocalFwd ? ((Component)Torso).transform.TransformDirection(_torsoLocalFwd) : (((Object)(object)Unit.data != (Object)null && (Object)(object)Unit.data.characterForwardObject != (Object)null) ? Unit.data.characterForwardObject.forward : ((Component)Unit).transform.forward)); val6 = Vector3.ProjectOnPlane(val6, Up); if (!(((Vector3)(ref val6)).sqrMagnitude > 1E-06f)) { Vector3 val7 = Vector3.Cross(Up, Vector3.right); return ((Vector3)(ref val7)).normalized; } return ((Vector3)(ref val6)).normalized; } } public Vector3 Right { get { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Cross(Up, Forward); return ((Vector3)(ref val)).normalized; } } public string Name { get { if (!((Object)(object)Runtime != (Object)null) || Runtime.Profile == null) { if (!((Object)(object)Unit != (Object)null)) { return "?"; } return ((Object)Unit).name; } return Runtime.Profile.Name; } } private void OnDestroy() { Pending.Remove(this); } private void Start() { foreach (BodyRegion value in Enum.GetValues(typeof(BodyRegion))) { Regions[value] = new RegionInfo(); } foreach (Organ value2 in Enum.GetValues(typeof(Organ))) { Organs[value2] = 0f; } if ((Object)(object)Unit == (Object)null) { Unit = ((Component)this).GetComponent<Unit>(); } CacheRig(); _movement = (((Object)(object)Unit != (Object)null) ? ((Component)Unit).GetComponentInChildren<MovementHandler>() : null); } private void CacheRig() { if ((Object)(object)Unit == (Object)null) { return; } Rigidbody[] componentsInChildren = ((Component)Unit).GetComponentsInChildren<Rigidbody>(true); RigidbodyHolder componentInChildren = ((Component)Unit).GetComponentInChildren<RigidbodyHolder>(); Transform val = (((Object)(object)componentInChildren != (Object)null) ? ((Component)componentInChildren).transform : ((Component)Unit).transform); Rigidbody[] array = componentsInChildren; foreach (Rigidbody val2 in array) { if (((Component)val2).transform.IsChildOf(val)) { switch (((Object)val2).name) { case "Head": Head = val2; break; case "Torso": Torso = val2; break; case "Hip": Hip = val2; break; case "Arm_Left": ArmL = val2; break; case "Elbow_Left": ElbowL = val2; break; case "Arm_Right": ArmR = val2; break; case "Elbow_Right": ElbowR = val2; break; case "Leg_Left": LegL = val2; break; case "Knee_Left": KneeL = val2; break; case "Leg_Right": LegR = val2; break; case "Knee_Right": KneeR = val2; break; } } } Transform[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<Transform>(true); foreach (Transform val3 in componentsInChildren2) { if (((Object)val3).name.StartsWith("M_") && !MeshBones.ContainsKey(((Object)val3).name)) { MeshBones[((Object)val3).name] = val3; } } MeshBones.TryGetValue("M_Hand_Left", out MHandL); MeshBones.TryGetValue("M_Hand_Right", out MHandR); MeshBones.TryGetValue("M_Foot_Left", out MFootL); MeshBones.TryGetValue("M_Foot_Right", out MFootR); MeshBones.TryGetValue("M_Neck", out MNeck); if ((Object)(object)Head != (Object)null) { Skull = ((Component)Head).GetComponentsInChildren<SphereCollider>(true).FirstOrDefault(); } RigOk = Object.op_Implicit((Object)(object)Head) && Object.op_Implicit((Object)(object)Torso) && Object.op_Implicit((Object)(object)Hip) && Object.op_Implicit((Object)(object)ArmL) && Object.op_Implicit((Object)(object)ElbowL) && Object.op_Implicit((Object)(object)ArmR) && Object.op_Implicit((Object)(object)ElbowR) && Object.op_Implicit((Object)(object)LegL) && Object.op_Implicit((Object)(object)KneeL) && Object.op_Implicit((Object)(object)LegR) && Object.op_Implicit((Object)(object)KneeR) && Object.op_Implicit((Object)(object)MHandL) && Object.op_Implicit((Object)(object)MHandR) && Object.op_Implicit((Object)(object)MFootL) && Object.op_Implicit((Object)(object)MFootR); if (!RigOk) { Log.Warn("[Injury] incomplete rig on " + ((Object)Unit).name + ": localisation falls back to whole body parts"); } } private static float Along(Vector3 a, Vector3 b, Vector3 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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) Vector3 val = b - a; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (!(sqrMagnitude < 1E-06f)) { return Mathf.Clamp01(Vector3.Dot(p - a, val) / sqrMagnitude); } return 0f; } public BodyRegion? Localize(Rigidbody rb, Collider col, Vector3 p) { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_0062: 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_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_015a: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0254: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0264: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rb == (Object)null) { return null; } InjuryConfig cfg = Cfg; if ((Object)(object)rb == (Object)(object)Hip) { return BodyRegion.Pelvis; } if ((Object)(object)rb == (Object)(object)Torso) { float num = (((Object)(object)Head != (Object)null) ? Along(Torso.position, Head.position, p) : 0.6f); return (num >= cfg.NeckAbove) ? BodyRegion.Neck : ((num < cfg.AbdomenBelow) ? BodyRegion.Abdomen : BodyRegion.Chest); } if ((Object)(object)rb == (Object)(object)Head) { return (Along(Head.position, SkullCenter, p) < cfg.HeadNeckBelow) ? BodyRegion.Neck : BodyRegion.Head; } if ((Object)(object)rb == (Object)(object)ArmL) { return BodyRegion.UpperArmL; } if ((Object)(object)rb == (Object)(object)ArmR) { return BodyRegion.UpperArmR; } if ((Object)(object)rb == (Object)(object)ElbowL) { return ((Object)(object)MHandL != (Object)null && Along(ElbowL.position, MHandL.position, p) >= cfg.HandFrom) ? BodyRegion.HandL : BodyRegion.ForearmL; } if ((Object)(object)rb == (Object)(object)ElbowR) { return ((Object)(object)MHandR != (Object)null && Along(ElbowR.position, MHandR.position, p) >= cfg.HandFrom) ? BodyRegion.HandR : BodyRegion.ForearmR; } if ((Object)(object)rb == (Object)(object)LegL) { return BodyRegion.ThighL; } if ((Object)(object)rb == (Object)(object)LegR) { return BodyRegion.ThighR; } if ((Object)(object)rb == (Object)(object)KneeL) { return (((Object)(object)col != (Object)null && ((Object)col).name == "FootCollider") || ((Object)(object)MFootL != (Object)null && Along(KneeL.position, MFootL.position, p) >= cfg.FootFrom)) ? BodyRegion.FootL : BodyRegion.ShinL; } if ((Object)(object)rb == (Object)(object)KneeR) { return (((Object)(object)col != (Object)null && ((Object)col).name == "FootCollider") || ((Object)(object)MFootR != (Object)null && Along(KneeR.position, MFootR.position, p) >= cfg.FootFrom)) ? BodyRegion.FootR : BodyRegion.ShinR; } return null; } public void OrganSphere(Organ o, out Vector3 center, out float radius) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_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_004e: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_008c: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_010a: 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_0114: 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_0127: 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_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_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: 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_01d0: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_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_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01ff: Unknown result type (might be due to invalid IL or missing references) float torsoLength = TorsoLength; Vector3 position = Torso.position; Vector3 up = Up; Vector3 forward = Forward; Vector3 right = Right; switch (o) { case Organ.Brain: center = SkullCenter + up * SkullRadius * 0.1f; radius = SkullRadius * 0.75f; break; case Organ.Heart: center = position + up * (0.7f * torsoLength) - right * (0.1f * torsoLength) + forward * (0.12f * torsoLength); radius = 0.16f * torsoLength; break; case Organ.LungL: center = position + up * (0.74f * torsoLength) - right * (0.27f * torsoLength); radius = 0.21f * torsoLength; break; case Organ.LungR: center = position + up * (0.74f * torsoLength) + right * (0.27f * torsoLength); radius = 0.21f * torsoLength; break; case Organ.Liver: center = position + up * (0.4f * torsoLength) + right * (0.22f * torsoLength) + forward * (0.08f * torsoLength); radius = 0.19f * torsoLength; break; case Organ.KidneyL: center = position + up * (0.3f * torsoLength) - right * (0.18f * torsoLength) - forward * (0.22f * torsoLength); radius = 0.12f * torsoLength; break; default: center = position + up * (0.3f * torsoLength) + right * (0.18f * torsoLength) - forward * (0.22f * torsoLength); radius = 0.12f * torsoLength; break; } } private static EquipmentSlot? ArmorSlot(BodyRegion r, out float coverage) { coverage = 1f; switch (r) { case BodyRegion.Head: return EquipmentSlot.Head; case BodyRegion.Neck: coverage = 0.5f; return EquipmentSlot.Head; case BodyRegion.Chest: case BodyRegion.Abdomen: return EquipmentSlot.Torso; case BodyRegion.Pelvis: coverage = 0.6f; return EquipmentSlot.Legs; case BodyRegion.UpperArmL: case BodyRegion.ForearmL: case BodyRegion.UpperArmR: case BodyRegion.ForearmR: return EquipmentSlot.Arms; case BodyRegion.HandL: case BodyRegion.HandR: coverage = 0.5f; return EquipmentSlot.Arms; case BodyRegion.ThighL: case BodyRegion.ShinL: case BodyRegion.ThighR: case BodyRegion.ShinR: return EquipmentSlot.Legs; default: coverage = 0.5f; return EquipmentSlot.Legs; } } private float CoverDefense(BodyRegion r, out EquipmentSlot? slot) { float coverage; EquipmentSlot? covering = ArmorSlot(r, out coverage); slot = covering; ItemDefinition itemDefinition = (((Object)(object)Runtime != (Object)null && Runtime.Profile != null && Runtime.Profile.Items != null && covering.HasValue) ? Runtime.Profile.Items.FirstOrDefault((ItemDefinition i) => i.Slot == covering.Value) : null); if (itemDefinition == null || itemDefinition.Defense <= 0f) { slot = null; return 0f; } if (!_integrity.TryGetValue(slot.Value, out var value)) { value = 1f; } return itemDefinition.Defense * coverage * value; } private float BaseDefense() { CombatProfile combatProfile = (((Object)(object)Runtime != (Object)null) ? Runtime.Profile : null); if (combatProfile == null) { return 0f; } float num = ((combatProfile.Items != null) ? combatProfile.Items.Sum((ItemDefinition i) => i.Defense) : 0f); return Mathf.Max(0f, combatProfile.Defense - num) + num * Cfg.GlobalArmorShare; } public float ArmorIntegrity(EquipmentSlot slot) { if (!_integrity.TryGetValue(slot, out var value)) { return 1f; } return value; } public static DamageKind KindOf(CollisionWeapon weapon, Unit attacker, out bool heavy) { heavy = false; GladiatorRuntime gladiatorRuntime = (((Object)(object)attacker != (Object)null) ? ((Component)attacker).GetComponent<GladiatorRuntime>() : null); List<ItemDefinition> list = (((Object)(object)gladiatorRuntime != (Object)null && gladiatorRuntime.Profile != null) ? gladiatorRuntime.Profile.Items : null); WeaponHandler val = (((Object)(object)attacker != (Object)null) ? attacker.WeaponHandler : null); bool offHand = (Object)(object)weapon != (Object)null && (Object)(object)val != (Object)null && (Object)(object)val.leftWeapon != (Object)null && (Object)(object)((Component)val.leftWeapon).gameObject == (Object)(object)((Component)weapon).gameObject; bool flag = (Object)(object)weapon != (Object)null && (Object)(object)val != (Object)null && (Object)(object)val.rightWeapon != (Object)null && (Object)(object)((Component)val.rightWeapon).gameObject == (Object)(object)((Component)weapon).gameObject; ItemDefinition itemDefinition = list?.FirstOrDefault((ItemDefinition i) => i.Slot == (EquipmentSlot)(offHand ? 1 : 0)); if (itemDefinition == null || (!offHand && !flag && (Object)(object)weapon != (Object)null && (Object)(object)((Component)weapon).GetComponent<Holdable>() == (Object)null)) { return DamageKind.Blunt; } switch (itemDefinition.Category) { case ItemCategory.LongSword: case ItemCategory.Axe: heavy = true; return DamageKind.Cut; case ItemCategory.ShortSword: return DamageKind.Cut; case ItemCategory.Spear: case ItemCategory.Trident: return DamageKind.Pierce; case ItemCategory.Mace: heavy = true; return DamageKind.Blunt; default: return DamageKind.Blunt; } } private static float RegionHpScale(BodyRegion r) { InjuryConfig cfg = Cfg; switch (r) { case BodyRegion.Head: return cfg.RegionHpScaleHead; case BodyRegion.Neck: return cfg.RegionHpScaleNeck; case BodyRegion.Chest: case BodyRegion.Abdomen: case BodyRegion.Pelvis: return cfg.RegionHpScaleTorso; case BodyRegion.HandL: case BodyRegion.HandR: case BodyRegion.FootL: case BodyRegion.FootR: return cfg.RegionHpScaleExtremity; default: return cfg.RegionHpScaleLimb; } } public float ProcessHit(float raw, HitContext ctx, Unit attacker) { //IL_0086: 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_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) EconomyConfig config = Mod.Session.Config; float num = Mathf.Max(1f, ((Object)(object)Unit.data != (Object)null) ? Unit.data.maxHealth : 250f); float num2 = Mathf.Lerp(Cfg.SeverityReferenceHealth, num, Cfg.SeverityOwnHealthWeight); BodyRegion? bodyRegion = ((RigOk && ctx != null) ? Localize(ctx.Body, ctx.Collider, ctx.Point) : ((BodyRegion?)null)); if (!bodyRegion.HasValue || Frozen || (Object)(object)Unit.data == (Object)null || Unit.data.Dead) { return raw * config.DuelDamageScale * Formulas.DamageTakenFactor(config, ((Object)(object)Runtime != (Object)null) ? Runtime.Profile.Defense : 0f); } if ((Object)(object)attacker != (Object)null) { _lastAttacker = attacker; } InjuryConfig cfg = Cfg; BodyRegion value = bodyRegion.Value; RegionInfo regionInfo = Regions[value]; InjuryEvent injuryEvent = new InjuryEvent { Victim = this, Attacker = attacker, Region = value, Point = ctx.Point, Direction = ctx.Direction, Before = regionInfo.State }; float value2; bool num3 = (Object)(object)ctx.Weapon != (Object)null && _lastHit.TryGetValue(ctx.Weapon, out value2) && Time.time - value2 < 0.15f; if ((Object)(object)ctx.Weapon != (Object)null) { _lastHit[ctx.Weapon] = Time.time; } bool heavy; DamageKind damageKind = KindOf(ctx.Weapon, attacker, out heavy); if (ctx.Kind.HasValue) { damageKind = ctx.Kind.Value; heavy = ctx.Heavy; } EquipmentSlot? slot; float num4 = CoverDefense(value, out slot); float num5 = BaseDefense(); float defenseK = config.DefenseK; float num6 = config.DuelDamageScale * RegionHpScale(value); injuryEvent.Covered = num4 > 0f; if (slot.HasValue && (Object)(object)Runtime != (Object)null && Runtime.Profile != null && Runtime.Profile.Items != null) { injuryEvent.ArmorContent = Runtime.Profile.Items.FirstOrDefault((ItemDefinition i) => i.Slot == slot.Value)?.Content; } float num7 = damageKind switch { DamageKind.Pierce => cfg.ArmorVsPierce, DamageKind.Cut => cfg.ArmorVsCut, _ => cfg.ArmorVsBlunt, }; float num8 = raw * damageKind switch { DamageKind.Cut => 0.8f, DamageKind.Pierce => 1.2f, _ => 0f, }; bool flag = (injuryEvent.Penetrated = damageKind != DamageKind.Blunt && (num4 <= 0f || num8 >= num4 * cfg.ArmorStopPerPoint)); DamageKind damageKind2 = damageKind; float num9; float num10; if (damageKind != DamageKind.Blunt && !flag) { num9 = raw * num6 * cfg.BlockedBladeDamage * defenseK / (defenseK + num5); num10 = num9 / num2 * cfg.BluntTransmission; damageKind2 = DamageKind.Blunt; } else { num9 = raw * num6 * defenseK / (defenseK + num4 * cfg.ArmorCoverage * num7 + num5); num10 = num9 / num2; if (damageKind == DamageKind.Blunt && num4 > 0f) { num10 = Mathf.Max(num10, raw * num6 * defenseK / (defenseK + num5) / num2 * cfg.BluntTransmission); } } injuryEvent.Kind = damageKind2; injuryEvent.WasBlade = damageKind != DamageKind.Blunt; injuryEvent.Severity = num10; injuryEvent.HpDamage = num9; if (slot.HasValue) { float num11 = ArmorIntegrity(slot.Value); _integrity[slot.Value] = Mathf.Max(0.25f, num11 - cfg.ArmorWearPerHit * num10 * 10f); } if (!num3) { _inHit = true; _knockOutPending = null; regionInfo.Hits++; Escalate(value, regionInfo, damageKind2, num10, heavy, attacker, injuryEvent); if (flag || damageKind2 == DamageKind.Blunt) { OrganHit(value, damageKind2, num10, ctx, injuryEvent); } injuryEvent.After = regionInfo.State; Events.Add(injuryEvent); InjuryStats.Record(injuryEvent); Log.Info(string.Format("[Injury] {0}: {1} {2}→{3} ({4} s={5:F3} hp={6:F1} cover={7:F0} pen={8}){9}{10}", Name, value, injuryEvent.Before, injuryEvent.After, damageKind2, num10, num9, num4, flag, injuryEvent.OrganHit.HasValue ? $" organ {injuryEvent.OrganHit.Value} {injuryEvent.OrganDamage:F2}" : "", injuryEvent.Fatal ? (" FATAL " + FatalCause) : "")); InjuryVisuals.OnInjury(injuryEvent); CinematicDirector instance = CinematicDirector.Instance; if ((Object)(object)instance != (Object)null) { instance.OnInjury(injuryEvent); } _inHit = false; if (_knockOutPending != null) { string knockOutPending = _knockOutPending; _knockOutPending = null; KnockOut(knockOutPending); } } if (FatalCause != null && (Object)(object)Unit.data != (Object)null) { num9 = Mathf.Max(num9, Unit.data.health + 10f); } ApplyFunction(afterHit: true); return num9; } private static bool IsBoneRegion(BodyRegion r) { return r != BodyRegion.Abdomen; } private static bool Severable(BodyRegion r) { if (r != BodyRegion.Head && r != BodyRegion.Chest && r != BodyRegion.Abdomen) { return r != BodyRegion.Pelvis; } return false; } private static bool Extremity(BodyRegion r) { if (r != BodyRegion.HandL && r != BodyRegion.HandR && r != BodyRegion.FootL) { return r == BodyRegion.FootR; } return true; } private void Escalate(BodyRegion reg, RegionInfo info, DamageKind kind, float s, bool heavy, Unit attacker, InjuryEvent ev) { InjuryConfig cfg = Cfg; if (info.Severed) { return; } info.Total += s; if (kind == DamageKind.Blunt) { if (s >= cfg.BruiseMin && info.Bone < 1) { info.Bone = 1; } if (IsBoneRegion(reg)) { if (info.Bone < 2 && (s >= cfg.FractureSingle || info.Total >= cfg.FractureTotal)) { info.Bone = 2; } bool flag = reg == BodyRegion.Head || reg == BodyRegion.Neck; float num = reg switch { BodyRegion.Neck => cfg.NeckBreakSingle, BodyRegion.Head => cfg.SkullCrushSingle, _ => cfg.CrushSingle, }; if (info.Bone < 3 && (s >= num || (!flag && info.Bone >= 2 && s >= cfg.FractureSingle && info.Hits > 1))) { info.Bone = 3; } } goto IL_01dd; } int wound = info.Wound; if (s >= cfg.CutMin && info.Wound < 1) { info.Wound = 1; } if (info.Wound < 2 && (s >= cfg.DeepWoundSingle || info.Total >= cfg.DeepWoundTotal)) { info.Wound = 2; } if (info.Wound > wound) { info.CutBleed = ((info.Wound == 1) ? cfg.BleedCut : 0f); } bool num2; if (kind == DamageKind.Cut && Severable(reg)) { if (!heavy) { if (Extremity(reg)) { num2 = s >= cfg.SeverLight; goto IL_01ac; } } else { if (s >= cfg.SeverHeavy * ((reg == BodyRegion.Neck) ? 1.15f : 1f)) { goto IL_01ae; } if (wound >= 2) { num2 = s >= cfg.SeverOnDeepWound; goto IL_01ac; } } } goto IL_01b7; IL_01ae: Sever(reg, ev); goto IL_01b7; IL_01dd: if (reg == BodyRegion.Head && info.Bone >= 3) { info.Destroyed = true; Organs[Organ.Brain] = 1f; Kill("cause.skull", ev); } if (reg == BodyRegion.Neck && info.Bone >= 3) { Kill("cause.neck", ev); } if (reg == BodyRegion.Chest && info.Bone >= 3) { Organs[Organ.LungL] = Mathf.Max(Organs[Organ.LungL], 0.5f); Organs[Organ.LungR] = Mathf.Max(Organs[Organ.LungR], 0.5f); } return; IL_01b7: if (kind == DamageKind.Pierce && IsBoneRegion(reg) && s >= cfg.CrushSingle && info.Bone < 2) { info.Bone = 2; } goto IL_01dd; IL_01ac: if (num2) { goto IL_01ae; } goto IL_01b7; } private void OrganHit(BodyRegion reg, DamageKind kind, float s, HitContext ctx, InjuryEvent ev) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: 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_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) InjuryConfig cfg = Cfg; if (reg != BodyRegion.Head && reg != BodyRegion.Chest && reg != BodyRegion.Abdomen) { return; } float torsoLength = TorsoLength; float num = kind switch { DamageKind.Cut => Mathf.Min(0.5f, 0.12f + s * 2f) * torsoLength, DamageKind.Pierce => Mathf.Min(1f, 0.3f + s * 4f) * torsoLength, _ => (s >= 0.1f) ? (0.25f * torsoLength) : 0f, }; if (num <= 0f) { return; } Vector3 val = ((reg == BodyRegion.Head) ? SkullCenter : (Torso.position + Up * (0.55f * torsoLength))); Vector3 val2 = ctx.Direction; if (((Vector3)(ref val2)).sqrMagnitude < 1E-06f || Vector3.Dot(val2, val - ctx.Point) < 0f) { val2 = val - ctx.Point; } ((Vector3)(ref val2)).Normalize(); Vector3 point = ctx.Point; Vector3 b = ctx.Point + val2 * num; float num2 = kind switch { DamageKind.Cut => cfg.OrganCut, DamageKind.Pierce => cfg.OrganPierce, _ => cfg.OrganBlunt, }; Organ? organHit = null; float num3 = 0f; foreach (Organ value in Enum.GetValues(typeof(Organ))) { if (value == Organ.Brain != (reg == BodyRegion.Head) || (kind == DamageKind.Blunt && (value == Organ.Liver || value == Organ.KidneyL || value == Organ.KidneyR))) { continue; } OrganSphere(value, out var center, out var radius); float num4 = DistanceToSegment(center, point, b); if (!(num4 >= radius)) { float num5 = s * num2 * (1f - 0.5f * num4 / radius); Organs[value] = Mathf.Min(1f, Organs[value] + num5); if (num5 > num3) { num3 = num5; organHit = value; } } } if (organHit.HasValue) { ev.OrganHit = organHit; ev.OrganDamage = Organs[organHit.Value]; if (Organs[Organ.Heart] >= 1f) { Kill("cause.heart", ev); } if (Organs[Organ.Brain] >= 1f) { Regions[BodyRegion.Head].Destroyed = true; Kill("cause.brain", ev); } else if (Organs[Organ.Brain] >= cfg.BrainKnockout) { KnockOut("cause.brain"); } } } private static float DistanceToSegment(Vector3 p, Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_0041: Unknown result type (might be due to invalid IL or missing references) Vector3 val = b - a; float num = ((((Vector3)(ref val)).sqrMagnitude < 1E-06f) ? 0f : Mathf.Clamp01(Vector3.Dot(p - a, val) / ((Vector3)(ref val)).sqrMagnitude)); return Vector3.Distance(p, a + val * num); } public void Sever(BodyRegion reg, InjuryEvent ev) { //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) RegionInfo regionInfo = Regions[reg]; if (regionInfo.Severed) { return; } regionInfo.Severed = true; regionInfo.Wound = 2; if (Distal.TryGetValue(reg, out var value)) { BodyRegion[] array = value; foreach (BodyRegion key in array) { Regions[key].Severed = true; } } try { GladiatorDismemberment.Sever(this, reg, ev?.Direction ?? Vector3.zero); } catch (Exception ex) { Log.Error("[Injury] severing " + reg.ToString() + " failed", ex); } if (IsArm(reg)) { DropWeapon(IsLeft(reg)); } if (reg == BodyRegion.Neck) { Kill("cause.decapitation", ev); } } public static bool IsArm(BodyRegion r) { if (r != BodyRegion.UpperArmL && r != BodyRegion.ForearmL && r != BodyRegion.HandL && r != BodyRegion.UpperArmR && r != BodyRegion.ForearmR) { return r == BodyRegion.HandR; } return true; } public static bool IsLeg(BodyRegion r) { if (r != BodyRegion.ThighL && r != BodyRegion.ShinL && r != BodyRegion.FootL && r != BodyRegion.ThighR && r != BodyRegion.ShinR) { return r == BodyRegion.FootR; } return true; } public static bool IsLeft(BodyRegion r) { if (r != BodyRegion.UpperArmL && r != BodyRegion.ForearmL && r != BodyRegion.HandL && r != BodyRegion.ThighL && r != BodyRegion.ShinL) { return r == BodyRegion.FootL; } return true; } public void DropWeapon(bool left) { HoldingHandler componentInChildren = ((Component)Unit).GetComponentInChildren<HoldingHandler>(); WeaponHandler weaponHandler = Unit.WeaponHandler; if ((Object)(object)componentInChildren == (Object)null) { return; } Holdable val = (left ? componentInChildren.leftObject : componentInChildren.rightObject); if ((Object)(object)val == (Object)null) { return; } GameObject gameObject = ((Component)val).gameObject; componentInChildren.LetGoOfWeapon(gameObject); if ((Object)(object)weaponHandler != (Object)null) { if ((Object)(object)weaponHandler.rightWeapon != (Object)null && (Object)(object)((Component)weaponHandler.rightWeapon).gameObject == (Object)(object)gameObject) { weaponHandler.rightWeapon = null; } if ((Object)(object)weaponHandler.leftWeapon != (Object)null && (Object)(object)((Component)weaponHandler.leftWeapon).gameObject == (Object)(object)gameObject) { weaponHandler.leftWeapon = null; } } InjuryStats.WeaponsDropped++; Log.Info("[Injury] " + Name + " drops " + ((Object)gameObject).name + (left ? " (left hand)" : " (right hand)")); if ((Object)(object)componentInChildren.leftObject == (Object)null && (Object)(object)componentInChildren.rightObject == (Object)null) { Disarmed = true; } } private void Kill(string cause, InjuryEvent ev) { if (FatalCause == null) { FatalCause = cause; if ((Object)(object)Unit != (Object)null && (Object)(object)Unit == (Object)(object)ArenaController.RedUnit) { ArenaController.OnRedFatal(cause); } _fatalSeq = ++_fatalCounter; if (!Pending.Contains(this)) { Pending.Add(this); } if (ev != null) { ev.Fatal = true; } InjuryStats.FatalInjuries++; Log.Info("[Injury] " + Name + ": fatal injury (" + cause + ")"); } } private void KnockOut(string cause) { if (Unconscious || Frozen) { return; } if (_inHit) { _knockOutPending = cause; return; } Unconscious = true; InjuryStats.KnockOuts++; Log.Info("[Injury] " + Name + " loses consciousness (" + cause + ")"); if ((Object)(object)Runtime != (Object)null) { ArenaController.OnGladiatorIncapacitated(Runtime, cause); } } private void Update() { if ((Object)(object)Unit == (Object)null || (Object)(object)Unit.data == (Object)null || !Active || Frozen || Unit.data.Dead) { return; } _inHit = false; float deltaTime = Time.deltaTime; InjuryConfig cfg = Cfg; if (FatalCause != null) { if (_fatalSeq == 0) { _fatalSeq = ++_fatalCounter; } if (!Pending.Any((GladiatorAnatomy a) => (Object)(object)a != (Object)(object)this && (Object)(object)a != (Object)null && a._fatalSeq > 0 && a._fatalSeq < _fatalSeq && (Object)(object)a.Unit != (Object)null && (Object)(object)a.Unit.data != (Object)null && !a.Unit.data.Dead && !a.Frozen)) { Die(); } return; } BleedRate = 0f; foreach (KeyValuePair<BodyRegion, RegionInfo> region in Regions) { RegionInfo value = region.Value; if (value.Severed) { if (IsProximalSever(region.Key)) { BleedRate += (IsLeg(region.Key) ? cfg.BleedSeveredLeg : (IsArm(region.Key) ? cfg.BleedSeveredArm : cfg.BleedNeckWound)); } continue; } if (value.Wound == 2) { BleedRate += ((region.Key == BodyRegion.Neck) ? cfg.BleedNeckWound : cfg.BleedDeepWound); } else if (value.Wound == 1) { value.CutBleed *= Mathf.Exp((0f - deltaTime) / Mathf.Max(1f, cfg.ClotSeconds)); BleedRate += value.CutBleed; } if (value.Bone == 3) { BleedRate += cfg.BleedCrushed; } else if (value.Bone == 2) { BleedRate += cfg.BleedFracture; } } BleedRate += Organs[Organ.Heart] * cfg.BleedHeart + (Organs[Organ.LungL] + Organs[Organ.LungR]) * cfg.BleedLung + Organs[Organ.Liver] * cfg.BleedLiver + (Organs[Organ.KidneyL] + Organs[Organ.KidneyR]) * cfg.BleedKidney; Blood = Mathf.Max(0f, Blood - BleedRate * deltaTime); if (Blood <= cfg.BloodDeath) { if (FatalCause == null) { FatalCause = "cause.bleed"; InjuryStats.FatalInjuries++; } Die(); return; } if (Blood <= cfg.BloodUnconscious && !Unconscious) { KnockOut("cause.bleed"); } _funcTimer -= deltaTime; if (_funcTimer <= 0f) { _funcTimer = 0.25f; ApplyFunction(afterHit: false); } Limp(deltaTime); if (Unconscious) { Unit.data.fallTime = 5f; } InjuryVisuals.Bleed(this, deltaTime); } private bool IsProximalSever(BodyRegion r) { foreach (KeyValuePair<BodyRegion, BodyRegion[]> item in Distal) { if (item.Value.Contains(r) && Regions[item.Key].Severed) { return false; } } return true; } private void Die() { if (!Unit.data.Dead && !((Object)(object)Unit.data.healthHandler == (Object)null)) { Log.Info("[Injury] " + Name + " dies (" + FatalCause + ")"); Unit.data.healthHandler.Die(_lastAttacker); } } private void ApplyFunction(bool afterHit) { if ((Object)(object)Runtime == (Object)null) { return; } InjuryConfig cfg = Cfg; float num = ((Blood >= cfg.BloodWeakFrom) ? 1f : Mathf.Lerp(0.45f, 1f, Mathf.InverseLerp(cfg.BloodUnconscious, cfg.BloodWeakFrom, Blood))); int num2 = LegLevel(left: true); int num3 = LegLevel(left: false); float num4 = 0f; if (num2 == 3 || num3 == 3) { num4 = cfg.LegSeveredSlow; } else if (num2 == 2 || num3 == 2 || (num2 >= 1 && num3 >= 1)) { num4 = cfg.LegsBrokenSlow; } else if (num2 == 1 || num3 == 1) { num4 = cfg.LegFractureSlow; } bool flag = ArmLevel(left: false) >= 1; bool flag2 = ArmLevel(left: true) >= 1; float num5 = Mathf.Clamp01(Organs[Organ.LungL] + Organs[Organ.LungR]); Runtime.InjuryMove = (1f - num4) * num; Runtime.InjuryAttack = (flag ? cfg.ArmFractureAttack : 1f) * num; Runtime.InjuryDamage = num; Runtime.InjuryRegen = num * (1f - 0.5f * num5); if (!afterHit) { return; } if (flag && !_rightDropRolled) { _rightDropRolled = true; if (Random.value < cfg.ArmFractureDropChance) { DropWeapon(left: false); } } if (flag2 && !_leftDropRolled) { _leftDropRolled = true; if (Random.value < cfg.ArmFractureDropChance) { DropWeapon(left: true); } } } public int LegLevel(bool left) { int num = 0; BodyRegion[] array = ((!left) ? new BodyRegion[3] { BodyRegion.ThighR, BodyRegion.ShinR, BodyRegion.FootR } : new BodyRegion[3] { BodyRegion.ThighL, BodyRegion.ShinL, BodyRegion.FootL }); foreach (BodyRegion key in array) { RegionInfo regionInfo = Regions[key]; if (regionInfo.Severed) { num = Math.Max(num, 3); } else if (regionInfo.Bone == 3) { num = Math.Max(num, 2); } else if (regionInfo.Bone == 2) { num = Math.Max(num, 1); } } return num; } public int ArmLevel(bool left) { int num = 0; BodyRegion[] array = ((!left) ? new BodyRegion[3] { BodyRegion.UpperArmR, BodyRegion.ForearmR, BodyRegion.HandR } : new BodyRegion[3] { BodyRegion.UpperArmL, BodyRegion.ForearmL, BodyRegion.HandL }); foreach (BodyRegion key in array) { RegionInfo regionInfo = Regions[key]; if (regionInfo.Severed) { num = Math.Max(num, 3); } else if (regionInfo.Bone >= 2) { num = Math.Max(num, regionInfo.Bone - 1); } } return num; } private void Limp(float dt) { int num = LegLevel(left: true); int num2 = LegLevel(left: false); int num3 = Math.Max(num, num2); if (num3 == 0 || Unconscious) { return; } _limpTimer -= dt; if (!(_limpTimer > 0f)) { _limpTimer = 1.5f; float num4 = ((num3 >= 3) ? 0.85f : (Cfg.LimpFallChance * ((num >= 1 && num2 >= 1) ? 3f : ((num3 >= 2) ? 2f : 1f)))); if (Random.value < num4 && Unit.data.isGrounded) { Unit.data.fallTime = ((num3 >= 3) ? 2.5f : 0.7f); InjuryStats.Stumbles++; } } } public List<InjuryRecord> Snapshot() { InjuryConfig cfg = Cfg; List<InjuryRecord> list = new List<InjuryRecord>(); foreach (KeyValuePair<BodyRegion, RegionInfo> region in Regions) { InjuryState state = region.Value.State; int num = state switch { InjuryState.Crushed => cfg.DaysCrushed, InjuryState.Fractured => cfg.DaysFractured, InjuryState.DeepWound => cfg.DaysDeepWound, InjuryState.Cut => cfg.DaysCut, _ => 0, }; bool flag = state == InjuryState.Severed || state == InjuryState.Destroyed; if ((!region.Value.Severed || IsProximalSever(region.Key)) && (num > 0 || flag)) { list.Add(new InjuryRecord { Region = region.Key, State = state, DaysLeft = num, Permanent = flag }); } } return list; } public BattleInjuryReport Freeze() { InjuryConfig cfg = Cfg; if (!Frozen && FatalCause == null && (Object)(object)Unit != (Object)null && (Object)(object)Unit.data != (Object)null && !Unit.data.Dead && BleedRate > 0f && Blood - BleedRate * cfg.BleedProjectionSeconds <= cfg.BloodDeath) { FatalCause = "cause.bleed"; InjuryStats.FatalInjuries++; Log.Info($"[Injury] {Name}: bleeds out after the duel (blood {Blood:P0}, losing {BleedRate:P1}/s)"); } Frozen = true; BattleInjuryReport battleInjuryReport = new BattleInjuryReport { Fatal = (FatalCause != null), CauseKey = FatalCause }; foreach (KeyValuePair<BodyRegion, RegionInfo> region in Regions) { InjuryState state = region.Value.State; int num = state switch { InjuryState.Crushed => cfg.DaysCrushed, InjuryState.Fractured => cfg.DaysFractured, InjuryState.DeepWound => cfg.DaysDeepWound, InjuryState.Cut => cfg.DaysCut, _ => 0, }; bool flag = state == InjuryState.Severed || state == InjuryState.Destroyed; if ((!region.Value.Severed || IsProximalSever(region.Key)) && (num > 0 || flag)) { battleInjuryReport.Injuries.Add(new InjuryRecord { Region = region.Key, State = state, DaysLeft = num, Permanent = flag }); } } return battleInjuryReport; } public string Summary() { IEnumerable<string> source = from kv in Regions where kv.Value.State != InjuryState.Healthy select kv.Key.ToString() + "=" + kv.Value.State; IEnumerable<string> source2 = from kv in Organs where kv.Value > 0.01f select $"{kv.Key}={kv.Value:F2}"; return string.Format("blood {0:P0} bleed {1:P1}/s [{2}] organs [{3}]{4}{5}", Blood, BleedRate, string.Join(", ", source.ToArray()), string.Join(", ", source2.ToArray()), Unconscious ? " UNCONSCIOUS" : "", (FatalCause != null) ? (" FATAL " + FatalCause) : ""); } } internal static class InjuryStats { public static int Hits; public static int Localized; public static int Cuts; public static int DeepWounds; public static int Fractures; public static int Crushes; public static int Severs; public static int OrganHits; public static int FatalInjuries; public static int KnockOuts; public static int WeaponsDropped; public static int Stumbles; public static int ArmorBlocked; public static readonly Dictionary<BodyRegion, int> ByRegion = new Dictionary<BodyRegion, int>(); public static readonly List<InjuryEvent> Recent = new List<InjuryEvent>(); public static void Record(InjuryEvent ev) { Localized++; ByRegion[ev.Region] = (ByRegion.TryGetValue(ev.Region, out var value) ? value : 0) + 1; if (ev.Covered && !ev.Penetrated && ev.Kind == DamageKind.Blunt) { ArmorBlocked++; } if (ev.After != ev.Before) { switch (ev.After) { case InjuryState.Cut: Cuts++; break; case InjuryState.DeepWound: DeepWounds++; break; case InjuryState.Fractured: Fractures++; break; case InjuryState.Crushed: Crushes++; break; case InjuryState.Severed: Severs++; break; } } if (ev.OrganHit.HasValue) { OrganHits++; } Recent.Add(ev); if (Recent.Count > 400) { Recent.RemoveAt(0); } } } internal static class InjuryHitResolver { [HarmonyPatch(typeof(CollisionWeapon), "OnCollisionEnter")] private static class Capture { private static void Prefix(CollisionWeapon __instance, Collision collision) { //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_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_006a: 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_0076: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) _current = null; try { if (GladiatorAnatomy.Active && collision != null && !((Object)(object)collision.rigidbody == (Object)null) && !((Object)(object)collision.transform.root == (Object)(object)((Component)__instance).transform.root)) { Vector3 val; if (collision.contactCount <= 0) { val = collision.rigidbody.position; } else { ContactPoint contact = collision.GetContact(0); val = ((ContactPoint)(ref contact)).point; } Vector3 point = val; Vector3 val2 = -collision.relativeVelocity; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = ((Component)__instance).transform.forward; } HitContext obj = new HitContext { Weapon = __instance, Body = collision.rigidbody, Collider = collision.collider, Point = point, Direction = ((Vector3)(ref val2)).normalized }; Vector3 impulse = collision.impulse; obj.Impulse = ((Vector3)(ref impulse)).magnitude; _current = obj; Captured++; } } catch (Exception ex) { Log.Error("[Injury] contact capture failed", ex); } } private static Exception Finalizer(Exception __exception) { _current = null; return __exception; } } private static HitContext _current; public static int Captured; public static int Consumed; public static void Inject(HitContext ctx) { _current = ctx; } public static HitContext Take(Unit victim) { HitContext current = _current; if (current == null || (Object)(object)victim == (Object)null || (Object)(object)current.Body == (Object)null) { return null; } DataHandler componentInParent = ((Component)current.Body).GetComponentInParent<DataHandler>(); if ((Object)(object)componentInParent == (Object)null || (Object)(object)componentInParent.unit != (Object)(object)victim) { return null; } _current = null; Consumed++; return current; } } internal static class GladiatorDismemberment { private struct Plan { public string[] Lost; public string Parent; public Rigidbody[] Bodies; public string[] Colliders; public Rigidbody Anchor; } private class PieceBuilder { public readonly List<Vector3> V = new List<Vector3>(); public readonly List<Vector3> N = new List<Vector3>(); public readonly List<Vector2> UV = new List<Vector2>(); public readonly List<List<int>> Sub = new List<List<int>>(); public readonly List<Material> Mats = new List<Material>(); public List<int> Submesh(Material m) { Sub.Add(new List<int>()); Mats.Add(m); return Sub[Sub.Count - 1]; } } private static readonly List<GameObject> Pieces = new List<GameObject>(); public static int LastCapTriangles; public static int LastPieceTriangles; public static int LastMeshesCut; public static int PieceCount { get { Pieces.RemoveAll((GameObject p) => (Object)(object)p == (Object)null); return Pieces.Count; } } private static Plan PlanFor(GladiatorAnatomy a, BodyRegion r) { return r switch { BodyRegion.UpperArmL => new Plan { Lost = new string[3] { "M_Arm_Left", "M_Elbow_Left", "M_Hand_Left" }, Parent = "M_Torso", Bodies = (Rigidbody[])(object)new Rigidbody[2] { a.ArmL, a.ElbowL }, Anchor = a.ArmL }, BodyRegion.UpperArmR => new Plan { Lost = new string[3] { "M_Arm_Right", "M_Elbow_Right", "M_Hand_Right" }, Parent = "M_Torso", Bodies = (Rigidbody[])(object)new Rigidbody[2] { a.ArmR, a.ElbowR }, Anchor = a.ArmR }, BodyRegion.ForearmL => new Plan { Lost = new string[2] { "M_Elbow_Left", "M_Hand_Left" }, Parent = "M_Arm_Left", Bodies = (Rigidbody[])(object)new Rigidbody[1] { a.ElbowL }, Anchor = a.ElbowL }, BodyRegion.ForearmR => new Plan { Lost = new string[2] { "M_Elbow_Right", "M_Hand_Right" }, Parent = "M_Arm_Right", Bodies = (Rigidbody[])(object)new Rigidbody[1] { a.ElbowR }, Anchor = a.ElbowR }, BodyRegion.HandL => new Plan { Lost = new string[1] { "M_Hand_Left" }, Parent = "M_Elbow_Left", Bodies = (Rigidbody[])(object)new Rigidbody[0], Anchor = a.ElbowL }, BodyRegion.HandR => new Plan { Lost = new string[1] { "M_Hand_Right" }, Parent = "M_Elbow_Right", Bodies = (Rigidbody[])(object)new Rigidbody[0], Anchor = a.ElbowR }, BodyRegion.ThighL => new Plan { Lost = new string[3] { "M_Leg_Left", "M_Knee_Left", "M_Foot_Left" }, Parent = "M_Hip", Bodies = (Rigidbody[])(object)new Rigidbody[2] { a.LegL, a.KneeL }, Anchor = a.LegL }, BodyRegion.ThighR => new Plan { Lost = new string[3] { "M_Leg_Right", "M_Knee_Right", "M_Foot_Right" }, Parent = "M_Hip", Bodies = (Rigidbody[])(object)new Rigidbody[2] { a.LegR, a.KneeR }, Anchor = a.LegR }, BodyRegion.ShinL => new Plan { Lost = new string[2] { "M_Knee_Left", "M_Foot_Left" }, Parent = "M_Leg_Left", Bodies = (Rigidbody[])(object)new Rigidbody[1] { a.KneeL }, Anchor = a.KneeL }, BodyRegion.ShinR => new Plan { Lost = new string[2] { "M_Knee_Right", "M_Foot_Right" }, Parent = "M_Leg_Right", Bodies = (Rigidbody[])(object)new Rigidbody[1] { a.KneeR }, Anchor = a.KneeR }, BodyRegion.FootL => new Plan { Lost = new string[1] { "M_Foot_Left" }, Parent = "M_Knee_Left", Bodies = (Rigidbody[])(object)new Rigidbody[1] { a.KneeL }, Colliders = new string[1] { "FootCollider" }, Anchor = a.KneeL }, BodyRegion.FootR => new Plan { Lost = new string[1] { "M_Foot_Right" }, Parent = "M_Knee_Right", Bodies = (Rigidbody[])(object)new Rigidbody[1] { a.KneeR }, Colliders = new string[1] { "FootCollider" }, Anchor = a.KneeR }, BodyRegion.Neck => new Plan { Lost = new string[2] { "M_Neck", "M_Head" }, Parent = "M_Torso", Bodies = (Rigidbody[])(object)new Rigidbody[1] { a.Head }, Anchor = a.Head }, _ => default(Plan), }; } public static GameObject Sever(GladiatorAnatomy a, BodyRegion region, Vector3 blowDir) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_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_0424: Unknown result type (might be due to invalid IL or missing references) //IL_0429: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_043d: Unknown result type (might be due to invalid IL or missing references) //IL_0441: 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_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0456: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) Plan plan = PlanFor(a, region); if (plan.Lost == null) { return null; } HashSet<string> hashSet = new HashSet<string>(plan.Lost); PieceBuilder pieceBuilder = new PieceBuilder(); Vector3 val = Vector3.zero; int num = 0; LastCapTriangles = (LastPieceTriangles = (LastMeshesCut = 0)); foreach (SkinnedMeshRenderer item3 in ((Component)a.Unit).GetComponentsInChildren<SkinnedMeshRenderer>(true).ToList()) { if ((Object)(object)item3 == (Object)null || (Object)(object)item3.sharedMesh == (Object)null || !item3.sharedMesh.isReadable) { continue; } Transform[] bones = item3.bones; HashSet<int> hashSet2 = new HashSet<int>(); int parentIdx = -1; for (int i = 0; i < bones.Length; i++) { if (!((Object)(object)bones[i] == (Object)null)) { if (hashSet.Contains(((Object)bones[i]).name)) { hashSet2.Add(i); } if (((Object)bones[i]).name == plan.Parent) { parentIdx = i; } } } if (hashSet2.Count != 0) { bool flag = ((Object)item3).name.StartsWith("TabsUnit"); bool flag2 = ((Renderer)item3).enabled && ((Component)item3).gameObject.activeInHierarchy && (flag ? (((Object)item3).name == "TabsUnit") : (!((Object)item3).name.Contains("_LOD") && (!((Object)item3).name.StartsWith("LOD") || !(((Object)item3).name != "LOD0")))); if (CutMesh(item3, hashSet2, parentIdx, flag, flag2 ? pieceBuilder : null, out var worldCentre)) { val += worldCentre; num++; } LastMeshesCut++; } } HashSet<Transform> hashSet3 = new HashSet<Transform>(); string[] lost = plan.Lost; foreach (string key in lost) { if (a.MeshBones.TryGetValue(key, out var value) && (Object)(object)value != (Object)null) { Transform[] componentsInChildren = ((Component)value).GetComponentsInChildren<Transform>(true); foreach (Transform item in componentsInChildren) { hashSet3.Add(item); } } } if (region == BodyRegion.Neck && (Object)(object)a.Head != (Object)null) { Transform val2 = ((Component)a.Head).transform.Find("SpawnEyes"); if ((Object)(object)val2 != (Object)null) { Transform[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Transform>(true); foreach (Transform item2 in componentsInChildren) { hashSet3.Add(item2); } } } List<MeshRenderer> list = new List<MeshRenderer>(); MeshRenderer[] componentsInChildren2 = ((Component)a.Unit).GetComponentsInChildren<MeshRenderer>(false); foreach (MeshRenderer val3 in componentsInChildren2) { if (((Object)(object)val3 != (Object)null && ((Renderer)val3).enabled && hashSet3.Contains(((Component)val3).transform.parent)) || ((Object)(object)val3 != (Object)null && ((Renderer)val3).enabled && IsUnder(((Component)val3).transform, hashSet3))) { list.Add(val3); } } GameObject result = (((Object)(object)plan.Anchor != (Object)null) ? BuildPiece(a, region, plan, pieceBuilder, list, blowDir) : null); foreach (MeshRenderer item4 in list) { ((Renderer)item4).enabled = false; } Rigidbody[] bodies = plan.Bodies; foreach (Rigidbody val4 in bodies) { if ((Object)(object)val4 == (Object)null) { continue; } Collider[] componentsInChildren3 = ((Component)val4).GetComponentsInChildren<Collider>(true); foreach (Collider val5 in componentsInChildren3) { if (plan.Colliders == null || plan.Colliders.Contains(((Object)val5).name)) { val5.enabled = false; } } } if (num > 0 && a.MeshBones.TryGetValue(plan.Parent, out var value2) && (Object)(object)value2 != (Object)null) { GameObject val6 = new GameObject("GM_Stump"); val6.transform.SetParent(value2, false); val6.transform.position = val / (float)num; InjuryVisuals.AttachSpurt(outward: val / (float)num - value2.position, at: val6.transform, seconds: (region == BodyRegion.Neck) ? 4f : 2.5f); } Log.Info($"[Injury] {a.Name}: {region} severed — {LastMeshesCut} meshes cut, {LastCapTriangles} cap triangles, piece {LastPieceTriangles} triangles"); return result; } private static bool CutMesh(SkinnedMeshRenderer smr, HashSet<int> lostIdx, int parentIdx, bool isBody, PieceBuilder piece, out Vector3 worldCentre) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_00cc: 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_014b: 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_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: 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_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0333: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_053f: Unknown result type (might be due to invalid IL or missing references) //IL_0544: Unknown result type (might be due to invalid IL or missing references) //IL_0549: Unknown result type (might be due to invalid IL or missing references) //IL_0563: Unknown result type (might be due to invalid IL or missing references) //IL_0576: Unknown result type (might be due to invalid IL or missing references) //IL_057b: Unknown result type (might be due to invalid IL or missing references) //IL_0580: Unknown result type (might be due to invalid IL or missing references) //IL_0585: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_0594: 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_05c0: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: 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_05d4: Unknown result type (might be due to invalid IL or missing references) //IL_05d9: Unknown result type (might be due to invalid IL or missing references) //IL_05dd: Unknown result type (might be due to invalid IL or missing references) //IL_05df: Unknown result type (might be due to invalid IL or missing references) //IL_05e4: Unknown result type (might be due to invalid IL or missing references) //IL_05e9: Unknown result type (might be due to invalid IL or missing references) //IL_0612: Unknown result type (might be due to invalid IL or missing references) //IL_0619: Unknown result type (might be due to invalid IL or missing references) //IL_061e: Unknown result type (might be due to invalid IL or missing references) //IL_0623: Unknown result type (might be due to invalid IL or missing references) //IL_0638: Unknown result type (might be due to invalid IL or missing references) //IL_063f: Unknown result type (might be due to invalid IL or missing references) //IL_0644: Unknown result type (might be due to invalid IL or missing references) //IL_0649: Unknown result type (might be due to invalid IL or missing references) //IL_064b: Unknown result type (might be due to invalid IL or missing references) //IL_064d: 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_0656: Unknown result type (might be due to invalid IL or missing references) //IL_065b: Unknown result type (might be due to invalid IL or missing references) //IL_068d: Unknown result type (might be due to invalid IL or missing references) //IL_0684: Unknown result type (might be due to invalid IL or missing references) //IL_0692: Unknown result type (might be due to invalid IL or missing references) //IL_0694: Unknown result type (might be due to invalid IL or missing references) //IL_0696: Unknown result type (might be due to invalid IL or missing references) //IL_06b0: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Unknown result type (might be due to invalid IL or missing references) //IL_06b5: Unknown result type (might be due to invalid IL or missing references) //IL_06ba: Unknown result type (might be due to invalid IL or missing references) //IL_06be: Unknown result type (might be due to invalid IL or missing references) //IL_06c3: Unknown result type (might be due to invalid IL or missing references) //IL_06c5: Unknown result type (might be due to invalid IL or missing references) //IL_06c7: Unknown result type (might be due to invalid IL or missing references) //IL_06c9: Unknown result type (might be due to invalid IL or missing references) //IL_06ce: Unknown result type (might be due to invalid IL or missing references) //IL_06fb: Unknown result type (might be due to invalid IL or missing references) //IL_06f2: Unknown result type (might be due to invalid IL or missing references) //IL_06f4: Unknown result type (might be due to invalid IL or missing references) //IL_06fd: Unknown result type (might be due to invalid IL or missing references) //IL_073b: Unknown result type (might be due to invalid IL or missing references) //IL_0742: Unknown result type (might be due to invalid IL or missing references) //IL_0747: Unknown result type (might be due to invalid IL or missing references) //IL_074c: Unknown result type (might be due to invalid IL or missing references) //IL_075e: Unknown result type (might be due to invalid IL or missing references) //IL_076e: Unknown result type (might be due to invalid IL or missing references) //IL_07ee: Unknown result type (might be due to invalid IL or missing references) //IL_096b: Unknown result type (might be due to invalid IL or missing references) //IL_0972: Unknown result type (might be due to invalid IL or missing references) //IL_0977: Unknown result type (might be due to invalid IL or missing references) //IL_097c: Unknown result type (might be due to invalid IL or missing references) //IL_0988: Unknown result type (might be due to invalid IL or missing references) //IL_0999: Unknown result type (might be due to invalid IL or missing references) //IL_09b4: Unknown result type (might be due to invalid IL or missing references) //IL_09b6: Unknown result type (might be due to invalid IL or missing references) //IL_09cc: Unknown result type (might be due to invalid IL or missing references) //IL_09ce: Unknown result type (might be due to invalid IL or missing references) //IL_09da: Unknown result type (might be due to invalid IL or missing references) //IL_07bb: Unknown result type (might be due to invalid IL or missing references) //IL_0785: Unknown result type (might be due to invalid IL or missing references) //IL_0787: Unknown result type (might be due to invalid IL or missing references) //IL_079d: Unknown result type (might be due to invalid IL or missing references) //IL_079f: Unknown result type (might be due to invalid IL or missing references) //IL_07ab: Unknown result type (might be due to invalid IL or missing references) //IL_07fe: Unknown result type (might be due to invalid IL or missing references) //IL_0a15: Unknown result type (might be due to invalid IL or missing references) //IL_0a23: Unknown result type (might be due to invalid IL or missing references) //IL_0a3e: Unknown result type (might be due to invalid IL or missing references) //IL_0815: Unknown result type (might be due to invalid IL or missing references) //IL_0838: Unknown result type (might be due to invalid IL or missing references) //IL_0852: Unknown result type (might be due to invalid IL or missing references) //IL_082f: Unknown result type (might be due to invalid IL or missing references) worldCentre = Vector3.zero; Mesh val = SkinUtil.OwnMesh(smr); SkinUtil.Skin(smr, val, out var pos, out var nrm); Vector3[] verts = val.vertices; Vector3[] normals = val.normals; Vector2[] uv = val.uv; BoneWeight[] boneWeights = val.boneWeights; bool flag = normals.Length == verts.Length; bool flag2 = uv.Length == verts.Length; float[] array = new float[verts.Length]; for (int i = 0; i < verts.Length; i++) { array[i] = LostWeight(boneWeights[i], lostIdx); } int[] weld = new int[verts.Length]; Dictionary<Vector3Int, int> dictionary = new Dictionary<Vector3Int, int>(); Bounds bounds = val.bounds; Vector3 val2 = ((Bounds)(ref bounds)).size; float num = 1f / Mathf.Max(1E-05f, ((Vector3)(ref val2)).magnitude * 0.0005f); Vector3Int key = default(Vector3Int); for (int j = 0; j < verts.Length; j++) { ((Vector3Int)(ref key))..ctor(Mathf.RoundToInt(verts[j].x * num), Mathf.RoundToInt(verts[j].y * num), Mathf.RoundToInt(verts[j].z * num)); if (!dictionary.TryGetValue(key, out var value)) { value = j; dictionary[key] = j; } weld[j] = value; } Func<int, int, long> func = (int x, int y) => Edge(weld[x], weld[y]); List<Material> list = ((Renderer)smr).sharedMaterials.ToList(); int subMeshCount = val.subMeshCount; List<int[]> list2 = new List<int[]>(); HashSet<long> hashSet = new HashSet<long>(); List<KeyValuePair<int, int>> list3 = new List<KeyValuePair<int, int>>(); Dictionary<int, int> dictionary2 = new Dictionary<int, int>(); List<int> list4 = new List<int>(); for (int num2 = 0; num2 < subMeshCount; num2++) { int[] triangles = val.GetTriangles(num2); List<int> list5 = new List<int>(triangles.Length); List<int> list6 = null; for (int num3 = 0; num3 < triangles.Length; num3 += 3) { int num4 = triangles[num3]; int num5 = triangles[num3 + 1]; int num6 = triangles[num3 + 2]; if (((array[num4] > 0.5f) ? 1 : 0) + ((array[num5] > 0.5f) ? 1 : 0) + ((array[num6] > 0.5f) ? 1 : 0) >= 2) { hashSet.Add(func(num4, num5)); hashSet.Add(func(num5, num6)); hashSet.Add(func(num6, num4)); if (piece == null) { continue; } if (list6 == null) { list6 = piece.Submesh((Material)((num2 < list.Count) ? ((object)list[num2]) : ((object)list.LastOrDefault()))); dictionary2.Clear(); } int[] array2 = new int[3] { num4, num5, num6 }; foreach (int num8 in array2) { if (!dictionary2.TryGetValue(num8, out var value2)) { value2 = (dictionary2[num8] = piece.V.Count); piece.V.Add(pos[num8]); piece.N.Add(nrm[num8]); piece.UV.Add(flag2 ? uv[num8] : Vector2.zero); } list6.Add(value2); } LastPieceTriangles++; } else { list5.Add(num4); list5.Add(num5); list5.Add(num6); } } list2.Add(list5.ToArray()); list4.AddRange(list5); } for (int num9 = 0; num9 < boneWeights.Length; num9++) { if (array[num9] > 0f) { boneWeights[num9] = Renormalize(boneWeights[num9], lostIdx, parentIdx); } } val.boneWeights = boneWeights; for (int num10 = 0; num10 < list4.Count; num10 += 3) { int num11 = list4[num10]; int num12 = list4[num10 + 1]; int num13 = list4[num10 + 2]; if (hashSet.Contains(func(num11, num12))) { list3.Add(new KeyValuePair<int, int>(num11, num12)); } if (hashSet.Contains(func(num12, num13))) { list3.Add(new KeyValuePair<int, int>(num12, num13)); } if (hashSet.Contains(func(num13, num11))) { list3.Add(new KeyValuePair<int, int>(num13, num11)); } } bool flag3 = false; List<Vector3> list7 = verts.ToList(); List<Vector3> list8 = (flag ? normals.ToList() : null); List<Vector2> list9 = (flag2 ? uv.ToList() : null); List<BoneWeight> list10 = boneWeights.ToList(); List<int> list11 = new List<int>(); if (isBody && list3.Count >= 3) { List<int> list12 = list3.SelectMany((KeyValuePair<int, int> e) => new int[2] { e.Key, e.Value }).Distinct().ToList(); Vector3 centre = Vector3.zero; Vector3 val3 = Vector3.zero; foreach (int item3 in list12) { centre += verts[item3]; val3 += pos[item3]; } centre /= (float)list12.Count; val3 = (worldCentre = val3 / (float)list12.Count); Vector3 val4 = Vector3.zero; foreach (KeyValuePair<int, int> item4 in list3) { Vector3 val5 = verts[item4.Key] - centre; Vector3 val6 = verts[item4.Value] - centre; val4 += Vector3.Cross(val6, val5); } val4 = ((((Vector3)(ref val4)).sqrMagnitude > 1E-12f) ? ((Vector3)(ref val4)).normalized : Vector3.up); val2 = Vector3.Cross(val4, (Mathf.Abs(val4.y) < 0.9f) ? Vector3.up : Vector3.right); Vector3 normalized = ((Vector3)(ref val2)).normalized; Vector3 val7 = Vector3.Cross(val4, normalized); float num14 = list12.Max(delegate(int num18) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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) Vector3 val11 = verts[num18] - centre; return ((Vector3)(ref val11)).magnitude; }); for (int num15 = 0; num15 < 2; num15++) { Vector3 item = ((num15 == 0) ? val4 : (-val4)); Dictionary<int, int> dictionary3 = new Dictionary<int, int>(); foreach (int item5 in list12) { dictionary3[item5] = list7.Count; Vector3 val8 = verts[item5] - centre; list7.Add(verts[item5]); list8?.Add(item); list9?.Add(new Vector2(0.5f + 0.5f * Vector3.Dot(val8, normalized) / num14, 0.5f + 0.5f * Vector3.Dot(val8, val7) / num14)); list10.Add(boneWeights[item5]); } int count2 = list7.Count; list7.Add(centre); list8?.Add(item); list9?.Add(new Vector2(0.5f, 0.5f)); ? item2; if (parentIdx < 0) { item2 = boneWeights[list12[0]]; } else { BoneWeight val9 = default(BoneWeight); ((BoneWeight)(ref val9)).boneIndex0 = parentIdx; ((BoneWeight)(ref val9)).weight0 = 1f; item2 = val9; } list10.Add((BoneWeight)item2); foreach (KeyValuePair<int, int> item6 in list3) { if (num15 == 0) { list11.Add(dictionary3[item6.Value]); list11.Add(dictionary3[item6.Key]); } else { list11.Add(dictionary3[item6.Key]); list11.Add(dictionary3[item6.Value]); } list11.Add(count2); } } LastCapTriangles += list3.Count; flag3 = true; if (piece != null) { List<int> list13 = piece.Submesh(WoundTextures.Get(WoundLook.StumpCap)); for (int num16 = 0; num16 < 2; num16++) { Dictionary<int, int> dictionary4 = new Dictionary<int, int>(); foreach (int item7 in list12) { dictionary4[item7] = piece.V.Count; Vector3 val10 = verts[item7] - centre; piece.V.Add(pos[item7]); piece.N.Add(Vector3.zero); piece.UV.Add(new Vector2(0.5f + 0.5f * Vector3.Dot(val10, normalized) / num14, 0.5f + 0.5f * Vector3.Dot(val10, val7) / num14)); } int count3 = piece.V.Count; piece.V.Add(val3); piece.N.Add(Vector3.zero); piece.UV.Add(new Vector2(0.5f, 0.5f)); foreach (KeyValuePair<int, int> item8 in list3) { if (num16 == 0) { list13.Add(dictionary4[item8.Key]); list13.Add(dictionary4[item8.Value]); } else { list13.Add(dictionary4[item8.Value]); list13.Add(dictionary4[item8.Key]); } list13.Add(count3); } } } } val.subMeshCount = 0; val.SetVertices(list7); if (list8 != null) { val.SetNormals(list8); } if (list9 != null) { val.SetUVs(0, list9); } val.boneWeights = list10.ToArray(); val.subMeshCount = list2.Count + (flag3 ? 1 : 0); for (int num17 = 0; num17 < list2.Count; num17++) { val.SetTriangles(list2[num17], num17); } if (flag3) { val.SetTriangles(list11, list2.Count); while (list.Count < list2.Count) { list.Add(list.LastOrDefault()); } list.Add(WoundTextures.Get(WoundLook.StumpCap)); ((Renderer)smr).sharedMaterials = list.ToArray(); } val.RecalculateBounds(); return flag3; } private static long Edge(int a, int b) { if (a >= b) { return ((long)b << 32) | (uint)a; } return ((long)a << 32) | (uint)b; } private static float LostWeight(BoneWeight w, HashSet<int> lost) { float num = 0f; if (lost.Contains(((BoneWeight)(ref w)).boneIndex0)) { num += ((BoneWeight)(ref w)).weight0; } if (lost.Contains(((BoneWeight)(ref w)).boneIndex1)) { num += ((BoneWeight)(ref w)).weight1; } if (lost.Contains(((BoneWeight)(ref w)).boneIndex2)) { num += ((BoneWeight)(ref w)).weight2; } if (lost.Contains(((BoneWeight)(ref w)).boneIndex3)) { num += ((BoneWeight)(ref w)).weight3; } return num; } private static BoneWeight Renormalize(BoneWeight w, HashSet<int> lost, int parent) { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) List<KeyValuePair<int, float>> list = new List<KeyValuePair<int, float>>(); if (!lost.Contains(((BoneWeight)(ref w)).boneIndex0) && ((BoneWeight)(ref w)).weight0 > 0f) { list.Add(new KeyValuePair<int, float>(((BoneWeight)(ref w)).boneIndex0, ((BoneWeight)(ref w)).weight0)); } if (!lost.Contains(((BoneWeight)(ref w)).boneIndex1) && ((BoneWeight)(ref w)).weight1 > 0f) { list.Add(new KeyValuePair<int, float>(((BoneWeight)(ref w)).boneIndex1, ((BoneWeight)(ref w)).weight1)); } if (!lost.Contains(((BoneWeight)(ref w)).boneIndex2) && ((BoneWeight)(ref w)).weight2 > 0f) { list.Add(new KeyValuePair<int, float>(((BoneWeight)(ref w)).boneIndex2, ((BoneWeight)(ref w)).weight2)); } if (!lost.Contains(((BoneWeight)(ref w)).boneIndex3) && ((BoneWeight)(ref w)).weight3 > 0f) { list.Add(new KeyValuePair<int, float>(((BoneWeight)(ref w)).boneIndex3, ((BoneWeight)(ref w)).weight3)); } if (list.Count == 0) { BoneWeight result = default(BoneWeight); ((BoneWeight)(ref result)).boneIndex0 = ((parent >= 0) ? parent : ((BoneWeight)(ref w)).boneIndex0); ((BoneWeight)(ref result)).weight0 = 1f; return result; } float num = list.Sum((KeyValuePair<int, float> p) => p.Value); BoneWeight result2 = default(BoneWeight); for (int num2 = 0; num2 < list.Count; num2++) { float num3 = list[num2].Value / num; switch (num2) { case 0: ((BoneWeight)(ref result2)).boneIndex0 = list[num2].Key; ((BoneWeight)(ref result2)).weight0 = num3; break; case 1: ((BoneWeight)(ref result2)).boneIndex1 = list[num2].Key; ((BoneWeight)(ref result2)).weight1 = num3; break; case 2: ((BoneWeight)(ref result2)).boneIndex2 = list[num2].Key; ((BoneWeight)(ref result2)).weight2 = num3; break; default: ((BoneWeight)(ref result2)).boneIndex3 = list[num2].Key; ((BoneWeight)(ref result2)).weight3 = num3; break; } } return result2; } private static GameObject BuildPiece(GladiatorAnatomy a, BodyRegion region, Plan plan, PieceBuilder b, List<MeshRenderer> rigid, Vector3 blowDir) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Unknown result type (might be due to invalid IL or missing references) //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03e5: Unknown result type (might be due to invalid IL or missing references) //IL_03ec: Unknown result type (might be due to invalid IL or missing references) //IL_0443: 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_0463: Unknown result type (might be due to invalid IL or missing references) //IL_046a: Unknown result type (might be due to invalid IL or missing references) //IL_0453: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_047a: Unknown result type (might be due to invalid IL or missing references) //IL_0473: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) //IL_04a9: Unknown result type (might be due to invalid IL or missing references) //IL_04b5: Unknown result type (might be due to invalid IL or missing references) //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missin