Class IdleAtSettlementMission

  • All Implemented Interfaces:
    java.lang.Comparable<FreeColObject>, ObjectWithId

    public class IdleAtSettlementMission
    extends Mission
    Mission for idling in a settlement.
    • Field Detail

      • logger

        private static final java.util.logging.Logger logger
      • tag

        private static final java.lang.String tag
        The tag for this mission.
        See Also:
        Constant Field Values
    • Constructor Detail

      • IdleAtSettlementMission

        public IdleAtSettlementMission​(AIMain aiMain,
                                       AIUnit aiUnit)
        Creates a mission for the given AIUnit.
        Parameters:
        aiMain - The main AI-object.
        aiUnit - The AIUnit this mission is created for.
      • IdleAtSettlementMission

        public IdleAtSettlementMission​(AIMain aiMain,
                                       AIUnit aiUnit,
                                       FreeColXMLReader xr)
                                throws javax.xml.stream.XMLStreamException
        Creates a new IdleAtSettlementMission from a reader.
        Parameters:
        aiMain - The main AI-object.
        aiUnit - The AIUnit this mission is created for.
        xr - The input stream containing the XML.
        Throws:
        javax.xml.stream.XMLStreamException - if a problem was encountered during parsing.
        See Also:
        FreeColObject.readFromXML(net.sf.freecol.common.io.FreeColXMLReader)
    • Method Detail

      • isSafe

        private boolean isSafe()
        Is the unit in a safe location where it can idle, or should it move?
        Returns:
        True if the unit is safe.
      • getBaseTransportPriority

        public int getBaseTransportPriority()
        Get the base transport priority for the unit performing this mission.
        Overrides:
        getBaseTransportPriority in class Mission
        Returns:
        A base transport priority.
      • getTarget

        public Location getTarget()
        Gets the target of this mission, if any.
        Specified by:
        getTarget in class Mission
        Returns:
        The target of this mission, or null if none.
      • setTarget

        public void setTarget​(Location target)
        Sets the target of this mission, if any. The actual target is handled in the missions that really have them, this is a helper to make sure the unit is updated.
        Specified by:
        setTarget in class Mission
        Parameters:
        target - The new target of this mission, or null if none.
      • findTarget

        public Location findTarget()
        Finds a new target for this mission.
        Specified by:
        findTarget in class Mission
        Returns:
        A new target for this mission.
      • isOneTime

        public boolean isOneTime()
        Should this mission be considered a mere fallback to be replaced at will? Missions are not one-time by default, true one-time missions must override this routine.
        Overrides:
        isOneTime in class Mission
        Returns:
        False.
      • invalidReason

        public java.lang.String invalidReason()
        Why is this mission invalid? Mission subclasses must implement this routine, which probably should start by checking invalidAIUnitReason. A mission can be invalid for a number of subclass-specific reasons. For example: a seek-and-destroy mission could be invalid because of a improved stance towards the targeted player.
        Specified by:
        invalidReason in class Mission
        Returns:
        A reason for mission invalidity, or null if none found.
      • doMission

        public Mission doMission​(LogBuilder lb)
        Performs the mission.
        Specified by:
        doMission in class Mission
        Parameters:
        lb - A LogBuilder to log to.
        Returns:
        The Mission to continue with, or null if the current mission has completed.
      • getXMLTagName

        public java.lang.String getXMLTagName()
        Get the serialization tag for this object.
        Specified by:
        getXMLTagName in class FreeColObject
        Returns:
        The tag.