Skip to content

Plant sound proximity component

abhat0 edited this page Oct 17, 2023 · 2 revisions

Description

The sound proximity component only allows plants to play sounds when the player is close enough. This will prevent the game from being cluttered with noise from plants.

Variables

  • private final float radius: Radius of the hitbox area
  • private final circleShape shape: shape of the hitbox

Methods

  • public void create(): Sets up the radius for the collider and listen for relevant services.
  • private void onCollisionStart: Check if the entity is a player and tell the plant the player is in range.
  • private void onCollisionEnd: Check if the entity leaving is the player and tell the plant the player is not in range.

Usage

To incorporate the PlantProximityComponent into the plant system:

1. Import the necessary classes

import com.csse3200.game.components.plants.PlantProximityComponent;

2. Add the PlantProximityComponent to a plant entity

plant.addComponent(new PlantProximityComponent());

Test Plan

  • create the setUp method to be run before each test
  • initialize the PlantProximityComponent object
  • mock the necessary dependencies
  • create tests for all methods
Clone this wiki locally