using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mirror;
using TMPro;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Components;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("GameAssembly")]
[assembly: IgnoresAccessChecksTo("SharedAssembly")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SBGGrenade")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+725fde1687ebdf77eaf2edf8ce7c4bf9c4d1a305")]
[assembly: AssemblyProduct("SBGGrenade")]
[assembly: AssemblyTitle("SBGGrenade")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace SBGGrenade
{
public class ExplosionVfx : MonoBehaviour
{
private float _duration = 0.4f;
private float _timer;
private float _maxScale;
private Renderer _renderer;
private Material _material;
public static void Create(Vector3 position, float radius)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
((Object)obj).name = "ExplosionVFX";
obj.transform.position = position;
obj.transform.localScale = Vector3.one * 0.1f;
Collider component = obj.GetComponent<Collider>();
if ((Object)(object)component != (Object)null)
{
Object.Destroy((Object)(object)component);
}
obj.AddComponent<ExplosionVfx>()._maxScale = radius * 0.6f;
}
private void Start()
{
//IL_00df: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Expected O, but got Unknown
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
_renderer = ((Component)this).GetComponent<Renderer>();
Shader val = Shader.Find("Universal Render Pipeline/Lit");
if ((Object)(object)val != (Object)null)
{
_material = new Material(val);
_material.SetFloat("_Surface", 1f);
_material.SetFloat("_Blend", 0f);
_material.SetOverrideTag("RenderType", "Transparent");
_material.SetInt("_SrcBlend", 5);
_material.SetInt("_DstBlend", 10);
_material.SetInt("_ZWrite", 0);
_material.renderQueue = 3000;
_material.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
_material.EnableKeyword("_EMISSION");
}
else
{
_material = new Material(Shader.Find("Standard"));
_material.SetFloat("_Mode", 3f);
_material.SetInt("_SrcBlend", 5);
_material.SetInt("_DstBlend", 10);
_material.SetInt("_ZWrite", 0);
_material.renderQueue = 3000;
}
_renderer.material = _material;
}
private void Update()
{
//IL_0053: 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_0088: 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_00a1: 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)
_timer += Time.deltaTime;
float num = Mathf.Clamp01(_timer / _duration);
float num2 = 1f - (1f - num) * (1f - num);
float num3 = Mathf.Lerp(0.1f, _maxScale, num2);
((Component)this).transform.localScale = Vector3.one * num3;
float num4 = 1f - num;
Color val = default(Color);
((Color)(ref val))..ctor(1f, 0.5f, 0f, num4);
_material.color = val;
_material.SetColor("_EmissionColor", val * 3f * num4);
if (_timer >= _duration)
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
}
public static class GrenadeConstants
{
public const int GrenadeItemTypeId = 99;
public const int GrenadeEquipmentTypeId = 99;
public static readonly ItemType GrenadeItemType = (ItemType)99;
public static readonly EquipmentType GrenadeEquipmentType = (EquipmentType)99;
}
public static class GrenadeEquipmentFactory
{
private static EquipmentSettings _cachedSettings;
private static Equipment _prefabEquipment;
public static EquipmentSettings GetOrCreateSettings()
{
//IL_0024: 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_00df: 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_0119: Expected O, but got Unknown
//IL_0123: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Expected O, but got Unknown
//IL_0085: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
if (_cachedSettings != null)
{
return _cachedSettings;
}
GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
((Object)obj).name = "GrenadeEquipment";
obj.transform.localScale = Vector3.one * 0.15f;
Collider component = obj.GetComponent<Collider>();
if ((Object)(object)component != (Object)null)
{
Object.Destroy((Object)(object)component);
}
Renderer component2 = obj.GetComponent<Renderer>();
Shader val = Shader.Find("Universal Render Pipeline/Lit");
if ((Object)(object)val != (Object)null)
{
Material val2 = new Material(val);
val2.color = new Color(0.2f, 0.8f, 0.2f, 1f);
val2.EnableKeyword("_EMISSION");
val2.SetColor("_EmissionColor", new Color(0.2f, 0.8f, 0.2f) * 0.3f);
component2.material = val2;
}
_prefabEquipment = obj.AddComponent<Equipment>();
SetBackingField(_prefabEquipment, "Type", GrenadeConstants.GrenadeEquipmentType);
SetBackingField(_prefabEquipment, "HasCosmetics", false);
obj.SetActive(false);
Object.DontDestroyOnLoad((Object)(object)obj);
_cachedSettings = new EquipmentSettings();
SetBackingField(_cachedSettings, "Type", GrenadeConstants.GrenadeEquipmentType);
SetBackingField(_cachedSettings, "Prefab", _prefabEquipment);
return _cachedSettings;
}
public static Equipment ClonePrefab()
{
if ((Object)(object)_prefabEquipment == (Object)null)
{
GetOrCreateSettings();
}
Equipment obj = Object.Instantiate<Equipment>(_prefabEquipment);
((Component)obj).gameObject.SetActive(false);
Object.DontDestroyOnLoad((Object)(object)((Component)obj).gameObject);
return obj;
}
private static void SetBackingField(object obj, string propertyName, object value)
{
obj.GetType().GetField("<" + propertyName + ">k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(obj, value);
}
}
public static class GrenadeItemDataFactory
{
private static ItemData _cachedItemData;
private static Sprite _cachedIcon;
public static ItemData GetOrCreate()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_0021: 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)
if (_cachedItemData != null)
{
return _cachedItemData;
}
_cachedItemData = new ItemData();
SetBackingField(_cachedItemData, "Type", GrenadeConstants.GrenadeItemType);
SetBackingField(_cachedItemData, "Icon", GetOrCreateIcon());
SetBackingField(_cachedItemData, "MaxUses", Plugin.MaxUses.Value);
SetBackingField(_cachedItemData, "IsExplosive", true);
SetBackingField(_cachedItemData, "NonAimUse", (object)(ItemNonAimingUse)0);
SetBackingField(_cachedItemData, "CanUsageAffectBalls", true);
SetBackingField(_cachedItemData, "HitTransfersToGolfCartPassengers", false);
_cachedItemData.Initialize();
try
{
((DetailedLocalizationTable<StringTableEntry>)(object)((LocalizedDatabase<StringTable, StringTableEntry>)(object)LocalizationSettings.StringDatabase).GetTable(TableReference.op_Implicit("Data"), (Locale)null))?.AddEntry("ITEM_99", "Grenade");
}
catch (Exception)
{
}
return _cachedItemData;
}
public static Sprite GetOrCreateIcon()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_00fb: 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_0070: 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_009b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_cachedIcon != (Object)null)
{
return _cachedIcon;
}
int num = 64;
Texture2D val = new Texture2D(num, num, (TextureFormat)4, false);
float num2 = (float)num / 2f;
float num3 = (float)num / 2f;
float num4 = num3 - 3f;
for (int i = 0; i < num; i++)
{
for (int j = 0; j < num; j++)
{
float num5 = (float)j - num2;
float num6 = (float)i - num2;
float num7 = Mathf.Sqrt(num5 * num5 + num6 * num6);
if (num7 > num3)
{
val.SetPixel(j, i, Color.clear);
}
else if (num7 > num4)
{
val.SetPixel(j, i, new Color(0.1f, 0.2f, 0.1f, 1f));
}
else
{
val.SetPixel(j, i, new Color(0.2f, 0.8f, 0.2f, 1f));
}
}
}
val.Apply();
_cachedIcon = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), 100f);
((Object)_cachedIcon).name = "GrenadeIcon";
return _cachedIcon;
}
private static void SetBackingField(object obj, string propertyName, object value)
{
obj.GetType().GetField("<" + propertyName + ">k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(obj, value);
}
}
public class GrenadeProjectile : MonoBehaviour
{
private static readonly ManualLogSource Log = Logger.CreateLogSource("SBGGrenade.Projectile");
private float _timer;
private float _fuseTime;
private Renderer _renderer;
private bool _exploded;
private PlayerInventory _ownerInventory;
private ItemUseId _itemUseId;
public static void Spawn(Vector3 position, Vector3 velocity, PlayerInventory owner, ItemUseId itemUseId)
{
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: 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_00c1: 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_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: 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)
GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0);
((Object)obj).name = "GrenadeProjectile";
obj.transform.position = position;
obj.transform.localScale = Vector3.one * 0.3f;
Renderer component = obj.GetComponent<Renderer>();
Shader val = Shader.Find("Universal Render Pipeline/Lit");
if ((Object)(object)val != (Object)null)
{
Material val2 = new Material(val);
val2.color = Color.green;
val2.EnableKeyword("_EMISSION");
val2.SetColor("_EmissionColor", Color.green * 0.5f);
component.material = val2;
}
Rigidbody obj2 = obj.AddComponent<Rigidbody>();
obj2.mass = 0.5f;
obj2.collisionDetectionMode = (CollisionDetectionMode)1;
obj2.linearVelocity = velocity;
obj.layer = 0;
GrenadeProjectile grenadeProjectile = obj.AddComponent<GrenadeProjectile>();
grenadeProjectile._ownerInventory = owner;
grenadeProjectile._itemUseId = itemUseId;
}
private void Start()
{
_fuseTime = Plugin.FuseTime.Value;
_timer = 0f;
_renderer = ((Component)this).GetComponent<Renderer>();
}
private void Update()
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: 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_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00a4: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
if (!_exploded)
{
_timer += Time.deltaTime;
float num = Mathf.Clamp01(_timer / _fuseTime);
Color val = Color.Lerp(Color.green, Color.red, num);
_renderer.material.color = val;
float num2 = Mathf.Lerp(2f, 12f, num);
float num3 = (Mathf.Sin(Time.time * num2) + 1f) * 0.5f;
Color val2 = val * Mathf.Lerp(0.3f, 2f, num3 * num);
_renderer.material.SetColor("_EmissionColor", val2);
float num4 = 0.3f + num3 * num * 0.05f;
((Component)this).transform.localScale = Vector3.one * num4;
if (_timer >= _fuseTime)
{
Explode();
}
}
}
private void OnCollisionEnter(Collision collision)
{
if (!_exploded && _timer >= _fuseTime * 0.7f)
{
Explode();
}
}
private void Explode()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_0042: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0136: Unknown result type (might be due to invalid IL or missing references)
//IL_0167: 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_0185: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_0197: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_0127: 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_012c: Unknown result type (might be due to invalid IL or missing references)
if (_exploded)
{
return;
}
_exploded = true;
float value = Plugin.ExplosionRadius.Value;
Vector3 position = ((Component)this).transform.position;
Log.LogInfo((object)$"[Explode] pos={position}, radius={value}, layerMask={GameManager.LayerSettings.RocketHittablesMask}");
int num = Physics.OverlapSphereNonAlloc(position, value, PlayerGolfer.overlappingColliderBuffer, LayerMask.op_Implicit(GameManager.LayerSettings.RocketHittablesMask), (QueryTriggerInteraction)1);
Log.LogInfo((object)$"[Explode] OverlapSphere found {num} colliders");
PlayerGolfer.processedHittableBuffer.Clear();
Hittable val2 = default(Hittable);
Vector3 val3 = default(Vector3);
float num2 = default(float);
for (int i = 0; i < num; i++)
{
Collider val = PlayerGolfer.overlappingColliderBuffer[i];
if (!ComponentExtensions.TryGetComponentInParent<Hittable>((Component)(object)val, ref val2, true))
{
Log.LogInfo((object)("[Explode] collider '" + ((Object)val).name + "' has no Hittable, skipping"));
}
else if (PlayerGolfer.processedHittableBuffer.Add(val2))
{
if (!ComponentExtensions.TryGetClosestPointOnAllActiveColliders((Component)(object)val2, position, ref val3, ref num2, -1))
{
num2 = 0f;
val3 = (val2.AsEntity.HasRigidbody ? val2.AsEntity.Rigidbody.worldCenterOfMass : ((Component)val2).transform.position);
}
Vector3 val4 = val3 - position;
float num3 = BMath.Sqrt(num2);
Log.LogInfo((object)$"[Explode] Hittable '{((Object)val2).name}' dist={num3:F3} dir={val4} closestPt={val3}");
val2.HitWithItem(GrenadeConstants.GrenadeItemType, _itemUseId, ((Component)val2).transform.InverseTransformPoint(val3), val4, ((Component)val2).transform.InverseTransformPoint(position), num3, _ownerInventory, false, false, true);
}
}
ExplosionVfx.Create(position, value);
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
public static class GrenadeUseHandler
{
public static IEnumerator ThrowGrenadeRoutine(PlayerInventory inventory)
{
PlayerInfo playerInfo = inventory.PlayerInfo;
inventory.SetCurrentItemUse((ItemUseType)2);
if (BMath.Abs(FloatExtensions.WrapAngleDeg(VectorExtensions.GetYawDeg(((Component)GameManager.Camera).transform.forward) - playerInfo.Movement.Yaw)) > 45f)
{
playerInfo.Movement.AlignWithCameraImmediately();
}
yield return (object)new WaitForSeconds(0.2f);
Vector3 position = default(Vector3);
Quaternion val = default(Quaternion);
((Component)playerInfo.RightHandEquipmentSwitcher).transform.GetPositionAndRotation(ref position, ref val);
Vector3 forward = ((Component)GameManager.Camera).transform.forward;
Vector3 velocity = playerInfo.Rigidbody.linearVelocity + forward * Plugin.ThrowForce.Value;
ItemUseId itemUseId = inventory.IncrementAndGetCurrentItemUseId(GrenadeConstants.GrenadeItemType);
GrenadeProjectile.Spawn(position, velocity, inventory, itemUseId);
inventory.MarkThrownItem((ThrownItemHand)2);
inventory.DecrementUseFromSlotAt(inventory.EquippedItemIndex);
yield return (object)new WaitForSeconds(0.3f);
inventory.SetCurrentItemUse((ItemUseType)0);
inventory.RemoveIfOutOfUses(inventory.EquippedItemIndex);
}
}
[BepInPlugin("SBGGrenade", "SBGGrenade", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
public static ConfigEntry<float> GrenadeSpawnWeight;
public static ConfigEntry<int> MaxUses;
public static ConfigEntry<float> ThrowForce;
public static ConfigEntry<float> FuseTime;
public static ConfigEntry<float> ExplosionRadius;
public static ConfigEntry<float> MaxKnockbackDistance;
public static ConfigEntry<float> MinKnockbackDistance;
public static ConfigEntry<float> MaxKnockbackSpeed;
public static ConfigEntry<float> MinKnockbackSpeed;
public static ConfigEntry<float> MinUpwardsSpeed;
public static ConfigEntry<float> RocketSpawnWeight;
public static ConfigEntry<int> RocketMaxUses;
public static ConfigEntry<float> RocketSpeed;
public static ConfigEntry<float> RocketTurnRate;
public static ConfigEntry<float> RocketHomingRampTime;
public static ConfigEntry<float> RocketMaxDistance;
public static ConfigEntry<float> RocketSpawnHeight;
private Harmony _harmony;
private void Awake()
{
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_026c: Expected O, but got Unknown
GrenadeSpawnWeight = ((BaseUnityPlugin)this).Config.Bind<float>("General", "GrenadeSpawnWeight", 5f, "Default spawn weight used when the Match Setup Rules menu initializes.");
MaxUses = ((BaseUnityPlugin)this).Config.Bind<int>("General", "MaxUses", 1, "Number of uses per grenade pickup.");
ThrowForce = ((BaseUnityPlugin)this).Config.Bind<float>("Throw", "ThrowForce", 25f, "Throw velocity.");
FuseTime = ((BaseUnityPlugin)this).Config.Bind<float>("Throw", "FuseTime", 3f, "Seconds before the grenade detonates.");
ExplosionRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Throw", "ExplosionRadius", 8f, "Explosion overlap sphere radius.");
MaxKnockbackDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Knockback", "MaxKnockbackDistance", 8f, "At this distance, knockback is weakest.");
MinKnockbackDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Knockback", "MinKnockbackDistance", 1f, "At this distance, knockback is strongest.");
MaxKnockbackSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Knockback", "MaxKnockbackSpeed", 8f, "Knockback speed at max distance (weaker).");
MinKnockbackSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Knockback", "MinKnockbackSpeed", 25f, "Knockback speed at min distance (stronger).");
MinUpwardsSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Knockback", "MinUpwardsSpeed", 5f, "Minimum upward knockback component.");
RocketSpawnWeight = ((BaseUnityPlugin)this).Config.Bind<float>("Guided Missile", "RocketSpawnWeight", 5f, "Default spawn weight used when the Match Setup Rules menu initializes.");
RocketMaxUses = ((BaseUnityPlugin)this).Config.Bind<int>("Guided Missile", "RocketMaxUses", 1, "Uses per pickup.");
RocketSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Guided Missile", "RocketSpeed", 8f, "Projectile speed (slow homing rocket).");
RocketTurnRate = ((BaseUnityPlugin)this).Config.Bind<float>("Guided Missile", "RocketTurnRate", 45f, "Max turn degrees per second.");
RocketHomingRampTime = ((BaseUnityPlugin)this).Config.Bind<float>("Guided Missile", "RocketHomingRampTime", 1.5f, "Seconds to reach full homing authority.");
RocketMaxDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Guided Missile", "RocketMaxDistance", 600f, "Self-destruct after this travel distance.");
RocketSpawnHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Guided Missile", "RocketSpawnHeight", 200f, "Y-position for sky spawn.");
_harmony = new Harmony("SBGGrenade");
_harmony.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("SBGGrenade v{0} loaded! ({1} methods patched)", "1.0.0", _harmony.GetPatchedMethods().Count()));
}
private void OnDestroy()
{
Harmony harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}
public static class RocketConstants
{
public const int RocketItemTypeId = 100;
public const int RocketEquipmentTypeId = 100;
public static readonly ItemType RocketItemType = (ItemType)100;
public static readonly EquipmentType RocketEquipmentType = (EquipmentType)100;
}
public static class RocketEquipmentFactory
{
private static EquipmentSettings _cachedSettings;
private static Equipment _prefabEquipment;
public static EquipmentSettings GetOrCreateSettings()
{
//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
//IL_01fe: Expected O, but got Unknown
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
//IL_0148: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Expected O, but got Unknown
//IL_0165: 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_019b: 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)
if (_cachedSettings != null)
{
return _cachedSettings;
}
GameObject val = null;
EquipmentSettings val2 = default(EquipmentSettings);
if (SingletonBehaviour<EquipmentManager>.HasInstance && (Object)(object)SingletonBehaviour<EquipmentManager>.Instance.equipmentCollection != (Object)null && SingletonBehaviour<EquipmentManager>.Instance.equipmentCollection.TryGetEquipmentSettings((EquipmentType)12, ref val2) && (Object)(object)val2.Prefab != (Object)null)
{
val = Object.Instantiate<GameObject>(((Component)val2.Prefab).gameObject);
((Object)val).name = "GuidedMissileEquipment";
OrbitalLaserEquipment component = val.GetComponent<OrbitalLaserEquipment>();
if ((Object)(object)component != (Object)null)
{
Object.Destroy((Object)(object)component);
}
_prefabEquipment = val.GetComponent<Equipment>();
if ((Object)(object)_prefabEquipment == (Object)null)
{
_prefabEquipment = val.AddComponent<Equipment>();
}
SetBackingField(_prefabEquipment, "Type", RocketConstants.RocketEquipmentType);
SetBackingField(_prefabEquipment, "HasCosmetics", false);
}
if ((Object)(object)val == (Object)null)
{
val = GameObject.CreatePrimitive((PrimitiveType)1);
((Object)val).name = "GuidedMissileEquipment";
val.transform.localScale = Vector3.one * 0.15f;
Collider component2 = val.GetComponent<Collider>();
if ((Object)(object)component2 != (Object)null)
{
Object.Destroy((Object)(object)component2);
}
Renderer component3 = val.GetComponent<Renderer>();
Shader val3 = Shader.Find("Universal Render Pipeline/Lit");
if ((Object)(object)val3 != (Object)null)
{
Material val4 = new Material(val3);
val4.color = new Color(0.9f, 0.4f, 0.1f, 1f);
val4.EnableKeyword("_EMISSION");
val4.SetColor("_EmissionColor", new Color(0.9f, 0.4f, 0.1f) * 0.3f);
component3.material = val4;
}
_prefabEquipment = val.AddComponent<Equipment>();
SetBackingField(_prefabEquipment, "Type", RocketConstants.RocketEquipmentType);
SetBackingField(_prefabEquipment, "HasCosmetics", false);
}
val.SetActive(false);
Object.DontDestroyOnLoad((Object)(object)val);
_cachedSettings = new EquipmentSettings();
SetBackingField(_cachedSettings, "Type", RocketConstants.RocketEquipmentType);
SetBackingField(_cachedSettings, "Prefab", _prefabEquipment);
return _cachedSettings;
}
public static Equipment ClonePrefab()
{
if ((Object)(object)_prefabEquipment == (Object)null)
{
GetOrCreateSettings();
}
Equipment obj = Object.Instantiate<Equipment>(_prefabEquipment);
((Component)obj).gameObject.SetActive(false);
Object.DontDestroyOnLoad((Object)(object)((Component)obj).gameObject);
return obj;
}
private static void SetBackingField(object obj, string propertyName, object value)
{
obj.GetType().GetField("<" + propertyName + ">k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(obj, value);
}
}
public static class RocketItemDataFactory
{
private static ItemData _cachedItemData;
private static Sprite _cachedIcon;
public static ItemData GetOrCreate()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Expected O, but got Unknown
//IL_00fc: 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_0086: 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)
if (_cachedItemData != null)
{
return _cachedItemData;
}
_cachedItemData = new ItemData();
bool flag = false;
try
{
ItemData val = default(ItemData);
if ((Object)(object)GameManager.AllItems != (Object)null && GameManager.AllItems.TryGetItemData((ItemType)10, ref val))
{
SetBackingField(_cachedItemData, "AnimatorOverrideController", val.AnimatorOverrideController);
SetBackingField(_cachedItemData, "Icon", val.Icon);
SetBackingField(_cachedItemData, "Prefab", val.Prefab);
SetBackingField(_cachedItemData, "DroppedLocalRotationEuler", val.DroppedLocalRotationEuler);
SetBackingField(_cachedItemData, "AirhornReaction", val.AirhornReaction);
SetBackingField(_cachedItemData, "FlourishFrames", val.FlourishFrames);
_cachedIcon = val.Icon;
flag = true;
}
}
catch (Exception)
{
}
if (!flag)
{
SetBackingField(_cachedItemData, "Icon", GetOrCreateFallbackIcon());
}
SetBackingField(_cachedItemData, "Type", RocketConstants.RocketItemType);
SetBackingField(_cachedItemData, "MaxUses", Plugin.RocketMaxUses.Value);
SetBackingField(_cachedItemData, "IsExplosive", true);
SetBackingField(_cachedItemData, "NonAimUse", (object)(ItemNonAimingUse)0);
SetBackingField(_cachedItemData, "CanUsageAffectBalls", true);
SetBackingField(_cachedItemData, "HitTransfersToGolfCartPassengers", false);
_cachedItemData.Initialize();
try
{
((DetailedLocalizationTable<StringTableEntry>)(object)((LocalizedDatabase<StringTable, StringTableEntry>)(object)LocalizationSettings.StringDatabase).GetTable(TableReference.op_Implicit("Data"), (Locale)null))?.AddEntry("ITEM_100", "Guided Rocket");
}
catch (Exception)
{
}
return _cachedItemData;
}
public static Sprite GetOrCreateIcon()
{
if ((Object)(object)_cachedIcon != (Object)null)
{
return _cachedIcon;
}
return GetOrCreateFallbackIcon();
}
private static Sprite GetOrCreateFallbackIcon()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_00fb: 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_0070: 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_009b: Unknown result type (might be due to invalid IL or missing references)
if ((Object)(object)_cachedIcon != (Object)null)
{
return _cachedIcon;
}
int num = 64;
Texture2D val = new Texture2D(num, num, (TextureFormat)4, false);
float num2 = (float)num / 2f;
float num3 = (float)num / 2f;
float num4 = num3 - 3f;
for (int i = 0; i < num; i++)
{
for (int j = 0; j < num; j++)
{
float num5 = (float)j - num2;
float num6 = (float)i - num2;
float num7 = Mathf.Sqrt(num5 * num5 + num6 * num6);
if (num7 > num3)
{
val.SetPixel(j, i, Color.clear);
}
else if (num7 > num4)
{
val.SetPixel(j, i, new Color(0.4f, 0.15f, 0.05f, 1f));
}
else
{
val.SetPixel(j, i, new Color(0.9f, 0.4f, 0.1f, 1f));
}
}
}
val.Apply();
_cachedIcon = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), 100f);
((Object)_cachedIcon).name = "GuidedRocketIcon";
return _cachedIcon;
}
private static void SetBackingField(object obj, string propertyName, object value)
{
obj.GetType().GetField("<" + propertyName + ">k__BackingField", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(obj, value);
}
}
public static class RocketUseHandler
{
public static IEnumerator LaunchRocketRoutine(PlayerInventory inventory)
{
PlayerInfo playerInfo = inventory.PlayerInfo;
LockOnTarget lockOnTarget = inventory.LockOnTarget;
inventory.SetCurrentItemUse((ItemUseType)1);
if (BMath.Abs(FloatExtensions.WrapAngleDeg(VectorExtensions.GetYawDeg(((Component)GameManager.Camera).transform.forward) - playerInfo.Movement.Yaw)) > 45f)
{
playerInfo.Movement.AlignWithCameraImmediately();
}
yield return (object)new WaitForSeconds(0.2f);
inventory.SetLockOnTarget((LockOnTarget)null);
Vector3 val = ((!((Object)(object)lockOnTarget != (Object)null) || !lockOnTarget.IsValid()) ? ((Component)inventory).transform.position : lockOnTarget.GetLockOnPosition());
Vector3 val2 = default(Vector3);
((Vector3)(ref val2))..ctor(val.x, Plugin.RocketSpawnHeight.Value, val.z);
Vector3 val3 = val - val2;
Quaternion val4 = Quaternion.LookRotation(((Vector3)(ref val3)).normalized);
object obj;
if (lockOnTarget == null)
{
obj = null;
}
else
{
Entity asEntity = lockOnTarget.AsEntity;
obj = ((asEntity != null) ? asEntity.AsHittable : null);
}
Hittable val5 = (Hittable)obj;
ItemUseId val6 = inventory.IncrementAndGetCurrentItemUseId((ItemType)7);
inventory.CmdInformShotRocket(val2, val4, val5, val6, (NetworkConnectionToClient)null);
inventory.DecrementUseFromSlotAt(inventory.EquippedItemIndex);
yield return (object)new WaitForSeconds(0.3f);
inventory.SetCurrentItemUse((ItemUseType)0);
inventory.RemoveIfOutOfUses(inventory.EquippedItemIndex);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "SBGGrenade";
public const string PLUGIN_NAME = "SBGGrenade";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace SBGGrenade.Patches
{
[HarmonyPatch(typeof(EquipmentCollection))]
public static class EquipmentCollectionPatches
{
[HarmonyPatch("TryGetEquipmentSettings")]
[HarmonyPostfix]
private static void TryGetEquipmentSettings_Postfix(EquipmentType type, ref EquipmentSettings equipmentSettings, ref bool __result)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
if (!__result)
{
if (type == GrenadeConstants.GrenadeEquipmentType)
{
equipmentSettings = GrenadeEquipmentFactory.GetOrCreateSettings();
__result = true;
}
else if (type == RocketConstants.RocketEquipmentType)
{
equipmentSettings = RocketEquipmentFactory.GetOrCreateSettings();
__result = true;
}
}
}
}
[HarmonyPatch(typeof(EquipmentManager))]
public static class EquipmentManagerPatches
{
[HarmonyPatch("GetUnusedEquipmentInternal")]
[HarmonyPrefix]
private static bool GetUnusedEquipmentInternal_Prefix(EquipmentType type, ref Equipment __result)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (type == GrenadeConstants.GrenadeEquipmentType)
{
__result = GrenadeEquipmentFactory.ClonePrefab();
return false;
}
if (type == RocketConstants.RocketEquipmentType)
{
__result = RocketEquipmentFactory.ClonePrefab();
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Hittable))]
public static class HittablePatches
{
private static readonly ManualLogSource Log = Logger.CreateLogSource("SBGGrenade.HittablePatch");
[HarmonyPatch("HitWithItemInternal")]
[HarmonyPostfix]
private static void HitWithItemInternal_Postfix(Hittable __instance, ItemType itemType, Vector3 hitLocalPosition, Vector3 direction, float distance, PlayerInventory itemUser, bool canHitWithNoUser)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: 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_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: 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)
if (itemType == GrenadeConstants.GrenadeItemType)
{
float value = Plugin.MaxKnockbackDistance.Value;
float value2 = Plugin.MinKnockbackDistance.Value;
float value3 = Plugin.MaxKnockbackSpeed.Value;
float value4 = Plugin.MinKnockbackSpeed.Value;
float value5 = Plugin.MinUpwardsSpeed.Value;
if ((canHitWithNoUser || !((Object)(object)itemUser == (Object)null)) && __instance.CanApplyPhysics())
{
Vector3 val = ((Component)__instance).transform.TransformPoint(hitLocalPosition);
Vector3 val2 = direction;
Vector3 normalized = ((Vector3)(ref val2)).normalized;
float num = BMath.InverseLerpClamped(value, value2, distance);
Vector3 val3 = BMath.Lerp(value3, value4, num) * normalized;
val3.y = BMath.Max(val3.y, value5);
__instance.AsEntity.Rigidbody.AddForceAtPosition(val3, val, (ForceMode)2);
}
}
}
}
[HarmonyPatch(typeof(PlayerMovement))]
public static class PlayerMovementPatches
{
private static readonly ManualLogSource Log = Logger.CreateLogSource("SBGGrenade.MovementPatch");
[HarmonyPatch("OnLocalPlayerWillApplyItemHitPhysics")]
[HarmonyPrefix]
private static bool Prefix(PlayerMovement __instance, PlayerInventory itemUser, ItemType itemType, ItemUseId itemUseId, Vector3 localOrigin, float distance, Vector3 incomingVelocityChange, bool isReflected, bool isInSpecialState)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0066: 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_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: 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_009c: 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_00cc: 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_00d9: 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_00e0: 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_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)
if (itemType == GrenadeConstants.GrenadeItemType)
{
float value = Plugin.MaxKnockbackDistance.Value;
float value2 = Plugin.MinKnockbackDistance.Value;
float value3 = Plugin.MaxKnockbackSpeed.Value;
float value4 = Plugin.MinKnockbackSpeed.Value;
float value5 = Plugin.MinUpwardsSpeed.Value;
Vector3 val = -((Vector3)(ref localOrigin)).normalized;
float num = BMath.InverseLerpClamped(value, value2, distance);
Vector3 val2 = BMath.Lerp(value3, value4, num) * val;
val2.y = BMath.Max(val2.y, value5);
PlayerInfo val3 = ((itemUser != null) ? itemUser.PlayerInfo : null);
bool flag = default(bool);
__instance.TryKnockOut(val3, (KnockoutType)12, false, localOrigin, distance, val2, true, itemUseId, isInSpecialState, true, ref flag);
if (!flag && __instance.PlayerInfo.IsElectromagnetShieldActive)
{
Vector3 position = ((Component)__instance.PlayerInfo.ElectromagnetShieldCollider).transform.position;
Vector3 val4 = ((Component)__instance).transform.TransformPoint(localOrigin);
__instance.PlayerInfo.PlayElectromagnetShieldHitForAllClients(val4 - position);
}
return false;
}
return true;
}
}
[HarmonyPatch(typeof(ItemCollection))]
public static class ItemCollectionPatches
{
[HarmonyPatch("TryGetItemData")]
[HarmonyPostfix]
private static void TryGetItemData_Postfix(ItemType itemType, ref ItemData itemData, ref bool __result)
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
if (!__result)
{
if (itemType == GrenadeConstants.GrenadeItemType)
{
itemData = GrenadeItemDataFactory.GetOrCreate();
__result = true;
}
else if (itemType == RocketConstants.RocketItemType)
{
itemData = RocketItemDataFactory.GetOrCreate();
__result = true;
}
}
}
[HarmonyPatch("GetItemIcon")]
[HarmonyPrefix]
private static bool GetItemIcon_Prefix(ItemType itemType, ref Sprite __result)
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
if (itemType == GrenadeConstants.GrenadeItemType)
{
__result = GrenadeItemDataFactory.GetOrCreateIcon();
return false;
}
if (itemType == RocketConstants.RocketItemType)
{
__result = RocketItemDataFactory.GetOrCreateIcon();
return false;
}
return true;
}
}
public static class MatchSetupRulesPatches
{
[HarmonyPatch(typeof(MatchSetupRules), "Initialize")]
public static class Initialize_Patch
{
[HarmonyPostfix]
private static void Postfix(MatchSetupRules __instance)
{
//IL_0023: 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_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0203: Unknown result type (might be due to invalid IL or missing references)
//IL_0212: Unknown result type (might be due to invalid IL or missing references)
ItemSpawnerSettings itemSpawnerSettings = __instance.itemSpawnerSettings;
InjectCustomItemsIntoPool(itemSpawnerSettings.aheadOfBallItemPool);
foreach (ItemPoolData itemPool in itemSpawnerSettings.itemPools)
{
InjectCustomItemsIntoPool(itemPool.pool);
}
InjectCustomItemsIntoPool(itemSpawnerSettings.AheadOfBallItemPool);
foreach (ItemPoolData itemPool2 in itemSpawnerSettings.ItemPools)
{
InjectCustomItemsIntoPool(itemPool2.pool);
}
ItemType[] itemOrder = __instance.itemOrder;
int num = itemOrder.Length;
ItemType[] array = (ItemType[])(object)new ItemType[num + CustomItems.Length];
Array.Copy(itemOrder, array, num);
for (int i = 0; i < CustomItems.Length; i++)
{
array[num + i] = CustomItems[i];
}
__instance.itemOrder = array;
int[] itemOrderLookup = __instance.itemOrderLookup;
int[] array2 = new int[100];
Array.Copy(itemOrderLookup, array2, itemOrderLookup.Length);
array2[98] = num;
array2[99] = num + 1;
__instance.itemOrderLookup = array2;
for (int j = 0; j < CustomItems.Length; j++)
{
GameObject val = Object.Instantiate<GameObject>(__instance.itemPrefab);
val.transform.SetParent((Transform)(object)__instance.itemsParent);
val.transform.localScale = Vector3.one;
__instance.spawnChanceSliders.Add(val.GetComponentInChildren<SliderOption>());
LocalizeStringEvent componentInChildren = val.GetComponentInChildren<LocalizeStringEvent>();
if ((Object)(object)componentInChildren != (Object)null)
{
((Behaviour)componentInChildren).enabled = false;
}
TMP_Text componentInChildren2 = val.GetComponentInChildren<TMP_Text>();
if ((Object)(object)componentInChildren2 != (Object)null)
{
componentInChildren2.text = CustomItemNames[j];
}
}
if (((NetworkBehaviour)__instance).isServer)
{
int num2 = 1 + itemSpawnerSettings.ItemPools.Count;
float[] array3 = new float[2]
{
Plugin.GrenadeSpawnWeight.Value,
Plugin.RocketSpawnWeight.Value
};
for (int k = 0; k < num2; k++)
{
for (int l = 0; l < CustomItems.Length; l++)
{
ItemPoolId val2 = ItemPoolId.Get(k, CustomItems[l]);
if (!((SyncIDictionary<ItemPoolId, float>)(object)__instance.spawnChanceWeights).ContainsKey(val2))
{
((SyncIDictionary<ItemPoolId, float>)(object)__instance.spawnChanceWeights)[val2] = array3[l];
}
}
}
}
InitializeCustomSliders(__instance);
}
}
[HarmonyPatch(typeof(MatchSetupRules), "ServerUpdateSpawnChanceValue")]
public static class ServerUpdateSpawnChanceValue_Patch
{
[HarmonyPostfix]
private static void Postfix(MatchSetupRules __instance, ItemPoolId itemPoolRef)
{
//IL_0009: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)__instance).isServer && itemPoolRef.itemPoolIndex == 0)
{
__instance.itemSpawnerSettings.AheadOfBallItemPool.UpdateTotalWeight();
}
}
}
private static readonly ItemType[] CustomItems = (ItemType[])(object)new ItemType[2]
{
(ItemType)(int)GrenadeConstants.GrenadeItemType,
(ItemType)(int)RocketConstants.RocketItemType
};
private static readonly string[] CustomItemNames = new string[2] { "Grenade", "Guided Rocket" };
private static void InjectCustomItemsIntoPool(ItemPool pool)
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
//IL_005c: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: 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_0078: 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_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: 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)
if ((Object)(object)pool == (Object)null)
{
return;
}
ItemSpawnChance[] spawnChances = pool.SpawnChances;
for (int i = 0; i < spawnChances.Length; i++)
{
if (spawnChances[i].item == GrenadeConstants.GrenadeItemType)
{
return;
}
}
ItemSpawnChance[] array = (ItemSpawnChance[])(object)new ItemSpawnChance[spawnChances.Length + CustomItems.Length];
Array.Copy(spawnChances, array, spawnChances.Length);
array[spawnChances.Length] = new ItemSpawnChance
{
item = GrenadeConstants.GrenadeItemType,
spawnChanceWeight = Plugin.GrenadeSpawnWeight.Value
};
array[spawnChances.Length + 1] = new ItemSpawnChance
{
item = RocketConstants.RocketItemType,
spawnChanceWeight = Plugin.RocketSpawnWeight.Value
};
pool.spawnChances = array;
pool.UpdateTotalWeight();
}
private static void InitializeCustomSliders(MatchSetupRules rules)
{
//IL_0052: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0091: 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_00a8: 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_010a: 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)
SyncDictionary<ItemPoolId, float> weights = rules.spawnChanceWeights;
int currentItemPoolIndex = rules.currentItemPoolIndex;
rules.supressPreset = true;
try
{
for (int i = 0; i < CustomItems.Length; i++)
{
ItemType item = CustomItems[i];
int index = rules.itemOrderLookup[item - 1];
SliderOption slider = rules.spawnChanceSliders[index];
ItemPoolId val = ItemPoolId.Get(currentItemPoolIndex, item);
float num = (((SyncIDictionary<ItemPoolId, float>)(object)weights).ContainsKey(val) ? (((SyncIDictionary<ItemPoolId, float>)(object)weights)[val] / 100f) : 0f);
slider.Initialize((Action)delegate
{
//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)
slider.valueWithoutNotify = Mathf.Round(slider.value / 0.025f) * 0.025f;
float num2 = slider.value * 100f;
if (((NetworkBehaviour)rules).isServer)
{
((SyncIDictionary<ItemPoolId, float>)(object)weights)[ItemPoolId.Get(rules.currentItemPoolIndex, item)] = num2;
rules.SetPreset((Preset)2);
}
}, num);
if (((NetworkBehaviour)rules).isServer)
{
rules.ServerUpdateSpawnChanceValue(ItemPoolId.Get(currentItemPoolIndex, item));
}
}
}
finally
{
rules.supressPreset = false;
rules.currentItemPoolDirty = true;
}
}
}
[HarmonyPatch(typeof(ItemTypeExtensions))]
public static class ItemTypeExtensionsPatches
{
[HarmonyPatch("TryGetEliminationReason")]
[HarmonyPostfix]
private static void TryGetEliminationReason_Postfix(ItemType itemType, float distance, bool isReflected, ref EliminationReason eliminationReason, ref bool __result)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if (!__result && itemType == GrenadeConstants.GrenadeItemType)
{
eliminationReason = (EliminationReason)18;
__result = true;
}
}
}
[HarmonyPatch(typeof(PlayerInventory))]
public static class PlayerInventoryPatches
{
[HarmonyPatch("TryUseItem")]
[HarmonyPrefix]
private static bool TryUseItem_Prefix(PlayerInventory __instance, bool isAirhornReaction, ref bool shouldEatInput, ref bool __result)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: 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)
if (!((NetworkBehaviour)__instance).isLocalPlayer)
{
return true;
}
InventorySlot effectiveSlot = __instance.GetEffectiveSlot(__instance.EquippedItemIndex);
if (effectiveSlot.itemType == GrenadeConstants.GrenadeItemType)
{
InventorySlot val = default(InventorySlot);
ItemData val2 = default(ItemData);
bool flag = default(bool);
if (!__instance.CanUseEquippedItem(false, isAirhornReaction, ref val, ref val2, ref shouldEatInput, ref flag))
{
__result = false;
return false;
}
__instance.ItemUseTimestamp = Time.timeAsDouble;
__instance.CancelItemUse();
__instance.itemUseRoutine = ((MonoBehaviour)__instance).StartCoroutine(GrenadeUseHandler.ThrowGrenadeRoutine(__instance));
__instance.PlayerInfo.CancelEmote(false);
__instance.CancelItemFlourish();
shouldEatInput = false;
__result = true;
return false;
}
if (effectiveSlot.itemType == RocketConstants.RocketItemType)
{
InventorySlot val3 = default(InventorySlot);
ItemData val4 = default(ItemData);
bool flag2 = default(bool);
if (!__instance.CanUseEquippedItem(false, isAirhornReaction, ref val3, ref val4, ref shouldEatInput, ref flag2))
{
__result = false;
return false;
}
__instance.ItemUseTimestamp = Time.timeAsDouble;
__instance.CancelItemUse();
__instance.itemUseRoutine = ((MonoBehaviour)__instance).StartCoroutine(RocketUseHandler.LaunchRocketRoutine(__instance));
__instance.PlayerInfo.CancelEmote(false);
__instance.CancelItemFlourish();
shouldEatInput = false;
__result = true;
return false;
}
return true;
}
[HarmonyPatch("UpdateIsUpdateLoopRunning")]
[HarmonyPrefix]
private static bool UpdateIsUpdateLoopRunning_Prefix(PlayerInventory __instance)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
if (!((NetworkBehaviour)__instance).isLocalPlayer)
{
return true;
}
if (__instance.GetEffectivelyEquippedItem(true) != RocketConstants.RocketItemType)
{
return true;
}
bool isUpdateLoopRunning = __instance.isUpdateLoopRunning;
bool flag = (__instance.isUpdateLoopRunning = __instance.IsAimingItem);
if (flag != isUpdateLoopRunning)
{
LockOnTargetUiManager.ClearTargets();
__instance.ClearAirhornTargets();
__instance.SetLockOnTarget((LockOnTarget)null);
if (flag)
{
BUpdate.RegisterCallback((IAnyBUpdateCallback)(object)__instance);
}
else
{
BUpdate.DeregisterCallback((IAnyBUpdateCallback)(object)__instance);
}
}
return false;
}
[HarmonyPatch("OnBUpdate")]
[HarmonyPrefix]
private static bool OnBUpdate_Prefix(PlayerInventory __instance)
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
if (!((NetworkBehaviour)__instance).isLocalPlayer)
{
return true;
}
if (__instance.GetEffectiveSlot(__instance.EquippedItemIndex).itemType != RocketConstants.RocketItemType)
{
return true;
}
if (__instance.IsAimingItem)
{
LockOnTarget lockOnTarget = FindBestLockOnTarget(__instance);
__instance.SetLockOnTarget(lockOnTarget);
}
return false;
}
[HarmonyPatch("UpdateAimingReticle")]
[HarmonyPostfix]
private static void UpdateAimingReticle_Postfix(PlayerInventory __instance)
{
//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)
if (((NetworkBehaviour)__instance).isLocalPlayer && __instance.IsAimingItem && __instance.GetEffectivelyEquippedItem(false) == RocketConstants.RocketItemType)
{
ReticleManager.SetRocketLauncher();
}
}
private static LockOnTarget FindBestLockOnTarget(PlayerInventory inventory)
{
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_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_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e6: 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_00fa: 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_00fe: 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_0102: 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_0118: 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_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0140: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_017b: Unknown result type (might be due to invalid IL or missing references)
//IL_017d: Unknown result type (might be due to invalid IL or missing references)
//IL_017f: Unknown result type (might be due to invalid IL or missing references)
//IL_0184: Unknown result type (might be due to invalid IL or missing references)
//IL_0186: Unknown result type (might be due to invalid IL or missing references)
//IL_0188: Unknown result type (might be due to invalid IL or missing references)
//IL_019b: Unknown result type (might be due to invalid IL or missing references)
//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
Camera camera = GameManager.Camera;
if ((Object)(object)camera == (Object)null)
{
return null;
}
float rocketLauncherLockOnMaxDistanceSquared = GameManager.ItemSettings.RocketLauncherLockOnMaxDistanceSquared;
float rocketLauncherLockOnMaxYawFromCenterScreen = GameManager.ItemSettings.RocketLauncherLockOnMaxYawFromCenterScreen;
float rocketLauncherLockOnYawWeight = GameManager.ItemSettings.RocketLauncherLockOnYawWeight;
LockOnTarget asLockOnTarget = inventory.PlayerInfo.AsEntity.AsLockOnTarget;
Hittable asHittable = inventory.PlayerInfo.AsHittable;
Transform transform = ((Component)inventory).transform;
Vector3 position = transform.position;
Vector3 forward = transform.forward;
Vector3 position2 = ((Component)camera).transform.position;
Vector3 forward2 = ((Component)camera).transform.forward;
float num = camera.fieldOfView / 2f;
LockOnTarget result = null;
float num2 = float.MaxValue;
Vector3 val2 = default(Vector3);
Hittable val5 = default(Hittable);
foreach (LockOnTarget target in LockOnTargetManager.Targets)
{
if ((Object)(object)target == (Object)null || (Object)(object)target == (Object)(object)asLockOnTarget || !target.IsValid())
{
continue;
}
Vector3 lockOnPosition = target.GetLockOnPosition();
Vector3 val = lockOnPosition - position;
if (((Vector3)(ref val)).sqrMagnitude > rocketLauncherLockOnMaxDistanceSquared)
{
continue;
}
if (!VectorExtensions.TryProjectPointOnPlaneAlong(position2, forward2, position, VectorExtensions.Horizontalized(forward), ref val2))
{
val2 = position2;
}
float num3 = BMath.Abs(FloatExtensions.WrapAngleDeg(VectorExtensions.GetYawDeg(lockOnPosition - val2) - VectorExtensions.GetYawDeg(forward2)));
if (num3 > rocketLauncherLockOnMaxYawFromCenterScreen)
{
continue;
}
float num4 = BMath.Abs(FloatExtensions.WrapAngleDeg(VectorExtensions.GetPitchDeg(lockOnPosition - position2) - VectorExtensions.GetPitchDeg(forward2)));
if (num4 > num)
{
continue;
}
float num5 = num3 * rocketLauncherLockOnYawWeight + num4;
if (num5 >= num2)
{
continue;
}
Vector3 val3 = lockOnPosition - position2;
int num6 = Physics.RaycastNonAlloc(position2, val3, PlayerGolfer.raycastHitBuffer, ((Vector3)(ref val3)).magnitude, LayerMask.op_Implicit(GameManager.LayerSettings.LockOnLineOfSightBlockerMask));
bool flag = true;
for (int i = 0; i < num6; i++)
{
RaycastHit val4 = PlayerGolfer.raycastHitBuffer[i];
if (!ComponentExtensions.TryGetComponentInParent<Hittable>((Component)(object)((RaycastHit)(ref val4)).collider, ref val5, true))
{
flag = false;
break;
}
if ((Object)(object)val5 != (Object)(object)asHittable && (Object)(object)val5 != (Object)(object)target.AsEntity.AsHittable)
{
flag = false;
break;
}
}
if (flag)
{
result = target;
num2 = num5;
}
}
return result;
}
[HarmonyPatch("UpdateEquipmentSwitchers")]
[HarmonyPostfix]
private static void UpdateEquipmentSwitchers_Postfix(PlayerInventory __instance)
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
if (((NetworkBehaviour)__instance).isLocalPlayer && __instance.GetEffectivelyEquippedItem(false) == RocketConstants.RocketItemType)
{
__instance.PlayerInfo.RightHandEquipmentSwitcher.SetEquipment(RocketConstants.RocketEquipmentType);
__instance.PlayerInfo.LeftHandEquipmentSwitcher.SetEquipment((EquipmentType)0);
}
}
}
[HarmonyPatch(typeof(Rocket))]
public static class RocketPatches
{
private class SkyRocketData
{
public float SpawnTime;
public float DistanceTravelled;
public Vector3 PreviousPosition;
public float LastRetargetTime;
}
private static readonly Dictionary<Rocket, SkyRocketData> _skyRockets = new Dictionary<Rocket, SkyRocketData>();
private static bool IsSkyRocket(Rocket rocket)
{
return _skyRockets.ContainsKey(rocket);
}
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void Start_Postfix(Rocket __instance)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: 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_0087: Unknown result type (might be due to invalid IL or missing references)
if (!(((Component)__instance).transform.position.y < Plugin.RocketSpawnHeight.Value - 10f))
{
SkyRocketData value = new SkyRocketData
{
SpawnTime = Time.time,
DistanceTravelled = 0f,
PreviousPosition = ((Component)__instance).transform.position,
LastRetargetTime = Time.time
};
_skyRockets[__instance] = value;
((Component)__instance).GetComponent<Entity>().Rigidbody.linearVelocity = ((Component)__instance).transform.forward * Plugin.RocketSpeed.Value;
}
}
[HarmonyPatch("OnFixedBUpdate")]
[HarmonyPrefix]
private static void OnFixedBUpdate_Prefix(Rocket __instance)
{
if (IsSkyRocket(__instance))
{
__instance.distanceTravelled = 0f;
}
}
[HarmonyPatch("OnFixedBUpdate")]
[HarmonyPostfix]
private static void OnFixedBUpdate_Postfix(Rocket __instance)
{
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002d: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_01db: Unknown result type (might be due to invalid IL or missing references)
//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: 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_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
//IL_0159: Unknown result type (might be due to invalid IL or missing references)
//IL_015e: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
if (!_skyRockets.TryGetValue(__instance, out var value))
{
return;
}
Rigidbody rigidbody = ((Component)__instance).GetComponent<Entity>().Rigidbody;
Vector3 val = rigidbody.position - value.PreviousPosition;
float magnitude = ((Vector3)(ref val)).magnitude;
value.DistanceTravelled += magnitude;
value.PreviousPosition = rigidbody.position;
if (((NetworkBehaviour)__instance).isServer && value.DistanceTravelled > Plugin.RocketMaxDistance.Value)
{
__instance.ServerExplode(((Component)__instance).transform.position);
return;
}
if (((NetworkBehaviour)__instance).isServer && Time.time - value.LastRetargetTime > 0.5f)
{
value.LastRetargetTime = Time.time;
Hittable networkhomingTargetHittable = __instance.NetworkhomingTargetHittable;
if ((Object)(object)networkhomingTargetHittable == (Object)null || (Object)(object)networkhomingTargetHittable.AsEntity == (Object)null || (Object)(object)networkhomingTargetHittable.AsEntity.AsLockOnTarget == (Object)null || !networkhomingTargetHittable.AsEntity.AsLockOnTarget.IsValid())
{
Hittable networkhomingTargetHittable2 = FindNearestTarget(rigidbody.position, __instance.Networklauncher);
__instance.NetworkhomingTargetHittable = networkhomingTargetHittable2;
}
}
Hittable networkhomingTargetHittable3 = __instance.NetworkhomingTargetHittable;
if ((Object)(object)networkhomingTargetHittable3 != (Object)null && (Object)(object)networkhomingTargetHittable3.AsEntity != (Object)null && (Object)(object)networkhomingTargetHittable3.AsEntity.AsLockOnTarget != (Object)null)
{
Vector3 val2 = networkhomingTargetHittable3.AsEntity.AsLockOnTarget.GetLockOnPosition() - rigidbody.worldCenterOfMass;
float num = Time.time - value.SpawnTime;
float num2 = Mathf.Min(1f, num / Plugin.RocketHomingRampTime.Value) * Plugin.RocketTurnRate.Value * Time.fixedDeltaTime * (MathF.PI / 180f);
Vector3 val3 = rigidbody.linearVelocity;
val3 = Vector3.RotateTowards(val3, val2, num2, 0f);
val3 = (rigidbody.linearVelocity = ((Vector3)(ref val3)).normalized * Plugin.RocketSpeed.Value);
}
else
{
val = rigidbody.linearVelocity;
rigidbody.linearVelocity = ((Vector3)(ref val)).normalized * Plugin.RocketSpeed.Value;
}
}
[HarmonyPatch("OnWillBeDestroyed")]
[HarmonyPostfix]
private static void OnWillBeDestroyed_Postfix(Rocket __instance)
{
_skyRockets.Remove(__instance);
}
private static Hittable FindNearestTarget(Vector3 position, PlayerInfo launcher)
{
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_007d: Unknown result type (might be due to invalid IL or missing references)
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
HashSet<LockOnTarget> targets = LockOnTargetManager.Targets;
if (targets == null)
{
return null;
}
Hittable result = null;
float num = float.MaxValue;
foreach (LockOnTarget item in targets)
{
if (!((Object)(object)item == (Object)null) && item.IsValid() && (!((Object)(object)launcher != (Object)null) || !((Object)(object)item.AsEntity != (Object)null) || !item.AsEntity.IsPlayer || !((Object)(object)item.AsEntity.PlayerInfo == (Object)(object)launcher)))
{
Vector3 val = item.GetLockOnPosition() - position;
float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
if (sqrMagnitude < num)
{
num = sqrMagnitude;
result = item.AsEntity.AsHittable;
}
}
}
return result;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}