-
Notifications
You must be signed in to change notification settings - Fork 7
Plant area of effect component
Tom edited this page Oct 3, 2023
·
6 revisions
This component allows plants to have an area that can detect other entities and effect them. The unique effects that plants have are based on the type of plant it is applied to and the current growth stage of the plant. The effects include a healing, poison, eating, and dead/decay. This component is very similar to the InteractionDetector component but it has been specialised just for plants.
-
private float radius
: The radius of the area of effect. -
private String effectType
: The type of effect to be implemented. -
private List<Entity> entitiiesInRange
: List of entities within range. -
private CircleShape shape
: Circle shape of the area.
-
public PlantAreaOfEffectComponent(float radius, String effectType)
: Constructor for the component, initialises the radius and effect type variables. -
public void create()
: Sets up a radius for the collider and listens to relevant services. -
private void hourlyEffect()
: Triggered every hour of in game time and checks if any hourly effects need to be executed. -
private void minuteUpdate()
: Triggered every minute of in game time and checks if any effects need to be executed. -
private void onCollisionStart(Fixture me, Fixture other)
: Adds entity to entitiesInRange on collision start. -
private void onCollisionEnd(Fixture me, Fixture other)
: Removes an entity from the entities in range list on collision end. -
public List<Entity> getEntitiesInRange()
: Get the list of entities in range. -
private void decayAndDeadEffect()
: Effect that is triggered when a plant has entered the decaying or dead growth stage. -
private void healthEffect()
: Effect that increases/decreases the health of plants, animals and the player. -
private void poisonEffect()
: Effect that poisons the player and any animals in the area. -
private void eatEffect()
: Effect that allows the space snapper to eat any animals. -
private void soundEffect()
: Plays a nearby sound if the player comes near the plant. -
public void setEffectType()
: Update the current effect being executed.
To incorporate the PlantAreaOfEffectClass into the plant system:
1. Import the necessary classes
import com.csse3200.game.components.plants.PlantAreaOfEffectComponent;
**2. Add the PlantAreaOfEffectComponent to a plant entity **
plant.addComponent(new PlantAreaOfEffectComponent(2f, "decay");