Class UnitRoutePlanner


  • public class UnitRoutePlanner
    extends java.lang.Object
    Handles user input for changing unit movement orders.
    Author:
    Andreas, stm
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  UnitRoutePlanner.LandCosts
      Cost function for overland movement.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean canPlan​(Unit unit)
      Returns true if this unit can move at all and is of a privileged faction.
      java.util.List<java.lang.String> getOrders​(Unit unit, GameData data, CoordinateID start, CoordinateID destination, java.awt.Component ui, boolean useRange, int mode, boolean useVorlage)
      Creates movement orders for a unit.
      boolean planUnitRoute​(Unit unit, GameData data, java.awt.Component ui, java.util.Collection<Unit> otherUnits, RoutingDialogDataPicker picker)
      Shows a dialog that lets the user select a destination for the unit and adds according movement orders to all provided units.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UnitRoutePlanner

        public UnitRoutePlanner()
    • Method Detail

      • canPlan

        public static boolean canPlan​(Unit unit)
        Returns true if this unit can move at all and is of a privileged faction.
      • planUnitRoute

        public boolean planUnitRoute​(Unit unit,
                                     GameData data,
                                     java.awt.Component ui,
                                     java.util.Collection<Unit> otherUnits,
                                     RoutingDialogDataPicker picker)
        Shows a dialog that lets the user select a destination for the unit and adds according movement orders to all provided units.
        Parameters:
        unit - This unit is used as a reference for determining speed
        data - GameData containing the units
        ui - The Component that is used as parent for the Dialog.
        otherUnits - The created orders will also be added to these units.
        picker - The user dialog that will be displayed
        Returns:
        true if orders were changed (i.e., the user didn't abort and a path existed)
      • getOrders

        public java.util.List<java.lang.String> getOrders​(Unit unit,
                                                          GameData data,
                                                          CoordinateID start,
                                                          CoordinateID destination,
                                                          java.awt.Component ui,
                                                          boolean useRange,
                                                          int mode,
                                                          boolean useVorlage)
        Creates movement orders for a unit.
        Parameters:
        unit - The unit for which a route is planned
        data - GameData containing the units
        start - The region where to start, not necessarily equal to the ship's region
        destination - The target region
        ui - The parent component for message panes
        useRange - If this is true, the orders are split into multiple orders, so that the ship's range is not exceeded.
        mode - a combination of RoutePlanner.MODE_CONTINUOUS, RoutePlanner.MODE_RETURN, RoutePlanner.MODE_STOP
        useVorlage - If this is true, Vorlage meta commands are produced.
        Returns:
        The list of new orders.