Class PlantProximityComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.physics.components.ColliderComponent
com.csse3200.game.physics.components.HitboxComponent
com.csse3200.game.components.plants.PlantProximityComponent
- All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable
Component to inform the plant when the player is close enough for plant sounds to be played.
This will prevent the game from being clogged up with plant sounds.
-
Field Summary
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcreate()Sets up the radius for the collider and listen for relevant services.floatGets the radius of the hitbox area.com.badlogic.gdx.physics.box2d.CircleShapegetShape()Gets the shape of the hitbox area.voidonCollisionStart(com.badlogic.gdx.physics.box2d.Fixture me, com.badlogic.gdx.physics.box2d.Fixture other) Checks if the entity is the player on collision start.Methods inherited from class com.csse3200.game.physics.components.ColliderComponent
dispose, getFixture, getLayer, setAsBox, setAsBox, setAsBoxAligned, setDensity, setFriction, setLayer, setRestitution, setSensor, setShapeMethods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, read, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update, write
-
Constructor Details
-
PlantProximityComponent
public PlantProximityComponent()Constructor for the plant proximity component. Just used to setting the radius of the area. The radius will be the same for all plants.
-
-
Method Details
-
getRadius
public float getRadius()Gets the radius of the hitbox area.- Returns:
- the radius of the hitbox area.
-
getShape
public com.badlogic.gdx.physics.box2d.CircleShape getShape()Gets the shape of the hitbox area.- Returns:
- the shape of the hitbox area
-
create
public void create()Sets up the radius for the collider and listen for relevant services.- Overrides:
createin classHitboxComponent
-
onCollisionStart
public void onCollisionStart(com.badlogic.gdx.physics.box2d.Fixture me, com.badlogic.gdx.physics.box2d.Fixture other) Checks if the entity is the player on collision start. If the entity is the player then tell the plant that the player is in range.- Parameters:
me- The fixture of this component.other- The fixture of the colliding entity.
-