Class SpriteItem
- java.lang.Object
-
- com.runemate.game.api.hybrid.local.hud.interfaces.SpriteItem
-
- All Implemented Interfaces:
Identifiable
,Interactable
,Renderable
,Item
,Validatable
public class SpriteItem extends java.lang.Object implements Item, Interactable, Validatable, Renderable
An item represented by a Sprite, typically on a InterfaceComponent
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SpriteItem.Image
Represents the various states an item can take (quantity/stack size), and loads image variations based on those states.static class
SpriteItem.Origin
-
Constructor Summary
Constructors Constructor Description SpriteItem(int id, int quantity)
SpriteItem(int id, int quantity, int index, SpriteItem.Origin origin)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
click()
Clicks this entity in an interactable pointboolean
contains(java.awt.Point point)
Checks if the projected bounds of this entity contains the Point provided.SpriteItem
derive(int quantity)
Derives a pseudo SpriteItem from this SpriteItemboolean
equals(java.lang.Object object)
@Nullable InteractableRectangle
getBounds()
@Nullable ItemDefinition
getDefinition()
The definition of the item.int
getId()
SpriteItem.Image
getImage()
int
getIndex()
@Nullable InteractablePoint
getInteractionPoint(java.awt.Point point)
Gets a point within the entity that can be interacted with.SpriteItem.Origin
getOrigin()
int
getQuantity()
The quantity of the item, also known as stack sizedouble
getVisibility()
Returns a rough estimate of how visible this entity is as a percent (0 to 100)boolean
hasDynamicBounds()
int
hashCode()
boolean
hover()
Moves the mouse over this entityboolean
interact(java.util.regex.Pattern action, java.util.regex.Pattern target)
Attempts to match action and target using Matcher.find() and then interacts with the appropriate menu itemboolean
isValid()
Verifies whether this entity is valid and still exists, typically on the world-graphboolean
isVisible()
Whether the entity is visiblevoid
render(java.awt.Graphics2D g2d)
Renders this entity onto the givenGraphics2D
, use is discouragedvoid
render(javafx.scene.canvas.GraphicsContext gc)
Renders this entity onto the givenGraphicsContext
java.lang.String
toString()
-
Methods inherited from interface com.runemate.game.api.hybrid.entities.details.Interactable
getInteractionPoint, interact, interact, interact, interact, interact, isHovered
-
-
-
-
Constructor Detail
-
SpriteItem
public SpriteItem(int id, int quantity)
-
SpriteItem
public SpriteItem(int id, int quantity, int index, SpriteItem.Origin origin)
-
-
Method Detail
-
derive
public SpriteItem derive(int quantity)
Derives a pseudo SpriteItem from this SpriteItem
-
getBounds
@Nullable public @Nullable InteractableRectangle getBounds()
-
getId
public int getId()
- Specified by:
getId
in interfaceIdentifiable
-
getQuantity
public int getQuantity()
Description copied from interface:Item
The quantity of the item, also known as stack size- Specified by:
getQuantity
in interfaceItem
-
getDefinition
@Nullable public @Nullable ItemDefinition getDefinition()
Description copied from interface:Item
The definition of the item.- Specified by:
getDefinition
in interfaceItem
-
getIndex
public int getIndex()
-
getOrigin
public SpriteItem.Origin getOrigin()
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object object)
- Overrides:
equals
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isValid
public boolean isValid()
Description copied from interface:Validatable
Verifies whether this entity is valid and still exists, typically on the world-graph- Specified by:
isValid
in interfaceValidatable
- Returns:
- true if it's still available, otherwise false
-
isVisible
public boolean isVisible()
Description copied from interface:Interactable
Whether the entity is visible- Specified by:
isVisible
in interfaceInteractable
- Returns:
- true if visible, and false if not visible
-
getVisibility
public double getVisibility()
Description copied from interface:Interactable
Returns a rough estimate of how visible this entity is as a percent (0 to 100)- Specified by:
getVisibility
in interfaceInteractable
-
hasDynamicBounds
public boolean hasDynamicBounds()
- Specified by:
hasDynamicBounds
in interfaceInteractable
-
getInteractionPoint
@Nullable public @Nullable InteractablePoint getInteractionPoint(java.awt.Point point)
Description copied from interface:Interactable
Gets a point within the entity that can be interacted with. Takes into account the direction of movement from the origin point.- Specified by:
getInteractionPoint
in interfaceInteractable
-
contains
public boolean contains(java.awt.Point point)
Description copied from interface:Interactable
Checks if the projected bounds of this entity contains the Point provided.- Specified by:
contains
in interfaceInteractable
- Returns:
-
click
public boolean click()
Description copied from interface:Interactable
Clicks this entity in an interactable point- Specified by:
click
in interfaceInteractable
- Returns:
- true if successfully clicked
-
hover
public boolean hover()
Description copied from interface:Interactable
Moves the mouse over this entity- Specified by:
hover
in interfaceInteractable
- Returns:
- true if the mouse is hovering the entity
-
interact
public boolean interact(java.util.regex.Pattern action, java.util.regex.Pattern target)
Description copied from interface:Interactable
Attempts to match action and target using Matcher.find() and then interacts with the appropriate menu item- Specified by:
interact
in interfaceInteractable
- Parameters:
action
- The pattern to match the action with, if null it's ignoredtarget
- The pattern to match the target with, if null it's ignored
-
render
public void render(java.awt.Graphics2D g2d)
Description copied from interface:Renderable
Renders this entity onto the givenGraphics2D
, use is discouraged- Specified by:
render
in interfaceRenderable
-
render
public void render(javafx.scene.canvas.GraphicsContext gc)
Description copied from interface:Renderable
Renders this entity onto the givenGraphicsContext
- Specified by:
render
in interfaceRenderable
-
getImage
public SpriteItem.Image getImage()
-
-