Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of MoreGuns Arsenal v1.0.0
LordValdomod.MoreGuns.dll
Decompiled 3 hours ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using MoreGuns.Weapons.GravityGun; using MoreGuns.Weapons.ShrinkGun; using MoreGuns.Weapons.SlimeGun; using MoreGuns.Weapons.VoidGun; using Photon.Pun; using REPOLib.Modules; using UnityEngine; using UnityEngine.Audio; using UnityEngine.Events; using UnityEngine.Rendering; [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("LordValdomod.MoreGuns")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("LordValdomod.MoreGuns")] [assembly: AssemblyTitle("LordValdomod.MoreGuns")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.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; } } [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public string AssemblyName { get; } public IgnoresAccessChecksToAttribute(string assemblyName) { AssemblyName = assemblyName; } } } namespace MoreGuns { [HarmonyPatch(typeof(PlayerController), "Update")] internal static class DebugSpawner { private static int _next; private static void Postfix() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) if (Plugin.DebugSpawnEnabled.Value && Input.GetKeyDown(Plugin.DebugSpawnKey.Value)) { Spawn(); } } private static void Spawn() { //IL_009c: 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_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer()) { Plugin.Log.LogWarning((object)"Debug spawn is host only."); } else if (!SemiFunc.MenuLevel() && !((Object)(object)LevelGenerator.Instance == (Object)null) && LevelGenerator.Instance.Generated && (!((Object)(object)ChatManager.instance != (Object)null) || !ChatManager.instance.chatActive) && WeaponRegistry.Items.Count != 0) { Camera main = Camera.main; if (!((Object)(object)main == (Object)null)) { Item val = WeaponRegistry.Items[_next % WeaponRegistry.Items.Count]; _next++; Vector3 val2 = ((Component)main).transform.position + ((Component)main).transform.forward * 1.5f; Quaternion val3 = Quaternion.LookRotation(((Component)main).transform.forward) * val.spawnRotationOffset; GameObject val4 = Items.SpawnItem(val, val2, val3); Plugin.Log.LogInfo((object)(((Object)(object)val4 != (Object)null) ? ("Debug spawned " + val.itemName + ".") : ("Debug spawn failed: " + val.itemName + "."))); } } } } internal static class GameAudio { internal static AudioMixerGroup DefaultMixerGroup { get { if ((Object)(object)AudioManager.instance == (Object)null || (Object)(object)AudioManager.instance.AudioDefault == (Object)null) { return null; } AudioSource component = AudioManager.instance.AudioDefault.GetComponent<AudioSource>(); if (!((Object)(object)component != (Object)null)) { return null; } return component.outputAudioMixerGroup; } } internal static Sound MakeSound(AudioClip clip, float volume, float pitchRandom = 0.05f) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0023: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)clip == (Object)null) { return null; } Sound val = new Sound(); val.Sounds = (AudioClip[])(object)new AudioClip[1] { clip }; val.Type = (AudioType)0; val.Volume = volume; val.VolumeRandom = 0.05f; val.Pitch = 1f; val.PitchRandom = pitchRandom; val.SpatialBlend = 1f; return val; } internal static AudioSource CreateLoopSource(GameObject host, AudioClip clip, float volume) { if ((Object)(object)clip == (Object)null) { return null; } AudioSource obj = host.AddComponent<AudioSource>(); obj.clip = clip; obj.loop = true; obj.volume = 0f; obj.spatialBlend = 1f; obj.rolloffMode = (AudioRolloffMode)1; obj.minDistance = 2f; obj.maxDistance = 25f; obj.dopplerLevel = 0f; obj.outputAudioMixerGroup = DefaultMixerGroup; obj.Play(); return obj; } } [HarmonyPatch(typeof(PlayerController), "Update")] internal static class GunInspector { private const float RotateSpeed = 1f; private static Transform _model; private static Transform _gunRoot; private static Transform _originalParent; private static Vector3 _originalLocalPos; private static Quaternion _originalLocalRot; private static Vector3 _originalLocalScale; private static GameObject _anchor; private static Transform _pivot; private static Light _light; private static float _distance; private static float _minDistance; private static float _maxDistance; private static float _yaw; private static float _pitch; private static void Postfix() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_model != (Object)null && (Object)(object)_gunRoot == (Object)null) { Object.Destroy((Object)(object)((Component)_model).gameObject); Cleanup(); } else if (!Plugin.InspectEnabled.Value || !Input.GetKey(Plugin.InspectKey.Value) || !CanInspect()) { if ((Object)(object)_model != (Object)null || (Object)(object)_anchor != (Object)null) { Stop(); } } else if (!((Object)(object)_model == (Object)null) || TryStart()) { Tick(); } } private static bool CanInspect() { if (SemiFunc.MenuLevel()) { return false; } if ((Object)(object)ChatManager.instance != (Object)null && ChatManager.instance.chatActive) { return false; } return (Object)(object)Camera.main != (Object)null; } private static bool TryStart() { //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_0092: 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_00aa: 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_00fb: Expected O, but got Unknown //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_0190: 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_01a0: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: 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_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_01ed: 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_020c: Unknown result type (might be due to invalid IL or missing references) PhysGrabber instance = PhysGrabber.instance; if ((Object)(object)instance == (Object)null || !instance.grabbed || (Object)(object)instance.grabbedPhysGrabObject == (Object)null) { return false; } Transform transform = ((Component)instance.grabbedPhysGrabObject).transform; Transform val = FindModel(transform); if ((Object)(object)val == (Object)null) { return false; } Camera main = Camera.main; _gunRoot = transform; _model = val; _originalParent = val.parent; _originalLocalPos = val.localPosition; _originalLocalRot = val.localRotation; _originalLocalScale = val.localScale; Bounds val2 = WorldBounds(val); float num = Mathf.Max(0.05f, Mathf.Max(((Bounds)(ref val2)).size.x, Mathf.Max(((Bounds)(ref val2)).size.y, ((Bounds)(ref val2)).size.z))); _distance = num * 1.5f; _minDistance = num * 0.6f; _maxDistance = num * 4f; _anchor = new GameObject("MoreGunsInspectAnchor"); _anchor.transform.SetParent(((Component)main).transform, false); _anchor.transform.localPosition = new Vector3(0f, 0f, _distance); _pivot = new GameObject("Pivot").transform; _pivot.SetParent(_anchor.transform, false); val.SetParent(_pivot, true); val.localRotation = Quaternion.Euler(0f, 90f, 0f); val.localPosition = Vector3.zero; Vector3 position = val.position; Vector3 position2 = _pivot.position; Bounds val3 = WorldBounds(val); val.position = position + (position2 - ((Bounds)(ref val3)).center); _yaw = 0f; _pitch = 0f; GameObject val4 = new GameObject("InspectLight"); val4.transform.SetParent(((Component)main).transform, false); val4.transform.localPosition = new Vector3(0.3f, 0.4f, 0f); val4.transform.SetParent(_anchor.transform, true); _light = val4.AddComponent<Light>(); _light.type = (LightType)2; _light.range = num * 6f; _light.intensity = 2.5f; _light.shadows = (LightShadows)0; return true; } private static void Tick() { //IL_001c: 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_0027: 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_0073: 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_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)InputManager.instance != (Object)null) { InputManager.instance.DisableAiming(0.15f); } Vector2 val = MouseDelta(); _yaw -= val.x * 1f; _pitch = Mathf.Clamp(_pitch + val.y * 1f, -89f, 89f); _pivot.localRotation = Quaternion.Euler(_pitch, 0f, 0f) * Quaternion.Euler(0f, _yaw, 0f); float y = Input.mouseScrollDelta.y; if (Mathf.Abs(y) > 0.01f) { _distance = Mathf.Clamp(_distance * (1f - y * 0.1f), _minDistance, _maxDistance); } Vector3 localPosition = _anchor.transform.localPosition; localPosition.z = Mathf.Lerp(localPosition.z, _distance, 1f - Mathf.Exp(-12f * Time.deltaTime)); _anchor.transform.localPosition = localPosition; } private static Vector2 MouseDelta() { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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) InputManager instance = InputManager.instance; if ((Object)(object)instance != (Object)null && instance.inputActions != null && instance.inputActions.TryGetValue((InputKey)16, out var value)) { return value.ReadValue<Vector2>() * Mathf.Max(0.02f, instance.mouseSensitivity) * 2f; } return Vector2.zero; } private static void Stop() { //IL_002f: 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_004d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_model != (Object)null && (Object)(object)_originalParent != (Object)null) { _model.SetParent(_originalParent, false); _model.localPosition = _originalLocalPos; _model.localRotation = _originalLocalRot; _model.localScale = _originalLocalScale; } Cleanup(); } private static void Cleanup() { if ((Object)(object)_anchor != (Object)null) { Object.Destroy((Object)(object)_anchor); } _anchor = null; _pivot = null; _light = null; _model = null; _gunRoot = null; _originalParent = null; } private static Transform FindModel(Transform root) { Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true); foreach (Transform val in componentsInChildren) { if (!((Object)(object)val == (Object)(object)root)) { string name = ((Object)val).name; if (name.EndsWith("Model") && name.Contains("Gun") && (Object)(object)((Component)val).GetComponentInChildren<Renderer>() != (Object)null) { return val; } } } return null; } private static Bounds WorldBounds(Transform t) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0040: Unknown result type (might be due to invalid IL or missing references) bool flag = false; Bounds bounds = default(Bounds); ((Bounds)(ref bounds))..ctor(t.position, Vector3.zero); Renderer[] componentsInChildren = ((Component)t).GetComponentsInChildren<Renderer>(); foreach (Renderer val in componentsInChildren) { if (!(val is ParticleSystemRenderer) && val.enabled) { if (!flag) { bounds = val.bounds; flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val.bounds); } } } return bounds; } } internal static class ItemCloner { private static GameObject _holder; internal static Transform Holder { get { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)_holder == (Object)null) { _holder = new GameObject("MoreGunsPrefabs"); _holder.SetActive(false); Object.DontDestroyOnLoad((Object)(object)_holder); } return _holder.transform; } } internal static bool TryFindBase(StatsManager stats, Func<GameObject, bool> match, out Item item, out GameObject prefab) { item = null; prefab = null; foreach (Item value in stats.itemDictionary.Values) { if (!((Object)(object)value == (Object)null) && value.prefab != null) { GameObject val = null; try { val = ((PrefabRef<GameObject>)(object)value.prefab).Prefab; } catch { } if ((Object)(object)val != (Object)null && match(val)) { item = value; prefab = val; return true; } } } return false; } internal static GameObject ClonePrefab(GameObject prefab, string name) { GameObject obj = Object.Instantiate<GameObject>(prefab, Holder); ((Object)obj).name = name; return obj; } internal static Item CloneItem(Item baseItem, string assetName, string displayName, string description) { Item obj = Object.Instantiate<Item>(baseItem); ((Object)obj).name = assetName; obj.itemName = displayName; obj.description = description; obj.itemNameLocalized = null; return obj; } } internal static class ModAssets { internal static T Load<T>(string name) where T : Object { if ((Object)(object)Plugin.Bundle == (Object)null) { return default(T); } T val = Plugin.Bundle.LoadAsset<T>(name); if ((Object)(object)val == (Object)null) { Plugin.Log.LogDebug((object)("Asset not in bundle: " + name)); } return val; } } internal static class ModelSwap { internal static bool Apply(GameObject gunObject, string modelAssetName, Transform muzzle, float scaleMultiplier, float yawOffset) { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) GameObject val = ModAssets.Load<GameObject>(modelAssetName); if ((Object)(object)val == (Object)null) { return false; } Transform transform = gunObject.transform; Material val2 = null; Renderer[] componentsInChildren = gunObject.GetComponentsInChildren<Renderer>(true); foreach (Renderer val3 in componentsInChildren) { if (val3 is MeshRenderer || val3 is SkinnedMeshRenderer) { if ((Object)(object)val2 == (Object)null) { val2 = val3.sharedMaterial; } val3.enabled = false; } } bool has = false; Bounds total = default(Bounds); Collider[] componentsInChildren2 = gunObject.GetComponentsInChildren<Collider>(true); foreach (Collider val4 in componentsInChildren2) { if (!val4.isTrigger) { Bounds? val5 = LocalColliderBounds(val4); if (val5.HasValue) { Encapsulate(ref total, ref has, val5.Value, ((Component)val4).transform, transform); } } } GameObject val6 = Object.Instantiate<GameObject>(val, transform, false); ((Object)val6).name = modelAssetName; componentsInChildren2 = val6.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } Fit(val6.transform, transform, muzzle, has ? new Bounds?(total) : ((Bounds?)null), scaleMultiplier, yawOffset); if ((Object)(object)val2 != (Object)null) { ApplyGameShader(val6, val2); } Plugin.Log.LogInfo((object)("Custom model applied: " + modelAssetName)); return true; } private static Bounds? LocalColliderBounds(Collider col) { //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) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_005f: 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_0079: 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_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_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_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) BoxCollider val = (BoxCollider)(object)((col is BoxCollider) ? col : null); if (val == null) { SphereCollider val2 = (SphereCollider)(object)((col is SphereCollider) ? col : null); if (val2 == null) { CapsuleCollider val3 = (CapsuleCollider)(object)((col is CapsuleCollider) ? col : null); if (val3 == null) { MeshCollider val4 = (MeshCollider)(object)((col is MeshCollider) ? col : null); if (val4 != null && (Object)(object)val4.sharedMesh != (Object)null) { return val4.sharedMesh.bounds; } return null; } Vector3 val5 = Vector3.one * val3.radius * 2f; ((Vector3)(ref val5))[val3.direction] = Mathf.Max(val3.height, val3.radius * 2f); return new Bounds(val3.center, val5); } return new Bounds(val2.center, Vector3.one * val2.radius * 2f); } return new Bounds(val.center, val.size); } private static Mesh GetMesh(Renderer renderer) { SkinnedMeshRenderer val = (SkinnedMeshRenderer)(object)((renderer is SkinnedMeshRenderer) ? renderer : null); if (val != null) { return val.sharedMesh; } MeshFilter component = ((Component)renderer).GetComponent<MeshFilter>(); if (!((Object)(object)component != (Object)null)) { return null; } return component.sharedMesh; } private static void Encapsulate(ref Bounds total, ref bool has, Bounds local, Transform from, Transform to) { //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_000a: 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_0014: 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_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_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_0047: 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_0052: 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_0059: 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_0060: 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) Vector3 center = ((Bounds)(ref local)).center; Vector3 extents = ((Bounds)(ref local)).extents; for (int i = 0; i < 8; i++) { Vector3 val = center + Vector3.Scale(extents, new Vector3((float)(((i & 1) != 0) ? 1 : (-1)), (float)(((i & 2) != 0) ? 1 : (-1)), (float)(((i & 4) != 0) ? 1 : (-1)))); Vector3 val2 = to.InverseTransformPoint(from.TransformPoint(val)); if (!has) { total = new Bounds(val2, Vector3.zero); has = true; } else { ((Bounds)(ref total)).Encapsulate(val2); } } } private static void Fit(Transform model, Transform root, Transform muzzle, Bounds? target, float scaleMultiplier, float yawOffset) { //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_0009: 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_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_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_0046: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007e: 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_003c: 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_0096: 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_00f0: 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_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0111: 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_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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_0187: 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) Vector3 val = (((Object)(object)muzzle != (Object)null) ? root.InverseTransformDirection(muzzle.forward) : Vector3.forward); Vector3 val2 = Vector3.ProjectOnPlane(Vector3.up, val); if (((Vector3)(ref val2)).sqrMagnitude < 0.001f) { val2 = Vector3.ProjectOnPlane(Vector3.forward, val); } model.localRotation = Quaternion.LookRotation(((Vector3)(ref val)).normalized, ((Vector3)(ref val2)).normalized) * Quaternion.Euler(0f, yawOffset, 0f); model.localScale = Vector3.one; model.localPosition = Vector3.zero; if (!target.HasValue) { return; } bool has = false; Bounds total = default(Bounds); Renderer[] componentsInChildren = ((Component)model).GetComponentsInChildren<Renderer>(true); foreach (Renderer val3 in componentsInChildren) { Mesh mesh = GetMesh(val3); if ((Object)(object)mesh != (Object)null) { Encapsulate(ref total, ref has, mesh.bounds, ((Component)val3).transform, root); } } if (has) { Bounds value = target.Value; float num = Mathf.Max(((Bounds)(ref value)).size.x, Mathf.Max(((Bounds)(ref value)).size.y, ((Bounds)(ref value)).size.z)); float num2 = Mathf.Max(((Bounds)(ref total)).size.x, Mathf.Max(((Bounds)(ref total)).size.y, ((Bounds)(ref total)).size.z)); if (!(num2 < 0.0001f)) { float num3 = num / num2 * scaleMultiplier; model.localScale = Vector3.one * num3; model.localPosition = ((Bounds)(ref value)).center - ((Bounds)(ref total)).center * num3; } } } private static void ApplyGameShader(GameObject model, Material template) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_0029: 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_005a: Expected O, but got Unknown //IL_0072: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = model.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { Material[] sharedMaterials = val.sharedMaterials; for (int j = 0; j < sharedMaterials.Length; j++) { Material val2 = sharedMaterials[j]; Material val3 = new Material(template) { name = "MoreGuns_" + (((Object)(object)val2 != (Object)null) ? ((Object)val2).name : j.ToString()) }; Texture mainTexture = (((Object)(object)val2 != (Object)null) ? val2.mainTexture : null); try { val3.color = Color.white; } catch { } try { val3.mainTexture = mainTexture; val3.mainTextureScale = Vector2.one; val3.mainTextureOffset = Vector2.zero; } catch { } if (val3.HasProperty("_EmissionMap")) { val3.SetTexture("_EmissionMap", (Texture)null); } if (val3.HasProperty("_EmissionColor")) { val3.SetColor("_EmissionColor", Color.black); } sharedMaterials[j] = val3; } val.sharedMaterials = sharedMaterials; } } } [HarmonyPatch(typeof(StatsManager), "LoadItemsFromFolder")] internal static class StatsManagerLoadItemsPatch { private static void Postfix(StatsManager __instance) { WeaponRegistry.RegisterAll(__instance); } } [HarmonyPatch(typeof(ItemGun), "ShootBulletRPC")] internal static class ItemGunShootBulletPatch { private static void Postfix(ItemGun __instance, Vector3 _endPosition, bool _hit, int _shooterID) { //IL_0026: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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) if (!((Object)(object)__instance.gunMuzzle == (Object)null)) { GravityGunBehaviour component = ((Component)__instance).GetComponent<GravityGunBehaviour>(); if ((Object)(object)component != (Object)null) { component.OnBulletFired(__instance.gunMuzzle.position, _endPosition, _hit, _shooterID); } VoidGunBehaviour component2 = ((Component)__instance).GetComponent<VoidGunBehaviour>(); if ((Object)(object)component2 != (Object)null) { component2.OnBulletFired(__instance.gunMuzzle.position, _endPosition); } SlimeGunBehaviour component3 = ((Component)__instance).GetComponent<SlimeGunBehaviour>(); if ((Object)(object)component3 != (Object)null) { component3.OnBulletFired(__instance.gunMuzzle); } ShrinkGunBehaviour component4 = ((Component)__instance).GetComponent<ShrinkGunBehaviour>(); if ((Object)(object)component4 != (Object)null) { component4.OnBulletFired(__instance.gunMuzzle.position, _endPosition, _shooterID); } } } } [BepInPlugin("LordValdomod.MoreGuns", "MoreGuns", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "LordValdomod.MoreGuns"; public const string Name = "MoreGuns"; public const string Version = "1.0.0"; internal static ManualLogSource Log; internal static AssetBundle Bundle; internal static ConfigEntry<bool> DebugSpawnEnabled; internal static ConfigEntry<KeyCode> DebugSpawnKey; internal static ConfigEntry<bool> InspectEnabled; internal static ConfigEntry<KeyCode> InspectKey; private void Awake() { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; DebugSpawnEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "SpawnKeyEnabled", false, "Host only: spawns a MoreGuns weapon in front of you when pressing the key in a level. Each press cycles to the next weapon."); DebugSpawnKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Debug", "SpawnKey", (KeyCode)289, "Key used to spawn weapons."); InspectEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "InspectKeyEnabled", false, "Hold the key while holding a MoreGuns weapon to inspect it up close (mouse rotates, scroll zooms)."); InspectKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Debug", "InspectKey", (KeyCode)290, "Key held to inspect the held weapon."); GravityGunConfig.Bind(((BaseUnityPlugin)this).Config); VoidGunConfig.Bind(((BaseUnityPlugin)this).Config); SlimeGunConfig.Bind(((BaseUnityPlugin)this).Config); ShrinkGunConfig.Bind(((BaseUnityPlugin)this).Config); LoadBundle(); new Harmony("LordValdomod.MoreGuns").PatchAll(); Log.LogInfo((object)"MoreGuns 1.0.0 loaded."); } private void LoadBundle() { string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? string.Empty, "moreguns"); if (!File.Exists(text)) { Log.LogWarning((object)("No asset bundle found at " + text + ", using placeholder visuals.")); return; } Bundle = AssetBundle.LoadFromFile(text); if ((Object)(object)Bundle == (Object)null) { Log.LogWarning((object)"Failed to load asset bundle."); } else { Log.LogInfo((object)("Asset bundle loaded: " + string.Join(", ", Bundle.GetAllAssetNames()))); } } } internal static class WeaponParts { internal static GameObject CreateHarmlessBullet(GameObject baseBullet, string name, Color color, bool hideLine = false) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected O, but got Unknown //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Expected O, but got Unknown //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_0160: 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) GameObject val = ItemCloner.ClonePrefab(baseBullet, name); HurtCollider[] componentsInChildren = val.GetComponentsInChildren<HurtCollider>(true); foreach (HurtCollider obj in componentsInChildren) { obj.playerLogic = false; obj.physLogic = false; obj.enemyLogic = false; obj.onImpactAny = new UnityEvent(); obj.onImpactPlayer = new UnityEvent(); obj.onImpactPhysObject = new UnityEvent(); obj.onImpactEnemy = new UnityEvent(); } LineRenderer[] componentsInChildren2 = val.GetComponentsInChildren<LineRenderer>(true); foreach (LineRenderer val2 in componentsInChildren2) { val2.startColor = color; val2.endColor = color; if (hideLine) { val2.startWidth = 0f; val2.endWidth = 0f; val2.widthMultiplier = 0f; } Material material = ((Renderer)val2).material; if ((Object)(object)material != (Object)null && material.HasProperty("_Color")) { material.color = color; } if ((Object)(object)material != (Object)null && material.HasProperty("_EmissionColor")) { material.SetColor("_EmissionColor", color * 2f); } } Light[] componentsInChildren3 = val.GetComponentsInChildren<Light>(true); foreach (Light val3 in componentsInChildren3) { val3.color = color; if (hideLine) { val3.intensity = 0f; } } ParticleSystem[] componentsInChildren4 = val.GetComponentsInChildren<ParticleSystem>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { MainModule main = componentsInChildren4[i].main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(color); if (hideLine) { ((MainModule)(ref main)).maxParticles = 0; } } return val; } internal static void TintPlaceholder(GameObject gunObject, Color color, float amount) { //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_0059: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = gunObject.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!(val is MeshRenderer) && !(val is SkinnedMeshRenderer)) { continue; } Material[] materials = val.materials; Material[] array = materials; foreach (Material val2 in array) { if ((Object)(object)val2 != (Object)null && val2.HasProperty("_Color")) { val2.color = Color.Lerp(val2.color, color, amount); } } val.materials = materials; } } internal static Light AddGlow(GameObject gunObject, ItemGun gun, string name, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0054: 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) GameObject val = new GameObject(name); val.transform.SetParent(gunObject.transform, false); if ((Object)(object)gun != (Object)null && (Object)(object)gun.gunMuzzle != (Object)null) { val.transform.position = gun.gunMuzzle.position; } Light obj = val.AddComponent<Light>(); obj.type = (LightType)2; obj.color = color; obj.range = 2f; obj.intensity = 0f; obj.shadows = (LightShadows)0; return obj; } internal static void ReplaceShotSound(ItemGun gun, AudioClip clip, float volume) { if (!((Object)(object)clip == (Object)null)) { if (gun.soundShoot != null) { gun.soundShoot.Sounds = (AudioClip[])(object)new AudioClip[1] { clip }; gun.soundShoot.Volume = volume; } if (gun.soundShootGlobal != null) { gun.soundShootGlobal.Sounds = (AudioClip[])(object)new AudioClip[0]; } } } internal static Transform FindDeep(Transform parent, string name) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if (((Object)parent).name == name) { return parent; } foreach (Transform item in parent) { Transform val = FindDeep(item, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } } internal static class WeaponRegistry { internal static readonly List<Item> Items = new List<Item>(); private static bool _registered; internal static void RegisterAll(StatsManager stats) { if (!_registered && !((Object)(object)stats == (Object)null)) { _registered = true; Add(GravityGunWeapon.Register(stats)); Add(VoidGunWeapon.Register(stats)); Add(SlimeGunWeapon.Register(stats)); Add(ShrinkGunWeapon.Register(stats)); } } private static void Add(Item item) { if ((Object)(object)item != (Object)null) { Items.Add(item); } } } } namespace MoreGuns.Weapons.VoidGun { internal class VoidController : MonoBehaviour { private class Capture { public Enemy Enemy; public float Duration; public float Timer; public float StartY; } private static VoidController _instance; private readonly List<Capture> _captures = new List<Capture>(); internal static VoidController Instance { get { //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_001d: Expected O, but got Unknown if ((Object)(object)_instance == (Object)null) { GameObject val = new GameObject("MoreGunsVoidController"); Object.DontDestroyOnLoad((Object)val); _instance = val.AddComponent<VoidController>(); } return _instance; } } internal bool IsCapturing(Enemy enemy) { return _captures.Exists((Capture c) => (Object)(object)c.Enemy == (Object)(object)enemy); } internal void Begin(Enemy enemy, float duration) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)enemy == (Object)null) && !IsCapturing(enemy)) { Capture capture = new Capture { Enemy = enemy, Duration = duration }; if (enemy.HasRigidbody && (Object)(object)enemy.Rigidbody != (Object)null && (Object)(object)enemy.Rigidbody.physGrabObject != (Object)null) { capture.StartY = enemy.Rigidbody.physGrabObject.rb.position.y; } Stun(enemy, duration + 1f); _captures.Add(capture); } } private static void Stun(Enemy enemy, float time) { if (enemy.HasStateStunned && (Object)(object)enemy.StateStunned != (Object)null) { enemy.StateStunned.Set(time); } } private void FixedUpdate() { if (_captures.Count == 0) { return; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { _captures.Clear(); return; } float fixedDeltaTime = Time.fixedDeltaTime; for (int num = _captures.Count - 1; num >= 0; num--) { Capture capture = _captures[num]; if ((Object)(object)capture.Enemy == (Object)null || (Object)(object)capture.Enemy.EnemyParent == (Object)null || !capture.Enemy.EnemyParent.Spawned) { _captures.RemoveAt(num); } else { capture.Timer += fixedDeltaTime; Stun(capture.Enemy, capture.Duration - capture.Timer + 1f); Hold(capture, fixedDeltaTime); if (capture.Timer >= capture.Duration) { Banish(capture.Enemy); _captures.RemoveAt(num); } } } } private static void Hold(Capture c, float dt) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00d3: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0117: 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_013f: Unknown result type (might be due to invalid IL or missing references) if (c.Enemy.HasRigidbody && !((Object)(object)c.Enemy.Rigidbody == (Object)null)) { PhysGrabObject physGrabObject = c.Enemy.Rigidbody.physGrabObject; if (!((Object)(object)physGrabObject == (Object)null) && !((Object)(object)physGrabObject.rb == (Object)null) && !physGrabObject.rb.isKinematic) { physGrabObject.OverrideZeroGravity(0.2f); float num = Mathf.Clamp01(c.Timer / c.Duration); float num2 = c.StartY + 0.6f * num; Rigidbody rb = physGrabObject.rb; Vector3 velocity = rb.velocity; velocity.x = Mathf.Lerp(velocity.x, 0f, dt * 6f); velocity.z = Mathf.Lerp(velocity.z, 0f, dt * 6f); velocity.y = Mathf.Lerp(velocity.y, Mathf.Clamp((num2 - rb.position.y) * 4f, -2f, 2f), dt * 8f); rb.velocity = velocity; rb.angularVelocity = Vector3.Lerp(rb.angularVelocity, new Vector3(0f, 2f + num * 10f, 0f), dt * 3f); } } } private static void Banish(Enemy enemy) { EnemyParent enemyParent = enemy.EnemyParent; if (!((Object)(object)enemyParent == (Object)null) && enemyParent.Spawned) { enemyParent.Despawn(); enemyParent.DespawnedTimer = Mathf.Max(enemyParent.DespawnedTimer, VoidGunConfig.ReturnTime.Value); Plugin.Log.LogInfo((object)$"Void Gun banished {enemyParent.enemyName} for {enemyParent.DespawnedTimer:0}s."); } } } public class VoidGunAnimator : MonoBehaviour { private static readonly Color CooldownColor = new Color(1f, 0.08f, 0.05f); private ItemGun _gun; private Transform _model; private Transform _vortex; private Transform _vortexRim; private ParticleSystem[] _nebula; private Light _canisterLight; private Sound _readySound; private Sound _clickSound; private Material _rimMaterial; private Color _rimBase; private Material[] _nebulaMaterials; private Color[] _nebulaBase; private State _state; private float _stateTime; private float _spin; private float _vortexScale = 1f; private float _readyFlash; private void Awake() { //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_021b: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Expected O, but got Unknown //IL_024f: 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_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0102: 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_0119: Unknown result type (might be due to invalid IL or missing references) _gun = ((Component)this).GetComponent<ItemGun>(); _model = FindDeep(((Component)this).transform, "VoidGunModel"); if ((Object)(object)_model == (Object)null) { return; } Transform val = FindDeep(_model, "VortexAnchor"); if ((Object)(object)val != (Object)null && (Object)(object)VoidGunWeapon.VortexFx != (Object)null) { GameObject val2 = Object.Instantiate<GameObject>(VoidGunWeapon.VortexFx, val, false); val2.transform.rotation = Quaternion.LookRotation(_model.forward, _model.up); _vortex = FindDeep(val2.transform, "Vortex"); _vortexRim = FindDeep(val2.transform, "VortexRim"); MeshRenderer val3 = (((Object)(object)_vortexRim != (Object)null) ? ((Component)_vortexRim).GetComponentInChildren<MeshRenderer>() : null); if ((Object)(object)val3 != (Object)null) { _rimMaterial = ((Renderer)val3).material; _rimBase = (_rimMaterial.HasProperty("_TintColor") ? _rimMaterial.GetColor("_TintColor") : Color.white); } } Transform val4 = FindDeep(_model, "CanisterAnchor"); if (!((Object)(object)val4 != (Object)null)) { return; } if ((Object)(object)VoidGunWeapon.NebulaFx != (Object)null) { GameObject val5 = Object.Instantiate<GameObject>(VoidGunWeapon.NebulaFx, val4, false); val5.transform.rotation = Quaternion.LookRotation(_model.forward, _model.up); _nebula = val5.GetComponentsInChildren<ParticleSystem>(); ParticleSystemRenderer[] componentsInChildren = val5.GetComponentsInChildren<ParticleSystemRenderer>(); _nebulaMaterials = (Material[])(object)new Material[componentsInChildren.Length]; _nebulaBase = (Color[])(object)new Color[componentsInChildren.Length]; for (int i = 0; i < componentsInChildren.Length; i++) { _nebulaMaterials[i] = ((Renderer)componentsInChildren[i]).material; _nebulaBase[i] = (_nebulaMaterials[i].HasProperty("_TintColor") ? _nebulaMaterials[i].GetColor("_TintColor") : Color.white); } } GameObject val6 = new GameObject("CanisterLight"); val6.transform.SetParent(val4, false); _canisterLight = val6.AddComponent<Light>(); _canisterLight.type = (LightType)2; _canisterLight.color = VoidGunWeapon.Teal; _canisterLight.range = 0.7f; _canisterLight.intensity = 1.2f; _canisterLight.shadows = (LightShadows)0; } private void Start() { _readySound = GameAudio.MakeSound(VoidGunWeapon.ReadyClip, VoidGunConfig.SoundVolume.Value * 0.35f, 0.02f); _clickSound = GameAudio.MakeSound(VoidGunWeapon.ClickClip, VoidGunConfig.SoundVolume.Value * 0.9f, 0.03f); } private void Update() { //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Invalid comparison between Unknown and I4 //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_0042: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_gun == (Object)null || (Object)(object)_model == (Object)null) { return; } if (_gun.stateCurrent != _state) { if ((int)_state == 4 && (int)_gun.stateCurrent == 0) { _readyFlash = 1f; Sound clickSound = _clickSound; if (clickSound != null) { clickSound.Play(((Component)this).transform, 1f, 1f, 1f, 1f); } Sound readySound = _readySound; if (readySound != null) { readySound.Play(((Component)this).transform, 1f, 1f, 1f, 1f); } } _state = _gun.stateCurrent; _stateTime = 0f; } _stateTime += Time.deltaTime; _readyFlash = Mathf.Max(0f, _readyFlash - Time.deltaTime * 2.5f); float progress = CooldownProgress(); UpdateVortex(progress); UpdateNebula(progress); } private float CooldownProgress() { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if ((int)_state != 4) { return 1f; } return Mathf.Clamp01(_stateTime / Mathf.Max(0.01f, _gun.shootCooldown)); } private void UpdateVortex(float progress) { //IL_0001: 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_0007: 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_001f: Expected I4, but got Unknown //IL_0138: 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_0186: 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) State state = _state; float num; float num2; switch (state - 1) { case 1: num = 900f; num2 = 1.15f + Mathf.Sin(Time.time * 25f) * 0.05f; break; case 2: num = 1400f; num2 = 1.3f; break; case 3: num = Mathf.Lerp(-60f, 120f, progress); num2 = Mathf.Lerp(0.15f, 1f, progress * progress); break; case 0: num = 20f; num2 = 0.25f; break; default: num = 120f; num2 = 1f + Mathf.Sin(Time.time * 2f) * 0.03f; break; } float deltaTime = Time.deltaTime; _spin = Mathf.Lerp(_spin, num, 1f - Mathf.Exp(-5f * deltaTime)); _vortexScale = Mathf.Lerp(_vortexScale, num2 + _readyFlash * 0.3f, 1f - Mathf.Exp(-8f * deltaTime)); if ((Object)(object)_vortex != (Object)null) { _vortex.Rotate(0f, 0f, _spin * deltaTime, (Space)1); _vortex.localScale = Vector3.one * _vortexScale; } if ((Object)(object)_vortexRim != (Object)null) { _vortexRim.Rotate(0f, 0f, (0f - _spin) * 0.6f * deltaTime, (Space)1); _vortexRim.localScale = Vector3.one * (_vortexScale * 1.05f); } } private void UpdateNebula(float progress) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 //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_0041: 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_0058: Invalid comparison between Unknown and I4 //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Invalid comparison between Unknown and I4 //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Invalid comparison between Unknown and I4 //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0174: 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_0186: 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_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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_0113: 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_0134: Unknown result type (might be due to invalid IL or missing references) bool flag = (int)_state == 4 || (int)_state == 1; float num = (flag ? Mathf.SmoothStep(0f, 1f, progress) : 1f); Color val = Color.Lerp(CooldownColor, VoidGunWeapon.Teal, num); float readyFlash = _readyFlash; if (_nebula != null) { float simulationSpeed = (((int)_state == 2) ? 3f : (flag ? Mathf.Lerp(0.3f, 1f, progress) : 1f)); ParticleSystem[] nebula = _nebula; for (int i = 0; i < nebula.Length; i++) { MainModule main = nebula[i].main; ((MainModule)(ref main)).simulationSpeed = simulationSpeed; } } if (_nebulaMaterials != null) { for (int j = 0; j < _nebulaMaterials.Length; j++) { if (!((Object)(object)_nebulaMaterials[j] == (Object)null) && _nebulaMaterials[j].HasProperty("_TintColor")) { Color val2 = (flag ? (val * 1.4f) : _nebulaBase[j]); val2 = Color.Lerp(val2, Color.white, readyFlash * 0.6f); val2.a = 1f; _nebulaMaterials[j].SetColor("_TintColor", val2); } } } if ((Object)(object)_rimMaterial != (Object)null && _rimMaterial.HasProperty("_TintColor")) { Color val3 = (flag ? (val * 0.9f) : _rimBase); val3 = Color.Lerp(val3, Color.white, readyFlash * 0.7f); val3.a = 1f; _rimMaterial.SetColor("_TintColor", val3); } if (!((Object)(object)_canisterLight == (Object)null)) { float num2 = (((int)_state == 2) ? (1.5f + _stateTime * 4f) : (((int)_state == 3) ? 5f : ((!flag) ? (1.2f + Mathf.Sin(Time.time * 1.5f) * 0.25f) : (2.2f * (0.75f + 0.25f * Mathf.Sin(Time.time * Mathf.Lerp(3f, 14f, progress))))))); _canisterLight.color = (flag ? val : VoidGunWeapon.Teal); _canisterLight.range = (flag ? 1.1f : 0.7f); _canisterLight.intensity = num2 + readyFlash * 5f; } } private static Transform FindDeep(Transform parent, string name) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Expected O, but got Unknown if (((Object)parent).name == name) { return parent; } foreach (Transform item in parent) { Transform val = FindDeep(item, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } } public class VoidGunBehaviour : MonoBehaviour { private ItemGun _gun; private PhotonView _photonView; private Light _glow; private float _flash; private State _lastState; private Sound _chargeSound; private void Awake() { _gun = ((Component)this).GetComponent<ItemGun>(); _photonView = ((Component)this).GetComponent<PhotonView>(); Transform val = ((Component)this).transform.Find("VoidGlow"); if ((Object)(object)val != (Object)null) { _glow = ((Component)val).GetComponent<Light>(); } } private void Start() { if (!((Object)(object)_gun == (Object)null)) { _gun.buildUpTime = VoidGunConfig.BuildUpTime.Value; _gun.shootCooldown = VoidGunConfig.ShootCooldown.Value; _chargeSound = GameAudio.MakeSound(VoidGunWeapon.ChargeClip, VoidGunConfig.SoundVolume.Value * 0.8f); } } private void Update() { //IL_0015: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Invalid comparison between Unknown and I4 //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Invalid comparison between Unknown and I4 //IL_0085: 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)_gun == (Object)null) { return; } if (_gun.stateCurrent != _lastState) { if ((int)_gun.stateCurrent == 2 && _chargeSound != null) { _chargeSound.Play(((Object)(object)_gun.gunMuzzle != (Object)null) ? _gun.gunMuzzle : ((Component)this).transform, 1f, 1f, 1f, 1f); } _lastState = _gun.stateCurrent; } if (!((Object)(object)_glow == (Object)null)) { float num = (((int)_gun.stateCurrent == 2) ? (2f + Mathf.Sin(Time.time * 18f) * 0.8f) : 0f); _flash = Mathf.Max(0f, _flash - Time.deltaTime * 5f); _glow.intensity = Mathf.Lerp(_glow.intensity, num, Time.deltaTime * 10f) + _flash; } } internal void OnBulletFired(Vector3 origin, Vector3 end) { //IL_0013: 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) _flash = 5f; if (!SemiFunc.IsMasterClientOrSingleplayer()) { return; } Enemy val = FindTarget(origin, end, VoidGunConfig.HitRadius.Value); if ((Object)(object)val == (Object)null || (Object)(object)val.EnemyParent == (Object)null || VoidController.Instance.IsCapturing(val)) { return; } float value = VoidGunConfig.CaptureTime.Value; if (SemiFunc.IsMultiplayer()) { PhotonView photonView = ((MonoBehaviourPun)val.EnemyParent).photonView; if (!((Object)(object)photonView == (Object)null) && !((Object)(object)_photonView == (Object)null)) { _photonView.RPC("VoidCaptureRPC", (RpcTarget)0, new object[2] { photonView.ViewID, value }); } } else { Apply(val, value); } } [PunRPC] public void VoidCaptureRPC(int viewId, float captureTime, PhotonMessageInfo info = default(PhotonMessageInfo)) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.MasterOnlyRPC(info)) { return; } PhotonView val = PhotonView.Find(viewId); if (!((Object)(object)val == (Object)null)) { EnemyParent component = ((Component)val).GetComponent<EnemyParent>(); if (!((Object)(object)component == (Object)null) && !((Object)(object)component.Enemy == (Object)null)) { Apply(component.Enemy, captureTime); } } } private static void Apply(Enemy enemy, float captureTime) { VoidVisual.Spawn(enemy, captureTime); if (SemiFunc.IsMasterClientOrSingleplayer()) { VoidController.Instance.Begin(enemy, captureTime); } } private static Enemy FindTarget(Vector3 origin, Vector3 end, float radius) { //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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)EnemyDirector.instance == (Object)null) { return null; } Enemy result = null; float num = float.MaxValue; foreach (EnemyParent item in EnemyDirector.instance.enemiesSpawned) { if ((Object)(object)item == (Object)null || !item.Spawned || (Object)(object)item.Enemy == (Object)null) { continue; } Vector3 val = EnemyCenter(item.Enemy); float num2 = Vector3.Distance(val, end); float num3 = DistanceToSegment(val, origin, end); if (!(num2 > radius) || !(num3 > radius * 0.6f)) { float num4 = Mathf.Min(num2, num3); if (num4 < num) { num = num4; result = item.Enemy; } } } return result; } internal static Vector3 EnemyCenter(Enemy enemy) { //IL_0020: 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) if ((Object)(object)enemy.CenterTransform != (Object)null) { return enemy.CenterTransform.position; } return ((Component)enemy).transform.position; } private static float DistanceToSegment(Vector3 point, Vector3 a, Vector3 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_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_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) Vector3 val = b - a; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < 0.0001f) { return Vector3.Distance(point, a); } float num = Mathf.Clamp01(Vector3.Dot(point - a, val) / sqrMagnitude); return Vector3.Distance(point, a + val * num); } } internal static class VoidGunConfig { internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<float> BuildUpTime; internal static ConfigEntry<float> ShootCooldown; internal static ConfigEntry<float> HitRadius; internal static ConfigEntry<float> CaptureTime; internal static ConfigEntry<float> ReturnTime; internal static ConfigEntry<float> ModelScale; internal static ConfigEntry<float> ModelYawOffset; internal static ConfigEntry<float> SoundVolume; internal static void Bind(ConfigFile config) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Expected O, but got Unknown //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Expected O, but got Unknown //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Expected O, but got Unknown //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Expected O, but got Unknown Enabled = config.Bind<bool>("VoidGun", "Enabled", true, "Adds the Void Gun to the game (restart required)."); BuildUpTime = config.Bind<float>("VoidGun", "BuildUpTime", 0.8f, new ConfigDescription("Charge time before firing.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>())); ShootCooldown = config.Bind<float>("VoidGun", "ShootCooldown", 5f, new ConfigDescription("Seconds between shots.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 30f), Array.Empty<object>())); HitRadius = config.Bind<float>("VoidGun.Effect", "HitRadius", 1.5f, new ConfigDescription("How close to the shot an enemy must be to get banished.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 5f), Array.Empty<object>())); CaptureTime = config.Bind<float>("VoidGun.Effect", "CaptureTime", 1.4f, new ConfigDescription("Seconds the enemy is held in the void before vanishing.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 5f), Array.Empty<object>())); ReturnTime = config.Bind<float>("VoidGun.Effect", "ReturnTime", 180f, new ConfigDescription("Minimum seconds before a banished enemy can respawn.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(10f, 1200f), Array.Empty<object>())); ModelScale = config.Bind<float>("VoidGun.Visual", "ModelScale", 0.75f, new ConfigDescription("Extra scale applied to the custom model after auto-fit.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 3f), Array.Empty<object>())); ModelYawOffset = config.Bind<float>("VoidGun.Visual", "ModelYawOffset", 0f, new ConfigDescription("Extra yaw rotation in degrees if the model points the wrong way.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-180f, 180f), Array.Empty<object>())); SoundVolume = config.Bind<float>("VoidGun.Visual", "SoundVolume", 0.7f, new ConfigDescription("Volume of the Void Gun sounds.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); } } internal static class VoidGunWeapon { internal const string ItemAssetName = "Item Gun Void"; internal const string GlowName = "VoidGlow"; internal static readonly Color Teal = new Color(0.2f, 1f, 0.8f); internal static AudioClip ChargeClip; internal static AudioClip ShotClip; internal static AudioClip CaptureClip; internal static AudioClip VanishClip; internal static GameObject CaptureFx; internal static GameObject VanishFx; internal static GameObject VortexFx; internal static GameObject NebulaFx; internal static AudioClip ReadyClip; internal static AudioClip ClickClip; internal static Item Register(StatsManager stats) { if (!VoidGunConfig.Enabled.Value) { return null; } if (!ItemCloner.TryFindBase(stats, IsShotgun, out var item, out var prefab)) { Plugin.Log.LogError((object)"Shotgun not found, Void Gun not registered."); return null; } ChargeClip = ModAssets.Load<AudioClip>("VoidGun_Charge"); ShotClip = ModAssets.Load<AudioClip>("VoidGun_Shot"); CaptureClip = ModAssets.Load<AudioClip>("VoidGun_Capture"); VanishClip = ModAssets.Load<AudioClip>("VoidGun_Vanish"); CaptureFx = ModAssets.Load<GameObject>("VoidGunCaptureFX"); VanishFx = ModAssets.Load<GameObject>("VoidGunVanishFX"); VortexFx = ModAssets.Load<GameObject>("VoidGunVortexFX"); NebulaFx = ModAssets.Load<GameObject>("VoidGunNebulaFX"); ReadyClip = ModAssets.Load<AudioClip>("VoidGun_Ready"); ClickClip = ModAssets.Load<AudioClip>("VoidGun_Click"); GameObject val = ItemCloner.ClonePrefab(prefab, "Item Gun Void"); Item val2 = ItemCloner.CloneItem(item, "Item Gun Void", "Void Gun", "Sends a monster somewhere else for a while. Only works on monsters."); ItemAttributes component = val.GetComponent<ItemAttributes>(); component.item = val2; ItemGun component2 = val.GetComponent<ItemGun>(); component2.hasBuildUp = true; component2.numberOfBullets = 1; component2.gunRandomSpread = 0f; component2.gunRange = 35f; component2.bulletPrefab = CreateBullet(component2.bulletPrefab); ApplySounds(component2); if (!ModelSwap.Apply(val, "VoidGunModel", component2.gunMuzzle, VoidGunConfig.ModelScale.Value, VoidGunConfig.ModelYawOffset.Value)) { TintPlaceholder(val); } AddGlow(val, component2); val.AddComponent<VoidGunBehaviour>(); val.AddComponent<VoidGunAnimator>(); Items.RegisterItem(component); Plugin.Log.LogInfo((object)"Void Gun registered."); return val2; } private static bool IsShotgun(GameObject prefab) { ItemGun component = prefab.GetComponent<ItemGun>(); if ((Object)(object)component != (Object)null && component.numberOfBullets > 1 && (Object)(object)prefab.GetComponent<ItemGunTranq>() == (Object)null) { return (Object)(object)prefab.GetComponent<ItemGunLaser>() == (Object)null; } return false; } private static void ApplySounds(ItemGun gun) { if (!((Object)(object)ShotClip == (Object)null)) { if (gun.soundShoot != null) { gun.soundShoot.Sounds = (AudioClip[])(object)new AudioClip[1] { ShotClip }; gun.soundShoot.Volume = VoidGunConfig.SoundVolume.Value; } if (gun.soundShootGlobal != null) { gun.soundShootGlobal.Sounds = (AudioClip[])(object)new AudioClip[0]; } } } private static GameObject CreateBullet(GameObject baseBullet) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: 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_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_0135: 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) GameObject val = ItemCloner.ClonePrefab(baseBullet, "Void Gun Bullet"); HurtCollider[] componentsInChildren = val.GetComponentsInChildren<HurtCollider>(true); foreach (HurtCollider obj in componentsInChildren) { obj.playerLogic = false; obj.physLogic = false; obj.enemyLogic = false; obj.onImpactAny = new UnityEvent(); obj.onImpactPlayer = new UnityEvent(); obj.onImpactPhysObject = new UnityEvent(); obj.onImpactEnemy = new UnityEvent(); } LineRenderer[] componentsInChildren2 = val.GetComponentsInChildren<LineRenderer>(true); foreach (LineRenderer obj2 in componentsInChildren2) { obj2.startColor = Teal; obj2.endColor = Teal; Material material = ((Renderer)obj2).material; if ((Object)(object)material != (Object)null && material.HasProperty("_Color")) { material.color = Teal; } if ((Object)(object)material != (Object)null && material.HasProperty("_EmissionColor")) { material.SetColor("_EmissionColor", Teal * 2f); } } Light[] componentsInChildren3 = val.GetComponentsInChildren<Light>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { componentsInChildren3[i].color = Teal; } ParticleSystem[] componentsInChildren4 = val.GetComponentsInChildren<ParticleSystem>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { MainModule main = componentsInChildren4[i].main; ((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Teal); } return val; } private static void TintPlaceholder(GameObject gunObject) { //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_0061: Unknown result type (might be due to invalid IL or missing references) Renderer[] componentsInChildren = gunObject.GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { if (!(val is MeshRenderer) && !(val is SkinnedMeshRenderer)) { continue; } Material[] materials = val.materials; Material[] array = materials; foreach (Material val2 in array) { if ((Object)(object)val2 != (Object)null && val2.HasProperty("_Color")) { val2.color = Color.Lerp(val2.color, Teal, 0.5f); } } val.materials = materials; } } private static void AddGlow(GameObject gunObject, ItemGun gun) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0058: 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) GameObject val = new GameObject("VoidGlow"); val.transform.SetParent(gunObject.transform, false); if ((Object)(object)gun != (Object)null && (Object)(object)gun.gunMuzzle != (Object)null) { val.transform.position = gun.gunMuzzle.position; } Light obj = val.AddComponent<Light>(); obj.type = (LightType)2; obj.color = Teal; obj.range = 2f; obj.intensity = 0f; obj.shadows = (LightShadows)0; } } internal class VoidVisual : MonoBehaviour { private Enemy _enemy; private Light _light; private GameObject _fx; private float _duration; private float _timer; private bool _vanished; internal static void Spawn(Enemy enemy, float duration) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("VoidCaptureVisual"); val.transform.position = VoidGunBehaviour.EnemyCenter(enemy); VoidVisual voidVisual = val.AddComponent<VoidVisual>(); voidVisual._enemy = enemy; voidVisual._duration = duration; voidVisual._light = val.AddComponent<Light>(); voidVisual._light.type = (LightType)2; voidVisual._light.color = VoidGunWeapon.Teal; voidVisual._light.range = 4f; voidVisual._light.intensity = 0f; voidVisual._light.shadows = (LightShadows)0; if ((Object)(object)VoidGunWeapon.CaptureFx != (Object)null) { voidVisual._fx = Object.Instantiate<GameObject>(VoidGunWeapon.CaptureFx, val.transform, false); } Sound obj = GameAudio.MakeSound(VoidGunWeapon.CaptureClip, VoidGunConfig.SoundVolume.Value, 0.03f); if (obj != null) { obj.Play(val.transform, 1f, 1f, 1f, 1f); } } private void LateUpdate() { //IL_0093: 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_00ad: 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) _timer += Time.deltaTime; if (!_vanished) { if ((Object)(object)_enemy != (Object)null) { ((Component)this).transform.position = VoidGunBehaviour.EnemyCenter(_enemy); } float num = Mathf.Clamp01(_timer / _duration); _light.intensity = Mathf.Lerp(0.5f, 4f, num) * (0.8f + Mathf.Sin(_timer * 30f) * 0.2f); _light.color = Color.Lerp(VoidGunWeapon.Teal, new Color(0.35f, 0.1f, 0.6f), num); if (_timer >= _duration) { Vanish(); } } else { float num2 = Mathf.Clamp01(1f - (_timer - _duration) / 0.6f); _light.intensity = 10f * num2 * num2; if (_timer >= _duration + 4f) { Object.Destroy((Object)(object)((Component)this).gameObject); } } } private void Vanish() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: 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) _vanished = true; if ((Object)(object)_fx != (Object)null) { ParticleSystem[] componentsInChildren = _fx.GetComponentsInChildren<ParticleSystem>(); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].Stop(true, (ParticleSystemStopBehavior)1); } } if ((Object)(object)VoidGunWeapon.VanishFx != (Object)null) { Object.Destroy((Object)(object)Object.Instantiate<GameObject>(VoidGunWeapon.VanishFx, ((Component)this).transform.position, Quaternion.identity), 5f); } Sound obj = GameAudio.MakeSound(VoidGunWeapon.VanishClip, VoidGunConfig.SoundVolume.Value, 0.04f); if (obj != null) { obj.Play(((Component)this).transform.position, 1f, 1f, 1f, 1f); } } } } namespace MoreGuns.Weapons.SlimeGun { internal class SlimeController : MonoBehaviour { private class Stuck { public Enemy Enemy; public float Duration; public float Timer; public Vector3 Anchor; public bool HasAnchor; } private static SlimeController _instance; private readonly List<Stuck> _stuck = new List<Stuck>(); internal static SlimeController Instance { get { //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_001d: Expected O, but got Unknown if ((Object)(object)_instance == (Object)null) { GameObject val = new GameObject("MoreGunsSlimeController"); Object.DontDestroyOnLoad((Object)val); _instance = val.AddComponent<SlimeController>(); } return _instance; } } internal void Begin(Enemy enemy, float duration) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)enemy == (Object)null) { return; } Stuck stuck = _stuck.Find((Stuck s) => (Object)(object)s.Enemy == (Object)(object)enemy); if (stuck != null) { stuck.Duration = Mathf.Max(stuck.Duration - stuck.Timer, duration); stuck.Timer = 0f; return; } Stuck stuck2 = new Stuck { Enemy = enemy, Duration = duration }; Rigidbody rigidbody = GetRigidbody(enemy); if ((Object)(object)rigidbody != (Object)null) { stuck2.Anchor = rigidbody.position; stuck2.HasAnchor = true; } Stun(enemy, duration + 0.5f); _stuck.Add(stuck2); } private static Rigidbody GetRigidbody(Enemy enemy) { if (!enemy.HasRigidbody || (Object)(object)enemy.Rigidbody == (Object)null || (Object)(object)enemy.Rigidbody.physGrabObject == (Object)null) { return null; } return enemy.Rigidbody.physGrabObject.rb; } private static void Stun(Enemy enemy, float time) { if (enemy.HasStateStunned && (Object)(object)enemy.StateStunned != (Object)null) { enemy.StateStunned.Set(time); } } private void FixedUpdate() { //IL_00dd: 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_00e8: 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_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: 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_0113: 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_0130: Unknown result type (might be due to invalid IL or missing references) if (_stuck.Count == 0) { return; } if (!SemiFunc.IsMasterClientOrSingleplayer()) { _stuck.Clear(); return; } float fixedDeltaTime = Time.fixedDeltaTime; for (int num = _stuck.Count - 1; num >= 0; num--) { Stuck stuck = _stuck[num]; if ((Object)(object)stuck.Enemy == (Object)null || (Object)(object)stuck.Enemy.EnemyParent == (Object)null || !stuck.Enemy.EnemyParent.Spawned) { _stuck.RemoveAt(num); } else { stuck.Timer += fixedDeltaTime; Stun(stuck.Enemy, stuck.Duration - stuck.Timer + 0.5f); Rigidbody rigidbody = GetRigidbody(stuck.Enemy); if ((Object)(object)rigidbody != (Object)null && !rigidbody.isKinematic && stuck.HasAnchor) { Vector3 val = (stuck.Anchor - rigidbody.position) * 6f; rigidbody.velocity = Vector3.Lerp(rigidbody.velocity, Vector3.ClampMagnitude(val, 3f), fixedDeltaTime * 12f); rigidbody.angularVelocity = Vector3.Lerp(rigidbody.angularVelocity, Vector3.zero, fixedDeltaTime * 8f); } if (stuck.Timer >= stuck.Duration) { _stuck.RemoveAt(num); } } } } } public class SlimeGunAnimator : MonoBehaviour { private const float MaxWobble = 0.9f; private const float WobbleSpeed = 1.6f; private const float Recovery = 1.4f; private ItemGun _gun; private ItemBattery _battery; private Transform _model; private Renderer _liquid; private Material _liquidMaterial; private SlimeJarBubbles _jarBubbles; private ParticleSystem _drip; private Light _jarLight; private Transform _goo; private Transform _dropAnchor; private Vector3 _gooBaseScale; private Vector3 _gooTipLocal; private Vector3 _gooTopLocal; private float _gooStretch; private float _gooVelocity; private float _gooTarget; private float _dripTimer; private float _nextDrip = 1.2f; private int _pendingDrops; private float _burstTimer; private float _fill = 1f; private float _wobbleAddX; private float _wobbleAddZ; private float _pulse; private Vector3 _lastPos; private Quaternion _lastRot; private bool _hasLast; private State _state; private void Awake() { //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Expected O, but got Unknown //IL_016b: 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_0111: Expected O, but got Unknown //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_021c: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_023e: 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_0255: 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_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_02ac: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Expected O, but got Unknown _gun = ((Component)this).GetComponent<ItemGun>(); _battery = ((Component)this).GetComponent<ItemBattery>(); _model = WeaponParts.FindDeep(((Component)this).transform, "SlimeGunModel"); if ((Object)(object)_model == (Object)null) { return; } Transform val = WeaponParts.FindDeep(_model, "Liquid"); if ((Object)(object)val != (Object)null) { _liquid = ((Component)val).GetComponent<Renderer>(); if ((Object)(object)_liquid != (Object)null && (Object)(object)SlimeGunWeapon.LiquidMaterial != (Object)null) { _liquidMaterial = new Material(SlimeGunWeapon.LiquidMaterial); _liquid.sharedMaterial = _liquidMaterial; _liquid.shadowCastingMode = (ShadowCastingMode)0; _jarBubbles = new SlimeJarBubbles(_liquid, _liquidMaterial, SlimeGunWeapon.BubbleMaterial); } } Transform val2 = WeaponParts.FindDeep(_model, "Jar"); Renderer val3 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<Renderer>() : null); if ((Object)(object)val3 != (Object)null && (Object)(object)SlimeGunWeapon.GlassMaterial != (Object)null) { val3.sharedMaterial = new Material(SlimeGunWeapon.GlassMaterial); val3.shadowCastingMode = (ShadowCastingMode)0; } Transform val4 = WeaponParts.FindDeep(_model, "JarAnchor"); if ((Object)(object)val4 != (Object)null) { GameObject val5 = new GameObject("JarLight"); val5.transform.SetParent(val4, false); _jarLight = val5.AddComponent<Light>(); _jarLight.type = (LightType)2; _jarLight.color = SlimeGunWeapon.Green; _jarLight.range = 0.8f; _jarLight.intensity = 1f; _jarLight.shadows = (LightShadows)0; } _goo = WeaponParts.FindDeep(_model, "NozzleGoo"); _dropAnchor = WeaponParts.FindDeep(_model, "DropAnchor"); if ((Object)(object)_goo != (Object)null) { _gooBaseScale = _goo.localScale; MeshFilter component = ((Component)_goo).GetComponent<MeshFilter>(); if ((Object)(object)component != (Object)null && (Object)(object)component.sharedMesh != (Object)null) { Bounds bounds = component.sharedMesh.bounds; _gooTipLocal = new Vector3(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).min.y, ((Bounds)(ref bounds)).center.z); _gooTopLocal = new Vector3(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).max.y, ((Bounds)(ref bounds)).center.z); } Renderer component2 = ((Component)_goo).GetComponent<Renderer>(); if ((Object)(object)component2 != (Object)null && (Object)(object)SlimeGunWeapon.SurfaceMaterial != (Object)null) { component2.sharedMaterial = new Material(SlimeGunWeapon.SurfaceMaterial); component2.shadowCastingMode = (ShadowCastingMode)0; } } if ((Object)(object)SlimeGunWeapon.DripFx != (Object)null) { GameObject val6 = Object.Instantiate<GameObject>(SlimeGunWeapon.DripFx); val6.transform.SetParent(((Component)this).transform, false); _drip = val6.GetComponentInChildren<ParticleSystem>(); } } internal void OnShot() { _wobbleAddX += Random.Range(-1f, 1f) * 0.9f * 0.8f; _wobbleAddZ += Random.Range(-1f, 1f) * 0.9f * 0.8f; _jarBubbles?.Boil(1f); _gooVelocity += 6f; _pendingDrops += 3; } private void LateUpdate() { //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_00b9: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: 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_0255: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Unknown result type (might be due to invalid IL or missing references) //IL_02f2: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0117: 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_013c: 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_014d: 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_01a5: 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_01e4: 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_015d: 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_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Invalid comparison between Unknown and I4 if ((Object)(object)_model == (Object)null || (Object)(object)_liquid == (Object)null || (Object)(object)_liquidMaterial == (Object)null) { return; } float num = Mathf.Max(Time.deltaTime, 0.0001f); float num2 = 1f; if ((Object)(object)_battery != (Object)null && _battery.batteryBars > 0) { num2 = Mathf.Clamp01((float)_battery.batteryLifeInt / (float)_battery.batteryBars); } _fill = Mathf.MoveTowards(_fill, num2, num * 0.8f); Bounds bounds = _liquid.bounds; float num3 = Mathf.Lerp(0.04f, 0.96f, _fill); float num4 = ((Bounds)(ref bounds)).min.y + ((Bounds)(ref bounds)).size.y * num3; Vector3 center = ((Bounds)(ref bounds)).center; Quaternion rotation = _model.rotation; if (_hasLast) { Vector3 val = (_lastPos - center) / num; Quaternion val2 = rotation * Quaternion.Inverse(_lastRot); float num5 = default(float); Vector3 val3 = default(Vector3); ((Quaternion)(ref val2)).ToAngleAxis(ref num5, ref val3); if (num5 > 180f) { num5 -= 360f; } Vector3 val4 = val3 * (num5 * (MathF.PI / 180f) / num); if (float.IsNaN(val4.x)) { val4 = Vector3.zero; } _wobbleAddX = Mathf.Lerp(_wobbleAddX, 0f, num * 1.4f); _wobbleAddZ = Mathf.Lerp(_wobbleAddZ, 0f, num * 1.4f); _wobbleAddX += Mathf.Clamp((val.x + val4.z * 0.2f) * 0.9f * num * 6f, -0.9f, 0.9f); _wobbleAddZ += Mathf.Clamp((val.z + val4.x * 0.2f) * 0.9f * num * 6f, -0.9f, 0.9f); _wobbleAddX = Mathf.Clamp(_wobbleAddX, -0.9f, 0.9f); _wobbleAddZ = Mathf.Clamp(_wobbleAddZ, -0.9f, 0.9f); } _lastPos = center; _lastRot = rotation; _hasLast = true; _pulse += num * 1.6f * MathF.PI * 2f; float num6 = _wobbleAddX * Mathf.Sin(_pulse); float num7 = _wobbleAddZ * Mathf.Sin(_pulse); _liquidMaterial.SetFloat("_FillY", num4); _liquidMaterial.SetFloat("_WobbleX", num6); _liquidMaterial.SetFloat("_WobbleZ", num7); _liquidMaterial.SetVector("_Center", Vector4.op_Implicit(center)); _liquidMaterial.SetFloat("_DepthRange", Mathf.Max(0.01f, ((Bounds)(ref bounds)).size.y)); _liquidMaterial.SetFloat("_Glow", 0.9f + Mathf.Sin(Time.time * 2f) * 0.08f + ((_fill < 0.2f) ? (Mathf.Sin(Time.time * 10f) * 0.1f) : 0f)); if ((Object)(object)_gun != (Object)null && _gun.stateCurrent != _state) { _state = _gun.stateCurrent; if ((int)_state == 3) { OnShot(); } } if (_jarBubbles != null) { float agitation = Mathf.Clamp01((Mathf.Abs(_wobbleAddX) + Mathf.Abs(_wobbleAddZ)) / 1.8f * 2.5f); _jarBubbles.Tick(num, _fill, num4, num6, num7, center, agitation); } UpdateGoo(num); if ((Object)(object)_jarLight != (Object)null) { _jarLight.intensity = Mathf.Lerp(0.2f, 1.2f, _fill); } } private void UpdateGoo(float dt) { //IL_022e: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_goo == (Object)null) { return; } float num = Mathf.Lerp(3.5f, 1.3f, _fill); float num2 = HangFactor(); int num3; if (num2 > 0.5f) { num3 = ((_fill > 0.03f) ? 1 : 0); if (num3 != 0) { _dripTimer += dt; goto IL_0075; } } else { num3 = 0; } _dripTimer = Mathf.Max(0f, _dripTimer - dt * 2f); goto IL_0075; IL_0075: float num4 = Mathf.Clamp01(_dripTimer / Mathf.Max(0.1f, _nextDrip)); _gooTarget = Mathf.SmoothStep(0f, 0.55f, num4) * Mathf.Clamp01(num2); float num5 = 60f; float num6 = 7f; float num7 = (_gooTarget - _gooStretch) * num5 - _gooVelocity * num6; _gooVelocity += num7 * dt; _gooStretch += _gooVelocity * dt; if (num3 != 0 && _dripTimer >= _nextDrip) { EmitDrop(); _dripTimer = 0f; _nextDrip = num * Random.Range(0.8f, 1.25f); _gooStretch -= 0.35f; _gooVelocity = -2.5f; } if (_pendingDrops > 0) { _burstTimer -= dt; if (_burstTimer <= 0f) { if (num2 > 0.2f) { EmitDrop(); } _pendingDrops--; _burstTimer = 0.07f; } } float num8 = Mathf.Sin(Time.time * 2.3f) * 0.04f; float num9 = Mathf.Max(-0.3f, _gooStretch); float num10 = 1f / Mathf.Sqrt(1f + Mathf.Max(0f, num9)); _goo.localScale = new Vector3(_gooBaseScale.x * num10 * (1f + num8), _gooBaseScale.y * (1f + num9), _gooBaseScale.z * num10 * (1f - num8)); } private float HangFactor() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL