示例#1
0
    /// <summary>
    /// Given the output position of a wire and an adjacent tile to check
    /// this method returns true if the adjacent tile has a connection
    /// input point that is intersecting the origin tiles output point
    ///
    /// originP = the two connection points of the WireTile that is doing the checking
    /// adjP = the two connection points of the WireTile that is being checked
    /// Adjtile = the direction to the adjacent tile
    /// </summary>
    public static bool IsConnectedToTile(ConnPoint originP, AdjDir adjTile, ConnPoint adjP)
    {
        if (adjTile == AdjDir.SW)
        {
            //SouthWest can't connect yet (future todo)
            return(false);
        }
        if (adjTile == AdjDir.NW)
        {
            //NorthWest can't connect yet (future todo)
            return(false);
        }
        if (adjTile == AdjDir.NE)
        {
            //NorthEast can't connect yet (future todo)
            return(false);
        }
        if (adjTile == AdjDir.SE)
        {
            //SouthEast can't connect yet (future todo)
            return(false);
        }
        if (adjTile == AdjDir.N)
        {
            if (originP.pointA == 1 || originP.pointB == 1)
            {
                if (adjP.pointA == 2 || adjP.pointB == 2)
                {
                    return(true);
                }
            }
        }
        if (adjTile == AdjDir.E)
        {
            if (originP.pointA == 4 || originP.pointB == 4)
            {
                if (adjP.pointA == 8 || adjP.pointB == 8)
                {
                    return(true);
                }
            }
        }
        if (adjTile == AdjDir.S)
        {
            if (originP.pointA == 2 || originP.pointB == 2)
            {
                if (adjP.pointA == 1 || adjP.pointB == 1)
                {
                    return(true);
                }
            }
        }
        if (adjTile == AdjDir.W)
        {
            if (originP.pointA == 8 || originP.pointB == 8)
            {
                if (adjP.pointA == 4 || adjP.pointB == 4)
                {
                    return(true);
                }
            }
        }

        /// <summary>
        ///     Returns a struct with both connection points as members
        ///     the connpoint connection positions are represented using 4 bits to indicate N S E W - 1 2 4 8
        ///     Corners can also be used i.e.: 5 = NE (1 + 4) = 0101
        ///     This is the edge of the location where the input connection enters the turf
        ///     Use 0 for Machines or grills that can conduct electricity from being placed ontop of any wire configuration
        /// </summary>
        if (adjTile == AdjDir.Overlap)
        {
            if (originP.pointA == 0 || originP.pointB == 0)
            {
                if (adjP.pointA == 0 || adjP.pointB == 0)
                {
                    return(true);
                }
            }
        }
        if (adjTile == AdjDir.W || adjTile == AdjDir.S || adjTile == AdjDir.N || adjTile == AdjDir.E)
        {
            //Logger.Log ("got here", Category.Electrical);
            if (originP.pointB == 9 && adjP.pointB == 9)
            {
                //Logger.Log ("yeah It happend", Category.Electrical);
                return(true);
            }
        }
        return(false);
    }
    /// <summary>
    /// Given the output position of a wire and an adjacent tile to check
    /// this method returns true if the adjacent tile has a connection
    /// input point that is intersecting the origin tiles output point
    /// </summary>
    public static bool IsConnectedToTile(Connection ConnectionDirection, ConnPoint AdjacentConnections)
    {
        Connection validDirection;

        switch (ConnectionDirection)
        {
        case Connection.North:
        {
            validDirection = Connection.South;
            break;
        }

        case Connection.NorthEast:
        {
            validDirection = Connection.SouthWest;
            break;
        }

        case Connection.East:
        {
            validDirection = Connection.West;
            break;
        }

        case Connection.SouthEast:
        {
            validDirection = Connection.NorthWest;
            break;
        }

        case Connection.South:
        {
            validDirection = Connection.North;
            break;
        }

        case Connection.SouthWest:
        {
            validDirection = Connection.NorthEast;
            break;
        }

        case Connection.West:
        {
            validDirection = Connection.East;
            break;
        }

        case Connection.NorthWest:
        {
            validDirection = Connection.SouthEast;
            break;
        }

        case Connection.Overlap:
        {
            validDirection = Connection.Overlap;
            break;
        }

        case Connection.MachineConnect:
        {
            validDirection = Connection.MachineConnect;
            break;
        }

        default:
        {
            return(false);
        }
        }

        return(AdjacentConnections.pointA == validDirection || AdjacentConnections.pointB == validDirection);
    }
示例#3
0
    /// <summary>
    /// Given the output position of a wire and an adjacent tile to check
    /// this method returns true if the adjacent tile has a connection
    /// input point that is intersecting the origin tiles output point
    /// </summary>
    public static bool IsConnectedToTile(Connection ConnectionDirection, ConnPoint AdjacentConnections)
    {
        Connection validDirection;

        switch (ConnectionDirection)
        {
        case Connection.North:
        {
            validDirection = Connection.South;
            break;
        }

        case Connection.NorthEast:
        {
            validDirection = Connection.SouthWest;
            break;
        }

        case Connection.East:
        {
            validDirection = Connection.West;
            break;
        }

        case Connection.SouthEast:
        {
            validDirection = Connection.NorthWest;
            break;
        }

        case Connection.South:
        {
            validDirection = Connection.North;
            break;
        }

        case Connection.SouthWest:
        {
            validDirection = Connection.NorthEast;
            break;
        }

        case Connection.West:
        {
            validDirection = Connection.East;
            break;
        }

        case Connection.NorthWest:
        {
            validDirection = Connection.SouthEast;
            break;
        }

        case Connection.Overlap:
        {
            validDirection = Connection.Overlap;
            break;
        }

        case Connection.MachineConnect:
        {
            validDirection = Connection.MachineConnect;
            break;
        }

        default:
        {
            return(false);
        }
        }

        // check if our connection is pointing towards tile with "SurroundingTiles" connection
        // Overlap will never point towards other tile
        if (validDirection != Connection.Overlap)
        {
            return((AdjacentConnections.pointA == validDirection || AdjacentConnections.pointB == validDirection) ||
                   (AdjacentConnections.pointA == Connection.SurroundingTiles || AdjacentConnections.pointB == Connection.SurroundingTiles));
        }

        return(AdjacentConnections.pointA == validDirection || AdjacentConnections.pointB == validDirection);
    }
示例#4
0
    /// <summary>
    /// Given the output position of a wire and an adjacent tile to check
    /// this method returns true if the adjacent tile has a connection
    /// input point that is intersecting the origin tiles output point
    ///
    /// originP = the two connection points of the WireTile that is doing the checking
    /// adjP = the two connection points of the WireTile that is being checked
    /// Adjtile = the direction to the adjacent tile
    /// </summary>
    public static bool IsConnectedToTile(Connection ConnectionDirection, ConnPoint AdjacentConnections)
    {
        switch (ConnectionDirection)
        {
        case Connection.North:
        {
            if (AdjacentConnections.pointA == Connection.South || AdjacentConnections.pointB == Connection.South)
            {
                return(true);
            }
        }
        break;

        case Connection.NorthEast:
        {
            if (AdjacentConnections.pointA == Connection.SouthWest || AdjacentConnections.pointB == Connection.SouthWest)
            {
                return(true);
            }
        }
        break;

        case Connection.East:
        {
            if (AdjacentConnections.pointA == Connection.West || AdjacentConnections.pointB == Connection.West)
            {
                return(true);
            }
        }
        break;

        case Connection.SouthEast:
        {
            if (AdjacentConnections.pointA == Connection.NorthWest || AdjacentConnections.pointB == Connection.NorthWest)
            {
                return(true);
            }
        }
        break;

        case Connection.South:
        {
            if (AdjacentConnections.pointA == Connection.North || AdjacentConnections.pointB == Connection.North)
            {
                return(true);
            }
        }
        break;

        case Connection.SouthWest:
        {
            if (AdjacentConnections.pointA == Connection.NorthEast || AdjacentConnections.pointB == Connection.NorthEast)
            {
                return(true);
            }
        }
        break;

        case Connection.West:
        {
            if (AdjacentConnections.pointA == Connection.East || AdjacentConnections.pointB == Connection.East)
            {
                return(true);
            }
        }
        break;

        case Connection.NorthWest:
        {
            if (AdjacentConnections.pointA == Connection.SouthEast || AdjacentConnections.pointB == Connection.SouthEast)
            {
                return(true);
            }
        }
        break;

        case Connection.Overlap:
        {
            if (AdjacentConnections.pointA == Connection.Overlap || AdjacentConnections.pointB == Connection.Overlap)
            {
                return(true);
            }
        }
        break;

        case Connection.MachineConnect:
        {
            if (AdjacentConnections.pointA == Connection.MachineConnect || AdjacentConnections.pointB == Connection.MachineConnect)
            {
                return(true);
            }
        }
        break;
        }
        return(false);
    }
示例#5
0
    public static List <IElectricityIO> FindPossibleConnections(Vector2 searchVec, Matrix matrix, HashSet <PowerTypeCategory> CanConnectTo, ConnPoint ConnPoints)
    {
        List <IElectricityIO> possibleConns = new List <IElectricityIO>();
        List <IElectricityIO> connections   = new List <IElectricityIO>();
        int progress = 0;

        searchVec.x -= 1;
        searchVec.y -= 1;
        for (int x = 0; x < 3; x++)
        {
            for (int y = 0; y < 3; y++)
            {
                Vector3Int pos = new Vector3Int((int)searchVec.x + x,
                                                (int)searchVec.y + y, 0);
                var conns = matrix.GetElectricalConnections(pos);
                foreach (IElectricityIO io in conns)
                {
                    possibleConns.Add(io);
                    if (CanConnectTo.Contains
                            (io.InData.Categorytype))
                    {
                        //Check if InputPosition and OutputPosition connect with this wire
                        if (ConnectionMap.IsConnectedToTile(ConnPoints, (AdjDir)progress, io.GetConnPoints()))
                        {
                            connections.Add(io);
                        }
                    }
                }
                progress++;
            }
        }
        return(connections);
    }
    public static HashSet <ElectricalOIinheritance> FindPossibleConnections(Vector2 searchVec, Matrix matrix, HashSet <PowerTypeCategory> CanConnectTo, ConnPoint ConnPoints, ElectricalOIinheritance OIinheritance)
    {
        HashSet <ElectricalOIinheritance> connections = new HashSet <ElectricalOIinheritance>();

        connections = SwitchCaseConnections(searchVec, matrix, CanConnectTo, ConnPoints.pointA, OIinheritance);
        connections.UnionWith(SwitchCaseConnections(searchVec, matrix, CanConnectTo, ConnPoints.pointB, OIinheritance));
        return(connections);
    }
 /// <summary>
 /// Given the output position of a wire and an adjacent tile to check
 /// this method returns true if the adjacent tile has a connection
 /// input point that is intersecting the origin tiles output point
 ///
 /// originP = the two connection points of the WireTile that is doing the checking
 /// adjP = the two connection points of the WireTile that is being checked
 /// Adjtile = the direction to the adjacent tile
 /// </summary>
 public static bool IsConnectedToTile(ConnPoint originP, AdjDir adjTile, ConnPoint adjP)
 {
     if (adjTile == AdjDir.SW)
     {
         //SouthWest can't connect yet (future todo)
         return(false);
     }
     if (adjTile == AdjDir.NW)
     {
         //NorthWest can't connect yet (future todo)
         return(false);
     }
     if (adjTile == AdjDir.NE)
     {
         //NorthEast can't connect yet (future todo)
         return(false);
     }
     if (adjTile == AdjDir.SE)
     {
         //SouthEast can't connect yet (future todo)
         return(false);
     }
     if (adjTile == AdjDir.N)
     {
         if (originP.pointA == 1 || originP.pointB == 1)
         {
             if (adjP.pointA == 2 || adjP.pointB == 2)
             {
                 return(true);
             }
         }
     }
     if (adjTile == AdjDir.E)
     {
         if (originP.pointA == 4 || originP.pointB == 4)
         {
             if (adjP.pointA == 8 || adjP.pointB == 8)
             {
                 return(true);
             }
         }
     }
     if (adjTile == AdjDir.S)
     {
         if (originP.pointA == 2 || originP.pointB == 2)
         {
             if (adjP.pointA == 1 || adjP.pointB == 1)
             {
                 return(true);
             }
         }
     }
     if (adjTile == AdjDir.W)
     {
         if (originP.pointA == 8 || originP.pointB == 8)
         {
             if (adjP.pointA == 4 || adjP.pointB == 4)
             {
                 return(true);
             }
         }
     }
     if (adjTile == AdjDir.Overlap)
     {
         if (originP.pointA == 0 || originP.pointB == 0 ||
             originP.pointA == 1 && originP.pointB == 2 ||
             originP.pointA == 2 && originP.pointB == 1 ||
             originP.pointA == 4 && originP.pointB == 8 ||
             originP.pointA == 8 && originP.pointB == 4)
         {
             if (adjP.pointA == 0 || adjP.pointB == 0)
             {
                 return(true);
             }
         }
     }
     if (adjTile == AdjDir.W || adjTile == AdjDir.S || adjTile == AdjDir.N || adjTile == AdjDir.E)
     {
         //Logger.Log ("got here", Category.Electrical);
         if (originP.pointB == 9 && adjP.pointB == 9)
         {
             //Logger.Log ("yeah It happend", Category.Electrical);
             return(true);
         }
     }
     return(false);
 }
示例#8
0
    /// <summary>
    /// Given the output position of a wire and an adjacent tile to check
    /// this method returns true if the adjacent tile has a connection
    /// input point that is intersecting the origin tiles output point
    ///
    /// originP = the two connection points of the WireTile that is doing the checking
    /// adjP = the two connection points of the WireTile that is being checked
    /// Adjtile = the direction to the adjacent tile
    /// </summary>
    public static bool IsConnectedToTile(ConnPoint originP, AdjDir adjTile, ConnPoint adjP)
    {
        if (adjTile == AdjDir.SW)
        {
            //SouthWest can't connect yet (future todo)
            return(false);
        }
        if (adjTile == AdjDir.NW)
        {
            //NorthWest can't connect yet (future todo)
            return(false);
        }
        if (adjTile == AdjDir.NE)
        {
            //NorthEast can't connect yet (future todo)
            return(false);
        }
        if (adjTile == AdjDir.SE)
        {
            //SouthEast can't connect yet (future todo)
            return(false);
        }
        if (adjTile == AdjDir.N)
        {
            if (originP.pointA == 1 || originP.pointB == 1)
            {
                if (adjP.pointA == 2 || adjP.pointB == 2)
                {
                    return(true);
                }
            }
        }
        if (adjTile == AdjDir.E)
        {
            if (originP.pointA == 4 || originP.pointB == 4)
            {
                if (adjP.pointA == 8 || adjP.pointB == 8)
                {
                    return(true);
                }
            }
        }
        if (adjTile == AdjDir.S)
        {
            if (originP.pointA == 2 || originP.pointB == 2)
            {
                if (adjP.pointA == 1 || adjP.pointB == 1)
                {
                    return(true);
                }
            }
        }
        if (adjTile == AdjDir.W)
        {
            if (originP.pointA == 8 || originP.pointB == 8)
            {
                if (adjP.pointA == 4 || adjP.pointB == 4)
                {
                    return(true);
                }
            }
        }
        if (adjTile == AdjDir.Overlap)
        {
            if (originP.pointA == 0 || originP.pointB == 0 ||
                originP.pointA == 1 && originP.pointB == 2 ||
                originP.pointA == 2 && originP.pointB == 1 ||
                originP.pointA == 4 && originP.pointB == 8 ||
                originP.pointA == 8 && originP.pointB == 4)
            {
                if (adjP.pointA == 0 || adjP.pointB == 0)
                {
                    return(true);
                }
            }
        }

        return(false);
    }