Example #1
0
        public void Calculate()
        {
            ConnectivityHelper south     = GetNeighbor(0, 1);
            ConnectivityHelper east      = GetNeighbor(1, 0);
            ConnectivityHelper southeast = GetNeighbor(1, 1);
            bool doEast  = true;
            bool doSouth = true;

            if (doEast && Connects(this, east))
            {
                Connect(this, east, Connectivity.East);
            }
            if (doSouth && Connects(this, south))
            {
                Connect(this, south, Connectivity.South);
            }
            if (doEast && doSouth)
            {
                if (Connects(this, southeast))
                {
                    Connect(this, southeast, Connectivity.SouthEast);
                }
                if (Connects(east, south))
                {
                    Connect(east, south, Connectivity.SouthWest);
                }
            }

            Dirty = false;
        }
Example #2
0
        public static void Disconnect(ConnectivityHelper a, ConnectivityHelper b, Connectivity connection)
        {
            Connectivity rotated = connection.Rotate(4);

            if (a != null)
            {
                a.Connectivity &= ~connection;
            }
            if (b != null)
            {
                b.Connectivity &= ~rotated;
            }
        }
Example #3
0
        public void Clear() //Bulky?
        {
            ConnectivityHelper north     = GetNeighbor(0, -1);
            ConnectivityHelper west      = GetNeighbor(-1, 0);
            ConnectivityHelper northwest = GetNeighbor(-1, -1);

            Disconnect(this, north, Connectivity.North);
            Disconnect(this, west, Connectivity.West);
            Disconnect(this, northwest, Connectivity.NorthWest);
            Disconnect(this, GetNeighbor(1, -1), Connectivity.NorthEast);
            Disconnect(this, GetNeighbor(1, 0), Connectivity.East);
            Disconnect(this, GetNeighbor(1, 1), Connectivity.SouthEast);
            Disconnect(this, GetNeighbor(0, 1), Connectivity.South);
            Disconnect(this, GetNeighbor(-1, 1), Connectivity.SouthWest);
            MarkDirty();
            north?.MarkDirty();
            west?.MarkDirty();
            northwest?.MarkDirty();
        }