using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
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 Photon.Pun;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BasketballHatesYou")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BasketballHatesYou")]
[assembly: AssemblyTitle("Basketball Hates You")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
[CompilerGenerated]
[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 BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
[Embedded]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
[Embedded]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
{
}
}
}
namespace Microsoft.CodeAnalysis
{
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace BasketballHatesYou
{
internal sealed class HatefulBall : MonoBehaviour
{
[HarmonyPatch(typeof(Item), "RPC_SetThrownData")]
private static class ThrowPatch
{
private static void Postfix(Item __instance, float thrownAmount)
{
if (PluginConfig.Enabled.Value && PhotonNetwork.IsMasterClient && !(thrownAmount <= 0f) && ((Object)__instance).name.Contains("Basketball") && !((Object)(object)__instance.lastThrownCharacter == (Object)null) && !((Object)(object)((Component)__instance).GetComponent<HatefulBall>() != (Object)null))
{
((Component)__instance).gameObject.AddComponent<HatefulBall>().Init(__instance.lastThrownCharacter);
}
}
}
[HarmonyPatch(typeof(BasketballHoop), "OnTriggerExit")]
private static class HoopScorePatch
{
private static void Prefix(BasketballHoop __instance, out float __state)
{
__state = __instance.lastScoredTime;
}
private static void Postfix(BasketballHoop __instance, Collider other, float __state)
{
if (__instance.lastScoredTime != __state && !((Object)(object)other.attachedRigidbody == (Object)null))
{
((Component)other.attachedRigidbody).GetComponent<HatefulBall>()?.OnScored();
}
}
}
private Rigidbody _rb;
private PhotonView _view;
private Character? _target;
private BasketballHoop? _hoop;
private BasketballHoop? _enteredHoop;
private bool _attacking;
private int _retries;
private float _attackStartTime;
private float _hitTime;
private float _spawnTime;
private float _stuckTime;
public void Init(Character thrower)
{
_target = thrower;
}
private void Awake()
{
_rb = ((Component)this).GetComponent<Rigidbody>();
_view = ((Component)this).GetComponent<PhotonView>();
_spawnTime = Time.time;
}
private void Start()
{
//IL_001b: 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)
float num = float.MaxValue;
BasketballHoop[] array = Object.FindObjectsByType<BasketballHoop>((FindObjectsSortMode)0);
foreach (BasketballHoop val in array)
{
float num2 = Vector3.Distance(((Component)val).transform.position, ((Component)this).transform.position);
if (num2 < num)
{
num = num2;
_hoop = val;
}
}
}
public void OnScored()
{
if (!_attacking)
{
Plugin.Log.LogInfo((object)"Nice shot, the basketball forgives you");
Object.Destroy((Object)(object)this);
}
}
private void OnTriggerEnter(Collider other)
{
//IL_0016: 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)
BasketballHoop componentInParent = ((Component)other).GetComponentInParent<BasketballHoop>();
if ((Object)(object)componentInParent != (Object)null && ((Component)this).transform.position.y > ((Component)componentInParent).transform.position.y)
{
_enteredHoop = componentInParent;
}
}
private void OnTriggerExit(Collider other)
{
//IL_0025: 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_004c: Unknown result type (might be due to invalid IL or missing references)
BasketballHoop componentInParent = ((Component)other).GetComponentInParent<BasketballHoop>();
if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)componentInParent != (Object)(object)_enteredHoop) && !(_rb.linearVelocity.y >= 0f) && !(((Component)this).transform.position.y >= ((Component)componentInParent).transform.position.y))
{
_enteredHoop = null;
OnScored();
}
}
private void OnCollisionEnter(Collision collision)
{
if (!_view.IsMine)
{
return;
}
if (_attacking && (Object)(object)_target != (Object)null && (Object)(object)((Component)collision.collider).GetComponentInParent<Character>() == (Object)(object)_target)
{
Plugin.Log.LogInfo((object)("Hit " + ((Object)_target).name));
Object.Destroy((Object)(object)this);
}
else if (IsFloor(collision) && !TouchingHoop(collision))
{
if (!_attacking)
{
Attack();
}
else if (Time.time - _attackStartTime > 0.3f)
{
OnAttackLanded();
}
}
}
private void FixedUpdate()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
//IL_0106: Unknown result type (might be due to invalid IL or missing references)
//IL_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0111: Unknown result type (might be due to invalid IL or missing references)
//IL_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_0126: Unknown result type (might be due to invalid IL or missing references)
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
if (!_view.IsMine)
{
return;
}
if ((Object)(object)_target == (Object)null || _target.data.dead)
{
Object.Destroy((Object)(object)this);
return;
}
if (!_rb.isKinematic)
{
Vector3 linearVelocity = _rb.linearVelocity;
if (((Vector3)(ref linearVelocity)).sqrMagnitude < 0.04f && Time.time - _attackStartTime > 0.5f)
{
_stuckTime += Time.fixedDeltaTime;
goto IL_008e;
}
}
_stuckTime = 0f;
goto IL_008e;
IL_008e:
if (_stuckTime > 1.5f)
{
_stuckTime = 0f;
if (!_attacking)
{
Attack();
}
else
{
OnAttackLanded();
}
}
else if (!_attacking)
{
if (Time.time - _spawnTime > 6f)
{
Attack();
}
}
else
{
float num = _hitTime - Time.time;
if (!(num <= Time.fixedDeltaTime))
{
_rb.linearVelocity = (AttackPoint() - _rb.position) / num - 0.5f * Physics.gravity * num;
}
}
}
private void Attack()
{
//IL_0021: Unknown result type (might be due to invalid IL or missing references)
//IL_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: 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_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: 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)
if (!((Object)(object)_target == (Object)null))
{
_attacking = true;
_attackStartTime = Time.time;
float num = Mathf.Abs(Physics.gravity.y);
if (Mathf.Approximately(num, 0f))
{
num = 9.81f;
}
Vector3 position = _rb.position;
Vector3 val = AttackPoint();
float num2 = Mathf.Max(position.y, val.y) + 1f;
float num3 = Mathf.Sqrt(2f * (num2 - position.y) / num) + Mathf.Sqrt(2f * (num2 - val.y) / num);
float num4 = Mathf.Min(num3 / PluginConfig.SpeedMultiplier.Value, Vector3.Distance(position, val) / PluginConfig.MinSpeed.Value);
_hitTime = Time.time + Mathf.Max(num4, 0.1f);
Plugin.Log.LogInfo((object)$"Going for {((Object)_target).name} (try {_retries + 1})");
}
}
private void OnAttackLanded()
{
if (_retries < PluginConfig.Retries.Value)
{
_retries++;
Attack();
}
else
{
Plugin.Log.LogInfo((object)"Out of retries, the basketball gives up");
Object.Destroy((Object)(object)this);
}
}
private Vector3 AttackPoint()
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
Bodypart bodypart = _target.GetBodypart((BodypartType)4);
if (!((Object)(object)bodypart != (Object)null))
{
return _target.Center;
}
return bodypart.transform.position;
}
private static bool IsFloor(Collision collision)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
if ((Object)(object)collision.rigidbody == (Object)null && collision.contactCount > 0)
{
ContactPoint contact = collision.GetContact(0);
return Vector3.Dot(((ContactPoint)(ref contact)).normal, Vector3.up) > 0.5f;
}
return false;
}
private bool TouchingHoop(Collision collision)
{
//IL_0030: 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_003c: 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_0053: 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_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_007e: 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)
if ((Object)(object)((Component)collision.collider).GetComponentInParent<BasketballHoop>() != (Object)null)
{
return true;
}
if ((Object)(object)_hoop == (Object)null)
{
return false;
}
Vector3 position = ((Component)_hoop).transform.position;
Vector2 val = new Vector2(((Component)this).transform.position.x - position.x, ((Component)this).transform.position.z - position.z);
if (((Vector2)(ref val)).magnitude < 1.5f)
{
return ((Component)this).transform.position.y > position.y - 0.5f;
}
return false;
}
}
[BepInPlugin("BasketballHatesYou", "Basketball Hates You", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private Harmony? _harmony;
public const string Id = "BasketballHatesYou";
internal static ManualLogSource Log { get; private set; }
public static string Name => "Basketball Hates You";
public static string Version => "1.0.0";
private void Awake()
{
//IL_001c: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
PluginConfig.Bind(((BaseUnityPlugin)this).Config);
_harmony = new Harmony("BasketballHatesYou");
_harmony.PatchAll();
Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
}
private void OnDestroy()
{
Harmony? harmony = _harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
}
internal static class PluginConfig
{
public static ConfigEntry<bool> Enabled { get; private set; }
public static ConfigEntry<int> Retries { get; private set; }
public static ConfigEntry<float> SpeedMultiplier { get; private set; }
public static ConfigEntry<float> MinSpeed { get; private set; }
public static void Bind(ConfigFile config)
{
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_0043: Expected O, but got Unknown
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Expected O, but got Unknown
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Expected O, but got Unknown
Enabled = config.Bind<bool>("General", "Enabled", true, "A thrown basketball that hits the floor without scoring flies back at whoever threw it.");
Retries = config.Bind<int>("General", "Retries", 5, new ConfigDescription("How many more times the ball tries again after missing you.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), Array.Empty<object>()));
SpeedMultiplier = config.Bind<float>("General", "Speed Multiplier", 2f, new ConfigDescription("How much faster than a normal lob the ball flies at you. A hard hit is what knocks you over.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
MinSpeed = config.Bind<float>("General", "Min Speed", 25f, new ConfigDescription("The ball flies at you at least this fast (m/s), even from close by.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>()));
}
}
}
namespace System.Diagnostics.CodeAnalysis
{
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ConstantExpectedAttribute : Attribute
{
public object? Min { get; set; }
public object? Max { get; set; }
}
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ExperimentalAttribute : Attribute
{
public string DiagnosticId { get; }
public string? UrlFormat { get; set; }
public ExperimentalAttribute(string diagnosticId)
{
DiagnosticId = diagnosticId;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullAttribute : Attribute
{
public string[] Members { get; }
public MemberNotNullAttribute(string member)
{
Members = new string[1] { member };
}
public MemberNotNullAttribute(params string[] members)
{
Members = members;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)]
[ExcludeFromCodeCoverage]
internal sealed class MemberNotNullWhenAttribute : Attribute
{
public bool ReturnValue { get; }
public string[] Members { get; }
public MemberNotNullWhenAttribute(bool returnValue, string member)
{
ReturnValue = returnValue;
Members = new string[1] { member };
}
public MemberNotNullWhenAttribute(bool returnValue, params string[] members)
{
ReturnValue = returnValue;
Members = members;
}
}
[AttributeUsage(AttributeTargets.Constructor, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SetsRequiredMembersAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class StringSyntaxAttribute : Attribute
{
public const string CompositeFormat = "CompositeFormat";
public const string DateOnlyFormat = "DateOnlyFormat";
public const string DateTimeFormat = "DateTimeFormat";
public const string EnumFormat = "EnumFormat";
public const string GuidFormat = "GuidFormat";
public const string Json = "Json";
public const string NumericFormat = "NumericFormat";
public const string Regex = "Regex";
public const string TimeOnlyFormat = "TimeOnlyFormat";
public const string TimeSpanFormat = "TimeSpanFormat";
public const string Uri = "Uri";
public const string Xml = "Xml";
public string Syntax { get; }
public object?[] Arguments { get; }
public StringSyntaxAttribute(string syntax)
{
Syntax = syntax;
Arguments = new object[0];
}
public StringSyntaxAttribute(string syntax, params object?[] arguments)
{
Syntax = syntax;
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class UnscopedRefAttribute : Attribute
{
}
}
namespace System.Runtime.Versioning
{
[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Enum | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Interface | AttributeTargets.Delegate, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresPreviewFeaturesAttribute : Attribute
{
public string? Message { get; }
public string? Url { get; set; }
public RequiresPreviewFeaturesAttribute()
{
}
public RequiresPreviewFeaturesAttribute(string? message)
{
Message = message;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CallerArgumentExpressionAttribute : Attribute
{
public string ParameterName { get; }
public CallerArgumentExpressionAttribute(string parameterName)
{
ParameterName = parameterName;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CollectionBuilderAttribute : Attribute
{
public Type BuilderType { get; }
public string MethodName { get; }
public CollectionBuilderAttribute(Type builderType, string methodName)
{
BuilderType = builderType;
MethodName = methodName;
}
}
[AttributeUsage(AttributeTargets.All, AllowMultiple = true, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class CompilerFeatureRequiredAttribute : Attribute
{
public const string RefStructs = "RefStructs";
public const string RequiredMembers = "RequiredMembers";
public string FeatureName { get; }
public bool IsOptional { get; set; }
public CompilerFeatureRequiredAttribute(string featureName)
{
FeatureName = featureName;
}
}
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerArgumentAttribute : Attribute
{
public string[] Arguments { get; }
public InterpolatedStringHandlerArgumentAttribute(string argument)
{
Arguments = new string[1] { argument };
}
public InterpolatedStringHandlerArgumentAttribute(params string[] arguments)
{
Arguments = arguments;
}
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class InterpolatedStringHandlerAttribute : Attribute
{
}
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal static class IsExternalInit
{
}
[AttributeUsage(AttributeTargets.Method, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class ModuleInitializerAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class OverloadResolutionPriorityAttribute : Attribute
{
public int Priority { get; }
public OverloadResolutionPriorityAttribute(int priority)
{
Priority = priority;
}
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = true, AllowMultiple = false)]
[ExcludeFromCodeCoverage]
internal sealed class ParamCollectionAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Property | AttributeTargets.Field, AllowMultiple = false, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class RequiredMemberAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Parameter, Inherited = false)]
[EditorBrowsable(EditorBrowsableState.Never)]
[ExcludeFromCodeCoverage]
internal sealed class RequiresLocationAttribute : Attribute
{
}
[AttributeUsage(AttributeTargets.Module | AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Constructor | AttributeTargets.Method | AttributeTargets.Property | AttributeTargets.Event | AttributeTargets.Interface, Inherited = false)]
[ExcludeFromCodeCoverage]
internal sealed class SkipLocalsInitAttribute : Attribute
{
}
}