using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("sonic")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("sonic")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("98f6da0c-f28e-4d99-a81d-92f0e99ae946")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] [BepInPlugin("YourModName.PingPong", "Ping Pong Mod", "1.0.0")] public class PingPongPlugin : BaseUnityPlugin { public Transform forceGrabPoint; public float grabVerticalOffset = -0.2f; public float aimVerticalOffset = -5f; public static AssetBundle Bundle; public static GameObject BallPrefab; public static GameObject RacketPrefab; public static PhysicMaterial BounceMat; public static AudioClip BounceSfx; public static PhysicMaterial RacketPhysMat; private void Awake() { //IL_0141: Unknown result type (might be due to invalid IL or missing references) string pluginPath = Paths.PluginPath; string[] array = new string[3] { "", ".bundle", ".assets" }; string text = null; string[] array2 = array; foreach (string text2 in array2) { string[] files = Directory.GetFiles(pluginPath, "pingpong" + text2, SearchOption.AllDirectories); if (files.Length != 0) { text = files[0]; break; } } if (string.IsNullOrEmpty(text)) { ((BaseUnityPlugin)this).Logger.LogError((object)"[PingPong] AssetBundle 'pingpong' not found anywhere in BepInEx/plugins!"); return; } ((BaseUnityPlugin)this).Logger.LogInfo((object)("[PingPong] Loading bundle from: " + text)); Bundle = AssetBundle.LoadFromFile(text); if ((Object)(object)Bundle == (Object)null) { ((BaseUnityPlugin)this).Logger.LogError((object)"[PingPong] Failed to load bundle!"); return; } BounceSfx = Bundle.LoadAsset("bounce"); BallPrefab = Bundle.LoadAsset("Valuable Museum GoldTooth1"); RacketPrefab = Bundle.LoadAsset("rracket"); BounceMat = Bundle.LoadAsset("yeah ball"); RacketPhysMat = Bundle.LoadAsset("racket"); new Harmony("YourModName.PingPong").PatchAll(); } } [HarmonyPatch(typeof(EnvironmentDirector), "Setup")] public static class SceneModifierPatch { [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "OnCollisionStay")] public static class ImpactDetectorPatch { [HarmonyPrefix] public static bool Prefix(PhysGrabObjectImpactDetector __instance) { if (((Object)((Component)__instance).gameObject).name == "PingPong_Ball" || ((Object)((Component)__instance).gameObject).name == "rracket") { return false; } return true; } } public class BounceHandler : MonoBehaviour { private float _lastTableBounceTime; private AudioSource _source; private Rigidbody _rb; private void Start() { _source = ((Component)this).gameObject.AddComponent(); _source.clip = PingPongPlugin.BounceSfx; _source.spatialBlend = 1f; _source.maxDistance = 10f; _source.playOnAwake = false; _rb = ((Component)this).GetComponent(); } private void FixedUpdate() { //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_0091: 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_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) RaycastHit val = default(RaycastHit); if (!((Object)(object)_rb == (Object)null) && Physics.Raycast(((Component)this).transform.position, Vector3.down, ref val, 2f) && (((Object)((RaycastHit)(ref val)).transform).name.Contains("Ping Pong Table") || ((Object)(object)((RaycastHit)(ref val)).transform.parent != (Object)null && ((Object)((RaycastHit)(ref val)).transform.parent).name.Contains("Ping Pong Table")))) { Vector3 val2 = ((RaycastHit)(ref val)).point - ((Component)this).transform.position; Vector3 normalized = ((Vector3)(ref val2)).normalized; _rb.AddForce(normalized * 5f, (ForceMode)5); if (_rb.velocity.y > 0f) { _rb.velocity = new Vector3(_rb.velocity.x, _rb.velocity.y * 0.98f, _rb.velocity.z); } } } private void OnCollisionEnter(Collision col) { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: 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_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) SphereCollider val = ((Component)this).GetComponent() ?? ((Component)this).GetComponentInChildren(); if ((Object)(object)val != (Object)null && (Object)(object)((Collider)val).sharedMaterial != (Object)(object)PingPongPlugin.BounceMat) { ((Collider)val).sharedMaterial = PingPongPlugin.BounceMat; } Vector3 val2; if ((Object)(object)_source != (Object)null && (Object)(object)_source.clip != (Object)null) { val2 = col.relativeVelocity; float num = Mathf.Clamp01(((Vector3)(ref val2)).magnitude / 8f); _source.PlayOneShot(_source.clip, num); } Transform val3 = col.transform; bool flag = false; while ((Object)(object)val3 != (Object)null) { if (((Object)val3).name.Contains("Ping Pong Table")) { flag = true; break; } val3 = val3.parent; } if (flag && (Object)(object)_rb != (Object)null) { if (Time.time - _lastTableBounceTime < 0.15f) { return; } _lastTableBounceTime = Time.time; val2 = _rb.velocity; float num2 = Mathf.Max(((Vector3)(ref val2)).magnitude, 2f); Vector3 val4 = Vector3.Reflect(_rb.velocity, Vector3.up); _rb.velocity = Vector3.zero; _rb.angularVelocity = Vector3.zero; _rb.velocity = ((Vector3)(ref val4)).normalized * (num2 * 1.5f); float num3 = ((ContactPoint)(ref col.contacts[0])).point.y + 0.05f; ((Component)this).transform.position = new Vector3(((Component)this).transform.position.x, num3, ((Component)this).transform.position.z); Debug.Log((object)"Forward Bounce Executed!"); } if (((Object)col.gameObject).name.Contains("rracket") && (Object)(object)_rb != (Object)null) { val2 = col.relativeVelocity; float magnitude = ((Vector3)(ref val2)).magnitude; float num4 = 1f + magnitude * 0.5f; num4 = Mathf.Clamp(num4, 1f, 3f); Vector3 velocity = _rb.velocity * num4; velocity.y = -1.5f; _rb.velocity = velocity; } try { } catch (Exception) { } } } public class RacketHandler : MonoBehaviour { private PhysGrabObject _physGrab; private Transform _grabPoint; public float aimVerticalOffset = -290f; public float grabVerticalOffset = -0.1f; private bool _wasGrabbedLastFrame = false; private void Start() { _physGrab = ((Component)this).GetComponent(); _grabPoint = ((Component)this).transform.Find("grab") ?? ((IEnumerable)((Component)((Component)this).transform).GetComponentsInChildren()).FirstOrDefault((Func)((Transform t) => ((Object)t).name == "grab")); } private void Update() { //IL_0051: 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) if (!_physGrab.grabbed || !_physGrab.grabbedLocal) { _wasGrabbedLastFrame = false; return; } if (!_wasGrabbedLastFrame && (Object)(object)_grabPoint != (Object)null) { float num = Vector3.Distance(((Component)this).transform.position, _grabPoint.position); PhysGrabber.instance.OverrideGrabDistance(num); _wasGrabbedLastFrame = true; } UpdateMaster(); } private void UpdateMaster() { //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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) if (!SemiFunc.IsMasterClientOrSingleplayer() || _physGrab.playerGrabbing.Count <= 0) { return; } bool flag = false; foreach (PhysGrabber item in _physGrab.playerGrabbing) { if (item.isRotating) { flag = true; } } if (!flag) { Quaternion val = Quaternion.Euler(aimVerticalOffset, 0f, 0f); _physGrab.TurnXYZ(val, Quaternion.identity, Quaternion.identity); _physGrab.OverrideTorqueStrength(10f, 0.1f); _physGrab.OverrideAngularDrag(40f, 0.1f); } else { _physGrab.OverrideTorqueStrength(2f, 0.1f); _physGrab.OverrideAngularDrag(20f, 0.1f); } _physGrab.OverrideGrabVerticalPosition(grabVerticalOffset); } } [HarmonyPostfix] public static void Postfix() { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0183: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) GameObject[] source = Resources.FindObjectsOfTypeAll(); IEnumerable enumerable = source.Where((GameObject o) => ((Object)o).name.Contains("Ping Pong Table")); foreach (GameObject item in enumerable) { string[] array = new string[2] { "Cube.045", "Cube.044" }; string[] array2 = array; foreach (string name in array2) { Transform val = FindRecursive(item.transform, name); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); } } IEnumerable enumerable2 = source.Where((GameObject o) => ((Object)o).name.Contains("Beer Bottle")); foreach (GameObject item2 in enumerable2) { if (Vector3.Distance(item2.transform.position, item.transform.position) < 700f) { Object.Destroy((Object)(object)item2); } } if ((Object)(object)PingPongPlugin.RacketPrefab != (Object)null) { GameObject val2 = Object.Instantiate(PingPongPlugin.RacketPrefab, item.transform.position + new Vector3(0f, 0.1f, 0.2f), Quaternion.identity); GameObject val3 = Object.Instantiate(PingPongPlugin.RacketPrefab, item.transform.position + new Vector3(0f, 0.1f, -0.2f), Quaternion.identity); ((Object)val2).name = "rracket"; ((Object)val3).name = "rracket"; val2.AddComponent(); val3.AddComponent(); ApplyPhysicMaterial(val2, PingPongPlugin.RacketPhysMat); ApplyPhysicMaterial(val3, PingPongPlugin.RacketPhysMat); } if ((Object)(object)PingPongPlugin.BallPrefab != (Object)null) { GameObject val4 = Object.Instantiate(PingPongPlugin.BallPrefab, item.transform.position + new Vector3(0f, 0.2f, 0f), Quaternion.identity); ((Object)val4).name = "PingPong_Ball"; Collider val5 = val4.GetComponent() ?? val4.GetComponentInChildren(); if ((Object)(object)val5 != (Object)null && (Object)(object)PingPongPlugin.BounceMat != (Object)null) { val5.material = PingPongPlugin.BounceMat; } SphereCollider componentInChildren = val4.GetComponentInChildren(); if ((Object)(object)componentInChildren != (Object)null) { ((Collider)componentInChildren).material = PingPongPlugin.BounceMat; } val4.AddComponent(); } CleanupStartRoomByProximity(); } } private static void ApplyPhysicMaterial(GameObject obj, PhysicMaterial mat) { if (!((Object)(object)obj == (Object)null) && !((Object)(object)mat == (Object)null)) { Collider component = obj.GetComponent(); if ((Object)(object)component != (Object)null) { component.material = mat; } Collider[] componentsInChildren = obj.GetComponentsInChildren(true); foreach (Collider val in componentsInChildren) { val.material = mat; } } } private static void CleanupStartRoomByProximity() { //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_004b: Unknown result type (might be due to invalid IL or missing references) Module[] source = Resources.FindObjectsOfTypeAll(); Module val = ((IEnumerable)source).FirstOrDefault((Func)((Module m) => ((Object)((Component)m).gameObject).name.Contains("Start"))); if ((Object)(object)val == (Object)null) { return; } Vector3 position = ((Component)val).transform.position; Collider[] array = Physics.OverlapSphere(position, 5f); Collider[] array2 = array; foreach (Collider val2 in array2) { GameObject gameObject = ((Component)val2).gameObject; if (((Object)gameObject).name == "PingPong_Ball" || ((Object)gameObject).name == "rracket" || ((Object)gameObject).name == "Valuable Museum GoldTooth1" || ((Object)gameObject).name == "racket") { Object.Destroy((Object)(object)gameObject); } } } private static Transform FindRecursive(Transform parent, string name) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown foreach (Transform item in parent) { Transform val = item; if (((Object)val).name == name) { return val; } Transform val2 = FindRecursive(val, name); if ((Object)(object)val2 != (Object)null) { return val2; } } return null; } }