// // MapOverlay implementation // public void drawVoxel(QuarterViewDrawer view, DrawContextEx context, Location loc, Point pt) { JunctionRailRoad jrr = JunctionRailRoad.get(loc); if (jrr == null) { return; } // draw an arrow that indicates the direction to go JunctionRoute go; bool isSimple = true; Junction j = controller.getJunction(loc); if (j == null) { go = JunctionRoute.Straight; } else { go = j.defaultRoute; if (j.advancedRules.Count != 0) { isSimple = false; } } // draw an arrow. pt.Y -= 2; jrr.getDirection(go).drawArrow(context.surface, pt, !isSimple); }
public override void onClick(MapViewWindow view, Location loc, Point ab) { JunctionRailRoad jrr = JunctionRailRoad.get(loc); if (jrr != null) { Form dialog = new JunctionConfigDialog(controller.getOrCreateJunction(loc)); dialog.ShowDialog(MainWindow.mainWindow); return; } Voxel v = World.world[loc]; if (v == null) { return; } TrainHarbor harbor = (TrainHarbor)v.queryInterface(typeof(TrainHarbor)); if (harbor != null) { StationHandler handler = controller.getStationHandler(harbor); StationConfigDialog dialog = new StationConfigDialog(handler); dialog.ShowDialog(MainWindow.mainWindow); controller.setStationHandler(harbor, dialog.currentHandler); return; } }
public bool isSelectable(Location loc) { Voxel v = World.world[loc]; if (v == null) { return(false); } // any junctions, platforms, stations are selectable return(JunctionRailRoad.get(loc) != null || v.queryInterface(typeof(TrainHarbor)) != null); }
public override JunctionRoute onJunction(Train train, JunctionRailRoad railRoad) { Junction jc = (Junction)junctions[railRoad.location]; if (jc == null) { // if no configuration is given, go straight as the default behavior return(JunctionRoute.Straight); } // ask it return(jc.determineRoute()); }
// private bool shallMoveForward() { // return isKeyPressed(VK_LEFT) || isKeyPressed(VK_RIGHT) || isKeyPressed(VK_UP); // } public override JunctionRoute onJunction(Train train, JunctionRailRoad railRoad) { Direction dir = train.head.state.asInside().direction; if (isKeyPressed(VK_LEFT) && railRoad.hasRail(dir.left)) { return(JunctionRoute.Curve); } if (isKeyPressed(VK_RIGHT) && railRoad.hasRail(dir.right)) { return(JunctionRoute.Curve); } return(JunctionRoute.Straight); }
/// <summary> /// Removes unused entries from the junctions table. /// </summary> private void refresh() { ArrayList tbr = new ArrayList(); foreach (Location loc in junctions.Keys) { if (JunctionRailRoad.get(loc) == null) { tbr.Add(loc); } } foreach (Location loc in tbr) { junctions.Remove(loc); } }