Decompiled source of Prosthetics mod v1.1.7
prosthetics.dll
Decompiled 2 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using CUCoreLib.Data; using CUCoreLib.Helpers; using CUCoreLib.Registries; using CUCoreLib.Saving; using HarmonyLib; using LiteEntitySystem.Internal; using LiteNetLib; using LiteNetLib.Utils; using Newtonsoft.Json.Linq; using TMPro; using Together; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.Rendering.Universal; using UnityEngine.SceneManagement; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyVersion("0.0.0.0")] internal static class AugmentCrate { public const string Id = "augment_box"; public const float Scale = 1.5f; public const float SoundPitch = 2f; public const float LightIntensityMultiplier = 0.5f; public static Sprite CrateSprite; private static GameObject _medcratePrefab; private static GameObject _dropcapsulePrefab; private static AudioClip _hitSound; private static AudioClip HitSound() { if ((Object)(object)_hitSound == (Object)null) { _hitSound = Resources.Load<AudioClip>("Sounds/steel"); } return _hitSound; } private static GameObject GetMedcratePrefab() { if ((Object)(object)_medcratePrefab == (Object)null) { _medcratePrefab = Resources.Load<GameObject>("medcrate"); } return _medcratePrefab; } private static AudioSource GetCapsuleAudioSource() { if ((Object)(object)_dropcapsulePrefab == (Object)null) { _dropcapsulePrefab = Resources.Load<GameObject>("dropcapsule"); } return ((Object)(object)_dropcapsulePrefab != (Object)null) ? _dropcapsulePrefab.GetComponent<AudioSource>() : null; } public static void Initialize(string dllDir) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Expected O, but got Unknown //IL_0093: 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) string text = Path.Combine(dllDir, "prosthetics", "crates", "augment_crate", "crate.png"); if (!File.Exists(text)) { ManualLogSource log = ProstheticsPlugin.Log; if (log != null) { log.LogWarning((object)("AugmentCrate: sprite missing at " + text)); } } else { Texture2D val = new Texture2D(2, 2); ImageConversion.LoadImage(val, File.ReadAllBytes(text)); ((Texture)val).filterMode = (FilterMode)0; CrateSprite = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), (float)((Texture)val).width); } } public static void RegisterBuilding() { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_007e: 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) if ((Object)(object)CrateSprite == (Object)null) { ManualLogSource log = ProstheticsPlugin.Log; if (log != null) { log.LogWarning((object)"AugmentCrate: CrateSprite null, skipping CUCoreLib registration"); } return; } CustomBuildingEntityDefinition val = new CustomBuildingEntityDefinition(); val.Name = ModLocale.Get("buildings", "augment_box"); val.Description = ModLocale.Get("buildings", "augment_boxdsc"); val.Sprite = CrateSprite; val.SortingOrder = 1; val.Scale = new Vector3(1.5f, 1.5f, 1f); val.Layer = LayerMask.NameToLayer("Ground"); val.Health = 500f; val.Metallic = true; val.RequireGround = false; val.ItemCategoriesToAdd = new string[1] { "augment" }; val.GuaranteedDropAmount = 1; val.DropChanceMultiplier = 1f; val.HitSound = HitSound(); val.AddRigidbody2D = false; val.ConfigureInstance = ConfigureCrateInstance; CustomBuildingEntityDefinition val2 = val; BuildingEntityRegistry.Register("augment_box", val2); } private static void ConfigureCrateInstance(GameObject go) { //IL_0043: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_0206: 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_02ee: Expected O, but got Unknown //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031a: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Unknown result type (might be due to invalid IL or missing references) //IL_032f: 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_040d: Unknown result type (might be due to invalid IL or missing references) //IL_0412: Unknown result type (might be due to invalid IL or missing references) //IL_0417: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_036c: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) GameObject medcratePrefab = GetMedcratePrefab(); if ((Object)(object)medcratePrefab != (Object)null) { Rigidbody2D component = medcratePrefab.GetComponent<Rigidbody2D>(); if ((Object)(object)component != (Object)null) { Rigidbody2D val = go.GetComponent<Rigidbody2D>() ?? go.AddComponent<Rigidbody2D>(); val.bodyType = component.bodyType; val.mass = component.mass; val.drag = component.drag; val.angularDrag = component.angularDrag; val.gravityScale = component.gravityScale; val.constraints = component.constraints; val.interpolation = component.interpolation; val.collisionDetectionMode = component.collisionDetectionMode; } BoxCollider2D component2 = medcratePrefab.GetComponent<BoxCollider2D>(); BoxCollider2D component3 = go.GetComponent<BoxCollider2D>(); if ((Object)(object)component2 != (Object)null && (Object)(object)component3 != (Object)null) { ((Collider2D)component3).sharedMaterial = ((Collider2D)component2).sharedMaterial; } DamagingCrate component4 = medcratePrefab.GetComponent<DamagingCrate>(); if ((Object)(object)component4 != (Object)null && (Object)(object)go.GetComponent<DamagingCrate>() == (Object)null) { DamagingCrate val2 = go.AddComponent<DamagingCrate>(); val2.type = component4.type; val2.stalactiteHitSound = component4.stalactiteHitSound; } } if ((Object)(object)go.GetComponent<UsableObject>() == (Object)null) { UsableObject val3 = go.AddComponent<UsableObject>(); val3.didLangString = true; val3.toggleString = "Unlock"; } if ((Object)(object)go.GetComponent<Openable>() == (Object)null) { Openable val4 = go.AddComponent<Openable>(); val4.isKeypad = true; } AudioSource capsuleAudioSource = GetCapsuleAudioSource(); if ((Object)(object)capsuleAudioSource != (Object)null && (Object)(object)go.GetComponent<AudioSource>() == (Object)null) { AudioSource val5 = go.AddComponent<AudioSource>(); val5.clip = capsuleAudioSource.clip; val5.outputAudioMixerGroup = capsuleAudioSource.outputAudioMixerGroup; val5.loop = capsuleAudioSource.loop; val5.volume = capsuleAudioSource.volume; val5.spatialBlend = capsuleAudioSource.spatialBlend; val5.rolloffMode = capsuleAudioSource.rolloffMode; val5.minDistance = capsuleAudioSource.minDistance; val5.maxDistance = capsuleAudioSource.maxDistance; val5.dopplerLevel = capsuleAudioSource.dopplerLevel; val5.spread = capsuleAudioSource.spread; val5.reverbZoneMix = capsuleAudioSource.reverbZoneMix; val5.bypassEffects = capsuleAudioSource.bypassEffects; val5.bypassListenerEffects = capsuleAudioSource.bypassListenerEffects; val5.bypassReverbZones = capsuleAudioSource.bypassReverbZones; val5.priority = capsuleAudioSource.priority; val5.playOnAwake = capsuleAudioSource.playOnAwake; val5.pitch = capsuleAudioSource.pitch * 2f; val5.Play(); } if ((Object)(object)go.transform.Find("AugmentCrateLight") == (Object)null) { SpriteRenderer component5 = go.GetComponent<SpriteRenderer>(); GameObject val6 = new GameObject("AugmentCrateLight"); val6.transform.SetParent(go.transform, false); float num; Bounds bounds; if (!((Object)(object)component5 != (Object)null)) { num = 2f; } else { bounds = ((Renderer)component5).bounds; float x = ((Bounds)(ref bounds)).extents.x; bounds = ((Renderer)component5).bounds; num = Mathf.Max(x, ((Bounds)(ref bounds)).extents.y) + 1.5f; } float pointLightOuterRadius = num; if ((Object)(object)component5 != (Object)null) { Transform transform = val6.transform; Transform transform2 = go.transform; bounds = ((Renderer)component5).bounds; transform.localPosition = transform2.InverseTransformPoint(((Bounds)(ref bounds)).center); } Light2D val7 = val6.AddComponent<Light2D>(); val7.lightType = (LightType)3; val7.color = new Color(1f, 0.235f, 0f, 1f); val7.pointLightInnerRadius = 0.2f; val7.pointLightOuterRadius = pointLightOuterRadius; val7.intensity = 0.75f; } if ((Object)(object)WorldGeneration.world != (Object)null) { BuildingEntity component6 = go.GetComponent<BuildingEntity>(); if ((Object)(object)component6 != (Object)null) { component6.blockPlacedOn = WorldGeneration.world.WorldToBlockPos(Vector2.op_Implicit(go.transform.position) + Vector2.down * 0.5f); } } if ((Object)(object)go.GetComponent<AugmentBoxSettle>() == (Object)null) { go.AddComponent<AugmentBoxSettle>(); } if (ProstheticsPlugin.KrokEnabled && KrokMPBridge.IsServer()) { KrokMPBridge.RegisterBox(go); } } } internal class AugmentBoxSettle : MonoBehaviour { private const float MaxWait = 8f; private Rigidbody2D _rb; private RigidbodyConstraints2D _saved; private float _elapsed; private bool _frozen; private static bool WorldReady() { return (Object)(object)WorldGeneration.world != (Object)null && WorldGeneration.world.timeSinceFinishedGeneration > 0f; } private void Start() { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) _rb = ((Component)this).GetComponent<Rigidbody2D>(); if ((Object)(object)_rb == (Object)null || WorldReady()) { Object.Destroy((Object)(object)this); return; } _saved = _rb.constraints; _rb.constraints = (RigidbodyConstraints2D)7; _rb.velocity = Vector2.zero; _frozen = true; } private void Update() { //IL_0046: 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) if (_frozen) { _elapsed += Time.deltaTime; if (WorldReady() || !(_elapsed < 8f)) { _rb.constraints = _saved; _rb.velocity = Vector2.zero; _frozen = false; Object.Destroy((Object)(object)this); } } } } [HarmonyPatch(typeof(ConsoleScript), "RegisterSpawnEntities")] internal class AugmentCrateSpawnAutofillPatch { private static void Postfix(ConsoleScript __instance) { Command val = ConsoleScript.Commands.Find((Command c) => c.name == "spawn"); if (val != null && val.argAutofill.TryGetValue(0, out var value) && !value.Contains("augment_box")) { value.Add("augment_box"); } } } [HarmonyPatch] internal class AugmentBoxClientDropSuppression { private static MethodBase TargetMethod() { Type type = AccessTools.TypeByName("CUCoreLib.Registries.BuildingEntityRegistry"); return (type != null) ? AccessTools.Method(type, "SpawnDrops", (Type[])null, (Type[])null) : null; } private static bool Prepare() { return TargetMethod() != null; } private static bool Prefix(string id) { if (id != "augment_box") { return true; } if (!ProstheticsPlugin.KrokEnabled) { return true; } return KrokMPBridge.IsServer(); } } [HarmonyPatch(typeof(WorldGeneration), "DistributeMiniBarrels")] internal class AugmentCrateLayerSpawnPatch { private const int CHUNKSIZE = 16; private static bool Prepare() { return false; } private static void Postfix(WorldGeneration __instance) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0164: 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_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) if (ProstheticsPlugin.KrokEnabled && KrokMPBridge.IsClient()) { return; } int num = (((Object)(object)WorldGeneration.world != (Object)null) ? WorldGeneration.world.biomeDepth : 0); if (Random.value > 0.5f) { return; } int halfWidth = (int)__instance.halfWidth; int halfHeight = (int)__instance.halfHeight; BuildingEntity[] array = Object.FindObjectsOfType<BuildingEntity>(); Vector2 zero = Vector2.zero; Vector2 val2 = default(Vector2); for (int i = 0; i < 30; i++) { if (array.Length != 0) { BuildingEntity val = array[Random.Range(0, array.Length)]; zero = Vector2.op_Implicit(((Component)val).transform.position); float num2 = Random.Range(0.5f, 1.5f) * ((Random.value < 0.5f) ? (-1f) : 1f); val2 = zero + new Vector2(num2, 2f); } else { ((Vector2)(ref val2))..ctor((float)Random.Range(-halfWidth + 5, halfWidth - 5), Random.Range((float)(-halfHeight + 5), (float)halfHeight)); } RaycastHit2D val3 = Physics2D.Raycast(val2, Vector2.down, 128f, LayerMask.GetMask(new string[1] { "Ground" })); if (!RaycastHit2D.op_Implicit(val3) || Mathf.Abs(((RaycastHit2D)(ref val3)).point.x) > (float)halfWidth - 1f || Mathf.Abs(((RaycastHit2D)(ref val3)).point.y) > (float)halfHeight - 1f) { continue; } Vector2 pos = ((RaycastHit2D)(ref val3)).point + Vector2.up * 1f; if (CrateSpawnTracker.TooClose(pos)) { continue; } GameObject val4 = ProstheticsSpawn.Create("augment_box", pos, 0f); if ((Object)(object)val4 != (Object)null) { CrateSpawnTracker.Record(pos); ManualLogSource log = ProstheticsPlugin.Log; if (log != null) { log.LogInfo((object)$"AugmentCrate: spawned at {((RaycastHit2D)(ref val3)).point} (layer {num + 1})"); } return; } } ManualLogSource log2 = ProstheticsPlugin.Log; if (log2 != null) { log2.LogWarning((object)"AugmentCrate: no valid spawn found after 30 tries"); } } } public static class BallisticTuning { public const float MitigateFraction = 0.5f; public const float PainMitigateFraction = 0.7f; public const float DrainPerHP = 0.00066666666f; public const float SyncInterval = 3f; public const float FlashSyncInterval = 0.2f; public static readonly Color TintColor = new Color(0f, 0.682f, 1f, 0.4f); public static readonly Color ShineColor = new Color(0f, 0.682f, 1f, 0.85f); public const float SweepSeconds = 1.3f; public const float LineThickFrac = 0.13f; public const float LineWidthFrac = 1.18f; public static readonly Color ActiveLightColor = new Color(0f, 0.682f, 1f, 1f); public const float ActiveLightInner = 0.15f; public const float ActiveLightOuter = 2.3f; public const float ActiveLightIntensity = 2f; public const float LightFadeFloor = 0.1f; public static readonly Color FlashColor = new Color(1f, 0f, 0f, 1f); public const float FlashDecaySeconds = 1f; public static readonly Color FlashLightColor = new Color(1f, 0f, 0f, 1f); public const float FlashLightInner = 0.05f; public const float FlashLightOuter = 0.85f; public const float FlashLightMinIntensity = 1.4f; public const float FlashLightMaxIntensity = 5f; public const float FlashLightRefDamage = 40f; public const float FlashLightJitter = 0.09f; public const float SheenJitter = 0.11f; public const float SheenGlitch = 0.3f; public const float SheenFlickerMin = 0.5f; } public static class BallisticRules { public static int Slot(TorsoAugmentSlots s) { return ((Object)(object)s != (Object)null) ? s.SlotOf("augment_ballistic") : (-1); } public static bool IsActive(Body body) { TorsoAugmentSlots torsoAugmentSlots = TorsoAugmentOps.Get(body); int num = Slot(torsoAugmentSlots); return num >= 0 && torsoAugmentSlots.active[num]; } public static bool ActiveWithEnergy(Body body) { TorsoAugmentSlots torsoAugmentSlots = TorsoAugmentOps.Get(body); int num = Slot(torsoAugmentSlots); return num >= 0 && torsoAugmentSlots.active[num] && torsoAugmentSlots.energy[num] >= 0.005f; } public static void Toggle(Body body) { TorsoAugmentSlots torsoAugmentSlots = TorsoAugmentOps.Get(body); int num = Slot(torsoAugmentSlots); if (num < 0) { return; } if (!torsoAugmentSlots.active[num]) { if (torsoAugmentSlots.energy[num] < 0.005f) { PlayerCamera main = PlayerCamera.main; if (main != null) { main.DoAlert(ModLocale.T("alert.ballistic_charge_too_low_needs_at"), false); } return; } torsoAugmentSlots.active[num] = true; AugmentSfx.Play("ballistic_on"); } else { torsoAugmentSlots.active[num] = false; AugmentSfx.Play("ballistic_off"); } KrokMPBridge.SendTorsoState(body); } public static void Deplete(Body body, TorsoAugmentSlots s, int sl) { s.active[sl] = false; PlayerCamera main = PlayerCamera.main; if (main != null) { main.DoAlert(ModLocale.T("alert.ballistic_depleted"), false); } AugmentSfx.Play("ballistic_off"); KrokMPBridge.SendTorsoState(body); } } internal static class BallisticMitigation { private struct Snap { public float skin; public float muscle; public float bleed; public float pain; public float dislocTimer; public int shrapnel; public bool broken; public bool dislocated; } private struct UnmitLoss { public float skin; public float muscle; public float pain; } private static readonly Dictionary<Limb, Snap> _snaps = new Dictionary<Limb, Snap>(); private static readonly Dictionary<Limb, float> _lastFlashSent = new Dictionary<Limb, float>(); private const float HitSoundMinGap = 0.12f; private static float _lastHitSound; private static readonly Dictionary<Limb, UnmitLoss> _unmitigatedLoss = new Dictionary<Limb, UnmitLoss>(); public static void NoteUnmitigatedLoss(Limb limb, float skin, float muscle, float pain) { if (!((Object)(object)limb == (Object)null)) { _unmitigatedLoss.TryGetValue(limb, out var value); value.skin += skin; value.muscle += muscle; value.pain += pain; _unmitigatedLoss[limb] = value; } } public static void Tick(Body body) { if (body?.limbs == null) { return; } TorsoAugmentSlots torsoAugmentSlots = TorsoAugmentOps.Get(body); int num = BallisticRules.Slot(torsoAugmentSlots); if (num < 0 || !torsoAugmentSlots.active[num] || torsoAugmentSlots.energy[num] < 0.005f) { ClearBody(body); return; } Limb[] limbs = body.limbs; foreach (Limb val in limbs) { if ((Object)(object)val == (Object)null) { continue; } if (val.dismembered || (!val.isHead && (Object)(object)((Component)val).GetComponent<ProstheticLimb>() != (Object)null)) { _snaps.Remove(val); continue; } float num2 = Mathf.Min(100f, val.skinHealth); float num3 = Mathf.Min(100f, val.muscleHealth); if (!_snaps.TryGetValue(val, out var value)) { _snaps[val] = Capture(val, num2, num3); continue; } bool flag = false; float num4 = value.skin - num2; float num5 = value.muscle - num3; float num6 = val.pain - value.pain; if (_unmitigatedLoss.TryGetValue(val, out var value2)) { num4 -= value2.skin; num5 -= value2.muscle; num6 -= value2.pain; _unmitigatedLoss.Remove(val); } if (num4 > 0f) { val.skinHealth += num4 * 0.5f; flag = true; } if (num5 > 0f) { val.muscleHealth += num5 * 0.5f; flag = true; } float num7 = val.bleedAmount - value.bleed; if (num7 > 0f) { val.bleedAmount -= num7 * 0.5f; flag = true; } int num8 = val.shrapnel - value.shrapnel; if (num8 > 0) { val.shrapnel = value.shrapnel + Mathf.RoundToInt((float)num8 * 0.5f); flag = true; } if (!value.dislocated && val.dislocated) { val.dislocationTimer *= 0.5f; flag = true; } if (!value.broken && val.broken) { flag = true; if (Random.value < 0.5f) { val.MendBone(); } } if (flag && num6 > 0f) { val.pain -= num6 * 0.7f; } float num9 = ((num4 > 0f) ? num4 : 0f) + ((num5 > 0f) ? num5 : 0f); if (flag) { BallisticOverlay.FlashLimb(val, num9); float time = Time.time; if (time - _lastHitSound >= 0.12f) { _lastHitSound = time; AugmentSfx.Play("ballistic_hit"); } if (ProstheticsPlugin.KrokEnabled) { float time2 = Time.time; if (!_lastFlashSent.TryGetValue(val, out var value3) || time2 - value3 >= 0.2f) { _lastFlashSent[val] = time2; int num10 = Array.IndexOf(body.limbs, val); if (num10 >= 0) { KrokMPBridge.RouteBallisticFlash(body, num10, num9); } } } } if (num9 > 0f) { torsoAugmentSlots.energy[num] = Mathf.Max(0f, torsoAugmentSlots.energy[num] - num9 * 0.00066666666f); if (torsoAugmentSlots.energy[num] < 0.005f) { BallisticRules.Deplete(body, torsoAugmentSlots, num); ClearBody(body); break; } } _snaps[val] = Capture(val, Mathf.Min(100f, val.skinHealth), Mathf.Min(100f, val.muscleHealth)); } } private static Snap Capture(Limb limb, float skin, float muscle) { return new Snap { skin = skin, muscle = muscle, bleed = limb.bleedAmount, pain = limb.pain, shrapnel = limb.shrapnel, broken = limb.broken, dislocated = limb.dislocated, dislocTimer = limb.dislocationTimer }; } private static void ClearBody(Body body) { if (body?.limbs == null) { return; } Limb[] limbs = body.limbs; foreach (Limb val in limbs) { if ((Object)(object)val != (Object)null) { _snaps.Remove(val); _lastFlashSent.Remove(val); _unmitigatedLoss.Remove(val); } } } } [HarmonyPatch] internal class BallisticInternalDamageGuardPatch { private static readonly Dictionary<Limb, Vector3> _pre = new Dictionary<Limb, Vector3>(); private static IEnumerable<MethodBase> TargetMethods() { string[] array = new string[5] { "HandleVariableUpdates", "HandleBody", "HandleBodyTemperature", "HandleRadiationSickness", "HandlePeriodicChecks" }; foreach (string name in array) { MethodInfo m = AccessTools.Method(typeof(Body), name, (Type[])null, (Type[])null); if (m != null) { yield return m; } } } private static void Prefix(Body __instance) { //IL_00d1: Unknown result type (might be due to invalid IL or missing references) _pre.Clear(); if (__instance?.limbs == null) { return; } if (ProstheticsPlugin.KrokEnabled) { if (!KrokMPBridge.IsServer()) { return; } } else if (__instance != PlayerCamera.main?.body) { return; } Limb[] limbs = __instance.limbs; foreach (Limb val in limbs) { if (!((Object)(object)val == (Object)null) && !val.dismembered && (val.isHead || !((Object)(object)((Component)val).GetComponent<ProstheticLimb>() != (Object)null))) { _pre[val] = new Vector3(val.skinHealth, val.muscleHealth, val.pain); } } } private static void Postfix() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<Limb, Vector3> item in _pre) { Limb key = item.Key; if (!((Object)(object)key == (Object)null)) { float num = item.Value.x - key.skinHealth; float num2 = item.Value.y - key.muscleHealth; float num3 = key.pain - item.Value.z; if (num > 0f || num2 > 0f || num3 > 0f) { BallisticMitigation.NoteUnmitigatedLoss(key, Mathf.Max(0f, num), Mathf.Max(0f, num2), Mathf.Max(0f, num3)); } } } _pre.Clear(); } } [HarmonyPatch(typeof(ConsoleScript), "TryExecuteCommand")] internal class BallisticConsoleDamageGuardPatch { private static readonly Dictionary<Limb, Vector3> _pre = new Dictionary<Limb, Vector3>(); private static void Prefix() { //IL_00a1: Unknown result type (might be due to invalid IL or missing references) _pre.Clear(); Body val = PlayerCamera.main?.body; if (val?.limbs == null) { return; } Limb[] limbs = val.limbs; foreach (Limb val2 in limbs) { if (!((Object)(object)val2 == (Object)null) && !val2.dismembered && (val2.isHead || !((Object)(object)((Component)val2).GetComponent<ProstheticLimb>() != (Object)null))) { _pre[val2] = new Vector3(val2.skinHealth, val2.muscleHealth, val2.pain); } } } private static void Postfix() { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) foreach (KeyValuePair<Limb, Vector3> item in _pre) { Limb key = item.Key; if (!((Object)(object)key == (Object)null)) { float num = item.Value.x - key.skinHealth; float num2 = item.Value.y - key.muscleHealth; float num3 = key.pain - item.Value.z; if (num > 0f || num2 > 0f || num3 > 0f) { BallisticMitigation.NoteUnmitigatedLoss(key, Mathf.Max(0f, num), Mathf.Max(0f, num2), Mathf.Max(0f, num3)); } } } _pre.Clear(); } } [HarmonyPatch(typeof(Limb), "Update")] internal class BallisticLimbStatusGuardPatch { private static readonly Dictionary<Limb, Vector2> _pre = new Dictionary<Limb, Vector2>(); private static void Prefix(Limb __instance) { //IL_0093: Unknown result type (might be due to invalid IL or missing references) _pre.Remove(__instance); if ((Object)(object)__instance == (Object)null || __instance.dismembered || (!__instance.isHead && (Object)(object)((Component)__instance).GetComponent<ProstheticLimb>() != (Object)null)) { return; } if (ProstheticsPlugin.KrokEnabled) { if (!KrokMPBridge.IsServer()) { return; } } else if (__instance.body != PlayerCamera.main?.body) { return; } _pre[__instance] = new Vector2(__instance.skinHealth, __instance.muscleHealth); } private static void Postfix(Limb __instance) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)__instance == (Object)null) && _pre.TryGetValue(__instance, out var value)) { _pre.Remove(__instance); float num = value.x - __instance.skinHealth; float num2 = value.y - __instance.muscleHealth; if (num > 0f || num2 > 0f) { BallisticMitigation.NoteUnmitigatedLoss(__instance, Mathf.Max(0f, num), Mathf.Max(0f, num2), 0f); } } } } [HarmonyPatch(typeof(Body), "Update")] internal class BallisticUpdatePatch { private static readonly Dictionary<Body, float> _lastEnergySync = new Dictionary<Body, float>(); private static void Postfix(Body __instance) { if ((Object)(object)__instance == (Object)null) { return; } BallisticOverlay.Refresh(__instance); BallisticLight.Refresh(__instance); if (__instance == PlayerCamera.main?.body) { TorsoAugmentSlots torsoAugmentSlots = TorsoAugmentOps.Get(__instance); int num = BallisticRules.Slot(torsoAugmentSlots); BallisticLoopSound.SetActive(num >= 0 && torsoAugmentSlots.active[num]); } if (ProstheticsPlugin.KrokEnabled) { if (!KrokMPBridge.IsServer()) { return; } } else if (__instance != PlayerCamera.main?.body) { return; } BallisticMitigation.Tick(__instance); if (!ProstheticsPlugin.KrokEnabled) { return; } TorsoAugmentSlots torsoAugmentSlots2 = TorsoAugmentOps.Get(__instance); int num2 = BallisticRules.Slot(torsoAugmentSlots2); if (num2 < 0 || !torsoAugmentSlots2.active[num2]) { _lastEnergySync.Remove(__instance); return; } float time = Time.time; if (!_lastEnergySync.TryGetValue(__instance, out var value) || time - value >= 3f) { _lastEnergySync[__instance] = time; KrokMPBridge.SendTorsoState(__instance); } } } public static class BallisticOverlay { private const string SheenGo = "BallisticSheen"; private const string MaskGo = "BallisticMaskRoot"; private const string ShineGo = "BallisticShine"; public static Sprite AuthoredLine; private static Sprite _lineSprite; private static readonly Dictionary<Body, bool> _painted = new Dictionary<Body, bool>(); public static void Refresh(Body body) { if (body?.limbs == null) { return; } TorsoAugmentSlots torsoAugmentSlots = TorsoAugmentOps.Get(body); int num = BallisticRules.Slot(torsoAugmentSlots); if (num < 0 || !torsoAugmentSlots.active[num]) { if (_painted.ContainsKey(body)) { RemoveAll(body); _painted.Remove(body); } return; } _painted[body] = true; Limb[] limbs = body.limbs; foreach (Limb val in limbs) { if (!((Object)(object)val == (Object)null)) { if (!val.dismembered && (val.isHead || (Object)(object)((Component)val).GetComponent<ProstheticLimb>() == (Object)null)) { EnsureRenderer(((Component)val).GetComponent<SpriteRenderer>()); } else { RemoveRenderer(((Component)val).transform); } } } foreach (SpriteRenderer item in TailRenderersUtil.Get(body)) { EnsureRenderer(item); } } private static void RemoveAll(Body body) { if (body?.limbs != null) { Limb[] limbs = body.limbs; foreach (Limb val in limbs) { if ((Object)(object)val != (Object)null) { RemoveRenderer(((Component)val).transform); } } } foreach (SpriteRenderer item in TailRenderersUtil.Get(body)) { RemoveRenderer(((Component)item).transform); } } public static void FlashLimb(Limb limb, float soaked) { Transform val = (((Object)(object)limb != (Object)null) ? ((Component)limb).transform.Find("BallisticSheen") : null); BallisticSheenState ballisticSheenState = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<BallisticSheenState>() : null); if ((Object)(object)ballisticSheenState != (Object)null) { ballisticSheenState.Flash(soaked); } } public static float MaxFlash(Body body) { if (body?.limbs == null) { return 0f; } float num = 0f; Limb[] limbs = body.limbs; foreach (Limb val in limbs) { if (!((Object)(object)val == (Object)null)) { Transform val2 = ((Component)val).transform.Find("BallisticSheen"); BallisticSheenState ballisticSheenState = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<BallisticSheenState>() : null); if ((Object)(object)ballisticSheenState != (Object)null && ballisticSheenState.FlashAmount > num) { num = ballisticSheenState.FlashAmount; } } } return num; } private static void EnsureRenderer(SpriteRenderer hostSr) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_0083: 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_0124: Expected O, but got Unknown //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Expected O, but got Unknown //IL_0175: 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) if ((Object)(object)hostSr == (Object)null || (Object)(object)hostSr.sprite == (Object)null) { if ((Object)(object)hostSr != (Object)null) { RemoveRenderer(((Component)hostSr).transform); } return; } Transform transform = ((Component)hostSr).transform; Transform val = transform.Find("BallisticSheen"); SpriteRenderer val3; if ((Object)(object)val == (Object)null) { GameObject val2 = new GameObject("BallisticSheen"); val2.transform.SetParent(transform, false); val3 = val2.AddComponent<SpriteRenderer>(); val3.color = BallisticTuning.TintColor; BallisticSheenState ballisticSheenState = val2.AddComponent<BallisticSheenState>(); ballisticSheenState.sr = val3; } else { val3 = ((Component)val).GetComponent<SpriteRenderer>(); } if ((Object)(object)val3 != (Object)null) { val3.sprite = hostSr.sprite; ((Renderer)val3).sortingLayerID = ((Renderer)hostSr).sortingLayerID; ((Renderer)val3).sortingOrder = ((Renderer)hostSr).sortingOrder + 2; val3.flipX = hostSr.flipX; val3.flipY = hostSr.flipY; } Transform val4 = transform.Find("BallisticMaskRoot"); SpriteMask val6; BallisticSweepState ballisticSweepState; if ((Object)(object)val4 == (Object)null) { GameObject val5 = new GameObject("BallisticMaskRoot"); val5.transform.SetParent(transform, false); val6 = val5.AddComponent<SpriteMask>(); GameObject val7 = new GameObject("BallisticShine"); val7.transform.SetParent(val5.transform, false); SpriteRenderer val8 = val7.AddComponent<SpriteRenderer>(); val8.sprite = LineSprite(); val8.color = BallisticTuning.ShineColor; val8.maskInteraction = (SpriteMaskInteraction)1; ballisticSweepState = val7.AddComponent<BallisticSweepState>(); ballisticSweepState.hostSr = hostSr; ballisticSweepState.shineSr = val8; val4 = val5.transform; } else { val6 = ((Component)val4).GetComponent<SpriteMask>(); ballisticSweepState = ((Component)val4).GetComponentInChildren<BallisticSweepState>(); } if ((Object)(object)val6 != (Object)null) { val6.sprite = hostSr.sprite; val4.localScale = new Vector3(hostSr.flipX ? (-1f) : 1f, hostSr.flipY ? (-1f) : 1f, 1f); val6.isCustomRangeActive = true; val6.frontSortingLayerID = ((Renderer)hostSr).sortingLayerID; val6.backSortingLayerID = ((Renderer)hostSr).sortingLayerID; val6.frontSortingOrder = ((Renderer)hostSr).sortingOrder + 4; val6.backSortingOrder = ((Renderer)hostSr).sortingOrder + 3; } if ((Object)(object)ballisticSweepState != (Object)null && (Object)(object)ballisticSweepState.shineSr != (Object)null) { ((Renderer)ballisticSweepState.shineSr).sortingLayerID = ((Renderer)hostSr).sortingLayerID; ((Renderer)ballisticSweepState.shineSr).sortingOrder = ((Renderer)hostSr).sortingOrder + 3; } } private static void RemoveRenderer(Transform host) { if ((Object)(object)host == (Object)null) { return; } for (int num = host.childCount - 1; num >= 0; num--) { Transform child = host.GetChild(num); if ((Object)(object)child != (Object)null && (((Object)((Component)child).gameObject).name == "BallisticSheen" || ((Object)((Component)child).gameObject).name == "BallisticMaskRoot")) { Object.Destroy((Object)(object)((Component)child).gameObject); } } } private static Sprite LineSprite() { if ((Object)(object)_lineSprite != (Object)null) { return _lineSprite; } _lineSprite = (((Object)(object)AuthoredLine != (Object)null) ? AuthoredLine : BuildLineSprite()); return _lineSprite; } private static Sprite BuildLineSprite() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) Texture2D val = new Texture2D(8, 24, (TextureFormat)4, false); ((Texture)val).filterMode = (FilterMode)1; Color32[] array = (Color32[])(object)new Color32[192]; float num = 11.5f; for (int i = 0; i < 24; i++) { float num2 = Mathf.Abs((float)i - num) / num; float num3 = Mathf.Clamp01(1f - num2); num3 *= num3; byte b = (byte)(num3 * 255f); for (int j = 0; j < 8; j++) { array[i * 8 + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, b); } } val.SetPixels32(array); val.Apply(); return Sprite.Create(val, new Rect(0f, 0f, 8f, 24f), new Vector2(0.5f, 0.5f), 24f); } } internal static class BallisticLight { private const string GoName = "BallisticLight"; public static void Refresh(Body body) { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0185: Unknown result type (might be due to invalid IL or missing references) Limb val = ((body != null) ? body.LimbByName("UpTorso") : null); if ((Object)(object)val == (Object)null) { return; } TorsoAugmentSlots component = ((Component)val).GetComponent<TorsoAugmentSlots>(); int num = (((Object)(object)component != (Object)null) ? component.SlotOf("augment_ballistic") : (-1)); bool flag = num >= 0 && component.active[num] && !val.dismembered; Transform val2 = ((Component)val).transform.Find("BallisticLight"); if (!flag) { if ((Object)(object)val2 != (Object)null && ((Component)val2).gameObject.activeSelf) { ((Component)val2).gameObject.SetActive(false); } return; } Light2D val4; if ((Object)(object)val2 == (Object)null) { GameObject val3 = new GameObject("BallisticLight"); val3.transform.SetParent(((Component)val).transform, false); val3.transform.localPosition = Vector3.zero; val4 = val3.AddComponent<Light2D>(); val4.lightType = (LightType)3; val4.color = BallisticTuning.ActiveLightColor; val4.pointLightInnerRadius = 0.15f; val4.pointLightOuterRadius = 2.3f; val2 = val3.transform; } else { val4 = ((Component)val2).GetComponent<Light2D>(); } if (!((Component)val2).gameObject.activeSelf) { ((Component)val2).gameObject.SetActive(true); } if ((Object)(object)val4 != (Object)null) { float num2 = BallisticOverlay.MaxFlash(body); val4.color = Color.Lerp(BallisticTuning.ActiveLightColor, BallisticTuning.FlashLightColor, num2); float num3 = Mathf.Clamp01((component.energy[num] - 0.1f) / 0.9f); val4.intensity = Mathf.Max(2f * num3, 2f * num2); } } } public class BallisticSheenState : MonoBehaviour { public SpriteRenderer sr; private float _flash; private float _peakIntensity; private float _seed; private Light2D _light; public float FlashAmount => _flash; public void Flash(float soaked) { _flash = 1f; float num = Mathf.Clamp01(soaked / Mathf.Max(0.01f, 40f)); _peakIntensity = Mathf.Lerp(1.4f, 5f, num); EnsureLight(); } private void EnsureLight() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown //IL_003a: 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) if (!((Object)(object)_light != (Object)null)) { GameObject val = new GameObject("BallisticHitLight"); val.transform.SetParent(((Component)this).transform, false); val.transform.localPosition = Vector3.zero; _light = val.AddComponent<Light2D>(); _light.lightType = (LightType)3; _light.color = BallisticTuning.FlashLightColor; _light.pointLightInnerRadius = 0.05f; _light.pointLightOuterRadius = 0.85f; _light.intensity = 0f; ((Behaviour)_light).enabled = false; } } private void Update() { //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00a8: 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_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_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)sr == (Object)null) { return; } if (_seed == 0f) { _seed = Random.value * 97f + 1f; } if (_flash > 0f) { _flash = Mathf.Max(0f, _flash - Time.deltaTime / Mathf.Max(0.01f, 1f)); } Color val = ((_flash > 0f) ? Color.Lerp(BallisticTuning.TintColor, BallisticTuning.FlashColor, _flash) : BallisticTuning.TintColor); Vector2 val2 = Random.insideUnitCircle * (0.11f * (1f + _flash)); if (Random.value < 0.15f) { val2.x += (Random.value - 0.5f) * 0.3f * (1f + _flash); } ((Component)this).transform.localPosition = new Vector3(val2.x, val2.y, 0f); float num = Mathf.Lerp(0.5f, 1f, Mathf.PerlinNoise(Time.time * 14f, _seed)); if (Random.value < 0.04f) { num *= 0.5f; } num = Mathf.Lerp(num, 1f, _flash); sr.color = new Color(val.r, val.g, val.b, val.a * num); if ((Object)(object)_light != (Object)null) { bool flag = _flash > 0f; if (((Behaviour)_light).enabled != flag) { ((Behaviour)_light).enabled = flag; } if (flag) { _light.intensity = _flash * _peakIntensity; Vector2 val3 = Random.insideUnitCircle * (0.09f * _flash); ((Component)_light).transform.localPosition = new Vector3(val3.x, val3.y, 0f); } else if (((Component)_light).transform.localPosition != Vector3.zero) { ((Component)_light).transform.localPosition = Vector3.zero; } } } } public class BallisticSweepState : MonoBehaviour { public SpriteRenderer hostSr; public SpriteRenderer shineSr; private float _phase; private void Update() { //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0073: 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_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_0121: 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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017c: 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_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)hostSr == (Object)null || (Object)(object)shineSr == (Object)null) { return; } if ((Object)(object)hostSr.sprite == (Object)null) { ((Renderer)shineSr).enabled = false; return; } ((Renderer)shineSr).enabled = true; Bounds bounds = hostSr.sprite.bounds; float y = ((Bounds)(ref bounds)).max.y; float y2 = ((Bounds)(ref bounds)).min.y; _phase += Time.deltaTime / Mathf.Max(0.05f, 1.3f); if (_phase >= 1f) { _phase -= 1f; } float num = Mathf.Lerp(y, y2, _phase); Rect rect = shineSr.sprite.rect; float num2 = ((Rect)(ref rect)).width / shineSr.sprite.pixelsPerUnit; float num3 = ((num2 > 0.0001f) ? (((Bounds)(ref bounds)).size.x * 1.18f / num2) : 1f); float num4 = ((Bounds)(ref bounds)).size.y * 0.13f; ((Component)this).transform.localScale = new Vector3(num3, num4, 1f); ((Component)this).transform.localPosition = new Vector3(((Bounds)(ref bounds)).center.x, num, 0f); float num5 = Mathf.Clamp01(Mathf.Min(_phase, 1f - _phase) / 0.12f); Color shineColor = BallisticTuning.ShineColor; shineSr.color = new Color(shineColor.r, shineColor.g, shineColor.b, shineColor.a * num5); } } internal static class BallisticLoopSound { private const float Volume = 0.6f; private static string _path; private static AudioClip _clip; private static bool _loading; private static bool _wantPlaying; private static AudioSource _src; public static void Register(string dllDir) { string path = Path.Combine(dllDir, "prosthetics", "augments", "Ballistic Protection"); string[] array = new string[2] { ".ogg", ".wav" }; foreach (string text in array) { string path2 = Path.Combine(path, "loop" + text); if (File.Exists(path2)) { _path = path2; break; } } } public static void SetActive(bool playing) { _wantPlaying = playing; if (playing && (Object)(object)_clip == (Object)null && !_loading && !string.IsNullOrEmpty(_path)) { PlayerCamera main = PlayerCamera.main; if ((Object)(object)main != (Object)null) { _loading = true; ((MonoBehaviour)main).StartCoroutine(Load()); } } Apply(); } private static void Apply() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown if ((Object)(object)_clip == (Object)null) { return; } if ((Object)(object)_src == (Object)null) { GameObject val = new GameObject("BallisticLoopSound"); Object.DontDestroyOnLoad((Object)(object)val); _src = val.AddComponent<AudioSource>(); _src.clip = _clip; _src.loop = true; _src.volume = 0.6f; _src.playOnAwake = false; } _src.volume = 0.6f * ModAudioSettings.GameplayVolume; if (_wantPlaying) { if (!_src.isPlaying) { _src.Play(); } } else if (_src.isPlaying) { _src.Stop(); } } private static IEnumerator Load() { string ext = Path.GetExtension(_path).ToLower(); AudioType type = (AudioType)((ext == ".ogg") ? 14 : 20); string uri = "file://" + _path.Replace('\\', '/'); UnityWebRequest www = new UnityWebRequest(uri); www.downloadHandler = (DownloadHandler)new DownloadHandlerAudioClip(uri, type); yield return www.SendWebRequest(); if ((int)www.result == 1) { _clip = DownloadHandlerAudioClip.GetContent(www); } www.Dispose(); _loading = false; Apply(); } } public class BioAugmentSlot : MonoBehaviour { public string modId = ""; public float condition = 0f; public string batteryType = ""; public float batteryMax = 0f; public bool modActive = false; public bool HasAugment(string id) { return !string.IsNullOrEmpty(modId) && modId == id; } public bool HasAnyAugment() { return !string.IsNullOrEmpty(modId); } public bool IsPowergripOn() { return HasAugment("augment_powergrip") && modActive && !string.IsNullOrEmpty(batteryType) && batteryMax > 0f && condition >= 0.005f; } public bool IsPowergripPowered() { return HasAugment("augment_powergrip") && !string.IsNullOrEmpty(batteryType) && batteryMax > 0f && condition >= 0.005f; } public bool IsHackingPowered() { return HasAugment("augment_hacking") && !string.IsNullOrEmpty(batteryType) && batteryMax > 0f && condition >= 0.005f; } public bool IsSteadyHandPowered() { return HasAugment("augment_steadyhand") && !string.IsNullOrEmpty(batteryType) && batteryMax > 0f && condition >= 0.005f; } public bool TogglePowergrip() { if (!HasAugment("augment_powergrip")) { return false; } modActive = !modActive; return true; } public bool IsPowerstepsOn() { return HasAugment("augment_powersteps") && modActive && !string.IsNullOrEmpty(batteryType) && batteryMax > 0f && condition >= 0.005f; } public bool IsPowerstepsPowered() { return HasAugment("augment_powersteps") && !string.IsNullOrEmpty(batteryType) && batteryMax > 0f && condition >= 0.005f; } public bool TogglePowersteps() { if (!HasAugment("augment_powersteps")) { return false; } modActive = !modActive; return true; } public bool IsTreadmillOn() { return HasAugment("augment_treadmill") && modActive && !string.IsNullOrEmpty(batteryType) && batteryMax > 0f && condition < 0.999f; } public bool IsTreadmillActivatable() { return HasAugment("augment_treadmill") && !string.IsNullOrEmpty(batteryType) && batteryMax > 0f && condition < 0.999f; } public bool ToggleTreadmill() { if (!HasAugment("augment_treadmill")) { return false; } modActive = !modActive; return true; } } public readonly struct AugmentHandle { public readonly ProstheticLimb prosthetic; public readonly BioAugmentSlot bio; public readonly Limb rootLimb; public bool IsValid => (Object)(object)prosthetic != (Object)null || (Object)(object)bio != (Object)null; public AugmentHandle(ProstheticLimb p, Limb root) { prosthetic = p; bio = null; rootLimb = root; } public AugmentHandle(BioAugmentSlot b, Limb root) { prosthetic = null; bio = b; rootLimb = root; } public bool IsPowergripOn() { if ((Object)(object)prosthetic != (Object)null) { return prosthetic.IsPowergripOn(); } if ((Object)(object)bio != (Object)null) { return bio.IsPowergripOn(); } return false; } public bool IsPowergripPowered() { if ((Object)(object)prosthetic != (Object)null) { return prosthetic.IsPowergripPowered(); } if ((Object)(object)bio != (Object)null) { return bio.IsPowergripPowered(); } return false; } public bool IsHackingPowered() { if ((Object)(object)prosthetic != (Object)null) { return prosthetic.IsHackingPowered(); } if ((Object)(object)bio != (Object)null) { return bio.IsHackingPowered(); } return false; } public bool IsSteadyHandPowered() { if ((Object)(object)prosthetic != (Object)null) { return prosthetic.IsSteadyHandPowered(); } if ((Object)(object)bio != (Object)null) { return bio.IsSteadyHandPowered(); } return false; } public bool IsPowerstepsOn() { if ((Object)(object)prosthetic != (Object)null) { int num = prosthetic.FindModSlot("augment_powersteps"); if (num < 0 || !prosthetic.GetModActive(num)) { return false; } return !string.IsNullOrEmpty(prosthetic.GetModBatteryType(num)) && prosthetic.GetModBatteryMax(num) > 0f && prosthetic.GetModCondition(num) >= 0.005f; } if ((Object)(object)bio != (Object)null) { return bio.IsPowerstepsOn(); } return false; } public bool IsPowerstepsPowered() { if ((Object)(object)prosthetic != (Object)null) { int num = prosthetic.FindModSlot("augment_powersteps"); if (num < 0) { return false; } return !string.IsNullOrEmpty(prosthetic.GetModBatteryType(num)) && prosthetic.GetModBatteryMax(num) > 0f && prosthetic.GetModCondition(num) >= 0.005f; } if ((Object)(object)bio != (Object)null) { return bio.IsPowerstepsPowered(); } return false; } public bool IsTreadmillOn() { if ((Object)(object)prosthetic != (Object)null) { int num = prosthetic.FindModSlot("augment_treadmill"); if (num < 0 || !prosthetic.GetModActive(num)) { return false; } return !string.IsNullOrEmpty(prosthetic.GetModBatteryType(num)) && prosthetic.GetModBatteryMax(num) > 0f && prosthetic.GetModCondition(num) < 0.999f; } if ((Object)(object)bio != (Object)null) { return bio.IsTreadmillOn(); } return false; } public bool IsTreadmillActivatable() { if ((Object)(object)prosthetic != (Object)null) { int num = prosthetic.FindModSlot("augment_treadmill"); if (num < 0) { return false; } return !string.IsNullOrEmpty(prosthetic.GetModBatteryType(num)) && prosthetic.GetModBatteryMax(num) > 0f && prosthetic.GetModCondition(num) < 0.999f; } if ((Object)(object)bio != (Object)null) { return bio.IsTreadmillActivatable(); } return false; } public bool HasMod(string id) { if ((Object)(object)prosthetic != (Object)null) { return prosthetic.HasMod(id); } if ((Object)(object)bio != (Object)null) { return bio.HasAugment(id); } return false; } public float GetCondition(string id) { if ((Object)(object)prosthetic != (Object)null) { int num = prosthetic.FindModSlot(id); return (num >= 0) ? prosthetic.GetModCondition(num) : 0f; } if ((Object)(object)bio != (Object)null && bio.HasAugment(id)) { return bio.condition; } return 0f; } public float GetBatteryMax(string id) { if ((Object)(object)prosthetic != (Object)null) { int num = prosthetic.FindModSlot(id); return (num >= 0) ? prosthetic.GetModBatteryMax(num) : 0f; } if ((Object)(object)bio != (Object)null && bio.HasAugment(id)) { return bio.batteryMax; } return 0f; } public bool SetConditionAndSync(string id, float newCond, Body body) { newCond = Mathf.Clamp01(newCond); if ((Object)(object)prosthetic != (Object)null) { int num = prosthetic.FindModSlot(id); if (num < 0) { return false; } prosthetic.SetModCondition(num, newCond); if (ProstheticsPlugin.KrokEnabled && (Object)(object)body != (Object)null) { int num2 = Array.IndexOf(body.limbs, prosthetic.rootLimb ?? ((Component)prosthetic).GetComponent<Limb>()); if (num2 >= 0) { switch (id) { case "augment_powergrip": KrokMPBridge.SendFwCondition(body, num2, newCond); break; case "augment_hacking": KrokMPBridge.SendHkCondition(body, num2, newCond); break; case "augment_steadyhand": KrokMPBridge.SendHandCondition(body, num2, newCond); break; case "augment_powersteps": KrokMPBridge.SendPsCondition(body, num2, newCond); break; } } } return true; } if ((Object)(object)bio != (Object)null && bio.HasAugment(id)) { bio.condition = newCond; if (ProstheticsPlugin.KrokEnabled && (Object)(object)body != (Object)null && (Object)(object)rootLimb != (Object)null) { int num3 = Array.IndexOf(body.limbs, rootLimb); if (num3 >= 0) { KrokMPBridge.SendBioSlot(body, num3, slotPresent: true, bio.modId, bio.condition, bio.batteryType, bio.batteryMax, bio.modActive); } } return true; } return false; } } public static class LimbChainUtil { public static string GetChainId(Limb limb) { if ((Object)(object)limb == (Object)null) { return null; } string text = ((Object)((Component)limb).gameObject).name ?? ""; bool flag = text.EndsWith("F", StringComparison.OrdinalIgnoreCase); bool flag2 = text.EndsWith("B", StringComparison.OrdinalIgnoreCase); if (!flag && !flag2) { return null; } bool flag3 = text.StartsWith("UpArm", StringComparison.OrdinalIgnoreCase) || text.IndexOf("Hand", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("DownArm", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("LoArm", StringComparison.OrdinalIgnoreCase) >= 0; bool flag4 = text.StartsWith("Thigh", StringComparison.OrdinalIgnoreCase) || text.IndexOf("Crus", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Shin", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("Foot", StringComparison.OrdinalIgnoreCase) >= 0; if (flag3) { return flag ? "armF" : "armB"; } if (flag4) { return flag ? "legF" : "legB"; } return null; } public static bool IsChainRooted(Body body, string chainId) { if (body?.limbs == null || string.IsNullOrEmpty(chainId)) { return false; } string text; switch (chainId) { case "armF": text = "UpArmF"; break; case "armB": text = "UpArmB"; break; case "legF": text = "ThighF"; break; case "legB": text = "ThighB"; break; default: return false; } Limb val = body.LimbByName(text); if ((Object)(object)val == (Object)null) { return false; } if (!val.dismembered) { return true; } return (Object)(object)((Component)val).GetComponent<ProstheticLimb>() != (Object)null; } public static bool ChainHasAugment(Limb anyLimb, string modId) { if ((Object)(object)anyLimb == (Object)null || string.IsNullOrEmpty(modId)) { return false; } Body body = anyLimb.body; if (body?.limbs == null) { return false; } string chainId = GetChainId(anyLimb); if (chainId == null) { return false; } Limb[] limbs = body.limbs; foreach (Limb val in limbs) { if (!((Object)(object)val == (Object)null) && !(GetChainId(val) != chainId)) { BioAugmentSlot component = ((Component)val).GetComponent<BioAugmentSlot>(); if ((Object)(object)component != (Object)null && component.HasAugment(modId)) { return true; } ProstheticLimb component2 = ((Component)val).GetComponent<ProstheticLimb>(); if ((Object)(object)component2 != (Object)null && (Object)(object)component2.rootLimb == (Object)(object)val && component2.FindModSlot(modId) >= 0) { return true; } } } return false; } public static Limb ResolveThighLimb(Limb legLimb) { if ((Object)(object)legLimb == (Object)null) { return null; } string chainId = GetChainId(legLimb); if (chainId != "legF" && chainId != "legB") { return null; } Body body = legLimb.body; return (body != null) ? body.LimbByName((chainId == "legF") ? "ThighF" : "ThighB") : null; } } public static class AugmentLookup { public static AugmentHandle ForSlotStrict(InventorySlot slot) { if ((Object)(object)slot == (Object)null) { return default(AugmentHandle); } ProstheticLimb forSlotStrict = MainHandProstheticRules.GetForSlotStrict(slot); if ((Object)(object)forSlotStrict != (Object)null) { Limb root = forSlotStrict.rootLimb ?? ((Component)forSlotStrict).GetComponent<Limb>(); return new AugmentHandle(forSlotStrict, root); } if ((Object)(object)slot.limb == (Object)null) { return default(AugmentHandle); } Limb val = ResolveBioArmRoot(slot.limb); if ((Object)(object)val == (Object)null) { return default(AugmentHandle); } BioAugmentSlot component = ((Component)val).GetComponent<BioAugmentSlot>(); if ((Object)(object)component == (Object)null) { return default(AugmentHandle); } return new AugmentHandle(component, val); } public static AugmentHandle ForBodyHandSlot(Body body, int slotIdx) { if (body?.slots == null || slotIdx < 0 || slotIdx >= body.slots.Length) { return default(AugmentHandle); } return ForSlotStrict(body.slots[slotIdx]); } public static AugmentHandle ForSlotChain(InventorySlot slot, string modId) { if ((Object)(object)slot?.limb == (Object)null || string.IsNullOrEmpty(modId)) { return default(AugmentHandle); } Body body = slot.limb.body; if (body?.limbs == null) { return default(AugmentHandle); } string chainId = LimbChainUtil.GetChainId(slot.limb); if (chainId == null) { return ForSlotStrict(slot); } if (!LimbChainUtil.IsChainRooted(body, chainId)) { return default(AugmentHandle); } Limb[] limbs = body.limbs; foreach (Limb val in limbs) { if (!((Object)(object)val == (Object)null) && !(LimbChainUtil.GetChainId(val) != chainId)) { ProstheticLimb component = ((Component)val).GetComponent<ProstheticLimb>(); if ((Object)(object)component != (Object)null && (Object)(object)component.rootLimb == (Object)(object)val && component.FindModSlot(modId) >= 0) { return new AugmentHandle(component, val); } BioAugmentSlot component2 = ((Component)val).GetComponent<BioAugmentSlot>(); if ((Object)(object)component2 != (Object)null && component2.HasAugment(modId)) { return new AugmentHandle(component2, val); } } } return default(AugmentHandle); } public static Limb ResolveBioArmRoot(Limb limb) { if ((Object)(object)limb == (Object)null) { return null; } string text = ((Object)((Component)limb).gameObject).name ?? ""; if (text.StartsWith("UpArm", StringComparison.OrdinalIgnoreCase) || text.StartsWith("Thigh", StringComparison.OrdinalIgnoreCase)) { return limb; } Body body = limb.body; if ((Object)(object)body == (Object)null) { return null; } bool flag = text.EndsWith("F", StringComparison.OrdinalIgnoreCase); bool flag2 = text.EndsWith("B", StringComparison.OrdinalIgnoreCase); if (!flag && !flag2) { return null; } string text2; if (text.IndexOf("Hand", StringComparison.OrdinalIgnoreCase) >= 0 || text.IndexOf("DownArm", StringComparison.OrdinalIgnoreCase) >= 0) { text2 = (flag ? "UpArmF" : "UpArmB"); } else { if (text.IndexOf("Foot", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("Crus", StringComparison.OrdinalIgnoreCase) < 0 && text.IndexOf("Shin", StringComparison.OrdinalIgnoreCase) < 0) { return null; } text2 = (flag ? "ThighF" : "ThighB"); } return body.LimbByName(text2); } public static IEnumerable<(Limb rootLimb, BioAugmentSlot bio)> BioSlotsWithAugment(Body body, string modId) { if (body?.limbs == null) { yield break; } for (int i = 0; i < body.limbs.Length; i++) { Limb l = body.limbs[i]; if (!((Object)(object)l == (Object)null)) { BioAugmentSlot b = ((Component)l).GetComponent<BioAugmentSlot>(); if ((Object)(object)b != (Object)null && b.HasAugment(modId)) { yield return (rootLimb: l, bio: b); } } } } public static IEnumerable<AugmentHandle> LegsWithAugment(Body body, string modId) { if (body?.legLimbs == null) { yield break; } Limb[] legLimbs = body.legLimbs; foreach (Limb l in legLimbs) { if ((Object)(object)l == (Object)null) { continue; } ProstheticLimb p = ((Component)l).GetComponent<ProstheticLimb>(); if ((Object)(object)p != (Object)null) { if (p.FindModSlot(modId) >= 0) { yield return new AugmentHandle(p, p.rootLimb ?? l); } continue; } BioAugmentSlot b = ((Component)l).GetComponent<BioAugmentSlot>(); if ((Object)(object)b != (Object)null && b.HasAugment(modId)) { yield return new AugmentHandle(b, l); } } } } public static class AugmentImplantToolItem { public static void Apply(Limb limb, Item item) { //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_04b3: Unknown result type (might be due to invalid IL or missing references) //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_04dd: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_0507: Unknown result type (might be due to invalid IL or missing references) //IL_050c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)limb == (Object)null || (Object)(object)item == (Object)null) { return; } Body body = limb.body; if ((Object)(object)body == (Object)null) { return; } bool flag = body == PlayerCamera.main?.body; string text = ((Object)((Component)limb).gameObject).name ?? ""; if (text.StartsWith("UpTorso", StringComparison.OrdinalIgnoreCase)) { if (limb.dismembered) { if (flag) { PlayerCamera main = PlayerCamera.main; if (main != null) { main.DoAlert(ModLocale.T("alert.limb_is_missing"), false); } } } else if ((Object)(object)((Component)limb).GetComponent<ProstheticLimb>() != (Object)null) { if (flag) { PlayerCamera main2 = PlayerCamera.main; if (main2 != null) { main2.DoAlert(ModLocale.T("alert.this_limb_is_already_a_prosthetic"), false); } } } else { if (!ProstheticsSetupPatch.PassesIntCheck(limb, 5) || !TorsoAugmentOps.OpenSlot(body, flag)) { return; } limb.skinHealth = Mathf.Max(0f, limb.skinHealth - 20f); limb.muscleHealth = Mathf.Max(0f, limb.muscleHealth - 10f); limb.bleedAmount += 5f; if (body.limbs != null) { Limb[] limbs = body.limbs; foreach (Limb val in limbs) { if (!((Object)(object)val == (Object)null)) { val.pain = Mathf.Min(val.pain + (((Object)(object)val == (Object)(object)limb) ? 65f : 10f), 95f); } } } Sound.Play("gore", Vector2.op_Implicit(((Component)limb).transform.position), false, true, (Transform)null, 1f, 1f, false, false); Sound.Play("blood", Vector2.op_Implicit(((Component)limb).transform.position), false, true, (Transform)null, 1f, 1f, false, false); Sound.Play("pain", Vector2.op_Implicit(((Component)body).transform.position), false, true, (Transform)null, 1f, 1f, false, false); if (flag) { PlayerCamera main3 = PlayerCamera.main; if (main3 != null) { main3.DoAlert(ModLocale.T("alert.torso_augment_slot_opened"), false); } } item.condition = 0f; } } else if (!text.StartsWith("UpArm", StringComparison.OrdinalIgnoreCase) && !text.StartsWith("Thigh", StringComparison.OrdinalIgnoreCase)) { if (flag) { PlayerCamera main4 = PlayerCamera.main; if (main4 != null) { main4.DoAlert(ModLocale.T("alert.apply_directly_to_an_upper_arm"), false); } } } else if ((Object)(object)((Component)limb).GetComponent<ProstheticLimb>() != (Object)null) { if (flag) { PlayerCamera main5 = PlayerCamera.main; if (main5 != null) { main5.DoAlert(ModLocale.T("alert.this_limb_is_already_a_prosthetic"), false); } } } else if (limb.dismembered) { if (flag) { PlayerCamera main6 = PlayerCamera.main; if (main6 != null) { main6.DoAlert(ModLocale.T("alert.limb_is_missing"), false); } } } else if ((Object)(object)((Component)limb).GetComponent<BioAugmentSlot>() != (Object)null) { if (flag) { PlayerCamera main7 = PlayerCamera.main; if (main7 != null) { main7.DoAlert(ModLocale.T("alert.limb_already_has_an_augment_slot"), false); } } } else { if (!ProstheticsSetupPatch.PassesIntCheck(limb, 5)) { return; } BioAugmentSlot bioAugmentSlot = ((Component)limb).gameObject.AddComponent<BioAugmentSlot>(); bioAugmentSlot.modId = ""; bioAugmentSlot.condition = 0f; bioAugmentSlot.batteryType = ""; bioAugmentSlot.batteryMax = 0f; bioAugmentSlot.modActive = false; BioImplantOverlay.Apply(limb); limb.skinHealth = Mathf.Max(0f, limb.skinHealth - 20f); limb.muscleHealth = Mathf.Max(0f, limb.muscleHealth - 10f); limb.bleedAmount += 5f; if (body.limbs != null) { Limb[] limbs2 = body.limbs; foreach (Limb val2 in limbs2) { if (!((Object)(object)val2 == (Object)null)) { float num = (((Object)(object)val2 == (Object)(object)limb) ? 65f : 10f); val2.pain = Mathf.Min(val2.pain + num, 95f); } } } Sound.Play("gore", Vector2.op_Implicit(((Component)limb).transform.position), false, true, (Transform)null, 1f, 1f, false, false); Sound.Play("blood", Vector2.op_Implicit(((Component)limb).transform.position), false, true, (Transform)null, 1f, 1f, false, false); Sound.Play("pain", Vector2.op_Implicit(((Component)body).transform.position), false, true, (Transform)null, 1f, 1f, false, false); if (flag) { PlayerCamera main8 = PlayerCamera.main; if (main8 != null) { main8.DoAlert(ModLocale.T("alert.augment_slot_implanted"), false); } } item.condition = 0f; CyberneticsUIController.Instance?.RebuildContent(); if (ProstheticsPlugin.KrokEnabled) { int num2 = Array.IndexOf(body.limbs, limb); if (num2 >= 0) { KrokMPBridge.SendBioSlot(body, num2, slotPresent: true, "", 0f, "", 0f, active: false); } } } } } public static class BioAugmentOps { public static bool InstallAugment(BioAugmentSlot bio, Limb rootArm, Body body, Item item) { if ((Object)(object)bio == (Object)null || (Object)(object)rootArm == (Object)null || (Object)(object)body == (Object)null || (Object)(object)item == (Object)null) { return false; } if (bio.HasAnyAugment()) { return false; } string id = item.id; if (id != "augment_powergrip" && id != "augment_steadyhand" && id != "augment_hacking" && id != "augment_powersteps" && id != "augment_treadmill" && id != "grapplinghook") { return false; } string text = ((Object)((Component)rootArm).gameObject).name ?? ""; bool flag = text.StartsWith("Thigh", StringComparison.OrdinalIgnoreCase); bool flag2 = text.StartsWith("UpArm", StringComparison.OrdinalIgnoreCase); bool flag3 = id == "augment_powersteps" || id == "augment_treadmill"; int num; switch (id) { default: num = ((id == "grapplinghook") ? 1 : 0); break; case "augment_powergrip": case "augment_steadyhand": case "augment_hacking": num = 1; break; } bool flag4 = (byte)num != 0; if (flag3 && !flag) { PlayerCamera main = PlayerCamera.main; if (main != null) { main.DoAlert(ModLocale.T("alert.leg_augment_can_t_be_installed"), false); } return false; } if (flag4 && !flag2) { PlayerCamera main2 = PlayerCamera.main; if (main2 != null) { main2.DoAlert(ModLocale.T("alert.arm_augment_can_t_be_installed"), false); } return false; } if (LimbChainUtil.ChainHasAugment(rootArm, id)) { PlayerCamera main3 = PlayerCamera.main; if (main3 != null) { main3.DoAlert(ModLocale.T("alert.already_installed_on_this_limb"), false); } return false; } bio.modId = id; bio.modActive = false; if (id == "grapplinghook") { BatteryItem battery = item.battery; if ((Object)(object)battery != (Object)null && battery.hasBattery) { bio.batteryType = battery.batteryType; bio.batteryMax = battery.maxCharge; bio.condition = Mathf.Clamp01(item.condition); } else { bio.batteryType = ""; bio.batteryMax = 0f; bio.condition = 0f; } GrapplingHookArm grapplingHookArm = ((Component)body).GetComponent<GrapplingHookArm>() ?? ((Component)body).gameObject.AddComponent<GrapplingHookArm>(); grapplingHookArm.Init(item, rootArm); if (ProstheticsPlugin.KrokEnabled) { int num2 = Array.IndexOf(body.limbs, rootArm); if (num2 >= 0) { KrokMPBridge.SendBioSlot(body, num2, slotPresent: true, bio.modId, bio.condition, bio.batteryType, bio.batteryMax, bio.modActive); KrokMPBridge.SendDestroyItemAndUnregisterLocal(item); } } return true; } BatteryItem component = ((Component)item).GetComponent<BatteryItem>(); if ((Object)(object)component != (Object)null && component.hasBattery) { bio.batteryType = component.batteryType; bio.batteryMax = component.maxCharge; bio.condition = Mathf.Clamp01(item.condition); } else { bio.batteryType = ""; bio.batteryMax = 0f; bio.condition = 0f; } ApplyOverlayFor(bio.modId, rootArm); AugmentInstallSound.Play(); if (ProstheticsPlugin.KrokEnabled) { int num3 = Array.IndexOf(body.limbs, rootArm); if (num3 >= 0) { KrokMPBridge.SendBioSlot(body, num3, slotPresent: true, bio.modId, bio.condition, bio.batteryType, bio.batteryMax, bio.modActive); } KrokMPBridge.SendDestroyItemAndUnregisterLocal(item); } item.condition = 0f; Object.Destroy((Object)(object)((Component)item).gameObject); return true; } public static void EjectAugment(BioAugmentSlot bio, Limb rootArm, Body body, Body wielder) { //IL_02ae: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)bio == (Object)null || (Object)(object)rootArm == (Object)null || (Object)(object)body == (Object)null || !bio.HasAnyAugment()) { return; } string modId = bio.modId; string batteryType = bio.batteryType; float batteryMax = bio.batteryMax; float condition = bio.condition; if (modId == "grapplinghook") { GrapplingHookArm component = ((Component)body).GetComponent<GrapplingHookArm>(); Item val = component?.GetHookItemForLimb(rootArm); bio.modId = ""; bio.batteryType = ""; bio.batteryMax = 0f; bio.condition = 0f; bio.modActive = false; if (ProstheticsPlugin.KrokEnabled && KrokMPBridge.ClientRouteAugmentEject(body, "grapplinghook", Mathf.Clamp01(condition), batteryType, batteryMax)) { if ((Object)(object)val != (Object)null) { if ((Object)(object)component != (Object)null) { component.DetachLimb(rootArm); } KrokMPBridge.SendDestroyItemAndUnregisterLocal(val); Object.Destroy((Object)(object)((Component)val).gameObject); } } else { if ((Object)(object)val == (Object)null) { GameObject val2 = ProstheticsSpawn.Create("grapplinghook", Vector2.op_Implicit(((Component)body).transform.position), 0f); val = ((val2 != null) ? val2.GetComponent<Item>() : null); if ((Object)(object)val != (Object)null) { if ((Object)(object)val.battery != (Object)null) { val.battery.batteryType = batteryType ?? ""; val.battery.maxCharge = batteryMax; } val.condition = Mathf.Clamp01(condition); } } else { val.condition = Mathf.Clamp01(condition); if ((Object)(object)component != (Object)null) { component.DetachLimb(rootArm); } } if ((Object)(object)val != (Object)null) { GrapplingHookArm.ReturnHookToWielder(wielder ?? body, val, condition, batteryType, batteryMax); } } if (ProstheticsPlugin.KrokEnabled) { int num = Array.IndexOf(body.limbs, rootArm); if (num >= 0) { KrokMPBridge.SendBioSlot(body, num, slotPresent: true, "", 0f, "", 0f, active: false); } } return; } RemoveOverlayFor(modId, rootArm); bio.modId = ""; bio.batteryType = ""; bio.batteryMax = 0f; bio.condition = 0f; bio.modActive = false; if (!ProstheticsPlugin.KrokEnabled || !KrokMPBridge.ClientRouteAugmentEject(body, modId, condition, batteryType, batteryMax)) { GameObject val3 = ProstheticsSpawn.Create(modId, Vector2.op_Implicit(((Component)body).transform.position), 0f); Item val4 = ((val3 != null) ? val3.GetComponent<Item>() : null); if ((Object)(object)val4 != (Object)null) { Body obj = wielder ?? body; if (obj != null) { obj.AutoPickUpItem(val4); } ProstheticItemBlockPatch.StampBatteryState(val4, batteryType, batteryMax, condition); } } if (ProstheticsPlugin.KrokEnabled) { int num2 = Array.IndexOf(body.limbs, rootArm); if (num2 >= 0) { KrokMPBridge.SendBioSlot(body, num2, slotPresent: true, "", 0f, "", 0f, active: false); } } } public static bool InsertBattery(BioAugmentSlot bio, Limb rootArm, Body body, Item batteryItem) { if ((Object)(object)bio == (Object)null || !bio.HasAnyAugment() || (Object)(object)batteryItem == (Object)null) { return false; } if (!string.IsNullOrEmpty(bio.batteryType)) { return false; } if (bio.modId == "grapplinghook") { GrapplingHookArm grapplingHookArm = ((body != null) ? ((Component)body).GetComponent<GrapplingHookArm>() : null); if ((Object)(object)grapplingHookArm == (Object)null) { return false; } if (!grapplingHookArm.InsertBatteryForLimb(rootArm, batteryItem)) { return false; } if (ProstheticsPlugin.KrokEnabled) { int num = Array.IndexOf(body.limbs, rootArm); if (num >= 0) { KrokMPBridge.SendBioSlot(body, num, slotPresent: true, bio.modId, bio.condition, bio.batteryType, bio.batteryMax, bio.modActive); } } return true; } ItemInfo stats = batteryItem.Stats; BatteryInfo val = (BatteryInfo)(object)((stats is BatteryInfo) ? stats : null); if (val == null) { return false; } float num2 = ((bio.modId == "augment_powersteps" || bio.modId == "augment_treadmill") ? 300f : 100f); if (val.maxCharge <= 0f || val.maxCharge > num2) { return false; } bio.batteryType = batteryItem.id; bio.batteryMax = val.maxCharge; bio.condition = Mathf.Clamp01(batteryItem.condition); if (ProstheticsPlugin.KrokEnabled) { int num3 = Array.IndexOf(body.limbs, rootArm); if (num3 >= 0) { KrokMPBridge.SendBioSlot(body, num3, slotPresent: true, bio.modId, bio.condition, bio.batteryType, bio.batteryMax, bio.modActive); } } batteryItem.condition = 0f; if (ProstheticsPlugin.KrokEnabled) { KrokMPBridge.SendDestroyItemAndUnregisterLocal(batteryItem); } Object.Destroy((Object)(object)((Component)batteryItem).gameObject); return true; } public static bool EjectBattery(BioAugmentSlot bio, Limb rootArm, Body body, Body wielder) { if ((Object)(object)bio == (Object)null || !bio.HasAnyAugment() || string.IsNullOrEmpty(bio.batteryType)) { return false; } if (bio.modId == "grapplinghook") { GrapplingHookArm grapplingHookArm = ((body != null) ? ((Component)body).GetComponent<GrapplingHookArm>() : null); if ((Object)(object)grapplingHookArm == (Object)null) { return false; } if (!grapplingHookArm.EjectBatteryForLimb(rootArm, wielder ?? body)) { return false; } if (ProstheticsPlugin.KrokEnabled) { int num = Array.IndexOf(body.limbs, rootArm); if (num >= 0) { KrokMPBridge.SendBioSlot(body, num, slotPresent: true, bio.modId, bio.condition, bio.batteryType, bio.batteryMax, bio.modActive); } } return true; } string batteryType = bio.batteryType; float condition = bio.condition; bio.batteryType = ""; bio.batteryMax = 0f; bio.condition = 0f; bio.modActive = false; KrokMPBridge.RouteOrSpawnBatteryEject(wielder ?? body, batteryType, condition); if (ProstheticsPlugin.KrokEnabled) { int num2 = Array.IndexOf(body.limbs, rootArm); if (num2 >= 0) { KrokMPBridge.SendBioSlot(body, num2, slotPresent: true, bio.modId, bio.condition, bio.batteryType, bio.batteryMax, bio.modActive); } } return true; } public static void DropAndClear(BioAugmentSlot bio, Limb rootArm, Body body) { //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015c: 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_00c0: 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) if ((Object)(object)bio == (Object)null || (Object)(object)rootArm == (Object)null) { return; } if (bio.HasAnyAugment()) { string modId = bio.modId; string batteryType = bio.batteryType; float batteryMax = bio.batteryMax; float condition = bio.condition; if (modId == "grapplinghook") { GrapplingHookArm grapplingHookArm = ((body != null) ? ((Component)body).GetComponent<GrapplingHookArm>() : null); Item val = grapplingHookArm?.GetHookItemForLimb(rootArm); if ((Object)(object)val != (Object)null) { val.condition = Mathf.Clamp01(condition); grapplingHookArm?.DetachLimb(rootArm); } else { Vector2 pos = Vector2.op_Implicit(((Component)rootArm).transform.position); GameObject val2 = ProstheticsSpawn.Create("grapplinghook", pos, 0f); Item val3 = ((val2 != null) ? val2.GetComponent<Item>() : null); if ((Object)(object)val3 != (Object)null) { if ((Object)(object)val3.battery != (Object)null) { val3.battery.batteryType = batteryType ?? ""; val3.battery.maxCharge = batteryMax; } val3.condition = Mathf.Clamp01(condition); } } } else { RemoveOverlayFor(modId, rootArm); Vector2 pos2 = Vector2.op_Implicit(((Component)rootArm).transform.position); GameObject val4 = ProstheticsSpawn.Create(modId, pos2, 0f); Item val5 = ((val4 != null) ? val4.GetComponent<Item>() : null); if ((Object)(object)val5 != (Object)null) { ProstheticItemBlockPatch.StampBatteryState(val5, batteryType, batteryMax, condition); } } } bio.modId = ""; bio.batteryType = ""; bio.batteryMax = 0f; bio.condition = 0f; bio.modActive = false; if ((Object)(object)body != (Object)null && ProstheticsPlugin.KrokEnabled) { int num = Array.IndexOf(body.limbs, rootArm); if (num >= 0) { KrokMPBridge.SendBioSlot(body, num, slotPresent: false, "", 0f, "", 0f, active: false); } } BioImplantOverlay.Remove(rootArm); Object.Destroy((Object)(object)bio); } public static void ApplyOverlayFor(string modId, Limb rootArm) { if (!((Object)(object)rootArm == (Object)null) && !string.IsNullOrEmpty(modId)) { switch (modId) { case "augment_powergrip": PowergripArmOverlay.Apply(rootArm); PowergripDownArmOverlay.Apply(rootArm); break; case "augment_steadyhand": SteadyHandArmOverlay.Apply(rootArm); break; case "augment_hacking": HackingArmOverlay.Apply(rootArm); break; case "augment_powersteps": PowerstepsThighOverlay.Apply(rootArm); break; case "augment_treadmill": TreadmillThighOverlay.Apply(rootArm); break; } } } public static void RemoveOverlayFor(string modId, Limb rootArm) { if (!((Object)(object)rootArm == (Object)null) && !string.IsNullOrEmpty(modId)) { switch (modId) { case "augment_powergrip": PowergripArmOverlay.Remove(rootArm); PowergripDownArmOverlay.Remove(rootArm); ScrubOverlayChildren(rootArm, "PowergripArmOverlay"); ScrubOverlayChildren(rootArm, "PowergripDownArmOverlay"); break; case "augment_steadyhand": SteadyHandArmOverlay.Remove(rootArm); ScrubOverlayChildren(rootArm, "SteadyHandArmOverlay"); break; case "augment_hacking": HackingArmOverlay.Remove(rootArm); ScrubOverlayChildren(rootArm, "HackingArmOverlay"); break; case "augment_powersteps": PowerstepsThighOverlay.Remove(rootArm); ScrubOverlayChildren(rootArm, "PowerstepsThighOverlay"); break; case "augment_treadmill": TreadmillThighOverlay.Remove(rootArm); ScrubOverlayChildren(rootArm, "TreadmillThighOverlay"); break; } } } public static void ScrubOverlayChildren(Limb rootArm, string overlayGoName) { if ((Object)(object)rootArm == (Object)null || string.IsNullOrEmpty(overlayGoName)) { return; } foreach (Limb item in ProstheticLimb.GetDownstreamChain(rootArm)) { if ((Object)(object)item == (Object)null) { continue; } Transform transform = ((Component)item).transform; for (int num = transform.childCount - 1; num >= 0; num--) { Transform child = transform.GetChild(num); if ((Object)(object)child != (Object)null && ((Object)((Component)child).gameObject).name == overlayGoName) { Object.Destroy((Object)(object)((Component)child).gameObject); } } } } public static void ScrubAllAugmentOverlays(Limb rootArm) { ScrubOverlayChildren(rootArm, "PowergripArmOverlay"); ScrubOverlayChildren(rootArm, "PowergripDownArmOverlay"); ScrubOverlayChildren(rootArm, "SteadyHandArmOverlay"); ScrubOverlayChildren(rootArm, "HackingArmOverlay"); ScrubOverlayChildren(rootArm, "PowerstepsThighOverlay"); } public static string SectionLabel(Limb rootArm) { if ((Object)(object)rootArm == (Object)null) { return ModLocale.T("ui.section_augment"); } string text = ((Object)((Component)rootArm).gameObject).name ?? ""; bool flag = text.EndsWith("F", StringComparison.OrdinalIgnoreCase); bool flag2 = text.StartsWith("Thigh", StringComparison.OrdinalIgnoreCase); return ModLocale.T("ui.section_bio_" + (flag ? "right" : "left") + "_" + (flag2 ? "leg" : "arm")); } } internal static class BioImplantOverlay { public static Texture2D UpArmFTex; public static Texture2D UpArmBTex; public static Texture2D ThighFTex; public static Texture2D ThighBTex; private const string OverlayGoName = "BioImplantOverlay"; public static Sprite UpArmFSprite { set { if ((Object)(object)value != (Object)null) { UpArmFTex = value.texture; } } } public static Sprite UpArmBSprite { set { if ((Object)(object)value != (Object)null) { UpArmBTex = value.texture; } } } public static Sprite ThighFSprite { set { if ((Object)(object)value != (Object)null) { ThighFTex = value.texture; } } } public static Sprite ThighBSprite { set { if ((Object)(object)value != (Object)null) { ThighBTex = value.texture; } } } public static void Apply(Limb rootLimb) { //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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown //IL_0134: 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_0158: 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_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rootLimb == (Object)null) { return; } Texture2D val = PickTexFor(rootLimb); if ((Object)(object)val == (Object)null) { return; } Remove(rootLimb); SpriteRenderer component = ((Component)rootLimb).GetComponent<SpriteRenderer>(); if ((Object)(object)component == (Object)null || (Object)(object)component.sprite == (Object)null) { return; } Sprite sprite = component.sprite; float pixelsPerUnit = sprite.pixelsPerUnit; Rect rect = sprite.rect; Vector2 val2; if (((Rect)(ref rect)).width > 0f) { rect = sprite.rect; if (((Rect)(ref rect)).height > 0f) { float x = sprite.pivot.x; rect = sprite.rect; float num = x / ((Rect)(ref rect)).width; float y = sprite.pivot.y; rect = sprite.rect; val2 = new Vector2(num, y / ((Rect)(ref rect)).height); goto IL_00e3; } } val2 = new Vector2(0.5f, 0.5f); goto IL_00e3; IL_00e3: Vector2 val3 = val2; Sprite sprite2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), val3, pixelsPerUnit); GameObject val4 = new GameObject("BioImplantOverlay"); val4.transform.SetParent(((Component)rootLimb).transform, false); val4.transform.localPosition = Vector3.zero; val4.transform.localRotation = Quaternion.identity; val4.transform.localScale = Vector3.one; SpriteRenderer val5 = val4.AddComponent<SpriteRenderer>(); val5.sprite = sprite2; ((Renderer)val5).sortingLayerID = ((Renderer)component).sortingLayerID; ((Renderer)val5).sortingOrder = ((Renderer)component).sortingOrder + 2; val5.flipX = component.flipX; val5.flipY = component.flipY; } public static void Remove(Limb rootLimb) { if ((Object)(object)rootLimb == (Object)null) { return; } for (int num = ((Component)rootLimb).transform.childCount - 1; num >= 0; num--) { Transform child = ((Component)rootLimb).transform.GetChild(num); if ((Object)(object)child != (Object)null && ((Object)((Component)child).gameObject).name == "BioImplantOverlay") { Object.Destroy((Object)(object)((Component)child).gameObject); } } } private static Texture2D PickTexFor(Limb rootLimb) { string text = ((Object)((Component)rootLimb).gameObject).name ?? ""; bool flag = text.EndsWith("F", StringComparison.OrdinalIgnoreCase); bool flag2 = text.StartsWith("UpArm", StringComparison.OrdinalIgnoreCase); bool flag3 = text.StartsWith("Thigh", StringComparison.OrdinalIgnoreCase); if (flag2) { return flag ? UpArmFTex : UpArmBTex; } if (flag3) { return flag ? ThighFTex : ThighBTex; } return null; } public static int AugmentOverlayOrder(SpriteRenderer hostSr, Limb rootLimb) { int num = (((Object)(object)hostSr != (Object)null) ? ((Renderer)hostSr).sortingOrder : 0); int num2 = num; if ((Object)(object)rootLimb != (Object)null) { SpriteRenderer component = ((Component)rootLimb).GetComponent<SpriteRenderer>(); if ((Object)(object)component != (Object)null) { num2 = ((Renderer)component).sortingOrder; } } return Math.Max(num + 2, num2 + 3); } } internal static class BioImplantWoundView { private const string ChildName = "bio_implant_woundview"; public static Sprite ArmSprite; public static Sprite ThighSprite; public static Sprite ArmAugmentedSprite; public static Sprite ThighAugmentedSprite; public static void Refresh(Limb limb, RectTransform rootRt) { //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Expected O, but got Unknown //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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_01b4: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)rootRt == (Object)null) { return; } BioAugmentSlot bioAugmentSlot = (((Object)(object)limb != (Object)null) ? ((Component)limb).GetComponent<BioAugmentSlot>() : null); if ((Object)(object)bioAugmentSlot == (Object)null) { Hide(rootRt); return; } string text = ((Object)((Component)limb).gameObject).name ?? ""; bool flag = text.StartsWith("Thigh", StringComparison.OrdinalIgnoreCase); bool flag2 = bioAugmentSlot.HasAnyAugment(); Sprite val = ((!flag) ? (flag2 ? (ArmAugmentedSprite ?? ArmSprite) : ArmSprite) : (flag2 ? (ThighAugmentedSprite ?? ThighSprite) : ThighSprite)); if ((Object)(object)val == (Object)null) { Hide(rootRt); return; } Transform val2 = ((Transform)rootRt).Find("bio_implant_woundview"); Image val4; if ((Object)(object)val2 == (Object)null) { GameObject val3 = new GameObject("bio_implant_woundview", new Type[1] { typeof(RectTransform) }); val2 = val3.transform; val2.SetParent((Transform)(object)rootRt, false); RectTransform component = val3.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.anchoredPosition = Vector2.zero; component.sizeDelta = ProstheticWoundView.OriginalSizeOf(rootRt); val4 = val3.AddComponent<Image>(); ((Graphic)val4).raycastTarget = false; } else { val4 = ((Component)val2).GetComponent<Image>(); RectTransform component2 = ((Component)val2).GetComponent<RectTransform>(); if ((Object)(object)component2 != (Object)null) { component2.sizeDelta = ProstheticWoundView.OriginalSizeOf(rootRt); } } if (!((Object)(object)val4 == (Object)null)) { val2.SetAsLastSibling(); if ((Object)(object)val4.sprite != (Object)(object)val) { val4.sprite = val; } if (!((Component)val2).gameObject.activeSelf) { ((Component)val2).gameObject.SetActive(true); } ((Behaviour)val4).enabled = true; } } private static void Hide(RectTransform rootRt) { Transform val = ((Transform)rootRt).Find("bio_implant_woundview"); if ((Object)(object)val != (Object)null) { ((Component)val).gameObject.SetActive(false); } } } [HarmonyPatch(typeof(Limb), "Dismember")] internal class BioSlotDismemberPatch { private static void Prefix(Limb __instance) { if ((Object)(object)__instance == (Object)null || __instance.dismembered) { return; } Body body = __instance.body; if ((Object)(object)body == (Object)null) { return; } string text = ((Object)((Component)__instance).gameObject).name ?? ""; if (text.StartsWith("UpArm", StringComparison.OrdinalIgnoreCase) || text.StartsWith("Thigh", StringComparison.OrdinalIgnoreCase)) { BioAugmentSlot component = ((Component)__instance).GetComponent<BioAugmentSlot>(); if ((Object)(object)component != (Object)null) { BioAugmentOps.DropAndClear(component, __instance, body); } bool severedLimbWasProsthetic = (Object)(object)((Component)__instance).GetComponent<ProstheticLimb>() != (Object)null; string chainId = LimbChainUtil.GetChainId(__instance); if (!string.IsNullOrEmpty(chainId)) { ProstheticItemBlockPatch.TearDownChainProsthetics(body, chainId, severedLimbWasProsthetic); } } } } public class BioAugmentSlotDropHandler : MonoBehaviour { public BioAugmentSlot bio; public Limb rootArm; public Body body; } public class BioAugmentBatteryDropHandler : MonoBehaviour { public BioAugmentSlot bio; public Limb rootArm; public Body body; } internal static class BodyFx { public const byte LobotomyFlash = 1; public const byte DeusRebirth = 2; public const byte DeusFlashQuick = 3; public const byte DeusFlashLong = 4; public const byte AlarmCue = 5; public const byte PrionCured = 6; public const byte ReservoirRefined = 7; public const byte IntDegraded = 8; public const byte DeusMindwipeAbsorbed = 9; public const byte PandoraBoxSpent = 10; public static void PlayLocal(byte fx) { switch (fx) { case 1: KrokMPBridge.FlashBrainLocal(); break; case 2: DeusEstMachina.PlayRebirthVisuals(); break; case 3: DeusEstMachina.FlashImage(0.8f); break; case 4: DeusEstMachina.FlashImage(6f); DeusEstMachina.PlayCancelSting(); break; case 5: { PlayerCamera main5 = PlayerCamera.main; if ((Object)(object)main5 != (Object)null) { main5.currentThreatTheme = 12; main5.threatMusicTime = 14f; main5.DoAlert(ModLocale.T("alert.something_heard_that"), false); } break; } case 6: { PlayerCamera main2 = PlayerCamera.main; if (main2 != null) { main2.DoAlert(ModLocale.T("alert.the_prions_are_cured"), false); } break; } case 9: DeusEstMachina.CompleteMindwipeAbsorption(PlayerCamera.main?.body); break; case 10: { PlayerCamera main4 = PlayerCamera.main; if (main4 != null) { main4.DoAlert(ModLocale.T("alert.the_reliquary_falls_silent_and_crumbles"), false); } break; } case 8: { PlayerCamera main3 = PlayerCamera.main; if (main3 != null) { main3.DoAlert(ModLocale.T("alert.intelligence_degraded"), false); } break; } case 7: { PlayerCamera main = PlayerCamera.main; if (main != null) { main.DoAlert(ModLocale.T("alert.the_reservoir_has_refined"), false); } break; } } } } internal static class CerebralExtractor { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static UseLimb <>9__29_0; public static Use <>9__29_1; internal void <RegisterItem>b__29_0(Limb limb, Item item) { UseOnLimb(limb, item); } internal void <RegisterItem>b__29_1(Body body, Item item) {