/// <summary> LocationDisambiguator implementation </summary> public bool IsSelectable(Location loc) { if (currentMode == Mode.Station) { return(GroundDisambiguator.theInstance.IsSelectable(loc)); } if (isPlacing) { // align to RRs or the ground if (currentMode == Mode.FatPlatform) { loc += direction.right90; } if (GroundDisambiguator.theInstance.IsSelectable(loc)) { return(true); } RailRoad rr = RailRoad.get(loc); if (rr == null) { return(false); } return(rr.hasRail(direction) && rr.hasRail(direction.opposite)); } else { return(Platform.get(loc) != null); } }
/// <summary> /// LocationDisambiguator implementation. /// Use the base of the slope to disambiguate. /// </summary> /// <param name="loc"></param> /// <returns></returns> public bool isSelectable(Location loc) { if (!isPlacing) { SlopeRailRoad rr = SlopeRailRoad.get(loc); if (rr != null && rr.level < 2) { return(true); } loc.z++; rr = SlopeRailRoad.get(loc); if (rr != null && rr.level >= 2) { return(true); } return(false); } else { // it is always allowed to place it on or under ground if (World.world.getGroundLevel(loc) >= loc.z) { return(true); } // if the new rail road is at the edge of existing rail, // allow. RailRoad rr = RailRoad.get(loc + direction.opposite); if (rr != null && rr.hasRail(direction)) { return(true); } for (int i = 0; i < 4; i++) { loc += direction; } loc.z++; // run the same test to the other end rr = RailRoad.get(loc); if (rr != null && rr.hasRail(direction.opposite)) { return(true); } return(false); } }
private void setupHandler(TrafficVoxel neighbor, Direction d) { RailRoad rr = neighbor.railRoad; if (rr != null && rr.hasRail(d.opposite)) { // connected? neighbor.onCarChanged += new TrafficVoxelHandler(onCarApproaching); } else { // disconnected? neighbor.onCarChanged -= new TrafficVoxelHandler(onCarApproaching); } }