Exemple #1
0
        /// <summary>
        /// ConnectorOnTileInSpace constructor
        /// </summary>
        /// <param name="tile">Tile on which is this connector placed.</param>
        /// <param name="connector">Base connector from which this connector derives.</param>
        public ConnectorOnTile(Tile tile, Connector connector) 
            : base(connector.Name, connector.Positions, connector.Glue, connector.Angle, connector.Resistance)
        {
            OnTile = tile ?? throw new ArgumentException("Tile cannot be null.");
            // setter to Positions uses OnTile!!!
            Positions = connector.Positions;

            if (OnTile.Vertices is Polygon3D && Positions.Count == 1)
            {
                if (Angle.Radians > 0)
                    Side = Tile.SideType.inside;
                if (Angle.Radians < 0)
                    Side = Tile.SideType.outside;
            }
        }
Exemple #2
0
 /// <summary>
 /// Returns the inside/outside reference point used for search / adding / removal of floating objects
 /// </summary>
 /// <param name="position">Position on tile.</param>
 /// <param name="side">Side of the tile</param>
 /// <returns>Reference point corresponding to the "side" parameter.</returns>
 public Point3D SidePoint(Point3D position, Tile.SideType side)
 {
     return(position + (side == Tile.SideType.inside ? 1 :
                        side == Tile.SideType.outside ? -1 : 0) * MSystem.SideDist * Normal);
 }
Exemple #3
0
        /// <summary>
        /// Gives the reference point close to a given position around which we search for / add / remove floating objects
        /// inside/outside this object. If the object is not 2D, the first argument is returned.
        /// </summary>
        /// <param name="position">Position on tiles (typically of connector or protein)</param>
        /// <param name="side">Side of the tile</param>
        /// <returns>Reference point corresponding to "inside"/"outside" parameter</returns>
        public Point3D SidePoint(Point3D position, Tile.SideType side)
        {
            Polygon3D polygon = Vertices as Polygon3D;

            return(polygon?.SidePoint(position, side) ?? position);
        }
Exemple #4
0
 /// <summary>
 /// Gets the set of floating objects within a reaction distance from a given position on a tile.
 /// Only objects unused in this simulation step are considered.
 /// If the tile is 2D, only floating objects on the inner/outer side are returned as specified by the parameter "isInside"
 /// Otherwise the parameter "isInside" is ignored.
 /// </summary>
 public FloatingObjectsSet GetNearObjects(ProteinOnTileInSpace protein, Tile.SideType side, NamedMultiset targetMultiset)
 {
     return(GetNearObjects(protein.m_tile.SidePoint(protein.Position, side), targetMultiset));
 }
Exemple #5
0
    public static bool dfs(Vector2Int currentPos, Vector2Int endPos)
    {
        if (currentPos == endPos)
        {
            return(true);
        }

        if (currentPos.x < 0 || currentPos.x >= tiles.GetLength(0))
        {
            return(false);
        }
        if (currentPos.y < 0 || currentPos.y >= tiles.GetLength(1))
        {
            return(false);
        }
        if (endPos.x < 0 || endPos.x >= tiles.GetLength(0))
        {
            return(false);
        }
        if (endPos.y < 0 || endPos.y >= tiles.GetLength(1))
        {
            return(false);
        }

        if (visited[currentPos.x, currentPos.y])
        {
            return(false);
        }

        visited[currentPos.x, currentPos.y] = true;

        Tile.SideType side = tiles[currentPos.x, currentPos.y].side[(int)Tile.Direction.N];
        if (side == Tile.SideType.grassRoad || side == Tile.SideType.pavementRoad)
        {
            if (dfs(new Vector2Int(currentPos.x - 1, currentPos.y), endPos))
            {
                return(true);
            }
        }

        side = tiles[currentPos.x, currentPos.y].side[(int)Tile.Direction.S];
        if (side == Tile.SideType.grassRoad || side == Tile.SideType.pavementRoad)
        {
            if (dfs(new Vector2Int(currentPos.x + 1, currentPos.y), endPos))
            {
                return(true);
            }
        }

        side = tiles[currentPos.x, currentPos.y].side[(int)Tile.Direction.E];
        if (side == Tile.SideType.grassRoad || side == Tile.SideType.pavementRoad)
        {
            if (dfs(new Vector2Int(currentPos.x, currentPos.y + 1), endPos))
            {
                return(true);
            }
        }

        side = tiles[currentPos.x, currentPos.y].side[(int)Tile.Direction.W];
        if (side == Tile.SideType.grassRoad || side == Tile.SideType.pavementRoad)
        {
            if (dfs(new Vector2Int(currentPos.x, currentPos.y - 1), endPos))
            {
                return(true);
            }
        }

        return(false);
    }