fix problems when drawing a road from a node to itself
1 parent f438491 commit b7f4bbeddf591c37dd7156cc8556ad8a5689ff9d
@biosfood biosfood authored on 22 Feb 2022
Showing 1 changed file
View
20
Assets/Scripts/Roads/Roads.cs
} else {
endNode = new CustomNode(groundPosition, transform, config);
}
Road road = new Road(pullingNode, endNode, config);
if (! pullingNode.roads.Contains(road) && pullingNode != endNode) {
if (pullingNode.roads.Contains(road)) {
Road other = pullingNode.roads.Find(it => road.Equals(it));
if (other.nodes[0] != road.nodes[0]) {
other.nodes = road.nodes;
other.update(true);
}
} else if (pullingNode != endNode) {
pullingNode.roads.Add(road);
endNode.roads.Add(road);
road.initialize(transform);
} else {
Road other = pullingNode.roads.Find(it => road.Equals(it));
if (other.nodes[0] != road.nodes[0]) {
other.nodes = road.nodes;
other.update(false);
}
}
pullingNode = null;
}