Beispiel #1
0
        private static int ScanForMatch(Command command, int element_index, InputBuffer input, int input_index)
        {
            if (command == null)
            {
                throw new ArgumentNullException(nameof(command));
            }
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            var element = command.Elements[element_index];

            var scanlength = Math.Min(input.Size, command.Time);

            for (var i = input_index; i < scanlength; ++i)
            {
                //Only check for the last element at the top of the input buffer
                if (element_index == command.Elements.Count - 1)
                {
                    if (element.TriggerOnRelease == null)
                    {
                        if (i != input_index)
                        {
                            return(int.MinValue);
                        }
                    }
                    else
                    {
                        if (i - 1 != input_index && i != input_index)
                        {
                            return(int.MinValue);
                        }
                    }
                }

                if (ElementMatch(element, input, i))
                {
                    //If no match, confirm CommandElement.NothingElse before going back a tick in the input.
                    if (element_index < command.Elements.Count - 1)
                    {
                        var nextelement = command.Elements[element_index + 1];
                        if (nextelement.NothingElse && input.AreIdentical(input_index, i) == false)
                        {
                            continue;
                        }
                    }

                    return(i);
                }
            }

            return(int.MinValue);
        }
Beispiel #2
0
		static Int32 ScanForMatch(Command command, Int32 element_index, InputBuffer input, Int32 input_index)
		{
			if (command == null) throw new ArgumentNullException("command");
			if (input == null) throw new ArgumentNullException("input");

			CommandElement element = command.Elements[element_index];

			Int32 scanlength = Math.Min(input.Size, command.Time);

			for (Int32 i = input_index; i < scanlength; ++i)
			{
				//Only check for the last element at the top of the input buffer
				if (element_index == command.Elements.Count - 1)
				{
					if (element.TriggerOnRelease == null)
					{
						if (i != input_index) return Int32.MinValue;
					}
					else
					{
						if (i - 1 != input_index && i != input_index) return Int32.MinValue;
					}
				}

				if (ElementMatch(element, input, i) == true)
				{
					//If no match, confirm CommandElement.NothingElse before going back a tick in the input.
					if (element_index < command.Elements.Count - 1)
					{
						CommandElement nextelement = command.Elements[element_index + 1];
						if (nextelement.NothingElse == true && input.AreIdentical(input_index, i) == false) continue;
					}

					return i;
				}
			}

			return Int32.MinValue;
		}