|
|
|
|
|
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Text.RegularExpressions;
|
|
|
using System.Linq;
|
|
|
|
|
|
using Microsoft.Xna.Framework;
|
|
|
|
|
|
using isometricparkfna.Messages;
|
|
|
using isometricparkfna.Components;
|
|
|
using static isometricparkfna.CellMap;
|
|
|
using isometricparkfna.UI;
|
|
|
|
|
|
using Encompass;
|
|
|
using TraceryNet;
|
|
|
using Ink.Runtime;
|
|
|
|
|
|
|
|
|
namespace isometricparkfna.Spawners {
|
|
|
|
|
|
[Receives(typeof(SpawnDialogMessage))]
|
|
|
class DialogSpawner : Spawner<SpawnDialogMessage>
|
|
|
|
|
|
{
|
|
|
Story Story;
|
|
|
Grammar Grammar;
|
|
|
|
|
|
public DialogSpawner(Story story, Grammar grammar)
|
|
|
{
|
|
|
this.Story = story;
|
|
|
this.Grammar = grammar;
|
|
|
}
|
|
|
|
|
|
protected override void Spawn(in SpawnDialogMessage message)
|
|
|
{
|
|
|
//Jump to the specified part of the story:
|
|
|
Story.ChoosePathString(message.Path);
|
|
|
|
|
|
var newDialog = CreateEntity();
|
|
|
var continuation = this.Story.ContinueMaximally();
|
|
|
|
|
|
var parts = Regex.Split(continuation, ":", 0);
|
|
|
var speaker = (parts.Length == 2) ? parts[0] : "";
|
|
|
var dialog = (parts.Length == 2) ? parts[1] : continuation;
|
|
|
|
|
|
AddComponent(newDialog, new DialogComponent {
|
|
|
CurrentDialog = dialog,
|
|
|
CurrentSpeaker = speaker,
|
|
|
Options = this.Story.currentChoices
|
|
|
.Select(option => option.text)
|
|
|
.ToList()});
|
|
|
|
|
|
AddComponent(newDialog, new WindowTypeComponent {
|
|
|
type = Window.Dialog});
|
|
|
AddComponent(newDialog,
|
|
|
new VisibilityComponent{ visible = true});
|
|
|
|
|
|
Logging.Success("Spawned new dialog.");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|