public bool canBeBuilt(Location loc) { TrafficVoxel voxel = TrafficVoxel.get(loc); if (voxel == null) { return(false); } RailRoad rr = voxel.railRoad; if (rr == null) { return(false); } RailPattern rp = rr.getPattern(); if (rp.numberOfRails != 2) { return(false); } if (!rp.hasRail(rr.dir1.opposite)) { return(false); } return(rr.dir1.isSharp); }
/// <summary> /// Check if this voxel should have a rail road crossing. /// </summary> /// <returns></returns> private bool shouldHaveCrossing() { if (_railRoad == null || _road == null) { return(false); } RailPattern rp = _railRoad.getPattern(); Direction rdir1 = _railRoad.dir1; if (rp.numberOfRails != 2 || !rp.hasRail(rdir1.opposite)) { return(false); // the rail must be going straight. } if (!rdir1.isSharp) { return(false); // rail must be paralell to X-axis or Y-axis. } if (!_road.hasRoad(rdir1.left90) || !_road.hasRoad(rdir1.right90)) { return(false); // road must be orthogonal to rail road } return(true); }