using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BoneLib;
using BoneLib.BoneMenu;
using GunSling;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSystem.Collections;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "GunSling", "0.5.0", "you", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonAdditionalDependencies(new string[] { "BoneLib" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace GunSling
{
public enum ColorMode
{
Solid,
Gradient,
Rainbow
}
public enum Pattern
{
None,
Stripes,
Diagonal,
Checker,
Dots,
Zigzag,
Diamonds
}
public class SlingStyle
{
public int R1 = 255;
public int G1;
public int B1;
public int R2;
public int G2;
public int B2 = 255;
public ColorMode Mode;
public Pattern Pat;
public int PR = 255;
public int PG = 255;
public int PB = 255;
public int PatSize = 2;
public int WidthCm = 3;
public int ThicknessMm = 4;
public override string ToString()
{
return $"{R1},{G1},{B1};{R2},{G2},{B2};{Mode};{Pat};{PR},{PG},{PB};{PatSize};{WidthCm};{ThicknessMm}";
}
public static SlingStyle Parse(string s)
{
try
{
string[] array = s.Split(';');
string[] array2 = array[0].Split(',');
string[] array3 = array[1].Split(',');
string[] array4 = array[4].Split(',');
return new SlingStyle
{
R1 = int.Parse(array2[0]),
G1 = int.Parse(array2[1]),
B1 = int.Parse(array2[2]),
R2 = int.Parse(array3[0]),
G2 = int.Parse(array3[1]),
B2 = int.Parse(array3[2]),
Mode = (ColorMode)int.Parse(array[2]),
Pat = (Pattern)int.Parse(array[3]),
PR = int.Parse(array4[0]),
PG = int.Parse(array4[1]),
PB = int.Parse(array4[2]),
PatSize = int.Parse(array[5]),
WidthCm = int.Parse(array[6]),
ThicknessMm = ((array.Length > 7) ? int.Parse(array[7]) : 4)
};
}
catch
{
return null;
}
}
}
public static class StrapTexture
{
private const int W = 256;
private const int H = 16;
private const float StrapLen = 1.2f;
private static readonly Dictionary<string, Texture2D> cache = new Dictionary<string, Texture2D>();
public static Texture2D Get(SlingStyle s)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0123: 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_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0171: Unknown result type (might be due to invalid IL or missing references)
string key = s.ToString();
if (cache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
{
return value;
}
Texture2D val = new Texture2D(256, 16, (TextureFormat)4, false);
((Texture)val).wrapMode = (TextureWrapMode)1;
Color val2 = default(Color);
((Color)(ref val2))..ctor((float)s.R1 / 255f, (float)s.G1 / 255f, (float)s.B1 / 255f);
Color val3 = default(Color);
((Color)(ref val3))..ctor((float)s.R2 / 255f, (float)s.G2 / 255f, (float)s.B2 / 255f);
Color val4 = default(Color);
((Color)(ref val4))..ctor((float)s.PR / 255f, (float)s.PG / 255f, (float)s.PB / 255f);
float num = (float)s.WidthCm / 100f;
float num2 = Mathf.Max(0.005f, num * (float)s.PatSize * 0.5f);
for (int i = 0; i < 256; i++)
{
float num3 = (float)i / 255f;
Color val5 = ((s.Mode == ColorMode.Solid) ? val2 : ((s.Mode == ColorMode.Gradient) ? Color.Lerp(val2, val3, num3) : Color.HSVToRGB(num3, 1f, 1f)));
for (int j = 0; j < 16; j++)
{
float num4 = (float)j / 15f;
float gx = num3 * 1.2f / num2;
float gy = num4 * num / num2;
val.SetPixel(i, j, Hit(s.Pat, gx, gy, num4) ? val4 : val5);
}
}
val.Apply();
if (cache.Count > 40)
{
cache.Clear();
}
cache[key] = val;
return val;
}
private static bool Hit(Pattern p, float gx, float gy, float v)
{
float num = gx - Mathf.Floor(gx);
float num2 = gy - Mathf.Floor(gy);
return p switch
{
Pattern.Stripes => (int)Mathf.Floor(gx) % 2 == 0,
Pattern.Diagonal => (int)Mathf.Floor(gx + gy) % 2 == 0,
Pattern.Checker => ((int)Mathf.Floor(gx) + (int)Mathf.Floor(gy)) % 2 == 0,
Pattern.Dots => (num - 0.5f) * (num - 0.5f) + (num2 - 0.5f) * (num2 - 0.5f) < 0.12f,
Pattern.Zigzag => Mathf.Abs(v - Mathf.Abs(num - 0.5f) * 2f) < 0.2f,
Pattern.Diamonds => Mathf.Abs(num - 0.5f) + Mathf.Abs(v - 0.5f) < 0.35f,
_ => false,
};
}
}
public class Strap
{
private const int PointCount = 7;
public GameObject Go;
private MeshFilter meshFilter;
private MeshRenderer meshRenderer;
private Mesh mesh;
private Material material;
private string appliedKey;
private readonly Vector3[] points = (Vector3[])(object)new Vector3[7];
private readonly Vector3[] vertices = (Vector3[])(object)new Vector3[28];
private readonly Vector3[] corners = (Vector3[])(object)new Vector3[4];
private readonly float[] distances = new float[7];
private readonly Vector2[] uvs = (Vector2[])(object)new Vector2[28];
private readonly int[] triangles = new int[156];
private float width = 0.03f;
private float thickness = 0.004f;
public bool Alive
{
get
{
if ((Object)(object)Go != (Object)null && (Object)(object)meshFilter != (Object)null && (Object)(object)meshRenderer != (Object)null)
{
return (Object)(object)mesh != (Object)null;
}
return false;
}
}
public Strap()
{
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Expected O, but got Unknown
//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_00b2: Expected O, but got Unknown
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0119: Expected O, but got Unknown
Go = new GameObject("GunSlingStrap3D");
meshFilter = Go.AddComponent<MeshFilter>();
meshRenderer = Go.AddComponent<MeshRenderer>();
mesh = new Mesh
{
name = "GunSlingStrapMesh"
};
mesh.MarkDynamic();
meshFilter.sharedMesh = mesh;
((Renderer)meshRenderer).shadowCastingMode = (ShadowCastingMode)0;
((Renderer)meshRenderer).receiveShadows = false;
Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Texture") ?? Shader.Find("Hidden/Internal-Colored");
material = new Material(val);
((Renderer)meshRenderer).material = material;
BuildTopology();
}
public void SetParent(Transform parent)
{
if (Alive && !((Object)(object)parent == (Object)null) && !((Object)(object)Go.transform.parent == (Object)(object)parent))
{
Go.transform.SetParent(parent, true);
SetLayerRecursive(Go, ((Component)parent).gameObject.layer);
}
}
private static void SetLayerRecursive(GameObject g, int layer)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
g.layer = layer;
IEnumerator enumerator = g.transform.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
SetLayerRecursive(((Component)(Transform)enumerator.Current).gameObject, layer);
}
}
finally
{
if (enumerator is IDisposable disposable)
{
disposable.Dispose();
}
}
}
public void Apply(SlingStyle s)
{
if (Alive)
{
string text = s.ToString();
if (!(text == appliedKey))
{
appliedKey = text;
material.mainTexture = (Texture)(object)StrapTexture.Get(s);
width = Mathf.Max(0.01f, (float)s.WidthCm / 100f);
thickness = Mathf.Max(0.001f, (float)s.ThicknessMm / 1000f);
}
}
}
public void SetPoints(Vector3 a, Vector3 b, Vector3 c, Vector3 d, Vector3 e, Vector3 f, Vector3 g, Vector3 outward, Vector3 bodyRight)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: 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_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0037: 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_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: 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_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
if (Alive)
{
points[0] = a;
points[1] = b;
points[2] = c;
points[3] = d;
points[4] = e;
points[5] = f;
points[6] = g;
UpdateMesh(outward, bodyRight);
}
}
private void BuildTopology()
{
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_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_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
int num = 0;
for (int i = 0; i < 6; i++)
{
for (int j = 0; j < 4; j++)
{
int num2 = (j + 1) % 4;
int num3 = i * 4 + j;
int num4 = (i + 1) * 4 + j;
int num5 = (i + 1) * 4 + num2;
int num6 = i * 4 + num2;
triangles[num++] = num3;
triangles[num++] = num4;
triangles[num++] = num5;
triangles[num++] = num3;
triangles[num++] = num5;
triangles[num++] = num6;
}
}
triangles[num++] = 0;
triangles[num++] = 2;
triangles[num++] = 1;
triangles[num++] = 0;
triangles[num++] = 3;
triangles[num++] = 2;
int num7 = 24;
triangles[num++] = num7;
triangles[num++] = num7 + 1;
triangles[num++] = num7 + 2;
triangles[num++] = num7;
triangles[num++] = num7 + 2;
triangles[num++] = num7 + 3;
for (int k = 0; k < 7; k++)
{
int num8 = k * 4;
uvs[num8] = new Vector2(0f, 0f);
uvs[num8 + 1] = new Vector2(0f, 1f);
uvs[num8 + 2] = new Vector2(1f, 1f);
uvs[num8 + 3] = new Vector2(1f, 0f);
}
mesh.vertices = Il2CppStructArray<Vector3>.op_Implicit(vertices);
mesh.uv = Il2CppStructArray<Vector2>.op_Implicit(uvs);
mesh.triangles = Il2CppStructArray<int>.op_Implicit(triangles);
}
private void UpdateMesh(Vector3 outward, Vector3 bodyRight)
{
//IL_002f: 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_0066: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
//IL_0115: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_011a: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Unknown result type (might be due to invalid IL or missing references)
//IL_011e: Unknown result type (might be due to invalid IL or missing references)
//IL_011f: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_0134: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_013c: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
//IL_017e: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: 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_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0195: 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_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_0168: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: 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_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0210: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Unknown result type (might be due to invalid IL or missing references)
//IL_021a: Unknown result type (might be due to invalid IL or missing references)
//IL_022e: Unknown result type (might be due to invalid IL or missing references)
//IL_0233: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_023b: Unknown result type (might be due to invalid IL or missing references)
//IL_0240: Unknown result type (might be due to invalid IL or missing references)
//IL_0243: Unknown result type (might be due to invalid IL or missing references)
//IL_0248: Unknown result type (might be due to invalid IL or missing references)
//IL_024d: Unknown result type (might be due to invalid IL or missing references)
//IL_0261: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_0269: Unknown result type (might be due to invalid IL or missing references)
//IL_026e: Unknown result type (might be due to invalid IL or missing references)
//IL_0273: Unknown result type (might be due to invalid IL or missing references)
//IL_0276: Unknown result type (might be due to invalid IL or missing references)
//IL_027b: Unknown result type (might be due to invalid IL or missing references)
//IL_0280: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: 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_01ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: 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_02bb: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
distances[0] = 0f;
for (int i = 1; i < 7; i++)
{
distances[i] = distances[i - 1] + Vector3.Distance(points[i - 1], points[i]);
}
float num = Mathf.Max(0.001f, distances[6]);
Vector3 val = Vector3.zero;
float num2 = width * 0.5f;
float num3 = thickness * 0.5f;
for (int j = 0; j < 7; j++)
{
Vector3 val2 = (Vector3)(j switch
{
6 => points[j] - points[j - 1],
0 => points[1] - points[0],
_ => points[j + 1] - points[j - 1],
});
val2 = ((((Vector3)(ref val2)).sqrMagnitude > 1E-06f) ? ((Vector3)(ref val2)).normalized : Vector3.forward);
Vector3 val3 = Vector3.Cross(val2, outward);
if (((Vector3)(ref val3)).sqrMagnitude < 1E-06f)
{
val3 = Vector3.Cross(val2, bodyRight);
}
if (((Vector3)(ref val3)).sqrMagnitude < 1E-06f)
{
val3 = Vector3.Cross(val2, Vector3.up);
}
((Vector3)(ref val3)).Normalize();
if (j > 0 && Vector3.Dot(val3, val) < 0f)
{
val3 = -val3;
}
val = val3;
Vector3 val4 = Vector3.Cross(val3, val2);
Vector3 val5 = ((Vector3)(ref val4)).normalized;
if (Vector3.Dot(val5, outward) < 0f)
{
val3 = -val3;
val5 = -val5;
val = val3;
}
corners[0] = points[j] - val3 * num2 - val5 * num3;
corners[1] = points[j] + val3 * num2 - val5 * num3;
corners[2] = points[j] + val3 * num2 + val5 * num3;
corners[3] = points[j] - val3 * num2 + val5 * num3;
float x = distances[j] / num;
int num4 = j * 4;
for (int k = 0; k < 4; k++)
{
vertices[num4 + k] = Go.transform.InverseTransformPoint(corners[k]);
uvs[num4 + k].x = x;
}
}
mesh.vertices = Il2CppStructArray<Vector3>.op_Implicit(vertices);
mesh.uv = Il2CppStructArray<Vector2>.op_Implicit(uvs);
mesh.RecalculateNormals();
mesh.RecalculateBounds();
}
public void Destroy()
{
if ((Object)(object)Go != (Object)null)
{
Object.Destroy((Object)(object)Go);
}
if ((Object)(object)mesh != (Object)null)
{
Object.Destroy((Object)(object)mesh);
}
if ((Object)(object)material != (Object)null)
{
Object.Destroy((Object)(object)material);
}
}
}
internal class SlingData
{
public List<ConfigurableJoint> Joints = new List<ConfigurableJoint>();
public Vector3 Front;
public Vector3 Back;
public Strap Strap;
}
public class Core : MelonMod
{
private enum Pick
{
Front,
Back
}
private class Tracked
{
public Gun Gun;
public Rigidbody Rb;
public InteractableHost Host;
}
private const float RopeSpring = 400f;
private const float RopeDamper = 20f;
private const float PickupRadius = 1.2f;
private static readonly Vector3 NeckFrontLeft = new Vector3(-0.065f, 0.19f, 0.075f);
private static readonly Vector3 NeckLeft = new Vector3(-0.095f, 0.23f, 0.015f);
private static readonly Vector3 NeckBack = new Vector3(0f, 0.25f, -0.105f);
private static readonly Vector3 NeckRight = new Vector3(0.095f, 0.23f, 0.015f);
private static readonly Vector3 NeckFrontRight = new Vector3(0.065f, 0.19f, 0.075f);
private static readonly string[] PistolNames = new string[9] { "pistol", "handgun", "1911", "eder", "m9", "revolver", "glock", "p350", "djinn" };
private static readonly string[] SupportedGunNames = new string[23]
{
"rifle", "shotgun", "smg", "submachine", "carbine", "assault", "m4", "m16", "ak47", "ak74",
"akm", "scar", "g36", "hk416", "g3", "aug", "mp5", "mp7", "uzi", "vector",
"p90", "mac10", "mk18"
};
private bool enabled = true;
private bool showStrap = true;
private bool worn;
private int lengthCm = 30;
private readonly SlingStyle style = new SlingStyle();
private readonly Dictionary<Rigidbody, SlingData> slung = new Dictionary<Rigidbody, SlingData>();
private readonly Dictionary<Rigidbody, SlingData> looseStraps = new Dictionary<Rigidbody, SlingData>();
private readonly Dictionary<string, Vector3> frontPoints = new Dictionary<string, Vector3>();
private readonly Dictionary<string, Vector3> backPoints = new Dictionary<string, Vector3>();
private Pick? pendingCapture;
private Gun pendingCaptureGun;
private Rigidbody pendingCaptureBody;
private string pendingCaptureKey;
private readonly List<Tracked> tracked = new List<Tracked>();
private readonly HashSet<Rigidbody> wasHeld = new HashSet<Rigidbody>();
public override void OnInitializeMelon()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: 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_006a: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: 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_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
//IL_030d: Unknown result type (might be due to invalid IL or missing references)
//IL_033d: Unknown result type (might be due to invalid IL or missing references)
//IL_036d: Unknown result type (might be due to invalid IL or missing references)
//IL_039d: Unknown result type (might be due to invalid IL or missing references)
//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
Page obj = Page.Root.CreatePage("GunSling", Color.cyan, 0, true);
Page obj2 = obj.CreatePage("Sling", Color.green, 0, true);
obj2.CreateBool("Sling Enabled", Color.green, true, (Action<bool>)delegate(bool v)
{
enabled = v;
if (!enabled)
{
DetachAll();
}
});
obj2.CreateBool("Wear Sling on Neck", Color.green, false, (Action<bool>)delegate(bool v)
{
worn = v;
if (!worn)
{
DropAllSlungWithStrap();
}
});
obj2.CreateFunction("Drop To Floor (Keep Strap)", Color.yellow, (Action)DropAllSlungWithStrap);
obj2.CreateFunction("Remove All Straps", Color.red, (Action)DetachAll);
obj2.CreateBool("Show 3D Strap", Color.green, true, (Action<bool>)delegate(bool v)
{
showStrap = v;
foreach (SlingData value in slung.Values)
{
if (value.Strap != null && value.Strap.Alive)
{
value.Strap.Go.SetActive(v);
}
}
foreach (SlingData value2 in looseStraps.Values)
{
if (value2.Strap != null && value2.Strap.Alive)
{
value2.Strap.Go.SetActive(v);
}
}
});
obj2.CreateInt("Length (cm)", Color.white, lengthCm, 5, 10, 150, (Action<int>)delegate(int v)
{
//IL_0042: 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)
lengthCm = v;
foreach (SlingData value3 in slung.Values)
{
foreach (ConfigurableJoint joint in value3.Joints)
{
if ((Object)(object)joint != (Object)null)
{
SoftJointLimit linearLimit = default(SoftJointLimit);
((SoftJointLimit)(ref linearLimit)).limit = (float)lengthCm / 100f;
joint.linearLimit = linearLimit;
}
}
}
});
Page obj3 = obj.CreatePage("Attachment Points", Color.yellow, 0, true);
obj3.CreateFunction("Set Front Sling (Press X)", Color.yellow, (Action)delegate
{
BeginCapturePoint(Pick.Front);
});
obj3.CreateFunction("Set Back Sling (Press X)", Color.yellow, (Action)delegate
{
BeginCapturePoint(Pick.Back);
});
obj3.CreateFunction("Reset Points (held gun)", Color.red, (Action)ResetHeldGunPoints);
Page obj4 = obj.CreatePage("Color", Color.magenta, 0, true);
obj4.CreateEnum("Mode", Color.white, (Enum)style.Mode, (Action<Enum>)delegate(Enum v)
{
style.Mode = (ColorMode)(object)v;
Changed();
});
obj4.CreateInt("Color 1 - Red", Color.red, style.R1, 15, 0, 255, (Action<int>)delegate(int v)
{
style.R1 = v;
Changed();
});
obj4.CreateInt("Color 1 - Green", Color.green, style.G1, 15, 0, 255, (Action<int>)delegate(int v)
{
style.G1 = v;
Changed();
});
obj4.CreateInt("Color 1 - Blue", Color.blue, style.B1, 15, 0, 255, (Action<int>)delegate(int v)
{
style.B1 = v;
Changed();
});
obj4.CreateInt("Color 2 - Red", Color.red, style.R2, 15, 0, 255, (Action<int>)delegate(int v)
{
style.R2 = v;
Changed();
});
obj4.CreateInt("Color 2 - Green", Color.green, style.G2, 15, 0, 255, (Action<int>)delegate(int v)
{
style.G2 = v;
Changed();
});
obj4.CreateInt("Color 2 - Blue", Color.blue, style.B2, 15, 0, 255, (Action<int>)delegate(int v)
{
style.B2 = v;
Changed();
});
obj4.CreateFunction("Random Colors", Color.yellow, (Action)delegate
{
Random random = new Random();
style.R1 = random.Next(256);
style.G1 = random.Next(256);
style.B1 = random.Next(256);
style.R2 = random.Next(256);
style.G2 = random.Next(256);
style.B2 = random.Next(256);
Changed();
});
Page obj5 = obj.CreatePage("Pattern & Fit", Color.yellow, 0, true);
obj5.CreateEnum("Pattern", Color.white, (Enum)style.Pat, (Action<Enum>)delegate(Enum v)
{
style.Pat = (Pattern)(object)v;
Changed();
});
obj5.CreateInt("Pattern - Red", Color.red, style.PR, 15, 0, 255, (Action<int>)delegate(int v)
{
style.PR = v;
Changed();
});
obj5.CreateInt("Pattern - Green", Color.green, style.PG, 15, 0, 255, (Action<int>)delegate(int v)
{
style.PG = v;
Changed();
});
obj5.CreateInt("Pattern - Blue", Color.blue, style.PB, 15, 0, 255, (Action<int>)delegate(int v)
{
style.PB = v;
Changed();
});
obj5.CreateInt("Pattern Size", Color.white, style.PatSize, 1, 1, 8, (Action<int>)delegate(int v)
{
style.PatSize = v;
Changed();
});
obj5.CreateInt("Strap Width (cm)", Color.white, style.WidthCm, 1, 1, 10, (Action<int>)delegate(int v)
{
style.WidthCm = v;
Changed();
});
obj5.CreateInt("Strap Thickness (mm)", Color.white, style.ThicknessMm, 1, 1, 10, (Action<int>)delegate(int v)
{
style.ThicknessMm = v;
Changed();
});
}
private void Changed()
{
foreach (SlingData value in slung.Values)
{
value.Strap?.Apply(style);
}
foreach (SlingData value2 in looseStraps.Values)
{
value2.Strap?.Apply(style);
}
}
private static string KeyFor(Gun gun)
{
return ((Object)((Component)gun).transform.root).name.Replace("(Clone)", "").Trim();
}
private static bool IsSupportedGun(Gun gun)
{
string text = KeyFor(gun).ToLowerInvariant();
string[] pistolNames = PistolNames;
foreach (string value in pistolNames)
{
if (text.Contains(value))
{
return false;
}
}
pistolNames = SupportedGunNames;
foreach (string value2 in pistolNames)
{
if (text.Contains(value2))
{
return true;
}
}
return false;
}
private static bool IsHeld(Gun gun)
{
InteractableHost componentInParent = ((Component)gun).GetComponentInParent<InteractableHost>();
if ((Object)(object)componentInParent != (Object)null)
{
return componentInParent.HandCount() > 0;
}
return false;
}
private Gun FindHeldGun()
{
foreach (Gun item in Object.FindObjectsOfType<Gun>())
{
if (IsSupportedGun(item) && IsHeld(item))
{
return item;
}
}
return null;
}
private void ResetHeldGunPoints()
{
Gun val = FindHeldGun();
if (!((Object)(object)val == (Object)null))
{
frontPoints.Remove(KeyFor(val));
backPoints.Remove(KeyFor(val));
Rigidbody componentInParent = ((Component)val).GetComponentInParent<Rigidbody>();
if ((Object)(object)componentInParent != (Object)null)
{
Detach(componentInParent);
}
}
}
public override void OnUpdate()
{
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_0129: Unknown result type (might be due to invalid IL or missing references)
ProcessPendingCapture();
if (!enabled)
{
return;
}
if (Time.frameCount % 60 == 0 || (tracked.Count == 0 && Time.frameCount % 15 == 0))
{
RefreshTracked();
}
RigManager rigManager = Player.RigManager;
if ((Object)(object)rigManager == (Object)null)
{
return;
}
Transform chest = ((Rig)rigManager.physicsRig).m_chest;
if ((Object)(object)chest == (Object)null)
{
return;
}
Rigidbody componentInParent = ((Component)chest).GetComponentInParent<Rigidbody>();
if ((Object)(object)componentInParent == (Object)null)
{
return;
}
foreach (Tracked item in tracked)
{
if (!((Object)(object)item.Gun == (Object)null) && !((Object)(object)item.Rb == (Object)null) && !((Object)(object)item.Host == (Object)null))
{
bool flag = item.Host.HandCount() > 0;
bool flag2 = slung.ContainsKey(item.Rb);
if (flag && flag2)
{
DetachFromNeck(item.Rb);
}
else if (!flag && !flag2 && worn && wasHeld.Contains(item.Rb) && Vector3.Distance(item.Rb.position, chest.position) < 1.2f)
{
Attach(item.Gun, item.Rb, chest, componentInParent);
}
if (flag)
{
wasHeld.Add(item.Rb);
}
else
{
wasHeld.Remove(item.Rb);
}
}
}
}
private void RefreshTracked()
{
tracked.Clear();
foreach (Gun item in Object.FindObjectsOfType<Gun>())
{
if (IsSupportedGun(item))
{
Rigidbody componentInParent = ((Component)item).GetComponentInParent<Rigidbody>();
InteractableHost componentInParent2 = ((Component)item).GetComponentInParent<InteractableHost>();
if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)componentInParent2 == (Object)null))
{
tracked.Add(new Tracked
{
Gun = item,
Rb = componentInParent,
Host = componentInParent2
});
}
}
}
}
public override void OnLateUpdate()
{
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: 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_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_0173: Unknown result type (might be due to invalid IL or missing references)
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_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_018c: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: 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_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
//IL_01af: 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_01c1: Unknown result type (might be due to invalid IL or missing references)
//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
//IL_01cf: 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_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
//IL_01e7: 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_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0209: 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_0212: 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_021e: Unknown result type (might be due to invalid IL or missing references)
//IL_0223: Unknown result type (might be due to invalid IL or missing references)
//IL_0228: Unknown result type (might be due to invalid IL or missing references)
//IL_022f: Unknown result type (might be due to invalid IL or missing references)
//IL_0234: Unknown result type (might be due to invalid IL or missing references)
//IL_0239: Unknown result type (might be due to invalid IL or missing references)
//IL_0245: Unknown result type (might be due to invalid IL or missing references)
//IL_0247: Unknown result type (might be due to invalid IL or missing references)
//IL_024e: Unknown result type (might be due to invalid IL or missing references)
//IL_0253: Unknown result type (might be due to invalid IL or missing references)
//IL_0258: Unknown result type (might be due to invalid IL or missing references)
//IL_0264: Unknown result type (might be due to invalid IL or missing references)
//IL_0266: Unknown result type (might be due to invalid IL or missing references)
//IL_026d: Unknown result type (might be due to invalid IL or missing references)
//IL_0272: Unknown result type (might be due to invalid IL or missing references)
//IL_0279: Unknown result type (might be due to invalid IL or missing references)
//IL_027e: Unknown result type (might be due to invalid IL or missing references)
//IL_0283: Unknown result type (might be due to invalid IL or missing references)
//IL_028a: Unknown result type (might be due to invalid IL or missing references)
//IL_028f: Unknown result type (might be due to invalid IL or missing references)
//IL_0294: Unknown result type (might be due to invalid IL or missing references)
//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
//IL_02de: Unknown result type (might be due to invalid IL or missing references)
//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
RigManager rigManager = Player.RigManager;
Transform val = (((Object)(object)rigManager != (Object)null) ? ((Rig)rigManager.physicsRig).m_chest : null);
foreach (KeyValuePair<Rigidbody, SlingData> item in slung)
{
Rigidbody key = item.Key;
SlingData value = item.Value;
if (!((Object)(object)key == (Object)null) && !((Object)(object)val == (Object)null) && value.Strap != null)
{
value.Strap.SetPoints(((Component)key).transform.TransformPoint(value.Front), ((Component)val).transform.TransformPoint(NeckFrontLeft), ((Component)val).transform.TransformPoint(NeckLeft), ((Component)val).transform.TransformPoint(NeckBack), ((Component)val).transform.TransformPoint(NeckRight), ((Component)val).transform.TransformPoint(NeckFrontRight), ((Component)key).transform.TransformPoint(value.Back), ((Component)val).transform.forward, ((Component)val).transform.right);
}
}
foreach (KeyValuePair<Rigidbody, SlingData> looseStrap in looseStraps)
{
Rigidbody key2 = looseStrap.Key;
SlingData value2 = looseStrap.Value;
if (!((Object)(object)key2 == (Object)null) && value2.Strap != null)
{
Vector3 val2 = ((Component)key2).transform.InverseTransformDirection(Vector3.down);
Vector3 normalized = ((Vector3)(ref val2)).normalized;
Vector3 forward = Vector3.forward;
Vector3 front = value2.Front;
Vector3 back = value2.Back;
Vector3 val3 = (front + back) * 0.5f;
value2.Strap.SetPoints(((Component)key2).transform.TransformPoint(front), ((Component)key2).transform.TransformPoint(Vector3.Lerp(front, val3, 0.25f) + normalized * 0.05f + forward * 0.04f), ((Component)key2).transform.TransformPoint(Vector3.Lerp(front, val3, 0.5f) + normalized * 0.11f + forward * 0.03f), ((Component)key2).transform.TransformPoint(val3 + normalized * 0.14f), ((Component)key2).transform.TransformPoint(Vector3.Lerp(val3, back, 0.5f) + normalized * 0.11f - forward * 0.03f), ((Component)key2).transform.TransformPoint(Vector3.Lerp(val3, back, 0.75f) + normalized * 0.05f - forward * 0.04f), ((Component)key2).transform.TransformPoint(back), ((Component)key2).transform.up, ((Component)key2).transform.right);
}
}
}
private void BeginCapturePoint(Pick which)
{
Gun val = FindHeldGun();
if ((Object)(object)val == (Object)null)
{
((MelonBase)this).LoggerInstance.Warning("Hold a rifle, shotgun, or SMG before capturing a point.");
return;
}
Rigidbody componentInParent = ((Component)val).GetComponentInParent<Rigidbody>();
if ((Object)(object)componentInParent == (Object)null)
{
((MelonBase)this).LoggerInstance.Warning("Could not read the held gun body; point capture cancelled.");
return;
}
pendingCapture = which;
pendingCaptureGun = val;
pendingCaptureBody = componentInParent;
pendingCaptureKey = KeyFor(val);
((MelonBase)this).LoggerInstance.Msg("Move your left controller to the " + which.ToString().ToLowerInvariant() + " sling point and press X to save it.");
}
private void ProcessPendingCapture()
{
//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_00af: 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)
if (!pendingCapture.HasValue)
{
return;
}
BaseController leftController = Player.LeftController;
if ((Object)(object)leftController == (Object)null || !leftController.GetAButtonDown())
{
return;
}
if ((Object)(object)pendingCaptureGun == (Object)null || (Object)(object)pendingCaptureBody == (Object)null || !IsHeld(pendingCaptureGun))
{
((MelonBase)this).LoggerInstance.Warning("Keep the supported gun held while saving the sling point. Capture cancelled.");
ClearPendingCapture();
return;
}
Vector3 value = ((Component)pendingCaptureBody).transform.InverseTransformPoint(((Component)leftController).transform.position);
if (pendingCapture.Value == Pick.Front)
{
frontPoints[pendingCaptureKey] = value;
}
else
{
backPoints[pendingCaptureKey] = value;
}
((MelonBase)this).LoggerInstance.Msg($"{pendingCapture.Value} sling point saved for {pendingCaptureKey}.");
ClearPendingCapture();
}
private void ClearPendingCapture()
{
pendingCapture = null;
pendingCaptureGun = null;
pendingCaptureBody = null;
pendingCaptureKey = null;
}
private void Attach(Gun gun, Rigidbody gunRb, Transform chest, Rigidbody chestBody)
{
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0027: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Unknown result type (might be due to invalid IL or missing references)
//IL_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_008d: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
//IL_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_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
//IL_00b4: 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)
string key = KeyFor(gun);
Vector3 chestLocal = ((Component)chestBody).transform.InverseTransformPoint(chest.TransformPoint(NeckLeft));
Vector3 chestLocal2 = ((Component)chestBody).transform.InverseTransformPoint(chest.TransformPoint(NeckRight));
if (looseStraps.TryGetValue(gunRb, out var value))
{
looseStraps.Remove(gunRb);
value.Joints.Clear();
}
else
{
value = new SlingData
{
Front = (Vector3)(frontPoints.TryGetValue(key, out var value2) ? value2 : new Vector3(0f, 0f, 0.25f)),
Back = (Vector3)(backPoints.TryGetValue(key, out var value3) ? value3 : new Vector3(0f, 0f, -0.2f)),
Strap = new Strap()
};
}
value.Joints.Add(MakeJoint(gunRb, chestBody, value.Front, chestLocal, (float)lengthCm / 100f));
value.Joints.Add(MakeJoint(gunRb, chestBody, value.Back, chestLocal2, (float)lengthCm / 100f));
value.Strap.SetParent(((Component)gunRb).transform);
value.Strap.Go.SetActive(showStrap);
value.Strap.Apply(style);
slung[gunRb] = value;
}
private static ConfigurableJoint MakeJoint(Rigidbody gunRb, Rigidbody chest, Vector3 gunLocalPoint, Vector3 chestLocal, float length)
{
//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_002c: 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_0033: 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_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: 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_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_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_006b: Unknown result type (might be due to invalid IL or missing references)
//IL_0074: 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)
ConfigurableJoint obj = ((Component)gunRb).gameObject.AddComponent<ConfigurableJoint>();
((Joint)obj).connectedBody = chest;
((Joint)obj).autoConfigureConnectedAnchor = false;
((Joint)obj).anchor = gunLocalPoint;
((Joint)obj).connectedAnchor = chestLocal;
ConfigurableJointMotion val = (ConfigurableJointMotion)1;
obj.zMotion = (ConfigurableJointMotion)1;
ConfigurableJointMotion xMotion = (obj.yMotion = val);
obj.xMotion = xMotion;
val = (ConfigurableJointMotion)2;
obj.angularZMotion = (ConfigurableJointMotion)2;
xMotion = (obj.angularYMotion = val);
obj.angularXMotion = xMotion;
SoftJointLimit linearLimit = default(SoftJointLimit);
((SoftJointLimit)(ref linearLimit)).limit = length;
obj.linearLimit = linearLimit;
SoftJointLimitSpring linearLimitSpring = default(SoftJointLimitSpring);
((SoftJointLimitSpring)(ref linearLimitSpring)).spring = 400f;
((SoftJointLimitSpring)(ref linearLimitSpring)).damper = 20f;
obj.linearLimitSpring = linearLimitSpring;
return obj;
}
private void Detach(Rigidbody gunRb)
{
if (slung.TryGetValue(gunRb, out var value))
{
foreach (ConfigurableJoint joint in value.Joints)
{
if ((Object)(object)joint != (Object)null)
{
Object.Destroy((Object)(object)joint);
}
}
value.Strap?.Destroy();
slung.Remove(gunRb);
}
if (looseStraps.TryGetValue(gunRb, out var value2))
{
value2.Strap?.Destroy();
looseStraps.Remove(gunRb);
}
}
private void DetachFromNeck(Rigidbody gunRb)
{
if (!slung.TryGetValue(gunRb, out var value))
{
return;
}
foreach (ConfigurableJoint joint in value.Joints)
{
if ((Object)(object)joint != (Object)null)
{
Object.Destroy((Object)(object)joint);
}
}
value.Joints.Clear();
slung.Remove(gunRb);
looseStraps[gunRb] = value;
}
private void DropAllSlungWithStrap()
{
foreach (Rigidbody item in new List<Rigidbody>(slung.Keys))
{
DetachFromNeck(item);
}
}
private void DetachAll()
{
HashSet<Rigidbody> hashSet = new HashSet<Rigidbody>(slung.Keys);
hashSet.UnionWith(looseStraps.Keys);
foreach (Rigidbody item in hashSet)
{
Detach(item);
}
}
public override void OnSceneWasLoaded(int buildIndex, string sceneName)
{
DetachAll();
}
}
}