protected virtual void SpawnMessage(string messageText, string actorNameText, List <string> voiceClipNames, PlaybackSpot rollbackSpot) { var message = default(BacklogMessage); if (messages.Count > Capacity) { message = messages.First.Value; message.gameObject.SetActive(true); message.transform.SetSiblingIndex(MessagesContainer.childCount - 1); messages.RemoveFirst(); messages.AddLast(message); } else { if (messagesPool.Count > 0) { message = messagesPool.Pop(); message.gameObject.SetActive(true); message.transform.SetSiblingIndex(MessagesContainer.childCount - 1); } else { message = Instantiate(MessagePrefab, MessagesContainer, false); } messages.AddLast(message); } message.Initialize(messageText, actorNameText, voiceClipNames, rollbackSpot); }
public override async UniTask ExecuteAsync(CancellationToken cancellationToken = default) { var player = Engine.GetService <IScriptPlayer>(); var spot = new PlaybackSpot(player.PlayedScript.Name, player.PlayedCommand?.PlaybackSpot.LineIndex + 1 ?? 0, 0); player.GosubReturnSpots.Push(spot); var resetState = Assigned(ResetState) ? ResetState : (StringListParameter) new List <string> { Goto.NoResetFlag }; await new Goto { Path = Path, ResetState = resetState }.ExecuteAsync(cancellationToken); }
/// <summary> /// Attempts to parse provided script text fragment representing value of the parameter and assign result to the current value. /// </summary> /// <param name="playbackSpot">Playback spot of the command to which the parameter belong.</param> /// <param name="valueText">Parameter value text to parse (see remarks for the expected format).</param> /// <param name="errors">Parse errors (if any) or null when the parse has succeeded.</param> /// <remarks> /// Parameter value is the content after <see cref="Command.ParameterAssignLiteral"/> and before next whitespace (except whitespace inside double quotes). /// </remarks> public virtual void SetValueFromScriptText(PlaybackSpot playbackSpot, string valueText, out string errors) { errors = null; var expressions = DynamicValueData.CaptureExprRegex.Matches(valueText).Cast <Match>().Select(m => m.Value).ToArray(); if (expressions.Length > 0) { // Value contains injected script expressions (dynamic value); keep the text and parse it at runtime. dynamicValueData = new DynamicValueData { PlaybackSpot = playbackSpot, ValueText = valueText, Expressions = expressions }; HasValue = true; } else { Value = ParseValueText(valueText, out var hasValue, out errors); HasValue = hasValue; } }