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)); }
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(); }); }
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)); }
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(); }); }
public virtual void SetValue(string variableName, Value value) { variableStore.SetValue(variableName, value); }
public virtual void SetNumber(string variableName, float number) { variableStore.SetValue(variableName, new Value(number)); }
public virtual void SetValue(string variableName, float floatValue) { variableStore.SetValue(variableName, floatValue); }