public InputSequenceMatcher(InputSequence sequence) { this.sequence = sequence.Inputs.GetEnumerator(); // Start by advancing the enumerator, makes match() logic simpler if (this.sequence.MoveNext() == false) { // Indicates empty InputSequence complete = true; } }
public bool Match(InputSequence sequence) { var now = DateTime.Now; if (now > lastAttackTime.AddSeconds(secondsBetweenAttacks)) { lastAttackTime = now; return(true); } return(false); }
public bool Match(InputSequence sequence) { // TODO: Thread safety concerns? int index = find(sequence); if (index != -1) { var newLen = buffer.Count - (index + 1); trimBuffer(newLen); } return(index != -1); }
/// <summary> /// Finds the index of the first (i.e oldest) InputState matching /// the provided sequence, or -1 if not found. /// </summary> private int find(InputSequence sequence) { var matcher = new InputSequenceMatcher(sequence); foreach ((InputState state, int index) in buffer.Select((x, i) => (x, i))) { if (matcher.isMatch(state)) { if (matcher.isComplete()) { return(index); } } else { matcher = new InputSequenceMatcher(sequence); } } return(-1); }
public bool Peek(InputSequence sequence) { return(false); }
public bool Peek(InputSequence sequence) { return(find(sequence) != -1); }
public bool Peek(InputSequence sequence) { return(buffer.Peek(sequence)); }
public bool Match(InputSequence sequence) { return(buffer.Match(sequence)); }