Beispiel #1
0
        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 == Play.Trading.TradeDialogResult.Cancel)
                {
                    Memory.SetValue("$trade_result", new Yarn.Value("cancelled"));
                }
                else if (tradeResult == Play.Trading.TradeDialogResult.RejectProfit)
                {
                    Memory.SetValue("$trade_result", new Yarn.Value("unprofitable"));
                }
                else if (envoy.OwnerFaction.Race.HasValue(out var race0) && transaction.PlayerItems.Select(i => Library.GetResourceType(i.TypeName))
                         .SelectMany(i => { if (i.HasValue(out var t))
                                            {
                                                return(t.Tags);
                                            }
                                            return(new List <String>()); })
                         .Any(tag => race0.HatedResources.Contains(tag)))
                {
                    Memory.SetValue("$trade_result", new Yarn.Value("hated"));
                }
Beispiel #2
0
        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();
            });
        }
Beispiel #3
0
        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();
            });
        }