Plant sound proximity component - UQcsse3200/2023-studio-1 GitHub Wiki
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 areaprivate 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
PlantProximityComponentobject - mock the necessary dependencies
- create tests for all methods