private static string CreateCharacterText(SerializableValue raw, ScriptRuntime runtime, string language) { var character = DialoguePlugin.CreateCharacter(runtime, raw); return(character == null ? "" : character.ConvertToString(language)); }
private async Task ProcessText(string language) { var dialogue = PopQuickCacheMessage <ContextMessage <DialoguePlugin.MessageIntegration.Content> >(); QuickCacheMessage(dialogue); if (dialogue == null) { return; } var(content, noWait, noClear) = DialoguePlugin.CreateDialogueContent(dialogue.Context.Runtime, dialogue.Content.Text, language); var history = noClear ? CurrentText : null; if (_generator == null) { ResetGenerator(textGenerator); } if (content.Any()) { foreach (var item in content) { switch (item) { case ClearDialogueItem _: ClearText(); history = null; break; case PauseDialogueItem pauseDialogueItem: State = RenderState.Waiting; if (_quickMode) { } else if (pauseDialogueItem.Time.HasValue) { await Dispatcher.WaitForSeconds(pauseDialogueItem.Time.Value); } else { await MessageService.WaitUntil(DialoguePlugin.MessageIntegration.Mask, DialoguePlugin.MessageIntegration.FinishContentWaiting); } State = RenderState.Idle; break; case TextDialogueItem textDialogueItem: State = RenderState.Rendering; PrepareStyle(textDialogueItem); _generator.Text = textDialogueItem.Text; _generator.Reset(); while (_generator.MoveNext()) { ShowText(history, _generator.Current); if (timeSpan <= 0.0F) { continue; } var time = 0.0F; while (time < timeSpan) { time += Time.deltaTime; if (_quickMode) { break; } await Dispatcher.NextUpdate(); } } State = RenderState.Idle; history = CurrentText; break; } } } else { ShowText(history, new StringBuilder()); } _quickMode = false; if (!noWait) { await MessageService.WaitUntil(DialoguePlugin.MessageIntegration.Mask, DialoguePlugin.MessageIntegration.FinishContentWaiting); } }