コード例 #1
0
        public static void PromptSendRequest(string key, string promptText)
        {
            int index = FindMatchingRequestIndex(key);

            if (index >= 0 && index < promptRequests.Count)
            {
                PromptRequestData matchingRequest = FindMatchingRequest(index);
                string            matchingKey     = matchingRequest.key;
                PromptRequestData updatedRequest  = new PromptRequestData(
                    matchingKey, promptText);
                promptRequests[index] = updatedRequest;
                OnPromptUpdated?.Invoke(updatedRequest, promptText);
                return;
            }

            PromptRequestData request = new PromptRequestData(key, promptText);

            if (request.IsInvalid)
            {
                return;
            }

            promptRequests.Add(request);
            OnPromptSendRequestReceived?.Invoke(request);
            OnLatestPromptSelected?.Invoke(request);
        }
コード例 #2
0
        public static void PromptRemovalRequest(string key)
        {
            PromptRequestData request = FindMatchingRequest(key);

            if (request.IsInvalid)
            {
                return;
            }

            promptRequests.Remove(request);
            OnPromptRemovalRequestReceived?.Invoke(request);

            if (promptRequests.Count > 0)
            {
                PromptRequestData lastPromptRequest = promptRequests.Last();
                OnLatestPromptSelected?.Invoke(request);
            }
            else
            {
                OnLatestPromptSelected?.Invoke(PromptRequestData.Invalid);
            }
        }