Class PlantAreaOfEffectComponent
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.PlantAreaOfEffectComponent
- All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable
Class to add an Area of Effect to all plants.
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionPlantAreaOfEffectComponent
(float radius, String effectType) Constructor for the Area of Effect class. -
Method Summary
Modifier and TypeMethodDescriptionvoid
create()
Sets up a radius for the collider and listens to relevant services.Returns a list of entities within the range.float
Returns the radius of the area of effect for the plant.void
onCollisionEnd
(com.badlogic.gdx.physics.box2d.Fixture me, com.badlogic.gdx.physics.box2d.Fixture other) Removes entity from entitiesInRange on collision end.void
onCollisionStart
(com.badlogic.gdx.physics.box2d.Fixture me, com.badlogic.gdx.physics.box2d.Fixture other) Adds entity to entitiesInRange on collision start.void
setEffectType
(String effectType) Update the current effect being executed.void
setRadius
(float radius) Set the radius of the area.Methods inherited from class com.csse3200.game.physics.components.ColliderComponent
dispose, getFixture, getLayer, setAsBox, setAsBox, setAsBoxAligned, setDensity, setFriction, setLayer, setRestitution, setSensor, setShape
Methods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, read, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update, write
-
Constructor Details
-
PlantAreaOfEffectComponent
Constructor for the Area of Effect class.- Parameters:
radius
- - The initial radius of the area.effectType
- - The type of effect.
-
-
Method Details
-
getEffectType
-
setEffectType
Update the current effect being executed.- Parameters:
effectType
- - The effect to be implemented.
-
getRadius
public float getRadius()Returns the radius of the area of effect for the plant.- Returns:
- The radius of the area of effect.
-
setRadius
public void setRadius(float radius) Set the radius of the area.- Parameters:
radius
- - the new radius of the area.
-
getEntitiesInRange
Returns a list of entities within the range.- Returns:
- A list of entities within the range.
-
create
public void create()Sets up a radius for the collider and listens to relevant services.- Overrides:
create
in classHitboxComponent
-
onCollisionStart
public void onCollisionStart(com.badlogic.gdx.physics.box2d.Fixture me, com.badlogic.gdx.physics.box2d.Fixture other) Adds entity to entitiesInRange on collision start. NOTE: This function is copied from the InteractionDetector class, written by someone else.- Parameters:
me
- The fixture of this component.other
- The fixture of the colliding entity.
-
onCollisionEnd
public void onCollisionEnd(com.badlogic.gdx.physics.box2d.Fixture me, com.badlogic.gdx.physics.box2d.Fixture other) Removes entity from entitiesInRange on collision end. NOTE: This function is copied from the InteractionDetector class, written by someone else.- Parameters:
me
- The fixture of this component.other
- The fixture of the colliding entity.
-