The BepInEx console will not appear when launching like it does for other games on Thunderstore (you can turn it back on in your BepInEx.cfg file). If your PEAK crashes on startup, add -dx12 to your launch parameters.
Decompiled source of StreamToEarn PEAK TikTok Integration v1.0.0
S2E_PEAK/PeakMod.dll
Decompiled a week ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Net; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using System.Threading; using System.Threading.Tasks; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Photon.Pun; using UnityEngine; using UnityEngine.SceneManagement; using Zorro.Core; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("PeakMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("PeakMod")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("1b91e668-275d-46ee-97d0-6582cb9ce3b6")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace PeakMod; internal static class BananaPeelController { private static ManualLogSource Logger = Logger.CreateLogSource("PEAKTikTok"); internal static void TriggerSlipEffect() { try { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { Logger.LogError((object)"❌ Локальний персонаж не знайдений!"); return; } Logger.LogInfo((object)"\ud83c\udf4c Викликаємо посковзування для локального гравця"); SlipperyJellyfish val = FindOrCreateJellyfish(); if ((Object)(object)val != (Object)null) { val.Trigger(localCharacter.refs.view.ViewID); Logger.LogInfo((object)"✅ Ефект посковзування застосовано через медузу!"); } else { Logger.LogError((object)"❌ Не вдалося знайти або створити медузу!"); } } catch (Exception ex) { Logger.LogError((object)("❌ Помилка при виклику посковзування: " + ex.Message)); } } private static SlipperyJellyfish FindOrCreateJellyfish() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown try { SlipperyJellyfish[] array = Object.FindObjectsByType<SlipperyJellyfish>((FindObjectsSortMode)0); if (array.Length != 0) { Logger.LogInfo((object)"\ud83c\udf90 Знайдено існуючу медузу"); return array[0]; } GameObject val = new GameObject("TempSlipperyJellyfish"); SlipperyJellyfish result = val.AddComponent<SlipperyJellyfish>(); Logger.LogInfo((object)"\ud83c\udf90 Створено тимчасову медузу"); return result; } catch (Exception ex) { Logger.LogError((object)("❌ Помилка при пошуку/створенні медузи: " + ex.Message)); return null; } } internal static void SpawnBananaPeelNearPlayer() { try { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { Logger.LogError((object)"❌ Локальний персонаж не знайдений!"); return; } Logger.LogInfo((object)"\ud83c\udf4c Створюємо віртуальну бананову шкурку біля гравця"); CoroutineRunner.StartDelayedSlipEffect(1f); } catch (Exception ex) { Logger.LogError((object)("❌ Помилка при створенні бананової шкурки: " + ex.Message)); } } } internal static class CoroutineRunner { [CompilerGenerated] private sealed class <DelayedSlipEffectCoroutine>d__2 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public float delay; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <DelayedSlipEffectCoroutine>d__2(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; Logger.LogInfo((object)$"⏳ Очікуємо {delay} секунд до посковзування..."); <>2__current = (object)new WaitForSeconds(delay); <>1__state = 1; return true; case 1: <>1__state = -1; Logger.LogInfo((object)"\ud83c\udf4c Час посковзування настав!"); BananaPeelController.TriggerSlipEffect(); return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } [CompilerGenerated] private sealed class <RepeatedSlipEffectCoroutine>d__5 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public float interval; public int count; private int <i>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RepeatedSlipEffectCoroutine>d__5(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown int num = <>1__state; if (num != 0) { if (num != 1) { return false; } <>1__state = -1; goto IL_0094; } <>1__state = -1; <i>5__1 = 0; goto IL_00a5; IL_0094: <i>5__1++; goto IL_00a5; IL_00a5: if (<i>5__1 < count) { Logger.LogInfo((object)$"\ud83c\udf4c Посковзування {<i>5__1 + 1} з {count}"); BananaPeelController.TriggerSlipEffect(); if (<i>5__1 < count - 1) { <>2__current = (object)new WaitForSeconds(interval); <>1__state = 1; return true; } goto IL_0094; } Logger.LogInfo((object)"✅ Серія посковзувань завершена!"); return false; } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static ManualLogSource Logger = Logger.CreateLogSource("PEAKTikTok"); internal static void StartDelayedSlipEffect(float delay) { if ((Object)(object)PEAKTikTok.Instance != (Object)null) { ((MonoBehaviour)PEAKTikTok.Instance).StartCoroutine(DelayedSlipEffectCoroutine(delay)); } else { Logger.LogError((object)"❌ PEAKTikTok.Instance is null, cannot start coroutine!"); } } [IteratorStateMachine(typeof(<DelayedSlipEffectCoroutine>d__2))] private static IEnumerator DelayedSlipEffectCoroutine(float delay) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <DelayedSlipEffectCoroutine>d__2(0) { delay = delay }; } internal static void StartCustomCoroutine(IEnumerator coroutine) { if ((Object)(object)PEAKTikTok.Instance != (Object)null) { ((MonoBehaviour)PEAKTikTok.Instance).StartCoroutine(coroutine); } else { Logger.LogError((object)"❌ PEAKTikTok.Instance is null, cannot start coroutine!"); } } internal static void StartRepeatedSlipEffect(float interval, int count) { if ((Object)(object)PEAKTikTok.Instance != (Object)null) { ((MonoBehaviour)PEAKTikTok.Instance).StartCoroutine(RepeatedSlipEffectCoroutine(interval, count)); } else { Logger.LogError((object)"❌ PEAKTikTok.Instance is null, cannot start coroutine!"); } } [IteratorStateMachine(typeof(<RepeatedSlipEffectCoroutine>d__5))] private static IEnumerator RepeatedSlipEffectCoroutine(float interval, int count) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <RepeatedSlipEffectCoroutine>d__5(0) { interval = interval, count = count }; } } internal class CustomItemPickup : MonoBehaviour { [CompilerGenerated] private sealed class <CooldownCoroutine>d__13 : IEnumerator<object>, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public CustomItemPickup <>4__this; private bool <originalNearby>5__1; object IEnumerator<object>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <CooldownCoroutine>d__13(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <originalNearby>5__1 = <>4__this.playerNearby; <>4__this.playerNearby = false; <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 1; return true; case 1: <>1__state = -1; if (!<>4__this.isPickedUp) { <>4__this.playerNearby = <originalNearby>5__1; } return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } private static ManualLogSource Logger = Logger.CreateLogSource("CustomPickup"); private ushort itemID; private string itemName; public bool isPickedUp = false; private bool playerNearby = false; internal void Initialize(ushort id, string name) { itemID = id; itemName = name; Logger.LogInfo((object)$"\ud83d\udd27 CustomPickup initialized: {itemName} (ID: {itemID})"); } private void Start() { SphereCollider val = ((Component)this).gameObject.AddComponent<SphereCollider>(); ((Collider)val).isTrigger = true; val.radius = 1.5f; Logger.LogInfo((object)("\ud83c\udfaf Added trigger to real item: " + itemName)); } private void Update() { if (isPickedUp) { return; } CheckPlayerDistance(); if (playerNearby && (Input.GetKeyDown((KeyCode)101) || Input.GetKeyDown((KeyCode)102))) { if (IsClosestItem()) { Logger.LogInfo((object)("\ud83d\udd18 Pickup key pressed for closest real item: " + itemName)); TryPickupRealItem(); } else { Logger.LogInfo((object)("\ud83d\udeab Ignoring pickup - " + itemName + " is not closest")); } } } private bool IsClosestItem() { //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_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //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) try { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { return false; } Vector3 position = ((Component)localCharacter).transform.position; float num = Vector3.Distance(((Component)this).transform.position, position); CustomItemPickup[] array = Object.FindObjectsOfType<CustomItemPickup>(); CustomItemPickup[] array2 = array; foreach (CustomItemPickup customItemPickup in array2) { if (!((Object)(object)customItemPickup == (Object)(object)this) && !customItemPickup.isPickedUp) { float num2 = Vector3.Distance(((Component)customItemPickup).transform.position, position); if (num2 < num && num2 <= 2f) { return false; } } } return true; } catch (Exception ex) { Logger.LogError((object)("❌ Error checking closest item: " + ex.Message)); return false; } } private void CheckPlayerDistance() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) try { Character localCharacter = Character.localCharacter; if (!((Object)(object)localCharacter == (Object)null)) { float num = Vector3.Distance(((Component)this).transform.position, ((Component)localCharacter).transform.position); bool flag = playerNearby; playerNearby = num <= 2f; if (playerNearby && !flag) { Logger.LogInfo((object)$"\ud83d\udc64 Player can pickup real item: {itemName} (distance: {num:F2}m)"); } } } catch (Exception ex) { Logger.LogError((object)("❌ Error checking distance for real item: " + ex.Message)); } } private void OnTriggerEnter(Collider other) { Logger.LogInfo((object)("\ud83c\udfaf Real item trigger: " + ((Object)other).name)); } private void TryPickupRealItem() { try { if (isPickedUp) { return; } Character localCharacter = Character.localCharacter; if ((Object)(object)((localCharacter != null) ? localCharacter.player : null) == (Object)null) { Logger.LogError((object)("❌ No character for real pickup: " + itemName)); return; } Logger.LogInfo((object)$"\ud83e\udd0f Attempting real pickup: {itemName} (ID: {itemID})"); ItemSlot val = default(ItemSlot); if (localCharacter.player.AddItem((ushort)(byte)itemID, (ItemInstanceData)null, ref val)) { Logger.LogInfo((object)$"✅ Real pickup successful: {itemName} -> slot {val.itemSlotID}"); AudioSource component = ((Component)this).GetComponent<AudioSource>(); if ((Object)(object)((component != null) ? component.clip : null) != (Object)null) { component.Play(); } isPickedUp = true; SetGlobalPickupCooldown(); Object.Destroy((Object)(object)((Component)this).gameObject, 0.1f); } else { Logger.LogWarning((object)("⚠\ufe0f Real pickup failed: " + itemName + " (inventory full)")); } } catch (Exception ex) { Logger.LogError((object)("❌ Real pickup error for " + itemName + ": " + ex.Message)); } } private void SetGlobalPickupCooldown() { try { CustomItemPickup[] array = Object.FindObjectsOfType<CustomItemPickup>(); CustomItemPickup[] array2 = array; foreach (CustomItemPickup customItemPickup in array2) { if ((Object)(object)customItemPickup != (Object)null && !customItemPickup.isPickedUp) { ((MonoBehaviour)customItemPickup).StartCoroutine(customItemPickup.CooldownCoroutine()); } } } catch (Exception ex) { Logger.LogError((object)("❌ Error setting global cooldown: " + ex.Message)); } } [IteratorStateMachine(typeof(<CooldownCoroutine>d__13))] private IEnumerator CooldownCoroutine() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <CooldownCoroutine>d__13(0) { <>4__this = this }; } } [HarmonyPatch(typeof(Character), "Die")] internal static class DeathPositionPatch { private static ManualLogSource Logger = Logger.CreateLogSource("DeathPatch"); internal static void Prefix(Character __instance) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance == (Object)(object)Character.localCharacter) { PlayerReviveController.SaveDeathPosition(((Component)__instance).transform.position); Logger.LogInfo((object)$"\ud83d\udc80 Saved death position via patch: {((Component)__instance).transform.position}"); } } } [BepInPlugin("com.streamtoearn.peaktiktok", "PEAKTikTok", "1.0.0")] internal class PEAKTikTokPlugin : BaseUnityPlugin { private static ManualLogSource Logger; private static Harmony harmony; private void Awake() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Expected O, but got Unknown //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"\ud83d\ude80 PEAKTikTok Plugin Awake called!"); try { harmony = new Harmony("com.streamtoearn.peaktiktok"); harmony.PatchAll(); Logger.LogInfo((object)"\ud83d\udd27 Harmony patches applied!"); GameObject val = new GameObject("ModLauncher"); val.AddComponent<ModLauncher>(); Object.DontDestroyOnLoad((Object)(object)val); Logger.LogInfo((object)"✅ Mod launcher initialized!"); } catch (Exception ex) { Logger.LogError((object)("❌ Failed to initialize: " + ex.Message)); } } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchAll("com.streamtoearn.peaktiktok"); } } } internal class EventResult { internal bool Success { get; set; } internal string Message { get; set; } internal Dictionary<string, object> Data { get; set; } internal EventResult() { Data = new Dictionary<string, object>(); } internal static EventResult SuccessResult(string message = "", Dictionary<string, object> data = null) { return new EventResult { Success = true, Message = (message ?? ""), Data = (data ?? new Dictionary<string, object>()) }; } internal static EventResult FailureResult(string message = "", Dictionary<string, object> data = null) { return new EventResult { Success = false, Message = (message ?? ""), Data = (data ?? new Dictionary<string, object>()) }; } internal static EventResult FromException(Exception ex, string context = "") { string message = (string.IsNullOrEmpty(context) ? ("Error: " + ex.Message) : ("Error in " + context + ": " + ex.Message)); return FailureResult(message, new Dictionary<string, object> { ["exception"] = ex.GetType().Name, ["stackTrace"] = ex.StackTrace }); } public override string ToString() { return $"EventResult[Success={Success}, Message='{Message}', DataCount={Data?.Count ?? 0}]"; } } internal class EventResponse { public bool Success { get; set; } public string Message { get; set; } public Dictionary<string, object> Data { get; set; } internal EventResponse() { Data = new Dictionary<string, object>(); } internal static EventResponse FromResult(EventResult result) { return new EventResponse { Success = result.Success, Message = result.Message, Data = result.Data }; } } internal class HttpServer : MonoBehaviour { private HttpListener listener; private bool isRunning; private CancellationTokenSource cancellationTokenSource; private static readonly string[] AllowedOrigins = new string[2] { "https://app.streamtoearn.io", "https://alt.streamtoearn.io" }; private static ManualLogSource Logger = Logger.CreateLogSource("HttpServer"); internal static HttpServer Instance { get; private set; } private void Start() { Instance = this; cancellationTokenSource = new CancellationTokenSource(); Logger.LogInfo((object)"\ud83d\ude80 Starting HTTP Server..."); StartServer(); } private void StartServer() { try { listener = new HttpListener(); listener.Prefixes.Add("http://127.0.0.1:55001/"); listener.Prefixes.Add("http://localhost:55001/"); listener.Start(); isRunning = true; Logger.LogInfo((object)"\ud83d\udce1 HTTP Server started on http://localhost:55001/"); Task.Run(async delegate { await ProcessRequestsAsync(cancellationTokenSource.Token); }).Forget(); } catch (Exception ex) { Logger.LogError((object)("❌ Failed to start HTTP server: " + ex.Message)); } } private async Task ProcessRequestsAsync(CancellationToken cancellationToken) { while (isRunning && !cancellationToken.IsCancellationRequested) { try { Task<HttpListenerContext> contextTask = listener.GetContextAsync(); HttpListenerContext context = await contextTask; Task.Run(delegate { HandleRequestSafe(context); }).Forget(); } catch (ObjectDisposedException) { break; } catch (HttpListenerException ex2) { if (ex2.ErrorCode != 995) { Logger.LogError((object)("❌ HTTP Listener error: " + ex2.Message)); } break; } catch (Exception ex) { Logger.LogError((object)("❌ Unexpected error in HTTP server: " + ex.Message)); await Task.Delay(1000, cancellationToken); } } } private void HandleRequestSafe(HttpListenerContext context) { try { HandleRequest(context); } catch (Exception ex) { Logger.LogError((object)("❌ Error handling HTTP request: " + ex.Message)); try { context.Response.StatusCode = 500; context.Response.Close(); } catch { } } } private void HandleRequest(HttpListenerContext context) { HttpListenerRequest request = context.Request; HttpListenerResponse response = context.Response; try { Logger.LogInfo((object)$"\ud83d\udce5 {request.HttpMethod} {request.Url?.AbsolutePath} from {request.RemoteEndPoint}"); string origin = request.Headers["Origin"]; bool flag = ValidateOrigin(origin); SetCorsHeaders(response, origin, flag); if (!flag) { Logger.LogWarning((object)"\ud83d\udeab Request blocked - unauthorized access attempt"); response.StatusCode = 403; response.Close(); return; } if (request.HttpMethod == "OPTIONS") { response.StatusCode = 200; response.Close(); return; } string requestBody = ""; if (request.HasEntityBody) { using StreamReader streamReader = new StreamReader(request.InputStream, request.ContentEncoding ?? Encoding.UTF8); requestBody = streamReader.ReadToEnd(); } Logger.LogInfo((object)("\ud83d\udce6 Request body: " + requestBody)); string path = request.Url?.AbsolutePath ?? "/"; MainThreadDispatcher.Enqueue(delegate { RequestHandler.HandleRequest(path, requestBody); }); SendResponse(response, "OK"); } catch (Exception ex) { Logger.LogError((object)("❌ Request handling error: " + ex.Message)); SendResponse(response, "Internal Server Error", 500); } } private bool ValidateOrigin(string origin) { if (string.IsNullOrEmpty(origin)) { Logger.LogWarning((object)"⚠\ufe0f Blocked request without Origin header"); return false; } string[] allowedOrigins = AllowedOrigins; foreach (string value in allowedOrigins) { if (origin.StartsWith(value, StringComparison.OrdinalIgnoreCase)) { Logger.LogInfo((object)("✅ Allowed request from: " + origin)); return true; } } Logger.LogWarning((object)("⚠\ufe0f Blocked request from unauthorized origin: " + origin)); return false; } private void SetCorsHeaders(HttpListenerResponse response, string origin, bool isAllowed) { if (isAllowed) { response.Headers.Add("Access-Control-Allow-Origin", origin ?? "*"); } response.Headers.Add("Access-Control-Allow-Methods", "GET, POST, OPTIONS"); response.Headers.Add("Access-Control-Allow-Headers", "Content-Type, Authorization, Superdupertoken"); response.Headers.Add("Access-Control-Max-Age", "3600"); } private void SendResponse(HttpListenerResponse response, string content, int statusCode = 200) { try { response.StatusCode = statusCode; response.ContentType = "text/plain; charset=utf-8"; byte[] bytes = Encoding.UTF8.GetBytes(content); response.ContentLength64 = bytes.Length; using (Stream stream = response.OutputStream) { stream.Write(bytes, 0, bytes.Length); } response.Close(); } catch (Exception ex) { Logger.LogError((object)("❌ Error sending response: " + ex.Message)); } } internal void StopServer() { try { isRunning = false; cancellationTokenSource?.Cancel(); if (listener != null && listener.IsListening) { listener.Stop(); listener.Close(); } cancellationTokenSource?.Dispose(); Logger.LogInfo((object)"\ud83d\udcf4 HTTP Server stopped"); } catch (Exception ex) { Logger.LogError((object)("❌ Error stopping HTTP server: " + ex.Message)); } } private void OnDestroy() { StopServer(); } private void OnApplicationQuit() { StopServer(); } } [HarmonyPatch(typeof(Item), "Interact")] internal static class ItemInteractionPatch { private static ManualLogSource Logger = Logger.CreateLogSource("ItemInteractionPatch"); internal static bool Prefix(Item __instance, Character interactor) { try { if (IsOurSpawnedItem(__instance)) { Logger.LogInfo((object)("\ud83c\udfaf Intercepting interaction with our item: " + ((Object)__instance).name)); if ((Object)(object)interactor == (Object)(object)Character.localCharacter) { Logger.LogInfo((object)$"\ud83d\udc64 Local player interacting with: {((Object)__instance).name} (ID: {__instance.itemID})"); if (!HasInventorySpace(interactor)) { Logger.LogWarning((object)("⚠\ufe0f Inventory full, cannot pickup " + ((Object)__instance).name)); return true; } if (AddItemToInventory(__instance, interactor)) { Logger.LogInfo((object)("✅ Successfully added " + ((Object)__instance).name + " to inventory")); Object.Destroy((Object)(object)((Component)__instance).gameObject); return false; } } } return true; } catch (Exception ex) { Logger.LogError((object)("❌ ItemInteractionPatch error: " + ex.Message)); return true; } } private static bool HasInventorySpace(Character character) { try { if ((Object)(object)((character != null) ? character.player : null) == (Object)null) { return false; } for (byte b = 0; b <= 2; b++) { ItemSlot itemSlot = character.player.GetItemSlot(b); if (itemSlot != null && itemSlot.IsEmpty()) { return true; } } ItemSlot itemSlot2 = character.player.GetItemSlot((byte)3); if (itemSlot2 != null && !itemSlot2.IsEmpty()) { for (byte b2 = 4; b2 <= 7; b2++) { try { ItemSlot itemSlot3 = character.player.GetItemSlot(b2); if (itemSlot3 != null && itemSlot3.IsEmpty()) { return true; } } catch { } } } return false; } catch (Exception ex) { Logger.LogError((object)("❌ Error checking inventory space: " + ex.Message)); return false; } } private static bool IsOurSpawnedItem(Item item) { return ((Object)item).name.Contains("(Clone)") && (Object)(object)((Component)item).GetComponent<SpawnedItemMarker>() != (Object)null; } private static bool AddItemToInventory(Item item, Character character) { try { if ((Object)(object)((character != null) ? character.player : null) == (Object)null) { return false; } return TryAddItemToSafeSlots(character.player, item.itemID); } catch (Exception ex) { Logger.LogError((object)("❌ Error adding item to inventory: " + ex.Message)); return false; } } private static bool TryAddItemToSafeSlots(Player player, ushort itemID) { try { ItemSlot val = default(ItemSlot); for (byte b = 0; b <= 2; b++) { ItemSlot itemSlot = player.GetItemSlot(b); if (itemSlot != null && itemSlot.IsEmpty() && player.AddItem((ushort)(byte)itemID, (ItemInstanceData)null, ref val) && val.itemSlotID == b) { Logger.LogInfo((object)$"✅ Added to regular slot {b}"); PlayPickupSound(); return true; } } ItemSlot itemSlot2 = player.GetItemSlot((byte)3); if (itemSlot2 != null && !itemSlot2.IsEmpty()) { ItemSlot val2 = default(ItemSlot); for (byte b2 = 4; b2 <= 7; b2++) { try { ItemSlot itemSlot3 = player.GetItemSlot(b2); if (itemSlot3 != null && itemSlot3.IsEmpty() && player.AddItem((ushort)(byte)itemID, (ItemInstanceData)null, ref val2) && val2.itemSlotID == b2) { Logger.LogInfo((object)$"✅ Added to backpack slot {b2}"); PlayPickupSound(); return true; } } catch { } } } return false; } catch (Exception ex) { Logger.LogError((object)("❌ Error in TryAddItemToSafeSlots: " + ex.Message)); return false; } } private static void PlayPickupSound() { try { Logger.LogInfo((object)"\ud83d\udd0a Played pickup sound"); } catch (Exception ex) { Logger.LogWarning((object)("⚠\ufe0f Could not play pickup sound: " + ex.Message)); } } } [HarmonyPatch(typeof(Item), "Update")] internal static class ItemUpdatePatch { private static ManualLogSource Logger = Logger.CreateLogSource("ItemUpdatePatch"); internal static bool Prefix(Item __instance) { try { if (IsOurSpawnedItem(__instance)) { HandleOurItemUpdate(__instance); return false; } if ((Object)(object)((MonoBehaviourPun)__instance).photonView == (Object)null) { Logger.LogWarning((object)("⚠\ufe0f Item " + ((Object)__instance).name + " has null photonView, skipping update")); return false; } return true; } catch (Exception ex) { Logger.LogError((object)("❌ ItemUpdatePatch error: " + ex.Message)); return false; } } private static bool IsOurSpawnedItem(Item item) { return (Object)(object)((Component)item).GetComponent<SpawnedItemMarker>() != (Object)null; } private static void HandleOurItemUpdate(Item item) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) try { if ((Object)(object)item == (Object)null || !((Behaviour)item).enabled) { return; } if (((Component)item).transform.position.y < -1000f) { Logger.LogInfo((object)("\ud83d\uddd1\ufe0f Destroying item " + ((Object)item).name + " - fell below world")); Object.Destroy((Object)(object)((Component)item).gameObject); return; } SpawnedItemMarker component = ((Component)item).GetComponent<SpawnedItemMarker>(); if (!((Object)(object)component != (Object)null) || !(Time.time - component.spawnTime > 30f)) { return; } Rigidbody component2 = ((Component)item).GetComponent<Rigidbody>(); if ((Object)(object)component2 != (Object)null) { Vector3 velocity = component2.velocity; if (!(((Vector3)(ref velocity)).magnitude < 0.1f)) { } } } catch (Exception ex) { Logger.LogError((object)("❌ Error in our item update: " + ex.Message)); } } } internal class SpawnedItemMarker : MonoBehaviour { private static ManualLogSource Logger = Logger.CreateLogSource("SpawnedItemMarker"); internal string spawnedBy = "PEAKTikTok"; internal float spawnTime; internal string itemName; private void Start() { spawnTime = Time.time; itemName = ((Object)((Component)this).gameObject).name; Logger.LogInfo((object)("\ud83c\udff7\ufe0f Spawned item marker created for: " + itemName)); } private void Update() { try { Item component = ((Component)this).GetComponent<Item>(); if ((Object)(object)component == (Object)null) { Logger.LogWarning((object)"⚠\ufe0f Item component missing on spawned item, destroying..."); Object.Destroy((Object)(object)((Component)this).gameObject); return; } if (Time.time - spawnTime > 1f && !((Behaviour)component).enabled) { Logger.LogWarning((object)"⚠\ufe0f Item component disabled, re-enabling..."); ((Behaviour)component).enabled = true; } if (Time.time - spawnTime > 300f) { Logger.LogInfo((object)("\ud83d\uddd1\ufe0f Auto-cleaning old spawned item: " + itemName)); Object.Destroy((Object)(object)((Component)this).gameObject); } } catch (Exception ex) { Logger.LogError((object)("❌ Error in SpawnedItemMarker update: " + ex.Message)); } } } internal static class ItemSpawner { private static ManualLogSource Logger = Logger.CreateLogSource("PEAKTikTok"); private static Dictionary<string, float> itemCooldowns = new Dictionary<string, float>(); private const float ITEM_COOLDOWN = 0.8f; private static readonly Dictionary<string, string> ItemMap = new Dictionary<string, string> { { "airplanefood", "Airplane Food" }, { "granolabar", "Granola Bar" }, { "energydrink", "Energy Drink" }, { "marshmallow", "Marshmallow" }, { "trailmix", "TrailMix" }, { "scoutcookies", "ScoutCookies" }, { "lollipop", "Lollipop" }, { "coconut", "Item_Coconut" }, { "coconuthalf", "Item_Coconut_half" }, { "honeycomb", "Item_Honeycomb" }, { "egg", "Egg" }, { "appleberrygreen", "Apple Berry Green" }, { "appleberryred", "Apple Berry Red" }, { "appleberryyellow", "Apple Berry Yellow" }, { "berrynanablue", "Berrynana Blue" }, { "berrynanabrown", "Berrynana Brown" }, { "berrynanapink", "Berrynana Pink" }, { "berrynanayellow", "Berrynana Yellow" }, { "clusterberryblack", "Clusterberry Black" }, { "clusterberryred", "Clusterberry Red" }, { "clusterberryyellow", "Clusterberry Yellow" }, { "kingberrygreen", "Kingberry Green" }, { "kingberrypurple", "Kingberry Purple" }, { "kingberryyellow", "Kingberry Yellow" }, { "napberry", "Napberry" }, { "pepperberry", "Pepper Berry" }, { "winterberryorange", "Winterberry Orange" }, { "winterberryyellow", "Winterberry Yellow" }, { "mushroomchubby", "Mushroom Chubby" }, { "mushroomcluster", "Mushroom Cluster" }, { "mushroomclusterpoison", "Mushroom Cluster Poison" }, { "mushroomglow", "Mushroom Glow" }, { "mushroomlace", "Mushroom Lace" }, { "mushroomlacepoison", "Mushroom Lace Poison" }, { "mushroomnormie", "Mushroom Normie" }, { "mushroomnormiepoison", "Mushroom Normie Poison" }, { "shelfshroom", "ShelfShroom" }, { "bounce", "BounceShroom" }, { "healingpuff", "HealingPuffShroom" }, { "antidote", "Antidote" }, { "bandage", "Bandages" }, { "firstaidkit", "FirstAidKit" }, { "cureall", "Cure-All" }, { "medicinalroot", "MedicinalRoot" }, { "heatpack", "Heat Pack" }, { "healingdart", "HealingDart Variant" }, { "backpack", "Backpack" }, { "binoculars", "Binoculars" }, { "compass", "Compass" }, { "piratecompass", "Pirate Compass" }, { "warpcompass", "Warp Compass" }, { "lantern", "Lantern" }, { "lanternfaerie", "Lantern_Faerie" }, { "flare", "Flare" }, { "rope", "RopeSpool" }, { "antirope", "Anti-Rope Spool" }, { "ropecannon", "RopeShooter" }, { "ropecannonanti", "RopeShooterAnti" }, { "chaincannon", "ChainShooter" }, { "climbingspike", "ClimbingSpike" }, { "firewood", "FireWood" }, { "stove", "PortableStovetopItem" }, { "bugle", "Bugle" }, { "buglemagic", "Bugle_Magic" }, { "buglescoutmaster", "Bugle_Scoutmaster Variant" }, { "beehive", "Beehive" }, { "book", "Guidebook" }, { "guidepage", "GuidebookPage" }, { "flagseagull", "Flag_Plantable_Seagull" }, { "flagturtle", "Flag_Plantable_Turtle" }, { "shellbig", "Shell Big" }, { "stone", "Stone" }, { "nestegg", "NestEgg" }, { "pandorasbox", "PandorasBox" }, { "passport", "Passport" }, { "toy", "BingBong" }, { "toyscout", "Toy" }, { "scouteffigy", "ScoutEffigy" }, { "cursedskull", "Cursed Skull" }, { "magicbean", "MagicBean" }, { "bugfix", "Bugfix" } }; private static readonly Dictionary<byte, string> IDToKeyMap = new Dictionary<byte, string> { { 36, "coconut" } }; internal static string GetItemKeyByID(byte itemID) { if (IDToKeyMap.TryGetValue(itemID, out var value)) { return value; } try { if (SingletonAsset<ItemDatabase>.Instance?.itemLookup != null) { foreach (KeyValuePair<ushort, Item> item in SingletonAsset<ItemDatabase>.Instance.itemLookup) { if (item.Value.itemID != itemID) { continue; } foreach (KeyValuePair<string, string> item2 in ItemMap) { if (item2.Value == ((Object)item.Value).name) { return item2.Key; } } } } } catch (Exception ex) { Logger.LogError((object)$"❌ Error finding item key for ID {itemID}: {ex.Message}"); } return "coconut"; } private static Item FindItemInDatabase(string itemName) { try { if (SingletonAsset<ItemDatabase>.Instance?.itemLookup == null) { Logger.LogError((object)"❌ ItemDatabase недоступна!"); return null; } foreach (KeyValuePair<ushort, Item> item in SingletonAsset<ItemDatabase>.Instance.itemLookup) { Item value = item.Value; if ((Object)(object)value != (Object)null && ((Object)value).name == itemName) { Logger.LogInfo((object)$"✅ Знайдено: {((Object)value).name} (ID: {value.itemID})"); return value; } } Logger.LogError((object)("❌ Предмет '" + itemName + "' не знайдено!")); return null; } catch (Exception ex) { Logger.LogError((object)("❌ Помилка пошуку: " + ex.Message)); return null; } } private static Vector3 GetCurrentPlayerPosition() { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_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_007b: 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_008f: Unknown result type (might be due to invalid IL or missing references) try { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { Logger.LogError((object)"❌ Local character is null!"); return Vector3.zero; } CharacterRefs refs = localCharacter.refs; object obj; if (refs == null) { obj = null; } else { Bodypart hip = refs.hip; obj = ((hip != null) ? ((Component)hip).transform : null); } if ((Object)obj != (Object)null) { Vector3 position = ((Component)localCharacter.refs.hip).transform.position; Logger.LogInfo((object)$"\ud83e\uddb4 Using LIVE hip position: {position}"); return position; } Vector3 position2 = ((Component)localCharacter).transform.position; Logger.LogWarning((object)$"⚠\ufe0f Using fallback transform position: {position2}"); return position2; } catch (Exception ex) { Logger.LogError((object)("❌ Error getting player position: " + ex.Message)); return Vector3.zero; } } private static Vector3 CalculateSpawnPositionFromPlayer(Vector3 playerPosition, float radius, int itemIndex, int totalItems) { //IL_014b: 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_0156: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_00f0: 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_0116: 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_0128: Unknown result type (might be due to invalid IL or missing references) try { Logger.LogInfo((object)$"\ud83c\udfaf Calculating spawn for item {itemIndex + 1}/{totalItems} from player at {playerPosition}"); Vector3 val = default(Vector3); if (totalItems == 1) { float num = Random.Range(0f, (float)Math.PI * 2f); float num2 = Random.Range(0.8f, radius); ((Vector3)(ref val))..ctor(Mathf.Cos(num) * num2, 0.5f, Mathf.Sin(num) * num2); Logger.LogInfo((object)$"\ud83c\udfaf Single item random spawn: angle={num:F2}, distance={num2:F2}"); } else { float num3 = (float)Math.PI * 2f * (float)itemIndex / (float)totalItems; ((Vector3)(ref val))..ctor(Mathf.Cos(num3) * radius, 0.5f, Mathf.Sin(num3) * radius); Logger.LogInfo((object)$"\ud83c\udfaf Circle spawn: angle={num3:F2}, distance={radius:F2}"); } Vector3 val2 = playerPosition + val; Logger.LogInfo((object)$"\ud83c\udfaf Final spawn position: {val2}"); Logger.LogInfo((object)$"\ud83c\udfaf Offset from player: {val}"); return val2; } catch (Exception ex) { Logger.LogError((object)("❌ Error calculating spawn position: " + ex.Message)); return playerPosition + Vector3.forward * 1.5f + Vector3.up * 0.5f; } } private static Vector3 GetPlayerPositionViaReflection() { //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0072: 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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) try { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { return Vector3.zero; } MethodInfo method = ((object)localCharacter).GetType().GetMethod("HipPos", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { Vector3 val = (Vector3)method.Invoke(localCharacter, null); Logger.LogInfo((object)$"\ud83d\udd27 Reflection hip position: {val}"); return val; } Vector3 center = localCharacter.Center; Logger.LogInfo((object)$"\ud83c\udfaf Center position: {center}"); return center; } catch (Exception ex) { Logger.LogError((object)("❌ Reflection method failed: " + ex.Message)); return Vector3.zero; } } private static Vector3 GetMostAccuratePlayerPosition() { //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_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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_0083: 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_0089: 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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_007f: 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_00b1: 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_00c3: 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_009c: Unknown result type (might be due to invalid IL or missing references) try { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { return Vector3.zero; } CharacterRefs refs = localCharacter.refs; object obj; if (refs == null) { obj = null; } else { Bodypart hip = refs.hip; obj = ((hip != null) ? ((Component)hip).transform : null); } if ((Object)obj != (Object)null) { Vector3 position = ((Component)localCharacter.refs.hip).transform.position; Logger.LogInfo((object)$"✅ Live hip position: {position}"); return position; } Vector3 playerPositionViaReflection = GetPlayerPositionViaReflection(); if (playerPositionViaReflection != Vector3.zero) { return playerPositionViaReflection; } Vector3 center = localCharacter.Center; Logger.LogWarning((object)$"⚠\ufe0f Using Center as last resort: {center}"); return center; } catch (Exception ex) { Logger.LogError((object)("❌ All position methods failed: " + ex.Message)); return Vector3.zero; } } internal static EventResult SpawnRealItem(string itemKey, int quantity = 1, float spawnRadius = 1f) { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: Unknown result type (might be due to invalid IL or missing references) //IL_02df: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: 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_0142: 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_014d: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_0198: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: 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_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_01fc: Unknown result type (might be due to invalid IL or missing references) try { Logger.LogInfo((object)$"\ud83c\udfae SpawnRealItem START: {itemKey} x{quantity}, radius: {spawnRadius}"); if (string.IsNullOrEmpty(itemKey)) { return EventResult.FailureResult("Item key is empty"); } string key = itemKey.ToLowerInvariant(); if (!ItemMap.TryGetValue(key, out var value)) { return EventResult.FailureResult("Unknown item: '" + itemKey + "'"); } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { return EventResult.FailureResult("No local character available"); } Item val = FindItemInDatabase(value); if ((Object)(object)val == (Object)null) { return EventResult.FailureResult("Item prefab not found: " + value); } quantity = Math.Min(quantity, 10); int num = 0; List<Vector3> list = new List<Vector3>(); for (int i = 0; i < quantity; i++) { Vector3 mostAccuratePlayerPosition = GetMostAccuratePlayerPosition(); if (mostAccuratePlayerPosition == Vector3.zero) { Logger.LogError((object)"❌ Could not get valid player position!"); continue; } Logger.LogInfo((object)$"\ud83d\udc64 Fresh player position for item {i + 1}: {mostAccuratePlayerPosition}"); Vector3 val2 = CalculateSpawnPositionFromPlayer(mostAccuratePlayerPosition, spawnRadius, i, quantity); Logger.LogInfo((object)$"\ud83c\udfaf Calculated spawn position {i + 1}: {val2}"); Logger.LogInfo((object)$"\ud83d\udccf Distance from player: {Vector3.Distance(val2, mostAccuratePlayerPosition):F2}m"); GameObject val3 = SpawnOriginalItem(val, val2); if ((Object)(object)val3 != (Object)null) { num++; list.Add(val2); Vector3 position = val3.transform.position; Logger.LogInfo((object)$"✅ Item {i + 1} spawned at: {position}"); Vector3 currentPlayerPosition = GetCurrentPlayerPosition(); float num2 = Vector3.Distance(position, currentPlayerPosition); Logger.LogInfo((object)$"✅ Final distance verification: {num2:F2}m"); } else { Logger.LogError((object)$"❌ Failed to spawn item {i + 1}"); } } Vector3 currentPlayerPosition2 = GetCurrentPlayerPosition(); Logger.LogInfo((object)$"\ud83d\udc64 FINAL verification - player position: {currentPlayerPosition2}"); return EventResult.SuccessResult($"Spawned {num}x real '{itemKey}' items near player", new Dictionary<string, object> { ["item"] = itemKey, ["spawned"] = num, ["positions"] = list, ["method"] = "real_game_items_fixed", ["finalPlayerPosition"] = new { currentPlayerPosition2.x, currentPlayerPosition2.y, currentPlayerPosition2.z } }); } catch (Exception ex) { return EventResult.FromException(ex, "SpawnRealItem"); } } private static GameObject SpawnOriginalItem(Item itemPrefab, Vector3 position) { //IL_000c: 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_0024: 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) try { Logger.LogInfo((object)$"\ud83c\udfae Creating local item at position: {position}"); GameObject val = Object.Instantiate<GameObject>(((Component)itemPrefab).gameObject, position, Quaternion.identity); val.SetActive(true); Item component = val.GetComponent<Item>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = true; } Rigidbody component2 = val.GetComponent<Rigidbody>(); if ((Object)(object)component2 != (Object)null) { component2.isKinematic = false; component2.useGravity = true; component2.constraints = (RigidbodyConstraints)0; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(Random.Range(-0.1f, 0.1f), Random.Range(0.2f, 0.5f), Random.Range(-0.1f, 0.1f)); component2.AddForce(val2, (ForceMode)1); } Collider[] components = val.GetComponents<Collider>(); Collider[] array = components; foreach (Collider val3 in array) { val3.enabled = true; val3.isTrigger = false; } SpawnedItemMarker spawnedItemMarker = val.AddComponent<SpawnedItemMarker>(); spawnedItemMarker.spawnedBy = "PEAKTikTok"; spawnedItemMarker.spawnTime = Time.time; spawnedItemMarker.itemName = ((Object)itemPrefab).name; Logger.LogInfo((object)"✅ Created local item with patch support"); return val; } catch (Exception ex) { Logger.LogError((object)("❌ Failed to create local item: " + ex.Message)); return null; } } private static Vector3 CalculateRealSpawnPosition(Character character, float radius, int index, int total) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: 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) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_004f: 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_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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_0095: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)character).transform.position; Vector3 forward = ((Component)character).transform.forward; Vector3 val = forward * 1f; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(Random.Range(-0.3f, 0.3f), 0.3f, Random.Range(-0.3f, 0.3f)); Vector3 val3 = position + val + val2; Logger.LogInfo((object)$"\ud83c\udfaf Simple spawn for item {index + 1}: {val3} (distance: {Vector3.Distance(val3, position):F2}m)"); return val3; } private static Vector3 GetRealPlayerPosition(Character character) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_005c: 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_006e: Unknown result type (might be due to invalid IL or missing references) try { Vector3 center = character.Center; Logger.LogInfo((object)$"\ud83c\udfaf Center position: {center}"); try { MethodInfo method = ((object)character).GetType().GetMethod("HipPos", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { Vector3 val = (Vector3)method.Invoke(character, null); Logger.LogInfo((object)$"\ud83e\uddb4 Hip position (reflection): {val}"); return val; } } catch (Exception ex) { Logger.LogWarning((object)("⚠\ufe0f Could not get HipPos via reflection: " + ex.Message)); } return center; } catch (Exception ex2) { Logger.LogError((object)("❌ Error getting position: " + ex2.Message)); return ((Component)character).transform.position; } } private static Vector3 CalculateSpawnPosition(Character character, float radius, int index, int total) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_015c: 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_0161: Unknown result type (might be due to invalid IL or missing references) Vector3 position = ((Component)character).transform.position; Logger.LogInfo((object)$"\ud83c\udfaf INPUT: Player at {position}, radius={radius}, item {index + 1}/{total}"); Vector3 val2; if (total == 1) { float num = Random.Range(0f, (float)Math.PI * 2f); float num2 = Random.Range(0.3f, radius); Vector3 val = default(Vector3); ((Vector3)(ref val))..ctor(Mathf.Cos(num) * num2, 0.1f, Mathf.Sin(num) * num2); val2 = position + val; Logger.LogInfo((object)$"\ud83c\udfaf RANDOM SPAWN: angle={num:F2}, radius={num2:F2}, offset={val}"); } else { float num3 = (float)Math.PI * 2f * (float)index / (float)total; Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(Mathf.Cos(num3) * radius, 0.1f, Mathf.Sin(num3) * radius); val2 = position + val3; Logger.LogInfo((object)$"\ud83c\udfaf CIRCLE SPAWN: angle={num3:F2}, offset={val3}"); } Logger.LogInfo((object)$"\ud83c\udfaf FINAL POSITION: {val2}"); Logger.LogInfo((object)$"\ud83c\udfaf Distance from player: {Vector3.Distance(val2, position):F2}m"); return val2; } private static GameObject CreateLocalItem(Item itemPrefab, Vector3 position) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) try { GameObject val = Object.Instantiate<GameObject>(((Component)itemPrefab).gameObject, position, Quaternion.identity); PhotonView[] components = val.GetComponents<PhotonView>(); PhotonView[] array = components; foreach (PhotonView val2 in array) { try { Object.DestroyImmediate((Object)(object)val2); } catch (Exception ex) { Logger.LogWarning((object)("⚠\ufe0f Could not remove PhotonView: " + ex.Message)); } } val.SetActive(true); Item component = val.GetComponent<Item>(); if ((Object)(object)component != (Object)null) { ((Behaviour)component).enabled = true; } Rigidbody component2 = val.GetComponent<Rigidbody>(); if ((Object)(object)component2 != (Object)null) { component2.isKinematic = false; component2.useGravity = true; component2.constraints = (RigidbodyConstraints)0; } Collider[] components2 = val.GetComponents<Collider>(); Collider[] array2 = components2; foreach (Collider val3 in array2) { val3.enabled = true; val3.isTrigger = false; } Logger.LogInfo((object)"✅ Created local item without PhotonView"); return val; } catch (Exception ex2) { Logger.LogError((object)("❌ Failed to create local item: " + ex2.Message)); return null; } } internal static bool GiveItemToPlayer(string itemKey, int quantity = 1) { //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: 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) try { Logger.LogInfo((object)$"\ud83c\udf92 GiveItemToPlayer: {itemKey} x{quantity}"); string key = itemKey.ToLowerInvariant(); if (!ItemMap.TryGetValue(key, out var value)) { Logger.LogError((object)("❌ Невідомий предмет: '" + itemKey + "'")); return false; } Character localCharacter = Character.localCharacter; if ((Object)(object)((localCharacter != null) ? localCharacter.player : null) == (Object)null) { Logger.LogError((object)"❌ Немає персонажа!"); return false; } Item val = FindItemInDatabase(value); if ((Object)(object)val == (Object)null) { return false; } quantity = Math.Min(quantity, 10); int num = 0; int num2 = 0; for (int i = 0; i < quantity; i++) { if (AddItemToSafeSlot(localCharacter.player, (byte)val.itemID)) { num++; Logger.LogInfo((object)$"✅ Додано предмет {i + 1}/{quantity} в інвентар"); continue; } Logger.LogInfo((object)$"\ud83c\udf92 Інвентар повний, спавним предмет {i + 1} біля гравця"); Vector3 mostAccuratePlayerPosition = GetMostAccuratePlayerPosition(); if (mostAccuratePlayerPosition != Vector3.zero) { Vector3 position = CalculateSpawnPositionFromPlayer(mostAccuratePlayerPosition, 1.5f, num2, quantity - num); GameObject val2 = SpawnOriginalItem(val, position); if ((Object)(object)val2 != (Object)null) { num2++; Logger.LogInfo((object)$"✅ Заспавнено предмет {i + 1} біля гравця"); } } } Logger.LogInfo((object)$"\ud83c\udf92 Результат: {num}/{quantity} в інвентарі, {num2}/{quantity} заспавнено"); return num + num2 > 0; } catch (Exception ex) { Logger.LogError((object)("❌ GiveItemToPlayer помилка: " + ex.Message)); return false; } } private static bool AddItemToSafeSlot(Player player, byte itemID) { try { ItemSlot val = default(ItemSlot); for (byte b = 0; b <= 2; b++) { ItemSlot itemSlot = player.GetItemSlot(b); if (itemSlot != null && itemSlot.IsEmpty() && player.AddItem((ushort)itemID, (ItemInstanceData)null, ref val) && val.itemSlotID == b) { Logger.LogInfo((object)$"✅ Додано в звичайний слот {b}"); return true; } } ItemSlot itemSlot2 = player.GetItemSlot((byte)3); ItemSlot val2 = default(ItemSlot); if (itemSlot2 != null && !itemSlot2.IsEmpty() && player.AddItem((ushort)itemID, (ItemInstanceData)null, ref val2)) { if (val2.itemSlotID <= 7) { Logger.LogInfo((object)$"✅ Додано в слот {val2.itemSlotID}"); return true; } Logger.LogWarning((object)$"⚠\ufe0f Предмет потрапив в слот руки ({val2.itemSlotID}), видаляємо"); val2.SetItem((Item)null, (ItemInstanceData)null); return false; } Logger.LogWarning((object)"⚠\ufe0f Немає вільних безпечних слотів"); return false; } catch (Exception ex) { Logger.LogError((object)("❌ AddItemToSafeSlot помилка: " + ex.Message)); return false; } } internal static bool GiveItemToPlayerSafe(string itemKey, int quantity = 1) { try { if (string.IsNullOrEmpty(itemKey)) { Logger.LogWarning((object)"⚠\ufe0f Empty item key"); return false; } if (quantity <= 0 || quantity > 10) { Logger.LogWarning((object)$"⚠\ufe0f Invalid quantity: {quantity}"); return false; } Character localCharacter = Character.localCharacter; if ((Object)(object)((localCharacter != null) ? localCharacter.player : null) == (Object)null) { Logger.LogWarning((object)"⚠\ufe0f No local character available"); return false; } return GiveItemToPlayer(itemKey, quantity); } catch (Exception ex) { Logger.LogError((object)("❌ GiveItemToPlayerSafe error: " + ex.Message)); return false; } } internal static EventResult GiveItemSafe(string itemKey, int quantity = 1) { //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020d: 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_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) try { Logger.LogInfo((object)$"\ud83c\udf92 GiveItemSafe: {itemKey} x{quantity}"); if (string.IsNullOrEmpty(itemKey)) { return EventResult.FailureResult("Item key is empty or null"); } if (quantity <= 0) { return EventResult.FailureResult($"Invalid quantity: {quantity}. Must be greater than 0"); } if (quantity > 10) { return EventResult.FailureResult($"Quantity too large: {quantity}. Maximum is 10"); } string key = itemKey.ToLowerInvariant(); if (!ItemMap.TryGetValue(key, out var value)) { string[] availableItems = GetAvailableItems(); return EventResult.FailureResult("Unknown item: '" + itemKey + "'", new Dictionary<string, object> { ["requestedItem"] = itemKey, ["availableItems"] = availableItems }); } Character localCharacter = Character.localCharacter; if ((Object)(object)((localCharacter != null) ? localCharacter.player : null) == (Object)null) { return EventResult.FailureResult("No local character or player available"); } Item val = FindItemInDatabase(value); if ((Object)(object)val == (Object)null) { return EventResult.FailureResult("Item prefab not found in database: " + value); } quantity = Math.Min(quantity, 10); int num = 0; int num2 = 0; List<byte> list = new List<byte>(); List<Vector3> list2 = new List<Vector3>(); for (int i = 0; i < quantity; i++) { if (AddItemToSafeSlotWithSlotInfo(localCharacter.player, (byte)val.itemID, out var slotIndex)) { num++; list.Add(slotIndex); Logger.LogInfo((object)$"✅ Added to inventory slot {slotIndex}"); continue; } Logger.LogInfo((object)$"\ud83c\udf92 Inventory full, spawning item {i + 1} near player"); Vector3 mostAccuratePlayerPosition = GetMostAccuratePlayerPosition(); if (mostAccuratePlayerPosition != Vector3.zero) { Vector3 val2 = CalculateSpawnPositionFromPlayer(mostAccuratePlayerPosition, 1.5f, num2, quantity - num); GameObject val3 = SpawnOriginalItem(val, val2); if ((Object)(object)val3 != (Object)null) { num2++; list2.Add(val2); Logger.LogInfo((object)$"✅ Spawned item {i + 1} near player at {val2}"); } else { Logger.LogError((object)$"❌ Failed to spawn item {i + 1} near player"); } } else { Logger.LogError((object)$"❌ Could not get player position for spawning item {i + 1}"); } } int num3 = num + num2; if (num3 <= 0) { return EventResult.FailureResult("Could not add items to inventory or spawn near player"); } string message = ((num > 0 && num2 > 0) ? $"Added {num}x '{itemKey}' to inventory and spawned {num2}x near player" : ((num <= 0) ? $"Inventory full! Spawned {num2}x '{itemKey}' near player" : $"Successfully added {num}x '{itemKey}' to inventory")); return EventResult.SuccessResult(message, new Dictionary<string, object> { ["item"] = itemKey, ["requested"] = quantity, ["addedToInventory"] = num, ["spawnedNearPlayer"] = num2, ["totalProcessed"] = num3, ["safeSlots"] = list.ToArray(), ["spawnedPositions"] = list2, ["prefabName"] = value, ["method"] = "inventory_with_fallback_spawn" }); } catch (Exception ex) { return EventResult.FromException(ex, "GiveItemSafe"); } } private static bool AddItemToSafeSlotWithSlotInfo(Player player, byte itemID, out byte slotIndex) { slotIndex = byte.MaxValue; try { ItemSlot val = default(ItemSlot); for (byte b = 0; b <= 2; b++) { ItemSlot itemSlot = player.GetItemSlot(b); if (itemSlot != null && itemSlot.IsEmpty() && player.AddItem((ushort)itemID, (ItemInstanceData)null, ref val) && val.itemSlotID == b) { slotIndex = b; Logger.LogInfo((object)$"✅ Додано в звичайний слот {b}"); return true; } } ItemSlot itemSlot2 = player.GetItemSlot((byte)3); if (itemSlot2 != null && !itemSlot2.IsEmpty()) { ItemSlot val2 = default(ItemSlot); for (byte b2 = 4; b2 <= 7; b2++) { try { ItemSlot itemSlot3 = player.GetItemSlot(b2); if (itemSlot3 != null && itemSlot3.IsEmpty() && player.AddItem((ushort)itemID, (ItemInstanceData)null, ref val2)) { if (val2.itemSlotID == b2 && b2 <= 7) { slotIndex = b2; Logger.LogInfo((object)$"✅ Додано в слот рюкзака {b2}"); return true; } val2.SetItem((Item)null, (ItemInstanceData)null); Logger.LogWarning((object)$"⚠\ufe0f Предмет потрапив не в той слот ({val2.itemSlotID} замість {b2})"); } } catch (Exception ex) { Logger.LogDebug((object)$"Слот {b2} недоступний: {ex.Message}"); } } } Logger.LogWarning((object)"⚠\ufe0f Немає вільних безпечних слотів"); return false; } catch (Exception ex2) { Logger.LogError((object)("❌ AddItemToSafeSlotWithSlotInfo помилка: " + ex2.Message)); return false; } } internal static EventResult GetItemInfo(string itemKey) { try { if (string.IsNullOrEmpty(itemKey)) { return EventResult.FailureResult("Item key is empty"); } string key = itemKey.ToLowerInvariant(); if (!ItemMap.TryGetValue(key, out var value)) { return EventResult.FailureResult("Unknown item: '" + itemKey + "'"); } Item val = FindItemInDatabase(value); if ((Object)(object)val == (Object)null) { return EventResult.FailureResult("Item prefab not found: " + value); } return EventResult.SuccessResult("Item info for '" + itemKey + "'", new Dictionary<string, object> { ["itemKey"] = itemKey, ["prefabName"] = value, ["itemID"] = val.itemID, ["displayName"] = ((Object)val).name, ["exists"] = true }); } catch (Exception ex) { return EventResult.FromException(ex, "GetItemInfo"); } } internal static EventResult GetInventoryInfo() { try { Character localCharacter = Character.localCharacter; if ((Object)(object)((localCharacter != null) ? localCharacter.player : null) == (Object)null) { return EventResult.FailureResult("No local character available"); } Player player = localCharacter.player; object field = player.GetField<object>("inventory"); if (field == null) { return EventResult.FailureResult("Could not access inventory"); } return EventResult.SuccessResult("Inventory info retrieved", new Dictionary<string, object> { ["hasCharacter"] = true, ["hasPlayer"] = true, ["hasInventory"] = field != null }); } catch (Exception ex) { return EventResult.FromException(ex, "GetInventoryInfo"); } } internal static string[] GetAvailableItems() { string[] array = new string[ItemMap.Count]; ItemMap.Keys.CopyTo(array, 0); return array; } internal static bool ItemExists(string itemKey) { return ItemMap.ContainsKey(itemKey.ToLowerInvariant()); } internal static void CleanupCooldowns() { List<string> list = new List<string>(); float time = Time.time; foreach (KeyValuePair<string, float> itemCooldown in itemCooldowns) { if (time - itemCooldown.Value > 60f) { list.Add(itemCooldown.Key); } } foreach (string item in list) { itemCooldowns.Remove(item); } } internal static EventResult CleanupCooldownsSafe() { try { int count = itemCooldowns.Count; CleanupCooldowns(); int count2 = itemCooldowns.Count; int num = count - count2; return EventResult.SuccessResult("Cleanup completed", new Dictionary<string, object> { ["initialCount"] = count, ["finalCount"] = count2, ["removed"] = num }); } catch (Exception ex) { return EventResult.FromException(ex, "CleanupCooldowns"); } } } internal class MainThreadDispatcher : MonoBehaviour { private static MainThreadDispatcher _instance; private readonly Queue<Action> _executionQueue = new Queue<Action>(); private static ManualLogSource Logger = Logger.CreateLogSource("MainThreadDispatcher"); internal static MainThreadDispatcher Instance { get { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown if ((Object)(object)_instance == (Object)null) { GameObject val = new GameObject("MainThreadDispatcher"); _instance = val.AddComponent<MainThreadDispatcher>(); Object.DontDestroyOnLoad((Object)(object)val); Logger.LogInfo((object)"✅ MainThreadDispatcher created"); } return _instance; } } internal static void Enqueue(Action action) { if (action != null) { Instance.EnqueueInternal(action); } } internal static void Enqueue(Action action, Action<Exception> onError) { if (action == null) { return; } Instance.EnqueueInternal(delegate { try { action(); } catch (Exception ex) { Logger.LogError((object)("❌ MainThread execution error: " + ex.Message)); onError?.Invoke(ex); } }); } private void EnqueueInternal(Action action) { lock (_executionQueue) { _executionQueue.Enqueue(action); } } private void Update() { lock (_executionQueue) { while (_executionQueue.Count > 0) { try { _executionQueue.Dequeue()(); } catch (Exception ex) { Logger.LogError((object)("❌ MainThread action error: " + ex.Message)); } } } } private void OnDestroy() { lock (_executionQueue) { _executionQueue.Clear(); } _instance = null; Logger.LogInfo((object)"\ud83d\uddd1\ufe0f MainThreadDispatcher destroyed"); } } public class ModLauncher : MonoBehaviour { private static ManualLogSource Logger = Logger.CreateLogSource("ModLauncher"); private GameObject modCore; public void Start() { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Expected O, but got Unknown try { Logger.LogInfo((object)"\ud83d\ude80 ModLauncher starting..."); modCore = new GameObject("ModCore"); modCore.AddComponent<PEAKTikTok>(); Object.DontDestroyOnLoad((Object)(object)modCore); Logger.LogInfo((object)"✅ Mod core initialized"); } catch (Exception ex) { Logger.LogError((object)("❌ ModLauncher failed: " + ex.Message)); } } public void OnDestroy() { if ((Object)(object)modCore != (Object)null) { Object.Destroy((Object)(object)modCore); } } } internal class PEAKTikTok : MonoBehaviour { private static ManualLogSource Logger = Logger.CreateLogSource("PEAKTikTok"); internal static PEAKTikTok Instance { get; private set; } private void Start() { Instance = this; Logger.LogInfo((object)"\ud83d\udce2 PEAK TikTok Mod loading..."); try { MainThreadDispatcher instance = MainThreadDispatcher.Instance; Logger.LogInfo((object)"✅ MainThreadDispatcher initialized"); ((Component)this).gameObject.AddComponent<HttpServer>(); Logger.LogInfo((object)"✅ HTTP Server component added"); ((MonoBehaviour)this).InvokeRepeating("CleanupCooldowns", 60f, 60f); Logger.LogInfo((object)"✅ Cooldown cleanup scheduled"); Logger.LogInfo((object)"\ud83c\udf89 PEAK TikTok Mod loaded successfully!"); } catch (Exception ex) { Logger.LogError((object)("❌ Failed to initialize PEAK TikTok Mod: " + ex.Message)); Logger.LogError((object)("Stack trace: " + ex.StackTrace)); } } private void Update() { PlayerReviveController.TrackDeathPosition(); } private void CleanupCooldowns() { try { EventResult eventResult = ItemSpawner.CleanupCooldownsSafe(); if (eventResult.Success) { Logger.LogInfo((object)("\ud83e\uddf9 " + eventResult.Message)); } else { Logger.LogWarning((object)("⚠\ufe0f Cleanup warning: " + eventResult.Message)); } } catch (Exception ex) { Logger.LogError((object)("❌ Cleanup error: " + ex.Message)); } } private void OnDestroy() { Logger.LogInfo((object)"\ud83d\uddd1\ufe0f PEAKTikTok destroyed"); } private void OnApplicationQuit() { Logger.LogInfo((object)"\ud83d\udeaa Application quitting - PEAKTikTok cleanup"); } } internal static class PlayerGravityController { private static ManualLogSource Logger = Logger.CreateLogSource("PlayerGravityController"); private static bool _active = false; private static float _originalJumpGravity = 10f; private static float _originalMaxGravity = -20f; private static float _originalJumpImpulse = 1f; private static float _originalBalloonFloatMultiplier = 1f; private static float _originalBalloonJumpMultiplier = 1f; internal static bool IsActive => _active; internal static EventResult ApplyGravityEffect(string gravityType, float duration = 30f) { try { if (_active) { ResetGravity(); } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || localCharacter.data.dead || localCharacter.data.fullyPassedOut) { return EventResult.FailureResult("Character not available for gravity effect"); } CharacterMovement component = ((Component)localCharacter).GetComponent<CharacterMovement>(); if ((Object)(object)component == (Object)null) { return EventResult.FailureResult("CharacterMovement component not found"); } if (!_active) { SaveOriginalValues(component); } _active = true; switch (gravityType.ToLowerInvariant()) { case "floaty": component.jumpGravity = 3f; component.maxGravity = -5f; component.balloonFloatMultiplier = 0.3f; component.balloonJumpMultiplier = 1.5f; Logger.LogInfo((object)"\ud83c\udf88 Applied floaty gravity effect"); break; case "heavy": component.jumpGravity = 25f; component.maxGravity = -100f; component.balloonFloatMultiplier = 3f; component.balloonJumpMultiplier = 0.5f; Logger.LogInfo((object)"\ud83e\udea8 Applied heavy gravity effect"); break; case "zero": component.jumpGravity = 0.1f; component.maxGravity = -0.1f; component.balloonFloatMultiplier = 0.01f; component.balloonJumpMultiplier = 3f; Logger.LogInfo((object)"\ud83d\ude80 Applied zero gravity effect"); break; case "reverse": component.jumpGravity = -8f; component.maxGravity = 15f; component.balloonFloatMultiplier = -2f; component.balloonJumpMultiplier = 2f; Logger.LogInfo((object)"\ud83d\udd04 Applied reverse gravity effect"); break; case "superjump": component.jumpGravity = _originalJumpGravity; component.maxGravity = -40f; component.jumpImpulse = _originalJumpImpulse * 2.5f; component.balloonJumpMultiplier = 3f; Logger.LogInfo((object)"\ud83e\udd98 Applied super jump effect"); break; case "moonjump": component.jumpGravity = 4f; component.maxGravity = -8f; component.jumpImpulse = _originalJumpImpulse * 1.8f; component.balloonFloatMultiplier = 0.4f; component.balloonJumpMultiplier = 2f; Logger.LogInfo((object)"\ud83c\udf19 Applied moon jump effect"); break; default: _active = false; return EventResult.FailureResult("Unknown gravity type: " + gravityType + ". Available: floaty, heavy, zero, reverse, superjump, moonjump"); } Task.Run(() => ResetGravityAfterDelay(duration)).Forget(); return EventResult.SuccessResult($"Gravity effect '{gravityType}' applied for {duration} seconds", new Dictionary<string, object> { ["gravityType"] = gravityType, ["duration"] = duration, ["jumpGravity"] = component.jumpGravity, ["maxGravity"] = component.maxGravity, ["balloonFloatMultiplier"] = component.balloonFloatMultiplier, ["balloonJumpMultiplier"] = component.balloonJumpMultiplier }); } catch (Exception ex) { _active = false; return EventResult.FromException(ex, "ApplyGravityEffect"); } } private static void SaveOriginalValues(CharacterMovement movement) { try { _originalJumpGravity = movement.jumpGravity; _originalMaxGravity = movement.maxGravity; _originalJumpImpulse = movement.jumpImpulse; _originalBalloonFloatMultiplier = movement.balloonFloatMultiplier; _originalBalloonJumpMultiplier = movement.balloonJumpMultiplier; Logger.LogInfo((object)$"\ud83d\udcbe Saved original values: jumpGravity={_originalJumpGravity}, maxGravity={_originalMaxGravity}, jumpImpulse={_originalJumpImpulse}"); Logger.LogInfo((object)$"\ud83d\udcbe Balloon multipliers: float={_originalBalloonFloatMultiplier}, jump={_originalBalloonJumpMultiplier}"); } catch (Exception ex) { Logger.LogError((object)("❌ Error saving original values: " + ex.Message)); _originalJumpGravity = 10f; _originalMaxGravity = -20f; _originalJumpImpulse = 7f; _originalBalloonFloatMultiplier = 1f; _originalBalloonJumpMultiplier = 1f; } } internal static EventResult ResetGravity() { try { if (!_active) { return EventResult.FailureResult("No gravity effect is currently active"); } Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { _active = false; return EventResult.FailureResult("Character not available"); } CharacterMovement component = ((Component)localCharacter).GetComponent<CharacterMovement>(); if ((Object)(object)component == (Object)null) { _active = false; return EventResult.FailureResult("CharacterMovement component not found"); } RestoreOriginalValues(component); _active = false; Logger.LogInfo((object)"\ud83d\udd04 Gravity effect reset to normal"); return EventResult.SuccessResult("Gravity effect reset to normal", new Dictionary<string, object> { ["jumpGravity"] = component.jumpGravity, ["maxGravity"] = component.maxGravity, ["jumpImpulse"] = component.jumpImpulse, ["balloonFloatMultiplier"] = component.balloonFloatMultiplier, ["balloonJumpMultiplier"] = component.balloonJumpMultiplier }); } catch (Exception ex) { _active = false; return EventResult.FromException(ex, "ResetGravity"); } } private static void RestoreOriginalValues(CharacterMovement movement) { try { movement.jumpGravity = _originalJumpGravity; movement.maxGravity = _originalMaxGravity; movement.jumpImpulse = _originalJumpImpulse; movement.balloonFloatMultiplier = _originalBalloonFloatMultiplier; movement.balloonJumpMultiplier = _originalBalloonJumpMultiplier; Logger.LogInfo((object)$"\ud83d\udd04 Restored original values: jumpGravity={_originalJumpGravity}, maxGravity={_originalMaxGravity}"); } catch (Exception ex) { Logger.LogError((object)("❌ Error restoring original values: " + ex.Message)); } } private static async Task ResetGravityAfterDelay(float duration) { try { await Task.Delay(TimeSpan.FromSeconds(duration)); MainThreadDispatcher.Enqueue(delegate { if (_active) { EventResult eventResult = ResetGravity(); if (eventResult.Success) { Logger.LogInfo((object)"⏰ Gravity effect automatically reset after duration"); } else { Logger.LogWarning((object)("⚠\ufe0f Auto reset failed: " + eventResult.Message)); _active = false; } } }); } catch (Exception ex2) { Exception ex = ex2; Logger.LogError((object)("❌ Error in ResetGravityAfterDelay: " + ex.Message)); MainThreadDispatcher.Enqueue(delegate { _active = false; }); } } internal static EventResult GetGravityStatus() { try { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null) { return EventResult.FailureResult("No local character"); } CharacterMovement component = ((Component)localCharacter).GetComponent<CharacterMovement>(); if ((Object)(object)component == (Object)null) { return EventResult.FailureResult("No CharacterMovement component"); } return EventResult.SuccessResult("Gravity status retrieved", new Dictionary<string, object> { ["isActive"] = _active, ["currentJumpGravity"] = component.jumpGravity, ["currentMaxGravity"] = component.maxGravity, ["currentJumpImpulse"] = component.jumpImpulse, ["currentBalloonFloatMultiplier"] = component.balloonFloatMultiplier, ["currentBalloonJumpMultiplier"] = component.balloonJumpMultiplier, ["originalJumpGravity"] = _originalJumpGravity, ["originalMaxGravity"] = _originalMaxGravity, ["originalJumpImpulse"] = _originalJumpImpulse, ["originalBalloonFloatMultiplier"] = _originalBalloonFloatMultiplier, ["originalBalloonJumpMultiplier"] = _originalBalloonJumpMultiplier }); } catch (Exception ex) { return EventResult.FromException(ex, "GetGravityStatus"); } } internal static string[] GetAvailableGravityEffects() { return new string[6] { "floaty", "heavy", "zero", "reverse", "superjump", "moonjump" }; } } internal static class PlayerInventoryController { private static ManualLogSource Logger = Logger.CreateLogSource("PlayerInventoryController"); internal static EventResult DropAllItems(bool includeBackpack = true) { try { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter?.refs?.items == (Object)null) { return EventResult.FailureResult("Local character or items not found"); } Logger.LogInfo((object)$"\ud83c\udf92 Dropping all items from inventory (includeBackpack: {includeBackpack})"); CharacterItems items = localCharacter.refs.items; MethodInfo method = ((object)items).GetType().GetMethod("DropAllItems", BindingFlags.Instance | BindingFlags.NonPublic); if (method != null) { method.Invoke(items, new object[1] { includeBackpack }); Logger.LogInfo((object)"\ud83c\udf92 Successfully dropped all items"); return EventResult.SuccessResult("Dropped all items from inventory", new Dictionary<string, object> { ["includeBackpack"] = includeBackpack, ["method"] = "DropAllItems" }); } Logger.LogError((object)"❌ DropAllItems method not found"); return EventResult.FailureResult("DropAllItems method not found"); } catch (Exception ex) { return EventResult.FromException(ex, "DropAllItems"); } } internal static EventResult DropHandItem() { //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Expected O, but got Unknown //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) try { Character localCharacter = Character.localCharacter; if ((Object)(object)localCharacter == (Object)null || (Object)(object)localCharacter.refs?.items == (Object)null) { return EventResult.FailureResult("Local character not found"); } Logger.LogInfo((object)"\ud83e\udd32 Attempting to drop item from hand"); if (!localCharacter.refs.items.currentSelectedSlot.IsSome) { return EventResult.FailureResult("No item equipped in hand"); } byte value = localCharacter.refs.items.currentSelectedSlot.Value; ItemSlot itemSlot = localCharacter.player.GetItemSlot(value); if (itemSlot == null || itemSlot.IsEmpty()) { return EventResult.FailureResult("No item in current slot"); } string itemName = itemSlot.prefab.GetItemName((ItemInstanceData)null); if (!itemSlot.prefab.UIData.canDrop) { return EventResult.FailureResult("Item '" + itemName + "' cannot be dropped"); } Bodypart hip = localCharacter.refs.hip; if ((Object)(object)((hip != null) ? ((Component)hip).transform : null) == (Object)null) { return EventResult.FailureResult("Could not get hip transform"); } Vector3 val = ((Component)hip).transform.position + ((Component)hip).transform.forward * 0.8f + Vector3.up * 0.5f; FieldInfo field = ((object)localCharacter.refs.items).GetType().GetField("photonView", BindingFlags.Instance | BindingFlags.NonPublic); if (field != null) { PhotonView val2 = (PhotonView)field.GetValue(localCharacter.refs.items); if ((Object)(object)val2 != (Object)null) { localCharacter.refs.items.EquipSlot(Optionable<byte>.None); val2.RPC("DropItemFromSlotRPC", (RpcTarget)0, new object[2] { value, val }); Logger.LogInfo((object)("\ud83e\udd32 Dropped item from hand: " + itemName)); return EventResult.SuccessResult("Dropped item from hand: " + itemName, new Dictionary<string, object> { ["itemName"] = itemName, ["slotIndex"] = value, ["dropPosition"] = new { val.x, val.y, val.z } }); } } return EventResult.FailureResult("Failed to access PhotonView for RPC call"); } catch (Exception ex) { return EventResult.FromException(ex, "DropHandItem"); } } internal static EventResult DropItemFromSlot(byte slotIndex) { //IL_0402: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_0416: Unknown result type (might be due to invalid IL or missing references) //IL_041b: Unknown result type (might be due to invalid IL or missing references) //IL_0425: Unknown result type (might be due to invalid IL or missing references) //IL_042a: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Expected O, but got Unknown //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03cd: Unknown result type (might be due to invalid IL or missing references) //IL_03d2: Unknown result type (might be due to invalid IL or missing references) //IL_03d7: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_035e: Unknown result type (might be due to invalid IL or missing references) //IL_0368: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_037c: Unknown result type (might be due to invalid IL or missing references) //IL_0381: Unknown result type (might be due to invalid IL or missing references) //IL_0386: Unknown result type (might be due to invalid IL or missing references) //IL_050a: Unknown result type (might be due to invalid IL or missing references) //IL_0581: Unknown result type (might be due to invalid IL or missing references) //IL_0588: Unknown result type (might be due to invalid IL or missing references) //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_04d5: Unknown result type (might be due to invalid IL or missing references) try { Character localCharacter = Character.localCharacter; if ((Object)(object)((localCharacter != null) ? localCharacter.player : null) == (Object)null) { return EventResult.FailureResult("Local character or player not found"); } Logger.LogInfo((object)$"\ud83c\udfaf Attempting to drop item from slot {slotIndex}"); if (slotIndex > 3) { return EventResult.FailureResult($"Invalid slot index: {slotIndex}. Valid range is 0-3."); } ItemSlot val = null; try { val = localCharacter.player.GetItemSlot(slotIndex); } catch (Exception ex) { Logger.LogError((object)$"❌ Error accessing slot {slotIndex}: {ex.Message}"); return EventResult.FailureResult($"Cannot access slot {slotIndex}: {ex.Message}"); } if (val == null) { return EventResult.FailureResult($"Slot {slotIndex} is null or does not exist"); } if (val.IsEmpty()) { return EventResult.FailureResult($"No item in slot {slotIndex}"); } string text = "Unknown Item"; byte b = 0; try { if ((Object)(object)val.prefab != (Object)null) { text = val.prefab.GetItemName((ItemInstanceData)null); b = (byte)val.prefab.itemID; Logger.LogInfo((object)$"\ud83c\udf92 Item found in slot {slotIndex}: {text} (ID: {b})"); } else { try { object field = val.GetField<object>("data"); if (field != null) { b = field.GetField("itemID", (byte)0); text = $"Item_ID_{b}"; Logger.LogInfo((object)$"\ud83d\udd27 Got item via reflection: {text} (ID: {b})"); } else { text = $"Slot_{slotIndex}_Item"; b = 1; Logger.LogWarning((object)$"⚠\ufe0f Using fallback for slot {slotIndex}"); } } catch (Exception ex2) { Logger.LogWarning((object)("⚠\ufe0f Reflection failed: " + ex2.Message)); text = $"Slot_{slotIndex}_Item"; b = 1; } } } catch (Exception ex3) { Logger.LogWarning((object)("⚠\ufe0f Could not get item info: " + ex3.Message)); text = $"Slot_{slotIndex}_Item"; b = 1; } bool flag = true; try { if (val.prefab?.UIData != null) { flag = val.prefab.UIData.canDrop; } else { flag = true; Logger.LogInfo((object)$"✅ Allowing drop for slot {slotIndex} (no UIData check)"); } } catch (Exception ex4) { Logger.LogWarning((object)("⚠\ufe0f Could not check canDrop: " + ex4.Message)); flag = true; } if (!flag) { return EventResult.FailureResult("Item '" + text + "' cannot be dropped"); } Vector3 val2; try { Bodypart hip = localCharacter.refs.hip; if ((Object)(object)((hip != null) ? ((Component)hip).transform : null) == (Object)null) { val2 = ((Component)localCharacter).transform.position + ((Component)localCharacter).transform.forward * 0.6f + Vector3.up * 0.5f; Logger.LogWarning((object)"⚠\ufe0f Using fallback position - hip transform not found"); } else { val2 = ((Component)hip).transform.position + ((Component)hip).transform.forward * 0.6f + Vector3.up * 0.5f; } } catch (Exception ex5) { Logger.LogWarning((object)("⚠\ufe0f Error getting hip position: " + ex5.Message)); val2 = ((Component)localCharacter).transform.position + Vector3.forward * 0.6f + Vector3.up * 0.5f; } try { FieldInfo field2 = ((object)localCharacter.refs.items).GetType().GetField("photonView", BindingFlags.Instance | BindingFlags.NonPublic); if (field2 != null) { PhotonView val3 = (PhotonView)field2.GetValue(localCharacter.refs.items); if ((Object)(object)val3 != (Object)null) { if (localCharacter.refs.items.currentSelectedSlot.IsSome && localCharacter.refs.items.currentSelectedSlot.Value == slotIndex) { localCharacter.refs.items.EquipSlot(Optionable<byte>.None); Logger.LogInfo((object)"\ud83d\udd13 Unequipped item from hand before dropping"); } val3.RPC("DropItemFromSlotRPC", (RpcTarget)0, new object[2] { slotIndex, val2 }); Logger.LogInfo((object)$"\ud83c\udfaf Dropped item from slot {slotIndex}: {text}"); return EventResult.SuccessResult($"Dropped item from slot {slotIndex}: {text}", new Dictionary<string, object> { ["itemName"] = text, ["slotIndex"] = slotIndex, ["itemID"] = b, ["dropPosition"] = new { val2.x, val2.y, val2.z } }); } return EventResult.FailureResult("PhotonView is null"); } return EventResult.FailureResult("Could not access photonView field"); } catch (Exception ex6) { Logger.LogError((object)("❌ Error in PhotonView RPC: " + ex6.Message)); return EventResult.FailureResult("Failed to drop item via RPC: " + ex6.Message); } } catch (Exception ex7) { return EventResult.FromException(ex7, "DropItemFromSlot"); } }