Class TooltipSystem.TooltipComponent

java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.tooltip.TooltipSystem.TooltipComponent
Enclosing class:
TooltipSystem

public static class TooltipSystem.TooltipComponent extends Component
Component that handles tooltip detection and triggering. Add this component to any entity that should display a tooltip when the player approaches. The component automatically: - Creates a HitboxComponent if the entity doesn't have one - Detects when the player enters/exits the trigger area - Triggers global events that TooltipDisplay listens for Usage examples: - Basic: new TooltipComponent("Press E to interact") - With style: new TooltipComponent("Dangerous!", TooltipStyle.WARNING) - With custom area: new TooltipComponent("Boss", TooltipStyle.WARNING, 4.0f, 3.0f)
  • Constructor Details

    • TooltipComponent

      public TooltipComponent(String text)
      Creates a tooltip with default style and auto-sized trigger area
      Parameters:
      text - The text to display in the tooltip
    • TooltipComponent

      public TooltipComponent(String text, TooltipSystem.TooltipStyle style)
      Creates a tooltip with custom style and auto-sized trigger area
      Parameters:
      text - The text to display in the tooltip
      style - The visual style for the tooltip
    • TooltipComponent

      public TooltipComponent(String text, TooltipSystem.TooltipStyle style, float widthMultiplier, float heightMultiplier)
      Creates a tooltip with custom style and trigger area size
      Parameters:
      text - The text to display in the tooltip
      style - The visual style for the tooltip
      widthMultiplier - Multiplier for trigger area width (relative to entity)
      heightMultiplier - Multiplier for trigger area height (relative to entity)
  • Method Details

    • getText

      public String getText()
      Gets the tooltip text.
      Returns:
      the text displayed in the tooltip
    • getStyle

      public TooltipSystem.TooltipStyle getStyle()
      Gets the tooltip style
      Returns:
      the style of the tooltip
    • create

      public void create()
      Description copied from class: Component
      Called when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished.
      Overrides:
      create in class Component
    • update

      public void update()
      Description copied from class: Component
      Called once per frame of the game, and should be used for most component logic. Not called if component is disabled.
      Overrides:
      update in class Component
    • getTriggerZoneEntity

      public Entity getTriggerZoneEntity()
      Gets the trigger zone entity for manual spawning if needed
      Returns:
      the trigger zone entity, or null if not created
    • dispose

      public void dispose()
      Description copied from class: Component
      Called when the component is disposed. Dispose of any internal resources here.
      Overrides:
      dispose in class Component