Mastahg, Can you give an example of proper usage of PreferedRoutine? Specifically, can you set the PreferedRoutine for a single job/class or is it an all or nothing? Currently the property is just a string, so my assumption is that it's an all or nothing deal. Can you add another Enumeration of CombatRoutines to the RoutineManager? Specifically, what I'm looking for is to get a distinct list of CombatRoutines that are loaded for the current user. Right now, if I look at RoutineManager.AllRoutines, and the only CR I have installed is the default Kupo, it will give me an enumeration of Kupo for every class that Kupo supports. If I were to run this code in the console: Code: foreach(var routineName in RoutineManager.AllRoutines.Select(x => x.Name)) { Log(routineName); } I would get something like this: Code: Kupo [Conjurer] Kupo [WhiteMage] Kupo [Lancer] Magitek [Conjurer] Magitek [WhiteMage] etc... The enumeration I'd like to have added would be something like this: Code: foreach(var routineName in RoutineManager.[B]NewEnumerationHere[/B]) { Log(routineName); } which would return Code: Kupo Magitek etc...
That is exactly what you are getting. There is no super class that contains each subclass for kupo. I'm not sure what you mean by all or nothing in this example. We do a case insensitive search for routine names containing the string and that match the current job. So if you set it to "kup" itd pick the proper kupo routine.
What I meant by all or nothing is would it be possible to set Kupo as my preferred CR for Warrior, but Ultima as my preferred CR for Dragoon, and then maybe Kupper as my preferred CR for Bard. It seems like when you talk about a preferred CR, you are talking about a CR in all of the classes it supports, but when you talk about a CR in something like RoutineManager.AllRoutines, you are talking about each Class/Job as it's own CR. Does that make sense? As an example. Let's say I have a combobox on my settings form for a plugin. I want to populate that combobox with all of the possible CR's that are loaded. If I were to just do "combobox1.DataSource = RoutineManager.AllRoutines.Select(x => x.Name);" Then I'm going to get a lot of stuff in there I wouldn't want to see. This is what I'm currently having to do in order to just get a list of CR's that I can use to set the preferred CR: Code: PreferedRoutine_ComboBox.DataSource = BuildCombatRoutineList().ToList(); private static IEnumerable<string> BuildCombatRoutineList() { var retval = new HashSet<string>(); foreach (var routine in RoutineManager.AllRoutines.Select(x => x.Name).Where(x => x != "InvalidRoutineWrapper")) { var index = routine.IndexOf('['); retval.Add(index > 0 ? routine.Substring(0, index) : routine); } retval.Add(string.Empty); return retval; }
Like I said there is no "super" class for combat routines. All the bot sees is every class that inherits from ICombatRoutine. If im understanding you, you want a list that would be like {"ultima","kupo","magitek"} and there just isn't one like that. As for setting the preferedroutine, add a event handler to RoutineManager.PickRoutineFired and check the players current class there and set the string accordingly.
Ok, hopefully last couple of questions: How does it handle instances where the match would return multiple results for the same search string. For instance, I set it to "kup" and when I switch to Bard it finds that I have both "Kupo" and "Kupper" loaded. Which would it pick? Will it gracefully handle situations where it doesn't find a match? For instance, I have a setting that is saved in my plugin for Preferred Routine. The user sets that Setting to "Kupo". The next time they load the plugin, I will try and set the Preferred Routine to "Kupo", but what happens if the user no longer has Kupo loaded as a CR? Will a null reference exception be thrown, or will it just gracefully keep/set the PreferredRoutine to null/string.empty?
If it matches more then one item its going to pick which ever one is first, and since they are stored in a hashset it could be random. if the string doesnt match any then if there is only one for the current job it uses that, otherwise it displays the popup asking the user to pick a routine.