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 ApexPredatorLauncher v0.1.2
BepInEx/plugins/ApexPredatorLauncher/ApexPredatorLauncher.dll
Decompiled 6 hours agousing System; using System.Collections; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Photon.Pun; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace ApexPredatorLauncherMod; public sealed class ApexAmmo : MonoBehaviour { public const string StatKey = "caspiApexAmmoUsed"; private static readonly FieldInfo Dictionaries = AccessTools.Field(typeof(StatsManager), "dictionaryOfDictionaries"); private static readonly FieldInfo LifeBars = AccessTools.Field(typeof(ItemBattery), "batteryLifeInt"); private static readonly FieldInfo InstanceName = AccessTools.Field(typeof(ItemAttributes), "instanceName"); private ItemBattery battery; private ItemAttributes attributes; private PhysGrabObject grab; private GUIStyle ammoStyle; private int unnamedUsed; public int UsedInCurrentBar { get { StatsManager instance = StatsManager.instance; string text = (Object.op_Implicit((Object)(object)attributes) ? (InstanceName.GetValue(attributes) as string) : null); if (!Object.op_Implicit((Object)(object)instance) || string.IsNullOrEmpty(text) || SemiFunc.RunIsArena()) { return unnamedUsed; } Dictionary<string, int> dictionary = EnsureStats(instance); if (!dictionary.TryGetValue(text, out var value)) { return 0; } return ApexAmmoMath.ClampUsed(value); } } public int RemainingShots { get { if (!Object.op_Implicit((Object)(object)battery)) { return 0; } return ApexAmmoMath.ShotsRemaining((int)LifeBars.GetValue(battery), UsedInCurrentBar); } } private void Awake() { battery = ((Component)this).GetComponent<ItemBattery>(); attributes = ((Component)this).GetComponent<ItemAttributes>(); grab = ((Component)this).GetComponent<PhysGrabObject>(); } private void OnGUI() { //IL_0097: 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_0038: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)grab) && grab.grabbedLocal) { if (ammoStyle == null) { ammoStyle = new GUIStyle(GUI.skin.box); ammoStyle.fontSize = 20; ammoStyle.alignment = (TextAnchor)4; ammoStyle.normal.textColor = new Color(1f, 0.8f, 0.2f); } GUI.Box(new Rect((float)Screen.width - 300f, (float)Screen.height - 82f, 280f, 42f), "DUCKS " + RemainingShots + " / " + 1000, ammoStyle); } } internal bool ConsumeShot() { if (RemainingShots <= 0) { return false; } int used = UsedInCurrentBar; bool result = ApexAmmoMath.TryConsume(ref used); SetUsed(used); return result; } internal void RefilledBar() { if (SemiFunc.IsMasterClientOrSingleplayer()) { SetUsed(0); } } private void SetUsed(int used) { unnamedUsed = ApexAmmoMath.ClampUsed(used); StatsManager instance = StatsManager.instance; string text = (Object.op_Implicit((Object)(object)attributes) ? (InstanceName.GetValue(attributes) as string) : null); if (Object.op_Implicit((Object)(object)instance) && !string.IsNullOrEmpty(text) && !SemiFunc.RunIsShop() && !SemiFunc.RunIsArena()) { EnsureStats(instance); instance.DictionaryUpdateValue("caspiApexAmmoUsed", text, unnamedUsed); if (SemiFunc.IsMultiplayer() && Object.op_Implicit((Object)(object)PunManager.instance)) { PunManager.instance.UpdateStat("caspiApexAmmoUsed", text, unnamedUsed); } } } internal static void Validate() { if (Dictionaries == null || LifeBars == null || InstanceName == null || AccessTools.Method(typeof(ItemBattery), "RemoveFullBar", (Type[])null, (Type[])null) == null || AccessTools.Method(typeof(ItemBattery), "BatteryFullPercentChangeLogic", (Type[])null, (Type[])null) == null) { throw new InvalidOperationException("Native ammo/battery APIs are unavailable."); } } internal static Dictionary<string, int> EnsureStats(StatsManager stats) { SortedDictionary<string, Dictionary<string, int>> sortedDictionary = (SortedDictionary<string, Dictionary<string, int>>)Dictionaries.GetValue(stats); if (!sortedDictionary.TryGetValue("caspiApexAmmoUsed", out var value)) { value = new Dictionary<string, int>(); sortedDictionary.Add("caspiApexAmmoUsed", value); } return value; } } [HarmonyPatch(typeof(StatsManager), "Awake")] internal static class ApexAmmoRegisterStats { private static void Postfix(StatsManager __instance) { if ((Object)(object)__instance == (Object)(object)StatsManager.instance) { ApexAmmo.EnsureStats(__instance); } } } [HarmonyPatch(typeof(StatsManager), "ItemRemove")] internal static class ApexAmmoRemoveStats { private static void Postfix(StatsManager __instance, string __0) { if (!SemiFunc.RunIsArena() && !string.IsNullOrEmpty(__0)) { ApexAmmo.EnsureStats(__instance).Remove(__0); } } } [HarmonyPatch(typeof(ItemBattery), "RemoveFullBar")] internal static class ApexAmmoConsume { private static bool Prefix(ItemBattery __instance, int __0) { ApexAmmo component = ((Component)__instance).GetComponent<ApexAmmo>(); if (!Object.op_Implicit((Object)(object)component) || __0 != 1 || !SemiFunc.IsMasterClientOrSingleplayer() || SemiFunc.RunIsShop()) { return true; } return component.ConsumeShot(); } } [HarmonyPatch(typeof(ItemGun), "Shoot")] internal static class ApexAmmoEmpty { private static bool Prefix(ItemGun __instance, ref bool __result) { ApexAmmo component = ((Component)__instance).GetComponent<ApexAmmo>(); if (!Object.op_Implicit((Object)(object)component) || component.RemainingShots > 0) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(ItemBattery), "BatteryFullPercentChangeLogic")] internal static class ApexAmmoRecharge { private static void Postfix(ItemBattery __instance, bool __1) { if (__1) { ApexAmmo component = ((Component)__instance).GetComponent<ApexAmmo>(); if (Object.op_Implicit((Object)(object)component)) { component.RefilledBar(); } } } } public static class ApexAmmoMath { public static int ShotsRemaining(int bars, int used) { int num = Math.Max(0, Math.Min(5, bars)); if (num == 0) { return 0; } return num * 200 - ClampUsed(used); } public static bool TryConsume(ref int used) { used = ClampUsed(used) + 1; if (used < 200) { return false; } used = 0; return true; } public static int ClampUsed(int used) { return Math.Max(0, Math.Min(199, used)); } } internal static class ApexDuckAudio { internal const string RootName = "Apex Duck Quack"; private const string DuckResource = "Enemies/Enemy - Duck"; internal static void Prepare(GameObject projectilePrefab) { //IL_00ea: 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_025d: Unknown result type (might be due to invalid IL or missing references) //IL_0263: Invalid comparison between Unknown and I4 if (!Object.op_Implicit((Object)(object)projectilePrefab)) { throw new ArgumentNullException("projectilePrefab"); } Transform val = projectilePrefab.transform.Find("Apex Duck Quack"); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Component)val).GetComponent<AudioSource>()) && Object.op_Implicit((Object)(object)((Component)val).GetComponent<AudioSource>().clip)) { return; } GameObject val2 = Resources.Load<GameObject>("Enemies/Enemy - Duck"); EnemyDuckAnim val3 = (Object.op_Implicit((Object)(object)val2) ? val2.GetComponentInChildren<EnemyDuckAnim>(true) : null); Sound val4 = (Object.op_Implicit((Object)(object)val3) ? val3.quackSound : null); AudioClip val5 = null; if (val4 != null && val4.Sounds != null) { AudioClip[] sounds = val4.Sounds; foreach (AudioClip val6 in sounds) { if (Object.op_Implicit((Object)(object)val6) && !(val6.length <= 0f)) { val5 = val6; break; } } } if (!Object.op_Implicit((Object)(object)val5)) { throw new InvalidOperationException("Native Apex Predator quack audio is unavailable."); } GameObject val7 = (GameObject)(Object.op_Implicit((Object)(object)val) ? ((object)((Component)val).gameObject) : ((object)new GameObject("Apex Duck Quack"))); val7.transform.SetParent(projectilePrefab.transform, false); val7.layer = projectilePrefab.layer; AudioSource val8 = val7.GetComponent<AudioSource>(); if (!Object.op_Implicit((Object)(object)val8)) { val8 = val7.AddComponent<AudioSource>(); } val8.playOnAwake = false; val8.loop = false; val8.clip = val5; val8.volume = Mathf.Clamp01(val4.Volume); val8.pitch = Mathf.Clamp(val4.Pitch, 0.1f, 3f); val8.spatialBlend = Mathf.Clamp01(val4.SpatialBlend); val8.dopplerLevel = 0f; val8.reverbZoneMix = Mathf.Clamp(val4.ReverbMix, 0f, 1.1f); AudioManager instance = AudioManager.instance; AudioSource val9 = ((Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)instance.AudioDefault)) ? instance.AudioDefault.GetComponent<AudioSource>() : null); float num = Mathf.Max(0.01f, val4.FalloffMultiplier); val8.minDistance = (Object.op_Implicit((Object)(object)val9) ? val9.minDistance : 2f) * num; val8.maxDistance = (Object.op_Implicit((Object)(object)val9) ? val9.maxDistance : 30f) * num; val8.rolloffMode = (AudioRolloffMode)(Object.op_Implicit((Object)(object)val9) ? ((int)val9.rolloffMode) : 0); if (Object.op_Implicit((Object)(object)val9) && (int)val9.rolloffMode == 2) { val8.SetCustomCurve((AudioSourceCurveType)0, val9.GetCustomCurve((AudioSourceCurveType)0)); } if (Object.op_Implicit((Object)(object)val9)) { val8.outputAudioMixerGroup = val9.outputAudioMixerGroup; } else if (Object.op_Implicit((Object)(object)instance)) { val8.outputAudioMixerGroup = instance.SoundMasterGroup; } } internal static bool Play(GameObject projectile) { if (!Object.op_Implicit((Object)(object)projectile)) { return false; } Transform val = projectile.transform.Find("Apex Duck Quack"); AudioSource val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<AudioSource>() : null); if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val2.clip) || !((Behaviour)val2).isActiveAndEnabled) { return false; } if (Object.op_Implicit((Object)(object)AudioManager.instance) && Object.op_Implicit((Object)(object)AudioManager.instance.SoundMasterGroup)) { val2.outputAudioMixerGroup = AudioManager.instance.SoundMasterGroup; } val2.Play(); return true; } } internal static class ApexDuckVisual { internal const string RootName = "Apex Duck Visual"; private const string DuckResource = "Enemies/Enemy - Duck"; private const float MaximumSize = 0.5f; internal static void Attach(GameObject grenade) { //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_00a0: 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_00b6: 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_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)grenade) || Object.op_Implicit((Object)(object)grenade.transform.Find("Apex Duck Visual"))) { return; } GameObject val = null; try { GameObject val2 = Resources.Load<GameObject>("Enemies/Enemy - Duck"); Transform val3 = (Object.op_Implicit((Object)(object)val2) ? val2.transform.Find("Enable/Visuals") : null); if (!Object.op_Implicit((Object)(object)val3)) { throw new InvalidOperationException("Native Apex Predator duck visual resource is unavailable."); } val = new GameObject("Apex Duck Visual"); val.SetActive(false); val.transform.SetParent(grenade.transform, false); val.layer = grenade.layer; Transform val4 = CopyVisualTransforms(val3, val.transform, grenade.layer); val4.localPosition = Vector3.zero; val4.localRotation = Quaternion.identity; val4.localScale = Vector3.one; if (!TryMeshBounds(val4, out var bounds)) { throw new InvalidOperationException("Native Apex Predator duck has no active mesh pieces."); } Vector3 size = ((Bounds)(ref bounds)).size; float num = Mathf.Max(size.x, Mathf.Max(size.y, size.z)); if (num <= 0.001f) { throw new InvalidOperationException("Native duck mesh bounds are empty."); } float num2 = 0.5f / num; val4.localScale = Vector3.one * num2; val4.localPosition = -((Bounds)(ref bounds)).center * num2; val.transform.localPosition = Vector3.up * (((Bounds)(ref bounds)).extents.y * num2 - 0.21f); HideRenderers(grenade.transform.Find("Mesh")); HideRenderers(grenade.transform.Find("Splinter")); val.SetActive(true); } catch (Exception ex) { if (Object.op_Implicit((Object)(object)val)) { Object.Destroy((Object)(object)val); } ApexLauncherPlugin.LogWarning("Duck visual could not be created: " + ex.Message); } } private static Transform CopyVisualTransforms(Transform source, Transform parent, int layer) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(((Object)source).name); val.layer = layer; Transform transform = val.transform; transform.SetParent(parent, false); transform.localPosition = source.localPosition; transform.localRotation = source.localRotation; transform.localScale = source.localScale; MeshFilter component = ((Component)source).GetComponent<MeshFilter>(); MeshRenderer component2 = ((Component)source).GetComponent<MeshRenderer>(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.sharedMesh) && Object.op_Implicit((Object)(object)component2) && ((Renderer)component2).enabled) { val.AddComponent<MeshFilter>().sharedMesh = component.sharedMesh; MeshRenderer val2 = val.AddComponent<MeshRenderer>(); ((Renderer)val2).sharedMaterials = ((Renderer)component2).sharedMaterials; ((Renderer)val2).shadowCastingMode = ((Renderer)component2).shadowCastingMode; ((Renderer)val2).receiveShadows = ((Renderer)component2).receiveShadows; ((Renderer)val2).lightProbeUsage = ((Renderer)component2).lightProbeUsage; ((Renderer)val2).reflectionProbeUsage = ((Renderer)component2).reflectionProbeUsage; } for (int i = 0; i < source.childCount; i++) { Transform child = source.GetChild(i); if (((Component)child).gameObject.activeSelf) { CopyVisualTransforms(child, transform, layer); } } return transform; } private static bool TryMeshBounds(Transform root, out Bounds bounds) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_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_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_005e: 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_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) bounds = default(Bounds); bool flag = false; MeshFilter[] componentsInChildren = ((Component)root).GetComponentsInChildren<MeshFilter>(true); Vector3 val3 = default(Vector3); foreach (MeshFilter val in componentsInChildren) { if (!Object.op_Implicit((Object)(object)val.sharedMesh)) { continue; } Bounds bounds2 = val.sharedMesh.bounds; Vector3 min = ((Bounds)(ref bounds2)).min; Vector3 max = ((Bounds)(ref bounds2)).max; Matrix4x4 val2 = root.worldToLocalMatrix * ((Component)val).transform.localToWorldMatrix; for (int j = 0; j < 8; j++) { ((Vector3)(ref val3))..ctor(((j & 1) == 0) ? min.x : max.x, ((j & 2) == 0) ? min.y : max.y, ((j & 4) == 0) ? min.z : max.z); Vector3 val4 = ((Matrix4x4)(ref val2)).MultiplyPoint3x4(val3); if (!flag) { bounds = new Bounds(val4, Vector3.zero); flag = true; } else { ((Bounds)(ref bounds)).Encapsulate(val4); } } } return flag; } private static void HideRenderers(Transform target) { if (Object.op_Implicit((Object)(object)target)) { Renderer[] componentsInChildren = ((Component)target).GetComponentsInChildren<Renderer>(true); foreach (Renderer val in componentsInChildren) { val.enabled = false; } } } } internal static class ApexFactory { internal const string ItemId = "Item Apex Predator Launcher"; internal const string LauncherPath = "Items/CaspiApexPredatorLauncher"; internal const string ProjectilePath = "Items/CaspiApexDuckProjectile"; private static GameObject holder; private static bool reportedFailure; internal static Item Definition { get; private set; } internal static GameObject LauncherPrefab { get; private set; } internal static GameObject ProjectilePrefab { get; private set; } internal static void Validate() { ApexAmmo.Validate(); if (AccessTools.Method(typeof(ItemGun), "ShootBullet", (Type[])null, (Type[])null) == null || AccessTools.Field(typeof(PhysGrabObject), "lastPlayerGrabbing") == null || AccessTools.Field(typeof(ItemGrenadeExplosive), "particleScriptExplosion") == null || AccessTools.Field(typeof(ItemGrenadeExplosive), "itemGrenade") == null) { throw new InvalidOperationException("Required launcher/grenade APIs are missing in this game version."); } } internal static void EnsureRegistered(StatsManager stats) { if (!Object.op_Implicit((Object)(object)stats)) { return; } try { ApexAmmo.EnsureStats(stats); if (!Object.op_Implicit((Object)(object)LauncherPrefab) || !Object.op_Implicit((Object)(object)ProjectilePrefab) || !Object.op_Implicit((Object)(object)Definition)) { Build(); } if (stats.itemDictionary.TryGetValue("Item Apex Predator Launcher", out var value) && (Object)(object)value != (Object)(object)Definition) { throw new InvalidOperationException("Another mod has registered Item Apex Predator Launcher"); } stats.itemDictionary["Item Apex Predator Launcher"] = Definition; RegisterPools(); } catch (Exception ex) { if (!reportedFailure) { reportedFailure = true; ApexLauncherPlugin.LogWarning("Apex launcher registration failed: " + ex); } } } private static void Build() { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_016a: 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_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Expected O, but got Unknown GameObject val = Resources.Load<GameObject>("Items/Item Gun Shotgun"); GameObject val2 = Resources.Load<GameObject>("Items/Item Grenade Explosive"); ItemAttributes val3 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<ItemAttributes>() : null); if (!Object.op_Implicit((Object)(object)val3) || !Object.op_Implicit((Object)(object)val3.item) || !Object.op_Implicit((Object)(object)val3.item.value) || !Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val2.GetComponent<ItemGrenade>()) || !Object.op_Implicit((Object)(object)val2.GetComponent<ItemGrenadeExplosive>())) { throw new InvalidOperationException("Native shotgun or explosive grenade prefab is unavailable."); } GameObject val4 = new GameObject("Apex launcher prefab holder"); val4.SetActive(false); ((Object)val4).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)val4); try { GameObject val5 = Object.Instantiate<GameObject>(val2, val4.transform, false); ((Object)val5).name = "Apex Duck Projectile"; val5.GetComponent<ItemGrenade>().tickTime = 1f; val5.GetComponent<ItemGrenade>().isSpawnedGrenade = true; val5.GetComponent<ItemToggle>().toggleState = false; ItemEquippable component = val5.GetComponent<ItemEquippable>(); if (Object.op_Implicit((Object)(object)component)) { ((Behaviour)component).enabled = false; } val5.AddComponent<ApexProjectile>(); ApexDuckVisual.Attach(val5); Transform val6 = val5.transform.Find("Apex Duck Visual"); if (!Object.op_Implicit((Object)(object)val6) || !((Component)val6).gameObject.activeSelf || ((Component)val6).GetComponentsInChildren<MeshRenderer>(true).Length == 0) { throw new InvalidOperationException("Duck projectile visual could not be built."); } Transform val7 = val5.transform.Find("Semi Sphere Collider"); if (Object.op_Implicit((Object)(object)val7)) { val7.localScale = Vector3.one * 0.42f; } Rigidbody component2 = val5.GetComponent<Rigidbody>(); component2.constraints = (RigidbodyConstraints)(component2.constraints | 0x70); ApexDuckAudio.Prepare(val5); val5.SetActive(true); GameObject val8 = Object.Instantiate<GameObject>(val, val4.transform, false); ((Object)val8).name = "Item Apex Predator Launcher"; Item val9 = Object.Instantiate<Item>(val3.item); ((Object)val9).name = "Item Apex Predator Launcher"; ((Object)val9).hideFlags = (HideFlags)61; val9.itemName = "Apex Predator Launcher"; val9.itemNameLocalized = null; val9.description = "1,000 duck shots per full charge. First impact: wait 5 seconds, QUACK, wait 1 second, BOOM."; val9.disabled = false; val9.minPlayerCount = 1; val9.maxAmountInShop = 1; val9.maxPurchase = false; val9.value = Object.Instantiate<Value>(val3.item.value); ((Object)val9.value).name = "Apex Predator Launcher Price"; ((Object)val9.value).hideFlags = (HideFlags)61; if (ApexLauncherPlugin.BasePrice.Value > 0) { val9.value.valueMin = (val9.value.valueMax = ApexLauncherPlugin.BasePrice.Value); } val9.prefab = new PrefabRef(); ((PrefabRef<GameObject>)(object)val9.prefab).SetPrefab(val8, "Items/CaspiApexPredatorLauncher"); val8.GetComponent<ItemAttributes>().item = val9; ItemGun component3 = val8.GetComponent<ItemGun>(); if (!Object.op_Implicit((Object)(object)component3) || !Object.op_Implicit((Object)(object)component3.gunMuzzle)) { throw new InvalidOperationException("Native shotgun has no gun muzzle."); } component3.numberOfBullets = 1; component3.hasOneShot = true; component3.hasBuildUp = false; component3.gunRandomSpread = 0f; component3.misfirePercentageChange = 0f; component3.batteryDrainFullBar = true; component3.batteryDrainFullBars = 1; val8.AddComponent<ApexLauncherMarker>(); ItemBattery component4 = val8.GetComponent<ItemBattery>(); if (!Object.op_Implicit((Object)(object)component4)) { throw new InvalidOperationException("Native shotgun has no battery."); } component4.batteryBars = 5; component4.autoDrain = false; val8.AddComponent<ApexAmmo>(); ApexLauncherVisual.Attach(val8); val8.SetActive(true); holder = val4; Definition = val9; LauncherPrefab = val8; ProjectilePrefab = val5; } catch { Object.Destroy((Object)(object)val4); throw; } } internal static GameObject Resolve(string path) { if (path == "Items/CaspiApexPredatorLauncher") { return LauncherPrefab; } if (path == "Items/CaspiApexDuckProjectile") { return ProjectilePrefab; } return null; } internal static void RegisterPools() { if (Object.op_Implicit((Object)(object)RunManager.instance) && Object.op_Implicit((Object)(object)LauncherPrefab) && Object.op_Implicit((Object)(object)ProjectilePrefab)) { Dictionary<string, Object> dictionary = AccessTools.Field(typeof(RunManager), "singleplayerPool").GetValue(RunManager.instance) as Dictionary<string, Object>; object? value = AccessTools.Field(typeof(RunManager), "multiplayerPool").GetValue(RunManager.instance); MultiplayerPool val = (MultiplayerPool)((value is MultiplayerPool) ? value : null); if (dictionary != null) { dictionary["Items/CaspiApexPredatorLauncher"] = (Object)(object)LauncherPrefab; dictionary["Items/CaspiApexDuckProjectile"] = (Object)(object)ProjectilePrefab; } if (val != null) { val.ResourceCache["Items/CaspiApexPredatorLauncher"] = LauncherPrefab; val.ResourceCache["Items/CaspiApexDuckProjectile"] = ProjectilePrefab; } } } } [HarmonyPatch(typeof(StatsManager), "LoadItemsFromFolder")] internal static class ApexItemRegistration { private static void Postfix(StatsManager __instance) { ApexFactory.EnsureRegistered(__instance); } } [HarmonyPatch(typeof(LevelGenerator), "Start")] internal static class ApexScenePool { private static void Postfix() { ApexFactory.RegisterPools(); } } [HarmonyPatch(typeof(PrefabRef<GameObject>), "get_Prefab")] internal static class ApexPrefabReference { private static bool Prefix(PrefabRef<GameObject> __instance, ref GameObject __result) { GameObject val = ApexFactory.Resolve(__instance.ResourcePath); if (!Object.op_Implicit((Object)(object)val)) { return true; } __result = val; return false; } } [HarmonyPatch(typeof(MultiplayerPool), "Instantiate")] internal static class ApexNetworkPrefab { private static void Prefix(MultiplayerPool __instance, string __0) { GameObject val = ApexFactory.Resolve(__0); if (Object.op_Implicit((Object)(object)val)) { __instance.ResourceCache[__0] = val; } } } [HarmonyPatch(typeof(ItemGun), "ShootBullet")] internal static class ApexFiring { private static bool Prefix(ItemGun __instance) { if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<ApexLauncherMarker>())) { return true; } if (SemiFunc.IsMasterClientOrSingleplayer()) { ApexProjectile.Spawn(__instance); } return false; } } [BepInPlugin("caspi.apexpredatorlauncher", "Apex Predator Launcher", "0.1.2")] public sealed class ApexLauncherPlugin : BaseUnityPlugin { public const string PluginId = "caspi.apexpredatorlauncher"; public const string Version = "0.1.2"; public const int AmmoCapacity = 1000; public const int ShotsPerBar = 200; public const float ImpactWaitSeconds = 5f; public const float AfterQuackFuseSeconds = 1f; internal static ConfigEntry<float> LaunchSpeed; internal static ConfigEntry<int> BasePrice; private Harmony harmony; public static ApexLauncherPlugin Instance { get; private set; } private void Awake() { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Expected O, but got Unknown GameObject gameObject = ((Component)this).gameObject; ((Object)gameObject).hideFlags = (HideFlags)(((Object)gameObject).hideFlags | 0x3D); Instance = this; BasePrice = ((BaseUnityPlugin)this).Config.Bind<int>("Shop", "BasePrice", 0, new ConfigDescription("Base shop price before the game's multiplier and rounding. 0 retains the original shotgun's price range. Restart after changing.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 1000000), new object[0])); LaunchSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Launcher", "LaunchSpeed", 18f, new ConfigDescription("Initial duck projectile speed in game units per second. Host setting applies to all shots.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 35f), new object[0])); try { ApexFactory.Validate(); harmony = new Harmony("caspi.apexpredatorlauncher"); harmony.PatchAll(typeof(ApexLauncherPlugin).Assembly); if (Object.op_Implicit((Object)(object)StatsManager.instance)) { ApexFactory.EnsureRegistered(StatsManager.instance); } ((BaseUnityPlugin)this).Logger.LogInfo((object)"Apex Predator Launcher 0.1.2 loaded. Upright ducks wait five seconds after first impact, quack once, then explode one second later."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Apex Predator Launcher could not initialize: " + ex)); if (harmony != null) { harmony.UnpatchSelf(); } ((Behaviour)this).enabled = false; } } internal static void LogWarning(string message) { if (Object.op_Implicit((Object)(object)Instance)) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)message); } } private void OnDestroy() { if (harmony != null) { harmony.UnpatchSelf(); } if ((Object)(object)Instance == (Object)(object)this) { Instance = null; } } } public sealed class ApexLauncherMarker : MonoBehaviour { } internal static class ApexLauncherVisual { private sealed class MeshBuilder { private readonly List<Vector3> vertices = new List<Vector3>(); private readonly List<Vector2> uv = new List<Vector2>(); private readonly List<int> triangles = new List<int>(); internal void Quad(Vector3 a, Vector3 b, Vector3 c, Vector3 d) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: 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_0053: 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_0073: Unknown result type (might be due to invalid IL or missing references) int count = vertices.Count; vertices.Add(a); vertices.Add(b); vertices.Add(c); vertices.Add(d); uv.Add(Vector2.zero); uv.Add(Vector2.right); uv.Add(Vector2.one); uv.Add(Vector2.up); triangles.Add(count); triangles.Add(count + 1); triangles.Add(count + 2); triangles.Add(count); triangles.Add(count + 2); triangles.Add(count + 3); } internal Mesh Finish(string name) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown Mesh val = new Mesh(); ((Object)val).name = name; val.vertices = vertices.ToArray(); val.uv = uv.ToArray(); val.triangles = triangles.ToArray(); val.RecalculateNormals(); val.RecalculateBounds(); return val; } } private const string VisualName = "Apex Predator Launcher - original barrel shroud"; private static Material graphite; private static Material black; private static Material yellow; private static Material orange; private static Mesh cube; private static Mesh barrel; private static Mesh muzzleBand; private static Mesh rearBand; internal static void Attach(GameObject launcher) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)launcher)) { return; } ItemGun component = launcher.GetComponent<ItemGun>(); if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.gunMuzzle) || Object.op_Implicit((Object)(object)component.gunMuzzle.Find("Apex Predator Launcher - original barrel shroud")) || !PrepareAssets()) { return; } GameObject val = new GameObject("Apex Predator Launcher - original barrel shroud"); val.layer = launcher.layer; val.transform.SetParent(component.gunMuzzle, false); AddMesh(val.transform, "Apex - hollow graphite barrel", barrel, graphite); AddMesh(val.transform, "Apex - yellow muzzle rim", muzzleBand, yellow); AddMesh(val.transform, "Apex - rear safety band", rearBand, yellow); AddBox(val.transform, "Apex - sight rail", new Vector3(0f, 0.151f, -0.2f), new Vector3(0.065f, 0.035f, 0.32f), black); AddBox(val.transform, "Apex - front sight", new Vector3(0f, 0.196f, -0.08f), new Vector3(0.023f, 0.065f, 0.027f), yellow); AddBox(val.transform, "Apex - rear sight left", new Vector3(-0.024f, 0.18f, -0.35f), new Vector3(0.015f, 0.045f, 0.025f), graphite); AddBox(val.transform, "Apex - rear sight right", new Vector3(0.024f, 0.18f, -0.35f), new Vector3(0.015f, 0.045f, 0.025f), graphite); for (int i = -1; i <= 1; i += 2) { AddBox(val.transform, "Apex - yellow side guard " + i, new Vector3((float)i * 0.145f, -0.003f, -0.2f), new Vector3(0.017f, 0.114f, 0.2f), yellow); for (int j = 0; j < 3; j++) { GameObject val2 = AddBox(val.transform, "Apex - hazard slash " + i + " " + j, new Vector3((float)i * 0.156f, -0.003f, -0.145f - (float)j * 0.055f), new Vector3(0.01f, 0.107f, 0.02f), black); val2.transform.localRotation = Quaternion.Euler(24f, 0f, 0f); } AddBox(val.transform, "Apex - orange chamber latch " + i, new Vector3((float)i * 0.152f, 0.026f, -0.353f), new Vector3(0.027f, 0.045f, 0.06f), orange); } } private static bool PrepareAssets() { //IL_00b2: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)graphite) && Object.op_Implicit((Object)(object)black) && Object.op_Implicit((Object)(object)yellow) && Object.op_Implicit((Object)(object)orange) && Object.op_Implicit((Object)(object)cube) && Object.op_Implicit((Object)(object)barrel) && Object.op_Implicit((Object)(object)muzzleBand) && Object.op_Implicit((Object)(object)rearBand)) { return true; } Shader val = Shader.Find("Standard"); if (!Object.op_Implicit((Object)(object)val)) { val = Shader.Find("Unlit/Color"); } if (!Object.op_Implicit((Object)(object)val)) { val = Shader.Find("Sprites/Default"); } if (!Object.op_Implicit((Object)(object)val)) { return false; } graphite = MaterialFor(val, "Apex graphite metal", new Color(0.065f, 0.077f, 0.082f), 0.6f); black = MaterialFor(val, "Apex black fittings", new Color(0.016f, 0.02f, 0.021f), 0.15f); yellow = MaterialFor(val, "Apex yellow safety paint", new Color(0.96f, 0.65f, 0.055f), 0.25f); orange = MaterialFor(val, "Apex orange chamber latch", new Color(0.98f, 0.28f, 0.035f), 0.2f); cube = MakeCube(); barrel = MakeTube("Apex original hollow barrel mesh", 0.145f, 0.111f, -0.39f, 0.125f); muzzleBand = MakeTube("Apex original open muzzle ring mesh", 0.158f, 0.111f, 0.08f, 0.132f); rearBand = MakeTube("Apex original rear ring mesh", 0.151f, 0.143f, -0.375f, -0.332f); return true; } private static Material MaterialFor(Shader shader, string name, Color color, float metallic) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_000f: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(shader); ((Object)val).name = name; val.color = color; if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", metallic); } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", 0.27f); } return val; } private static GameObject AddMesh(Transform parent, string name, Mesh mesh, Material material) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown GameObject val = new GameObject(name); val.layer = ((Component)parent).gameObject.layer; val.transform.SetParent(parent, false); val.AddComponent<MeshFilter>().sharedMesh = mesh; ((Renderer)val.AddComponent<MeshRenderer>()).sharedMaterial = material; return val; } private static GameObject AddBox(Transform parent, string name, Vector3 position, Vector3 scale, Material material) { //IL_0015: 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) GameObject val = AddMesh(parent, name, cube, material); val.transform.localPosition = position; val.transform.localScale = scale; return val; } private static Mesh MakeTube(string name, float outer, float inner, float back, float front) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_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) //IL_0090: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: 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_00b6: 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_00ba: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) MeshBuilder meshBuilder = new MeshBuilder(); for (int i = 0; i < 16; i++) { float angle = ((float)i + 0.5f) * (float)Math.PI * 2f / 16f; float angle2 = ((float)i + 1.5f) * (float)Math.PI * 2f / 16f; Vector3 a = Point(angle, outer, back); Vector3 val = Point(angle2, outer, back); Vector3 val2 = Point(angle, inner, back); Vector3 val3 = Point(angle2, inner, back); Vector3 val4 = Point(angle, outer, front); Vector3 val5 = Point(angle2, outer, front); Vector3 val6 = Point(angle, inner, front); Vector3 c = Point(angle2, inner, front); meshBuilder.Quad(a, val, val5, val4); meshBuilder.Quad(val2, val6, c, val3); meshBuilder.Quad(val4, val5, c, val6); meshBuilder.Quad(a, val2, val3, val); } return meshBuilder.Finish(name); } private static Vector3 Point(float angle, float radius, float z) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) return new Vector3(Mathf.Cos(angle) * radius, Mathf.Sin(angle) * radius, z); } private static Mesh MakeCube() { //IL_00b7: 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_00ba: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: 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_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_00f8: 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) MeshBuilder meshBuilder = new MeshBuilder(); Vector3 a = default(Vector3); ((Vector3)(ref a))..ctor(-0.5f, -0.5f, -0.5f); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(0.5f, -0.5f, -0.5f); Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0.5f, 0.5f, -0.5f); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(-0.5f, 0.5f, -0.5f); Vector3 val4 = default(Vector3); ((Vector3)(ref val4))..ctor(-0.5f, -0.5f, 0.5f); Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(0.5f, -0.5f, 0.5f); Vector3 c = default(Vector3); ((Vector3)(ref c))..ctor(0.5f, 0.5f, 0.5f); Vector3 val6 = default(Vector3); ((Vector3)(ref val6))..ctor(-0.5f, 0.5f, 0.5f); meshBuilder.Quad(a, val3, val2, val); meshBuilder.Quad(val4, val5, c, val6); meshBuilder.Quad(a, val4, val6, val3); meshBuilder.Quad(val, val2, c, val5); meshBuilder.Quad(val3, val6, c, val2); meshBuilder.Quad(a, val, val5, val4); return meshBuilder.Finish("Apex original accent box mesh"); } } public sealed class ApexProjectile : MonoBehaviour { private static readonly FieldInfo LastGrabber = AccessTools.Field(typeof(PhysGrabObject), "lastPlayerGrabbing"); private ItemGrenade grenade; private ItemToggle itemToggle; private PhysGrabObject grabObject; private Rigidbody body; private PlayerAvatar shooter; private GameObject launcher; private Vector3 initialVelocity; private bool initialized; private bool ready; private bool pendingImpact; private bool quackRequested; public bool HasImpacted { get; private set; } public bool HasQuacked { get; private set; } public float QuackedAt { get; private set; } public float ImpactAt { get; private set; } public float LaunchedAt { get; private set; } internal static void Spawn(ItemGun gun) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //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) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_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_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_0165: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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) if (!SemiFunc.IsMasterClientOrSingleplayer() || !Object.op_Implicit((Object)(object)gun) || !Object.op_Implicit((Object)(object)gun.gunMuzzle)) { return; } if (!Object.op_Implicit((Object)(object)ApexFactory.ProjectilePrefab)) { ApexLauncherPlugin.LogWarning("Cannot fire: duck projectile prefab is unavailable."); return; } PhysGrabObject component = ((Component)gun).GetComponent<PhysGrabObject>(); PlayerAvatar val = (PlayerAvatar)(Object.op_Implicit((Object)(object)component) ? /*isinst with value type is only supported in some contexts*/: null); PhotonView component2 = ((Component)gun).GetComponent<PhotonView>(); PhotonView val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<PhotonView>() : null); Vector3 val3 = gun.gunMuzzle.forward * ApexLauncherPlugin.LaunchSpeed.Value; Vector3 position = gun.gunMuzzle.position; Vector3 val4 = Vector3.ProjectOnPlane(gun.gunMuzzle.forward, Vector3.up); if (((Vector3)(ref val4)).sqrMagnitude < 0.001f) { val4 = Vector3.ProjectOnPlane(((Component)gun).transform.forward, Vector3.up); } if (((Vector3)(ref val4)).sqrMagnitude < 0.001f) { val4 = Vector3.forward; } Quaternion val5 = Quaternion.LookRotation(((Vector3)(ref val4)).normalized, Vector3.up); GameObject val6 = ((!SemiFunc.IsMultiplayer()) ? Object.Instantiate<GameObject>(ApexFactory.ProjectilePrefab, position, val5) : PhotonNetwork.InstantiateRoomObject("Items/CaspiApexDuckProjectile", position, val5, (byte)0, new object[3] { val3, Object.op_Implicit((Object)(object)component2) ? component2.ViewID : 0, Object.op_Implicit((Object)(object)val2) ? val2.ViewID : 0 })); ApexProjectile apexProjectile = (Object.op_Implicit((Object)(object)val6) ? val6.GetComponent<ApexProjectile>() : null); if (Object.op_Implicit((Object)(object)apexProjectile)) { apexProjectile.Initialize(val3, ((Component)gun).gameObject, val); } } private void Awake() { //IL_0080: 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) grenade = ((Component)this).GetComponent<ItemGrenade>(); itemToggle = ((Component)this).GetComponent<ItemToggle>(); grabObject = ((Component)this).GetComponent<PhysGrabObject>(); body = ((Component)this).GetComponent<Rigidbody>(); ImpactAt = -1f; QuackedAt = -1f; LaunchedAt = Time.time; grenade.isSpawnedGrenade = true; grenade.tickTime = 1f; itemToggle.toggleState = false; Rigidbody obj = body; obj.constraints = (RigidbodyConstraints)(obj.constraints | 0x70); ItemEquippable component = ((Component)this).GetComponent<ItemEquippable>(); if (Object.op_Implicit((Object)(object)component)) { ((Behaviour)component).enabled = false; } ProtectProjectile(); } internal void Initialize(Vector3 velocity, GameObject firingLauncher, PlayerAvatar firingPlayer) { //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) initialVelocity = velocity; launcher = firingLauncher; shooter = firingPlayer; initialized = true; IgnoreSourceColliders(); } private IEnumerator Start() { if (!initialized) { PhotonView component = ((Component)this).GetComponent<PhotonView>(); object[] array = (Object.op_Implicit((Object)(object)component) ? component.InstantiationData : null); if (array != null && array.Length == 3 && array[0] is Vector3 && array[1] is int && array[2] is int) { PhotonView val = (((int)array[1] > 0) ? PhotonView.Find((int)array[1]) : null); PhotonView val2 = (((int)array[2] > 0) ? PhotonView.Find((int)array[2]) : null); Initialize((Vector3)array[0], Object.op_Implicit((Object)(object)val) ? ((Component)val).gameObject : null, Object.op_Implicit((Object)(object)val2) ? ((Component)val2).GetComponent<PlayerAvatar>() : null); } } yield return null; IgnoreSourceColliders(); if (SemiFunc.IsMasterClientOrSingleplayer()) { if (Object.op_Implicit((Object)(object)shooter)) { grenade.SetActivator(shooter); } body.isKinematic = false; body.useGravity = true; body.collisionDetectionMode = (CollisionDetectionMode)2; body.velocity = initialVelocity; body.angularVelocity = Vector3.zero; body.WakeUp(); } ready = true; if (pendingImpact) { Arm(); } } private void IgnoreSourceColliders() { Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(true); foreach (Collider val in componentsInChildren) { if (Object.op_Implicit((Object)(object)launcher)) { Collider[] componentsInChildren2 = launcher.GetComponentsInChildren<Collider>(true); foreach (Collider val2 in componentsInChildren2) { Physics.IgnoreCollision(val, val2, true); } } if (Object.op_Implicit((Object)(object)shooter)) { Collider[] componentsInChildren3 = ((Component)shooter).GetComponentsInChildren<Collider>(true); foreach (Collider val3 in componentsInChildren3) { Physics.IgnoreCollision(val, val3, true); } } } } private void ProtectProjectile() { if (Object.op_Implicit((Object)(object)grabObject)) { grabObject.OverrideIndestructible(1f); grabObject.OverrideGrabDisable(1f); } } private void Update() { ProtectProjectile(); if (ready && HasImpacted && !quackRequested && SemiFunc.IsMasterClientOrSingleplayer() && Time.time - ImpactAt >= 5f) { QuackAndArm(); } if (!HasImpacted && Time.time - LaunchedAt > 90f && SemiFunc.IsMasterClientOrSingleplayer()) { PhysGrabObjectImpactDetector component = ((Component)this).GetComponent<PhysGrabObjectImpactDetector>(); if (Object.op_Implicit((Object)(object)component)) { component.DestroyObject(false); } } } private void OnCollisionEnter(Collision collision) { if (HasImpacted || !SemiFunc.IsMasterClientOrSingleplayer() || collision == null || !Object.op_Implicit((Object)(object)collision.collider)) { return; } Transform transform = ((Component)collision.collider).transform; if ((!Object.op_Implicit((Object)(object)launcher) || !transform.IsChildOf(launcher.transform)) && (!Object.op_Implicit((Object)(object)shooter) || !transform.IsChildOf(((Component)shooter).transform))) { if (!ready) { pendingImpact = true; } else { Arm(); } } } private void Arm() { if (!HasImpacted && ready && SemiFunc.IsMasterClientOrSingleplayer()) { HasImpacted = true; ImpactAt = Time.time; } } private void QuackAndArm() { //IL_003a: 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) if (!quackRequested && SemiFunc.IsMasterClientOrSingleplayer()) { quackRequested = true; if (SemiFunc.IsMultiplayer()) { ((Component)this).GetComponent<PhotonView>().RPC("ApexDuckQuackRPC", (RpcTarget)0, new object[0]); } else { ApexDuckQuackRPC(default(PhotonMessageInfo)); } grenade.tickTime = 1f; PhotonView val = (Object.op_Implicit((Object)(object)shooter) ? ((Component)shooter).GetComponent<PhotonView>() : null); itemToggle.ToggleItem(true, Object.op_Implicit((Object)(object)val) ? val.ViewID : (-1)); } } [PunRPC] public void ApexDuckQuackRPC(PhotonMessageInfo info) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) if (SemiFunc.MasterOnlyRPC(info) && !HasQuacked) { HasQuacked = true; QuackedAt = Time.time; ApexDuckAudio.Play(((Component)this).gameObject); } } } [HarmonyPatch(typeof(ItemToggle), "Update")] internal static class ApexProjectileToggleInput { private static bool Prefix(ItemToggle __instance) { return !Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<ApexProjectile>()); } } [HarmonyPatch(typeof(ItemGrenadeExplosive), "Start")] internal static class ApexProjectileExplosiveStart { private static readonly FieldInfo ExplosionField = AccessTools.Field(typeof(ItemGrenadeExplosive), "particleScriptExplosion"); private static readonly FieldInfo GrenadeField = AccessTools.Field(typeof(ItemGrenadeExplosive), "itemGrenade"); private static bool Prefix(ItemGrenadeExplosive __instance) { if (!Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<ApexProjectile>())) { return true; } ExplosionField.SetValue(__instance, ((Component)__instance).GetComponent<ParticleScriptExplosion>()); GrenadeField.SetValue(__instance, ((Component)__instance).GetComponent<ItemGrenade>()); return false; } } [HarmonyPatch(typeof(StatsManager), "ItemFetchName")] internal static class ApexProjectileInventoryName { private static bool Prefix(ItemAttributes __1) { if (Object.op_Implicit((Object)(object)__1)) { return !Object.op_Implicit((Object)(object)((Component)__1).GetComponent<ApexProjectile>()); } return true; } } [HarmonyPatch(typeof(ItemManager), "AddSpawnedItem")] internal static class ApexProjectileSpawnedInventory { private static bool Prefix(ItemAttributes __0) { if (Object.op_Implicit((Object)(object)__0)) { return !Object.op_Implicit((Object)(object)((Component)__0).GetComponent<ApexProjectile>()); } return true; } } [HarmonyPatch(typeof(ItemAttributes), "ShopInTruckLogic")] internal static class ApexProjectileShopTracking { private static bool Prefix(ItemAttributes __instance) { return !Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<ApexProjectile>()); } } [HarmonyPatch(typeof(ItemAttributes), "Start")] internal static class ApexProjectileItemPrompt { private static readonly FieldInfo DisableUi = AccessTools.Field(typeof(ItemAttributes), "disableUI"); private static void Prefix(ItemAttributes __instance) { if (Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<ApexProjectile>()) && DisableUi != null) { DisableUi.SetValue(__instance, true); } } }