Decompiled source of GunUI New Firearms v2.0.2
GunMinigame.dll
Decompiled 7 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.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Bootstrap; using HarmonyLib; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("GunMinigame")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2+2d0add431a2c96a088c52dd44c20c7b71c73e29e")] [assembly: AssemblyProduct("GunMinigame")] [assembly: AssemblyTitle("GunMinigame")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: UnverifiableCode] namespace GunMinigame { public class Casing : MonoBehaviour { public Vector3 inertia; private float spin; private float age; private Image visual; private MinigameManager owner; private static Sprite fallback; public static void Create(Sprite casing, Vector3 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) CreateVisual(MinigameManager.GetOrAddInstance(), casing, position, Vector3.zero, live: false); } internal static Sprite GetVisualSprite(Sprite sprite) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)sprite == (Object)null) && !((Object)(object)sprite.texture == (Object)null)) { Rect rect = sprite.rect; if (!(((Rect)(ref rect)).width < 3f)) { rect = sprite.rect; if (!(((Rect)(ref rect)).height < 3f)) { goto IL_00fb; } } } if ((Object)(object)fallback == (Object)null) { Texture2D val = new Texture2D(5, 12, (TextureFormat)4, false); ((Texture)val).filterMode = (FilterMode)0; for (int i = 0; i < 12; i++) { for (int j = 0; j < 5; j++) { val.SetPixel(j, i, (j == 0 || j == 4 || i == 0) ? new Color(0.95f, 0.85f, 0.57f) : new Color(0.61f, 0.47f, 0.23f)); } } val.Apply(); fallback = Sprite.Create(val, new Rect(0f, 0f, 5f, 12f), new Vector2(0.5f, 0.5f)); } sprite = fallback; goto IL_00fb; IL_00fb: return sprite; } internal static void CreateVisual(MinigameManager manager, Sprite sprite, Vector3 position, Vector3 inherited, bool live) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0090: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)manager.maskBase == (Object)null) && manager.active) { Casing[] componentsInChildren = manager.maskBase.GetComponentsInChildren<Casing>(); if (componentsInChildren.Length >= 40) { Object.Destroy((Object)(object)((Component)componentsInChildren[0]).gameObject); } sprite = GetVisualSprite(sprite); Image val = new GameObject("Casing").AddComponent<Image>(); ((Component)val).transform.SetParent(manager.maskBase.transform, false); ((Component)val).transform.localPosition = position; ((Component)val).transform.localScale = new Vector3(0.003515625f * (float)Screen.width, 1f / 160f * (float)Screen.height); ((Graphic)val).rectTransform.sizeDelta = RoundVisual.GetSize(sprite, manager.info?.roundHeight ?? 0f, live); val.sprite = sprite; val.preserveAspect = true; ((Graphic)val).raycastTarget = false; Casing casing = ((Component)val).gameObject.AddComponent<Casing>(); casing.visual = val; casing.owner = manager; bool flag = manager.info != null && manager.info.casingsDrop; float num = ((manager.info != null && manager.info.doubleCasingLift) ? 2f : 1f); casing.inertia = Vector3.ClampMagnitude(inherited, 400f) + new Vector3(Random.Range(-190f, -110f), flag ? 0f : (Random.Range(210f, 290f) * num)); casing.spin = Random.Range(-620f, 620f); } } private void Update() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_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_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)owner == (Object)null || !owner.active) { Object.Destroy((Object)(object)((Component)this).gameObject); return; } float num = Mathf.Min(Time.deltaTime, 0.1f); if (!((Object)(object)PauseHandler.main != (Object)null) || !PauseHandler.main.isPaused) { float num2 = Mathf.Exp(-0.5f * num); float num3 = (1f - num2) / 0.5f; Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0f, -3900f); Transform transform = ((Component)this).transform; transform.localPosition += val * num + (inertia - val) * num3; inertia = val + (inertia - val) * num2; ((Component)this).transform.Rotate(0f, 0f, spin * num); age += num; if ((Object)(object)visual != (Object)null) { ((Graphic)visual).color = new Color(1f, 1f, 1f, owner.windowAlpha * Mathf.Clamp01((1.8f - age) / 0.3f)); } if (age >= 1.8f || ((Component)this).transform.localPosition.y < -240f) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } } public class FannyPackScript : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { public static bool isHovering; public void OnPointerEnter(PointerEventData eventData) { isHovering = true; } public void OnPointerExit(PointerEventData eventData) { isHovering = false; } } internal sealed class GunInertia { private Vector2 center; private Vector2 gripArm; private Vector2 muzzleArm; private float moment; private bool sliderHeld; private Vector2 sliderPoint; private Vector2 sliderTarget; private const float MaxAngle = 0.34906584f; internal Vector2 Grip { get; private set; } internal Vector2 Muzzle { get; private set; } internal Vector2 Offset { get; private set; } internal Vector2 Velocity { get; private set; } internal float Angle { get; private set; } internal float AngularVelocity { get; private set; } internal float Mass { get; private set; } = 1f; internal Vector2 GripPosition => center + Offset + Rotate(gripArm, Angle); internal Vector2 MuzzlePosition => center + Offset + Rotate(muzzleArm, Angle); internal Vector2 Position => center + Offset - Rotate(center, Angle); internal GunInertia() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) Configure(new Vector2(-0.3f, -0.025f), new Vector2(0.2f, 0.05f), 1f); } internal void Configure(Vector2 grip, Vector2 muzzle, float mass) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) Grip = grip; Muzzle = muzzle; Mass = Mathf.Clamp(mass, 0.25f, 12f); center = (grip + muzzle) * 0.5f; gripArm = grip - center; muzzleArm = muzzle - center; float mass2 = Mass; Vector2 val = muzzle - grip; moment = mass2 * Mathf.Max(((Vector2)(ref val)).sqrMagnitude, 0.01f) / 12f; Reset(); } internal void Reset() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) Vector2 offset = (Velocity = Vector2.zero); Offset = offset; float angle = (AngularVelocity = 0f); Angle = angle; ReleaseSlider(); } internal void ImpulseAtGrip(Vector2 impulse) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) ApplyImpulse(gripArm, impulse); } internal void ImpulseAtMuzzle(Vector2 impulse) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) ApplyImpulse(muzzleArm, impulse); } internal void ImpulseAtPoint(Vector2 point, Vector2 impulse) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) ApplyImpulse(point - center, impulse); } internal void HoldSlider(Vector2 point, Vector2 target) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) sliderHeld = true; sliderPoint = point; sliderTarget = target; } internal void ReleaseSlider() { sliderHeld = false; } private void ApplyImpulse(Vector2 arm, Vector2 impulse) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Velocity = Vector2.ClampMagnitude(Velocity + impulse / Mass, 4f); AngularVelocity = Mathf.Clamp(AngularVelocity + Cross(Rotate(arm, Angle), impulse) / moment, -12f, 12f); } internal void Step(float deltaTime, Vector2 handTarget, float gripStrength) { //IL_0037: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0265: Unknown result type (might be due to invalid IL or missing references) //IL_026a: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: 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_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0211: Unknown result type (might be due to invalid IL or missing references) if (deltaTime <= 0f) { return; } float num = Mathf.Min(deltaTime, 0.25f); int num2 = Mathf.CeilToInt(num * 240f); float num3 = num / (float)num2; gripStrength = Mathf.Clamp(gripStrength, 0.15f, 2f); handTarget = Vector2.ClampMagnitude(handTarget, 0.15f); for (int i = 0; i < num2; i++) { Vector2 val = Rotate(gripArm, Angle); Vector2 val2 = Rotate(muzzleArm, Angle); Vector2 val3 = Velocity + Perpendicular(val) * AngularVelocity; Vector2 val4 = Velocity + Perpendicular(val2) * AngularVelocity; Vector2 val5 = ((Grip + handTarget - center - Offset - val) * (240f * gripStrength) - val3 * (16f * Mathf.Sqrt(gripStrength))) * Mass; Vector2 val6 = ((Muzzle - center - Offset - val2) * 55f - val4 * 3f) * Mass; Vector2 val7 = val5 + val6; float num4 = Cross(val, val5) + Cross(val2, val6); if (sliderHeld) { Vector2 val8 = Rotate(sliderPoint - center, Angle); Vector2 val9 = Velocity + Perpendicular(val8) * AngularVelocity; Vector2 val10 = Vector2.ClampMagnitude((sliderTarget - (center + Offset + val8)) * 480f - val9 * 28f, 25f); val7 += val10; num4 += Cross(val8, val10); } Velocity += val7 / Mass * num3; AngularVelocity += num4 / moment * num3; Offset += Velocity * num3; Angle += AngularVelocity * num3; LimitPose(); } } private void LimitPose() { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0068: 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_0086: 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) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(Mathf.Clamp(Offset.x, -0.15f, 0.15f), Mathf.Clamp(Offset.y, -0.12f, 0.12f)); Velocity = new Vector2((val.x != Offset.x) ? 0f : Velocity.x, (val.y != Offset.y) ? 0f : Velocity.y); Offset = val; if (Mathf.Abs(Angle) > 0.34906584f) { Angle = Mathf.Clamp(Angle, -0.34906584f, 0.34906584f); AngularVelocity = 0f; } } private static float Cross(Vector2 a, Vector2 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) return a.x * b.y - a.y * b.x; } private static Vector2 Perpendicular(Vector2 v) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) return new Vector2(0f - v.y, v.x); } private static Vector2 Rotate(Vector2 v, float angle) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Cos(angle); float num2 = Mathf.Sin(angle); return new Vector2(num * v.x - num2 * v.y, num2 * v.x + num * v.y); } } public interface IMinigameGun { bool IsRacked(); bool TryGetChamberVisual(out Sprite sprite, out bool liveRound); byte CurrentFireMode(); void Rack(); void ToggleFireMode(); bool DragOnto(Item item); void RemoveMag(); string CurrentMag(); bool HasEmptyMagazine(); bool IsReady(); void SetHalfRecoil(bool active); } public interface IMinigameRetractableGun { bool UsesRetraction(); } public interface IMinigameMag { bool DragOnto(Item item); } public interface IMinigameJammedGun { bool TryGetJam(out Sprite sprite, out bool liveRound); void ClearJam(); } public interface IMinigameFlashlight { bool HasFlashlight(); void ToggleFlashlight(); } public interface ILaser { void Toggle(); bool IsEnabled(); } public class MagazineDragTrigger : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { public static bool isHovering; public void OnPointerEnter(PointerEventData eventData) { isHovering = true; } public void OnPointerExit(PointerEventData eventData) { isHovering = false; } } public class MagazineScript : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler, IPointerEnterHandler { public Item it; public static MagazineScript currentlyHovering; private Container dragSource; public void OnBeginDrag(PointerEventData eventData) { dragSource = (((Object)(object)it != (Object)null) ? it.ParentContainer() : null); if (!((Object)(object)dragSource == (Object)null)) { MinigameManager orAddInstance = MinigameManager.GetOrAddInstance(); MagazineDragTrigger.isHovering = false; ((Component)orAddInstance.magazineDragTrigger).gameObject.SetActive(true); ((Transform)((Component)this).GetComponent<RectTransform>()).SetParent((Transform)(object)orAddInstance.handTransform); ((Graphic)((Component)this).GetComponent<Image>()).raycastTarget = false; } } public void OnDrag(PointerEventData eventData) { } public void OnPointerEnter(PointerEventData eventData) { currentlyHovering = this; } public void OnEndDrag(PointerEventData eventData) { MinigameManager orAddInstance = MinigameManager.GetOrAddInstance(); if (!((Component)orAddInstance.magazineDragTrigger).gameObject.activeSelf) { return; } if ((Object)(object)dragSource != (Object)null && (Object)(object)it != (Object)null && (Object)(object)it.ParentContainer() == (Object)(object)dragSource) { if (MagazineDragTrigger.isHovering) { orAddInstance.DropMagazine(it, ((Component)this).GetComponent<Image>()); } else if (!FannyPackScript.isHovering && !Plugin.IsMarksman(PlayerCamera.main.body)) { dragSource.UnloadItem(it, (Body)null); } } dragSource = null; orAddInstance.EndMagazineDrag(); Object.Destroy((Object)(object)((Component)this).gameObject); } public void Jump() { ((MonoBehaviour)this).StartCoroutine(_Jump()); } private IEnumerator _Jump() { float timer = 0.2f; Vector3 ogPosition = ((Component)this).transform.position; while (0f < timer) { Transform transform = ((Component)this).transform; transform.position -= new Vector3(0f, (0.1f - timer) * 20f); timer -= Time.deltaTime; yield return null; } ((Component)this).transform.position = ogPosition; } } [HarmonyPatch(typeof(PlayerCamera), "HandleInput")] internal static class MarksmanGunHotkeysPatch { private static bool nativeRackHotkey; private static bool nativeUnloadHotkey; private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { nativeUnloadHotkey = false; nativeRackHotkey = false; MethodInfo rack = AccessTools.Method(typeof(PlayerCamera), "GunRack", (Type[])null, (Type[])null); MethodInfo unload = AccessTools.Method(typeof(PlayerCamera), "GunEjectMag", (Type[])null, (Type[])null); MethodInfo rackHotkey = AccessTools.Method(typeof(MarksmanGunHotkeysPatch), "RackHotkey", (Type[])null, (Type[])null); MethodInfo unloadHotkey = AccessTools.Method(typeof(MarksmanGunHotkeysPatch), "UnloadHotkey", (Type[])null, (Type[])null); foreach (CodeInstruction instruction in instructions) { if (CodeInstructionExtensions.Calls(instruction, rack) || CodeInstructionExtensions.Calls(instruction, unload)) { if (CodeInstructionExtensions.Calls(instruction, rack)) { nativeRackHotkey = true; } else { nativeUnloadHotkey = true; } CodeInstruction val = new CodeInstruction(instruction); val.opcode = OpCodes.Call; val.operand = (CodeInstructionExtensions.Calls(instruction, rack) ? rackHotkey : unloadHotkey); yield return val; } else { yield return instruction; } } } private static void Postfix(PlayerCamera __instance) { //IL_0046: 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) if (!((Object)(object)__instance != (Object)(object)PlayerCamera.main) && !((Object)(object)__instance.body == (Object)null) && Plugin.IsMarksman(__instance.body)) { bool num = Plugin.GetPlayerSpecies(__instance.body) == PlayerSpecies.Milky; if ((!num || !nativeRackHotkey) && Input.GetKeyDown(KeyBinds.GetBind("marksmanrack"))) { RackHotkey(__instance); } if ((!num || !nativeUnloadHotkey) && Input.GetKeyDown(KeyBinds.GetBind("marksmanunload"))) { UnloadHotkey(__instance); } } } private static void RackHotkey(PlayerCamera player) { HandleHotkey(player, rack: true); } private static void UnloadHotkey(PlayerCamera player) { HandleHotkey(player, rack: false); } private static void HandleHotkey(PlayerCamera player, bool rack) { if ((Object)(object)player != (Object)(object)PlayerCamera.main || (Object)(object)player.body == (Object)null || !Plugin.IsMarksman(player.body) || MinigameManager.IsAnyGameUIOpen() || !player.body.HoldingItem(player.body.handSlot)) { return; } Item item = player.body.GetItem(player.body.handSlot); if (!item.Stats.HasTag("gun")) { return; } MinigameManager instance = MinigameManager.instance; IMinigameGun minigameGun = ((Component)item).GetComponent(typeof(IMinigameGun)) as IMinigameGun; if (rack && minigameGun is IMinigameRetractableGun minigameRetractableGun && minigameRetractableGun.UsesRetraction()) { if (player.body.conscious) { minigameGun.Rack(); } return; } if ((Object)(object)instance != (Object)null && instance.active) { if (minigameGun == instance.gun && !instance.hiden) { instance.HandleMarksmanHotkey(rack); return; } if (minigameGun != instance.gun) { instance.Hide(); } } if (rack) { player.GunRack(); } else { player.GunEjectMag(); } } } public class MinigameConfig : MinigameInfo { public string mainExperimentPath; public string mainMilkyTriggerOnPath; public string mainMilkyTriggerOffPath; public string mainDunePath; public string sliderFrontPath; public string grabTrigger; public string sliderBackPath; public string backLayerPath; public string magazineBackLayerPath; public string barrelPath; public string rackedOnlyPath; public string unrackedOnlyPath; public string[] ammosInHandPaths; public string[] ammosInPtrPaths; public string receiverPath; public string magReleasePath; public string rackTriggerPath; public Dictionary<string, string> magazinePaths; public Dictionary<string, string[]> ammosInMagazinePaths; public string magazineDragPath; public string[] casingsPath; public string laserTogglePath; public string flashlightTogglePath; public string laserPath; public string fireTogglePath; public string[] fireModePaths; public string[] coverAnimationPaths; } [DefaultExecutionOrder(100)] internal sealed class MinigameCoordinates : MonoBehaviour { internal static bool Visible; private MinigameManager manager; private RectTransform panel; private Text label; internal void Initialize(MinigameManager owner) { manager = owner; } private void LateUpdate() { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0161: 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_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) bool flag = Visible && (Object)(object)manager != (Object)null && manager.active && !manager.hiden && manager.info != null && (Object)(object)manager.gunBase != (Object)null && (Object)(object)manager.canvas != (Object)null; if ((Object)(object)panel != (Object)null) { ((Component)panel).gameObject.SetActive(flag); } if (flag) { if ((Object)(object)panel == (Object)null) { CreatePanel(); } ((Transform)panel).SetAsLastSibling(); Canvas component = manager.canvas.GetComponent<Canvas>(); Transform transform = manager.canvas.transform; RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null); Camera val2 = (((Object)(object)component != (Object)null && (int)component.renderMode != 0) ? component.worldCamera : null); Vector3 val3 = default(Vector3); if ((Object)(object)val == (Object)null || !RectTransformUtility.ScreenPointToWorldPointInRectangle(val, Vector2.op_Implicit(Input.mousePosition), val2, ref val3)) { ((Component)panel).gameObject.SetActive(false); return; } Vector3 val4 = manager.gunBase.transform.InverseTransformPoint(val3); float num = val4.x / Mathf.Max(1f, (float)Screen.width); float num2 = val4.y / Mathf.Max(1f, (float)Screen.height); float num3 = val4.x / Mathf.Max(1f, MinigameManager.size.x); float num4 = val4.y / Mathf.Max(1f, MinigameManager.size.y); bool flag2 = manager.info.rackByRotation && !manager.info.mosynStyleRack; Vector2 val5 = Vector2.op_Implicit(val4) - Vector2.op_Implicit(((Component)manager.sliderFrontImage).transform.localPosition); float num5 = Mathf.Atan2(val5.y, val5.x) * 57.29578f; label.text = string.Format(CultureInfo.InvariantCulture, "nf_coordinate\ncasing / magazine / cover / barrel / rack center\nX: {0:0.00000} Y: {1:0.00000}\ninertiaHand / inertiaBarrel\nX: {2:0.00000} Y: {3:0.00000}\n" + (flag2 ? "slider: {4:0.000} degrees" : "slider X: {0:0.00000}"), num, num2, num3, num4, num5); } } private void CreatePanel() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) Image component = new GameObject("Minigame mouse coordinates", new Type[2] { typeof(RectTransform), typeof(Image) }).GetComponent<Image>(); panel = ((Graphic)component).rectTransform; ((Transform)panel).SetParent(manager.canvas.transform, false); RectTransform obj = panel; RectTransform obj2 = panel; RectTransform obj3 = panel; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 1f); obj3.pivot = val; Vector2 anchorMin = (obj2.anchorMax = val); obj.anchorMin = anchorMin; panel.anchoredPosition = new Vector2(12f, -12f); ((Graphic)component).color = new Color(0f, 0f, 0f, 0.85f); ((Graphic)component).raycastTarget = false; label = new GameObject("Coordinates", new Type[2] { typeof(RectTransform), typeof(Text) }).GetComponent<Text>(); ((Component)label).transform.SetParent((Transform)(object)panel, false); ((Graphic)label).rectTransform.anchorMin = Vector2.zero; ((Graphic)label).rectTransform.anchorMax = Vector2.one; ((Graphic)label).rectTransform.offsetMin = new Vector2(10f, 8f); ((Graphic)label).rectTransform.offsetMax = new Vector2(-10f, -8f); label.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); label.fontSize = Mathf.Max(12, Mathf.RoundToInt(16f * (float)Screen.height / 1440f)); label.alignment = (TextAnchor)0; ((Graphic)label).color = Color.white; ((Graphic)label).raycastTarget = false; label.supportRichText = false; panel.sizeDelta = new Vector2((float)label.fontSize * 30f, (float)label.fontSize * 8f); } private void OnDisable() { if ((Object)(object)panel != (Object)null) { ((Component)panel).gameObject.SetActive(false); } } private void OnDestroy() { if ((Object)(object)panel != (Object)null) { Object.Destroy((Object)(object)((Component)panel).gameObject); } } } internal sealed class MinigameJamVisual : MonoBehaviour { private MinigameManager manager; private Image image; private IMinigameJammedGun jammedGun; private float nextClearTime; internal void Initialize(MinigameManager owner) { manager = owner; } private void LateUpdate() { //IL_0135: 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_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_01f6: Unknown result type (might be due to invalid IL or missing references) jammedGun = manager.gun as IMinigameJammedGun; Sprite sprite; bool liveRound; bool flag = manager.active && manager.info != null && jammedGun != null && jammedGun.TryGetJam(out sprite, out liveRound); if ((Object)(object)image != (Object)null) { ((Component)image).gameObject.SetActive(flag); } if (flag) { jammedGun.TryGetJam(out var sprite2, out var liveRound2); if ((Object)(object)image == (Object)null) { image = new GameObject("JammedRound").AddComponent<Image>(); ((Component)image).transform.SetParent(manager.gunBase.transform, false); ((UnityEvent)((Component)image).gameObject.AddComponent<Button>().onClick).AddListener(new UnityAction(Clear)); image.preserveAspect = true; } ((Component)image).transform.SetAsLastSibling(); image.sprite = Casing.GetVisualSprite(sprite2); ((Graphic)image).color = new Color(1f, 1f, 1f, manager.windowAlpha); ((Component)image).transform.localScale = new Vector3(0.003515625f * (float)Screen.width, 1f / 160f * (float)Screen.height); ((Graphic)image).rectTransform.sizeDelta = RoundVisual.GetSize(image.sprite, manager.info.roundHeight, liveRound2); ((Component)image).transform.localPosition = new Vector3(manager.info.casingXPosition, manager.info.casingYPosition); ((Component)image).transform.localRotation = Quaternion.Euler(0f, 0f, liveRound2 ? (-35f) : 25f); } } private void Clear() { if (!(Time.unscaledTime < nextClearTime) && manager.active && !manager.hiden && !MinigameManager.IsAnyGameUIOpen()) { nextClearTime = Time.unscaledTime + 0.3f; jammedGun?.ClearJam(); } } } internal static class ModLocale { private static string loadedLanguage; private static Dictionary<string, string> fallback; internal static void ApplyFallback() { if (Locale.currentLang == null) { return; } string currentLangName = Locale.currentLangName; if (fallback == null || loadedLanguage != currentLangName) { fallback = new Dictionary<string, string>(); LoadEmbedded("EN"); if (!string.Equals(currentLangName, "EN", StringComparison.OrdinalIgnoreCase)) { LoadEmbedded(currentLangName); } loadedLanguage = currentLangName; } foreach (KeyValuePair<string, string> item in fallback) { if (!Locale.currentLang.other.TryGetValue(item.Key, out var value) || string.IsNullOrWhiteSpace(value)) { Locale.currentLang.other[item.Key] = item.Value; } } } private static void LoadEmbedded(string language) { if (string.IsNullOrWhiteSpace(language)) { return; } string text = "GunMinigame.lang." + language + "-com.rushellxyz.gunminigame.json"; try { using Stream stream = typeof(ModLocale).Assembly.GetManifestResourceStream(text); if (stream == null) { return; } using StreamReader streamReader = new StreamReader(stream); Language val = JsonConvert.DeserializeObject<Language>(streamReader.ReadToEnd()); if (val?.other == null) { return; } foreach (KeyValuePair<string, string> item in val.other) { if (!string.IsNullOrWhiteSpace(item.Value)) { fallback[item.Key] = item.Value; } } } catch (Exception ex) { Debug.LogWarning((object)("[GunMinigame] Failed to load locale '" + text + "': " + ex.Message)); } } } public class MinigameManager : MonoBehaviour { private Image barrelImage; private bool automatedRackAction; private bool automatedMagazineRemoval; private bool magazineReleasedAtRear; private Item stagedMagazineItem; private Image stagedMagazineImage; private Transform stagedMagazinePivot; private float stagedMagazineAngle; public bool active; public bool holdsSlide; public Vector2 onBeginHoldSlide; public Image handImage; public bool handIsHovered; public bool handFaded; public Image uiImage; public Image sliderFrontImage; private Image chamberedRoundImage; public Image sliderBackImage; private Image backLayerImage; private Image magazineBackLayerImage; public Vector2 sliderHoldOffset; public GameObject canvas; public GameObject uiBase; private RectTransform windowClip; public GameObject gunBase; public GameObject maskBase; public Image mainImage; public RectTransform mainImageRect; public static Sprite backgroundSprite; public RectTransform handTransform; public Vector2 handVelocity; public Vector2 handPos; public static MinigameManager instance; public MinigameInfo info; public IMinigameGun gun; public bool shouldResetHandSprite; private float sliderLastXPos; private bool automatedHandAction; public Image rackedSpecific; public Image receiverTrigger; public static Sprite bandolierBackground; public static Sprite bandolierForeground; public static Sprite ptrBlank; public Image bandolierBase; public Image bandolierFront; public Transform ptrBase; public Image[] ptrs; public Container bandolier; public Item holding; public GameObject holdingInMinigame; public bool ignoreNextMouseKey; public static Sprite hideSprite; public static Sprite showSprite; public Image hideShowButton; public bool hiding; public bool hiden; public float windowAlpha; public bool shouldntRefreshBandolierCount; public static Sprite ammoSelectorSprite; public Image ammoSelector; public Image ammoIcon; public bool lastWindowAlphaWasLimit; public static Sprite ammoSelectWindowSprite; public static Sprite ammoSelectCursorSprite; public Image ammoSelectWindow; public List<Image> ammoSelectAmmo; public Image ammoSelectCursor; private bool pointerOverAmmoSelectionArea; public static Sprite fannyPackSprite; public static Sprite traumarigForegroundSprite; public static Sprite traumarigBackgroundSprite; public GameObject fannyPack; public Image fannyPackImage; public Image traumarigBackground; public static Sprite fannyPackZipSprite; public Image fannyPackZip; public float fannyPackZipInertia; public Image magReleaseTrigger; public Image rackTrigger; public bool handIsInBandolier; public float magSyncIgnoreTime; public Image insertedMagazine; public string insertedMagazineType; public bool shouldUpdateMagazineCount; public Item pendingJump; private List<Image> placedMagazines; private readonly List<Item> visiblePouchMagazines = new List<Item>(); public Image magazineDragTrigger; public static Vector3 size; public bool bandolierIsSpinning; public static Func<Item, string> bulletToShow; public static Vector3 fitSize; public ILaser laser; public Image laserToggleTrigger; public Image flashlightToggleTrigger; public Image laserImage; public Image fireToggleTrigger; public Image fireModeImage; public Image coverImage; public float coverTimer; public int coverIndex; public int coverChange; private Sprite marksmanGripSprite; private Vector2 marksmanGripCenter; private bool marksmanGripHasPixels; private float zipStepDirection = 1f; private readonly GunInertia inertia = new GunInertia(); private Body inertiaBody; private int inertiaSlot = -1; private Rigidbody2D inertiaHand; private Vector2 lastBodyVelocity; private Vector2 lastHandVelocity; private Vector2 lastBodyPosition; private float lastBodyAngularVelocity; private Vector2 painTremor; private bool sliderGripActive; private bool chargingHandleReturnPending; private bool chargingHandleCloseRequested; private Vector2 sliderGripLocalPoint; private Vector2 sliderPullTarget; private Quaternion sliderHandRotationOffset; private Quaternion sliderHandRestRotation; private readonly MosynRackMotion mosynMotion = new MosynRackMotion(); private bool mosynInitialized; private bool mosynObservedRacked; private bool? mosynRequestedRacked; private float mosynRequestTime; private readonly PumpGesture outsidePump = new PumpGesture(); private bool outsidePumpRequired; private bool outsidePumpInitialized; private bool outsidePumpOpened; private bool? outsidePumpRequest; private float outsidePumpRequestTime; private RectTransform pumpGuideRoot; private Image pumpGuideLine; private Image pumpGuideStart; private Image pumpGuideEnd; private Image pumpGuideCursor; public bool hadRacked; internal Image grabTriggerImage; private Image supportHandImage; private GameObject supportGripInputBlocker; private bool supportGripHeld; private Vector3 supportGripPoint; public static Body body => PlayerCamera.main.body; public bool IsManipulatingGun { get { if (!holdsSlide) { return automatedHandAction; } return true; } } internal bool IsSliderOpeningBlocked { get { if (info != null && info.locksSliderOnSafety && gun != null && !gun.IsRacked()) { return gun.CurrentFireMode() == 0; } return false; } } internal Vector2 SliderPointer { get { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!sliderGripActive) { return handPos; } return sliderPullTarget; } } internal Vector2 SliderGripPoint => Vector2.op_Implicit(gunBase.transform.InverseTransformPoint(((Component)sliderFrontImage).transform.TransformPoint(Vector2.op_Implicit(sliderGripActive ? sliderGripLocalPoint : Vector2.zero)))); private float MosynLift => Mathf.Max(0.5f, (float)Screen.height * 0.0175f); private Vector2 MosynPointer => Vector2.op_Implicit(gunBase.transform.InverseTransformPoint(Vector2.op_Implicit(SliderPointer))); private void UpdateBarrelTransform() { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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) if (((Behaviour)barrelImage).enabled) { ((Component)barrelImage).transform.localPosition = new Vector3(info.barrelXPosition, info.barrelYPosition, 0f); float num = Mathf.InverseLerp(info.sliderMaximumPosition, info.sliderMinimumPosition, ((Component)sliderFrontImage).transform.localPosition.x); float num2 = Mathf.Lerp(0f, 7f, num); ((Component)barrelImage).transform.localRotation = Quaternion.Euler(0f, 0f, num2); ((Graphic)barrelImage).color = new Color(1f, 1f, 1f, windowAlpha); } } private void ClearStagedMagazine() { if (!((Object)null == (Object)(object)stagedMagazineItem) || !((Object)null == (Object)(object)stagedMagazineImage)) { stagedMagazineItem = null; if ((Object)null != (Object)(object)stagedMagazineImage) { Object.Destroy((Object)(object)((Component)stagedMagazinePivot).gameObject); } stagedMagazineImage = null; stagedMagazinePivot = null; shouldUpdateMagazineCount = true; } } public void DropMagazine(Item item, Image draggedImage) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: 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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ae: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) if (!info.p90reload) { gun.DragOnto(item); return; } if ((Object)null != (Object)(object)stagedMagazineItem || !string.IsNullOrEmpty(gun.CurrentMag())) { PlayerCamera.main.PlayUISound((UISoundType)6, 1f); return; } stagedMagazineItem = item; stagedMagazineImage = new GameObject("StagedMagazine").AddComponent<Image>(); ((Component)stagedMagazineImage).transform.SetParent(gunBase.transform, false); stagedMagazineImage.sprite = draggedImage.sprite; Rect rect; if (info.resizeMagazine) { RectTransform rectTransform = ((Graphic)stagedMagazineImage).rectTransform; rect = draggedImage.sprite.rect; float width = ((Rect)(ref rect)).width; rect = draggedImage.sprite.rect; rectTransform.sizeDelta = new Vector2(width, ((Rect)(ref rect)).height); ((Component)stagedMagazineImage).transform.localScale = new Vector3(0.00048828125f * (float)Screen.width, 0.00086805556f * (float)Screen.height); } else { ((Component)stagedMagazineImage).transform.localScale = new Vector3(0.000390625f * (float)Screen.width, 0.00069444446f * (float)Screen.height); } ((Component)stagedMagazineImage).transform.localRotation = Quaternion.Euler(0f, 0f, info.magazineRotation); rect = ((Graphic)stagedMagazineImage).rectTransform.rect; Vector3 val = Vector3.Scale(Vector2.op_Implicit(((Rect)(ref rect)).size), ((Component)stagedMagazineImage).transform.localScale) * 0.5f; Quaternion localRotation = ((Component)stagedMagazineImage).transform.localRotation; Vector3 val2 = localRotation * new Vector3(val.x, 0f); Vector3 val3 = localRotation * new Vector3(0f, val.y); Vector3 val4 = ((Mathf.Abs(val2.x) >= Mathf.Abs(val3.x)) ? val2 : val3); if (val4.x < 0f) { val4 = -val4; } stagedMagazinePivot = new GameObject("StagedMagazinePivot").transform; stagedMagazinePivot.SetParent(gunBase.transform, false); stagedMagazinePivot.localPosition = new Vector3(info.magazineXPosition, info.magazineYPosition) - val4; PlaceMagazineLayer(stagedMagazinePivot); ((Component)stagedMagazineImage).transform.SetParent(stagedMagazinePivot, false); ((Component)stagedMagazineImage).transform.localPosition = val4; stagedMagazineAngle = 12.5f; stagedMagazinePivot.localRotation = Quaternion.Euler(0f, 0f, stagedMagazineAngle); ((Component)stagedMagazineImage).gameObject.AddComponent<SlidingMagazine>(); shouldUpdateMagazineCount = true; } public void SlideStagedMagazine(float delta) { //IL_0069: Unknown result type (might be due to invalid IL or missing references) if ((Object)null == (Object)(object)stagedMagazineItem || (Object)null == (Object)(object)stagedMagazineImage) { ClearStagedMagazine(); return; } stagedMagazineAngle = Mathf.Clamp(stagedMagazineAngle + delta * 25f / ((float)Screen.height * 0.06f), 0f, 25f); stagedMagazinePivot.localRotation = Quaternion.Euler(0f, 0f, stagedMagazineAngle); if (!(stagedMagazineAngle > 0f)) { if (!gun.DragOnto(stagedMagazineItem)) { PlayerCamera.main.PlayUISound((UISoundType)6, 1f); } ClearStagedMagazine(); } } public static MinigameManager GetOrAddInstance() { if ((Object)null == (Object)(object)instance) { instance = ((Component)PlayerCamera.main).gameObject.AddComponent<MinigameManager>(); } return instance; } public void AddRecoil(float knockback, float muzzleRise) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) if (active) { if ((Object)null == (Object)(object)uiBase) { Debug.LogError((object)"[NewFirearms] Attempt to draw recoil before minigame initialization!"); return; } muzzleRise = Mathf.Abs(muzzleRise); BeginOutsidePumpAfterShot(); inertia.ImpulseAtMuzzle(new Vector2((0f - knockback) * 0.12f, muzzleRise * 0.055f)); AddFannyPackZipImpulse(muzzleRise * 10f); } } public void Hide() { EndSupportGrip(); EndMagazineDrag(); if (active) { ResetInertia(); } mosynInitialized = false; ClearStagedMagazine(); PlayerCamera.main.gunMenu.SetActive(false); ((Component)PlayerCamera.main.gunCrosshair).gameObject.SetActive(false); active = false; if ((Object)null != (Object)(object)uiBase) { uiBase.SetActive(false); } } public void Show(MinigameInfo newInfo, IMinigameGun newGun, ILaser newLaser = null) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_035c: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_037e: Unknown result type (might be due to invalid IL or missing references) //IL_038a: 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_0758: Unknown result type (might be due to invalid IL or missing references) //IL_07d4: Unknown result type (might be due to invalid IL or missing references) //IL_079d: Unknown result type (might be due to invalid IL or missing references) //IL_07bd: Unknown result type (might be due to invalid IL or missing references) //IL_086c: Unknown result type (might be due to invalid IL or missing references) //IL_09b1: Unknown result type (might be due to invalid IL or missing references) //IL_09d1: Unknown result type (might be due to invalid IL or missing references) //IL_09e6: Unknown result type (might be due to invalid IL or missing references) //IL_095c: Unknown result type (might be due to invalid IL or missing references) bool flag = !active || gun != newGun || info != newInfo; if (gun != newGun || info != newInfo) { EndSupportGrip(); EndMagazineDrag(); if (info != null && info.mosynStyleRack && !newInfo.mosynStyleRack && (Object)(object)sliderFrontImage != (Object)null) { Vector3 localPosition = ((Component)sliderFrontImage).transform.localPosition; localPosition.y = 0f; ((Component)sliderFrontImage).transform.localPosition = localPosition; ((Component)sliderBackImage).transform.localPosition = localPosition; } mosynInitialized = false; ClearStagedMagazine(); magSyncIgnoreTime = 0f; insertedMagazineType = null; if ((Object)(object)insertedMagazine != (Object)null) { Object.Destroy((Object)(object)((Component)insertedMagazine).gameObject); } insertedMagazine = null; shouldUpdateMagazineCount = true; shouldntRefreshBandolierCount = false; } if ((Object)null == (Object)(object)uiBase) { PrepareGunUi(); } UpdateWindowHandedness(); PlayerCamera.main.gunMenu.SetActive(false); info = newInfo; if (!info.HasBandolier) { HideBandolier(); } if (!info.initialized) { if (!info.rackByRotation || info.mosynStyleRack) { info.sliderMaximumPosition *= Screen.width; info.sliderMinimumPosition *= Screen.width; info.unrackedIdlePosition *= Screen.width; info.rackedIdlePosition *= Screen.width; info.unrackedToRacked *= Screen.width; info.rackedToUnracked *= Screen.width; } else { info.rackRotationCenterXPosition *= Screen.width; info.rackRotationCenterYPosition *= Screen.height; } info.magazineXPosition *= Screen.width; info.magazineYPosition *= Screen.height; info.magazineXSpeed *= Screen.width; info.magazineYSpeed *= Screen.height; info.casingXPosition *= Screen.width; info.casingYPosition *= Screen.height; info.initialized = true; info.coverXPosition *= Screen.width; info.coverYPosition *= Screen.height; info.barrelXPosition *= Screen.width; info.barrelYPosition *= Screen.height; } if (info.fitMainSprite) { mainImageRect.sizeDelta = Vector2.op_Implicit(fitSize); } else { mainImageRect.sizeDelta = Vector2.op_Implicit(size); } ((Component)laserImage).GetComponent<RectTransform>().sizeDelta = Vector2.op_Implicit(info.fitLaserImage ? fitSize : size); UpdateMainSprite(); if (!info.sliderRightClickFireToggle || info.fireModeSprites == null) { sliderFrontImage.sprite = info.sliderFrontSprite; } ((Behaviour)sliderFrontImage).enabled = (Object)(object)sliderFrontImage.sprite != (Object)null; ((Behaviour)chamberedRoundImage).enabled = false; ((Graphic)sliderFrontImage).color = new Color(1f, 1f, 1f, info.frontSliderInvisble ? 0f : windowAlpha); sliderBackImage.sprite = info.sliderBackSprite; ((Behaviour)sliderBackImage).enabled = (Object)(object)info.sliderBackSprite != (Object)null; backLayerImage.sprite = info.backLayerSprite; ((Behaviour)backLayerImage).enabled = (Object)(object)info.backLayerSprite != (Object)null; magazineBackLayerImage.sprite = info.magazineBackLayerSprite; ((Behaviour)magazineBackLayerImage).enabled = (Object)(object)info.magazineBackLayerSprite != (Object)null; if ((Object)(object)insertedMagazine != (Object)null) { PlaceMagazineLayer(((Component)insertedMagazine).transform); } if ((Object)(object)stagedMagazinePivot != (Object)null) { PlaceMagazineLayer(stagedMagazinePivot); } barrelImage.sprite = info.barrelSprite; ((Behaviour)barrelImage).enabled = (Object)(object)info.barrelSprite != (Object)null && (!info.rackByRotation || info.mosynStyleRack); receiverTrigger.sprite = info.receiverTrigger; grabTriggerImage.sprite = info.grabTriggerSprite; ((Component)grabTriggerImage).gameObject.SetActive(!info.grabOnSlider && info.HasSupportGrip); magReleaseTrigger.sprite = info.magReleaseTrigger; ((Component)magReleaseTrigger).gameObject.SetActive((Object)(object)info.magReleaseTrigger != (Object)null); rackTrigger.sprite = info.rackTrigger; ((Component)rackTrigger).gameObject.SetActive((Object)(object)info.rackTrigger != (Object)null); magazineDragTrigger.sprite = info.magazineDragTrigger; laserToggleTrigger.sprite = info.laserToggleTrigger; flashlightToggleTrigger.sprite = info.flashlightToggleTrigger; ((Component)flashlightToggleTrigger).gameObject.SetActive((Object)(object)info.flashlightToggleTrigger != (Object)null && newGun is IMinigameFlashlight minigameFlashlight && minigameFlashlight.HasFlashlight()); laserImage.sprite = info.laserImage; fireToggleTrigger.sprite = info.fireToggleTrigger; ((Component)fireToggleTrigger).gameObject.SetActive((Object)null != (Object)(object)info.fireToggleTrigger); if (info.coverAnimation == null) { ((Behaviour)coverImage).enabled = false; } else if (newGun != gun) { ((Behaviour)coverImage).enabled = true; coverImage.sprite = info.coverAnimation[0]; coverIndex = 0; coverTimer = 0f; coverChange = 0; ((Component)coverImage).transform.localPosition = new Vector3(info.coverXPosition, info.coverYPosition); } if (info.rackByRotation && !info.mosynStyleRack) { ((Component)sliderFrontImage).transform.localPosition = new Vector3(info.rackRotationCenterXPosition, info.rackRotationCenterYPosition); ((Component)sliderBackImage).transform.localPosition = ((Component)sliderFrontImage).transform.localPosition; } else { ((Component)sliderBackImage).transform.localRotation = Quaternion.identity; } ((Behaviour)((Component)sliderFrontImage).gameObject.GetComponent<RotatingSlider>()).enabled = info.rackByRotation && !info.mosynStyleRack; ammoIcon.sprite = info.ammosIcons[info.dCurrentAmmo]; EnsureAmmoIcons(info.ammos.Length); ((Component)ammoSelectCursor).transform.localPosition = ((Component)ammoSelectAmmo[info.dCurrentAmmo]).transform.localPosition; for (int i = 0; i < ammoSelectAmmo.Count; i++) { if (i < info.ammosIcons.Length) { ammoSelectAmmo[i].sprite = info.ammosIcons[i]; ((Behaviour)ammoSelectAmmo[i]).enabled = true; } else { ((Behaviour)ammoSelectAmmo[i]).enabled = false; } } active = true; gun = newGun; if (flag) { ResetInertia(); } if (info.mosynStyleRack) { EnsureMosynRack(); } else if (flag) { if (info.rackByRotation) { ((Component)sliderFrontImage).transform.localRotation = Quaternion.Euler(0f, 0f, gun.IsRacked() ? info.rackedIdlePosition : info.unrackedIdlePosition); } else { sliderLastXPos = (gun.IsRacked() ? info.rackedIdlePosition : info.unrackedIdlePosition); ((Component)sliderFrontImage).transform.localPosition = new Vector3(sliderLastXPos, 0f, 0f); ((Component)sliderBackImage).transform.localPosition = ((Component)sliderFrontImage).transform.localPosition; ((Component)sliderFrontImage).transform.localRotation = Quaternion.identity; } } laser = newLaser; UpdateSliderFireToggle(gun.IsRacked()); UpdateBackLayerTransform(); UpdateBarrelTransform(); ((Behaviour)laserToggleTrigger).enabled = laser != null; ((Selectable)((Component)laserToggleTrigger).GetComponent<Button>()).interactable = laser != null; uiBase.SetActive(!IsCutsceneOrEnding()); } private void PrepareGunUi() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_0091: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: 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_015e: Expected O, but got Unknown //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Expected O, but got Unknown //IL_0242: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02e1: Unknown result type (might be due to invalid IL or missing references) //IL_02eb: Expected O, but got Unknown //IL_0311: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03e3: Unknown result type (might be due to invalid IL or missing references) //IL_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_0419: Unknown result type (might be due to invalid IL or missing references) //IL_044f: Unknown result type (might be due to invalid IL or missing references) //IL_0454: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04fe: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) //IL_0548: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Unknown result type (might be due to invalid IL or missing references) //IL_0562: Unknown result type (might be due to invalid IL or missing references) //IL_058a: Unknown result type (might be due to invalid IL or missing references) //IL_05cb: Unknown result type (might be due to invalid IL or missing references) //IL_05e0: Unknown result type (might be due to invalid IL or missing references) //IL_0601: Unknown result type (might be due to invalid IL or missing references) //IL_0637: Unknown result type (might be due to invalid IL or missing references) //IL_063c: Unknown result type (might be due to invalid IL or missing references) //IL_0664: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Unknown result type (might be due to invalid IL or missing references) //IL_06ba: Unknown result type (might be due to invalid IL or missing references) //IL_06cf: Unknown result type (might be due to invalid IL or missing references) //IL_06d4: Unknown result type (might be due to invalid IL or missing references) //IL_06f5: Unknown result type (might be due to invalid IL or missing references) //IL_0736: Unknown result type (might be due to invalid IL or missing references) //IL_0755: Unknown result type (might be due to invalid IL or missing references) //IL_076a: Unknown result type (might be due to invalid IL or missing references) //IL_076f: Unknown result type (might be due to invalid IL or missing references) //IL_077f: Unknown result type (might be due to invalid IL or missing references) //IL_07b4: Unknown result type (might be due to invalid IL or missing references) //IL_07c9: Unknown result type (might be due to invalid IL or missing references) //IL_07ee: Unknown result type (might be due to invalid IL or missing references) //IL_07f3: Unknown result type (might be due to invalid IL or missing references) //IL_0834: Unknown result type (might be due to invalid IL or missing references) //IL_0839: Unknown result type (might be due to invalid IL or missing references) //IL_083b: Unknown result type (might be due to invalid IL or missing references) //IL_0841: Expected O, but got Unknown //IL_0869: Unknown result type (might be due to invalid IL or missing references) //IL_089e: Unknown result type (might be due to invalid IL or missing references) //IL_08b3: Unknown result type (might be due to invalid IL or missing references) //IL_08c8: Unknown result type (might be due to invalid IL or missing references) //IL_08cd: Unknown result type (might be due to invalid IL or missing references) //IL_08f5: Unknown result type (might be due to invalid IL or missing references) //IL_092a: Unknown result type (might be due to invalid IL or missing references) //IL_093f: Unknown result type (might be due to invalid IL or missing references) //IL_0964: Unknown result type (might be due to invalid IL or missing references) //IL_0969: Unknown result type (might be due to invalid IL or missing references) //IL_09a0: Unknown result type (might be due to invalid IL or missing references) //IL_09aa: Expected O, but got Unknown //IL_09c4: Unknown result type (might be due to invalid IL or missing references) //IL_09d4: Unknown result type (might be due to invalid IL or missing references) //IL_0a09: Unknown result type (might be due to invalid IL or missing references) //IL_0a1e: Unknown result type (might be due to invalid IL or missing references) //IL_0a43: Unknown result type (might be due to invalid IL or missing references) //IL_0a48: Unknown result type (might be due to invalid IL or missing references) //IL_0a7f: Unknown result type (might be due to invalid IL or missing references) //IL_0a89: Expected O, but got Unknown //IL_0aa3: Unknown result type (might be due to invalid IL or missing references) //IL_0ac4: Unknown result type (might be due to invalid IL or missing references) //IL_0af9: Unknown result type (might be due to invalid IL or missing references) //IL_0b0e: Unknown result type (might be due to invalid IL or missing references) //IL_0b33: Unknown result type (might be due to invalid IL or missing references) //IL_0b38: Unknown result type (might be due to invalid IL or missing references) //IL_0b6d: Unknown result type (might be due to invalid IL or missing references) //IL_0b93: Unknown result type (might be due to invalid IL or missing references) //IL_0b9d: Expected O, but got Unknown //IL_0ba3: Unknown result type (might be due to invalid IL or missing references) //IL_0bd8: Unknown result type (might be due to invalid IL or missing references) //IL_0bed: Unknown result type (might be due to invalid IL or missing references) //IL_0c12: Unknown result type (might be due to invalid IL or missing references) //IL_0c17: Unknown result type (might be due to invalid IL or missing references) //IL_0c4c: Unknown result type (might be due to invalid IL or missing references) //IL_0c72: Unknown result type (might be due to invalid IL or missing references) //IL_0c7c: Expected O, but got Unknown //IL_0c93: Unknown result type (might be due to invalid IL or missing references) //IL_0cc8: Unknown result type (might be due to invalid IL or missing references) //IL_0cdd: Unknown result type (might be due to invalid IL or missing references) //IL_0d02: Unknown result type (might be due to invalid IL or missing references) //IL_0d07: Unknown result type (might be due to invalid IL or missing references) //IL_0d3c: Unknown result type (might be due to invalid IL or missing references) //IL_0d62: Unknown result type (might be due to invalid IL or missing references) //IL_0d6c: Expected O, but got Unknown //IL_0d72: Unknown result type (might be due to invalid IL or missing references) //IL_0da7: Unknown result type (might be due to invalid IL or missing references) //IL_0dbc: Unknown result type (might be due to invalid IL or missing references) //IL_0de1: Unknown result type (might be due to invalid IL or missing references) //IL_0de6: Unknown result type (might be due to invalid IL or missing references) //IL_0e11: Unknown result type (might be due to invalid IL or missing references) //IL_0e16: Unknown result type (might be due to invalid IL or missing references) //IL_0e18: Unknown result type (might be due to invalid IL or missing references) //IL_0e1e: Expected O, but got Unknown //IL_0e5a: Unknown result type (might be due to invalid IL or missing references) //IL_0e7b: Unknown result type (might be due to invalid IL or missing references) //IL_0eb0: Unknown result type (might be due to invalid IL or missing references) //IL_0ec5: Unknown result type (might be due to invalid IL or missing references) //IL_0eea: Unknown result type (might be due to invalid IL or missing references) //IL_0eef: Unknown result type (might be due to invalid IL or missing references) //IL_0f24: Unknown result type (might be due to invalid IL or missing references) //IL_0f56: Unknown result type (might be due to invalid IL or missing references) //IL_0f60: Expected O, but got Unknown //IL_0f86: Unknown result type (might be due to invalid IL or missing references) //IL_0f9b: Unknown result type (might be due to invalid IL or missing references) //IL_0fab: Unknown result type (might be due to invalid IL or missing references) //IL_0fe0: Unknown result type (might be due to invalid IL or missing references) //IL_0ff5: Unknown result type (might be due to invalid IL or missing references) //IL_100a: Unknown result type (might be due to invalid IL or missing references) //IL_100f: Unknown result type (might be due to invalid IL or missing references) //IL_104c: Unknown result type (might be due to invalid IL or missing references) //IL_1081: Unknown result type (might be due to invalid IL or missing references) //IL_1096: Unknown result type (might be due to invalid IL or missing references) //IL_10ab: Unknown result type (might be due to invalid IL or missing references) //IL_10b0: Unknown result type (might be due to invalid IL or missing references) //IL_10fd: Unknown result type (might be due to invalid IL or missing references) //IL_114a: Unknown result type (might be due to invalid IL or missing references) //IL_115f: Unknown result type (might be due to invalid IL or missing references) //IL_11a8: Unknown result type (might be due to invalid IL or missing references) //IL_11ad: Unknown result type (might be due to invalid IL or missing references) //IL_11bd: Unknown result type (might be due to invalid IL or missing references) //IL_11f2: Unknown result type (might be due to invalid IL or missing references) //IL_1207: Unknown result type (might be due to invalid IL or missing references) //IL_122c: Unknown result type (might be due to invalid IL or missing references) //IL_1231: Unknown result type (might be due to invalid IL or missing references) //IL_126c: Unknown result type (might be due to invalid IL or missing references) //IL_1271: Unknown result type (might be due to invalid IL or missing references) //IL_1273: Unknown result type (might be due to invalid IL or missing references) //IL_1279: Expected O, but got Unknown //IL_1279: Unknown result type (might be due to invalid IL or missing references) //IL_127e: Unknown result type (might be due to invalid IL or missing references) //IL_1280: Unknown result type (might be due to invalid IL or missing references) //IL_1286: Expected O, but got Unknown //IL_1286: Unknown result type (might be due to invalid IL or missing references) //IL_128b: Unknown result type (might be due to invalid IL or missing references) //IL_128d: Unknown result type (might be due to invalid IL or missing references) //IL_1294: Expected O, but got Unknown //IL_1304: Unknown result type (might be due to invalid IL or missing references) //IL_132f: Unknown result type (might be due to invalid IL or missing references) //IL_133f: Unknown result type (might be due to invalid IL or missing references) //IL_1363: Unknown result type (might be due to invalid IL or missing references) //IL_13b1: Unknown result type (might be due to invalid IL or missing references) //IL_13df: Unknown result type (might be due to invalid IL or missing references) //IL_1406: Unknown result type (might be due to invalid IL or missing references) //IL_1438: Unknown result type (might be due to invalid IL or missing references) //IL_146d: Unknown result type (might be due to invalid IL or missing references) //IL_1482: Unknown result type (might be due to invalid IL or missing references) //IL_14a7: Unknown result type (might be due to invalid IL or missing references) //IL_14ac: Unknown result type (might be due to invalid IL or missing references) //IL_14c8: Unknown result type (might be due to invalid IL or missing references) //IL_1515: Unknown result type (might be due to invalid IL or missing references) //IL_1542: Unknown result type (might be due to invalid IL or missing references) //IL_1597: Unknown result type (might be due to invalid IL or missing references) //IL_15d6: Unknown result type (might be due to invalid IL or missing references) //IL_15eb: Unknown result type (might be due to invalid IL or missing references) //IL_1613: Unknown result type (might be due to invalid IL or missing references) //IL_1665: Unknown result type (might be due to invalid IL or missing references) //IL_1697: Unknown result type (might be due to invalid IL or missing references) //IL_16d4: Unknown result type (might be due to invalid IL or missing references) //IL_1713: Unknown result type (might be due to invalid IL or missing references) //IL_1737: Unknown result type (might be due to invalid IL or missing references) //IL_1767: Unknown result type (might be due to invalid IL or missing references) //IL_17b2: Unknown result type (might be due to invalid IL or missing references) //IL_17d7: Unknown result type (might be due to invalid IL or missing references) //IL_1803: Unknown result type (might be due to invalid IL or missing references) //IL_1808: Unknown result type (might be due to invalid IL or missing references) //IL_180d: Unknown result type (might be due to invalid IL or missing references) //IL_1855: Unknown result type (might be due to invalid IL or missing references) if ((Object)null == (Object)(object)backgroundSprite) { PrepareResources(); } if ((Object)null == (Object)(object)canvas) { canvas = ((Component)PlayerCamera.main.gunMenu.GetComponentInParent<Canvas>(true).rootCanvas).gameObject; } uiBase = new GameObject("GunMinigame"); uiBase.AddComponent<MinigameMenuInputFilter>(); uiBase.transform.SetParent(canvas.transform); uiBase.transform.localPosition = new Vector3(0f, -415f, 0f); hideShowButton = new GameObject("MinigameHideShowButton").AddComponent<Image>(); ((Component)hideShowButton).transform.SetParent(uiBase.transform); ((Component)hideShowButton).transform.localPosition = new Vector3(0f, 0.12986112f * (float)Screen.height, 0f); hideShowButton.sprite = hideSprite; ((Component)hideShowButton).GetComponent<RectTransform>().sizeDelta = Vector2.op_Implicit(new Vector3(0.05859375f * (float)Screen.width, 0.029513888f * (float)Screen.height)); ((UnityEvent)((Component)hideShowButton).gameObject.AddComponent<Button>().onClick).AddListener((UnityAction)delegate { HideShow(); }); ((Component)hideShowButton).gameObject.AddComponent<ImageHoverror>(); size = new Vector3(0.26171875f * (float)Screen.width, 0.2326389f * (float)Screen.height); fitSize = new Vector3((float)Screen.width, size.y); windowClip = new GameObject("MinigameWindowClip", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)windowClip).SetParent(uiBase.transform, false); windowClip.sizeDelta = Vector2.op_Implicit(size); ((Component)windowClip).gameObject.AddComponent<RectMask2D>(); maskBase = new GameObject("MaskBase"); maskBase.transform.SetParent((Transform)(object)windowClip, false); maskBase.transform.localPosition = Vector3.zero; maskBase.transform.localScale = Vector3.one; uiImage = maskBase.AddComponent<Image>(); uiImage.sprite = backgroundSprite; ((Component)uiImage).GetComponent<RectTransform>().sizeDelta = Vector2.op_Implicit(size); maskBase.AddComponent<ImageHoverror>(); maskBase.AddComponent<MinigameVisualization>().Initialize(this); maskBase.AddComponent<MinigameCoordinates>().Initialize(this); maskBase.AddComponent<MinigameJamVisual>().Initialize(this); gunBase = new GameObject("GunBase"); gunBase.transform.SetParent(maskBase.transform); gunBase.transform.localPosition = Vector3.zero; gunBase.transform.localScale = Vector3.one; backLayerImage = new GameObject("MinigameBackLayer").AddComponent<Image>(); ((Graphic)backLayerImage).raycastTarget = false; ((Component)backLayerImage).transform.SetParent(gunBase.transform, false); ((Graphic)backLayerImage).rectTransform.sizeDelta = Vector2.op_Implicit(size); sliderBackImage = new GameObject("MinigameSliderBack").AddComponent<Image>(); ((Graphic)sliderBackImage).raycastTarget = false; ((Component)sliderBackImage).transform.SetParent(gunBase.transform); ((Component)sliderBackImage).transform.localPosition = Vector3.zero; ((Component)sliderBackImage).transform.localScale = Vector3.one; ((Component)sliderBackImage).GetComponent<RectTransform>().sizeDelta = Vector2.op_Implicit(size); ((Behaviour)sliderBackImage).enabled = false; magazineBackLayerImage = new GameObject("MinigameMagazineBackLayer").AddComponent<Image>(); ((Component)magazineBackLayerImage).transform.SetParent(gunBase.transform, false); ((Graphic)magazineBackLayerImage).rectTransform.sizeDelta = Vector2.op_Implicit(size); ((Graphic)magazineBackLayerImage).raycastTarget = false; ((Behaviour)magazineBackLayerImage).enabled = false; chamberedRoundImage = new GameObject("MinigameChamberedRound").AddComponent<Image>(); ((Component)chamberedRoundImage).transform.SetParent(gunBase.transform, false); ((Component)chamberedRoundImage).transform.localScale = new Vector3(0.003515625f * (float)Screen.width, 1f / 160f * (float)Screen.height); chamberedRoundImage.preserveAspect = true; ((Graphic)chamberedRoundImage).raycastTarget = false; ((Behaviour)chamberedRoundImage).enabled = false; rackedSpecific = new GameObject("MinigameRackedSpecific").AddComponent<Image>(); ((Component)rackedSpecific).transform.SetParent(gunBase.transform); ((Component)rackedSpecific).transform.localPosition = Vector3.zero; ((Component)rackedSpecific).transform.localScale = Vector3.one; ((Component)rackedSpecific).GetComponent<RectTransform>().sizeDelta = Vector2.op_Implicit(size); ((Graphic)rackedSpecific).raycastTarget = false; ((Behaviour)rackedSpecific).enabled = false; mainImage = new GameObject("MinigameMainSprite").AddComponent<Image>(); ((Graphic)mainImage).raycastTarget = false; ((Component)mainImage).transform.SetParent(gunBase.transform); ((Component)mainImage).transform.localPosition = Vector3.zero; ((Component)mainImage).transform.localScale = Vector3.one; mainImageRect = ((Component)mainImage).GetComponent<RectTransform>(); barrelImage = new GameObject("MinigameBarrel").AddComponent<Image>(); ((Component)barrelImage).transform.SetParent(gunBase.transform, false); ((Graphic)barrelImage).rectTransform.sizeDelta = Vector2.op_Implicit(size); ((Graphic)barrelImage).raycastTarget = false; ((Behaviour)barrelImage).enabled = false; laserImage = new GameObject("MinigameLaserImage").AddComponent<Image>(); ((Graphic)laserImage).raycastTarget = false; ((Component)laserImage).transform.SetParent(gunBase.transform); ((Component)laserImage).transform.localPosition = Vector3.zero; ((Component)laserImage).transform.localScale = Vector3.one; ((Component)laserImage).GetComponent<RectTransform>().sizeDelta = Vector2.op_Implicit(fitSize); ((Component)laserImage).gameObject.SetActive(false); coverImage = new GameObject("CoverImage").AddComponent<Image>(); ((Graphic)coverImage).raycastTarget = false; ((Component)coverImage).transform.SetParent(gunBase.transform); ((Component)coverImage).transform.localPosition = Vector3.zero; ((Component)coverImage).transform.localScale = new Vector3(0.15f, 0.15f); ((Component)coverImage).GetComponent<RectTransform>().sizeDelta = Vector2.op_Implicit(size); sliderFrontImage = new GameObject("MinigameSliderFront").AddComponent<Image>(); ((Component)sliderFrontImage).transform.SetParent(gunBase.transform); ((Component)sliderFrontImage).transform.localPosition = Vector3.zero; ((Component)sliderFrontImage).transform.localScale = Vector3.one; sliderFrontImage.alphaHitTestMinimumThreshold = 0.1f; ((Component)sliderFrontImage).GetComponent<RectTransform>().sizeDelta = Vector2.op_Implicit(size); ((Component)sliderFrontImage).gameObject.AddComponent<AlphaRaycastFilter>(); ((Behaviour)((Component)sliderFrontImage).gameObject.AddComponent<RotatingSlider>()).enabled = false; EventTrigger obj = ((Component)sliderFrontImage).gameObject.AddComponent<EventTrigger>(); Entry val = new Entry { eventID = (EventTriggerType)2 }; ((UnityEvent<BaseEventData>)(object)val.callback).AddListener((UnityAction<BaseEventData>)delegate(BaseEventData data) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Invalid comparison between Unknown and I4 //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) PointerEventData val7 = (PointerEventData)data; if ((int)val7.button == 0) { SliderClickDown(val7.position); } else if ((int)val7.button == 1) { SliderRightClick(val7.position); } }); obj.triggers.Add(val); fireModeImage = new GameObject("MinigameFireModeImage").AddComponent<Image>(); ((Component)fireModeImage).transform.SetParent(gunBase.transform); ((Component)fireModeImage).transform.localPosition = Vector3.zero; ((Component)fireModeImage).transform.localScale = Vector3.one; ((Component)fireModeImage).GetComponent<RectTransform>().sizeDelta = Vector2.op_Implicit(size); ((Graphic)fireModeImage).raycastTarget = false; ((Behaviour)fireModeImage).enabled = false; magReleaseTrigger = new GameObject("MinigameMagRelease").AddComponent<Image>(); ((Component)magReleaseTrigger).transform.SetParent(gunBase.transform); ((Component)magReleaseTrigger).transform.localPosition = Vector3.zero; ((Component)magReleaseTrigger).transform.localScale = Vector3.one; magReleaseTrigger.alphaHitTestMinimumThreshold = 0.1f; ((Component)magReleaseTrigger).GetComponent<RectTransform>().sizeDelta = Vector2.op_Implicit(size); ((Component)magReleaseTrigger).gameObject.AddComponent<AlphaRaycastFilter>(); ((UnityEvent)((Component)magReleaseTrigger).gameObject.AddComponent<Button>().onClick).AddListener((UnityAction)delegate { MagRemoveButton(); }); ((Graphic)magReleaseTrigger).color = new Color(1f, 1f, 1f, 0f); rackTrigger = new GameObject("MinigameRackTrigger").AddComponent<Image>(); ((Component)rackTrigger).transform.SetParent(gunBase.transform); ((Component)rackTrigger).transform.localPosition = Vector3.zero; ((Component)rackTrigger).transform.localScale = Vector3.one; rackTrigger.alphaHitTestMinimumThreshold = 0.1f; ((Component)rackTrigger).GetComponent<RectTransform>().sizeDelta = Vector2.op_Implicit(size); ((Component)rackTrigger).gameObject.AddComponent<AlphaRaycastFilter>(); ((UnityEvent)((Component)rackTrigger).gameObject.AddComponent<Button>().onClick).AddListener((UnityAction)delegate { if (active && !hiden && !automatedHandAction && !IsAnyGameUIOpen() && PlayerCamera.main.body.conscious && (!info.onlyUnrackedToRacked || !gun.IsRacked()) && !IsSliderOpeningBlocked) { gun.Rack(); EventSystem.current.SetSelectedGameObject((GameObject)null); } }); ((Graphic)rackTrigger).color = new Color(1f, 1f, 1f, 0f); ((Component)rackTrigger).gameObject.SetActive(false); laserToggleTrigger = new GameObject("LaserToggleTrigger").AddComponent<Image>(); ((Component)laserToggleTrigger).transform.SetParent(gunBase.transform); ((Component)laserToggleTrigger).transform.localPosition = Vector3.zero; ((Component)laserToggleTrigger).transform.localScale = Vector3.one; laserToggleTrigger.alphaHitTestMinimumThreshold = 0.1f; ((Component)laserToggleTrigger).GetComponent<RectTransform>().sizeDelta = Vector2.op_Implicit(size); ((Component)laserToggleTrigger).gameObject.AddComponent<AlphaRaycastFilter>(); ((Graphic)laserToggleTrigger).color = new Color(1f, 1f, 1f, 0f); ((UnityEvent)((Component)laserToggleTrigger).gameObject.AddComponent<Button>().onClick).AddListener((UnityAction)delegate { if (laser != null) { laser.Toggle(); PlayerCamera.main.PlayUISound((UISoundType)0, 1f); EventSystem.current.SetSelectedGameObject((GameObject)null); } }); flashlightToggleTrigger = new GameObject("FlashlightToggleTrigger").AddComponent<Image>(); ((Component)flashlightToggleTrigger).transform.SetParent(gunBase.transform); ((Component)flashlightToggleTrigger).transform.localPosition = Vector3.zero; ((Component)flashlightToggleTrigger).transform.localScale = Vector3.one; flashlightToggleTrigger.alphaHitTestMinimumThreshold = 0.1f; ((Component)flashlightToggleTrigger).GetComponent<RectTransform>().sizeDelta = Vector2.op_Implicit(size); ((Component)flashlightToggleTrigger).gameObject.AddComponent<AlphaRaycastFilter>(); ((Graphic)flashlightToggleTrigger).color = new Color(1f, 1f, 1f, 0f); ((UnityEvent)((Component)flashlightToggleTrigger).gameObject.AddComponent<Button>().onClick).AddListener((UnityAction)delegate { if (active && !hiden && !automatedHandAction && !IsAnyGameUIOpen() && PlayerCamera.main.body.conscious) { (gun as IMinigameFlashlight)?.ToggleFlashlight(); EventSystem.current.SetSelectedGameObject((GameObject)null); } }); ((Component)flashlightToggleTrigger).gameObject.SetActive(false); fireToggleTrigger = new GameObject("FireToggleTrigger").AddComponent<Image>(); ((Component)fireToggleTrigger).transform.SetParent(gunBase.transform); ((Component)fireToggleTrigger).transform.localPosition = Vector3.zero; ((Component)fireToggleTrigger).transform.localScale = Vector3.one; fireToggleTrigger.alphaHitTestMinimumThreshold = 0.1f; ((Component)fireToggleTrigger).GetComponent<RectTransform>().sizeDelta = Vector2.op_Implicit(size); ((Component)fireToggleTrigger).gameObject.AddComponent<AlphaRaycastFilter>(); ((Graphic)fireToggleTrigger).color = new Color(1f, 1f, 1f, 0f); ((UnityEvent)((Component)fireToggleTrigger).gameObject.AddComponent<Button>().onClick).AddListener((UnityAction)delegate { TryToggleFireMode(); }); receiverTrigger = new GameObject("MinigameReceiverTrigger").AddComponent<Image>(); ((Component)receiverTrigger).transform.SetParent(gunBase.transform); ((Component)receiverTrigger).transform.localPosition = Vector3.zero; ((Component)receiverTrigger).transform.localScale = Vector3.one; receiverTrigger.alphaHitTestMinimumThreshold = 0.1f; ((Component)receiverTrigger).GetComponent<RectTransform>().sizeDelta = Vector2.op_Implicit(size); ((Component)receiverTrigger).gameObject.AddComponent<AlphaRaycastFilter>(); EventTrigger obj2 = ((Component)receiverTrigger).gameObject.AddComponent<EventTrigger>(); Entry val2 = new Entry { eventID = (EventTriggerType)6 }; ((UnityEvent<BaseEventData>)(object)val2.callback).AddListener((UnityAction<BaseEventData>)delegate { ReceiverDrop(); }); obj2.triggers.Add(val2); ((Graphic)receiverTrigger).color = new Color(1f, 1f, 1f, 0f); ((Component)receiverTrigger).gameObject.SetActive(false); magazineDragTrigger = new GameObject("MinigameMagazineDragTrigger").AddComponent<Image>(); ((Component)magazineDragTrigger).transform.SetParent(gunBase.transform); ((Component)magazineDragTrigger).transform.localPosition = Vector3.zero; ((Component)magazineDragTrigger).transform.localScale = Vector3.one; magazineDragTrigger.alphaHitTestMinimumThreshold = 0.1f; ((Component)magazineDragTrigger).GetComponent<RectTransform>().sizeDelta = Vector2.op_Implicit(size); ((Component)magazineDragTrigger).gameObject.AddComponent<AlphaRaycastFilter>(); ((Graphic)magazineDragTrigger).color = new Color(1f, 1f, 1f, 0f); ((Component)magazineDragTrigger).gameObject.AddComponent<MagazineDragTrigger>(); ((Component)magazineDragTrigger).gameObject.S
NewFirearms.dll
Decompiled 7 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.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Threading.Tasks; using BepInEx; using BepInEx.Bootstrap; using CUCoreLib.Data; using CUCoreLib.Helpers; using CUCoreLib.Registries; using CasualtiesTogetherUtils; using GunMinigame; using HarmonyLib; using LiteNetLib; using LiteNetLib.Utils; using Newtonsoft.Json; using Newtonsoft.Json.Converters; using Newtonsoft.Json.Linq; using Together; using UnityEngine; using UnityEngine.Events; using UnityEngine.Networking; using UnityEngine.Rendering.Universal; using UnityEngine.SceneManagement; using UnityEngine.Tilemaps; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("CasualtiesMP")] [assembly: IgnoresAccessChecksTo("CUCoreLib")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NewFirearms")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("2.0.2.0")] [assembly: AssemblyInformationalVersion("2.0.2+2d0add431a2c96a088c52dd44c20c7b71c73e29e")] [assembly: AssemblyProduct("NewFirearms")] [assembly: AssemblyTitle("NewFirearms")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.0.2.0")] [module: UnverifiableCode] namespace NewFirearms { public static class AudioLoader { private static readonly Dictionary<string, AudioType> audioTypes = new Dictionary<string, AudioType>(StringComparer.OrdinalIgnoreCase) { [".aif"] = (AudioType)2, [".aiff"] = (AudioType)2, [".it"] = (AudioType)10, [".mod"] = (AudioType)12, [".mp3"] = (AudioType)13, [".ogg"] = (AudioType)14, [".s3m"] = (AudioType)17, [".wav"] = (AudioType)20, [".xm"] = (AudioType)21 }; private static readonly string[] extensionlessAudioExtensions = new string[9] { ".wav", ".ogg", ".mp3", ".aiff", ".aif", ".mod", ".it", ".s3m", ".xm" }; public static void LoadAudio(string folder, string relativePath, Action<AudioClip> setClip, AudioClip fallback) { LoadAudio(folder, relativePath, setClip, fallback, "audio"); } public static void LoadAudio(string folder, string relativePath, Action<AudioClip> setClip, AudioClip fallback, string fieldName) { setClip(fallback); if (!string.IsNullOrWhiteSpace(relativePath)) { string text = Path.Combine(folder, relativePath); string text2 = ResolveAudioPath(text); if (text2 == null) { Debug.LogError((object)("[NewFirearms] " + fieldName + ": Audio file '" + text + "' doesn't exist or has an unsupported extension.")); } else { LoadAudioAsync(text2, setClip, fieldName); } } } private static string ResolveAudioPath(string path) { string extension = Path.GetExtension(path); if (!string.IsNullOrEmpty(extension)) { if (!audioTypes.ContainsKey(extension) || !File.Exists(path)) { return null; } return path; } string[] array = extensionlessAudioExtensions; foreach (string text in array) { string text2 = path + text; if (File.Exists(text2)) { return text2; } } return null; } private static async void LoadAudioAsync(string path, Action<AudioClip> setClip, string fieldName) { try { string extension = Path.GetExtension(path); AudioType val = audioTypes[extension]; string absoluteUri = new Uri(Path.GetFullPath(path)).AbsoluteUri; UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(absoluteUri, val); try { UnityWebRequestAsyncOperation obj = request.SendWebRequest(); TaskCompletionSource<bool> completion = new TaskCompletionSource<bool>(); ((AsyncOperation)obj).completed += delegate { completion.TrySetResult(result: true); }; await completion.Task; if ((int)request.result != 1) { Debug.LogError((object)("[NewFirearms] " + fieldName + ": Failed to load audio '" + path + "': " + request.error)); return; } AudioClip content = DownloadHandlerAudioClip.GetContent(request); if ((Object)null == (Object)(object)content) { Debug.LogError((object)("[NewFirearms] " + fieldName + ": Audio file '" + path + "' returned no clip.")); return; } setClip(content); } finally { ((IDisposable)request)?.Dispose(); } } catch (Exception arg) { Debug.LogError((object)$"[NewFirearms] {fieldName}: Exception loading audio '{path}': {arg}"); } } } [HarmonyPatch(typeof(PantSound), "Bark")] internal static class BarkReloadPatch { private sealed class LoadCooldown { internal float Until; } private static readonly ConditionalWeakTable<Body, LoadCooldown> cooldowns = new ConditionalWeakTable<Body, LoadCooldown>(); private static void Prefix(PantSound __instance, out Body __state) { Body component = ((Component)__instance).GetComponent<Body>(); __state = (((Object)(object)component != (Object)null && component.conscious && !(component.eatTime > 0f)) ? component : null); } private static void Postfix(Body __state, bool __runOriginal) { if (__runOriginal && (Object)(object)__state != (Object)null && __state.eatTime == 0.5f) { TryLoadHeldItems(__state); } } internal static bool TryLoadHeldItems(Body body) { if ((Object)(object)body == (Object)null || !body.alive || !body.conscious || (Plugin.MultiplayerActive && !Plugin.IsHost()) || (body.handSlot != 0 && body.handSlot != 1)) { return false; } Item item = body.GetItem(body.handSlot); Item item2 = body.GetItem(1 - body.handSlot); if ((Object)(object)item == (Object)null || (Object)(object)item2 == (Object)null || (Object)(object)item == (Object)(object)item2) { return false; } RshGun component = ((Component)item).GetComponent<RshGun>(); RshMag component2 = ((Component)item).GetComponent<RshMag>(); if ((Object)(object)component == (Object)null && (Object)(object)component2 == (Object)null) { return false; } LoadCooldown value = cooldowns.GetValue(body, (Body _) => new LoadCooldown()); if (Time.unscaledTime < value.Until) { return false; } int num; if (!((Object)(object)component != (Object)null)) { if (component2.prop != null) { num = (component2.DragOnto(item2) ? 1 : 0); goto IL_0116; } num = 0; } else { if (component.prop != null && component.rounds != null && component.rounds.Count > 0) { num = (component.DragOnto(item2) ? 1 : 0); goto IL_0116; } num = 0; } goto IL_012b; IL_0116: if (num != 0) { value.Until = Time.unscaledTime + 0.25f; } goto IL_012b; IL_012b: return (byte)num != 0; } } public sealed class BatteryCell { public string id; public float charge; } internal static class BatteryCells { internal static List<BatteryCell> Copy(IEnumerable<BatteryCell> cells) { if (cells != null) { return (from cell in cells where cell != null && !string.IsNullOrEmpty(cell.id) select new BatteryCell { id = cell.id, charge = Mathf.Clamp01(cell.charge) }).ToList(); } return new List<BatteryCell>(); } internal static float Charge(IList<BatteryCell> cells) { return cells?.Sum((BatteryCell cell) => Mathf.Clamp01(cell.charge)) ?? 0f; } internal static float Condition(IList<BatteryCell> cells, int capacity) { return Mathf.Clamp01(Charge(cells) / (float)Mathf.Max(1, capacity)); } internal static void Drain(IList<BatteryCell> cells, float amount) { foreach (BatteryCell cell in cells) { float num = Mathf.Min(cell.charge, amount); cell.charge = Mathf.Max(0f, cell.charge - num); amount -= num; if (amount <= 0f) { break; } } } } internal static class BatteryNetwork { internal static void Write(NetDataWriter writer, List<BatteryCell> cells) { writer.Put((ushort)(cells?.Count ?? 0)); if (cells == null) { return; } foreach (BatteryCell cell in cells) { writer.Put(cell.id, 0); writer.Put(cell.charge); } } internal static List<BatteryCell> Read(NetDataReader reader) { List<BatteryCell> list = new List<BatteryCell>(); ushort num = default(ushort); reader.Get(ref num); string id = default(string); float charge = default(float); for (int i = 0; i < num; i++) { reader.Get(ref id); reader.Get(ref charge); list.Add(new BatteryCell { id = id, charge = charge }); } return BatteryCells.Copy(list); } } [HarmonyPatch(typeof(Body), "UseItemInHand")] public class BodyPatch1 { public static bool Prefix(Body __instance) { //IL_0072: 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) if (!__instance.HoldingItem(__instance.handSlot)) { return true; } Item item = __instance.GetItem(__instance.handSlot); if (!item.Stats.HasTag("gun")) { return true; } RshGun component = ((Component)item).GetComponent<RshGun>(); if ((Object)null == (Object)(object)component) { return true; } if (!__instance.conscious) { return false; } if ((!Plugin.useMinigame || component.prop.minigame == null || MinigameManager.GetOrAddInstance().handFaded) && Input.GetKeyDown(KeyBinds.GetBind("attack"))) { if (MinigameManager.IsAnyGameUIOpen()) { return false; } component.Shoot(__instance); if ((Object)(object)__instance == (Object)(object)PlayerCamera.main.body && Input.GetKey(Plugin.fireBothKey)) { Item item2 = __instance.GetItem(1 - __instance.handSlot); if (item2 != null) { ((Component)item2).GetComponent<RshGun>()?.Shoot(__instance); } } } return false; } } [HarmonyPatch(typeof(Body), "CanCombine")] public class BodyPatch2 { public static bool Prefix(Body __instance, ref bool __result, Item it1, Item it2) { if (NewDescentsCompatibility.IsMagazinePair(it1, it2)) { __result = NewDescentsCompatibility.CanLoad(it1, it2); return false; } RshGun rshGun = default(RshGun); RshMag rshMag = default(RshMag); if (((Component)it1).TryGetComponent<RshGun>(ref rshGun) && ((((Component)it2).TryGetComponent<RshMag>(ref rshMag) && rshGun.CanFitMag(rshMag.prop)) || (rshGun.prop.feedType != FeedKind.Battery && rshGun.prop.ammoTypes.Any((AmmoInfo ammo) => ammo.round == it2.id)))) { __result = true; return false; } RshMag rshMag2 = default(RshMag); if (((Component)it1).TryGetComponent<RshMag>(ref rshMag2) && rshMag2.CanAccept(it2)) { __result = true; return false; } return true; } } [HarmonyPatch(typeof(Body), "CombineItems")] [HarmonyAfter(new string[] { "CasualtiesMP" })] public class BodyPatch3 { public static bool Prefix(Body __instance, Item it1, Item it2, bool __runOriginal = true) { if (!__runOriginal) { return false; } if (NewDescentsCompatibility.IsMagazinePair(it1, it2)) { NewDescentsCompatibility.LoadMagazine(it1, it2); return false; } RshGun rshGun = default(RshGun); if (((Component)it1).TryGetComponent<RshGun>(ref rshGun)) { rshGun.DragOnto(it2); return false; } RshMag rshMag = default(RshMag); if (((Component)it1).TryGetComponent<RshMag>(ref rshMag)) { rshMag.DragOnto(it2); return false; } return true; } } [Saveable] [JsonObject(/*Could not decode attribute arguments.*/)] public sealed class CasingAppearance : MonoBehaviour { internal const string MessageId = "NewFirearms_CasingAppearance"; [JsonProperty("gunId")] public string gunId; [JsonProperty("ammoIndex")] public sbyte ammoIndex; private Sprite sprite; private SpriteRenderer spriteRenderer; internal static void Attach(GameObject casing, string definitionId, sbyte index) { CasingAppearance casingAppearance = default(CasingAppearance); if (!casing.TryGetComponent<CasingAppearance>(ref casingAppearance)) { casingAppearance = casing.AddComponent<CasingAppearance>(); } casingAppearance.gunId = definitionId; casingAppearance.ammoIndex = index; casingAppearance.ResolveSprite(); } private void Start() { ResolveSprite(); if (Plugin.MultiplayerActive) { StartSync(); } } private void ResolveSprite() { sprite = null; if (!string.IsNullOrEmpty(gunId) && Plugin.GunDefinitions.TryGetValue(gunId, out var value) && ammoIndex >= 0 && ammoIndex < value.ammoTypes.Count) { sprite = value.ammoTypes[ammoIndex].loadedCasingSprite; } spriteRenderer = ((Component)this).GetComponent<SpriteRenderer>(); if ((Object)(object)sprite != (Object)null) { CUCoreUtils.SetItemSprite(((Component)this).GetComponent<Item>(), sprite); ApplySprite(); } } private void LateUpdate() { ApplySprite(); } private void ApplySprite() { if ((Object)(object)sprite != (Object)null && (Object)(object)spriteRenderer != (Object)null && (Object)(object)spriteRenderer.sprite != (Object)(object)sprite) { spriteRenderer.sprite = sprite; } } private void StartSync() { if (Plugin.MultiplayerActive && Net.IsServer) { ((MonoBehaviour)this).InvokeRepeating("Sync", 0.1f, 1f); } } private void Sync() { //IL_003b: 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) SyncInfoGameObjectTracker val = default(SyncInfoGameObjectTracker); if (Plugin.MultiplayerActive && Net.IsServer && !string.IsNullOrEmpty(gunId) && ((Component)this).TryGetComponent<SyncInfoGameObjectTracker>(ref val) && val.isVisible) { NetDataWriter val2 = Multiplayer.CreateNamedWriter("NewFirearms_CasingAppearance"); val2.Put(knetid.op_Implicit(val.syncId)); val2.Put(gunId, 0); val2.Put(ammoIndex); DeliveryMethod val3 = (DeliveryMethod)0; IEnumerable<knetid> allClientIdsExceptHost = ServerMain.AllClientIdsExceptHost; Net.Server_SendToClients(ref val3, ref val2, ref allClientIdsExceptHost); } } } internal static class CasingNetwork { internal static void ClientSync(NetDataReader reader) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) ushort num = default(ushort); reader.Get(ref num); string definitionId = reader.GetString(); sbyte index = default(sbyte); reader.Get(ref index); SyncInfo val = default(SyncInfo); Item val2 = default(Item); if (ItemSync.TryGetItem(new knetid(num), ref val, ref val2) && (Object)(object)val2 != (Object)null && val2.id == "casing") { CasingAppearance.Attach(((Component)val2).gameObject, definitionId, index); } } } [HarmonyPatch(typeof(Item), "SetupItems")] [HarmonyAfter(new string[] { "CasualtiesMP" })] public static class CCLWorkaround { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static Use <>9__1_0; public static Use <>9__1_1; public static Use <>9__1_2; public static Use <>9__1_3; public static Use <>9__1_4; public static Use <>9__1_5; public static Use <>9__1_6; internal void <Postfix>b__1_0(Body body, Item item) { ((Component)item).GetComponent<RshMag>().OnInventoryUse(body); } internal void <Postfix>b__1_1(Body body, Item item) { ((Component)item).GetComponent<RshMag>().OnInventoryUse(body); } internal void <Postfix>b__1_2(Body body, Item item) { ((Component)item).GetComponent<RshMag>().OnInventoryUse(body); } internal void <Postfix>b__1_3(Body body, Item item) { ((Component)item).GetComponent<RshGun>().RemoveMag(body); } internal void <Postfix>b__1_4(Body body, Item item) { ((Component)item).GetComponent<RshGun>().RemoveMag(body); } internal void <Postfix>b__1_5(Body body, Item item) { ((Component)item).GetComponent<RshGun>().RemoveMag(body); } internal void <Postfix>b__1_6(Body body, Item item) { ((Component)item).GetComponent<RshGun>().RemoveMag(body); } } public static Dictionary<string, (string, string)> itemsToDesc; private static void Postfix() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Expected O, but got Unknown //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Expected O, but got Unknown ItemInfo obj = Item.GlobalItems["boxof12gauge"]; object obj2 = <>c.<>9__1_0; if (obj2 == null) { Use val = delegate(Body body, Item item) { ((Component)item).GetComponent<RshMag>().OnInventoryUse(body); }; <>c.<>9__1_0 = val; obj2 = (object)val; } obj.useAction = (Use)obj2; ItemInfo obj3 = Item.GlobalItems["smallmagazine"]; object obj4 = <>c.<>9__1_1; if (obj4 == null) { Use val2 = delegate(Body body, Item item) { ((Component)item).GetComponent<RshMag>().OnInventoryUse(body); }; <>c.<>9__1_1 = val2; obj4 = (object)val2; } obj3.useAction = (Use)obj4; ItemInfo obj5 = Item.GlobalItems["riflemagazine"]; object obj6 = <>c.<>9__1_2; if (obj6 == null) { Use val3 = delegate(Body body, Item item) { ((Component)item).GetComponent<RshMag>().OnInventoryUse(body); }; <>c.<>9__1_2 = val3; obj6 = (object)val3; } obj5.useAction = (Use)obj6; ItemInfo obj7 = Item.GlobalItems["pistol"]; object obj8 = <>c.<>9__1_3; if (obj8 == null) { Use val4 = delegate(Body body, Item item) { ((Component)item).GetComponent<RshGun>().RemoveMag(body); }; <>c.<>9__1_3 = val4; obj8 = (object)val4; } obj7.useAction = (Use)obj8; ItemInfo obj9 = Item.GlobalItems["shotgun"]; object obj10 = <>c.<>9__1_4; if (obj10 == null) { Use val5 = delegate(Body body, Item item) { ((Component)item).GetComponent<RshGun>().RemoveMag(body); }; <>c.<>9__1_4 = val5; obj10 = (object)val5; } obj9.useAction = (Use)obj10; ItemInfo obj11 = Item.GlobalItems["rifle"]; object obj12 = <>c.<>9__1_5; if (obj12 == null) { Use val6 = delegate(Body body, Item item) { ((Component)item).GetComponent<RshGun>().RemoveMag(body); }; <>c.<>9__1_5 = val6; obj12 = (object)val6; } obj11.useAction = (Use)obj12; ItemInfo obj13 = Item.GlobalItems["makeshiftrifle"]; object obj14 = <>c.<>9__1_6; if (obj14 == null) { Use val7 = delegate(Body body, Item item) { ((Component)item).GetComponent<RshGun>().RemoveMag(body); }; <>c.<>9__1_6 = val7; obj14 = (object)val7; } obj13.useAction = (Use)obj14; foreach (KeyValuePair<string, (string, string)> item in itemsToDesc) { Item.GlobalItems[item.Key].description = LocaleRegistry.Get("item", item.Key + "dsc", item.Value.Item1); Item.GlobalItems[item.Key].fullName = LocaleRegistry.Get("item", item.Key, item.Value.Item2); } } private static void Prepare() { itemsToDesc = new Dictionary<string, (string, string)>(); } } internal sealed class ConfigValidationException : Exception { internal ConfigValidationException(IEnumerable<string> errors, Exception inner = null) : base(string.Join("\n", errors.Select((string error) => " - " + error)), inner) { } } internal sealed class ConfigValidation { private readonly List<string> errors = new List<string>(); private readonly string folder; private readonly Func<string, bool> cachedSprite; internal ConfigValidation(string folder, Func<string, bool> cachedSprite) { this.folder = folder; this.cachedSprite = cachedSprite; } private void Require(bool valid, string field, string expected) { if (!valid) { errors.Add(field + ": " + expected); } } private void Finish() { if (errors.Count > 0) { throw new ConfigValidationException(errors); } } private void Sprite(string path, string field, bool required = false) { if (string.IsNullOrWhiteSpace(path)) { Require(!required, field, "a sprite path is required (relative to the item folder, without .png)."); } else if (path.StartsWith("COPY__", StringComparison.Ordinal)) { Require(cachedSprite(path), field, "cached sprite '" + path + "' does not exist; check its spelling and loading order."); } else { Require(File.Exists(Path.Combine(folder, path + ".png")), field, "sprite file '" + Path.Combine(folder, path + ".png") + "' does not exist; paths must omit .png."); } } private void SpriteArray(IList<string> paths, string field, int minimum = 0, bool required = false) { Require(!required || paths != null, field, $"expected at least {minimum} entries, one per ammo type."); if (paths != null) { Require(paths.Count >= minimum, field, $"has {paths.Count} entries; expected at least {minimum}."); for (int i = 0; i < paths.Count; i++) { Sprite(paths[i], $"{field}[{i}]"); } } } private void Texture(string path, string field, bool required = false) { if (path != null && path.StartsWith("COPY__", StringComparison.Ordinal)) { errors.Add(field + ": COPY__ is supported for sprite fields, not texture fields; use a local PNG path without .png."); } else { Sprite(path, field, required); } } private void Ids(IList<string> ids, string field, bool required) { Require(!required || (ids != null && ids.Count > 0), field, "expected a non-empty array of item/type IDs."); if (ids != null) { for (int i = 0; i < ids.Count; i++) { Require(!string.IsNullOrWhiteSpace(ids[i]), $"{field}[{i}]", "ID cannot be null or empty."); } } } private void Recipe(bool craftable, IList<string> recipe) { Require(!craftable || recipe != null, "recipe", "an array is required when craftable is true (use [] for no solid ingredients)."); if (craftable) { Ids(recipe, "recipe", required: false); } } private void SpawnFrequency(float frequency) { Require(frequency >= 0f && (double)frequency <= 2147483647.0, "spawnFrequency", "must be finite, non-negative, and fit an integer loot pool entry count."); } internal void Gun(GunJson gun) { if (gun == null) { throw new ConfigValidationException(new string[1] { "$: expected a JSON object, got null." }); } SpawnFrequency(gun.spawnFrequency); Require(Enum.IsDefined(typeof(FeedKind), gun.feedType), "feedType", "expected Magazine (1), Tube (2), Barrel (3), Revolver (4), or Battery (5)."); Require(!gun.needRetract || gun.feedType == FeedKind.Battery, "needRetract", "requires feedType 5 (battery magazine)."); Require(gun.batteryDrainPerRetract >= 0f && gun.batteryDrainPerRetract <= 1f, "batteryDrainPerRetract", "must be between 0 and 1 (fraction of full cell charge per manual retraction)."); Require(gun.batteryDrainPerRetract == 0f || (gun.feedType == FeedKind.Battery && gun.needRetract), "batteryDrainPerRetract", "requires feedType 5 and needRetract when greater than zero."); Require(!gun.hasFlashlight || gun.feedType == FeedKind.Battery, "hasFlashlight", "requires feedType 5 (battery magazine)."); Require(!gun.hasFlashlight || gun.minigame != null, "minigame", "is required when hasFlashlight is true."); Require(!gun.hasFlashlight || !string.IsNullOrWhiteSpace(gun.minigame?.flashlightTogglePath), "minigame.flashlightTogglePath", "a toggle hit-area sprite is required when hasFlashlight is true."); Require(gun.internalCapacity > 0, "internalCapacity", "must be greater than zero."); Require((gun.feedType != FeedKind.Magazine && gun.feedType != FeedKind.Battery) || gun.internalCapacity == 1, "internalCapacity", "must be 1 for magazine-fed and battery-fed guns."); if (gun.feedType == FeedKind.Battery) { Require(gun.batteryDrainPerShot > 0f && gun.batteryDrainPerShot <= 1f, "batteryDrainPerShot", "must be greater than zero and at most 1 (fraction of full charge per shot)."); List<AmmoInfo> ammoTypes = gun.ammoTypes; Require(ammoTypes != null && ammoTypes.Count == 1, "ammoTypes", "battery-fed guns require exactly one firing profile."); } Require(gun.ppu > 0f && !float.IsInfinity(gun.ppu), "ppu", "must be a finite number greater than zero."); int num = gun.ammoTypes?.Count ?? 0; Require(num > 0 && num <= 127, "ammoTypes", $"has {num} entries; expected 1 to 127."); for (int i = 0; i < num; i++) { AmmoInfo ammoInfo = gun.ammoTypes[i]; Require(ammoInfo != null, $"ammoTypes[{i}]", "expected an ammo object, got null."); if (ammoInfo != null) { Require(!string.IsNullOrWhiteSpace(ammoInfo.round), $"ammoTypes[{i}].round", "an item ID is required."); Require(ammoInfo.additionalStun >= 0f && !float.IsInfinity(ammoInfo.additionalStun), $"ammoTypes[{i}].additionalStun", "must be finite and greater than or equal to zero (seconds)."); Sprite(ammoInfo.casingSprite, $"ammoTypes[{i}].casingSprite"); Sprite(ammoInfo.minigameCasingSprite, $"ammoTypes[{i}].minigameCasingSprite"); if (ammoInfo.explosionParams != null) { float projectileVelocity = ammoInfo.explosionParams.projectileVelocity; float minimumTravelDistance = ammoInfo.explosionParams.minimumTravelDistance; Require(projectileVelocity > 0f && !float.IsInfinity(projectileVelocity), $"ammoTypes[{i}].explosionParams.projectileVelocity", "must be a finite number greater than zero."); Require(minimumTravelDistance >= 0f && !float.IsInfinity(minimumTravelDistance), $"ammoTypes[{i}].explosionParams.minimumTravelDistance", "must be a finite number greater than or equal to zero."); } } } Require(gun.fireModes != null && gun.fireModes.Count > 0, "fireModes", "a non-empty array is required."); int num2 = 0; if (gun.fireModes != null) { for (int j = 0; j < gun.fireModes.Count; j++) { Require(gun.fireModes[j] <= 4, $"fireModes[{j}]", "expected 0 (safe), 1 (manual), 2 (semi-auto), 3 (full-auto), or 4 (three-round burst)."); num2 = Math.Max(num2, gun.fireModes[j]); } } Require((gun.feedType != FeedKind.Magazine && gun.feedType != FeedKind.Battery) || gun.magazineType != null, "magazineType", "an array is required for magazine-fed and battery-fed guns."); Ids(gun.magazineType, "magazineType", required: false); Recipe(gun.craftable, gun.recipe); Texture(gun.normalTexturePath, "normalTexturePath", required: true); Texture(gun.rackedTexturePath, "rackedTexturePath", required: true); List<string> bulletsSpritesPath = gun.bulletsSpritesPath; if (bulletsSpritesPath != null && bulletsSpritesPath.Count > 0) { Require(gun.bulletsSpritesPath.Count >= num + 2, "bulletsSpritesPath", $"has {gun.bulletsSpritesPath.Count} entries; expected at least {num + 2}: empty, spent casing, then one sprite for each of {num} ammoTypes entries."); SpriteArray(gun.bulletsSpritesPath, "bulletsSpritesPath"); } List<string> fireModesSpritePath = gun.fireModesSpritePath; if (fireModesSpritePath != null && fireModesSpritePath.Count > 0) { SpriteArray(gun.fireModesSpritePath, "fireModesSpritePath", num2 + 1); } Sprite(gun.rackSpritePath, "rackSpritePath"); Sprite(gun.unrackSpritePath, "unrackSpritePath"); Sprite(gun.removeMagSpritePath, "removeMagSpritePath"); if (gun.magazineTexturesPath != null) { foreach (KeyValuePair<string, string> item in gun.magazineTexturesPath) { Texture(item.Value, "magazineTexturesPath['" + item.Key + "']"); } } if (gun.minigame != null) { Minigame(gun.minigame, num, num2); } MinigameConfig minigame = gun.minigame; Require(minigame == null || !((MinigameInfo)minigame).pumpOutsideWindow || gun.feedType == FeedKind.Tube, "minigame.pumpOutsideWindow", "requires a tube-fed gun (feedType 2)."); Finish(); } private void Minigame(MinigameConfig game, int count, int lastMode) { //IL_033e: Unknown result type (might be due to invalid IL or missing references) Require(((MinigameInfo)game).roundHeight >= 0f && !float.IsInfinity(((MinigameInfo)game).roundHeight), "minigame.roundHeight", "must be a finite, non-negative height; zero hides the chamber preview and keeps original sizes for ejection/jam visuals."); float[] array = new float[4] { ((MinigameInfo)game).inertiaHandXPosition, ((MinigameInfo)game).inertiaHandYPosition, ((MinigameInfo)game).inertiaBarrelXPosition, ((MinigameInfo)game).inertiaBarrelYPosition }; string[] array2 = new string[4] { "inertiaHandXPosition", "inertiaHandYPosition", "inertiaBarrelXPosition", "inertiaBarrelYPosition" }; for (int i = 0; i < array.Length; i++) { Require(array[i] >= -0.5f && array[i] <= 0.5f, "minigame." + array2[i], "must be between -0.5 and 0.5 (fraction of window width/height from its center)."); } float num = ((MinigameInfo)game).inertiaBarrelXPosition - ((MinigameInfo)game).inertiaHandXPosition; float num2 = ((MinigameInfo)game).inertiaBarrelYPosition - ((MinigameInfo)game).inertiaHandYPosition; Require(num * num + num2 * num2 >= 0.0025f, "minigame.inertiaBarrelXPosition / inertiaBarrelYPosition", "must be at least 0.05 away from the hand anchor."); Sprite(game.mainExperimentPath, "minigame.mainExperimentPath", required: true); Sprite(game.mainMilkyTriggerOnPath, "minigame.mainMilkyTriggerOnPath", required: true); Sprite(game.mainMilkyTriggerOffPath, "minigame.mainMilkyTriggerOffPath", required: true); Sprite(game.mainDunePath, "minigame.mainDunePath", required: true); Require(((MinigameInfo)game).ammos == null || ((MinigameInfo)game).ammos.Length == count, "minigame.ammos", $"must have {count} entries to match ammoTypes, or be omitted to generate automatically."); Require(((MinigameInfo)game).dCurrentAmmo < count, "minigame.dCurrentAmmo", "must index ammoTypes; omit this runtime field to start at the first ammo type."); Require(!((MinigameInfo)game).initialized, "minigame.initialized", "must be omitted or false; this is runtime state, not a config option."); string[] ammosInHandPaths = game.ammosInHandPaths; if (ammosInHandPaths != null && ammosInHandPaths.Any((string path) => !string.IsNullOrWhiteSpace(path))) { SpriteArray(game.ammosInHandPaths, "minigame.ammosInHandPaths", count); } string[] ammosInPtrPaths = game.ammosInPtrPaths; if (ammosInPtrPaths != null && ammosInPtrPaths.Any((string path) => !string.IsNullOrWhiteSpace(path))) { SpriteArray(game.ammosInPtrPaths, "minigame.ammosInPtrPaths", count); } string[] casingsPath = game.casingsPath; if (casingsPath != null && casingsPath.Length != 0) { SpriteArray(game.casingsPath, "minigame.casingsPath", count + 1); } string[] fireModePaths = game.fireModePaths; if (fireModePaths != null && fireModePaths.Length != 0) { SpriteArray(game.fireModePaths, "minigame.fireModePaths", lastMode + 1); } SpriteArray(game.coverAnimationPaths, "minigame.coverAnimationPaths"); Sprite(game.sliderFrontPath, "minigame.sliderFrontPath"); if (!((MinigameInfo)game).grabOnSlider) { Sprite(game.grabTrigger, "minigame.grabTrigger"); } Require(!((MinigameInfo)game).grabOnSlider || !string.IsNullOrWhiteSpace(game.sliderFrontPath), "minigame.sliderFrontPath", "is required when grabOnSlider is true."); Require(!((MinigameInfo)game).pumpOutsideWindow || (((MinigameInfo)game).grabOnSlider && !((MinigameInfo)game).rackByRotation && !((MinigameInfo)game).mosynStyleRack && !((MinigameInfo)game).chargingHandle), "minigame.pumpOutsideWindow", "requires grabOnSlider and a linear, non-charging slider (rackByRotation and mosynStyleRack must be false)."); Require(Enum.IsDefined(typeof(GrabType), ((MinigameInfo)game).grabType), "minigame.grabType", "must be Flat, Curved, or Vertical (0, 1, or 2)."); Sprite(game.sliderBackPath, "minigame.sliderBackPath"); Sprite(game.backLayerPath, "minigame.backLayerPath"); Sprite(game.magazineBackLayerPath, "minigame.magazineBackLayerPath"); Sprite(game.barrelPath, "minigame.barrelPath"); Require(string.IsNullOrWhiteSpace(game.barrelPath) || !((MinigameInfo)game).rackByRotation || ((MinigameInfo)game).mosynStyleRack, "minigame.barrelPath", "requires a linear slider; disable rackByRotation."); Require(!float.IsNaN(((MinigameInfo)game).barrelXPosition) && !float.IsInfinity(((MinigameInfo)game).barrelXPosition), "minigame.barrelXPosition", "must be a finite fraction of screen width."); Require(!float.IsNaN(((MinigameInfo)game).barrelYPosition) && !float.IsInfinity(((MinigameInfo)game).barrelYPosition), "minigame.barrelYPosition", "must be a finite fraction of screen height."); Sprite(game.rackedOnlyPath, "minigame.rackedOnlyPath"); Sprite(game.unrackedOnlyPath, "minigame.unrackedOnlyPath"); Sprite(game.receiverPath, "minigame.receiverPath"); Sprite(game.magReleasePath, "minigame.magReleasePath"); Sprite(game.rackTriggerPath, "minigame.rackTriggerPath"); Sprite(game.magazineDragPath, "minigame.magazineDragPath"); Sprite(game.laserTogglePath, "minigame.laserTogglePath"); Sprite(game.flashlightTogglePath, "minigame.flashlightTogglePath"); Sprite(game.laserPath, "minigame.laserPath"); Sprite(game.fireTogglePath, "minigame.fireTogglePath"); float num3 = Math.Min(((MinigameInfo)game).sliderMinimumPosition, ((MinigameInfo)game).sliderMaximumPosition); float num4 = Math.Max(((MinigameInfo)game).sliderMinimumPosition, ((MinigameInfo)game).sliderMaximumPosition); Require(((MinigameInfo)game).unrackedToRacked >= num3 && ((MinigameInfo)game).unrackedToRacked <= num4, "minigame.unrackedToRacked", "must be between sliderMinimumPosition and sliderMaximumPosition."); Require(((MinigameInfo)game).rackedToUnracked >= num3 && ((MinigameInfo)game).rackedToUnracked <= num4, "minigame.rackedToUnracked", "must be between sliderMinimumPosition and sliderMaximumPosition."); Require((((MinigameInfo)game).sliderMinimumPosition <= ((MinigameInfo)game).sliderMaximumPosition) ? (((MinigameInfo)game).unrackedToRacked <= ((MinigameInfo)game).rackedToUnracked) : (((MinigameInfo)game).unrackedToRacked >= ((MinigameInfo)game).rackedToUnracked), "minigame.rackedToUnracked", "must be at or beyond unrackedToRacked toward sliderMaximumPosition, so the thresholds do not overlap."); if (((MinigameInfo)game).pumpOutsideWindow) { float num5 = ((((MinigameInfo)game).sliderMinimumPosition <= ((MinigameInfo)game).sliderMaximumPosition) ? 1f : (-1f)); Require((((MinigameInfo)game).rackedIdlePosition - ((MinigameInfo)game).unrackedToRacked) * num5 < 0f, "minigame.rackedIdlePosition", "must pass unrackedToRacked toward sliderMinimumPosition for outside pumping."); Require((((MinigameInfo)game).unrackedIdlePosition - ((MinigameInfo)game).rackedToUnracked) * num5 > 0f, "minigame.unrackedIdlePosition", "must pass rackedToUnracked toward sliderMaximumPosition for outside pumping."); } Require(!((MinigameInfo)game).canUseFannyPack || game.magazinePaths != null, "minigame.magazinePaths", "a dictionary is required when canUseFannyPack is true (use {} for no magazines)."); if (game.magazinePaths != null) { foreach (KeyValuePair<string, string> magazinePath in game.magazinePaths) { Sprite(magazinePath.Value, "minigame.magazinePaths['" + magazinePath.Key + "']"); if (game.ammosInMagazinePaths != null) { Require(game.ammosInMagazinePaths.ContainsKey(magazinePath.Key), "minigame.ammosInMagazinePaths['" + magazinePath.Key + "']", "missing entry for a magazine listed in magazinePaths."); } } } if (game.ammosInMagazinePaths == null) { return; } foreach (KeyValuePair<string, string[]> ammosInMagazinePath in game.ammosInMagazinePaths) { SpriteArray(ammosInMagazinePath.Value, "minigame.ammosInMagazinePaths['" + ammosInMagazinePath.Key + "']", count, required: true); } } internal void Magazine(MagJson mag) { if (mag == null) { throw new ConfigValidationException(new string[1] { "$: expected a JSON object, got null." }); } SpawnFrequency(mag.spawnFrequency); Require(Enum.IsDefined(typeof(MagazineKind), mag.type), "type", "expected regular, pseudo, or battery."); Require(mag.capacity > 0 && mag.capacity <= 65535, "capacity", "must be between 1 and 65535 (battery slots for battery magazines)."); Ids(mag.ammoTypes, "ammoTypes", required: true); Require(mag.ammoTypes == null || mag.ammoTypes.Count <= 127, "ammoTypes", "cannot contain more than 127 ammo types."); Require(mag.magazineType != null, "magazineType", "an array is required; use [] for ammo boxes that cannot be inserted into guns."); Ids(mag.magazineType, "magazineType", required: false); Recipe(mag.craftable, mag.recipe); Sprite("item", "item sprite", required: true); Sprite(mag.nonEmptySpritePath, "nonEmptySpritePath"); Finish(); } internal void Round(RoundJson round) { if (round == null) { throw new ConfigValidationException(new string[1] { "$: expected a JSON object, got null." }); } SpawnFrequency(round.spawnFrequency); Recipe(round.craftable, round.recipe); Require(!round.craftable || round.craftAmount > 0, "craftAmount", "must be greater than zero when craftable is true."); Sprite("item", "item sprite", required: true); Finish(); } } internal sealed class ExplosiveProjectile : MonoBehaviour { internal int NetworkId; private Rigidbody2D rb; private Vector2 previousPosition; private float distance; private AmmoInfo ammo; private Body shooter; private bool authoritative; private float age; private LineRenderer trail; private RshGun tetherGun; internal Vector2 Position => rb.position; internal Vector2 Velocity => rb.velocity; internal static void Launch(AmmoInfo ammo, Vector2 position, Vector2 direction, Body shooter, RshGun tetherGun = null) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.MultiplayerActive || Plugin.IsHost()) { ExplosiveProjectile explosiveProjectile = Create(position, ((Vector2)(ref direction)).normalized * ammo.explosionParams.projectileVelocity); explosiveProjectile.ammo = ammo; explosiveProjectile.shooter = shooter; explosiveProjectile.authoritative = true; if ((Object)(object)tetherGun != (Object)null && !tetherGun.needsRetraction) { explosiveProjectile.tetherGun = tetherGun; tetherGun.AttachTether(((Component)explosiveProjectile).transform, position); } if (Plugin.MultiplayerActive) { ExplosiveProjectileNetwork.Spawn(explosiveProjectile); float projectileSyncRate = Plugin.sett.projectileSyncRate; ((MonoBehaviour)explosiveProjectile).InvokeRepeating("Sync", projectileSyncRate, projectileSyncRate); } } } internal static ExplosiveProjectile Create(Vector2 position, Vector2 velocity) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Expected O, but got Unknown ExplosiveProjectile explosiveProjectile = new GameObject("NewFirearms_ExplosiveProjectile").AddComponent<ExplosiveProjectile>(); ((Component)explosiveProjectile).transform.position = Vector2.op_Implicit(position); explosiveProjectile.rb = ((Component)explosiveProjectile).gameObject.AddComponent<Rigidbody2D>(); explosiveProjectile.rb.bodyType = (RigidbodyType2D)0; explosiveProjectile.rb.gravityScale = 1f; explosiveProjectile.rb.drag = 0f; explosiveProjectile.rb.freezeRotation = true; explosiveProjectile.rb.position = position; explosiveProjectile.rb.velocity = velocity; explosiveProjectile.previousPosition = position; if (!Plugin.MultiplayerActive || !Plugin.IsDedicated()) { GameObject val = (GameObject)Object.Instantiate(Resources.Load("Special/TurretLine"), Vector2.op_Implicit(position), Quaternion.identity); val.transform.SetParent(((Component)explosiveProjectile).transform); explosiveProjectile.trail = val.GetComponent<LineRenderer>(); explosiveProjectile.trail.useWorldSpace = true; LineRenderer obj = explosiveProjectile.trail; float startWidth = (explosiveProjectile.trail.endWidth = 0.12f); obj.startWidth = startWidth; explosiveProjectile.UpdateVisual(); } return explosiveProjectile; } internal void Correct(Vector2 position, Vector2 velocity) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) rb.position = position; rb.velocity = velocity; previousPosition = position; age = 0f; UpdateVisual(); } private void Update() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0198: 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_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) float deltaTime = Time.deltaTime; age += deltaTime; if (age > 60f) { Finish(); return; } Vector2 position = rb.position; if (authoritative && TryHit(position, out var hit)) { bool num = distance + Vector2.Distance(previousPosition, ((RaycastHit2D)(ref hit)).point) >= ammo.explosionParams.minimumTravelDistance; rb.position = ((RaycastHit2D)(ref hit)).point; if ((Object)(object)tetherGun != (Object)null && tetherGun.needsRetraction && (Object)(object)tetherGun.TetherTarget == (Object)(object)((Component)this).transform) { if (((Component)((RaycastHit2D)(ref hit)).collider).gameObject.layer == 6) { tetherGun.ApplyTetherState(active: true, ((RaycastHit2D)(ref hit)).point, null, WorldGeneration.world.WorldToBlockPos(((RaycastHit2D)(ref hit)).point - ((RaycastHit2D)(ref hit)).normal * 0.05f)); } else { tetherGun.ApplyTetherState(active: true, ((RaycastHit2D)(ref hit)).point, ((RaycastHit2D)(ref hit)).transform); } } if (num) { ShootManager.ApplyAdditionalStun(ammo, ((RaycastHit2D)(ref hit)).collider); FirearmCourseTarget firearmCourseTarget = default(FirearmCourseTarget); if (((Component)((RaycastHit2D)(ref hit)).collider).TryGetComponent<FirearmCourseTarget>(ref firearmCourseTarget)) { firearmCourseTarget.Hit(shooter, Mathf.Max(ammo.structureDamage, ammo.animalDamage)); } WorldGeneration.CreateExplosion(ammo.explosionParams.AtPosition(((RaycastHit2D)(ref hit)).point)); Finish(); } } else { distance += Vector2.Distance(previousPosition, position); previousPosition = position; UpdateVisual(); } } private void Sync() { if (((Behaviour)this).enabled && authoritative && Plugin.MultiplayerActive) { ExplosiveProjectileNetwork.Sync(this, alive: true); } } private bool TryHit(Vector2 next, out RaycastHit2D hit) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) Vector2 val = next - previousPosition; bool queriesHitTriggers = Physics2D.queriesHitTriggers; RaycastHit2D[] array; try { Physics2D.queriesHitTriggers = true; array = Physics2D.RaycastAll(previousPosition, ((Vector2)(ref val)).normalized, ((Vector2)(ref val)).magnitude, LayerMask.GetMask(new string[4] { "Ground", "Body", "Limb", "Descriptor" })); } finally { Physics2D.queriesHitTriggers = queriesHitTriggers; } RaycastHit2D[] array2 = array; Limb val3 = default(Limb); BuildingEntity val4 = default(BuildingEntity); FirearmCourseTarget firearmCourseTarget = default(FirearmCourseTarget); for (int i = 0; i < array2.Length; i++) { RaycastHit2D val2 = array2[i]; Collider2D collider = ((RaycastHit2D)(ref val2)).collider; if (!((Object)((Component)collider).gameObject).name.StartsWith("StunHitbox") && (!((Object)(object)shooter != (Object)null) || (!((Object)(object)((Component)collider).GetComponentInParent<Body>() == (Object)(object)shooter) && (!((Component)collider).TryGetComponent<Limb>(ref val3) || !((Object)(object)val3.body == (Object)(object)shooter)))) && (!((Component)collider).TryGetComponent<BuildingEntity>(ref val4) || !val4.cantHit) && (((Component)collider).gameObject.layer == 6 || !((Object)(object)((RaycastHit2D)(ref val2)).rigidbody == (Object)null) || !((Object)(object)val4 == (Object)null) || ((Component)collider).TryGetComponent<FirearmCourseTarget>(ref firearmCourseTarget))) { hit = val2; return true; } } hit = default(RaycastHit2D); return false; } private void UpdateVisual() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)trail == (Object)null)) { LineRenderer obj = trail; Vector2 position = Position; Vector2 velocity = Velocity; obj.SetPosition(0, Vector2.op_Implicit(position - ((Vector2)(ref velocity)).normalized * 0.3f)); trail.SetPosition(1, Vector2.op_Implicit(Position)); } } private void Finish() { //IL_003b: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)tetherGun != (Object)null && tetherGun.needsRetraction && (Object)(object)tetherGun.TetherTarget == (Object)(object)((Component)this).transform) { tetherGun.ApplyTetherState(active: true, Position); } ((MonoBehaviour)this).CancelInvoke("Sync"); ((Behaviour)this).enabled = false; rb.simulated = false; if (authoritative && Plugin.MultiplayerActive) { ExplosiveProjectileNetwork.Sync(this, alive: false); } Object.Destroy((Object)(object)((Component)this).gameObject); } private void OnDestroy() { ExplosiveProjectileNetwork.Forget(NetworkId, this); } } internal static class ExplosiveProjectileNetwork { internal const string MessageId = "NewFirearms_ExplosiveProjectile"; private static int nextId; private static readonly Dictionary<int, ExplosiveProjectile> replicas = new Dictionary<int, ExplosiveProjectile>(); internal static void Spawn(ExplosiveProjectile projectile) { projectile.NetworkId = ++nextId; Sync(projectile, alive: true); } internal static void Sync(ExplosiveProjectile projectile, bool alive) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) if (Plugin.MultiplayerActive && Net.IsServer) { NetDataWriter val = Multiplayer.CreateNamedWriter("NewFirearms_ExplosiveProjectile"); val.Put(projectile.NetworkId); val.Put(alive); val.Put(projectile.Position.x); val.Put(projectile.Position.y); val.Put(projectile.Velocity.x); val.Put(projectile.Velocity.y); DeliveryMethod val2 = (DeliveryMethod)2; IEnumerable<knetid> allClientIdsExceptHost = ServerMain.AllClientIdsExceptHost; Net.Server_SendToClients(ref val2, ref val, ref allClientIdsExceptHost); } } internal static void Receive(NetDataReader reader) { //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) int num = default(int); reader.Get(ref num); bool flag = default(bool); reader.Get(ref flag); float num2 = default(float); reader.Get(ref num2); float num3 = default(float); reader.Get(ref num3); float num4 = default(float); reader.Get(ref num4); float num5 = default(float); reader.Get(ref num5); replicas.TryGetValue(num, out var value); if (!flag) { if ((Object)(object)value != (Object)null) { Object.Destroy((Object)(object)((Component)value).gameObject); } replicas.Remove(num); return; } if ((Object)(object)value == (Object)null) { value = ExplosiveProjectile.Create(new Vector2(num2, num3), new Vector2(num4, num5)); value.NetworkId = num; replicas[num] = value; } value.Correct(new Vector2(num2, num3), new Vector2(num4, num5)); } internal static void Forget(int id, ExplosiveProjectile projectile) { if (replicas.TryGetValue(id, out var value) && value == projectile) { replicas.Remove(id); } } } [JsonConverter(typeof(StringEnumConverter))] public enum FeedKind { Magazine = 1, Tube, Barrel, Revolver, Battery } public class FirearmCourseResults : MonoBehaviour { private Text title; private Text status; private Text score; internal static string FormatTime(float seconds) { TimeSpan timeSpan = TimeSpan.FromSeconds(Mathf.Max(0f, seconds)); return ((int)timeSpan.TotalMinutes).ToString("00") + ":" + timeSpan.Seconds.ToString("00"); } private void BuildResultsPanel() { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Expected O, but got Unknown Canvas obj = ((Component)this).gameObject.AddComponent<Canvas>(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 30000; ((Component)this).gameObject.AddComponent<CanvasScaler>().uiScaleMode = (ScaleMode)1; ((Component)this).GetComponent<CanvasScaler>().referenceResolution = new Vector2(1920f, 1080f); ((Component)this).gameObject.AddComponent<GraphicRaycaster>(); GameObject val = new GameObject("Course results", new Type[2] { typeof(RectTransform), typeof(Image) }); val.transform.SetParent(((Component)this).transform, false); RectTransform component = val.GetComponent<RectTransform>(); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 1f); component.pivot = val2; Vector2 anchorMin = (component.anchorMax = val2); component.anchorMin = anchorMin; component.anchoredPosition = new Vector2(16f, -16f); component.sizeDelta = new Vector2(480f, 190f); ((Graphic)val.GetComponent<Image>()).color = new Color(0.04f, 0.04f, 0.04f, 0.92f); ((Graphic)val.GetComponent<Image>()).raycastTarget = false; title = MakeText(val.transform, "Title", 12f, 28f); status = MakeText(val.transform, "Objective", 44f, 58f); score = MakeText(val.transform, "Score", 105f, 28f); title.text = ModLocale.Course("ui.resultsTitle"); ((UnityEvent)MakeButton(val.transform, ModLocale.Course("ui.return"), 12f).onClick).AddListener((UnityAction)delegate { if ((Object)(object)TutorialHandler.main != (Object)null) { TutorialHandler.main.EndCourse(); } SceneManager.LoadScene("PreGen"); Object.Destroy((Object)(object)((Component)this).gameObject); }); ((UnityEvent)MakeButton(val.transform, ModLocale.Course("ui.dismiss"), 245f).onClick).AddListener((UnityAction)delegate { Object.Destroy((Object)(object)((Component)this).gameObject); }); } private static Text MakeText(Transform parent, string name, float top, float height) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0079: 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) GameObject val = new GameObject(name, new Type[2] { typeof(RectTransform), typeof(Text) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent<RectTransform>(); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 1f); component.pivot = val2; Vector2 anchorMin = (component.anchorMax = val2); component.anchorMin = anchorMin; component.anchoredPosition = new Vector2(12f, 0f - top); component.sizeDelta = new Vector2(456f, height); Text component2 = val.GetComponent<Text>(); component2.font = Resources.GetBuiltinResource<Font>("Arial.ttf"); component2.fontSize = 19; ((Graphic)component2).color = Color.white; ((Graphic)component2).raycastTarget = false; return component2; } private static Button MakeButton(Transform parent, string caption, float left) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0075: 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_0093: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(caption, new Type[3] { typeof(RectTransform), typeof(Image), typeof(Button) }); val.transform.SetParent(parent, false); RectTransform component = val.GetComponent<RectTransform>(); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(0f, 1f); component.pivot = val2; Vector2 anchorMin = (component.anchorMax = val2); component.anchorMin = anchorMin; component.anchoredPosition = new Vector2(left, -145f); component.sizeDelta = new Vector2(220f, 32f); ((Graphic)val.GetComponent<Image>()).color = new Color(0.23f, 0.23f, 0.23f); Text obj = MakeText(val.transform, "Label", 3f, 26f); ((Graphic)obj).rectTransform.sizeDelta = new Vector2(196f, 26f); obj.text = caption; return val.GetComponent<Button>(); } internal void Show(string reason, float survived, float highscore) { if ((Object)(object)title == (Object)null) { BuildResultsPanel(); } title.text = ModLocale.Course("ui.resultsTitle"); status.text = ModLocale.Course("ui.result", reason, FormatTime(survived)); score.text = ModLocale.Course("ui.best", FormatTime(highscore)); } } public class FirearmCourseTarget : MonoBehaviour { private RshGun requiredGun; private float health = 60f; private Texture2D texture; private Sprite sprite; public bool Destroyed => health <= 0f; public static FirearmCourseTarget Create(Vector2 position, RshGun gun) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Firearm course dummy"); val.layer = LayerMask.NameToLayer("Descriptor"); val.transform.position = Vector2.op_Implicit(position); FirearmCourseTarget firearmCourseTarget = val.AddComponent<FirearmCourseTarget>(); firearmCourseTarget.requiredGun = gun; firearmCourseTarget.texture = new Texture2D(16, 32, (TextureFormat)4, false); ((Texture)firearmCourseTarget.texture).filterMode = (FilterMode)0; for (int i = 0; i < 32; i++) { for (int j = 0; j < 16; j++) { bool flag = ((float)j - 7.5f) * ((float)j - 7.5f) + ((float)i - 26f) * ((float)i - 26f) <= 20f; bool flag2 = i >= 8 && i < 22 && j >= 2 && j <= 13; bool flag3 = i < 8 && ((j >= 3 && j <= 6) || (j >= 9 && j <= 12)); bool flag4 = ((float)j - 7.5f) * ((float)j - 7.5f) + ((float)i - 16f) * ((float)i - 16f) < 12f; firearmCourseTarget.texture.SetPixel(j, i, (Color)((flag || flag2 || flag3) ? (flag4 ? Color.red : new Color(0.85f, 0.75f, 0.5f)) : Color.clear)); } } firearmCourseTarget.texture.Apply(); firearmCourseTarget.sprite = Sprite.Create(firearmCourseTarget.texture, new Rect(0f, 0f, 16f, 32f), new Vector2(0.5f, 0.5f), 12f); val.AddComponent<SpriteRenderer>().sprite = firearmCourseTarget.sprite; val.AddComponent<BoxCollider2D>().size = new Vector2(1.3f, 2.7f); return firearmCourseTarget; } public void Hit(Body shooter, float damage) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) if (!Destroyed && !((Object)(object)requiredGun == (Object)null) && !((Object)(object)shooter == (Object)null) && shooter.HoldingItem(shooter.handSlot) && !((Object)(object)shooter.GetItem(shooter.handSlot) != (Object)(object)requiredGun.it)) { health -= Mathf.Max(1f, damage); if (Destroyed) { ((Behaviour)((Component)this).GetComponent<Collider2D>()).enabled = false; ((Component)this).GetComponent<SpriteRenderer>().color = Color.gray; ((Component)this).transform.rotation = Quaternion.Euler(0f, 0f, 80f); } } } private void OnDestroy() { if ((Object)(object)sprite != (Object)null) { Object.Destroy((Object)(object)sprite); } if ((Object)(object)texture != (Object)null) { Object.Destroy((Object)(object)texture); } } } public class FirearmExplosionParams : ExplosionParams { public float projectileVelocity = 40f; public float minimumTravelDistance; internal ExplosionParams AtPosition(Vector2 point) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) FirearmExplosionParams obj = (FirearmExplosionParams)((object)this).MemberwiseClone(); ((ExplosionParams)obj).position = point; return (ExplosionParams)(object)obj; } } public class FirearmHandlingCourse : TutorialCourse { public const int LEFT_PAW = 14; internal const string BestTimeKey = "NewFirearms.FirearmHandling.BestSurvivalSeconds"; private static readonly string[] Weapons = new string[3] { "nf.m1911", "nf.mp5", "nf.saiga" }; private static readonly string[] EnemyTypes = new string[2] { "wallbiter", "thornbackyoung" }; private readonly List<GameObject> spawned = new List<GameObject>(); private readonly List<GameObject> medicine = new List<GameObject>(); private readonly List<BuildingEntity> enemies = new List<BuildingEntity>(); private readonly List<FirearmCourseTarget> targets = new List<FirearmCourseTarget>(); private readonly List<GunJson> supplyWeapons = new List<GunJson>(); private readonly HashSet<string> ammunitionIds = new HashSet<string>(); private TutorialHandler handler; private Body trainee; private FirearmCourseResults results; private bool previousForceAlive; private bool previousEscapeCheck; private bool previousForceWalk; private bool initialized; private bool replenish; private bool survival; private bool finished; private bool supplying; private float survivalSeconds; private float nextSupply; private float nextEnemyWave; private int survivalWave; public override string LocaleName() { return "newfirearms.firearmhandlingcourse"; } public override IEnumerator Sequence() { handler = TutorialCourse.tutorial; trainee = TutorialCourse.body; previousForceAlive = handler.forcePlayerAlive; previousEscapeCheck = handler.checkForEscape; previousForceWalk = trainee.forceWalk; initialized = true; handler.forcePlayerAlive = false; handler.checkForEscape = false; trainee.forceWalk = true; trainee.skills.AddExp(2, 1000f); FirearmCourseResults[] array = Object.FindObjectsOfType<FirearmCourseResults>(); for (int i = 0; i < array.Length; i++) { Object.Destroy((Object)(object)((Component)array[i]).gameObject); } results = new GameObject("FirearmCourseResults").AddComponent<FirearmCourseResults>(); Object.DontDestroyOnLoad((Object)(object)((Component)results).gameObject); yield return Say(ModLocale.Course("dialogue.intro")); yield return MedicalLesson(); yield return EquipContainer("fannypack", "torsofront"); yield return EquipContainer("bandolier", "bandolier"); yield return WeaponLesson(); yield return MoveToRange(); replenish = true; yield return TargetPractice(); yield return CombatPractice(); yield return BeginSurvival(); } private IEnumerator Say(string text) { handler.Speak(text); float remaining = Mathf.Max(6f, (float)text.Length / 18f + 6f); yield return null; while ((Object)(object)handler != (Object)null && !handler.finishedTalking && remaining > 0f) { if (!PauseHandler.paused && Time.timeScale > 0f) { remaining -= Mathf.Min(Time.unscaledDeltaTime, 0.2f); } yield return null; } if ((Object)(object)handler != (Object)null && !handler.finishedTalking) { Debug.LogWarning((object)"[NewFirearms] Course speaker did not finish; continuing after the dialogue timeout."); handler.speakerTalker.Skip(); } } private static IEnumerator WaitUnpausedSeconds(float seconds) { while (seconds > 0f) { yield return null; if (!PauseHandler.paused && Time.timeScale > 0f) { seconds -= Mathf.Min(Time.unscaledDeltaTime, 0.2f); } } } private IEnumerator MedicalLesson() { yield return FetchInstructorItem(Weapons[0], Vector2.op_Implicit(((Component)trainee).transform.position + Vector3.right * 4f + Vector3.up * 3f)); GameObject demonstration = handler.lastSpawnedObject; yield return WaitForGun(demonstration); RshGun gun = demonstration.GetComponent<RshGun>(); Limb leg = trainee.limbs[14]; Coroutine aiming = ((MonoBehaviour)this).StartCoroutine(AimInstructorItem(demonstration.transform, ((Component)leg).transform)); yield return WaitUnpausedSeconds(1f); Sound.Play(gun.prop.shootAudio, Vector2.op_Implicit(demonstration.transform.position), false, true, (Transform)null, 1f, 1f, false, false); ShootManager.DrawVisuals(new ShootVisuals { start = Vector2.op_Implicit(demonstration.transform.position + demonstration.transform.up * gun.prop.barrelOffset), ends = new List<Vector2> { Vector2.op_Implicit(((Component)leg).transform.position) }, hitNumbers = new List<(Vector2, ushort)>(), knockbacks = new List<(ushort, Vector2)>() }); ShootManager.InduceDamage(leg, gun.prop.ammoTypes[0].playerDamage, 1f); leg.MendBone(); leg.skinHealth = Mathf.Max(leg.skinHealth, 60f); leg.muscleHealth = Mathf.Max(leg.muscleHealth, 70f); leg.bleedAmount = 15f; leg.shrapnel = 5; yield return WaitUnpausedSeconds(1f); handler.handPos = new Vector2(10f, 27f); yield return (object)new WaitUntil((Func<bool>)(() => handler.handPos == handler.handPosCurrent)); ((MonoBehaviour)this).StopCoroutine(aiming); handler.Ungrab(); Object.Destroy((Object)(object)demonstration); yield return Say(ModLocale.Course("dialogue.medical")); yield return FetchInstructorItem("medkit", Vector2.op_Implicit(((Component)trainee).transform.position + Vector3.up * 4f)); GameObject kit = handler.lastSpawnedObject; medicine.Add(kit); yield return null; Container component = kit.GetComponent<Container>(); if ((Object)(object)component == (Object)null) { throw new InvalidOperationException("[NewFirearms] Course medkit is missing its Container component."); } component.maxWeight = Mathf.Max(component.maxWeight, 8f); component.maxWeightPerItem = Mathf.Max(component.maxWeightPerItem, 3f); component.tagRestriction = new string[0]; component.itemsVisible = false; string[] array = new string[6] { "tweezers", "rippeddressing", "bandage", "antisepticmush", "tourniquet", "icepack" }; foreach (string id in array) { GiveMedicine(id, component); } yield return WaitUnpausedSeconds(0.5f); handler.Ungrab(); handler.showHealthPanelHighlight = true; yield return (object)new WaitUntil((Func<bool>)(() => leg.shrapnel == 0 && leg.bleedAmount < 0.1f)); handler.showHealthPanelHighlight = false; yield return Say(ModLocale.Course("dialogue.medicalComplete", WoundView.specimenId)); } private IEnumerator FetchInstructorItem(string id, Vector2 destination) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) handler.objectToCreate = id; yield return (object)new WaitUntil((Func<bool>)(() => string.IsNullOrEmpty(handler.objectToCreate) && (Object)(object)handler.lastSpawnedObject != (Object)null && (Object)(object)handler.grabInfo.Item1 == (Object)(object)handler.lastSpawnedObject.transform && handler.lastSpawnedObject.GetComponent<Item>().id == id)); TrackSpawned(handler.lastSpawnedObject); ((MonoBehaviour)this).StartCoroutine(FollowInstructorHand(handler.lastSpawnedObject.GetComponent<Item>())); handler.handPos.y -= 15f; yield return (object)new WaitUntil((Func<bool>)(() => handler.handPos == handler.handPosCurrent)); handler.handPos = destination; yield return (object)new WaitUntil((Func<bool>)(() => handler.handPos == handler.handPosCurrent)); } private IEnumerator FollowInstructorHand(Item item) { SpriteRenderer visual = ((Component)item).GetComponent<SpriteRenderer>(); while ((Object)(object)handler != (Object)null && (Object)(object)item != (Object)null && (Object)(object)handler.grabInfo.Item1 == (Object)(object)((Component)item).transform) { item.rb.position = handler.handPosCurrent; ((Component)item).transform.position = Vector2.op_Implicit(handler.handPosCurrent); if ((Object)(object)visual != (Object)null) { ((Renderer)visual).enabled = true; } yield return null; } } private IEnumerator AimInstructorItem(Transform item, Transform target) { while ((Object)(object)item != (Object)null && (Object)(object)target != (Object)null && (Object)(object)handler.grabInfo.Item1 == (Object)(object)item) { Vector2 val = Vector2.op_Implicit(target.position - item.position); item.rotation = Quaternion.Euler(0f, 0f, Mathf.Atan2(val.y, val.x) * 57.29578f); yield return null; } } private IEnumerator EquipContainer(string id, string slot) { if (!((Object)(object)trainee.GetWearableBySlotID(slot) != (Object)null)) { GameObject obj = Spawn(id, Vector2.op_Implicit(((Component)trainee).transform.position)); yield return null; trainee.WearWearable(obj.GetComponent<Item>()); } } private IEnumerator WaitForGun(GameObject obj) { float timeout = 10f; while ((Object)(object)obj != (Object)null && ((Object)(object)obj.GetComponent<RshGun>() == (Object)null || !obj.GetComponent<RshGun>().existed) && timeout > 0f) { timeout -= Time.deltaTime; yield return null; } if ((Object)(object)obj == (Object)null || (Object)(object)obj.GetComponent<RshGun>() == (Object)null || !obj.GetComponent<RshGun>().existed) { throw new InvalidOperationException("[NewFirearms] Course gun failed to initialize through CUCoreLib."); } RshGun component = obj.GetComponent<RshGun>(); component.MagazineCreated += TrackSpawned; ammunitionIds.Add(FindMagazine(component.prop)); foreach (AmmoInfo ammoType in component.prop.ammoTypes) { ammunitionIds.Add(ammoType.round); } } private IEnumerator WeaponLesson() { GameObject obj = Spawn(Weapons[0], Vector2.op_Implicit(((Component)trainee).transform.position)); yield return WaitForGun(obj); RshGun gun = obj.GetComponent<RshGun>(); gun.rounds = Enumerable.Repeat((sbyte)(-2), gun.prop.internalCapacity).ToList(); gun.mag = ""; gun.racked = false; gun.UpdateSprite(); trainee.AutoPickUpItem(obj.GetComponent<Item>()); yield return Say(ModLocale.Course("dialogue.rack")); yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)gun == (Object)null || gun.racked)); if ((Object)(object)gun == (Object)null) { yield break; } yield return SupplyMagazine(gun.prop, 0); yield return Say(ModLocale.Course("dialogue.insert")); yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)gun == (Object)null || !string.IsNullOrEmpty(gun.mag))); if ((Object)(object)gun == (Object)null) { yield break; } yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)gun == (Object)null || !gun.racked)); if ((Object)(object)gun == (Object)null) { yield break; } yield return Say(ModLocale.Course("dialogue.eject")); yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)gun == (Object)null || string.IsNullOrEmpty(gun.mag))); if ((Object)(object)gun == (Object)null) { yield break; } yield return SupplyMagazine(gun.prop, 0); yield return Say(ModLocale.Course("dialogue.reinsert")); yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)gun == (Object)null || !string.IsNullOrEmpty(gun.mag))); if (!((Object)(object)gun == (Object)null)) { GameObject empty = Spawn(FindMagazine(gun.prop), Vector2.op_Implicit(((Component)trainee).transform.position + Vector3.right)); yield return InitializeMagazine(empty, 0); PutInWearable(empty.GetComponent<Item>(), "torsofront"); for (int num = 0; num < 6; num++) { GiveAmmo("9mmround"); } RshMag mag = empty.GetComponent<RshMag>(); yield return Say(ModLocale.Course("dialogue.looseRound")); yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)mag == (Object)null || mag.TotalRounds() > 0)); } } private IEnumerator MoveToRange() { yield return Say(ModLocale.Course("dialogue.range")); GlobalDark.main.Darken(); yield return (object)new WaitUntil((Func<bool>)(() => !GlobalDark.main.IsDarkening())); ((Component)trainee).transform.position = Vector3.down * 106f; trainee.rb.velocity = Vector2.zero; ((Component)PlayerCamera.main).transform.position = ((Component)trainee).transform.position; handler.handPos = Vector2.op_Implicit(((Component)trainee).transform.position + Vector3.up * 8f); } private IEnumerator TargetPractice() { string[] weapons = Weapons; foreach (string id in weapons) { replenish = false; yield return (object)new WaitUntil((Func<bool>)(() => !supplying)); ClearTargets(); RemoveCourseGuns(); RemoveCourseAmmo(); supplyWeapons.Clear(); GameObject obj = Spawn(id, Vector2.op_Implicit(((Component)trainee).transform.position)); yield return WaitForGun(obj); RshGun gun = obj.GetComponent<RshGun>(); supplyWeapons.Add(gun.prop); trainee.AutoPickUpItem(obj.GetComponent<Item>()); yield return SupplyMagazine(gun.prop, 0); yield return SupplyMagazine(gun.prop, 1); replenish = true; Vector2 val = Vector2.down * 106f; for (int num = 0; num < 3; num++) { targets.Add(FirearmCourseTarget.Create(FindFloor(val + Vector2.right * (6f + (float)num * 4f)), gun)); } yield return Say(ModLocale.Course("dialogue.targets", gun.prop.fullName)); yield return (object)new WaitUntil((Func<bool>)(() => targets.All((FirearmCourseTarget target) => (Object)(object)target == (Object)null || target.Destroyed))); } ClearTargets(); } private IEnumerator CombatPractice() { replenish = false; yield return (object)new WaitUntil((Func<bool>)(() => !supplying)); supplyWeapons.Clear(); RemoveCourseGuns(); RemoveCourseAmmo(); string[] weapons = Weapons; foreach (string id in weapons) { GameObject obj = Spawn(id, Vector2.op_Implicit(((Component)trainee).transform.position + Vector3.right * 2f)); yield return WaitForGun(obj); GunJson prop = obj.GetComponent<RshGun>().prop; supplyWeapons.Add(prop); yield return SupplyMagazine(prop, 0); } replenish = true; yield return Say(ModLocale.Course("dialogue.combat")); for (int num = 0; num < 3; num++) { Debug.Log((object)$"[NewFirearms] Course practice wave {num + 1}/3 starting."); trainee.forceWalk = false; SpawnWave(2 + num, num); yield return (object)new WaitUntil((Func<bool>)(() => LivingEnemies() == 0)); trainee.forceWalk = true; Debug.Log((object)$"[NewFirearms] Course practice wave {num + 1}/3 cleared."); yield return Say(ModLocale.Course("dialogue.waveCleared", num + 1)); yield return WaitUnpausedSeconds(5f); } } private IEnumerator BeginSurvival() { replenish = false; supplyWeapons.Clear(); yield return (object)new WaitUntil((Func<bool>)(() => !supplying)); RemoveCourseGuns(); RemoveCourseAmmo(); ClearEnemies(); yield return Say(ModLocale.Course("dialogue.survival")); ((Component)trainee).transform.position = Vector3.down * 106f; trainee.rb.velocity = Vector2.zero; ((Component)PlayerCamera.main).transform.position = ((Component)trainee).transform.position; string[] weapons = Weapons; foreach (string id in weapons) { GameObject obj = Spawn(id, Vector2.op_Implicit(((Component)trainee).transform.position + Vector3.right * Random.Range(-2f, 2f))); yield return WaitForGun(obj); GunJson prop = obj.GetComponent<RshGun>().prop; for (int i = 0; i < 8; i++) { yield return SupplyMagazine(prop, i); } for (int num2 = 0; num2 < 60; num2++) { GiveAmmo(prop.ammoTypes[0].round); } } foreach (GameObject item in medicine) { if ((Object)(object)item != (Object)null) { Object.Destroy((Object)(object)item); } } Item[] array = trainee.GetAllItemsThorough().ToArray(); foreach (Item val in array) { if ((Object)(object)val != (Object)null && (val.Stats.category == "medical" || val.id == "autopump" || val.id == "medkit")) { if (val.Stats.wearable) { trainee.DropWearable(val); } Object.Destroy((Object)(object)((Component)val).gameObject); } } RestoreTrainingHealth(); handler.forcePlayerAlive = false; survivalSeconds = 0f; survivalWave = 0; nextEnemyWave = 0f; trainee.forceWalk = false; survival = true; handler.Speak(ModLocale.Course("dialogue.survivalStart")); } private void Update() { if (!initialized || finished || (Object)(object)trainee == (Object)null || InterruptForTurrets()) { return; } if (survival) { if (!trainee.alive) { FinishSurvival("died"); return; } if (PauseHandler.paused || Time.timeScale <= 0f) { return; } survivalSeconds += Time.unscaledDeltaTime; nextEnemyWave -= Time.deltaTime; if (nextEnemyWave <= 0f) { SpawnWave(Mathf.Min(2 + survivalWave / 2, 6), survivalWave); survivalWave++; nextEnemyWave = Mathf.Max(6f, 20f - (float)survivalWave); } } if (replenish && !supplying && Time.time >= nextSupply) { nextSupply = Time.time + 4f; ((MonoBehaviour)this).StartCoroutine(ReplenishAmmo()); } } private bool InterruptForTurrets() { if ((Object)(object)handler == (Object)null || handler.turrets == null) { return false; } TurretScript[] turrets = handler.turrets; foreach (TurretScript val in turrets) { if (!((Object)(object)val != (Object)null) || !(val.timeSinceFired >= 5f)) { TutorialHandler obj = handler; CleanupCourse(); obj.escapeSequenceActive = true; obj.EndCourse(); obj.StartCourse<EscapeCourse>(); return true; } } return false; } private IEnumerator ReplenishAmmo() { supplying = true; try { RshMag rshMag = default(RshMag); foreach (GameObject item in spawned) { if ((Object)(object)item != (Object)null && item.TryGetComponent<RshMag>(ref rshMag) && rshMag.existed && rshMag.TotalRounds() == 0) { Object.Destroy((Object)(object)item); } } GunJson[] array = supplyWeapons.ToArray(); RshMag rshMag2 = default(RshMag); foreach (GunJson gun in array) { if (!replenish) { break; } string id = FindMagazine(gun); int num = AvailableItems().Count((Item item) => item.id == id && ((Component)item).TryGetComponent<RshMag>(ref rshMag2) && rshMag2.TotalRounds() > 0); if (num < 3) { yield return SupplyMagazine(gun, num); } for (int num2 = AvailableItems().Count((Item item) => item.id == gun.ammoTypes[0].round); num2 < 12; num2++) { if (!replenish) { break; } GiveAmmo(gun.ammoTypes[0].round); } } } finally { supplying = false; } } private IEnumerable<Item> AvailableItems() { return (from item in trainee.GetAllItemsThorough().Concat(spawned.Where((GameObject obj) => (Object)(object)obj != (Object)null && Vector2.Distance(Vector2.op_Implicit(obj.transform.position), Vector2.op_Implicit(((Component)trainee).transform.position)) < 12f).SelectMany((GameObject obj) => obj.GetComponentsInChildren<Item>())) where (Object)(object)item != (Object)null select item).Distinct(); } private string FindMagazine(GunJson gun) { foreach (KeyValuePair<string, MagJson> magazineDefinition in Plugin.MagazineDefinitions) { if (magazineDefinition.Value.magazineType.Intersect(gun.magazineType).Any()) { return magazineDefinition.Key; } } throw new InvalidOperationException("[NewFirearms] Course could not find a magazine for " + gun.fullName); } private IEnumerator InitializeMagazine(GameObject obj, int amount) { float timeout = 10f; RshMag mag = null; while ((Object)(object)obj != (Object)null && timeout > 0f) { mag = obj.GetComponent<RshMag>(); if ((Object)(object)mag != (Object)null && mag.existed) { break; } timeout -= Time.deltaTime; yield return null; } if ((Object)(object)mag == (Object)null || !mag.existed) { throw new InvalidOperationException("[NewFirearms] Course magazine failed to initialize through CUCoreLib."); } mag.Fill(0, (amount < 0) ? mag.prop.capacity : amount); } private IEnumerator SupplyMagazine(GunJson gun, int offset) { GameObject obj = Spawn(FindMagazine(gun), Vector2.op_Implicit(((Component)trainee).transform.position + Vector3.right * (1f + (float)(offset % 4)))); yield return InitializeMagazine(obj, -1); PutInWearable(obj.GetComponent<Item>(), "torsofront"); } private void GiveAmmo(string id) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) Item component = Spawn(id, Vector2.op_Implicit(((Component)trainee).transform.position + Vector3.right)).GetComponent<Item>(); PutInWearable(component, "bandolier"); } private void PutInWearable(Item item, string slot) { Item wearableBySlotID = trainee.GetWearableBySlotID(slot); Container val = default(Container); if ((Object)(object)wearableBySlotID != (Object)null && ((Component)wearableBySlotID).TryGetComponent<Container>(ref val)) { val.LoadItem(item); } } private void GiveMedicine(string id, Container container) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) Vector2 position = (((Object)(object)container != (Object)null) ? Vector2.op_Implicit(((Component)container).transform.position) : (Vector2.op_Implicit(((Component)trainee).transform.position) + Vector2.right * 2f)); GameObject val = Spawn(id, position); medicine.Add(val); if ((Object)(object)container != (Object)null) { container.LoadItem(val.GetComponent<Item>()); if ((Object)(object)val.transform.parent != (Object)(object)((Component)container).transform) { throw new InvalidOperationException("[NewFirearms] Could not put course supply into medkit: " + id); } } } private GameObject Spawn(string id, Vector2 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) GameObject val = Utils.Create(id, position, 0f); if ((Object)(object)val == (Object)null) { throw new InvalidOperationException("[NewFirearms] Course could not spawn " + id); } TrackSpawned(val); return val; } private void TrackSpawned(GameObject obj) { spawned.RemoveAll((GameObject entry) => (Object)(object)entry == (Object)null); spawned.Add(obj); } private static Vector2 FindFloor(Vector2 near) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) RaycastHit2D val = Physics2D.Raycast(near + Vector2.up * 4f, Vector2.down, 12f, LayerMask.GetMask(new string[1] { "Ground" })); if (!((Object)(object)((RaycastHit2D)(ref val)).collider != (Object)null)) { return near; } return ((RaycastHit2D)(ref val)).point + Vector2.up * 1.5f; } private void SpawnWave(int count, int wave) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) LivingEnemies(); count = Mathf.Min(count, 16); while (enemies.Count + count > 16) { BuildingEntity val = enemies[0]; enemies.RemoveAt(0); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } } SpiderHandler val5 = default(SpiderHandler); for (int i = 0; i < count; i++) { float num = (((i + wave) % 2 == 0) ? 1f : (-1f)); Vector2 val2 = FindFloor(Vector2.op_Implicit(((Component)trainee).transform.position) + Vector2.right * num * Random.Range(9f, 16f)); GameObject val3 = Spawn(EnemyTypes[(i + wave) % EnemyTypes.Length], val2 + Vector2.up * 3.3f); BuildingEntity component = val3.GetComponent<BuildingEntity>(); if ((Object)(object)component == (Object)null) { throw new InvalidOperationException("[NewFirearms] Course enemy has no BuildingEntity: " + ((Object)val3).name); } component.itemsDropOnDestroy = (ItemDrop[])(object)new ItemDrop[0]; component.alwaysDrop = (ItemDrop[])(object)new ItemDrop[0]; component.guaranteedDropAmount = 0; component.ignoreBodyOptimize = true; RaycastHit2D val4 = Physics2D.Raycast(val2 + Vector2.up, Vector2.down, 8f, LayerMask.GetMask(new string[1] { "Ground" })); if ((Object)(object)((RaycastHit2D)(ref val4)).collider != (Object)null) { component.blockPlacedOn = WorldGeneration.world.WorldToBlockPos(((RaycastHit2D)(ref val4)).point + Vector2.down * 0.5f); } else { component.requireGround = false; } if (val3.TryGetComponent<SpiderHandler>(ref val5)) { val5.stunTime = Mathf.Max(val5.stunTime, 5f); val5.aggro = 1f; val5.seeDistance = 40f; val5.retreatHealth = -1f; } enemies.Add(component); } } private int LivingEnemies() { enemies.RemoveAll((BuildingEntity enemy) => (Object)(object)enemy == (Object)null || BuildingEntityHealth.GetHealth(enemy) < 0.5f); return enemies.Count; } private void RestoreTrainingHealth() { trainee.bloodVolume = (trainee.bloodOxygen = (trainee.brainHealth = 100f)); trainee.shock = (trainee.fibrillationProgress = 0f); trainee.fibrillationForced = false; trainee.internalBleeding = (trainee.venomTotal = (trainee.strokeAmount = (trainee.septicShock = 0f))); trainee.heartRate = 80f; trainee.bloodPressure = 120f; trainee.consciousness = 100f; trainee.hunger = (trainee.thirst = (trainee.energy = (trainee.stamina = 100f))); Limb[] limbs = trainee.limbs; foreach (Limb obj in limbs) { obj.bleedAmount = 0f; obj.shrapnel = 0; obj.skinHealth = (obj.muscleHealth = 100f); obj.pain = 0f; obj.infected = false; obj.infectionAmount = 0f; obj.MendBone(); obj.UnDislocate(); } } private void RemoveCourseGuns() { foreach (GameObject item in spawned) { if ((Object)(object)item != (Object)null && (Object)(object)item.GetComponent<RshGun>() != (Object)null) { Object.Destroy((Object)(object)item); } } } private void RemoveCourseAmmo() { Item val = default(Item); foreach (GameObject item in spawned) { if ((Object)(object)item != (Object)null && ((Object)(object)item.GetComponent<RshMag>() != (Object)null || (item.TryGetComponent<Item>(ref val) && ammunitionIds.Contains(val.id)))) { Object.Destroy((Object)(object)item); } } } private void ClearTargets() { foreach (FirearmCourseTarget target in targets) { if ((Object)(object)target != (Object)null) { Object.Destroy((Object)(object)((Component)target).gameObject); } } targets.Clear(); } private void ClearEnemies() { foreach (BuildingEntity enemy in enemies) { if ((Object)(object)enemy != (Object)null) { Object.Destroy((Object)(object)((Component)enemy).gameObject); } } enemies.Clear(); } private void FinishSurvival(string reason) { if (survival && !finished) { finished = true; survival = false; if ((Object)(object)trainee != (Object)null) { trainee.forceWalk = true; } ClearEnemies(); float num = Mathf.Max(PlayerPrefs.GetFloat("NewFirearms.FirearmHandling.BestSurvivalSeconds", 0f), survivalSeconds); PlayerPrefs.SetFloat("NewFirearms.FirearmHandling.BestSurvivalSeconds", num); PlayerPrefs.Save(); if ((Object)(object)results != (Object)null) { results.Show(ModLocale.Course("result." + reason), survivalSeconds, num); } } } private void OnDestroy() { CleanupCourse(); } private void CleanupCourse() { if (!initialized) { return; } initialized = false; FinishSurvival("leftCourse"); replenish = false; if ((Object)(object)results != (Object)null && !finished) { Object.Destroy((Object)(object)((Component)results).gameObject); } if ((Object)(object)handler != (Object)null) { handler.objectToCreate = ""; if ((Object)(object)handler.grabInfo.Item1 != (Object)null && spawned.Any((GameObject obj) => (Object)(object)obj != (Object)null && (Object)(object)obj.transform == (Object)(object)handler.grabInfo.Item1)) { handler.Ungrab(); } handler.forcePlayerAlive = previousForceAlive; handler.checkForEscape = previousEscapeCheck; handler.showHealthPanelHighlight = (handler.showUiHighlight = false); } if ((Object)(object)trainee != (Object)null) { trainee.forceWalk = previousForceWalk; } ClearTargets(); ClearEnemies(); foreach (GameObject item in spawned) { if ((Object)(object)item != (Object)null) { Object.Destroy((Object)(object)item); } } } } [HarmonyPatch(typeof(Settings), "DefaultSettings")] internal static class FireBothKeybindPatch { private const string Name = "newfirearms.fireboth"; private static SettingKeybind CreateKeybind() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown SettingKeybind setting = new SettingKeybind { name = "newfirearms.fireboth", value = (KeyCode)327, category = (SettingCategory)3 }; ((Setting)setting).apply = delegate { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) Plugin.fireBothKey = setting.value; }; return setting; } private static void Postfix(ref List<Setting> __result) { if (!__result.Exists((Setting setting) => setting.name == "newfirearms.fireboth")) { __result.Add((Setting)(object)CreateKeybind()); } } } [HarmonyPatch] internal static class GuardPistolDropPatch { private static MethodBase target; private static bool Prepare() { Type type = AccessTools.TypeByName("GuardScript"); target = ((type == null) ? null : AccessTools.DeclaredMethod(type, "Die", Type.EmptyTypes, (Type[])null)); return target != null; } private static MethodBase TargetMethod() { return target; } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, MethodBase __originalMethod) { //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Expected O, but got Unknown //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Expected O, but got Unknown List<CodeInstruction> list = new List<CodeInstruction>(instructions); MethodInfo create = AccessTools.Method(typeof(Utils), "Create", new Type[3] { typeof(string), typeof(Vector2), typeof(float) }, (Type[])null); FieldInfo fieldInfo = AccessTools.Field(__originalMethod.DeclaringType, "ammo"); FieldInfo hasMagField = AccessTools.Field(typeof(GunScript), "hasMag"); FieldInfo magazineRoundsField = AccessTools.Field(typeof(GunScript), "roundsInMag"); FieldInfo chamberField = AccessTools.Field(typeof(GunScript), "roundInChamber"); int num = list.FindIndex((CodeInstruction instruction) => CodeInstructionExtensions.StoresField(instruction, hasMagField)); int num2 = list.FindIndex((CodeInstruction instruction) => CodeInstructionExtensions.StoresField(instruction, magazineRoundsField)); int num3 = list.FindIndex((CodeInstruction instruction) => CodeInstructionExt
NewFirearmsManage.dll
Decompiled 7 hours agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("NewFirearmsManage")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+759929173ee3a2a7555ec30fb6dfac288b37f004")] [assembly: AssemblyProduct("NewFirearmsManage")] [assembly: AssemblyTitle("NewFirearmsManage")] [assembly: AssemblyVersion("1.0.0.0")] namespace NewFirearmsManage; [BepInPlugin("com.rushellxyz.newfirearmsmanage", "New Firearms Manage", "1.0.0")] public sealed class Plugin : BaseUnityPlugin { private const string Id = "com.rushellxyz.newfirearmsmanage"; internal static ManualLogSource Log { get; private set; } private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; new Harmony("com.rushellxyz.newfirearmsmanage").PatchAll(); } } [HarmonyPatch(typeof(Settings), "GetAllSettings")] internal static class ArsenalSetting { private const string SettingName = "newfirearmsmanage.extendarsenal"; private const string EnabledFile = "NewFirearms.dll"; private const string DisabledFile = "NewFirearms.dll.disabled"; private static void Postfix(ref List<Setting> __result) { //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown string enabledPath = Path.Combine(Paths.PluginPath, "NewFirearms.dll"); string disabledPath = Path.Combine(Paths.PluginPath, "NewFirearms.dll.disabled"); bool flag = File.Exists(enabledPath); if (flag || File.Exists(disabledPath)) { if (Locale.currentLang == null) { Locale.LoadLanguage(); } Dictionary<string, string> dictionary = Locale.currentLang?.other; if (dictionary != null) { dictionary["gamesetnewfirearmsmanage.extendarsenal"] = "Extend vanilla arsenal?"; dictionary["gamesetnewfirearmsmanage.extendarsenaldsc"] = "If disabled, New Firearms will not add new weapons. Restart the game to apply."; } SettingBool setting = new SettingBool { name = "newfirearmsmanage.extendarsenal", category = (SettingCategory)2, value = flag }; ((Setting)setting).apply = delegate { Apply(setting, enabledPath, disabledPath); }; __result = new List<Setting>(__result) { (Setting)(object)setting }; } } private static void Apply(SettingBool setting, string enabledPath, string disabledPath) { string text = (setting.value ? disabledPath : enabledPath); string text2 = (setting.value ? enabledPath : disabledPath); if (!File.Exists(text) && File.Exists(text2)) { return; } try { File.Move(text, text2); } catch (Exception ex) when (ex is IOException || ex is UnauthorizedAccessException) { ManualLogSource log = Plugin.Log; if (log != null) { log.LogWarning((object)("Could not rename '" + text + "' to '" + text2 + "': " + ex.Message)); } setting.value = File.Exists(enabledPath); } } }