예제 #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"));
                }
        private static void _pay_tribute(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;

            if (envoy == null || playerFaction == null || world == null)
            {
                State.PlayerInterface.Output("Command 'pay_tribute' can only be called from a TradeEnvoy initiated conversation.");
                return;
            }

            envoy.TributeDemanded = (decimal)0.0f;
            playerFaction.AddMoney(-Math.Min(world.PlayerFaction.Economy.CurrentMoney,
                                             envoy.TributeDemanded));
            Memory.SetValue("$envoy_tribute_demanded", new Yarn.Value(0.0f));
            Memory.SetValue("$envoy_demands_tribute", new Yarn.Value(false));
        }
예제 #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();
            });
        }
예제 #4
0
        private static void _make_peace(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;

            if (envoy == null || playerFaction == null || world == null)
            {
                State.PlayerInterface.Output("Command 'make_peace' can only be called from a TradeEnvoy initiated conversation.");
                return;
            }

            world.Overworld.GetPolitics(playerFaction.ParentFaction, envoy.OwnerFaction.ParentFaction).IsAtWar = false;
            Memory.SetValue("$faction_was_at_war", new Yarn.Value(false));
        }
예제 #5
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();
            });
        }
예제 #6
0
파일: Main.cs 프로젝트: rcuddy/YarnSpinner
 public virtual void SetValue(string variableName, Value value)
 {
     variableStore.SetValue(variableName, value);
 }
예제 #7
0
 public virtual void SetNumber(string variableName, float number)
 {
     variableStore.SetValue(variableName, new Value(number));
 }
예제 #8
0
 public virtual void SetValue(string variableName, float floatValue)
 {
     variableStore.SetValue(variableName, floatValue);
 }