Class ItemPermanent

    • Field Detail

      • duration

        protected int duration
        The duration. Initially set to 0.
      • drawDuration

        protected boolean drawDuration
        Flag, if the duration should be drawn on game display (or cockpit).
      • unique

        protected boolean unique
        Flag, if only one item of this kind can be owned.
      • displayInSlot

        protected boolean displayInSlot
        Flag, if item has an image to display on the figure in 2D
      • isPermanentlyActive

        protected boolean isPermanentlyActive
        Flag, if the item should be updated, when on a figures permanent items list.
      • usesUp

        protected boolean usesUp
        Flag, if item is used up by the time. This is set to false for the ComputerFigures internal equipment
      • useText

        protected java.lang.String useText
        The text displayed if the item is used.
      • energyFactor

        protected int energyFactor
        Used for default duration calculation. Energy is divided by this factor, to determine items duration. Default is 1. Set to individual factor in constructor of overriding classes.
    • Constructor Detail

      • ItemPermanent

        public ItemPermanent()
    • Method Detail

      • onBePickedUp

        public final boolean onBePickedUp​(Figure picker,
                                          AnimationInfo animation)
        This method is called, when the item is picked up by a figure. If item can be picked up, a check is performed, if this item is unique and already present, if yes, false is returned, true otherwise
        Overrides:
        onBePickedUp in class Item
        Parameters:
        picker - The figure who picked up the item.
        animation - The AnimationInfo.
        Returns:
        true, if the item can be carried around, false otherwise.
      • isAddingEnergy

        protected boolean isAddingEnergy()
        Should return true for permanent items, that add energy to an already existing item, if this is unique. Not needed for non unique items.
        Returns:
        true by default.
      • beforePickup

        protected boolean beforePickup​(Figure picker,
                                       AnimationInfo animation)
        Called befor picking up a permanent item.
        Parameters:
        picker - The figure picking the item.
        animation - The AnimationInfo.
        Returns:
        true, if the item can be picked up (either if item is unique or picker still has free slots).
      • onBeUsed

        protected final boolean onBeUsed​(Figure user,
                                         AnimationInfo animation)
        If the user user this permanent item, it is added to the permanent item list of the user.
        Overrides:
        onBeUsed in class Item
        Parameters:
        user - The figure using the item
        animation - The AnimationInfo.
        Returns:
        true, if item can be used
      • calculateDuration

        protected int calculateDuration()
        Calculates the duration. Called after energy changes.
        Returns:
        The duration.
      • useUp

        public void useUp​(AnimationInfo animation)
        Uses this item up by removing the energy factor from the items energy.
        Parameters:
        animation - The AnimationInfo.
      • doSpecialUpdate

        protected void doSpecialUpdate​(AnimationInfo animation)
        Performs the update in each round in overridden classes. Recalculates duration.
        Overrides:
        doSpecialUpdate in class Item
        Parameters:
        animation - The AnimationInfo.
      • getUseText

        public java.lang.String getUseText()
        Gets a text to display when used.
        Returns:
        null as default.
      • isPermanentlyActive

        public boolean isPermanentlyActive()
        Returns true, if the item should be updated, when on a figures permanent items list.
        Returns:
        true as default.
      • getSlotImageName

        public java.lang.String getSlotImageName()
        Returns an image name for slot display.
        Returns:
        getImageName()+"_slot"
      • displayInSlot

        public boolean displayInSlot()
        Called to determine if item has an image to display on the figure in 2D display. If true is returned, an image with filename getImageName()+"_slot" is searched and displayed on the figure in 2D display.
        Returns:
        Value of displayInSlot
      • isDrawingDuration

        public boolean isDrawingDuration()
        Checks, if item duration should be drawn.
        Returns:
        true, if duration should be drawn.
      • setDrawDuration

        public void setDrawDuration​(boolean drawDuration)
        Sets the draw duration flag.
        Parameters:
        drawDuration - true, if duration should be drawn.
      • getDuration

        public int getDuration()
        Gets this item duration.
        Returns:
        The duration.
      • setDuration

        public void setDuration​(int duration,
                                AnimationInfo animation)
        Sets the duration for this item. If the item uses up and duration is 0 or below, this item dies.
        Parameters:
        duration - The new duration.
        animation - The AnimationInfo.
      • die

        public void die​(Thing source,
                        DieReason reason,
                        AnimationInfo animation)
        Removes the item as listener.
        Overrides:
        die in class Item
        Parameters:
        source - The source.
        reason - The die reason.
        animation - The Animationinfo.
      • performPermanentEffect

        public void performPermanentEffect​(Figure owner,
                                           AnimationInfo animation)
        Performs the permanent effect of the item, if it can be carried wround permanently. Does nothing.
        Parameters:
        owner - The figure that owns this item.
        animation - The Animationinfo.
      • onDropPermanent

        protected final void onDropPermanent​(Figure oldOwner,
                                             AnimationInfo animation)
        Called if the item is lost.
        Parameters:
        oldOwner - The old owner of the item.
        animation - The Animationinfo.
      • onAddedAsPermanentItem

        protected void onAddedAsPermanentItem​(Figure user,
                                              AnimationInfo animation)
        Should register this item as listener for events when used. Is called during the beUsed. Item subclasses overriding registerListeners() should override unregisterListeners() as well, to unregister when dying. Does nothing by default.
        Parameters:
        user - The figure using the item.
        animation - The Animationinfo.
      • onBeLost

        protected void onBeLost​(Figure oldOwner,
                                AnimationInfo animation)
        Should be overridden in subclasses to unregister figure listeners added in the registerListeners-method. Does nothing by default
        Parameters:
        oldOwner - The old owner of the item.
        animation - The Animationinfo.
      • isUsingUp

        public boolean isUsingUp()
        Checks, if this item uses up.
        Returns:
        Flag, if item uses Up
      • setIsUsingUp

        public void setIsUsingUp​(boolean usesUp)
        Parameters:
        usesUp - the usesUp to set
      • getFigureOverlayImageName

        public java.lang.String getFigureOverlayImageName​(AnimationInfo animation)
        Gets an image name for painting on the figure. Returns null by default for no overlay image.
        Parameters:
        animation - The AnimationInfo.
        Returns:
        The overlay image name or null for no overlay.
      • onReinitForNewLevel

        protected void onReinitForNewLevel​(Figure user)
        Called after a level, if this item is stored in a permanent slot of the figure. Does nothing by default.
        Parameters:
        user - The user
      • isUnique

        public boolean isUnique()
        Checks, if this permament item is unique in the players inventory.
        Returns:
        true, if unique.