Adjusted TileProperties to prevent issues with double-adding or double-removing the same direction, not that this should happen.

main
Bryson Zimmerman 11 months ago
parent bf63f78a9f
commit 55e1f66daa

@ -19,14 +19,15 @@ value class TileProperties(val connections: Int) {
} }
//Remove a direction from the list of connections //Remove a direction from the list of connections
@SuppressWarnings
fun remove(dir: Directions): TileProperties { fun remove(dir: Directions): TileProperties {
return this - dir return TileProperties(connections and(dir.dir.inv()))
} }
//Add a direction to the list of connections //Add a direction to the list of connections
//Should only be accessed by the Tile class //Should only be accessed by the Tile class
fun add(dir: Directions): TileProperties { fun add(dir: Directions): TileProperties {
return this + dir return TileProperties(this.connections or(dir.dir))
} }
operator fun plus(dir: Directions): TileProperties { operator fun plus(dir: Directions): TileProperties {

Loading…
Cancel
Save