Class TrainingDummy2DView

java.lang.Object
games.stendhal.client.gui.j2d.entity.Entity2DView<T>
games.stendhal.client.gui.j2d.entity.TrainingDummy2DView
All Implemented Interfaces:
Inspectable, EntityView<NPC>

public class TrainingDummy2DView extends Entity2DView<T>
  • Field Details

    • titleDrawYOffset

      protected int titleDrawYOffset
      for adjusting entity hp bar & title vertical position
    • height

      protected int height
      The drawn height.
    • width

      protected int width
      The drawn width.
    • sprites

      protected Map<Object,Sprite> sprites
      Map of named sprites.
  • Constructor Details

    • TrainingDummy2DView

      public TrainingDummy2DView()
  • Method Details

    • reorderActions

      protected void reorderActions(List<String> list)
      Places "attack" as first option in action context menu.
      Overrides:
      reorderActions in class Entity2DView<NPC>
      Parameters:
      list - The list to reorder.
    • onAction

      public void onAction()
      Perform the default action.
      Specified by:
      onAction in interface EntityView<NPC>
    • getCursor

      public StendhalCursor getCursor()
      Gets the mouse cursor image to use for this entity.
      Specified by:
      getCursor in interface EntityView<NPC>
      Returns:
      StendhalCursor
    • initialize

      public void initialize(NPC entity)
      Specified by:
      initialize in interface EntityView<T extends NPC>
    • getAnimationSprite

      protected Sprite getAnimationSprite()
      Get the full directional animation tile set for this entity.
      Returns:
      A tile sprite containing all animation images.
    • buildActions

      protected void buildActions(List<String> list)
      Build a list of entity specific actions. NOTE: The first entry should be the default.
      Parameters:
      list - The list to populate.
    • update

      protected void update()
      Handle updates.
    • onAction

      public void onAction(ActionType at)
      Perform an action.
      Specified by:
      onAction in interface EntityView<T extends NPC>
      Parameters:
      at - The action.
    • buildSprites

      protected void buildSprites(Map<Object,Sprite> map, Sprite tiles, int width, int height)
      Populate keyed state sprites.
      Parameters:
      map - The map to populate.
      tiles - The master sprite.
      width - The tile width (in pixels).
      height - The tile height (in pixels).
    • createWalkSprite

      protected Sprite createWalkSprite(Sprite tiles, int y, int width, int height)
      Extract a walking animation for a specific row. The source sprite contains 3 animation tiles, but this is converted to 4 frames.
      Parameters:
      tiles - The tile image.
      y - The base Y coordinate.
      width - The frame width.
      height - The frame height.
      Returns:
      A sprite.
    • drawHPbar

      protected void drawHPbar(Graphics2D g2d, int x, int y, int width)
      Draw the entity HP bar.
      Parameters:
      g2d - The graphics context.
      x - The drawn X coordinate.
      y - The drawn Y coordinate.
      width - The drawn width.
    • drawStatusBar

      protected void drawStatusBar(Graphics2D g2d, int x, int y, int width)
      Draw the entity status bar. The status bar show the title and HP bar.
      Parameters:
      g2d - The graphics context.
      x - The drawn X coordinate.
      y - The drawn Y coordinate.
      width - The drawn width.
    • drawTitle

      protected void drawTitle(Graphics2D g2d, int x, int y, int width)
      Draw the entity title.
      Parameters:
      g2d - The graphics context.
      x - The drawn X coordinate.
      y - The drawn Y coordinate.
      width - The drawn width.
    • addShadow

      protected Sprite addShadow(Sprite sprite)
      Draws a shadow under image if shadows are enabled in the client.
      Parameters:
      sprite - The sprite to manipulate.
      Returns:
      Sprite
    • getTilesX

      protected int getTilesX()
      Get the number of tiles in the X axis of the base sprite.
      Returns:
      The number of tiles.
    • getTilesY

      protected int getTilesY()
      Get the number of tiles in the Y axis of the base sprite.
      Returns:
      The number of tiles.
    • isVisibleGhost

      protected boolean isVisibleGhost()
      Determine is the user can see this entity while in ghostmode.
      Returns:
      true if the client user can see this entity while in ghostmode.
    • buildSprites

      protected void buildSprites(NPC entity, Map<Object,Sprite> map)
      Populate keyed state sprites.
      Parameters:
      entity - the entity to build sprites for
      map - The map to populate.
    • draw

      protected void draw(Graphics2D g2d, int x, int y, int width, int height)
      Draw the entity.
      Overrides:
      draw in class Entity2DView<T extends RPEntity>
      Parameters:
      g2d - The graphics context.
      x - The drawn X coordinate.
      y - The drawn Y coordinate.
      width - The drawn entity width.
      height - The drawn entity height.
    • drawTop

      protected void drawTop(Graphics2D g2d, int x, int y, int width, int height)
      Draw the top layer parts of an entity. This will be on down after all other game layers are rendered.
      Overrides:
      drawTop in class Entity2DView<T extends RPEntity>
      Parameters:
      g2d - The graphics context.
      x - The drawn X coordinate.
      y - The drawn Y coordinate.
      width - The drawn entity width.
      height - The drawn entity height.
    • getHeight

      public int getHeight()
      Get the height.
      Overrides:
      getHeight in class Entity2DView<T extends RPEntity>
      Returns:
      The height (in pixels).
    • getVisibility

      protected int getVisibility()
      Get the entity's visibility.
      Overrides:
      getVisibility in class Entity2DView<T extends RPEntity>
      Returns:
      The visibility value (0-100).
    • getWidth

      public int getWidth()
      Get the width.
      Overrides:
      getWidth in class Entity2DView<T extends RPEntity>
      Returns:
      The width (in pixels).
    • getZIndex

      public int getZIndex()
      Determines on top of which other entities this entity should be drawn. Entities with a high Z index will be drawn on top of ones with a lower Z index. Also, players can only interact with the topmost entity.
      Specified by:
      getZIndex in interface EntityView<T extends RPEntity>
      Overrides:
      getZIndex in class Entity2DView<T extends RPEntity>
      Returns:
      The drawing index.
    • setVisibleScreenArea

      public void setVisibleScreenArea(Rectangle area)
      Specified by:
      setVisibleScreenArea in interface EntityView<T extends RPEntity>
      Overrides:
      setVisibleScreenArea in class Entity2DView<T extends RPEntity>
    • getState

      protected Direction getState(NPC entity)
      Get the current model state.
      Parameters:
      entity -
      Returns:
      The model state.
    • isAnimating

      protected boolean isAnimating()
      Determine if this view is currently animatable.
      Overrides:
      isAnimating in class Entity2DView<T extends ActiveEntity>
      Returns:
      true if animating enabled.
    • getSprite

      protected Sprite getSprite(Object state)
      Get a keyed state sprite.
      Parameters:
      state - The state.
      Returns:
      The appropriate sprite for the given state.
    • buildRepresentation

      protected void buildRepresentation(NPC entity)
      Build the visual representation of this entity. This builds all the animation sprites and sets the default frame.
      Overrides:
      buildRepresentation in class Entity2DView<T extends IEntity>
      Parameters:
      entity - the eEntity to build the representation for
    • proceedChangedState

      protected void proceedChangedState(NPC entity)
      Update sprite state of the entity.
      Parameters:
      entity -