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 PeakChatOps v1.2.3
plugins/com.github.LIghtJUNction.PeakChatOps.dll
Decompiled 2 weeks 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.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Net.Http; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Threading; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Cysharp.Threading.Tasks; using Cysharp.Threading.Tasks.CompilerServices; using ExitGames.Client.Photon; using HarmonyLib; using HarmonyLib.Tools; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using PEAKLib.Core; using PeakChatOps.API; using PeakChatOps.API.AI; using PeakChatOps.API.AI.Apis; using PeakChatOps.Commands; using PeakChatOps.Core; using PeakChatOps.Core.MsgChain; using PeakChatOps.Core.MsgChain.Handle; using PeakChatOps.Patches; using PeakChatOps.UI; using PeakChatOps.core; using Photon.Pun; using Photon.Realtime; using Steamworks; using TMPro; using UnityEngine; using UnityEngine.SceneManagement; using UnityEngine.TextCore; using UnityEngine.UIElements; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("com.github.LIghtJUNction.PeakChatOps")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.2.3.0")] [assembly: AssemblyInformationalVersion("1.2.3+5b6d2c4367f20c4671fd5319b09ae8adc15d761e")] [assembly: AssemblyProduct("com.github.LIghtJUNction.PeakChatOps")] [assembly: AssemblyTitle("PeakChatOps")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.2.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace PeakChatOps { public class PConfig { private static readonly string ApiKeyFolder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "PeakChatOps"); private static readonly string ApiKeyFilePath = Path.Combine(ApiKeyFolder, "api_keys.dat"); private static readonly Dictionary<string, string> _keyCache = new Dictionary<string, string>(); public ConfigEntry<KeyCode> Key; public ConfigEntry<UIAlignment> Pos; public ConfigEntry<string> CmdPrefix; public ConfigEntry<string> DeathMessage; public ConfigEntry<string> ReviveMessage; public ConfigEntry<string> PassOutMessage; public ConfigEntry<string> AiModel; public ConfigEntry<string> AiApiKey; public ConfigEntry<string> AiEndpoint; public ConfigEntry<int> AiContextMaxCount; public ConfigEntry<bool> AiAutoTranslate; public ConfigEntry<string> PromptTranslate; public ConfigEntry<string> PromptSend; public ConfigEntry<int> AiMaxTokens; public ConfigEntry<float> AiTemperature; public ConfigEntry<float> AiTopP; public ConfigEntry<int> AiN; public ConfigEntry<bool> AiShowResponse; public PConfig(ConfigFile config) { Key = config.Bind<KeyCode>("Display", "ChatKey", (KeyCode)121, PLocalizedText.GetText("CHAT_KEY_DESCRIPTION")); Pos = config.Bind<UIAlignment>("Display", "ChatPosition", UIAlignment.TopLeft, PLocalizedText.GetText("CHAT_POSITION_DESCRIPTION")); CmdPrefix = config.Bind<string>("Commands", "CommandPrefix", "/", PLocalizedText.GetText("COMMAND_PREFIX_DESCRIPTION")); DeathMessage = config.Bind<string>("preset", "DeathMessage", PLocalizedText.GetText("DEATH_MESSAGE"), PLocalizedText.GetText("DEATH_MESSAGE_DESCRIPTION")); ReviveMessage = config.Bind<string>("preset", "ReviveMessage", PLocalizedText.GetText("REVIVE_MESSAGE"), PLocalizedText.GetText("REVIVE_MESSAGE_DESCRIPTION")); PassOutMessage = config.Bind<string>("preset", "PassOutMessage", PLocalizedText.GetText("PASS_OUT_MESSAGE"), PLocalizedText.GetText("PASS_OUT_MESSAGE_DESCRIPTION")); AiModel = config.Bind<string>("AI", "Model", "gpt-oss:120b-cloud", PLocalizedText.GetText("AI_MODEL_DESCRIPTION")); string text = LoadApiKeyFromFile(); AiApiKey = config.Bind<string>("AI", "ApiKey", text, PLocalizedText.GetText("AI_APIKEY_DESCRIPTION")); AiApiKey.SettingChanged += delegate { SaveApiKeyToFile(AiApiKey.Value); }; AiEndpoint = config.Bind<string>("AI", "Endpoint", "http://localhost:11434/v1", PLocalizedText.GetText("AI_ENDPOINT_DESCRIPTION")); AiContextMaxCount = config.Bind<int>("AI", "ContextMaxCount", 30, PLocalizedText.GetText("AI_CONTEXT_MAX_COUNT_DESCRIPTION")); AiShowResponse = config.Bind<bool>("AI", "ShowResponse", true, PLocalizedText.GetText("AI_SHOW_RESPONSE_DESCRIPTION")); AiAutoTranslate = config.Bind<bool>("AI", "AutoTranslate", false, PLocalizedText.GetText("AI_AUTOTRANSLATE_DESCRIPTION")); PromptTranslate = config.Bind<string>("prompt", "Prompt_Translate", PLocalizedText.GetText("TRANSLATE_PROMPT"), PLocalizedText.GetText("PROMPT_TRANSLATE_DESCRIPTION")); PromptSend = config.Bind<string>("prompt", "Prompt_Send", PLocalizedText.GetText("PROMPT_SEND"), PLocalizedText.GetText("PROMPT_SEND_DESCRIPTION")); } private static string ComputeHash(string input) { if (string.IsNullOrEmpty(input)) { return string.Empty; } using SHA256 sHA = SHA256.Create(); byte[] array = sHA.ComputeHash(Encoding.UTF8.GetBytes(input)); return BitConverter.ToString(array).Replace("-", "").Substring(0, 16); } private static void LoadApiKeysFromFile() { _keyCache.Clear(); try { if (!File.Exists(ApiKeyFilePath)) { return; } string[] array = File.ReadAllLines(ApiKeyFilePath); string[] array2 = array; foreach (string text in array2) { string[] array3 = text.Split(new char[1] { '=' }, 2); if (array3.Length == 2) { string key = array3[0].Trim(); string value = array3[1].Trim(); _keyCache[key] = value; } } Debug.Log((object)$"[PeakChatOps] Loaded {_keyCache.Count} API key(s) from: {ApiKeyFilePath}"); } catch (Exception ex) { Debug.LogWarning((object)("[PeakChatOps] Failed to load API keys from file: " + ex.Message)); } } private static string LoadApiKeyFromFile() { LoadApiKeysFromFile(); if (_keyCache.Count > 0) { string input = _keyCache.Values.First(); string text = ComputeHash(input); Debug.Log((object)("[PeakChatOps] Using API Key with hash: " + text)); return text; } return "ollama"; } private static void SaveApiKeyToFile(string input) { try { if (IsHashValue(input)) { Debug.Log((object)("[PeakChatOps] Input is already a hash: " + input)); return; } string text = ComputeHash(input); _keyCache[text] = input; if (!Directory.Exists(ApiKeyFolder)) { Directory.CreateDirectory(ApiKeyFolder); } IEnumerable<string> contents = _keyCache.Select((KeyValuePair<string, string> kvp) => kvp.Key + "=" + kvp.Value); File.WriteAllLines(ApiKeyFilePath, contents); Debug.Log((object)("[PeakChatOps] API Key saved with hash: " + text + " -> " + ApiKeyFilePath)); if (PeakChatOpsPlugin.config != null && PeakChatOpsPlugin.config.AiApiKey != null && PeakChatOpsPlugin.config.AiApiKey.Value != text) { PeakChatOpsPlugin.config.AiApiKey.Value = text; } } catch (Exception ex) { Debug.LogError((object)("[PeakChatOps] Failed to save API Key: " + ex.Message)); } } private static bool IsHashValue(string input) { if (string.IsNullOrEmpty(input) || input.Length != 16) { return false; } return input.All((char c) => (c >= '0' && c <= '9') || (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')); } public static string GetActualApiKey(string hashOrKey) { if (string.IsNullOrEmpty(hashOrKey)) { return "ollama"; } if (IsHashValue(hashOrKey) && _keyCache.ContainsKey(hashOrKey)) { return _keyCache[hashOrKey]; } return hashOrKey; } } public enum UIAlignment { TopLeft, TopRight, Center } [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("com.github.LIghtJUNction.PeakChatOps", "PeakChatOps", "1.2.3")] internal class PeakChatOpsPlugin : BaseUnityPlugin { public static readonly string PluginPath = Path.Combine(Paths.PluginPath, "PeakChatOps"); internal static ManualLogSource Logger = null; private Harmony _harmony; public static PConfig config = null; public static GameObject PeakChatOpsUIPrefab = null; private static TMP_FontAsset? _darumaFontAsset; public const string Id = "com.github.LIghtJUNction.PeakChatOps"; public static PeakChatOpsPlugin Instance { get; private set; } = null; public static TMP_FontAsset? DarumaDropOneFont { get { if ((Object)(object)_darumaFontAsset == (Object)null) { TMP_FontAsset[] source = Resources.FindObjectsOfTypeAll<TMP_FontAsset>(); _darumaFontAsset = ((IEnumerable<TMP_FontAsset>)source).FirstOrDefault((Func<TMP_FontAsset, bool>)delegate(TMP_FontAsset fontAsset) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) FaceInfo faceInfo = ((TMP_Asset)fontAsset).faceInfo; return ((FaceInfo)(ref faceInfo)).familyName == "Daruma Drop One"; }); } return _darumaFontAsset; } } public static string Name => "PeakChatOps"; public static string Version => "1.2.3"; private void Awake() { //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown Logger = ((BaseUnityPlugin)this).Logger; Instance = this; Logger.LogInfo((object)"PeakChatOps is loaded!"); BundleLoader.LoadBundleWithName((BaseUnityPlugin)(object)this, "PeakChatOpsUI.peakbundle", (Action<PeakBundle>)delegate(PeakBundle peakBundle) { PeakChatOpsUIPrefab = peakBundle.LoadAsset<GameObject>("Assets/MOD/PeakChatOpsUI.prefab"); }); _harmony = new Harmony("com.lightjunction.peakchatops"); _harmony.PatchAll(typeof(GUIManagerPatch)); _harmony.PatchAll(typeof(CharacterStatsPatches)); _harmony.PatchAll(typeof(InputBlockingPatches)); PLocalizedText.Init(); PeakChatOpsUI.Help(); config = new PConfig(((BaseUnityPlugin)this).Config); if ((Object)(object)GameObject.Find("ChatSystem") == (Object)null) { GameObject val = new GameObject("ChatSystem"); val.AddComponent<ChatSystem>(); Object.DontDestroyOnLoad((Object)(object)val); Logger.LogInfo((object)"[PeakChatOps] ChatSystem GameObject created and initialized."); } AIChatContextLogger.CreateGlobalInstance(config.AiContextMaxCount.Value); AIChatContextLogger.Instance?.LogSystem(PLocalizedText.GetText("AI_CONTEXT_PEAK_WORLD_PROMPT_SYSTEM"), "System", "system", pinned: true); try { CentralCmdRouter.EnsureInitialized(); Logger.LogDebug((object)"[PeakChatOps] CentralCmdRouter.EnsureInitialized called"); } catch (Exception ex) { Logger.LogError((object)("[PeakChatOps] Error ensuring MsgHandlerChain initialization: " + ex.Message)); } } private void OnDestroy() { _harmony.UnpatchSelf(); Logger.LogInfo((object)"PeakChatOps is unloaded!"); } } } namespace PeakChatOps.UI { public class PeakChatOpsUI : MonoBehaviour { public static UIDocument uIDocument; public bool isBlockingInput; private TextField messageInputField; public static List<string> messages = new List<string>(); public static PeakChatOpsUI Instance { get; private set; } private void Start() { if ((Object)(object)Instance != (Object)null) { Object.Destroy((Object)(object)this); } else { Instance = this; } } public void BindUIEvents(GameObject uiGO) { //IL_0100: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)uiGO == (Object)null) { return; } uIDocument = uiGO.GetComponent<UIDocument>(); if (!((Object)(object)uIDocument == (Object)null)) { VisualElement rootVisualElement = uIDocument.rootVisualElement; Button val = UQueryExtensions.Q<Button>(rootVisualElement, "send-button", (string)null); if (val != null) { val.clicked += OnSendMessage; } Button val2 = UQueryExtensions.Q<Button>(rootVisualElement, "close-button", (string)null); if (val2 != null) { val2.clicked += HideNow; } Button val3 = UQueryExtensions.Q<Button>(rootVisualElement, "minimize-button", (string)null); if (val3 != null) { val3.clicked += MinimizeUI; } Button val4 = UQueryExtensions.Q<Button>(rootVisualElement, "maximize-button", (string)null); if (val4 != null) { val4.clicked += MaximizeUI; } messageInputField = UQueryExtensions.Q<TextField>(rootVisualElement, "message-input", (string)null); _ = messageInputField; ListView val5 = UQueryExtensions.Q<ListView>(rootVisualElement, "message-list", (string)null); if (val5 != null) { ((BaseVerticalCollectionView)val5).virtualizationMethod = (CollectionVirtualizationMethod)1; ((BaseVerticalCollectionView)val5).selectionType = (SelectionType)0; ((VisualElement)val5).style.flexGrow = StyleFloat.op_Implicit(1f); messages.Clear(); messages.Add(PLocalizedText.GetText("PEAKCHATOPSWELCOME")); ((BaseVerticalCollectionView)val5).itemsSource = messages; val5.makeItem = MakeItem(); val5.bindItem = BindItem(); } VisualElement val6 = UQueryExtensions.Q(rootVisualElement, "chat-panel", (string)null); if (val6 != null) { val6.RemoveFromClassList("pos-topleft"); val6.RemoveFromClassList("pos-topright"); val6.RemoveFromClassList("pos-center"); } switch (PeakChatOpsPlugin.config?.Pos.Value ?? UIAlignment.TopLeft) { case UIAlignment.TopLeft: OnTopLeft(); break; case UIAlignment.TopRight: OnTopRight(); break; case UIAlignment.Center: OnCenter(); break; default: OnTopLeft(); break; } } } private void Update() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) if (!isBlockingInput) { if (PeakChatOpsPlugin.config?.Key != null && Input.GetKeyDown(PeakChatOpsPlugin.config.Key.Value)) { EnterInputMode(); } } else if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271)) { OnSendMessage(); } else if (Input.GetKeyDown((KeyCode)27)) { ExitInputMode(); } } private void EnterInputMode() { if (!isBlockingInput) { isBlockingInput = true; ShowNow(); if (messageInputField != null) { ((Focusable)messageInputField).Focus(); } } } private void ExitInputMode() { if (!isBlockingInput) { return; } if (messageInputField != null) { ((Focusable)messageInputField).Blur(); } if ((Object)(object)uIDocument != (Object)null) { VisualElement rootVisualElement = uIDocument.rootVisualElement; ListView val = UQueryExtensions.Q<ListView>(rootVisualElement, "message-list", (string)null); if (val != null) { ((BaseVerticalCollectionView)val).ClearSelection(); } } isBlockingInput = false; } private async void OnSendMessage() { if ((Object)(object)uIDocument == (Object)null) { return; } VisualElement rootVisualElement = uIDocument.rootVisualElement; TextField val = UQueryExtensions.Q<TextField>(rootVisualElement, "message-input", (string)null); if (val == null || string.IsNullOrWhiteSpace(((BaseField<string>)(object)val).value)) { return; } string value = ((BaseField<string>)(object)val).value; ((BaseField<string>)(object)val).value = ""; ExitInputMode(); if (!((Object)(object)ChatSystem.Instance != (Object)null)) { return; } try { await ChatSystem.Instance.SendChatMessageAsync(value, null); } catch (Exception) { } } public void OnTopLeft() { UIDocument obj = uIDocument; object obj2; if (obj == null) { obj2 = null; } else { VisualElement rootVisualElement = obj.rootVisualElement; obj2 = ((rootVisualElement != null) ? UQueryExtensions.Q(rootVisualElement, "chat-panel", (string)null) : null); } VisualElement val = (VisualElement)obj2; if (val != null) { val.RemoveFromClassList("pos-topright"); val.RemoveFromClassList("pos-center"); val.AddToClassList("pos-topleft"); } } public void OnTopRight() { UIDocument obj = uIDocument; object obj2; if (obj == null) { obj2 = null; } else { VisualElement rootVisualElement = obj.rootVisualElement; obj2 = ((rootVisualElement != null) ? UQueryExtensions.Q(rootVisualElement, "chat-panel", (string)null) : null); } VisualElement val = (VisualElement)obj2; if (val != null) { val.RemoveFromClassList("pos-topleft"); val.RemoveFromClassList("pos-center"); val.AddToClassList("pos-topright"); } } public void OnCenter() { UIDocument obj = uIDocument; object obj2; if (obj == null) { obj2 = null; } else { VisualElement rootVisualElement = obj.rootVisualElement; obj2 = ((rootVisualElement != null) ? UQueryExtensions.Q(rootVisualElement, "chat-panel", (string)null) : null); } VisualElement val = (VisualElement)obj2; if (val != null) { val.RemoveFromClassList("pos-topright"); val.RemoveFromClassList("pos-topleft"); val.AddToClassList("pos-center"); } } public void AddMessage(string sender, string content) { if ((Object)(object)uIDocument == (Object)null) { return; } VisualElement rootVisualElement = uIDocument.rootVisualElement; ListView messageListView = UQueryExtensions.Q<ListView>(rootVisualElement, "message-list", (string)null); if (messageListView == null) { return; } string item = (string.IsNullOrEmpty(sender) ? content : ("[" + sender + "] " + content)); messages.Add(item); ((BaseVerticalCollectionView)messageListView).Rebuild(); if (messages.Count > 0) { ((VisualElement)messageListView).schedule.Execute((Action)delegate { ((BaseVerticalCollectionView)messageListView).ScrollToItem(messages.Count - 1); }).StartingIn(50L); } } public void RefreshUI() { UIDocument obj = uIDocument; if (obj != null) { VisualElement rootVisualElement = obj.rootVisualElement; if (rootVisualElement != null) { rootVisualElement.Clear(); } } } public void HideNow() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)uIDocument != (Object)null) { uIDocument.rootVisualElement.style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)1); ExitInputMode(); } } public void ShowNow() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)uIDocument != (Object)null) { uIDocument.rootVisualElement.style.display = StyleEnum<DisplayStyle>.op_Implicit((DisplayStyle)0); EnterInputMode(); } } private void MinimizeUI() { UIDocument obj = uIDocument; object obj2; if (obj == null) { obj2 = null; } else { VisualElement rootVisualElement = obj.rootVisualElement; obj2 = ((rootVisualElement != null) ? UQueryExtensions.Q<VisualElement>(rootVisualElement, "chat-panel", (string)null) : null); } VisualElement val = (VisualElement)obj2; if (val != null) { bool flag = val.ClassListContains("minimized"); val.RemoveFromClassList("minimized"); val.RemoveFromClassList("maximized"); if (!flag) { val.AddToClassList("minimized"); } ExitInputMode(); } } private void MaximizeUI() { UIDocument obj = uIDocument; object obj2; if (obj == null) { obj2 = null; } else { VisualElement rootVisualElement = obj.rootVisualElement; obj2 = ((rootVisualElement != null) ? UQueryExtensions.Q<VisualElement>(rootVisualElement, "chat-panel", (string)null) : null); } VisualElement val = (VisualElement)obj2; if (val != null) { bool flag = val.ClassListContains("maximized"); val.RemoveFromClassList("minimized"); val.RemoveFromClassList("maximized"); if (!flag) { val.AddToClassList("maximized"); } EnterInputMode(); } } public static void Help() { PeakChatOpsPlugin.Logger.LogInfo((object)("Localization test: '" + PLocalizedText.GetText("PEAKCHATOPSWELCOME") + "'")); } private Func<VisualElement> MakeItem() { return () => (VisualElement)(object)new MessageLabel(); } private Action<VisualElement, int> BindItem() { return delegate(VisualElement element, int i) { Label val = (Label)(object)((element is Label) ? element : null); if (val != null) { if (i >= 0 && i < messages.Count) { ((TextElement)val).text = messages[i]; } else { ((TextElement)val).text = string.Empty; } } }; } } public class MessageLabel : Label { public MessageLabel() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) ((VisualElement)this).AddToClassList("message-item"); ((TextElement)this).selection.isSelectable = true; ((VisualElement)this).style.whiteSpace = StyleEnum<WhiteSpace>.op_Implicit((WhiteSpace)0); ((VisualElement)this).style.flexShrink = StyleFloat.op_Implicit(0f); ((VisualElement)this).style.flexGrow = StyleFloat.op_Implicit(1f); ((VisualElement)this).style.paddingLeft = StyleLength.op_Implicit(8f); ((VisualElement)this).style.paddingRight = StyleLength.op_Implicit(8f); ((VisualElement)this).style.paddingTop = StyleLength.op_Implicit(4f); ((VisualElement)this).style.paddingBottom = StyleLength.op_Implicit(4f); ((VisualElement)this).style.marginTop = StyleLength.op_Implicit(1f); ((VisualElement)this).style.marginBottom = StyleLength.op_Implicit(1f); ((VisualElement)this).style.unityTextAlign = StyleEnum<TextAnchor>.op_Implicit((TextAnchor)0); ((VisualElement)this).style.color = StyleColor.op_Implicit(new Color(0.9f, 0.9f, 0.9f, 1f)); } } } namespace PeakChatOps.Patches { [HarmonyPatch(typeof(CharacterStats))] public class CharacterStatsPatches { private class CharacterStateInfo { public bool died { get; set; } public bool revived { get; set; } public bool passedOut { get; set; } } private static readonly Dictionary<CharacterStats, (bool died, bool revived, bool passedOut)> lastStates; private static Dictionary<string, object> CreateExtraForEvent(CharacterStateInfo info) { return new Dictionary<string, object> { ["CharacterState"] = new Dictionary<string, bool> { ["died"] = info?.died ?? false, ["revived"] = info?.revived ?? false, ["passedOut"] = info?.passedOut ?? false } }; } static CharacterStatsPatches() { lastStates = new Dictionary<CharacterStats, (bool, bool, bool)>(); PeakChatOpsPlugin.Logger.LogWarning((object)"[Harmony] CharacterStatsPatches static ctor loaded!"); } [HarmonyPatch("Record", new Type[] { typeof(bool), typeof(float) })] [HarmonyPostfix] public static void RecordPostfix(CharacterStats __instance, bool useOverridePosition, float overrideHeight) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0177: 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_0201: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_014e: 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) string name = ((Object)__instance).name; string userId = PhotonNetwork.LocalPlayer.UserId; bool flag = ((Object)__instance).name.Contains(PhotonNetwork.LocalPlayer.NickName); List<TimelineInfo> timelineInfo = __instance.timelineInfo; if (timelineInfo == null || timelineInfo.Count == 0) { return; } TimelineInfo val = timelineInfo[timelineInfo.Count - 1]; bool flag2 = false; bool flag3 = false; bool flag4 = false; lastStates.TryGetValue(__instance, out (bool, bool, bool) value); (flag2, flag3, flag4) = value; if (val.died && !flag2) { if (flag) { EventBusRegistry.ChatMessageBus.Publish("sander://self", new ChatMessageEvent(PhotonNetwork.LocalPlayer.NickName, PeakChatOpsPlugin.config.DeathMessage.Value, PhotonNetwork.LocalPlayer.UserId, isDead: true, CreateExtraForEvent(new CharacterStateInfo { died = true }))); } AIChatContextLogger.Instance?.LogSystem("玩家[" + name + "]死亡", name, userId); } if (val.revived && !flag3) { if (flag) { EventBusRegistry.ChatMessageBus.Publish("sander://self", new ChatMessageEvent(PhotonNetwork.LocalPlayer.NickName, PeakChatOpsPlugin.config.ReviveMessage.Value, PhotonNetwork.LocalPlayer.UserId, isDead: false, CreateExtraForEvent(new CharacterStateInfo { revived = true }))); } AIChatContextLogger.Instance?.LogSystem("玩家[" + name + "]复活", name, userId); } if (val.justPassedOut && !flag4) { if (flag) { EventBusRegistry.ChatMessageBus.Publish("sander://self", new ChatMessageEvent(PhotonNetwork.LocalPlayer.NickName, PeakChatOpsPlugin.config.PassOutMessage.Value, PhotonNetwork.LocalPlayer.UserId, isDead: false, CreateExtraForEvent(new CharacterStateInfo { passedOut = true }))); } AIChatContextLogger.Instance?.LogSystem("玩家[" + name + "]晕厥", name, userId); } lastStates[__instance] = (val.died, val.revived, val.justPassedOut); } } [HarmonyPatch(typeof(GUIManager))] public static class GUIManagerPatch { public static GameObject PeakChatOpsUIGO; public static PeakChatOpsUI PeakChatOpsUIInstance; [HarmonyPatch("Start")] [HarmonyPostfix] public static void StartPostfix(GUIManager __instance) { try { Transform transform = ((Component)__instance).transform; if ((Object)(object)PeakChatOpsPlugin.PeakChatOpsUIPrefab != (Object)null) { PeakChatOpsUIGO = Object.Instantiate<GameObject>(PeakChatOpsPlugin.PeakChatOpsUIPrefab, transform); ((Object)PeakChatOpsUIGO).name = "PeakChatOpsUI"; PeakChatOpsUIInstance = PeakChatOpsUIGO.GetComponent<PeakChatOpsUI>(); if ((Object)(object)PeakChatOpsUIInstance == (Object)null) { PeakChatOpsUIInstance = PeakChatOpsUIGO.AddComponent<PeakChatOpsUI>(); } PeakChatOpsUIInstance.BindUIEvents(PeakChatOpsUIGO); } } catch (Exception) { } } } public static class InputBlockingPatches { private static readonly MethodInfo windowBlockingInput = AccessTools.PropertySetter(typeof(GUIManager), "windowBlockingInput"); [HarmonyPatch(typeof(GUIManager), "UpdateWindowStatus")] [HarmonyPostfix] public static void UpdateWindowStatusPatch(GUIManager __instance) { PeakChatOpsUI instance = PeakChatOpsUI.Instance; if (instance != null && instance.isBlockingInput) { windowBlockingInput?.Invoke(__instance, new object[1] { true }); __instance.windowShowingCursor = true; } } [HarmonyPatch(typeof(CinemaCamera), "Update")] [HarmonyPrefix] public static bool UpdateCinemaCamPatch(CinemaCamera __instance) { GUIManager instance = GUIManager.instance; if (instance != null && instance.windowBlockingInput && !__instance.on) { return false; } return true; } [HarmonyPatch(typeof(Character), "UpdateVariablesFixed")] [HarmonyPrefix] public static bool UpdateCharacterVariablesPatch(Character __instance) { GUIManager instance = GUIManager.instance; if (instance != null && instance.windowBlockingInput) { __instance.input.interactIsPressed = false; } return true; } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] public static bool InputStringPatch(ref string __result) { GUIManager instance = GUIManager.instance; if (instance != null) { _ = instance.windowBlockingInput; } else _ = 0; return true; } } } namespace PeakChatOps.core { public static class PLocalizedText { private static Dictionary<string, string> _textTable = new Dictionary<string, string>(); private static int _currentLangIndex = -1; private static bool _initialized; public static void Init() { if (_initialized) { PeakChatOpsPlugin.Logger.LogWarning((object)"[PLocalizedText] Already initialized, skipping."); return; } string text = Path.Combine(PeakChatOpsPlugin.PluginPath, "Localization.csv"); if (!File.Exists(text)) { PeakChatOpsPlugin.Logger.LogError((object)("[PLocalizedText] CSV file not found: " + text)); _initialized = true; return; } try { LoadLocalizationCsv(text); _initialized = true; PeakChatOpsPlugin.Logger.LogInfo((object)$"[PLocalizedText] Loaded {_textTable.Count} localization entries for language index {_currentLangIndex}"); } catch (Exception ex) { PeakChatOpsPlugin.Logger.LogError((object)("[PLocalizedText] Failed to load CSV: " + ex.Message)); } } private static void LoadLocalizationCsv(string csvPath) { string[] array = File.ReadAllLines(csvPath); if (array.Length == 0) { PeakChatOpsPlugin.Logger.LogWarning((object)"[PLocalizedText] CSV file is empty."); return; } List<string> list = ParseCsvLine(array[0]); _currentLangIndex = GetCurrentLanguageIndex(list); if (_currentLangIndex < 0 || _currentLangIndex >= list.Count) { PeakChatOpsPlugin.Logger.LogWarning((object)$"[PLocalizedText] Invalid language index: {_currentLangIndex}, defaulting to 0 (English)"); _currentLangIndex = 0; } for (int i = 1; i < array.Length; i++) { List<string> list2 = ParseCsvLine(array[i]); if (list2.Count <= _currentLangIndex) { PeakChatOpsPlugin.Logger.LogWarning((object)$"[PLocalizedText] Line {i + 1} has insufficient columns, skipping."); continue; } string text = list2[0]; string value = list2[_currentLangIndex]; if (!string.IsNullOrEmpty(text) && text != "ENDLINE") { _textTable[text] = value; } } } private static int GetCurrentLanguageIndex(List<string> header) { string text; try { text = LocalizedText.GetText("CURRENT_LANGUAGE", true); } catch { PeakChatOpsPlugin.Logger.LogWarning((object)"[PLocalizedText] Could not get current language from game, defaulting to English"); return 1; } for (int i = 0; i < header.Count; i++) { if (header[i].Equals(text, StringComparison.OrdinalIgnoreCase)) { return i; } } if (text.Contains("中文") || text.Contains("Chinese")) { for (int j = 0; j < header.Count; j++) { if (header[j].Contains("简体中文") || header[j].Contains("Chinese")) { return j; } } } PeakChatOpsPlugin.Logger.LogWarning((object)("[PLocalizedText] Language '" + text + "' not found in header, defaulting to English")); return 1; } private static List<string> ParseCsvLine(string line) { List<string> list = new List<string>(); bool flag = false; StringBuilder stringBuilder = new StringBuilder(); foreach (char c in line) { switch (c) { case '"': flag = !flag; continue; case ',': if (!flag) { list.Add(stringBuilder.ToString()); stringBuilder.Clear(); continue; } break; } stringBuilder.Append(c); } list.Add(stringBuilder.ToString()); return list; } public static string GetText(string key, string? fallback = null) { if (!_initialized) { PeakChatOpsPlugin.Logger.LogWarning((object)"[PLocalizedText] Not initialized yet, returning key as-is"); return fallback ?? key; } if (_textTable.TryGetValue(key, out string value)) { return value; } PeakChatOpsPlugin.Logger.LogWarning((object)("[PLocalizedText] Key '" + key + "' not found in localization table")); return fallback ?? key; } public static bool HasKey(string key) { return _textTable.ContainsKey(key); } public static IEnumerable<string> GetAllKeys() { return _textTable.Keys; } public static void Reload() { _initialized = false; _textTable.Clear(); Init(); } } } namespace PeakChatOps.Core { public class AIChatContextLogger { private sealed class MessageEntry { public AIChatMessageEvent Message { get; } public Dictionary<string, object> Payload { get; } public bool IsPinned { get; } public MessageEntry(AIChatMessageEvent message, Dictionary<string, object> payload, bool isPinned) { Message = message; Payload = payload; IsPinned = isPinned; } } private readonly LinkedList<MessageEntry> _history = new LinkedList<MessageEntry>(); private readonly List<MessageEntry> _messages = new List<MessageEntry>(); private int _maxHistory; private int _nonPinnedCount; public static AIChatContextLogger? Instance { get; private set; } public void ExportHistoryToFile(string filePath) { try { List<string> list = new List<string>(); foreach (MessageEntry item in _history) { AIChatMessageEvent message = item.Message; string text = (item.IsPinned ? " [PINNED]" : ""); list.Add($"[{message.Role}] {message.Sender}({message.UserId}): {message.Message}{text}"); } File.WriteAllLines(filePath, list); } catch (Exception ex) { PeakChatOpsPlugin.Logger.LogError((object)("[AIContext] 导出聊天记录到文件失败: " + filePath + ",错误信息: " + ex.Message)); } } public void LogSystem(string message, string sender = "system", string userId = "system", bool pinned = false) { Add(new AIChatMessageEvent(sender, message, userId, AIChatRole.system), pinned); } public void LogUser(string message, string sender = "PlayerName", string userId = "uuid-user", bool pinned = false) { Add(new AIChatMessageEvent(sender, message, userId), pinned); } public void LogAssistant(string message, string sender = "ModelName", string userId = "assistant", bool pinned = false) { Add(new AIChatMessageEvent(sender, message, userId, AIChatRole.assistant), pinned); } public static void CreateGlobalInstance(int maxHistory = 30) { Instance = new AIChatContextLogger(maxHistory); } public AIChatContextLogger(int maxHistory = 30) { _maxHistory = ((maxHistory > 0) ? maxHistory : 30); } public void SyncMaxHistoryFromConfig() { int num = 30; try { num = PeakChatOpsPlugin.config.AiContextMaxCount?.Value ?? 30; } catch (Exception ex) { PeakChatOpsPlugin.Logger.LogDebug((object)("[AIContext] SyncMaxHistoryFromConfig failed to read config: " + ex.Message)); } if (num > 0) { _maxHistory = num; TrimExcess(); } } public void Add(AIChatMessageEvent msg, bool pinned = false) { Dictionary<string, object> payload = new Dictionary<string, object> { ["role"] = msg.Role.ToString(), ["content"] = msg.Message, ["name"] = msg.UserId }; MessageEntry messageEntry = new MessageEntry(msg, payload, pinned); _history.AddLast(messageEntry); _messages.Add(messageEntry); if (!pinned) { _nonPinnedCount++; } TrimExcess(); } private void TrimExcess() { while (_nonPinnedCount > _maxHistory) { for (LinkedListNode<MessageEntry> linkedListNode = _history.First; linkedListNode != null; linkedListNode = linkedListNode.Next) { if (!linkedListNode.Value.IsPinned) { _history.Remove(linkedListNode); _messages.Remove(linkedListNode.Value); _nonPinnedCount--; break; } } } } public List<Dictionary<string, object>> BuildContextMessages(string userPrompt, string userName = "玩家") { List<Dictionary<string, object>> list = new List<Dictionary<string, object>>(_messages.Count); foreach (MessageEntry message in _messages) { list.Add(message.Payload); } return list; } public void Clear() { _history.Clear(); _messages.Clear(); _nonPinnedCount = 0; } public static (string? content, string? reasoning) ParseOpenAICompletionResponseWithReasoning(string response) { try { JObject val = JObject.Parse(response); JToken obj = val["choices"]; JArray val2 = (JArray)(object)((obj is JArray) ? obj : null); if (val2 != null && ((JContainer)val2).Count > 0) { foreach (JToken item in val2) { JToken obj2 = item[(object)"message"]; string text = ((obj2 == null) ? null : ((object)obj2[(object)"content"])?.ToString()); JToken obj3 = item[(object)"message"]; object obj4 = ((obj3 == null) ? null : ((object)obj3[(object)"reasoning"])?.ToString()); if (obj4 == null) { JToken obj5 = item[(object)"message"]; obj4 = ((obj5 == null) ? null : ((object)obj5[(object)"thoughts"])?.ToString()); } string text2 = (string)obj4; string text3 = ((object)item[(object)"text"])?.ToString(); if (!string.IsNullOrWhiteSpace(text)) { return (text.Trim(), string.IsNullOrWhiteSpace(text2) ? null : text2.Trim()); } if (!string.IsNullOrWhiteSpace(text2)) { return (null, text2.Trim()); } if (!string.IsNullOrWhiteSpace(text3)) { return (text3.Trim(), null); } } } return (null, null); } catch (Exception) { return (null, null); } } public string BuildRoomEnvironmentPrompt(bool includeTimestamp = true) { try { Room currentRoom = PhotonNetwork.CurrentRoom; string text = ((currentRoom != null) ? currentRoom.Name : null) ?? "unknown"; Player[] array = PhotonNetwork.PlayerList ?? Array.Empty<Player>(); Player localPlayer = PhotonNetwork.LocalPlayer; Player masterClient = PhotonNetwork.MasterClient; List<string> list = new List<string>(); Player[] array2 = array; foreach (Player val in array2) { string text2 = ((!string.IsNullOrEmpty(val.NickName)) ? val.NickName : $"Player{val.ActorNumber}"); string text3 = ((!string.IsNullOrEmpty(val.UserId)) ? val.UserId : "unknown"); int actorNumber = val.ActorNumber; bool flag = ((object)val).Equals((object?)localPlayer); bool flag2 = ((object)val).Equals((object?)masterClient); list.Add($"{text2}|id={text3}|actor={actorNumber}|local={flag.ToString().ToLower()}|master={flag2.ToString().ToLower()}"); } string text4 = ((list.Count > 0) ? string.Join(";", list) : string.Empty); string text5 = "none"; try { if (((currentRoom != null) ? ((RoomInfo)currentRoom).CustomProperties : null) != null && ((Dictionary<object, object>)(object)((RoomInfo)currentRoom).CustomProperties).ContainsKey((object)"seed")) { text5 = ((RoomInfo)currentRoom).CustomProperties[(object)"seed"]?.ToString() ?? "none"; } } catch (Exception ex) { PeakChatOpsPlugin.Logger.LogDebug((object)("[AIContext] BuildRoomEnvironmentPrompt read seed: " + ex.Message)); } string text6 = ((masterClient != null) ? masterClient.NickName : null) ?? "unknown"; string text7 = (includeTimestamp ? $",time={DateTimeOffset.UtcNow.ToUnixTimeSeconds()}" : string.Empty); return $"room[{text}] players={array.Length} [{text4}] host={text6},mapSeed={text5}{text7}"; } catch (Exception ex2) { PeakChatOpsPlugin.Logger.LogError((object)("[AIContext] BuildRoomEnvironmentPrompt failed: " + ex2.Message)); return "room=unknown players=0"; } } } public class MessageData { public string Nickname; public string Message; public string UserId; public bool IsDead; public Dictionary<string, object> Extra; public MessageData(string nickname, string message, string userId, bool isDead, Dictionary<string, object> extra = null) { Nickname = nickname; Message = message; UserId = userId; IsDead = isDead; Extra = extra; } } public class ChatSystem : MonoBehaviour { [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct <FlushStaticPendingSendsAsync>d__10 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskVoidMethodBuilder <>t__builder; public ChatSystem <>4__this; private Awaiter <>u__1; private void MoveNext() { //IL_0065: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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) int num = <>1__state; ChatSystem chatSystem = <>4__this; try { if (num != 0) { goto IL_0011; } Awaiter awaiter = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); goto IL_0080; IL_0011: if (_staticPendingSends.TryDequeue(out (string, Dictionary<string, object>) result)) { UniTask val = chatSystem.SendChatMessageAsync(result.Item1, result.Item2); awaiter = ((UniTask)(ref val)).GetAwaiter(); if (!((Awaiter)(ref awaiter)).IsCompleted) { num = (<>1__state = 0); <>u__1 = awaiter; ((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <FlushStaticPendingSendsAsync>d__10>(ref awaiter, ref this); return; } goto IL_0080; } goto end_IL_000e; IL_0080: ((Awaiter)(ref awaiter)).GetResult(); goto IL_0011; end_IL_000e:; } catch (Exception exception) { <>1__state = -2; ((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; ((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetResult(); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { ((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine); } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct <PublishRemoteMessageAsync>d__7 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskVoidMethodBuilder <>t__builder; public ChatMessageEvent evt; private Awaiter <>u__1; private void MoveNext() { //IL_0055: 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_0061: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; try { try { Awaiter awaiter; if (num != 0) { UniTask val = EventBusRegistry.ChatMessageBus.Publish("sander://other", evt); awaiter = ((UniTask)(ref val)).GetAwaiter(); if (!((Awaiter)(ref awaiter)).IsCompleted) { num = (<>1__state = 0); <>u__1 = awaiter; ((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <PublishRemoteMessageAsync>d__7>(ref awaiter, ref this); return; } } else { awaiter = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); } ((Awaiter)(ref awaiter)).GetResult(); } catch (Exception) { } } catch (Exception exception) { <>1__state = -2; ((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; ((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetResult(); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { ((AsyncUniTaskVoidMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine); } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct <SendChatMessageAsync>d__8 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder <>t__builder; public string message; public Dictionary<string, object> extra; private Awaiter <>u__1; private void MoveNext() { //IL_0135: 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_0142: 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_0200: 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_01bd: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; try { Awaiter awaiter; if (num == 0) { awaiter = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); goto IL_0151; } Awaiter awaiter2; if (num == 1) { awaiter2 = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); goto IL_020f; } if (!string.IsNullOrWhiteSpace(message)) { string value = PeakChatOpsPlugin.config.CmdPrefix.Value; bool isDead = false; UniTask val; if (!string.IsNullOrEmpty(value) && message.StartsWith(value)) { if ((Object)(object)Character.localCharacter?.data != (Object)null) { isDead = Character.localCharacter.data.dead; } string text = message.Substring(value.Length).Trim(); string[] array = text.Split(' ', StringSplitOptions.RemoveEmptyEntries); string command = ((array.Length != 0) ? array[0] : string.Empty); string[] args = ((array.Length > 1) ? array[1..] : new string[0]); CmdMessageEvent ev = new CmdMessageEvent(command, args, PhotonNetwork.LocalPlayer.UserId); val = EventBusRegistry.CmdMessageBus.Publish("cmd://", ev); awaiter = ((UniTask)(ref val)).GetAwaiter(); if (!((Awaiter)(ref awaiter)).IsCompleted) { num = (<>1__state = 0); <>u__1 = awaiter; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <SendChatMessageAsync>d__8>(ref awaiter, ref this); return; } goto IL_0151; } if ((Object)(object)Character.localCharacter?.data != (Object)null) { isDead = Character.localCharacter.data.dead; } ChatMessageEvent ev2 = new ChatMessageEvent(PhotonNetwork.LocalPlayer.NickName, message, PhotonNetwork.LocalPlayer.UserId, isDead, extra); val = EventBusRegistry.ChatMessageBus.Publish("sander://self", ev2); awaiter2 = ((UniTask)(ref val)).GetAwaiter(); if (!((Awaiter)(ref awaiter2)).IsCompleted) { num = (<>1__state = 1); <>u__1 = awaiter2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <SendChatMessageAsync>d__8>(ref awaiter2, ref this); return; } goto IL_020f; } goto end_IL_0007; IL_0151: ((Awaiter)(ref awaiter)).GetResult(); goto end_IL_0007; IL_020f: ((Awaiter)(ref awaiter2)).GetResult(); end_IL_0007:; } catch (Exception exception) { <>1__state = -2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult(); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine); } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } public static ChatSystem Instance; private readonly Dictionary<byte, Action<EventData>> eventHandlers = new Dictionary<byte, Action<EventData>>(); private static ConcurrentQueue<(string message, Dictionary<string, object> extra)> _staticPendingSends = new ConcurrentQueue<(string, Dictionary<string, object>)>(); private void Start() { //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) Instance = this; UniTaskVoid val = FlushStaticPendingSendsAsync(); ((UniTaskVoid)(ref val)).Forget(); eventHandlers[81] = HandleChatEvent; PhotonNetwork.NetworkingClient.EventReceived += OnEvent; } private void OnDestroy() { PhotonNetwork.NetworkingClient.EventReceived -= OnEvent; } public void OnEvent(EventData photonEvent) { if (eventHandlers.TryGetValue(photonEvent.Code, out var value)) { value(photonEvent); } } internal void HandleChatEvent(EventData photonEvent) { //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) object[] array = (object[])photonEvent.CustomData; if (array.Length < 4) { return; } Dictionary<string, object> dictionary = null; if (array.Length > 4 && array[4] != null) { if (array[4] is Dictionary<string, object> dictionary2) { dictionary = dictionary2; } else { object obj = array[4]; Hashtable val = (Hashtable)((obj is Hashtable) ? obj : null); if (val != null) { dictionary = ConvertHashtableToDictionary(val); } else if (array[4] is IDictionary dictionary3) { dictionary = new Dictionary<string, object>(); foreach (DictionaryEntry item in dictionary3) { if (item.Key != null) { string key = item.Key.ToString(); dictionary[key] = item.Value; } } } } } bool result; MessageData messageData = new MessageData(array[0]?.ToString() ?? null, array[1]?.ToString() ?? null, array[2]?.ToString() ?? null, bool.TryParse(array[3]?.ToString(), out result) && result, dictionary); ChatMessageEvent evt = new ChatMessageEvent(messageData.Nickname, messageData.Message, messageData.UserId, messageData.IsDead, messageData.Extra); UniTaskVoid val2 = PublishRemoteMessageAsync(evt); ((UniTaskVoid)(ref val2)).Forget(); } [AsyncStateMachine(typeof(<PublishRemoteMessageAsync>d__7))] private UniTaskVoid PublishRemoteMessageAsync(ChatMessageEvent evt) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) <PublishRemoteMessageAsync>d__7 <PublishRemoteMessageAsync>d__ = default(<PublishRemoteMessageAsync>d__7); <PublishRemoteMessageAsync>d__.<>t__builder = AsyncUniTaskVoidMethodBuilder.Create(); <PublishRemoteMessageAsync>d__.evt = evt; <PublishRemoteMessageAsync>d__.<>1__state = -1; ((AsyncUniTaskVoidMethodBuilder)(ref <PublishRemoteMessageAsync>d__.<>t__builder)).Start<<PublishRemoteMessageAsync>d__7>(ref <PublishRemoteMessageAsync>d__); return ((AsyncUniTaskVoidMethodBuilder)(ref <PublishRemoteMessageAsync>d__.<>t__builder)).Task; } [AsyncStateMachine(typeof(<SendChatMessageAsync>d__8))] public UniTask SendChatMessageAsync(string message, Dictionary<string, object> extra) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) <SendChatMessageAsync>d__8 <SendChatMessageAsync>d__ = default(<SendChatMessageAsync>d__8); <SendChatMessageAsync>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create(); <SendChatMessageAsync>d__.message = message; <SendChatMessageAsync>d__.extra = extra; <SendChatMessageAsync>d__.<>1__state = -1; ((AsyncUniTaskMethodBuilder)(ref <SendChatMessageAsync>d__.<>t__builder)).Start<<SendChatMessageAsync>d__8>(ref <SendChatMessageAsync>d__); return ((AsyncUniTaskMethodBuilder)(ref <SendChatMessageAsync>d__.<>t__builder)).Task; } private static Dictionary<string, object> ConvertHashtableToDictionary(Hashtable hashtable) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (hashtable == null) { return null; } Dictionary<string, object> dictionary = new Dictionary<string, object>(); DictionaryEntryEnumerator enumerator = hashtable.GetEnumerator(); try { while (((DictionaryEntryEnumerator)(ref enumerator)).MoveNext()) { DictionaryEntry current = ((DictionaryEntryEnumerator)(ref enumerator)).Current; if (current.Key != null) { dictionary[current.Key.ToString()] = current.Value; } } return dictionary; } finally { ((IDisposable)(DictionaryEntryEnumerator)(ref enumerator)).Dispose(); } } [AsyncStateMachine(typeof(<FlushStaticPendingSendsAsync>d__10))] private UniTaskVoid FlushStaticPendingSendsAsync() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) <FlushStaticPendingSendsAsync>d__10 <FlushStaticPendingSendsAsync>d__ = default(<FlushStaticPendingSendsAsync>d__10); <FlushStaticPendingSendsAsync>d__.<>t__builder = AsyncUniTaskVoidMethodBuilder.Create(); <FlushStaticPendingSendsAsync>d__.<>4__this = this; <FlushStaticPendingSendsAsync>d__.<>1__state = -1; ((AsyncUniTaskVoidMethodBuilder)(ref <FlushStaticPendingSendsAsync>d__.<>t__builder)).Start<<FlushStaticPendingSendsAsync>d__10>(ref <FlushStaticPendingSendsAsync>d__); return ((AsyncUniTaskVoidMethodBuilder)(ref <FlushStaticPendingSendsAsync>d__.<>t__builder)).Task; } } public static class MessageStyles { public const string ColorCommand = "#5BA3F5"; public const string ColorAI = "#00D9FF"; public const string ColorSuccess = "#4ADE80"; public const string ColorError = "#F87171"; public const string ColorWarning = "#FBBF24"; public const string ColorSystem = "#A78BFA"; public const string ColorTranslate = "#FB923C"; public const string ColorDead = "#9CA3AF"; public const string ColorPlayerLocal = "#34D399"; public const string ColorPlayerRemote = "#E5E7EB"; public const string ColorSecondary = "#9CA3AF"; public const string ColorReasoning = "#6B7280"; public const string ColorText = "#D1D5DB"; public const string ColorTextAI = "#7DD3FC"; public const string ColorTextCommand = "#93C5FD"; public const string ColorTextSuccess = "#86EFAC"; public const string ColorTextError = "#FCA5A5"; public const string ColorTextWarning = "#FDE047"; public const string ColorTextSystem = "#C4B5FD"; public const string ColorTextTranslate = "#FDBA74"; public const string SizeLabel = "90%"; public const string SizeSecondary = "85%"; public const string SizeReasoning = "80%"; public static string Label(string text, string color, string size = "90%") { return "<color=" + color + "><size=" + size + ">" + text + "</size></color>"; } public static string CommandLabel(string command) { return Label("[" + command + "]", "#5BA3F5"); } public static string AILabel(string modelName = "AI") { return Label("[" + modelName + "]", "#00D9FF"); } public static string SuccessLabel(string text = "Success") { return Label("[" + text + "]", "#4ADE80"); } public static string ErrorLabel(string text = "Error") { return Label("<b>[" + text + "]</b>", "#F87171"); } public static string WarningLabel(string text = "Warning") { return Label("[" + text + "]", "#FBBF24"); } public static string SystemLabel(string text = "System") { return Label("[" + text + "]", "#A78BFA"); } public static string TranslateLabel() { return Label("[T]", "#FB923C"); } public static string PlayerLabel(string playerName, bool isLocal, bool isDead = false) { string text = (isDead ? "#9CA3AF" : (isLocal ? "#34D399" : "#E5E7EB")); string text2 = (isDead ? " <b><color=#F87171>(DEAD)</color></b>" : ""); return "<color=" + text + "><size=90%>[" + playerName + "]</size></color>" + text2; } public static string SecondaryText(string text) { return "<color=#9CA3AF><size=85%>" + text + "</size></color>"; } public static string ReasoningText(string text) { return "<color=#6B7280><size=80%>" + text + "</size></color>"; } public static string ColoredContent(string content, string color = null) { if (string.IsNullOrWhiteSpace(content)) { return string.Empty; } string text = color ?? "#D1D5DB"; return "<color=" + text + ">" + content + "</color>"; } public static string AIContent(string content) { return ColoredContent(content, "#7DD3FC"); } public static string CommandContent(string content) { return ColoredContent(content, "#93C5FD"); } public static string SuccessContent(string content) { return ColoredContent(content, "#86EFAC"); } public static string ErrorContent(string content) { return ColoredContent(content, "#FCA5A5"); } public static string WarningContent(string content) { return ColoredContent(content, "#FDE047"); } public static string SystemContent(string content) { return ColoredContent(content, "#C4B5FD"); } public static string TranslateContent(string content) { return ColoredContent(content, "#FDBA74"); } public static string PlayerContent(string content, bool isLocal = false) { string color = (isLocal ? "#34D399" : "#D1D5DB"); return ColoredContent(content, color); } } public static class DevLog { private static string lastDevLogMessage = ""; [Conditional("DEBUGUI")] public static void UI(string message) { try { if (!(lastDevLogMessage == message)) { HarmonyFileLog.Enabled = true; PeakChatOpsPlugin.Logger.LogDebug((object)message); if ((Object)(object)PeakChatOpsUI.Instance != (Object)null) { PeakChatOpsUI.Instance.AddMessage("<color=#FFA500>[DevLog]</color> ", message); } lastDevLogMessage = message; } } catch { } } [Conditional("DEBUG")] public static void File(string message) { try { HarmonyFileLog.Enabled = true; PeakChatOpsPlugin.Logger.LogDebug((object)message); } catch { } } } } namespace PeakChatOps.Core.MsgChain { public static class AIChatMessageChain { [CompilerGenerated] private sealed class <>c__DisplayClass1_0 { public string atCommand; internal bool <HandleAiChatMessageAsync>b__0(PCOCommandAttribute c) { return c.Name.Equals(atCommand, StringComparison.OrdinalIgnoreCase); } } [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct <HandleAiChatMessageAsync>d__1 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder <>t__builder; public AIChatMessageEvent evt; private bool <hasError>5__2; private OpenAIClient <client>5__3; private Awaiter<string> <>u__1; private void MoveNext() { //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0408: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03e0: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_06a5: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; try { if (num == 0) { goto IL_020f; } if (evt != null && evt.Role == AIChatRole.user && !string.IsNullOrWhiteSpace(evt.Message)) { if (evt.Extra == null || !evt.Extra.TryGetValue("AI", out object value) || !(value is AIExtra aIExtra)) { goto IL_01d5; } <>c__DisplayClass1_0 CS$<>8__locals0 = new <>c__DisplayClass1_0 { atCommand = aIExtra.AtCommand?.ToLowerInvariant() }; string atCommand = CS$<>8__locals0.atCommand; if (!(atCommand == "clear")) { if (atCommand == "send") { string value2 = PeakChatOpsPlugin.config.PromptSend.Value; evt.Message = ((!string.IsNullOrWhiteSpace(aIExtra.PromptAppend)) ? (evt.Message + "(" + aIExtra.PromptAppend + ")") : (evt.Message + "(" + value2 + ")")); } else { PCOCommandAttribute pCOCommandAttribute = Cmdx.CommandMetas.Find((PCOCommandAttribute c) => c.Name.Equals(CS$<>8__locals0.atCommand, StringComparison.OrdinalIgnoreCase)); if (pCOCommandAttribute != null) { evt.Message = evt.Message + " (Command Info: " + pCOCommandAttribute.Name + " - " + pCOCommandAttribute.Description + ")"; } } goto IL_01d5; } AIChatContextLogger.Instance?.Clear(); PeakChatOpsUI.Instance?.AddMessage(MessageStyles.AILabel(), MessageStyles.SystemContent("上下文已清空 (Context cleared)")); } goto end_IL_0007; IL_01d5: AIChatContextLogger.Instance?.LogUser(evt.Message, evt.Sender, evt.UserId); <hasError>5__2 = false; goto IL_020f; IL_020f: string text3; try { if (num == 0) { goto IL_03a5; } string hashOrKey = PeakChatOpsPlugin.config.AiApiKey?.Value; string actualApiKey = PConfig.GetActualApiKey(hashOrKey); string text = PeakChatOpsPlugin.config.AiEndpoint?.Value; string text2 = default(string); List<Dictionary<string, object>> messages = default(List<Dictionary<string, object>>); int maxTokens = default(int); if (!string.IsNullOrEmpty(actualApiKey) && !string.IsNullOrEmpty(text)) { string message = evt.Message; text2 = PeakChatOpsPlugin.config.AiModel?.Value; if (string.IsNullOrWhiteSpace(text2)) { text2 = "gpt-oss:120b-cloud"; } AIChatContextLogger instance = AIChatContextLogger.Instance; messages = (List<Dictionary<string, object>>)((instance == null) ? ((IList)new List<Dictionary<string, object>>()) : ((IList)instance.BuildContextMessages(message, evt.UserId))); maxTokens = PeakChatOpsPlugin.config.AiMaxTokens?.Value ?? 1024; double temperature = ((double?)PeakChatOpsPlugin.config.AiTemperature?.Value) ?? 0.7; double topP = ((double?)PeakChatOpsPlugin.config.AiTopP?.Value) ?? 1.0; int n = PeakChatOpsPlugin.config.AiN?.Value ?? 1; <client>5__3 = new OpenAIClient(actualApiKey, text, maxTokens, temperature, topP, n); goto IL_03a5; } text3 = "未配置 API Key 或 Endpoint,请先在设置中填写。"; <hasError>5__2 = true; goto end_IL_020f; IL_03a5: try { Awaiter<string> awaiter; if (num != 0) { OpenAIChatApi openAIChatApi = new OpenAIChatApi(<client>5__3); awaiter = openAIChatApi.CreateChatCompletionAsync(text2, messages, maxTokens).GetAwaiter(); if (!awaiter.IsCompleted) { num = (<>1__state = 0); <>u__1 = awaiter; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter<string>, <HandleAiChatMessageAsync>d__1>(ref awaiter, ref this); return; } } else { awaiter = <>u__1; <>u__1 = default(Awaiter<string>); num = (<>1__state = -1); } string result = awaiter.GetResult(); string text4 = result; if (text4 == null) { text3 = "AI API 返回空响应,请检查网络连接或 API 配置"; <hasError>5__2 = true; } else { var (text5, text6) = AIChatContextLogger.ParseOpenAICompletionResponseWithReasoning(text4); string text9; if (text5 != null && text6 != null) { ConfigEntry<bool> aiShowResponse = PeakChatOpsPlugin.config.AiShowResponse; if (aiShowResponse == null || aiShowResponse.Value) { string text7 = MessageStyles.ReasoningText(text6); string text8 = MessageStyles.SecondaryText("[R]"); text9 = text5 + "\n" + text8 + ": " + text7; } else { text9 = text5; } } else if (text5 != null) { text9 = text5; } else if (text6 != null) { text9 = MessageStyles.ReasoningText(text6); } else { text9 = PLocalizedText.GetText("AI_NO_RESPONSE"); <hasError>5__2 = true; } if (text5 == null && text6 != null) { string text10 = text6.Substring(0, Math.Min(200, text6.Length)); } if (!<hasError>5__2) { AIChatContextLogger.Instance?.LogAssistant(text5 ?? text9, PeakChatOpsPlugin.config.AiModel?.Value ?? "AI"); } text3 = text9; } } finally { if (num < 0 && <client>5__3 != null) { ((IDisposable)<client>5__3).Dispose(); } } <client>5__3 = null; end_IL_020f:; } catch (Exception ex) { text3 = "AI 请求异常: " + ex.Message; <hasError>5__2 = true; } bool flag = false; if (evt.Extra != null && evt.Extra.TryGetValue("AI", out object value3) && value3 is AIExtra aIExtra2) { string text11 = aIExtra2.AtCommand?.ToLowerInvariant(); if (text11 == "send") { flag = true; } } if (!string.IsNullOrWhiteSpace(text3)) { if (flag && !<hasError>5__2) { ChatMessageEvent ev = new ChatMessageEvent(evt.Sender + " And " + (PeakChatOpsPlugin.config.AiModel?.Value ?? "AI"), text3, evt.UserId, (Character.localCharacter?.data?.dead).GetValueOrDefault(), evt.Extra); UniTaskExtensions.Forget(EventBusRegistry.ChatMessageBus.Publish("sander://self", ev)); string text12 = text3.Substring(0, Math.Min(50, text3.Length)); string content = MessageStyles.SuccessContent("已发送到游戏聊天: " + text12 + "..."); PeakChatOpsUI.Instance?.AddMessage(MessageStyles.SuccessLabel("AI→Chat"), content); } else { string modelName = PeakChatOpsPlugin.config.AiModel?.Value ?? "AI"; string sender = (<hasError>5__2 ? MessageStyles.ErrorLabel("AI Error") : MessageStyles.AILabel(modelName)); string content2 = (<hasError>5__2 ? MessageStyles.ErrorContent(text3) : MessageStyles.AIContent(text3)); PeakChatOpsUI.Instance?.AddMessage(sender, content2); } } else { PeakChatOpsUI.Instance?.AddMessage(MessageStyles.WarningLabel("AI"), MessageStyles.WarningContent("没有收到任何响应")); } end_IL_0007:; } catch (Exception exception) { <>1__state = -2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult(); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine); } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct <HandleAiTranslateMessageAsync>d__2 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder <>t__builder; public AIChatMessageEvent evt; private bool <hasError>5__2; private OpenAIClient <client>5__3; private Awaiter<string> <>u__1; private void MoveNext() { //IL_02f1: Unknown result type (might be due to invalid IL or missing references) //IL_02f6: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02d6: 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) int num = <>1__state; try { if (num != 0) { <hasError>5__2 = false; } string text2; try { if (num == 0) { goto IL_029b; } string hashOrKey = PeakChatOpsPlugin.config.AiApiKey?.Value; string actualApiKey = PConfig.GetActualApiKey(hashOrKey); string text = PeakChatOpsPlugin.config.AiEndpoint?.Value; string model = default(string); int maxTokens = default(int); List<Dictionary<string, object>> list = default(List<Dictionary<string, object>>); if (!string.IsNullOrEmpty(actualApiKey) && !string.IsNullOrEmpty(text)) { string value = (string.IsNullOrWhiteSpace(PeakChatOpsPlugin.config.PromptTranslate?.Value) ? PLocalizedText.GetText("TRANSLATE_PROMPT") : PeakChatOpsPlugin.config.PromptTranslate.Value); model = (string.IsNullOrWhiteSpace(PeakChatOpsPlugin.config.AiModel?.Value) ? "gpt-oss:120b-cloud" : PeakChatOpsPlugin.config.AiModel.Value); maxTokens = PeakChatOpsPlugin.config.AiMaxTokens?.Value ?? 1024; double temperature = ((double?)PeakChatOpsPlugin.config.AiTemperature?.Value) ?? 0.9; double topP = ((double?)PeakChatOpsPlugin.config.AiTopP?.Value) ?? 1.0; int n = PeakChatOpsPlugin.config.AiN?.Value ?? 1; AIChatContextLogger instance = AIChatContextLogger.Instance; if (instance != null) { list = new List<Dictionary<string, object>> { new Dictionary<string, object> { { "role", "system" }, { "content", value } } }; List<Dictionary<string, object>> collection = instance.BuildContextMessages(evt.Message, evt.UserId); list.AddRange(collection); } else { list = new List<Dictionary<string, object>> { new Dictionary<string, object> { { "role", "system" }, { "content", value } }, new Dictionary<string, object> { { "role", "user" }, { "content", "Translation Mode:" + evt.Message + PeakChatOpsPlugin.config.PromptTranslate?.Value } } }; } <client>5__3 = new OpenAIClient(actualApiKey, text, maxTokens, temperature, topP, n); goto IL_029b; } text2 = "未配置 API Key 或 Endpoint,请先在设置中填写。"; <hasError>5__2 = true; goto end_IL_0012; IL_029b: try { Awaiter<string> awaiter; if (num != 0) { OpenAIChatApi openAIChatApi = new OpenAIChatApi(<client>5__3); awaiter = openAIChatApi.CreateChatCompletionAsync(model, list, maxTokens).GetAwaiter(); if (!awaiter.IsCompleted) { num = (<>1__state = 0); <>u__1 = awaiter; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter<string>, <HandleAiTranslateMessageAsync>d__2>(ref awaiter, ref this); return; } } else { awaiter = <>u__1; <>u__1 = default(Awaiter<string>); num = (<>1__state = -1); } string result = awaiter.GetResult(); string text3 = result; if (text3 == null) { text2 = "AI API 返回空响应,请检查网络连接或 API 配置"; <hasError>5__2 = true; } else { var (text4, text5) = AIChatContextLogger.ParseOpenAICompletionResponseWithReasoning(text3); string text8; if (text4 != null && text5 != null) { string text6 = MessageStyles.ReasoningText(text5); string text7 = MessageStyles.SecondaryText("[R]"); text8 = text4 + "\n" + text7 + ": " + text6; } else if (text4 != null) { text8 = text4; } else if (text5 != null) { text8 = MessageStyles.ReasoningText(text5); } else { text8 = PLocalizedText.GetText("AI_NO_RESPONSE"); <hasError>5__2 = true; } if (text4 == null && text5 != null) { string text9 = text5.Substring(0, Math.Min(200, text5.Length)); } text2 = text8; } } finally { if (num < 0 && <client>5__3 != null) { ((IDisposable)<client>5__3).Dispose(); } } <client>5__3 = null; end_IL_0012:; } catch (Exception ex) { text2 = "翻译异常: " + ex.Message; <hasError>5__2 = true; } if (!string.IsNullOrWhiteSpace(text2)) { string sender = (<hasError>5__2 ? MessageStyles.ErrorLabel("翻译错误") : MessageStyles.TranslateLabel()); string content = (<hasError>5__2 ? MessageStyles.ErrorContent(text2) : MessageStyles.TranslateContent(text2)); PeakChatOpsUI.Instance.AddMessage(sender, content); } else { PeakChatOpsUI.Instance.AddMessage(MessageStyles.WarningLabel("翻译"), MessageStyles.WarningContent("没有收到任何响应")); } } catch (Exception exception) { <>1__state = -2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult(); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine); } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } public static void EnsureInitialized() { //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) EventBusRegistry.AIChatMessageBus.Subscribe("ai://chat", HandleAiChatMessageAsync); EventBusRegistry.AIChatMessageBus.Subscribe("ai://translate", HandleAiTranslateMessageAsync); CancellationTokenSource orCreateBusCts = CentralCmdRouter.GetOrCreateBusCts(); UniTaskExtensions.Forget(EventBusRegistry.AIChatMessageBus.RunAsync("ai://chat", orCreateBusCts.Token)); UniTaskExtensions.Forget(EventBusRegistry.AIChatMessageBus.RunAsync("ai://translate", orCreateBusCts.Token)); } [AsyncStateMachine(typeof(<HandleAiChatMessageAsync>d__1))] private static UniTask HandleAiChatMessageAsync(AIChatMessageEvent evt) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) <HandleAiChatMessageAsync>d__1 <HandleAiChatMessageAsync>d__ = default(<HandleAiChatMessageAsync>d__1); <HandleAiChatMessageAsync>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create(); <HandleAiChatMessageAsync>d__.evt = evt; <HandleAiChatMessageAsync>d__.<>1__state = -1; ((AsyncUniTaskMethodBuilder)(ref <HandleAiChatMessageAsync>d__.<>t__builder)).Start<<HandleAiChatMessageAsync>d__1>(ref <HandleAiChatMessageAsync>d__); return ((AsyncUniTaskMethodBuilder)(ref <HandleAiChatMessageAsync>d__.<>t__builder)).Task; } [AsyncStateMachine(typeof(<HandleAiTranslateMessageAsync>d__2))] private static UniTask HandleAiTranslateMessageAsync(AIChatMessageEvent evt) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) <HandleAiTranslateMessageAsync>d__2 <HandleAiTranslateMessageAsync>d__ = default(<HandleAiTranslateMessageAsync>d__2); <HandleAiTranslateMessageAsync>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create(); <HandleAiTranslateMessageAsync>d__.evt = evt; <HandleAiTranslateMessageAsync>d__.<>1__state = -1; ((AsyncUniTaskMethodBuilder)(ref <HandleAiTranslateMessageAsync>d__.<>t__builder)).Start<<HandleAiTranslateMessageAsync>d__2>(ref <HandleAiTranslateMessageAsync>d__); return ((AsyncUniTaskMethodBuilder)(ref <HandleAiTranslateMessageAsync>d__.<>t__builder)).Task; } } public static class CentralCmdRouter { [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct <RouteCommandAsync>d__4 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder <>t__builder; public CmdMessageEvent evt; private object <>7__wrap1; private int <>7__wrap2; private Awaiter <>u__1; private void MoveNext() { //IL_04c7: Unknown result type (might be due to invalid IL or missing references) //IL_04cc: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_04fb: Unknown result type (might be due to invalid IL or missing references) //IL_0510: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_03c7: Unknown result type (might be due to invalid IL or missing references) //IL_03cc: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_031e: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_02db: Unknown result type (might be due to invalid IL or missing references) //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0489: Unknown result type (might be due to invalid IL or missing references) //IL_048e: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_0497: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Unknown result type (might be due to invalid IL or missing references) //IL_04ae: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_038e: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_03ac: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) int num = <>1__state; try { Awaiter awaiter2; Awaiter awaiter; switch (num) { default: <>7__wrap2 = 0; goto case 0; case 0: case 1: case 2: { UniTask val; try { Awaiter awaiter4; Func<CmdMessageEvent, UniTask> func = default(Func<CmdMessageEvent, UniTask>); Awaiter awaiter3; switch (num) { default: { if (evt == null || string.IsNullOrWhiteSpace(evt.Command)) { CmdExecResultEvent ev = new CmdExecResultEvent(evt?.Command ?? string.Empty, evt?.Args ?? Array.Empty<string>(), evt?.UserId ?? string.Empty, null, "command not found", success: false); val = EventBusRegistry.CmdExecResultBus.Publish("cmd://", ev); awaiter4 = ((UniTask)(ref val)).GetAwaiter(); if (!((Awaiter)(ref awaiter4)).IsCompleted) { num = (<>1__state = 0); <>u__1 = awaiter4; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <RouteCommandAsync>d__4>(ref awaiter4, ref this); return; } goto IL_011d; } string sender = MessageStyles.CommandLabel("> " + evt.Command); string content = ((evt.Args != null) ? string.Join(" ", evt.Args) : string.Empty); string content2 = MessageStyles.CommandContent(content); PeakChatOpsUI.Instance.AddMessage(sender, content2); string text = evt.Command.Trim(); List<string> list = new List<string> { "cmd://" + text, "cmd://" + text.ToLowerInvariant(), "cmd://" + text.ToUpperInvariant() }; if (text.Length > 0) { string text2 = char.ToUpperInvariant(text[0]) + ((text.Length > 1) ? text.Substring(1) : string.Empty); string text3 = char.ToLowerInvariant(text[0]) + ((text.Length > 1) ? text.Substring(1) : string.Empty); list.Add("cmd://" + text2); list.Add("cmd://" + text3); } func = null; string text4 = null; List<string>.Enumerator enumerator = list.GetEnumerator(); try { while (enumerator.MoveNext()) { string current = enumerator.Current; if (EventBusRegistry.CmdMessageBus.TryGetHandler(current, out Func<CmdMessageEvent, UniTask> handler)) { func = handler; text4 = current; break; } } } finally { if (num < 0) { ((IDisposable)enumerator).Dispose(); } } if (func == null) { CmdExecResultEvent ev2 = new CmdExecResultEvent(evt.Command, evt.Args ?? Array.Empty<string>(), evt.UserId, null, "command not found", success: false); val = EventBusRegistry.CmdExecResultBus.Publish("cmd://", ev2); awaiter3 = ((UniTask)(ref val)).GetAwaiter(); if (!((Awaiter)(ref awaiter3)).IsCompleted) { num = (<>1__state = 2); <>u__1 = awaiter3; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <RouteCommandAsync>d__4>(ref awaiter3, ref this); return; } break; } goto case 1; } case 0: awaiter4 = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); goto IL_011d; case 1: try { Awaiter awaiter5; if (num != 1) { val = func(evt); awaiter5 = ((UniTask)(ref val)).GetAwaiter(); if (!((Awaiter)(ref awaiter5)).IsCompleted) { num = (<>1__state = 1); <>u__1 = awaiter5; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <RouteCommandAsync>d__4>(ref awaiter5, ref this); return; } } else { awaiter5 = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); } ((Awaiter)(ref awaiter5)).GetResult(); } catch (Exception) { throw; } goto end_IL_0029; case 2: { awaiter3 = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); break; } IL_011d: ((Awaiter)(ref awaiter4)).GetResult(); goto end_IL_0007; } ((Awaiter)(ref awaiter3)).GetResult(); end_IL_0029:; } catch (Exception ex2) { <>7__wrap1 = ex2; <>7__wrap2 = 1; } int num2 = <>7__wrap2; if (num2 == 1) { Exception ex3 = (Exception)<>7__wrap1; CmdExecResultEvent ev3 = new CmdExecResultEvent(evt?.Command ?? string.Empty, evt?.Args ?? Array.Empty<string>(), evt?.UserId ?? string.Empty, null, ex3.Message, success: false); val = EventBusRegistry.CmdExecResultBus.Publish("cmd://", ev3); awaiter2 = ((UniTask)(ref val)).GetAwaiter(); if (!((Awaiter)(ref awaiter2)).IsCompleted) { num = (<>1__state = 3); <>u__1 = awaiter2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <RouteCommandAsync>d__4>(ref awaiter2, ref this); return; } goto IL_04e3; } goto IL_04ea; } case 3: awaiter2 = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); goto IL_04e3; case 4: { awaiter = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); break; } IL_04e3: ((Awaiter)(ref awaiter2)).GetResult(); goto IL_04ea; IL_04ea: <>7__wrap1 = null; awaiter = ((UniTask)(ref UniTask.CompletedTask)).GetAwaiter(); if (!((Awaiter)(ref awaiter)).IsCompleted) { num = (<>1__state = 4); <>u__1 = awaiter; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <RouteCommandAsync>d__4>(ref awaiter, ref this); return; } break; } ((Awaiter)(ref awaiter)).GetResult(); end_IL_0007:; } catch (Exception exception) { <>1__state = -2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult(); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private void SetStateMachine(IAsyncStateMachine stateMachine) { ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetStateMachine(stateMachine); } void IAsyncStateMachine.SetStateMachine(IAsyncStateMachine stateMachine) { //ILSpy generated this explicit interface implementation from .override directive in SetStateMachine this.SetStateMachine(stateMachine); } } private static CancellationTokenSource _busCts; public static CancellationTokenSource GetOrCreateBusCts() { return _busCts; } static CentralCmdRouter() { //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) _busCts = new CancellationTokenSource(); Cmdx.LoadPCmd(); Cmdx.Prefix = PeakChatOpsPlugin.config.CmdPrefix.Value; EventBusRegistry.CmdMessageBus.Subscribe("cmd://", RouteCommandAsync); EventBusRegistry.CmdExecResultBus.Subscribe("cmd://", HandleCmdExecResultAsync); UniTaskExtensions.Forget(EventBusRegistry.CmdMessageBus.RunAsync("cmd://", _busCts.Token)); UniTaskExtensions.Forget(EventBusRegistry.CmdExecResultBus.RunAsync("cmd://", _busCts.Token)); ChatMessageChain.EnsureInitialized(); } public static void EnsureInitialized() { } [AsyncStateMachine(typeof(<RouteCommandAsync>d__4))] private static UniTask RouteCommandAsync(CmdMessageEvent evt) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) <RouteCommandAsync>d__4 <RouteCommandAsync>d__ = default(<RouteCommandAsync>d__4); <RouteCommandAsync>d__.<>t__builder = AsyncUniTaskMethodBuilder.Create(); <RouteCommandAsync>d__.evt = evt; <RouteCommandAsync>d__.<>1__state = -1; ((AsyncUniTaskMethodBuilder)(ref <RouteCommandAsync>d__.<>t__builder)).Start<<RouteCommandAsync>d__4>(ref <RouteCommandAsync>d__); return ((AsyncUniTaskMethodBuilder)(ref <RouteCommandAsync>d__.<>t__builder)).Task; } private static UniTask HandleCmdExecResultAsync(CmdExecResultEvent evt) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) if (evt == null) { return UniTask.CompletedTask; } string sender = (evt.Success ? MessageStyles.SuccessLabel("Cmd") : MessageStyles.ErrorLabel("Cmd")); string content = evt.Stdout ?? evt.Stderr ?? string.Empty; string content2 = (evt.Success ? MessageStyles.SuccessContent(content) : MessageStyles.ErrorContent(content)); PeakChatOpsUI.Instance.AddMessage(sender, content2); return UniTask.CompletedTask; } public static UniTask HandleAnyMessageAsync(string anyText) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) PeakChatOpsUI.Instance.AddMessage(MessageStyles.SystemLabel("Info"), MessageStyles.SystemContent(anyText)); return UniTask.CompletedTask; } } public static class ChatMessageChain { [StructLayout(LayoutKind.Auto)] [CompilerGenerated] private struct <HandleLocalChatMessageAsync>d__2 : IAsyncStateMachine { public int <>1__state; public AsyncUniTaskMethodBuilder <>t__builder; public ChatMessageEvent evt; private Awaiter <>u__1; private void MoveNext() { //IL_012b: 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_015d: 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_016a: 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_0147: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Expected O, but got Unknown int num = <>1__state; try { Awaiter awaiter; if (num != 0) { if (evt != null && !string.IsNullOrWhiteSpace(evt.Message)) { AIChatContextLogger.Instance?.LogUser(evt.Message, evt.Sender, evt.UserId); } try { object[] array = new object[5] { evt.Sender, evt.Message, evt.UserId, evt.IsDead, ConvertExtraToHashtable(evt.Extra) }; PhotonNetwork.RaiseEvent((byte)81, (object)array, new RaiseEventOptions { Receivers = (ReceiverGroup)0 }, SendOptions.SendReliable); } catch (Exception ex) { PeakChatOpsUI.Instance.AddMessage(MessageStyles.ErrorLabel(), MessageStyles.ErrorContent(ex.Message)); } string sender = MessageStyles.PlayerLabel("You", isLocal: true, evt.IsDead); string content = MessageStyles.PlayerContent(evt.Message, isLocal: true); PeakChatOpsUI.Instance.AddMessage(sender, content); awaiter = ((UniTask)(ref UniTask.CompletedTask)).GetAwaiter(); if (!((Awaiter)(ref awaiter)).IsCompleted) { num = (<>1__state = 0); <>u__1 = awaiter; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).AwaitUnsafeOnCompleted<Awaiter, <HandleLocalChatMessageAsync>d__2>(ref awaiter, ref this); return; } } else { awaiter = <>u__1; <>u__1 = default(Awaiter); num = (<>1__state = -1); } ((Awaiter)(ref awaiter)).GetResult(); } catch (Exception exception) { <>1__state = -2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetException(exception); return; } <>1__state = -2; ((AsyncUniTaskMethodBuilder)(ref <>t__builder)).SetResult(); } void IAsyncStateMachine.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext this.MoveNext(); } [DebuggerHidden] private