using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("newgan")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("newgan")]
[assembly: AssemblyTitle("newgan")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace UltrakillMglMod;
[BepInPlugin("com.custom.ultrakill.mgl", "MGL Grenade Launcher", "0.5.1")]
public class MglPlugin : BaseUnityPlugin
{
public static GameObject MglModelPrefab;
public static Sprite MglCustomIcon;
public static GameObject ActiveMglWeapon;
public static GameObject PreviousWeaponBeforeMgl;
public static bool IsMglEquipped;
private void Awake()
{
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0137: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00c1: Expected O, but got Unknown
//IL_00f6: 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)
string directoryName = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
string text = Path.Combine(directoryName, "mgl_bundle");
if (File.Exists(text))
{
AssetBundle val = AssetBundle.LoadFromFile(text);
if ((Object)(object)val != (Object)null)
{
MglModelPrefab = val.LoadAsset<GameObject>("MGL_Prefab");
((BaseUnityPlugin)this).Logger.LogInfo((object)(((Object)(object)MglModelPrefab != (Object)null) ? "[MGL] Префаб MGL_Prefab успешно загружен из бандла!" : "[MGL] Бандл открыт, но MGL_Prefab внутри не найден!"));
}
}
else
{
((BaseUnityPlugin)this).Logger.LogError((object)("[MGL] Файл mgl_bundle не найден рядом с DLL: " + text));
}
string path = Path.Combine(directoryName, "mgl_icon.png");
if (File.Exists(path))
{
byte[] array = File.ReadAllBytes(path);
Texture2D val2 = new Texture2D(2, 2, (TextureFormat)4, false);
if (ImageConversion.LoadImage(val2, array))
{
((Texture)val2).filterMode = (FilterMode)0;
MglCustomIcon = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 100f);
((BaseUnityPlugin)this).Logger.LogInfo((object)"[MGL] Иконка mgl_icon.png успешно загружена!");
}
}
Harmony val3 = new Harmony("com.custom.ultrakill.mgl");
val3.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"MGL Mod loaded!");
}
private void Update()
{
GunControl instance = MonoSingleton<GunControl>.Instance;
if (!((Object)(object)instance == (Object)null) && instance.activated && (!((Object)(object)GameStateManager.Instance != (Object)null) || !GameStateManager.Instance.PlayerInputLocked))
{
bool flag = Input.GetKeyDown((KeyCode)116);
if (!flag && Keyboard.current != null && ((ButtonControl)Keyboard.current.tKey).wasPressedThisFrame)
{
flag = true;
}
if (flag)
{
ToggleMglWeapon(instance);
}
}
}
public static void ToggleMglWeapon(GunControl gc)
{
if ((Object)(object)gc == (Object)null)
{
return;
}
if ((Object)(object)ActiveMglWeapon == (Object)null)
{
CreateMglWeapon(gc);
}
if ((Object)(object)ActiveMglWeapon == (Object)null)
{
return;
}
if (IsMglEquipped && (Object)(object)gc.currentWeapon == (Object)(object)ActiveMglWeapon)
{
IsMglEquipped = false;
ActiveMglWeapon.SetActive(false);
GameObject val = PreviousWeaponBeforeMgl;
if ((Object)(object)val == (Object)null || (Object)(object)val == (Object)(object)ActiveMglWeapon)
{
val = ((IEnumerable<GameObject>)gc.allWeapons).FirstOrDefault((Func<GameObject, bool>)((GameObject w) => (Object)(object)w != (Object)null && (Object)(object)w != (Object)(object)ActiveMglWeapon));
}
if ((Object)(object)val != (Object)null)
{
int num = ((gc.slotDict == null || !gc.slotDict.ContainsKey(val)) ? 1 : gc.slotDict[val]);
int value = 0;
if (num == 1 && gc.slot1 != null)
{
value = Mathf.Max(0, gc.slot1.IndexOf(val));
}
else if (num == 2 && gc.slot2 != null)
{
value = Mathf.Max(0, gc.slot2.IndexOf(val));
}
else if (num == 3 && gc.slot3 != null)
{
value = Mathf.Max(0, gc.slot3.IndexOf(val));
}
else if (num == 4 && gc.slot4 != null)
{
value = Mathf.Max(0, gc.slot4.IndexOf(val));
}
else if (num == 5 && gc.slot5 != null)
{
value = Mathf.Max(0, gc.slot5.IndexOf(val));
}
gc.SwitchWeapon(num, (int?)value, false, false, false);
val.SetActive(true);
gc.currentWeapon = val;
WeaponIcon componentInChildren = val.GetComponentInChildren<WeaponIcon>(true);
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.UpdateIcon();
}
}
return;
}
if ((Object)(object)gc.currentWeapon != (Object)null && (Object)(object)gc.currentWeapon != (Object)(object)ActiveMglWeapon)
{
PreviousWeaponBeforeMgl = gc.currentWeapon;
gc.currentWeapon.SetActive(false);
}
foreach (GameObject allWeapon in gc.allWeapons)
{
if ((Object)(object)allWeapon != (Object)null && (Object)(object)allWeapon != (Object)(object)ActiveMglWeapon && allWeapon.activeSelf)
{
allWeapon.SetActive(false);
}
}
IsMglEquipped = true;
gc.currentWeapon = ActiveMglWeapon;
ActiveMglWeapon.SetActive(true);
MglLauncher component = ActiveMglWeapon.GetComponent<MglLauncher>();
if ((Object)(object)component != (Object)null)
{
component.ResetSwitchDelay();
}
WeaponIcon componentInChildren2 = ActiveMglWeapon.GetComponentInChildren<WeaponIcon>(true);
if ((Object)(object)componentInChildren2 != (Object)null)
{
componentInChildren2.UpdateIcon();
}
}
public static GameObject CreateMglWeapon(GunControl gc)
{
if ((Object)(object)gc == (Object)null || gc.slot5 == null)
{
return null;
}
if ((Object)(object)ActiveMglWeapon != (Object)null)
{
if (gc.slot5.Contains(ActiveMglWeapon))
{
gc.slot5.Remove(ActiveMglWeapon);
}
if (gc.allWeapons != null && !gc.allWeapons.Contains(ActiveMglWeapon))
{
gc.allWeapons.Add(ActiveMglWeapon);
}
if (gc.slotDict != null && !gc.slotDict.ContainsKey(ActiveMglWeapon))
{
gc.slotDict[ActiveMglWeapon] = 4;
}
return ActiveMglWeapon;
}
GameObject val = ((IEnumerable<GameObject>)gc.slot5).FirstOrDefault((Func<GameObject, bool>)delegate(GameObject w)
{
if ((Object)(object)w == (Object)null)
{
return false;
}
RocketLauncher component3 = w.GetComponent<RocketLauncher>();
return (Object)(object)component3 != (Object)null && component3.variation == 2;
});
if ((Object)(object)val == (Object)null)
{
return null;
}
GameObject val2 = Object.Instantiate<GameObject>(val, val.transform.parent);
((Object)val2).name = "Rocket Launcher MGL";
val2.SetActive(false);
RocketLauncher component = val2.GetComponent<RocketLauncher>();
DisableNapalmVisuals(component, val2);
MglLauncher mglLauncher = val2.AddComponent<MglLauncher>();
mglLauncher.shootPoint = component.shootPoint;
mglLauncher.muzzleFlash = component.muzzleFlash;
mglLauncher.aud = val2.GetComponent<AudioSource>();
mglLauncher.anim = val2.GetComponent<Animator>();
mglLauncher.CachePrefabsStatic();
if ((Object)(object)component.rocket != (Object)null)
{
Grenade component2 = component.rocket.GetComponent<Grenade>();
if ((Object)(object)component2 != (Object)null && (Object)(object)component2.superExplosion != (Object)null)
{
MglLauncher.CachedSuperExplosionPrefab = component2.superExplosion;
}
}
if ((Object)(object)MglModelPrefab != (Object)null)
{
ApplyCustomModel(val2, mglLauncher);
}
if ((Object)(object)MglCustomIcon != (Object)null)
{
ApplyCustomHudIcon(val2);
}
Object.Destroy((Object)(object)component);
if (gc.slot5.Contains(val2))
{
gc.slot5.Remove(val2);
}
if (gc.allWeapons != null && !gc.allWeapons.Contains(val2))
{
gc.allWeapons.Add(val2);
}
if (gc.slotDict != null && !gc.slotDict.ContainsKey(val2))
{
gc.slotDict[val2] = 4;
}
ActiveMglWeapon = val2;
IsMglEquipped = false;
return val2;
}
private static void ApplyCustomHudIcon(GameObject mglObj)
{
WeaponIcon componentInChildren = mglObj.GetComponentInChildren<WeaponIcon>(true);
if ((Object)(object)componentInChildren == (Object)null)
{
return;
}
if ((Object)(object)componentInChildren.weaponDescriptor != (Object)null)
{
WeaponDescriptor val = Object.Instantiate<WeaponDescriptor>(componentInChildren.weaponDescriptor);
val.icon = MglCustomIcon;
val.glowIcon = MglCustomIcon;
componentInChildren.weaponDescriptor = val;
}
Image[] componentsInChildren = ((Component)componentInChildren).GetComponentsInChildren<Image>(true);
foreach (Image val2 in componentsInChildren)
{
if ((Object)(object)val2 != (Object)null)
{
val2.sprite = MglCustomIcon;
}
}
}
private static void ApplyCustomModel(GameObject mglObj, MglLauncher mgl)
{
//IL_00a4: 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_00cc: 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_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
Renderer[] componentsInChildren = mglObj.GetComponentsInChildren<Renderer>(true);
foreach (Renderer val in componentsInChildren)
{
val.enabled = false;
}
DisableWorldIndicators(mglObj);
Camera[] componentsInParent = mglObj.GetComponentsInParent<Camera>(true);
foreach (Camera val2 in componentsInParent)
{
if (val2.nearClipPlane > 0.01f)
{
val2.nearClipPlane = 0.01f;
}
}
GameObject val3 = Object.Instantiate<GameObject>(MglModelPrefab, mglObj.transform);
((Object)val3).name = "MGL_Visual";
val3.transform.localPosition = mgl.baseLocalPos;
val3.transform.localRotation = Quaternion.Euler(mgl.baseLocalRot);
val3.transform.localScale = Vector3.one * 0.65f;
mgl.visualTransform = val3.transform;
int layer = mglObj.layer;
Transform[] componentsInChildren2 = val3.GetComponentsInChildren<Transform>(true);
foreach (Transform val4 in componentsInChildren2)
{
((Component)val4).gameObject.layer = layer;
}
Shader val5 = Shader.Find("ULTRAKILL/Standard");
Renderer[] componentsInChildren3 = val3.GetComponentsInChildren<Renderer>(true);
foreach (Renderer val6 in componentsInChildren3)
{
val6.enabled = true;
Material[] materials = val6.materials;
foreach (Material val7 in materials)
{
if ((Object)(object)val7 == (Object)null)
{
continue;
}
Texture val8 = val7.mainTexture;
if ((Object)(object)val8 == (Object)null && val7.HasProperty("baseColorTexture"))
{
val8 = val7.GetTexture("baseColorTexture");
}
if ((Object)(object)val8 != (Object)null)
{
val8.filterMode = (FilterMode)0;
}
if ((Object)(object)val5 != (Object)null)
{
Color color = (val7.HasProperty("_Color") ? val7.color : Color.white);
val7.shader = val5;
if ((Object)(object)val8 != (Object)null)
{
val7.mainTexture = val8;
}
if (val7.HasProperty("_Color"))
{
val7.color = color;
}
}
}
}
Transform val9 = val3.transform.Find("ShootPoint");
if ((Object)(object)val9 != (Object)null)
{
mgl.shootPoint = val9;
}
}
public static void DisableWorldIndicators(GameObject mglObj)
{
if (!((Object)(object)mglObj == (Object)null))
{
Canvas[] componentsInChildren = mglObj.GetComponentsInChildren<Canvas>(true);
foreach (Canvas val in componentsInChildren)
{
((Component)val).gameObject.SetActive(false);
}
Image[] componentsInChildren2 = mglObj.GetComponentsInChildren<Image>(true);
foreach (Image val2 in componentsInChildren2)
{
((Behaviour)val2).enabled = false;
}
}
}
private static void DisableNapalmVisuals(RocketLauncher rl, GameObject root)
{
if ((Object)(object)rl != (Object)null)
{
FieldInfo[] fields = typeof(RocketLauncher).GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
FieldInfo[] array = fields;
foreach (FieldInfo fieldInfo in array)
{
if (!fieldInfo.Name.ToLower().Contains("napalm"))
{
continue;
}
object value = fieldInfo.GetValue(rl);
GameObject val = (GameObject)((value is GameObject) ? value : null);
if (val != null && (Object)(object)val != (Object)null && val.transform.IsChildOf(root.transform))
{
val.SetActive(false);
continue;
}
Component val2 = (Component)((value is Component) ? value : null);
if (val2 != null && (Object)(object)val2 != (Object)null && val2.transform.IsChildOf(root.transform))
{
val2.gameObject.SetActive(false);
}
}
}
ParticleSystem[] componentsInChildren = root.GetComponentsInChildren<ParticleSystem>(true);
foreach (ParticleSystem val3 in componentsInChildren)
{
val3.Stop(true, (ParticleSystemStopBehavior)0);
((Component)val3).gameObject.SetActive(false);
}
}
}
[HarmonyPatch(typeof(GunControl), "Start")]
public static class GunControlStartPatch
{
[HarmonyPostfix]
public static void Postfix(GunControl __instance)
{
MglPlugin.CreateMglWeapon(__instance);
}
}
[HarmonyPatch(typeof(GunControl), "Update")]
public static class GunControlUpdatePatch
{
[HarmonyPostfix]
public static void Postfix(GunControl __instance)
{
if (MglPlugin.IsMglEquipped && !((Object)(object)MglPlugin.ActiveMglWeapon == (Object)null) && !((Object)(object)__instance == (Object)null))
{
if ((Object)(object)__instance.currentWeapon != (Object)null && (Object)(object)__instance.currentWeapon != (Object)(object)MglPlugin.ActiveMglWeapon && __instance.currentWeapon.activeSelf)
{
MglPlugin.IsMglEquipped = false;
MglPlugin.ActiveMglWeapon.SetActive(false);
}
else if ((Object)(object)__instance.currentWeapon != (Object)(object)MglPlugin.ActiveMglWeapon || !MglPlugin.ActiveMglWeapon.activeSelf)
{
__instance.currentWeapon = MglPlugin.ActiveMglWeapon;
MglPlugin.ActiveMglWeapon.SetActive(true);
}
}
}
}
[HarmonyPatch(typeof(GunSetter), "ResetWeapons")]
public static class GunSetterResetWeaponsPatch
{
[HarmonyPostfix]
public static void Postfix()
{
if ((Object)(object)MonoSingleton<GunControl>.Instance != (Object)null)
{
MglPlugin.ActiveMglWeapon = null;
MglPlugin.IsMglEquipped = false;
MglPlugin.CreateMglWeapon(MonoSingleton<GunControl>.Instance);
}
}
}
[HarmonyPatch(typeof(StyleHUD), "GetLocalizedName")]
public static class StyleHudGetLocalizedNamePatch
{
[HarmonyPrefix]
public static bool Prefix(string id, ref string __result)
{
switch (id)
{
case "mgl.exploded":
__result = "ВЗОРВАН";
return false;
case "mgl.fireworks":
__result = "<color=#00ffffff>ФЕЙРВЕРК</color>";
return false;
case "mgl.godaim":
__result = "<color=green>ЕБЕЙШИЙ АИМ</color>";
return false;
default:
return true;
}
}
}
[HarmonyPatch(typeof(WalkingBob), "Update")]
public static class WalkingBobPatch
{
public struct BobState
{
public bool modified;
public Vector3 origRight;
public Vector3 origLeft;
public Vector3 posBeforeUpdate;
}
private static readonly FieldInfo RightPosField = typeof(WalkingBob).GetField("rightPos", BindingFlags.Instance | BindingFlags.NonPublic);
private static readonly FieldInfo LeftPosField = typeof(WalkingBob).GetField("leftPos", BindingFlags.Instance | BindingFlags.NonPublic);
private static readonly FieldInfo OriginalPosField = typeof(WalkingBob).GetField("originalPos", BindingFlags.Instance | BindingFlags.NonPublic);
private static readonly FieldInfo TargetField = typeof(WalkingBob).GetField("target", BindingFlags.Instance | BindingFlags.NonPublic);
[HarmonyPrefix]
public static void Prefix(WalkingBob __instance, out BobState __state)
{
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: 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_00c3: 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_00d1: 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_00d8: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_00f9: 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_0105: 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_010c: 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_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0120: Unknown result type (might be due to invalid IL or missing references)
//IL_0128: Unknown result type (might be due to invalid IL or missing references)
//IL_013b: Unknown result type (might be due to invalid IL or missing references)
//IL_0165: Unknown result type (might be due to invalid IL or missing references)
//IL_016a: Unknown result type (might be due to invalid IL or missing references)
//IL_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_016e: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0191: Unknown result type (might be due to invalid IL or missing references)
//IL_0180: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
__state = new BobState
{
modified = false
};
if ((Object)(object)__instance == (Object)null || RightPosField == null || LeftPosField == null || OriginalPosField == null || !((Object)(object)MglPlugin.ActiveMglWeapon != (Object)null) || !((Object)(object)MonoSingleton<GunControl>.Instance != (Object)null) || !((Object)(object)MonoSingleton<GunControl>.Instance.currentWeapon == (Object)(object)MglPlugin.ActiveMglWeapon))
{
return;
}
Vector3 val = (Vector3)OriginalPosField.GetValue(__instance);
Vector3 val2 = (Vector3)RightPosField.GetValue(__instance);
Vector3 val3 = (Vector3)LeftPosField.GetValue(__instance);
__state.modified = true;
__state.origRight = val2;
__state.origLeft = val3;
__state.posBeforeUpdate = ((Component)__instance).transform.localPosition;
float num = 0.35f;
Vector3 val4 = val + (val2 - val) * num;
Vector3 val5 = val + (val3 - val) * num;
RightPosField.SetValue(__instance, val4);
LeftPosField.SetValue(__instance, val5);
if (TargetField != null)
{
Vector3 val6 = (Vector3)TargetField.GetValue(__instance);
if (val6 == val2)
{
TargetField.SetValue(__instance, val4);
}
else if (val6 == val3)
{
TargetField.SetValue(__instance, val5);
}
}
}
[HarmonyPostfix]
public static void Postfix(WalkingBob __instance, BobState __state)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: 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_0065: 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_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00af: Unknown result type (might be due to invalid IL or missing references)
//IL_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_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: 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_00d4: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_00ee: 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_0116: 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_012a: Unknown result type (might be due to invalid IL or missing references)
if (!__state.modified || (Object)(object)__instance == (Object)null)
{
return;
}
float num = 0.35f;
Vector3 localPosition = ((Component)__instance).transform.localPosition;
((Component)__instance).transform.localPosition = Vector3.Lerp(__state.posBeforeUpdate, localPosition, num);
RightPosField.SetValue(__instance, __state.origRight);
LeftPosField.SetValue(__instance, __state.origLeft);
if (TargetField != null)
{
Vector3 val = (Vector3)TargetField.GetValue(__instance);
Vector3 val2 = (Vector3)OriginalPosField.GetValue(__instance);
Vector3 val3 = val2 + (__state.origRight - val2) * 0.35f;
Vector3 val4 = val2 + (__state.origLeft - val2) * 0.35f;
if (val == val3)
{
TargetField.SetValue(__instance, __state.origRight);
}
else if (val == val4)
{
TargetField.SetValue(__instance, __state.origLeft);
}
}
}
}
[HarmonyPatch(typeof(EnemyIdentifier), "DeliverDamage")]
public static class EnemyDeliverDamagePatch
{
[HarmonyPrefix]
public static void Prefix(EnemyIdentifier __instance, ref bool __state)
{
__state = (Object)(object)__instance != (Object)null && !__instance.dead && __instance.health > 0f;
}
[HarmonyPostfix]
public static void Postfix(EnemyIdentifier __instance, GameObject sourceWeapon, bool __state)
{
if (!__state || (Object)(object)__instance == (Object)null || !__instance.dead || (Object)(object)MglPlugin.ActiveMglWeapon == (Object)null || (Object)(object)sourceWeapon != (Object)(object)MglPlugin.ActiveMglWeapon)
{
return;
}
MglGrenadeMarker currentExplodingGrenade = MglGrenadeMarker.CurrentExplodingGrenade;
if ((Object)(object)currentExplodingGrenade == (Object)null)
{
return;
}
StyleHUD instance = MonoSingleton<StyleHUD>.Instance;
if ((Object)(object)instance != (Object)null && !__instance.puppet)
{
if (currentExplodingGrenade.triggeredFireworks)
{
instance.AddPoints(120, "mgl.fireworks", MglPlugin.ActiveMglWeapon, __instance, -1, "", "");
}
else
{
instance.AddPoints(45, "mgl.exploded", MglPlugin.ActiveMglWeapon, __instance, -1, "", "");
}
}
if (currentExplodingGrenade.burstTracker != null)
{
currentExplodingGrenade.burstTracker.RegisterKill(currentExplodingGrenade.shotIndex, ((Object)__instance).GetInstanceID());
}
}
}
public class MglBurstTracker
{
private readonly HashSet<int> shotsWithKills = new HashSet<int>();
private readonly HashSet<int> countedEnemyIds = new HashSet<int>();
private bool bonusAwarded = false;
public void RegisterKill(int shotIndex, int enemyInstanceId)
{
if (bonusAwarded || countedEnemyIds.Contains(enemyInstanceId))
{
return;
}
countedEnemyIds.Add(enemyInstanceId);
shotsWithKills.Add(shotIndex);
if (shotsWithKills.Count >= 3)
{
bonusAwarded = true;
StyleHUD instance = MonoSingleton<StyleHUD>.Instance;
if ((Object)(object)instance != (Object)null && (Object)(object)MglPlugin.ActiveMglWeapon != (Object)null)
{
instance.AddPoints(250, "mgl.godaim", MglPlugin.ActiveMglWeapon, (EnemyIdentifier)null, -1, "", "");
}
}
}
}
public class MglGrenadeMarker : MonoBehaviour
{
public static MglGrenadeMarker CurrentExplodingGrenade;
public static readonly List<MglGrenadeMarker> ActiveRemoteGrenades = new List<MglGrenadeMarker>();
public MglBurstTracker burstTracker;
public int shotIndex;
public GameObject normalExplosion;
public GameObject superExplosion;
public bool triggeredFireworks = false;
public bool isRemoteControlled = false;
private bool hasDetonated = false;
private void OnEnable()
{
if (isRemoteControlled && !ActiveRemoteGrenades.Contains(this))
{
ActiveRemoteGrenades.Add(this);
}
}
private void OnDisable()
{
ActiveRemoteGrenades.Remove(this);
}
private void OnTriggerEnter(Collider other)
{
if (!hasDetonated && !isRemoteControlled && !((Object)(object)other == (Object)null))
{
CheckAirborneDirectHit(other);
}
}
private void OnCollisionEnter(Collision collision)
{
if (!hasDetonated && !isRemoteControlled && collision != null)
{
CheckAirborneDirectHit(collision.collider);
}
}
private void CheckAirborneDirectHit(Collider col)
{
//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)col == (Object)null)
{
return;
}
EnemyIdentifierIdentifier component = ((Component)col).GetComponent<EnemyIdentifierIdentifier>();
EnemyIdentifier val = (((Object)(object)component != (Object)null) ? component.eid : ((Component)col).GetComponentInParent<EnemyIdentifier>());
if ((Object)(object)val == (Object)null || val.dead || val.health <= 0f)
{
return;
}
bool flag = false;
if ((Object)(object)val.gce != (Object)null && !val.gce.onGround)
{
flag = true;
}
else
{
Rigidbody component2 = ((Component)val).GetComponent<Rigidbody>();
if ((Object)(object)component2 != (Object)null && component2.useGravity && Mathf.Abs(component2.velocity.y) > 1.2f)
{
flag = true;
}
}
if (flag)
{
triggeredFireworks = true;
Projectile component3 = ((Component)this).GetComponent<Projectile>();
if ((Object)(object)component3 != (Object)null && (Object)(object)superExplosion != (Object)null)
{
component3.explosionEffect = superExplosion;
}
}
}
public void RemoteDetonate()
{
//IL_0030: Unknown result type (might be due to invalid IL or missing references)
//IL_0121: 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)
if (hasDetonated)
{
return;
}
hasDetonated = true;
ActiveRemoteGrenades.Remove(this);
GameObject val = normalExplosion;
Collider[] array = Physics.OverlapSphere(((Component)this).transform.position, 4.5f);
Collider[] array2 = array;
foreach (Collider val2 in array2)
{
if ((Object)(object)val2 == (Object)null)
{
continue;
}
EnemyIdentifierIdentifier component = ((Component)val2).GetComponent<EnemyIdentifierIdentifier>();
EnemyIdentifier val3 = (((Object)(object)component != (Object)null) ? component.eid : ((Component)val2).GetComponentInParent<EnemyIdentifier>());
if ((Object)(object)val3 != (Object)null && !val3.dead && val3.health > 0f && (Object)(object)val3.gce != (Object)null && !val3.gce.onGround)
{
triggeredFireworks = true;
if ((Object)(object)superExplosion != (Object)null)
{
val = superExplosion;
}
break;
}
}
CurrentExplodingGrenade = this;
if ((Object)(object)val != (Object)null)
{
GameObject val4 = Object.Instantiate<GameObject>(val, ((Component)this).transform.position, Quaternion.identity);
Explosion[] componentsInChildren = val4.GetComponentsInChildren<Explosion>(true);
foreach (Explosion val5 in componentsInChildren)
{
val5.sourceWeapon = MglPlugin.ActiveMglWeapon;
}
}
CurrentExplodingGrenade = null;
Object.Destroy((Object)(object)((Component)this).gameObject);
}
private void OnDestroy()
{
ActiveRemoteGrenades.Remove(this);
if (!hasDetonated)
{
hasDetonated = true;
CurrentExplodingGrenade = this;
}
}
}
public class MglRemoteRollingGrenade : MonoBehaviour
{
public Vector3 initialVelocity;
private Rigidbody rb;
private bool touchedGround = false;
private float lifeTimer = 0f;
private void Awake()
{
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Expected O, but got Unknown
rb = ((Component)this).GetComponent<Rigidbody>();
if ((Object)(object)rb != (Object)null)
{
rb.isKinematic = false;
rb.useGravity = true;
rb.collisionDetectionMode = (CollisionDetectionMode)2;
rb.drag = 0.05f;
rb.angularDrag = 0.2f;
}
PhysicMaterial val = new PhysicMaterial("MglRollingMat");
val.bounciness = 0.55f;
val.dynamicFriction = 0.08f;
val.staticFriction = 0.08f;
val.frictionCombine = (PhysicMaterialCombine)2;
val.bounceCombine = (PhysicMaterialCombine)3;
Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(true);
foreach (Collider val2 in componentsInChildren)
{
if ((Object)(object)val2 != (Object)null)
{
val2.isTrigger = false;
val2.material = val;
}
}
}
private void Start()
{
//IL_0019: 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_0034: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)rb != (Object)null)
{
rb.velocity = initialVelocity;
rb.angularVelocity = Random.insideUnitSphere * 12f;
}
}
private void OnCollisionEnter(Collision collision)
{
if (collision != null && (!(lifeTimer < 0.08f) || !((Object)(object)collision.gameObject.GetComponentInParent<NewMovement>() != (Object)null)) && !touchedGround)
{
touchedGround = true;
if ((Object)(object)rb != (Object)null)
{
rb.drag = 1.45f;
rb.angularDrag = 1.8f;
}
}
}
private void FixedUpdate()
{
//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_0044: 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_005a: 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_006b: 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_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_009a: 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_00bc: 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)
lifeTimer += Time.fixedDeltaTime;
if (!((Object)(object)rb == (Object)null) && touchedGround)
{
Vector3 velocity = rb.velocity;
Vector3 val = default(Vector3);
((Vector3)(ref val))..ctor(velocity.x, 0f, velocity.z);
val = Vector3.MoveTowards(val, Vector3.zero, 1.4f * Time.fixedDeltaTime);
rb.velocity = new Vector3(val.x, velocity.y, val.z);
Vector3 velocity2 = rb.velocity;
if (((Vector3)(ref velocity2)).sqrMagnitude < 0.02f)
{
rb.velocity = Vector3.zero;
rb.angularVelocity = Vector3.zero;
}
}
}
}
public class MglLauncher : MonoBehaviour
{
public static GameObject CachedGrenadePrefab;
public static GameObject CachedExplosionPrefab;
public static GameObject CachedSuperExplosionPrefab;
public Transform shootPoint;
public GameObject muzzleFlash;
public AudioSource aud;
public Animator anim;
public Transform visualTransform;
public Vector3 baseLocalPos = new Vector3(0.15f, -0.145f, 0.08f);
public Vector3 baseLocalRot = new Vector3(-1.5f, -3.5f, 0f);
public int burstCount = 3;
public float timeBetweenShots = 0.13f;
public float burstCooldown = 0.85f;
public float launchSpeed = 80f;
public float upwardArc = 4.5f;
public float grenadeDamage = 13.5f;
private bool isFiring = false;
private float cooldownTimer = 0f;
private Vector3 currentRecoilPos = Vector3.zero;
private Vector3 currentRecoilRot = Vector3.zero;
private float equipProgress = 1f;
public void CachePrefabsStatic()
{
if ((Object)(object)CachedGrenadePrefab == (Object)null || (Object)(object)CachedExplosionPrefab == (Object)null)
{
Shotgun[] array = Resources.FindObjectsOfTypeAll<Shotgun>();
Shotgun[] array2 = array;
foreach (Shotgun val in array2)
{
if ((Object)(object)val != (Object)null && (Object)(object)val.bullet != (Object)null)
{
CachedGrenadePrefab = val.bullet;
if ((Object)(object)val.explosion != (Object)null)
{
CachedExplosionPrefab = val.explosion;
}
break;
}
}
if ((Object)(object)CachedExplosionPrefab == (Object)null && (Object)(object)MonoSingleton<DefaultReferenceManager>.Instance != (Object)null)
{
CachedExplosionPrefab = MonoSingleton<DefaultReferenceManager>.Instance.explosion;
}
}
if (!((Object)(object)CachedSuperExplosionPrefab == (Object)null))
{
return;
}
Grenade[] array3 = Resources.FindObjectsOfTypeAll<Grenade>();
Grenade[] array4 = array3;
foreach (Grenade val2 in array4)
{
if ((Object)(object)val2 != (Object)null && (Object)(object)val2.superExplosion != (Object)null)
{
CachedSuperExplosionPrefab = val2.superExplosion;
break;
}
}
}
public void ResetSwitchDelay()
{
isFiring = false;
cooldownTimer = 0f;
}
private void OnEnable()
{
//IL_0014: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
isFiring = false;
cooldownTimer = 0f;
currentRecoilPos = Vector3.zero;
currentRecoilRot = Vector3.zero;
equipProgress = 0f;
MglPlugin.DisableWorldIndicators(((Component)this).gameObject);
if ((Object)(object)CachedGrenadePrefab == (Object)null)
{
CachePrefabsStatic();
}
WeaponIcon componentInChildren = ((Component)this).GetComponentInChildren<WeaponIcon>(true);
if ((Object)(object)componentInChildren != (Object)null)
{
componentInChildren.UpdateIcon();
}
WeaponPos component = ((Component)this).GetComponent<WeaponPos>();
if ((Object)(object)component != (Object)null)
{
component.CheckPosition();
}
if ((Object)(object)anim != (Object)null)
{
anim.Play("Equip", -1, 0f);
}
}
private void OnDisable()
{
isFiring = false;
((MonoBehaviour)this).StopAllCoroutines();
}
private void Update()
{
//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_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0099: 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_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_00ee: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: 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_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: 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_011d: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_0124: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_0141: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: 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_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0153: Unknown result type (might be due to invalid IL or missing references)
//IL_0158: Unknown result type (might be due to invalid IL or missing references)
if (cooldownTimer > 0f)
{
cooldownTimer = Mathf.MoveTowards(cooldownTimer, 0f, Time.deltaTime);
}
if (equipProgress < 1f)
{
equipProgress = Mathf.MoveTowards(equipProgress, 1f, Time.deltaTime / 0.22f);
}
currentRecoilPos = Vector3.Lerp(currentRecoilPos, Vector3.zero, Time.deltaTime * 16f);
currentRecoilRot = Vector3.Lerp(currentRecoilRot, Vector3.zero, Time.deltaTime * 16f);
if ((Object)(object)visualTransform != (Object)null)
{
float num = 1f - Mathf.Pow(1f - equipProgress, 3f);
Vector3 val = Vector3.Lerp(new Vector3(0f, -0.35f, -0.15f), Vector3.zero, num);
Vector3 val2 = Vector3.Lerp(new Vector3(35f, 0f, 0f), Vector3.zero, num);
visualTransform.localPosition = baseLocalPos + val + currentRecoilPos;
visualTransform.localRotation = Quaternion.Euler(baseLocalRot + val2 + currentRecoilRot);
}
if (!MonoSingleton<GunControl>.Instance.activated || GameStateManager.Instance.PlayerInputLocked)
{
return;
}
MglGrenadeMarker.ActiveRemoteGrenades.RemoveAll((MglGrenadeMarker g) => (Object)(object)g == (Object)null);
bool flag = MglGrenadeMarker.ActiveRemoteGrenades.Count > 0;
if (MonoSingleton<InputManager>.Instance.InputSource.Fire2.WasPerformedThisFrame)
{
if (flag)
{
DetonateAllRemoteGrenades();
}
else if (!isFiring && cooldownTimer <= 0f)
{
if ((Object)(object)CachedGrenadePrefab == (Object)null)
{
CachePrefabsStatic();
}
if ((Object)(object)CachedGrenadePrefab != (Object)null)
{
((MonoBehaviour)this).StartCoroutine(FireBurst(remoteMode: true));
}
}
}
if (!flag && !isFiring && cooldownTimer <= 0f && MonoSingleton<InputManager>.Instance.InputSource.Fire1.IsPressed)
{
if ((Object)(object)CachedGrenadePrefab == (Object)null)
{
CachePrefabsStatic();
}
if ((Object)(object)CachedGrenadePrefab != (Object)null)
{
((MonoBehaviour)this).StartCoroutine(FireBurst(remoteMode: false));
}
}
}
private void DetonateAllRemoteGrenades()
{
//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_0091: 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_00ac: 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)
MglGrenadeMarker.ActiveRemoteGrenades.RemoveAll((MglGrenadeMarker g) => (Object)(object)g == (Object)null);
if (MglGrenadeMarker.ActiveRemoteGrenades.Count == 0)
{
return;
}
if ((Object)(object)aud != (Object)null)
{
AudioSourceExtensions.SetPitch(aud, 1.45f);
AudioSourceExtensions.Play(aud, true);
}
currentRecoilPos += new Vector3(0f, 0.025f, -0.02f);
currentRecoilRot += new Vector3(-4f, 0f, 0f);
List<MglGrenadeMarker> list = MglGrenadeMarker.ActiveRemoteGrenades.ToList();
foreach (MglGrenadeMarker item in list)
{
if ((Object)(object)item != (Object)null)
{
item.RemoteDetonate();
}
}
}
private IEnumerator FireBurst(bool remoteMode)
{
isFiring = true;
MglBurstTracker tracker = new MglBurstTracker();
for (int i = 0; i < burstCount; i++)
{
FireSingleGrenade(tracker, i, remoteMode);
if (i < burstCount - 1)
{
yield return (object)new WaitForSeconds(timeBetweenShots);
}
}
cooldownTimer = burstCooldown;
isFiring = false;
}
private void FireSingleGrenade(MglBurstTracker tracker, int shotIndex, bool remoteMode)
{
//IL_0082: 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_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_00a7: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
//IL_0156: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Unknown result type (might be due to invalid IL or missing references)
//IL_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_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Unknown result type (might be due to invalid IL or missing references)
//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_01f9: 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_02d4: Unknown result type (might be due to invalid IL or missing references)
//IL_02de: Unknown result type (might be due to invalid IL or missing references)
CameraController instance = MonoSingleton<CameraController>.Instance;
if ((Object)(object)aud != (Object)null)
{
AudioSourceExtensions.SetPitch(aud, remoteMode ? Random.Range(0.75f, 0.88f) : Random.Range(0.95f, 1.1f));
AudioSourceExtensions.Play(aud, true);
}
if ((Object)(object)anim != (Object)null)
{
anim.Play("Fire", -1, 0f);
}
currentRecoilPos += new Vector3(0f, 0.015f, -0.07f);
currentRecoilRot += new Vector3(-6.5f, 0f, 0f);
Vector3 val = ((Component)instance).transform.position + ((Component)instance).transform.forward * 1.2f;
GameObject val2 = Object.Instantiate<GameObject>(CachedGrenadePrefab, val, ((Component)instance).transform.rotation);
if ((Object)(object)MonoSingleton<CameraFrustumTargeter>.Instance != (Object)null && Object.op_Implicit((Object)(object)MonoSingleton<CameraFrustumTargeter>.Instance.CurrentTarget) && MonoSingleton<CameraFrustumTargeter>.Instance.IsAutoAimed)
{
val2.transform.LookAt(MonoSingleton<CameraFrustumTargeter>.Instance.CurrentTargetAimPosition);
}
Vector3 val3 = val2.transform.forward * launchSpeed + Vector3.up * upwardArc;
MglGrenadeMarker mglGrenadeMarker = val2.AddComponent<MglGrenadeMarker>();
mglGrenadeMarker.burstTracker = tracker;
mglGrenadeMarker.shotIndex = shotIndex;
mglGrenadeMarker.normalExplosion = CachedExplosionPrefab;
mglGrenadeMarker.superExplosion = CachedSuperExplosionPrefab;
mglGrenadeMarker.isRemoteControlled = remoteMode;
if (remoteMode)
{
MglGrenadeMarker.ActiveRemoteGrenades.Add(mglGrenadeMarker);
Projectile component = val2.GetComponent<Projectile>();
if ((Object)(object)component != (Object)null)
{
Object.DestroyImmediate((Object)(object)component);
}
MglRemoteRollingGrenade mglRemoteRollingGrenade = val2.AddComponent<MglRemoteRollingGrenade>();
mglRemoteRollingGrenade.initialVelocity = val3 * 0.72f;
}
else
{
Projectile component2 = val2.GetComponent<Projectile>();
if ((Object)(object)component2 != (Object)null)
{
component2.sourceWeapon = MonoSingleton<GunControl>.Instance.currentWeapon;
component2.playerBullet = true;
component2.friendly = true;
component2.boosted = false;
component2.weaponType = "";
component2.bulletType = "mgl_grenade";
component2.damage = grenadeDamage;
component2.speed = 0f;
component2.ignoreExplosions = true;
component2.undeflectable = true;
component2.breakable = false;
component2.precheckForCollisions = true;
if ((Object)(object)CachedExplosionPrefab != (Object)null)
{
component2.explosionEffect = CachedExplosionPrefab;
}
}
MglBallisticGrenade mglBallisticGrenade = val2.AddComponent<MglBallisticGrenade>();
mglBallisticGrenade.velocity = val3;
}
Transform transform = val2.transform;
transform.localScale *= 1.8f;
instance.CameraShake(0.5f);
}
}
public class MglBallisticGrenade : MonoBehaviour
{
public Vector3 velocity;
private Rigidbody rb;
private void Awake()
{
//IL_0032: Unknown result type (might be due to invalid IL or missing references)
rb = ((Component)this).GetComponent<Rigidbody>();
if ((Object)(object)rb != (Object)null)
{
rb.useGravity = false;
rb.velocity = velocity;
}
}
private void FixedUpdate()
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: 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_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)rb == (Object)null))
{
velocity += Physics.gravity * Time.fixedDeltaTime;
rb.velocity = velocity;
if (((Vector3)(ref velocity)).sqrMagnitude > 0.01f)
{
((Component)this).transform.rotation = Quaternion.LookRotation(((Vector3)(ref velocity)).normalized);
}
}
}
}