Example #1
0
    private IEnumerator CheckForWires(IEnumerable <FloorFace> path)
    {
        var isWireValidCoroutine = new CoroutineWithData <(bool, List <Wire>)>(this, IsPathValid(path));

        yield return(isWireValidCoroutine.Coroutine);

        bool        isWireValid = isWireValidCoroutine.Result.Item1;
        List <Wire> wires       = isWireValidCoroutine.Result.Item2;

        if (!isWireValid)
        {
            Destroy(gameObject);
            yield break;
        }

        if (wires.Any())
        {
            for (int i = 0; i < wires.Count; i++)
            {
                Wire wire = wires[i];
                if (i == 0)
                {
                    wire.AddFaces(path);
                }
                else
                {
                    wires.First().AddWire(wire);
                }
                yield return(null);
            }
            Destroy(gameObject);
        }
        else
        {
            Init(path);
        }
    }