protected override IEnumerator RespondToCommandInternal(string inputCommand)
    {
        if (!inputCommand.StartsWith("cut ", StringComparison.InvariantCultureIgnoreCase))
        {
            yield break;
        }
        inputCommand = inputCommand.Substring(4);

        foreach (Match wireIndexString in Regex.Matches(inputCommand, @"[1-6]"))
        {
            if (!int.TryParse(wireIndexString.Value, out int wireIndex))
            {
                continue;
            }
            wireIndex--;

            if (wireIndex >= 0 && wireIndex < _wires.Length)
            {
                if (_wires[wireIndex].Snipped)
                {
                    continue;
                }

                yield return(wireIndexString.Value);

                if (Canceller.ShouldCancel)
                {
                    Canceller.ResetCancel();
                    yield break;
                }
                VennSnippableWire wire = _wires[wireIndex];
                yield return(DoInteractionClick(wire, string.Format("cutting wire {0}", wireIndexString.Value)));
            }
        }
    }
예제 #2
0
    protected internal override IEnumerator RespondToCommandInternal(string inputCommand)
    {
        inputCommand = inputCommand.Trim();
        if (!inputCommand.StartsWith("cut ", StringComparison.InvariantCultureIgnoreCase))
        {
            yield break;
        }
        inputCommand = inputCommand.Substring(4);

        foreach (Match wireIndexString in Regex.Matches(inputCommand, @"[1-6]"))
        {
            if (!int.TryParse(wireIndexString.Value, out int wireIndex))
            {
                continue;
            }
            wireIndex--;

            if (wireIndex < 0 || wireIndex >= _wires.Length)
            {
                continue;
            }
            if (_wires[wireIndex].Snipped)
            {
                continue;
            }

            yield return(wireIndexString.Value);

            yield return("trycancel");

            VennSnippableWire wire = _wires[wireIndex];
            yield return(DoInteractionClick(wire, $"cutting wire {wireIndexString.Value}"));
        }
    }
 /// <summary>Attaches this instance to the specified <see cref="VennSnippableWire"/>, allowing events to be received from the wire.</summary>
 public void Attach(VennSnippableWire wire) => wire.ParentComponent = this;