public static void AtStartup(RMUD.RuleEngine GlobalRules) { ConversationModule.Settings.ListDiscussedTopics = false; ConversationModule.Settings.AllowRepeats = false; RMUD.Core.OverrideMessage("empty handed", ""); RMUD.Core.OverrideMessage("convo topic prompt", "You could ask <l0>."); GlobalRules.Perform <Player>("list topics") .When(player => SuppressTopics) .Do(player => RMUD.PerformResult.Stop); GlobalRules.Perform <Player>("singleplayer game started") .First .Do((actor) => { //BlockingConversation = true; //RMUD.MudObject.SendMessage(actor, "Sal? Sal? Can you hear me?"); //actor.SetProperty("interlocutor", RMUD.MudObject.GetObject("DanConversation0")); //RMUD.Core.EnqueuActorCommand(actor, "topics"); SwitchPlayerCharacter(RMUD.MudObject.GetObject("Areas.Prologue.Player") as RMUD.Player); RMUD.MudObject.Move(Player, RMUD.MudObject.GetObject("Areas.Lighthouse.Base")); RMUD.Core.EnqueuActorCommand(Player, "look"); //Player.SetProperty("interlocutor", RMUD.MudObject.GetObject("Areas.Prologue.Henrico")); //RMUD.Core.EnqueuActorCommand(Player, "topics"); //BlockingConversation = true; return(RMUD.PerformResult.Stop); }); }
static void Main(string[] args) { try { var engine = new RMUD.RuleEngine(RMUD.NewRuleQueueingMode.ImmediatelyAddNewRules); engine.DeclarePerformRuleBook <TestBase>("test", ""); engine.Perform <TestBase>("test") .Do((thing) => { Console.WriteLine("Base"); return(RMUD.PerformResult.Continue); }); engine.Perform <TestChild>("test") .Do((thing) => { Console.WriteLine("Child"); return(RMUD.PerformResult.Continue); }); Console.WriteLine("Output when given a child:"); engine.ConsiderPerformRule("test", new TestChild()); Console.WriteLine("Output when given a base:"); engine.ConsiderPerformRule("test", new TestBase()); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } Console.ReadKey(); }
static void Main(string[] args) { try { var engine = new RMUD.RuleEngine(RMUD.NewRuleQueueingMode.ImmediatelyAddNewRules); engine.DeclarePerformRuleBook<TestBase>("test", ""); engine.Perform<TestBase>("test") .Do((thing) => { Console.WriteLine("Base"); return RMUD.PerformResult.Continue; }); engine.Perform<TestChild>("test") .Do((thing) => { Console.WriteLine("Child"); return RMUD.PerformResult.Continue; }); Console.WriteLine("Output when given a child:"); engine.ConsiderPerformRule("test", new TestChild()); Console.WriteLine("Output when given a base:"); engine.ConsiderPerformRule("test", new TestBase()); } catch (Exception e) { Console.WriteLine(e.Message); Console.WriteLine(e.StackTrace); } Console.ReadKey(); }
public static void AtStartup(RMUD.RuleEngine GlobalRules) { GlobalRules.Perform <RMUD.PossibleMatch, RMUD.Actor>("before command") .When((m, a) => BlockingConversation == true) .Do((match, actor) => { var command = match["COMMAND"] as RMUD.CommandEntry; if (command.IsNamed("ASK") || command.IsNamed("HELP") || command.IsNamed("TOPICS")) { return(RMUD.PerformResult.Continue); } RMUD.MudObject.SendMessage(actor, "Sal, I really need to talk about this."); RMUD.Core.EnqueuActorCommand(actor, "TOPICS"); return(RMUD.PerformResult.Stop); }) .Name("Can only converse during a blocking conversation rule."); GlobalRules.Perform <Player, RMUD.MudObject, ConversationModule.Topic>("discuss topic") .Do((actor, npc, topic) => { topic.SetProperty("discussed", true); return(RMUD.PerformResult.Continue); }) .Name("Mark topic discussed rule."); GlobalRules.Perform <Player>("list topics") .When(player => SuppressTopics) .Do(player => RMUD.PerformResult.Stop); GlobalRules.Perform <Player>("list topics") .Do(player => { var npc = player.GetProperty <RMUD.NPC>("interlocutor"); var availableTopics = npc.GetPropertyOrDefault <List <RMUD.MudObject> >("conversation-topics", new List <RMUD.MudObject>()).Where(topic => GlobalRules.ConsiderValueRule <bool>("topic available?", player, npc, topic)); if (availableTopics.Count() == 0) { BlockingConversation = false; } return(RMUD.PerformResult.Continue); }) .Name("Unblock game if no available topics rule."); GlobalRules.Perform <Player>("singleplayer game started") .First .Do((actor) => { //BlockingConversation = true; //RMUD.MudObject.SendMessage(actor, "Sal? Sal? Can you hear me?"); //actor.SetProperty("interlocutor", RMUD.MudObject.GetObject("DanConversation0")); //RMUD.Core.EnqueuActorCommand(actor, "topics"); RMUD.MudObject.Move(actor, RMUD.MudObject.GetObject("Start")); RMUD.Core.EnqueuActorCommand(actor, "look"); return(RMUD.PerformResult.Stop); }); }
public static void AtStartup(RMUD.RuleEngine GlobalRules) { GlobalRules.Perform <RMUD.MudObject, Room>("describe") .Do((viewer, item) => { var auto = RMUD.Core.ExecutingCommand.ValueOrDefault("AUTO", false); if (item.TimesViewed > 0 && auto) { RMUD.MudObject.SendMessage(viewer, item.BriefDescription); } else { RMUD.MudObject.SendMessage(viewer, item.Long); } item.TimesViewed += 1; return(RMUD.PerformResult.Stop); }).Name("Choose brief or long description rule."); }