/** * Adjusts the connections value based on the given new tile. * Returns whether value changed. */ private bool UpdateSingleConnection(Direction direction, PlacedTileObject placedObject) { SetPerpendicularBlocked(true); bool isConnected = (placedObject && placedObject.HasAdjacencyConnector() && placedObject.GetGenericType() == TileObjectGenericType.Wall); return(adjacencyMap.SetConnection(direction, new AdjacencyData(TileObjectGenericType.None, TileObjectSpecificType.None, isConnected))); }
/** * Adjusts the connections value based on the given new tile. * Returns whether value changed. */ private bool UpdateSingleConnection(Direction direction, PlacedTileObject placedObject) { SetPerpendicularBlocked(true); bool isConnected = (placedObject && placedObject.HasAdjacencyConnector() && placedObject.GetGenericType() == "wall"); return(adjacents.UpdateDirection(direction, isConnected, true)); }
/// <summary> /// Update a single direction. /// </summary> /// <param name="dir"></param> /// <param name="placedObject"></param> /// <returns></returns> private bool UpdateSingleConnection(Direction dir, PlacedTileObject placedObject) { // For some reason called before OnAwake() EnsureInit(); UpdateBlockedFromEditor(); bool isConnected = false; if (placedObject) { isConnected = (placedObject && placedObject.HasAdjacencyConnector()); // If cross connect is allowed, we only allow it to connect when the object type matches the connector type if (CrossConnectAllowed) { isConnected &= (placedObject.GetGenericType() == genericType && genericType != ""); } else { isConnected &= (placedObject.GetGenericType() == genericType || genericType == null); } // Check for specific isConnected &= (placedObject.GetSpecificType() == specificType || specificType == ""); isConnected &= (AdjacencyBitmap.Adjacent(blockedConnections, dir) == 0); } bool isUpdated = adjacents.UpdateDirection(dir, isConnected, true); SyncAdjacentConnections(adjacents.Connections, adjacents.Connections); // Cross connect will override adjacents for other layers, so return isConnected instead. if (CrossConnectAllowed) { return(isConnected); } else { return(isUpdated); } }
/// <summary> /// Update a single direction. /// </summary> /// <param name="dir"></param> /// <param name="placedObject"></param> /// <returns></returns> private bool UpdateSingleConnection(Direction dir, PlacedTileObject placedObject) { // For some reason called before OnAwake() EnsureInit(); UpdateBlockedFromEditor(); bool isConnected = false; if (placedObject) { isConnected = (placedObject && placedObject.HasAdjacencyConnector()); // If cross connect is allowed, we only allow it to connect when the object type matches the connector type if (CrossConnectAllowed) { isConnected &= placedObject.GetGenericType() == genericType && genericType != TileObjectGenericType.None; } else { isConnected &= placedObject.GetGenericType() == genericType || genericType == TileObjectGenericType.None; } // Check for specific isConnected &= placedObject.GetSpecificType() == specificType || specificType == TileObjectSpecificType.None; isConnected &= ((blockedConnections >> (int)dir) & 0x1) == 0; } bool isUpdated = adjacencyMap.SetConnection(dir, new AdjacencyData(TileObjectGenericType.None, TileObjectSpecificType.None, isConnected)); byte connections = adjacencyMap.SerializeToByte(); SyncAdjacentConnections(connections, connections); // Cross connect will override adjacents for other layers, so return isConnected instead. return(CrossConnectAllowed ? isConnected : isUpdated); }