using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using Il2Cpp; using Il2CppDG.Tweening; using Il2CppDG.Tweening.Core; using Il2CppDG.Tweening.Plugins.Options; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using InventoryFramework; using MelonLoader; using MelonLoader.Utils; using Microsoft.CodeAnalysis; using MultiSide.shared; using NAudio.Wave; using Newtonsoft.Json; using UnityEngine; using VGltf; using VGltf.Types; using mszguns; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: MelonInfo(typeof(Core), "Miside Zero AK47", "2.0.0", "gameknight963", null)] [assembly: MelonOptionalDependencies(new string[] { "Multiside.shared" })] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("mszguns")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+ea64eccaf8e04528403e11d3d55c582edd51a6b1")] [assembly: AssemblyProduct("mszguns")] [assembly: AssemblyTitle("mszguns")] [assembly: NeutralResourcesLanguage("en-US")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.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 mszguns { public static class AudioImporter { public static AudioClip Load(string filePath) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if (!File.Exists(filePath)) { throw new FileNotFoundException(filePath); } AudioFileReader val = new AudioFileReader(filePath); try { int channels = ((WaveStream)val).WaveFormat.Channels; int sampleRate = ((WaveStream)val).WaveFormat.SampleRate; float[] array = ReadAllSamples(val); AudioClip val2 = AudioClip.Create(Path.GetFileNameWithoutExtension(filePath), array.Length / channels, channels, sampleRate, false); val2.SetData(Il2CppStructArray.op_Implicit(array), 0); return val2; } finally { ((IDisposable)val)?.Dispose(); } } private static float[] ReadAllSamples(AudioFileReader reader) { List list = new List((int)(((Stream)(object)reader).Length / 4)); float[] array = new float[4096]; int num; while ((num = reader.Read(array, 0, array.Length)) > 0) { for (int i = 0; i < num; i++) { list.Add(array[i]); } } return list.ToArray(); } } public class Core : MelonMod { private List guns = new List(); private List gunObjects = new List(); private List gunShots = new List(); private List gunSources = new List(); private static Gun? activeGun; private GameObject? activeGunObject; private AudioSource? activeSource; private SettingsManager? settingsManager; private float fireTimer = 0f; private const string MoveTweenId = "gun_move"; private const string RotateTweenId = "gun_rotate"; public static string ModResources { get; set; } = Path.Combine(MelonEnvironment.ModsDirectory, "mszguns"); public static string? ActiveGunId => activeGun?.Id; public static Texture2D? BulletHoleTexture { get; private set; } public override void OnInitializeMelon() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Expected O, but got Unknown //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown guns = GunLoader.LoadAll(ModResources); foreach (Gun gun in guns) { InventoryManager.Instance.RegisterItem(new ItemDefinition(gun.Id, gun.DisplayName, LoadSprite(GunLoader.GetIconPath(ModResources, gun)))); } InventoryManager.Instance.OnItemSelected += Instance_OnItemSelected; BulletHoleTexture = new Texture2D(2, 2, (TextureFormat)4, false); ImageConversion.LoadImage(BulletHoleTexture, Il2CppStructArray.op_Implicit(File.ReadAllBytes(GunLoader.GetDefaultHolePath(ModResources)))); ((Object)BulletHoleTexture).hideFlags = (HideFlags)32; GunNetworking.Init(ModResources, guns, ((MelonBase)this).LoggerInstance); } public override void OnLateInitializeMelon() { settingsManager = Void.instance.settings; } public override void OnSceneWasLoaded(int buildIndex, string sceneName) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) if (sceneName != "Version 1.9 POST") { return; } Transform transform = ((Component)Camera.main).transform; gunObjects.Clear(); gunShots.Clear(); gunSources.Clear(); foreach (Gun gun in guns) { GameObject val = GunLoader.LoadGun(GunLoader.GetModelPath(ModResources, gun)); val.transform.parent = transform; val.transform.eulerAngles = transform.eulerAngles; val.transform.position = transform.position; Transform transform2 = val.transform; transform2.localPosition += gun.NormalPosition.ToVector3(); val.active = false; AudioClip val2 = AudioImporter.Load(GunLoader.GetAudioPath(ModResources, gun)); AudioSource val3 = val.AddComponent(); val3.clip = val2; val3.volume = gun.AudioVolume; val3.playOnAwake = false; gunObjects.Add(val); gunShots.Add(val2); gunSources.Add(val3); } } public override void OnUpdate() { //IL_0084: 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) if (activeGun == null || (Object)(object)activeGunObject == (Object)null) { return; } InventoryItem selectedItem = InventoryManager.Instance.SelectedItem; if (!(((selectedItem != null) ? selectedItem.Definition.Id : null) != activeGun.Id)) { if (Input.GetMouseButtonDown(1)) { DOTween.Kill(Object.op_Implicit("gun_move"), false); TweenSettingsExtensions.SetId>(TweenSettingsExtensions.SetEase>(ShortcutExtensions.DOLocalMove(activeGunObject.transform, activeGun.AdsPosition.ToVector3(), activeGun.AdsSpeed, false), (Ease)6), "gun_move"); TweenSettingsExtensions.SetId>(TweenSettingsExtensions.SetEase>(ShortcutExtensions.DOFieldOfView(Camera.main, activeGun.AdsFov, activeGun.AdsSpeed), (Ease)6), "gun_move"); } if (Input.GetMouseButtonUp(1)) { DOTween.Kill(Object.op_Implicit("gun_move"), false); TweenSettingsExtensions.SetId>(TweenSettingsExtensions.SetEase>(ShortcutExtensions.DOLocalMove(activeGunObject.transform, activeGun.NormalPosition.ToVector3(), activeGun.AdsSpeed, false), (Ease)6), "gun_move"); TweenSettingsExtensions.SetId>(TweenSettingsExtensions.SetEase>(ShortcutExtensions.DOFieldOfView(Camera.main, settingsManager.fov, activeGun.AdsSpeed), (Ease)6), "gun_move"); } if (Input.GetMouseButton(0) && fireTimer <= 0f) { fireTimer = activeGun.FireRate; Shoot(activeGun, activeGunObject, activeSource, BulletHoleTexture); } fireTimer -= Time.deltaTime; } } private void Shoot(Gun gun, GameObject gunObject, AudioSource source, Texture2D holeTexture) { //IL_005d: 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_012f: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0185: 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) //IL_01b2: 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_01c6: 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_021f: 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_00b7: Unknown result type (might be due to invalid IL or missing references) Gun gun2 = gun; Texture2D holeTexture2 = holeTexture; GameObject gunObject2 = gunObject; source.PlayOneShot(source.clip); switch (gun2.Effect) { case ShotEffect.Normal: { RaycastHit hit = default(RaycastHit); if (Physics.Raycast(((Component)Camera.main).transform.position, ((Component)Camera.main).transform.forward, ref hit, gun2.Range)) { SpawnBulletHole(hit, holeTexture2, gun2.BulletHoleDuration); GunNetworking.Instance?.SendShot(ShotEffect.Normal, ((RaycastHit)(ref hit)).point, ((RaycastHit)(ref hit)).normal, gun2.BulletHoleDuration); } GunNetworking.Instance?.SendFireAudioMessage(); break; } case ShotEffect.Shotgun: Enumerable.Range(0, 8).ToList().ForEach(delegate { //IL_000b: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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_0065: 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_0092: Unknown result type (might be due to invalid IL or missing references) Vector3 val3 = ((Component)Camera.main).transform.forward + new Vector3(Random.Range(-0.1f, 0.1f), Random.Range(-0.1f, 0.1f), 0f); RaycastHit hit2 = default(RaycastHit); if (Physics.Raycast(((Component)Camera.main).transform.position, val3, ref hit2, gun2.Range)) { SpawnBulletHole(hit2, holeTexture2, gun2.BulletHoleDuration); GunNetworking.Instance?.SendShot(ShotEffect.Shotgun, ((RaycastHit)(ref hit2)).point, ((RaycastHit)(ref hit2)).normal, gun2.BulletHoleDuration); } }); GunNetworking.Instance?.SendFireAudioMessage(); break; case ShotEffect.Cube: { GameObject val = GameObject.CreatePrimitive((PrimitiveType)3); val.transform.position = ((Component)Camera.main).transform.position + ((Component)Camera.main).transform.forward; val.transform.localScale = Vector3.one * 0.2f; Rigidbody val2 = val.AddComponent(); val2.velocity = ((Component)Camera.main).transform.forward * 20f; Object.Destroy((Object)(object)val, 5f); GunNetworking.Instance?.SendShot(ShotEffect.Cube, ((Component)Camera.main).transform.position + ((Component)Camera.main).transform.forward, ((Component)Camera.main).transform.forward, 0f); GunNetworking.Instance?.SendFireAudioMessage(); break; } } DOTween.Kill(Object.op_Implicit("gun_rotate"), false); TweenSettingsExtensions.OnComplete>(TweenSettingsExtensions.SetId>(TweenSettingsExtensions.SetEase>(ShortcutExtensions.DOLocalRotate(gunObject2.transform, gun2.RecoilAngle.ToVector3(), gun2.RecoilKickDuration, (RotateMode)0), (Ease)6), "gun_rotate"), TweenCallback.op_Implicit((Action)delegate { //IL_0017: Unknown result type (might be due to invalid IL or missing references) TweenSettingsExtensions.SetId>(TweenSettingsExtensions.SetEase>(ShortcutExtensions.DOLocalRotate(gunObject2.transform, gun2.NormalAngle.ToVector3(), gun2.RecoilRecoverDuration, (RotateMode)0), (Ease)6), "gun_rotate"); })); } private void Instance_OnItemSelected(InventoryItem? item) { InventoryItem item2 = item; if ((Object)(object)Camera.main == (Object)null) { return; } foreach (GameObject gunObject in gunObjects) { gunObject.active = false; } if (item2 == null) { activeGun = null; activeGunObject = null; activeSource = null; Camera.main.fieldOfView = settingsManager.fov; GunNetworking.Instance?.SendEquip(null); return; } int num = guns.FindIndex((Gun g) => g.Id == item2.Definition.Id); if (num != -1) { activeGun = guns[num]; activeGunObject = gunObjects[num]; activeSource = gunSources[num]; activeGunObject.active = true; fireTimer = 0f; GunNetworking.Instance?.SendEquip(activeGun.Id); } } internal static void SpawnBulletHole(Vector3 point, Vector3 normal, Texture2D texture, float duration) { //IL_002f: 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) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0052: 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_0097: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_0112: Unknown result type (might be due to invalid IL or missing references) GameObject hole = GameObject.CreatePrimitive((PrimitiveType)5); ((Object)hole).name = "bullet hole"; hole.transform.position = point + normal * 0.01f; hole.transform.rotation = Quaternion.LookRotation(-normal); hole.transform.Rotate(0f, 0f, Random.Range(0f, 360f)); hole.transform.localScale = Vector3.one * Random.Range(0.1f, 0.3f); Object.Destroy((Object)(object)hole.GetComponent()); MeshRenderer component = hole.GetComponent(); Material val = new Material(Shader.Find("Unlit/Transparent")); val.SetTexture("_MainTex", (Texture)(object)texture); ((Renderer)component).material = val; TweenSettingsExtensions.OnComplete>(TweenSettingsExtensions.SetDelay>(ShortcutExtensions.DOColor(((Renderer)component).material, new Color(1f, 1f, 1f, 0f), 1f), duration), TweenCallback.op_Implicit((Action)delegate { Object.Destroy((Object)(object)hole); })); } private static void SpawnBulletHole(RaycastHit hit, Texture2D texture, float duration) { //IL_0002: 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) SpawnBulletHole(((RaycastHit)(ref hit)).point, ((RaycastHit)(ref hit)).normal, texture, duration); } public Sprite LoadSprite(string path) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0038: 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) byte[] array = File.ReadAllBytes(path); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); ImageConversion.LoadImage(val, Il2CppStructArray.op_Implicit(array)); return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)); } } public static class Extensions { public static Vector3 ToVector3(this float[] arr) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) return new Vector3(arr[0], arr[1], arr[2]); } public static Transform? FindRecursive(this Transform parent, string name) { for (int i = 0; i < parent.childCount; i++) { Transform child = parent.GetChild(i); if (((Object)child).name == name) { return child; } Transform val = child.FindRecursive(name); if ((Object)(object)val != (Object)null) { return val; } } return null; } } internal static class GltfHelpers { public static void BuildNode(GltfContainer container, int nodeIndex, Transform parent) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown Node val = container.Gltf.Nodes[nodeIndex]; GameObject val2 = new GameObject(((GltfChildOfRootProperty)val).Name ?? "Node"); val2.transform.SetParent(parent, false); if (val.Mesh.HasValue) { var (sharedMesh, num) = BuildMesh(container, val.Mesh.Value); val2.AddComponent().sharedMesh = sharedMesh; MeshRenderer val3 = val2.AddComponent(); Material val4 = new Material(Shader.Find("Standard")); if (num.HasValue) { Texture2D val5 = LoadTexture(container, num.Value); if ((Object)(object)val5 != (Object)null) { val4.mainTexture = (Texture)(object)val5; } } ((Renderer)val3).material = val4; } if (val.Children != null) { int[] children = val.Children; foreach (int nodeIndex2 in children) { BuildNode(container, nodeIndex2, val2.transform); } } } public static (Mesh, int?) BuildMesh(GltfContainer container, int meshIndex) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown Mesh val = container.Gltf.Meshes[meshIndex]; Mesh val2 = new Mesh(); PrimitiveType val3 = val.Primitives[0]; int accessorIndex = val3.Attributes["POSITION"]; Vector3[] array = ReadVec3Array(container, accessorIndex); val2.vertices = Il2CppStructArray.op_Implicit(array); if (val3.Attributes.ContainsKey("TEXCOORD_0")) { int accessorIndex2 = val3.Attributes["TEXCOORD_0"]; Vector2[] array2 = ReadVec2Array(container, accessorIndex2); val2.uv = Il2CppStructArray.op_Implicit(array2); } if (val3.Indices.HasValue) { int[] array3 = ReadIntArray(container, val3.Indices.Value); for (int i = 0; i < array3.Length; i += 3) { ref int reference = ref array3[i + 2]; ref int reference2 = ref array3[i]; int num = array3[i]; int num2 = array3[i + 2]; reference = num; reference2 = num2; } val2.triangles = Il2CppStructArray.op_Implicit(array3); } val2.RecalculateNormals(); val2.RecalculateBounds(); return (val2, val3.Material); } public static Texture2D? LoadTexture(GltfContainer container, int materialIndex) { //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Expected O, but got Unknown Material val = container.Gltf.Materials[materialIndex]; if (val.PbrMetallicRoughness?.BaseColorTexture == null) { return null; } int index = ((TextureInfo)val.PbrMetallicRoughness.BaseColorTexture).Index; Texture val2 = container.Gltf.Textures[index]; if (!val2.Source.HasValue) { return null; } Image val3 = container.Gltf.Images[val2.Source.Value]; if (!val3.BufferView.HasValue) { return null; } BufferView val4 = container.Gltf.BufferViews[val3.BufferView.Value]; byte[] sourceArray = container.Buffer.Payload.ToArray(); byte[] array = new byte[val4.ByteLength]; Array.Copy(sourceArray, val4.ByteOffset, array, 0, val4.ByteLength); Texture2D val5 = new Texture2D(2, 2, (TextureFormat)4, false); ImageConversion.LoadImage(val5, Il2CppStructArray.op_Implicit(array)); return val5; } public static Vector2[] ReadVec2Array(GltfContainer container, int accessorIndex) { //IL_008d: 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) Accessor val = container.Gltf.Accessors[accessorIndex]; BufferView val2 = container.Gltf.BufferViews[val.BufferView.Value]; byte[] value = container.Buffer.Payload.ToArray(); int num = val2.ByteOffset + val.ByteOffset; Vector2[] array = (Vector2[])(object)new Vector2[val.Count]; for (int i = 0; i < val.Count; i++) { float num2 = BitConverter.ToSingle(value, num + i * 8); float num3 = BitConverter.ToSingle(value, num + i * 8 + 4); array[i] = new Vector2(num2, 1f - num3); } return array; } public static Vector3[] ReadVec3Array(GltfContainer container, int accessorIndex) { //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) Accessor val = container.Gltf.Accessors[accessorIndex]; BufferView val2 = container.Gltf.BufferViews[val.BufferView.Value]; byte[] value = container.Buffer.Payload.ToArray(); int num = val2.ByteOffset + val.ByteOffset; Vector3[] array = (Vector3[])(object)new Vector3[val.Count]; for (int i = 0; i < val.Count; i++) { float num2 = BitConverter.ToSingle(value, num + i * 12); float num3 = BitConverter.ToSingle(value, num + i * 12 + 4); float num4 = BitConverter.ToSingle(value, num + i * 12 + 8); array[i] = new Vector3(0f - num2, num3, num4); } return array; } public static int[] ReadIntArray(GltfContainer container, int accessorIndex) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Invalid comparison between Unknown and I4 //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Invalid comparison between Unknown and I4 Accessor val = container.Gltf.Accessors[accessorIndex]; BufferView val2 = container.Gltf.BufferViews[val.BufferView.Value]; byte[] value = container.Buffer.Payload.ToArray(); int num = val2.ByteOffset + val.ByteOffset; int[] array = new int[val.Count]; for (int i = 0; i < val.Count; i++) { if ((int)val.ComponentType == 5123) { array[i] = BitConverter.ToUInt16(value, num + i * 2); } else if ((int)val.ComponentType == 5125) { array[i] = (int)BitConverter.ToUInt32(value, num + i * 4); } } return array; } } public class Grip { public string BoneName { get; set; } = ""; public float PositionWeight { get; set; } = 1f; public float RotationWeight { get; set; } = 1f; } public class Gun { public int[] Version { get; set; } = new int[3] { 1, 0, 0 }; public string Id { get; set; } = ""; public string DisplayName { get; set; } = ""; public string ModelFile { get; set; } = ""; public string? AudioFile { get; set; } public string? IconFile { get; set; } public string? HoleFile { get; set; } public float FireRate { get; set; } = 0.1f; public float AudioVolume { get; set; } = 0.5f; public float Damage { get; set; } = 10f; public float Range { get; set; } = 100f; public float AdsSpeed { get; set; } = 0.2f; public float AdsFov { get; set; } = 50f; public float RecoilKickDuration { get; set; } = 0.05f; public float RecoilRecoverDuration { get; set; } = 0.15f; public float BulletHoleDuration { get; set; } = 10f; public float[] NormalPosition { get; set; } = new float[3]; public float[] AdsPosition { get; set; } = new float[3]; public float[] NormalAngle { get; set; } = new float[3]; public float[] RecoilAngle { get; set; } = new float[3]; public ShotEffect Effect { get; set; } = ShotEffect.Normal; } internal static class GunLoader { public static List LoadAll(string modResources) { List list = new List(); string[] directories = Directory.GetDirectories(modResources); foreach (string text in directories) { string path = Path.Combine(text, "gun.json"); if (File.Exists(path)) { Gun gun = JsonConvert.DeserializeObject(File.ReadAllText(path)); if (string.IsNullOrEmpty(gun.Id)) { gun.Id = Path.GetFileName(text); } Gun gun2 = gun; if (gun2.ModelFile == null) { Gun gun3 = gun2; string? obj = Directory.GetFiles(text, "*.glb").FirstOrDefault() ?? ""; string text2 = obj; gun3.ModelFile = obj; } gun2 = gun; if (gun2.AudioFile == null) { Gun gun4 = gun2; string? obj2 = Directory.GetFiles(text, "*.wav").FirstOrDefault() ?? Directory.GetFiles(text, "*.mp3").FirstOrDefault(); string text2 = obj2; gun4.AudioFile = obj2; } gun2 = gun; if (gun2.IconFile == null) { Gun gun5 = gun2; string? obj3 = Directory.GetFiles(text, "icon.*").FirstOrDefault() ?? Directory.GetFiles(text, "*.png").FirstOrDefault(); string text2 = obj3; gun5.IconFile = obj3; } gun2 = gun; if (gun2.HoleFile == null) { string text2 = (gun2.HoleFile = Directory.GetFiles(text, "hole.*").FirstOrDefault()); } list.Add(gun); } } return list; } public static GameObject LoadGun(string path) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Expected O, but got Unknown //IL_0093: 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) GltfContainer val; using (FileStream fileStream = new FileStream(path, FileMode.Open)) { val = GltfContainer.FromGlb((Stream)fileStream); } GameObject val2 = new GameObject("Gun"); if (val.Gltf.Scene.HasValue) { int[] nodes = val.Gltf.Scenes[val.Gltf.Scene.Value].Nodes; foreach (int nodeIndex in nodes) { GltfHelpers.BuildNode(val, nodeIndex, val2.transform); } } val2.transform.localScale = Vector3.one * 0.075f; return val2; } public static string GetModelPath(string modResources, Gun gun) { return Path.IsPathRooted(gun.ModelFile) ? gun.ModelFile : Path.Combine(modResources, gun.Id, gun.ModelFile); } public static string GetAudioPath(string modResources, Gun gun) { return (gun.AudioFile != null && Path.IsPathRooted(gun.AudioFile)) ? gun.AudioFile : Fallback(modResources, gun.Id, gun.AudioFile ?? "shot.wav", "shot.wav"); } public static string GetIconPath(string modResources, Gun gun) { return (gun.IconFile != null && Path.IsPathRooted(gun.IconFile)) ? gun.IconFile : Fallback(modResources, gun.Id, gun.IconFile ?? "icon.png", "icon.png"); } public static string GetHolePath(string modResources, Gun gun) { return (gun.HoleFile != null && Path.IsPathRooted(gun.HoleFile)) ? gun.HoleFile : Fallback(modResources, gun.Id, gun.HoleFile ?? "hole.png", "hole.png"); } public static string GetDefaultHolePath(string modResources) { return Path.Combine(modResources, "hole.png"); } private static string Fallback(string modResources, string gunId, string file, string fallback) { string text = Path.Combine(modResources, gunId, file); return File.Exists(text) ? text : Path.Combine(modResources, fallback); } } public class GunNetworking { private class GunNetworkLogger { [CompilerGenerated] [DebuggerBrowsable(DebuggerBrowsableState.Never)] private Instance P; public bool _loggingEnabled; public GunNetworkLogger(Instance logger) { P = logger; _loggingEnabled = false; base..ctor(); } public void SetLoggingEnabled(bool enabled) { _loggingEnabled = enabled; } public void Msg(object obj) { if (_loggingEnabled) { P.Msg(obj); } } public void Warning(object obj) { if (_loggingEnabled) { P.Warning(obj); } } public void Error(object obj) { if (_loggingEnabled) { P.Warning(obj); } } } private readonly Dictionary _remoteGuns = new Dictionary(); private readonly Dictionary> _remoteGunObjects = new Dictionary>(); private readonly string _modResources; private readonly List _guns; private GunNetworkLogger? _logger; private bool _loggingEnabled = false; public static GunNetworking? Instance { get; private set; } public bool LoggingEnabled { get { return _loggingEnabled; } set { _loggingEnabled = value; _logger?.SetLoggingEnabled(value); } } private GunNetworking(string modResources, List guns) { _modResources = modResources; _guns = guns; } public static void Init(string modResources, List guns, Instance logger) { if (AppDomain.CurrentDomain.GetAssemblies().Any((Assembly a) => a.GetName().Name == "Multiside.shared")) { Instance = new GunNetworking(modResources, guns); Instance._logger = new GunNetworkLogger(logger); Instance._logger.SetLoggingEnabled(Instance.LoggingEnabled); Instance._logger.Msg("Starting in Online mode"); Instance.InitNetwork(); } } private void InitNetwork() { if (NetworkRegistry.Provider != null) { Subscribe(NetworkRegistry.Provider); } else { NetworkRegistry.OnProviderRegistered += Subscribe; } } private void Subscribe(INetworkProvider provider) { INetworkProvider provider2 = provider; _logger?.Msg("GunNetworking: subscribing to network events"); provider2.OnReceived += delegate(int actor, string channel, object data) { //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01de: 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) if (channel == "mszguns.equip") { string text = (string)data; _logger?.Msg($"GunNetworking: equip received from {actor}: '{text}'"); if (string.IsNullOrEmpty(text)) { _remoteGuns.Remove(actor); } else { _remoteGuns[actor] = text; } GameObject playerObject = provider2.GetPlayerObject(actor); if ((Object)(object)playerObject == (Object)null) { _logger?.Warning($"GunNetworking: no player object for actor {actor}"); } else { SetRemoteGun(actor, playerObject, text); } } else if (channel == "mszguns.audio") { GameObject playerObject2 = provider2.GetPlayerObject(actor); if ((Object)(object)playerObject2 != (Object)null) { PlayRemoteShot(playerObject2); } } else if (!(channel != "mszguns.shot")) { float[] array = (float[])data; ShotEffect shotEffect = (ShotEffect)array[7]; if (shotEffect == ShotEffect.Cube) { SpawnRemoteCube(new Vector3(array[0], array[1], array[2]), new Vector3(array[3], array[4], array[5])); } else if (array.Length >= 7 && !((Object)(object)Core.BulletHoleTexture == (Object)null)) { Core.SpawnBulletHole(new Vector3(array[0], array[1], array[2]), new Vector3(array[3], array[4], array[5]), Core.BulletHoleTexture, array[6]); } } }; provider2.OnPlayerLeft += delegate(int actor) { _logger?.Msg($"GunNetworking: player {actor} left, cleaning up"); _remoteGuns.Remove(actor); _remoteGunObjects.Remove(actor); }; provider2.OnRoomJoined += delegate { _logger?.Msg("GunNetworking: room joined, broadcasting equip: '" + Core.ActiveGunId + "'"); SendEquip(Core.ActiveGunId); }; provider2.OnPlayerJoined += delegate(int actor) { _logger?.Msg($"GunNetworking: player {actor} joined, sending equip: '{Core.ActiveGunId}'"); if (!string.IsNullOrEmpty(Core.ActiveGunId)) { provider2.SendTo(actor, "mszguns.equip", (object)Core.ActiveGunId, true); } }; } public void SendFireAudioMessage() { INetworkProvider provider = NetworkRegistry.Provider; if (provider != null) { provider.Send("mszguns.audio", (object)(-1), true); } } private void SetRemoteGun(int actor, GameObject playerObj, string gunId) { //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) string gunId2 = gunId; _logger?.Msg($"GunNetworking: setting remote gun for actor {actor}: '{gunId2}'"); if (_remoteGunObjects.TryGetValue(actor, out Dictionary value)) { foreach (GameObject value3 in value.Values) { value3.SetActive(false); } if (!string.IsNullOrEmpty(gunId2) && value.TryGetValue(gunId2, out var value2)) { _logger?.Msg("GunNetworking: using cached model for '" + gunId2 + "'"); value2.SetActive(true); UpdateAudioClip(playerObj, gunId2); return; } } if (string.IsNullOrEmpty(gunId2)) { return; } Gun gun = _guns.FirstOrDefault((Gun g) => g.Id == gunId2); if (gun == null) { _logger?.Warning("GunNetworking: gun '" + gunId2 + "' not found in registry"); return; } _logger?.Msg("GunNetworking: loading model for '" + gunId2 + "'"); GameObject val = GunLoader.LoadGun(GunLoader.GetModelPath(_modResources, gun)); ((Object)val).name = "RemoteGun"; Transform val2 = playerObj.transform.Find("Zero/PLAYER Armature/Rig Root/Hips/Spine/Chest/Neck2/Neck1/Head/CameraHoldHead/playerCamera"); if ((Object)(object)val2 == (Object)null) { _logger?.Warning($"GunNetworking: could not find camera transform on actor {actor}, parenting to root"); } val.transform.SetParent(val2 ?? playerObj.transform, false); val.transform.localPosition = gun.NormalPosition.ToVector3(); val.transform.localEulerAngles = gun.NormalAngle.ToVector3(); if (!_remoteGunObjects.ContainsKey(actor)) { _remoteGunObjects[actor] = new Dictionary(); } _remoteGunObjects[actor][gunId2] = val; UpdateAudioClip(playerObj, gunId2); } private void UpdateAudioClip(GameObject playerObj, string gunId) { string gunId2 = gunId; Gun gun = _guns.FirstOrDefault((Gun g) => g.Id == gunId2); if (gun == null) { _logger?.Warning("HandleGunAudio: gun '" + gunId2 + "' not found"); return; } AudioSource val = playerObj.GetComponent(); if ((Object)(object)val == (Object)null) { _logger?.Msg("GunNetworking: adding AudioSource to player object for '" + gunId2 + "'"); val = playerObj.AddComponent(); val.spatialBlend = 1f; val.maxDistance = 50f; val.rolloffMode = (AudioRolloffMode)1; } if ((Object)(object)val.clip == (Object)null || ((Object)val.clip).name != gun.Id) { val.clip = AudioImporter.Load(GunLoader.GetAudioPath(_modResources, gun)); } } private void PlayRemoteShot(GameObject playerObj) { AudioSource component = playerObj.GetComponent(); component.PlayOneShot(component.clip); } private static void SpawnRemoteCube(Vector3 spawnPos, Vector3 spawnDir) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) GameObject val = GameObject.CreatePrimitive((PrimitiveType)3); val.transform.position = spawnPos; val.transform.localScale = Vector3.one * 0.2f; Rigidbody val2 = val.AddComponent(); val2.velocity = spawnDir * 20f; Object.Destroy((Object)(object)val, 5f); } public void SendShot(ShotEffect effect, Vector3 pos, Vector3 dir, float duration) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002b: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) INetworkProvider provider = NetworkRegistry.Provider; if (provider != null) { provider.Send("mszguns.shot", (object)new float[8] { pos.x, pos.y, pos.z, dir.x, dir.y, dir.z, duration, (float)effect }, true); } } public void SendEquip(string? gunId) { INetworkProvider provider = NetworkRegistry.Provider; if (provider != null) { provider.Send("mszguns.equip", (object)(gunId ?? ""), true); } } } public enum ShotEffect { Normal, Shotgun, Cube } }