private static void _wait_for_trade(YarnEngine State, List <Ancora.AstNode> Arguments, Yarn.MemoryVariableStore Memory) { var envoy = Memory.GetValue("$envoy").AsObject as TradeEnvoy; var playerFaction = Memory.GetValue("$player_faction").AsObject as Faction; var world = Memory.GetValue("$world").AsObject as WorldManager; State.Pause(); State.PlayerInterface.WaitForTrade((tradeResult, transaction) => { if (tradeResult == Gui.Widgets.TradeDialogResult.Cancel) { Memory.SetValue("$trade_result", new Yarn.Value("cancelled")); } else if (tradeResult == Gui.Widgets.TradeDialogResult.RejectProfit) { Memory.SetValue("$trade_result", new Yarn.Value("unprofitable")); } else if (transaction.PlayerItems.Select(i => Library.GetResourceType(i.Type)) .SelectMany(i => i.Tags) .Any(tag => envoy.OwnerFaction.Race.HatedResources.Contains(tag))) { Memory.SetValue("$trade_result", new Yarn.Value("hated")); } else if (transaction.PlayerItems.Select(i => Library.GetResourceType(i.Type)) .SelectMany(i => i.Tags) .Any(tag => envoy.OwnerFaction.Race.LikedResources.Contains(tag))) { Memory.SetValue("$trade_result", new Yarn.Value("liked")); } else { Memory.SetValue("$trade_result", new Yarn.Value("acceptable")); } Memory.SetValue("$trade_transaction", new Yarn.Value(transaction)); State.CancelSpeech(); State.Unpause(); }); }
private static void _wait_for_market(YarnEngine State, List <Ancora.AstNode> Arguments, Yarn.MemoryVariableStore Memory) { var envoy = Memory.GetValue("$envoy").AsObject as TradeEnvoy; var playerFaction = Memory.GetValue("$player_faction").AsObject as Faction; var world = Memory.GetValue("$world").AsObject as WorldManager; State.Pause(); State.PlayerInterface.WaitForMarket((tradeResult, transaction) => { if (tradeResult == Gui.Widgets.MarketDialogResult.Cancel) { Memory.SetValue("$trade_result", new Yarn.Value("cancelled")); } else { Memory.SetValue("$trade_result", new Yarn.Value("acceptable")); } Memory.SetValue("$trade_transaction", new Yarn.Value(transaction)); State.CancelSpeech(); State.Unpause(); }); }