public SelectFromList(Action <T> doWithThing, StandardHeldPrompt calledBy = null) : base(calledBy) { actionToDo = doWithThing; }
/// <summary> /// Find an item that the specified mob can sense and identify from the given text input. /// </summary> /// <param name="input"></param> /// <param name="mob"></param> /// <param name="start"></param> /// <param name="end"></param> /// <param name="onPrompt"></param> /// <param name="addToPrompt"></param> /// <returns></returns> public static Item FindKnownItem(StringWords input, MOB mob, int start, int end, SelectAction onPrompt = null, StandardHeldPrompt addToPrompt = null) //, out RoomLink viaExit { //viaExit = null; //TODO later: When finding items in other rooms, report what direction the item is in. List <Item> options = FindKnownItems(input, mob, start, end); if (options.Count == 1) { return(options[0]); } Client client = mob.Client; if (client == null) { //TODO: Have an NPC say they don't know what item they were told to find? return(null); } if (options.Count == 0) { client.sendMessage("You don't notice a '" + input.StringRange(start, end) + "'"); return(null); } if (onPrompt == null) { client.sendMessage("There are too many things that fit that description."); return(null); } //TODO: Consider an alternative function to move prompt stuff to and add an out bool for prompting instead, not //sure if there's a need for that bool right now though; leave this one without prompt stuff //TODO: Some way to check if the prompt is still valid would be nice too, but not sure how to do that well without // just requiring another function passed into here. Might do that anyways. SelectFromList <Item> itemSelectPrompt = new SelectFromList <Item>(onPrompt.Invoke); if (addToPrompt == null || !addToPrompt.TransitionTo(itemSelectPrompt, true)) { client.Prompt(itemSelectPrompt); } return(null); }