void AddResult( List<CommandVariation> list, CommandVariation CV, MatchRecord record ) { foreach( CommandVariation cv in list ) { // check if already here if ( cv.Cmd == CV.Cmd ) { if ( record.GreaterThan(cv.Record) ) { // swap this record for the one that is better list.Remove (cv); CV.Record = record; list.Add (CV); // this is going to add the new, better variation at the end of the list #if DEBUG_MATCH UnityEngine.Debug.Log (">>>> Replacing " + CV.Cmd + "<" + record.Full + "," + cv.Record.Full + ">"); #endif } else { #if DEBUG_MATCH UnityEngine.Debug.Log (">>>> Ignorning " + CV.Cmd + "<" + record.Full + "," + cv.Record.Full + ">"); #endif } return; } } // check if command is currently available if ( Dispatcher.GetInstance().IsCommandAvailable(CV.Cmd) == false ) return; #if DEBUG_MATCH UnityEngine.Debug.Log (">>>> Adding " + CV.Cmd + "<" + record.Full + ">"); #endif CV.Record = record; list.Add(CV); }
// this method is for adding additional strings to a command void AddVariation( string cmd, List<string> strings ) { bool found = false; if ( variations == null ) variations = new List<CommandVariation>(); foreach(CommandVariation var in variations ) { if ( var.Cmd == cmd ) { found = true; // add list foreach ( string str in strings ) { if ( str != "" && str != null ) var.Variations.Add(str); } } } if ( found == false ) { CommandVariation cv = new CommandVariation(); cv.Cmd = cmd; foreach( string str in strings ) cv.Variations.Add(str); variations.Add(cv); } }