public Storyboard() { Root = new StoryboardBlock(null); current = Root; stack = new Stack <StoryboardBlock>(); Context = new StoryContext(); }
private StoryboardParser(XmlReader reader, Dictionary <string, Trophy>?trophies) { this.reader = reader; this.trophies = trophies; storyboard = new Storyboard(); blocks = new Stack <StoryboardBlock>(); currentBlock = storyboard.Root; }
private async Task <bool> MoveAsync(bool forward) { var block = current; if (block.Current is not null) { await block.Current.LeaveAsync(Context); } for (; ;) { var item = forward ? await block.MoveNextAsync(Context) : await block.MovePreviousAsync(Context); if (item == null) { if (!stack.TryPop(out block)) { await HandleContextChangingItemsAsync(forward); Context.CurrentItem = null; return(false); } if (block.Current != null) { await block.Current.LeaveAsync(Context); block.Current = null; } current = block; } else { if (item.ChangesContext) { StoreContextChangingItem(item); } if (item.Block == null) { if (item.IsPause) { Context.CurrentItem = item; return(true); } await item.LeaveAsync(Context); } else { stack.Push(block); current = item.Block; block = item.Block; } } } }
private void OpenBlock(IStoryboardItem item) { blocks.Push(currentBlock); if (item.Block == null) { throw new InvalidOperationException(); } Add(item); currentBlock = item.Block; }
private static T Get <T>(StoryboardBlock block, bool single) where T : IStoryboardItem { var item = block.ForwardQueue.Dequeue(); item.Should().BeOfType <T>(); if (single && block.ForwardQueue.Count > 0) { var type = block.ForwardQueue.Peek().GetType(); throw new Exception($"Era esperado que '{typeof(T).Name}' fosse o Ășltimo elemento do bloco, mas existe um elemento '{type.Name}' depois dele."); } return((T)item); }
private void CloseBlock() => currentBlock = blocks.Pop();
public InterlocutorMoodItem(string name, ICondition?condition) { Name = name; Condition = condition; Block = new StoryboardBlock(this); }
public ConditionItem(ICondition?condition) { Condition = condition; Block = new StoryboardBlock(this); }
public InterlocutorSpeechItem(ICondition?condition) { Condition = condition; Block = new StoryboardBlock(this); }
public ProtagonistItem(ICondition?condition) { Condition = condition; Block = new StoryboardBlock(this); }
public PromptItem(Prompt prompt, ICondition?condition) { Prompt = prompt; Condition = condition; Block = new StoryboardBlock(this); }
public ProtagonistMoodItem(string name, ICondition?condition) { Name = name; Condition = condition; Block = new StoryboardBlock(this); }