Package com.csse3200.game.components
Class ParticleEffectComponent
java.lang.Object
com.csse3200.game.components.Component
com.csse3200.game.components.ParticleEffectComponent
- All Implemented Interfaces:
com.badlogic.gdx.utils.Json.Serializable
Component which can be added to entities allowing them to have
ParticleEffect rendering on them and attached
to their body. This also enables the ParticleService to keep track of these entities, rendering their effects
in the game loop.
This component also allows multiple particle effects to be rendered on a single entity ct the one time.-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionCreates a new component with an empty list of effects to render. -
Method Summary
Modifier and TypeMethodDescriptionvoidcreate()Adds event listeners to the component, allowing for effects to be stopped and started.voiddispose()Disposes of the component, freeing all effects and removing the component from the entity.booleaneffectExists(ParticleService.ParticleEffectType effectType) Determines whether aParticleEffectis being tracked by this component with the same type as the givenParticleService.ParticleEffectType.intGets the number of effects that are currently being tracked by the component.voidrender(com.badlogic.gdx.graphics.g2d.SpriteBatch batch, float delta) Renders all the effects that are being managed by the component for this entity.voidstartEffect(ParticleService.ParticleEffectType effectType) Starts aParticleEffecton an entity, enabling this component to control it throughout its lifecyclevoidStops all of the particle effects for this entity, freeing the effects back to theirParticleEffectPools and removing them from theListof effects being tracked.voidstopEffect(ParticleService.ParticleEffectType effectType) Stops rendering an effect on the entity, freeing the effect and giving it back to theParticleEffectPool.voidstopEffectCategory(String category) Stops all particle effects by category in the entity's list of effectsMethods inherited from class com.csse3200.game.components.Component
earlyUpdate, getEntity, read, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update, write
-
Constructor Details
-
ParticleEffectComponent
public ParticleEffectComponent()Creates a new component with an empty list of effects to render.
-
-
Method Details
-
create
public void create()Adds event listeners to the component, allowing for effects to be stopped and started. -
render
public void render(com.badlogic.gdx.graphics.g2d.SpriteBatch batch, float delta) Renders all the effects that are being managed by the component for this entity.- Parameters:
batch- sprite batch to use while renderingdelta- delta time value used to update the particle effects
-
startEffect
Starts aParticleEffecton an entity, enabling this component to control it throughout its lifecycle- Parameters:
effectType- type ofParticleEffectto be added to the entity
-
stopEffect
Stops rendering an effect on the entity, freeing the effect and giving it back to theParticleEffectPool. This will also remove the effect from theListof effects to be controlled by this component.- Parameters:
effectType- type ofParticleEffectto be stopped
-
stopEffectCategory
Stops all particle effects by category in the entity's list of effects- Parameters:
category- category of particle effects
-
stopAllEffects
public void stopAllEffects()Stops all of the particle effects for this entity, freeing the effects back to theirParticleEffectPools and removing them from theListof effects being tracked. -
getNumEffects
public int getNumEffects()Gets the number of effects that are currently being tracked by the component.- Returns:
- number of effects being tracked by this component.
-
effectExists
Determines whether aParticleEffectis being tracked by this component with the same type as the givenParticleService.ParticleEffectType.- Parameters:
effectType- type of particle effect- Returns:
- whether that particle is being tracked
-
dispose
public void dispose()Disposes of the component, freeing all effects and removing the component from the entity.
-