private static void _political_event(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 'political_event' can only be called from a TradeEnvoy initiated conversation."); return; } var politics = world.Diplomacy.GetPolitics(playerFaction, envoy.OwnerFaction); if (!politics.RecentEvents.Any(ev => ev.Description == (string)Arguments[0].Value)) { politics.RecentEvents.Add(new Diplomacy.PoliticalEvent() { Description = (string)Arguments[0].Value, Change = (float)Arguments[1].Value, Duration = new TimeSpan((int)((float)Arguments[2].Value), 0, 0, 0), Time = world.Time.CurrentDate }); } }
private static void _finalize_trade(YarnEngine State, List <Ancora.AstNode> Arguments, Yarn.MemoryVariableStore Memory) { var transaction = Memory.GetValue("$trade_transaction").AsObject as Trade.TradeTransaction; 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 (transaction == null || envoy == null || playerFaction == null || world == null) { State.PlayerInterface.Output("Command 'finalize_trade' can only be called from a TradeEnvoy initiated conversation."); return; } transaction.Apply(world); world.GoalManager.OnGameEvent(new Goals.Triggers.Trade { PlayerFaction = playerFaction, PlayerGold = transaction.PlayerMoney, PlayerGoods = transaction.PlayerItems, OtherFaction = envoy.OwnerFaction, OtherGold = transaction.EnvoyMoney, OtherGoods = transaction.EnvoyItems }); }
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 _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; }
private static void _pay_employee(YarnEngine State, List <Ancora.AstNode> Arguments, Yarn.MemoryVariableStore Memory) { var employee = Memory.GetValue("$employee"); var creature = employee.AsObject as CreatureAI; if (creature == null) { return; } var bonus = Memory.GetValue("$employee_bonus").AsNumber; creature.AddMoney((decimal)(float)bonus); creature.Faction.AddMoney(-(decimal)(float)bonus); }
private static void _finalize_market(YarnEngine State, List <Ancora.AstNode> Arguments, Yarn.MemoryVariableStore Memory) { var transaction = Memory.GetValue("$trade_transaction").AsObject as Trade.MarketTransaction; 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 (transaction == null || envoy == null || playerFaction == null || world == null) { State.PlayerInterface.Output("Command 'finalize_trade' can only be called from a TradeEnvoy initiated conversation."); return; } transaction.Apply(world); }
private static void _market(YarnEngine State, List <Ancora.AstNode> Arguments, Yarn.MemoryVariableStore Memory) { var realState = State.PlayerInterface as YarnState; // THIS IS A HACK. 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 'trade' can only be called from a TradeEnvoy initiated conversation."); return; } State.PlayerInterface.BeginMarket(envoy, playerFaction); }
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 _declare_war(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 'declare_war' can only be called from a TradeEnvoy initiated conversation."); return; } world.GoalManager.OnGameEvent(new Goals.Triggers.DeclareWar { PlayerFaction = playerFaction, OtherFaction = envoy.OwnerFaction }); }
private static void _end_strike(YarnEngine State, List <Ancora.AstNode> Arguments, Yarn.MemoryVariableStore Memory) { var employee = Memory.GetValue("$employee"); var creature = employee.AsObject as CreatureAI; if (creature == null) { return; } creature.Status.IsOnStrike = false; }
private static void _add_thought(YarnEngine State, List <Ancora.AstNode> Arguments, Yarn.MemoryVariableStore Memory) { var employee = Memory.GetValue("$employee"); var creature = employee.AsObject as CreatureAI; if (creature == null) { return; } creature.Creature.AddThought((string)Arguments[0].Value, new TimeSpan((int)(float)Arguments[2].Value, 0, 0), (float)Arguments[1].Value); }
private static void _recall_envoy(YarnEngine State, List <Ancora.AstNode> Arguments, Yarn.MemoryVariableStore Memory) { var envoy = Memory.GetValue("$envoy").AsObject as TradeEnvoy; if (envoy == null) { State.PlayerInterface.Output("Command 'recall_envoy' can only be called from a TradeEnvoy initiated conversation."); return; } Diplomacy.RecallEnvoy(envoy); }
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(); }); }
private static void _political_event(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 'political_event' can only be called from a TradeEnvoy initiated conversation."); return; } var politics = world.Overworld.GetPolitics(playerFaction.ParentFaction, envoy.OwnerFaction.ParentFaction); if (!politics.HasEvent((string)Arguments[0].Value)) { politics.AddEvent(new PoliticalEvent() { Description = (string)Arguments[0].Value, Change = (float)Arguments[1].Value, }); } }
private static void _add_thought(YarnEngine State, List <Ancora.AstNode> Arguments, Yarn.MemoryVariableStore Memory) { var employee = Memory.GetValue("$employee"); var creature = employee.AsObject as CreatureAI; if (creature == null) { return; } creature.Creature.AddThought(new Thought() { Description = (string)Arguments[0].Value, TimeLimit = new TimeSpan((int)(float)Arguments[2].Value, 0, 0), HappinessModifier = (float)Arguments[1].Value, Type = Thought.ThoughtType.Other, TimeStamp = creature.World.Time.CurrentDate }, false); }
private static void _end_strike(YarnEngine State, List <Ancora.AstNode> Arguments, Yarn.MemoryVariableStore Memory) { var employee = Memory.GetValue("$employee"); var creature = employee.AsObject as CreatureAI; if (creature == null) { return; } creature.Stats.IsOnStrike = false; if (creature.GetRoot().GetComponent <DwarfThoughts>().HasValue(out var thoughts)) { thoughts.Thoughts.RemoveAll(t => t.Description.Contains("paid")); creature.Creature.AddThought("I got paid recently.", new TimeSpan(1, 0, 0, 0), 10.0f); } if (creature is DwarfAI dorf) { dorf.OnPaid(); } }
public virtual Value GetValue(string variableName) { return(variableStore.GetValue(variableName)); }
public virtual float GetNumber(string variableName) { return(variableStore.GetValue(variableName).AsNumber); }