Class EmitterAttributes

All Implemented Interfaces:
Resource, Serializable, Comparable<Resource>

public class EmitterAttributes extends Object implements Serializable, Resource

Represents the data structure for a particle emitter.

This class is used to serialize and configure emitter properties such as color, particle movement, rendering options, and particle life cycle. It supports XML binding for persistent configurations.

See Also:
  • Field Details

    • DEFAULT_COLOR

      public static final Color DEFAULT_COLOR
      Default base color used for emitted particles when no colors are configured.
    • DEFAULT_SPRITESHEET

      public static final String DEFAULT_SPRITESHEET
      Default spritesheet name; empty means no spritesheet is associated.
      See Also:
    • DEFAULT_NAME

      public static final String DEFAULT_NAME
      Default display name assigned to a newly created emitter.
      See Also:
    • DEFAULT_TEXT

      public static final String DEFAULT_TEXT
      Default text content used by text-rendering particles.
      See Also:
    • DEFAULT_ANIMATE_SPRITE

      public static final boolean DEFAULT_ANIMATE_SPRITE
      Default value controlling whether sprite-based particles are animated.
      See Also:
    • DEFAULT_LOOP_SPRITE

      public static final boolean DEFAULT_LOOP_SPRITE
      Default value controlling whether sprite-based particle animations are looped.
      See Also:
    • DEFAULT_FADE

      public static final boolean DEFAULT_FADE
      Default value controlling whether particles fade out over their lifetime.
      See Also:
    • DEFAULT_FADE_ON_COLLISION

      public static final boolean DEFAULT_FADE_ON_COLLISION
      Default value controlling whether particles fade upon collision.
      See Also:
    • DEFAULT_OUTLINE_ONLY

      public static final boolean DEFAULT_OUTLINE_ONLY
      Default value controlling whether shape-based particles are rendered as outlines only.
      See Also:
    • DEFAULT_ANTIALIASING

      public static final boolean DEFAULT_ANTIALIASING
      Default value controlling whether particles are rendered with anti-aliasing.
      See Also:
    • DEFAULT_COLLISION

      public static final Collision DEFAULT_COLLISION
      Default collision behavior applied to emitted particles.
    • DEFAULT_PARTICLE_TYPE

      public static final ParticleType DEFAULT_PARTICLE_TYPE
      Default particle shape/type used when none is specified.
    • DEFAULT_REQUIRED_QUALITY

      public static final Quality DEFAULT_REQUIRED_QUALITY
      Default minimum graphics quality required for the emitter to be rendered.
    • DEFAULT_ORIGIN_ALIGN

      public static final Align DEFAULT_ORIGIN_ALIGN
      Default horizontal alignment of the emitter origin.
    • DEFAULT_ORIGIN_VALIGN

      public static final Valign DEFAULT_ORIGIN_VALIGN
      Default vertical alignment of the emitter origin.
    • DEFAULT_WIDTH

      public static final float DEFAULT_WIDTH
      Default emitter width in pixels.
      See Also:
    • DEFAULT_HEIGHT

      public static final float DEFAULT_HEIGHT
      Default emitter height in pixels.
      See Also:
    • DEFAULT_COLOR_VARIANCE

      public static final float DEFAULT_COLOR_VARIANCE
      Default color variance (0..1) applied per particle.
      See Also:
    • DEFAULT_ALPHA_VARIANCE

      public static final float DEFAULT_ALPHA_VARIANCE
      Default alpha variance (0..1) applied per particle.
      See Also:
    • DEFAULT_UPDATERATE

      public static final int DEFAULT_UPDATERATE
      Default update rate of the emitter in milliseconds.
      See Also:
    • DEFAULT_SPAWNAMOUNT

      public static final int DEFAULT_SPAWNAMOUNT
      Default number of particles spawned per spawn tick.
      See Also:
    • DEFAULT_SPAWNRATE

      public static final int DEFAULT_SPAWNRATE
      Default spawn rate in milliseconds between spawn ticks.
      See Also:
    • DEFAULT_MAXPARTICLES

      public static final int DEFAULT_MAXPARTICLES
      Default maximum number of concurrently alive particles.
      See Also:
    • DEFAULT_DURATION

      public static final int DEFAULT_DURATION
      Default emitter duration in milliseconds; 0 means the emitter runs indefinitely.
      See Also:
    • DEFAULT_MIN_PARTICLE_TTL

      public static final int DEFAULT_MIN_PARTICLE_TTL
      Default minimum time-to-live for a particle in milliseconds.
      See Also:
    • DEFAULT_MAX_PARTICLE_TTL

      public static final int DEFAULT_MAX_PARTICLE_TTL
      Default maximum time-to-live for a particle in milliseconds.
      See Also:
    • DEFAULT_MIN_OFFSET_X

      public static final float DEFAULT_MIN_OFFSET_X
      Default minimum horizontal spawn offset relative to the emitter origin.
      See Also:
    • DEFAULT_MAX_OFFSET_X

      public static final float DEFAULT_MAX_OFFSET_X
      Default maximum horizontal spawn offset relative to the emitter origin.
      See Also:
    • DEFAULT_MIN_OFFSET_Y

      public static final float DEFAULT_MIN_OFFSET_Y
      Default minimum vertical spawn offset relative to the emitter origin.
      See Also:
    • DEFAULT_MAX_OFFSET_Y

      public static final float DEFAULT_MAX_OFFSET_Y
      Default maximum vertical spawn offset relative to the emitter origin.
      See Also:
    • DEFAULT_MIN_DELTA_WIDTH

      public static final float DEFAULT_MIN_DELTA_WIDTH
      Default minimum width delta applied per update to a particle.
      See Also:
    • DEFAULT_MAX_DELTA_WIDTH

      public static final float DEFAULT_MAX_DELTA_WIDTH
      Default maximum width delta applied per update to a particle.
      See Also:
    • DEFAULT_MIN_DELTA_HEIGHT

      public static final float DEFAULT_MIN_DELTA_HEIGHT
      Default minimum height delta applied per update to a particle.
      See Also:
    • DEFAULT_MAX_DELTA_HEIGHT

      public static final float DEFAULT_MAX_DELTA_HEIGHT
      Default maximum height delta applied per update to a particle.
      See Also:
    • DEFAULT_MIN_ACCELERATION_X

      public static final float DEFAULT_MIN_ACCELERATION_X
      Default minimum horizontal acceleration applied to a particle.
      See Also:
    • DEFAULT_MAX_ACCELERATION_X

      public static final float DEFAULT_MAX_ACCELERATION_X
      Default maximum horizontal acceleration applied to a particle.
      See Also:
    • DEFAULT_MIN_ACCELERATION_Y

      public static final float DEFAULT_MIN_ACCELERATION_Y
      Default minimum vertical acceleration applied to a particle.
      See Also:
    • DEFAULT_MAX_ACCELERATION_Y

      public static final float DEFAULT_MAX_ACCELERATION_Y
      Default maximum vertical acceleration applied to a particle.
      See Also:
    • DEFAULT_MIN_ANGLE

      public static final float DEFAULT_MIN_ANGLE
      Default minimum starting angle in degrees of a spawned particle.
      See Also:
    • DEFAULT_MAX_ROTATION

      public static final float DEFAULT_MAX_ROTATION
      Default maximum starting angle in degrees of a spawned particle.
      See Also:
    • DEFAULT_MIN_DELTA_ANGLE

      public static final float DEFAULT_MIN_DELTA_ANGLE
      Default minimum angle delta applied per update to a particle.
      See Also:
    • DEFAULT_MAX_DELTA_ANGLE

      public static final float DEFAULT_MAX_DELTA_ANGLE
      Default maximum angle delta applied per update to a particle.
      See Also:
    • DEFAULT_MIN_VELOCITY_X

      public static final float DEFAULT_MIN_VELOCITY_X
      Default minimum horizontal velocity of a spawned particle.
      See Also:
    • DEFAULT_MAX_VELOCITY_X

      public static final float DEFAULT_MAX_VELOCITY_X
      Default maximum horizontal velocity of a spawned particle.
      See Also:
    • DEFAULT_MIN_VELOCITY_Y

      public static final float DEFAULT_MIN_VELOCITY_Y
      Default minimum vertical velocity of a spawned particle.
      See Also:
    • DEFAULT_MAX_VELOCITY_Y

      public static final float DEFAULT_MAX_VELOCITY_Y
      Default maximum vertical velocity of a spawned particle.
      See Also:
    • DEFAULT_MIN_OUTLINETHICKNESS

      public static final float DEFAULT_MIN_OUTLINETHICKNESS
      Default minimum outline thickness for outline-rendered particles.
      See Also:
    • DEFAULT_MAX_OUTLINETHICKNESS

      public static final float DEFAULT_MAX_OUTLINETHICKNESS
      Default maximum outline thickness for outline-rendered particles.
      See Also:
    • DEFAULT_MIN_WIDTH

      public static final float DEFAULT_MIN_WIDTH
      Default minimum width of a spawned particle.
      See Also:
    • DEFAULT_MAX_WIDTH

      public static final float DEFAULT_MAX_WIDTH
      Default maximum width of a spawned particle.
      See Also:
    • DEFAULT_MIN_HEIGHT

      public static final float DEFAULT_MIN_HEIGHT
      Default minimum height of a spawned particle.
      See Also:
    • DEFAULT_MAX_HEIGHT

      public static final float DEFAULT_MAX_HEIGHT
      Default maximum height of a spawned particle.
      See Also:
  • Constructor Details

    • EmitterAttributes

      public EmitterAttributes()
      Creates a new EmitterAttributes instance and initializes all RangeAttribute fields and other defaults required for the emitter to be rendered and updated correctly.
  • Method Details

    • getAlphaVariance

      public float getAlphaVariance()
      Gets the per-particle alpha variance.
      Returns:
      the alpha variance in the range [0, 1]
    • setAlphaVariance

      public void setAlphaVariance(float alphaVariance)
      Sets the per-particle alpha variance. The value is clamped to the range [0, 1].
      Parameters:
      alphaVariance - the alpha variance to set
    • getCollision

      public Collision getCollision()
      Gets the collision behavior of emitted particles.
      Returns:
      the configured Collision behavior
    • setCollision

      public void setCollision(Collision collision)
      Sets the collision behavior of emitted particles.
      Parameters:
      collision - the Collision behavior to apply
    • getRequiredQuality

      public Quality getRequiredQuality()
      Gets the minimum graphics Quality required for this emitter to be rendered.
      Returns:
      the required quality
    • setRequiredQuality

      public void setRequiredQuality(Quality minQuality)
      Sets the minimum graphics Quality required for this emitter to be rendered.
      Parameters:
      minQuality - the minimum required quality
    • getColorVariance

      public float getColorVariance()
      Gets the per-particle color variance.
      Returns:
      the color variance in the range [0, 1]
    • setColorVariance

      public void setColorVariance(float colorVariance)
      Sets the per-particle color variance. The value is clamped to the range [0, 1].
      Parameters:
      colorVariance - the color variance to set
    • getColors

      public List<String> getColors()
      Gets the configured list of color strings used when spawning particles.
      Returns:
      the list of encoded color strings
    • getDecodedColors

      public List<Color> getDecodedColors()
      Gets the decoded Color list derived from the configured color strings. The result is cached after the first call.
      Returns:
      the decoded colors, falling back to DEFAULT_COLOR for entries that cannot be decoded
    • setColors

      public void setColors(List<String> colors)
      Sets the list of color strings used when spawning particles and invalidates the decoded color cache.
      Parameters:
      colors - the list of encoded color strings
    • setColors

      public void setColors(Color... colors)
      Sets the colors used when spawning particles by encoding the given AWT colors.
      Parameters:
      colors - the colors to apply
    • getDeltaHeight

      public RangeAttribute<Float> getDeltaHeight()
      Gets the per-particle height delta parameter.
      Returns:
      the height delta RangeAttribute
    • setDeltaHeight

      public void setDeltaHeight(RangeAttribute<Float> deltaHeight)
      Sets the per-particle height delta parameter.
      Parameters:
      deltaHeight - the height delta parameter to set
    • getDeltaWidth

      public RangeAttribute<Float> getDeltaWidth()
      Gets the per-particle width delta parameter.
      Returns:
      the width delta RangeAttribute
    • setDeltaWidth

      public void setDeltaWidth(RangeAttribute<Float> deltaWidth)
      Sets the per-particle width delta parameter.
      Parameters:
      deltaWidth - the width delta parameter to set
    • getAngle

      public RangeAttribute<Float> getAngle()
      Gets the starting angle parameter for spawned particles.
      Returns:
      the angle RangeAttribute
    • setAngle

      public void setAngle(RangeAttribute<Float> angle)
      Sets the starting angle parameter for spawned particles.
      Parameters:
      angle - the angle parameter to set
    • getDeltaAngle

      public RangeAttribute<Float> getDeltaAngle()
      Gets the per-particle angle delta parameter.
      Returns:
      the angle delta RangeAttribute
    • getVelocityX

      public RangeAttribute<Float> getVelocityX()
      Gets the horizontal velocity parameter of spawned particles.
      Returns:
      the horizontal velocity RangeAttribute
    • setVelocityX

      public void setVelocityX(RangeAttribute<Float> velocityX)
      Sets the horizontal velocity parameter of spawned particles.
      Parameters:
      velocityX - the horizontal velocity parameter to set
    • getVelocityY

      public RangeAttribute<Float> getVelocityY()
      Gets the vertical velocity parameter of spawned particles.
      Returns:
      the vertical velocity RangeAttribute
    • setVelocityY

      public void setVelocityY(RangeAttribute<Float> velocityY)
      Sets the vertical velocity parameter of spawned particles.
      Parameters:
      velocityY - the vertical velocity parameter to set
    • getEmitterDuration

      public int getEmitterDuration()
      Gets the emitter duration in milliseconds. A value of 0 means the emitter runs indefinitely.
      Returns:
      the emitter duration in milliseconds
    • setEmitterDuration

      public void setEmitterDuration(int emitterDuration)
      Sets the emitter duration in milliseconds. A value of 0 means the emitter runs indefinitely.
      Parameters:
      emitterDuration - the emitter duration in milliseconds
    • getAccelerationX

      public RangeAttribute<Float> getAccelerationX()
      Gets the horizontal acceleration parameter of spawned particles.
      Returns:
      the horizontal acceleration RangeAttribute
    • setAccelerationX

      public void setAccelerationX(RangeAttribute<Float> accelerationX)
      Sets the horizontal acceleration parameter of spawned particles.
      Parameters:
      accelerationX - the horizontal acceleration parameter to set
    • getAccelerationY

      public RangeAttribute<Float> getAccelerationY()
      Gets the vertical acceleration parameter of spawned particles.
      Returns:
      the vertical acceleration RangeAttribute
    • setAccelerationY

      public void setAccelerationY(RangeAttribute<Float> accelerationY)
      Sets the vertical acceleration parameter of spawned particles.
      Parameters:
      accelerationY - the vertical acceleration parameter to set
    • getOutlineThickness

      public RangeAttribute<Float> getOutlineThickness()
      Gets the outline thickness parameter applied to outline-rendered particles.
      Returns:
      the outline thickness RangeAttribute
    • setOutlineThickness

      public void setOutlineThickness(RangeAttribute<Float> outlineThickness)
      Sets the outline thickness parameter applied to outline-rendered particles.
      Parameters:
      outlineThickness - the outline thickness parameter to set
    • getHeight

      public float getHeight()
      Gets the height of the emitter in pixels.
      Returns:
      the emitter height
    • setHeight

      public void setHeight(float height)
      Sets the height of the emitter in pixels.
      Parameters:
      height - the emitter height to set
    • getMaxParticles

      public int getMaxParticles()
      Gets the maximum number of concurrently alive particles allowed for this emitter.
      Returns:
      the maximum number of particles
    • setMaxParticles

      public void setMaxParticles(int maxParticles)
      Sets the maximum number of concurrently alive particles allowed for this emitter.
      Parameters:
      maxParticles - the maximum number of particles
    • getName

      public String getName()
      Description copied from interface: Resource
      Gets the name of the resource.
      Specified by:
      getName in interface Resource
      Returns:
      The name of the resource.
    • setName

      public void setName(String name)
      Description copied from interface: Resource
      Sets the name of the resource.
      Specified by:
      setName in interface Resource
      Parameters:
      name - The new name of the resource.
    • getOriginAlign

      public Align getOriginAlign()
      Gets the horizontal alignment of the emitter origin.
      Returns:
      the horizontal origin alignment
    • setOriginAlign

      public void setOriginAlign(Align align)
      Sets the horizontal alignment of the emitter origin.
      Parameters:
      align - the horizontal origin alignment to set
    • getOriginValign

      public Valign getOriginValign()
      Gets the vertical alignment of the emitter origin.
      Returns:
      the vertical origin alignment
    • setOriginValign

      public void setOriginValign(Valign valign)
      Sets the vertical alignment of the emitter origin.
      Parameters:
      valign - the vertical origin alignment to set
    • getParticleHeight

      public RangeAttribute<Float> getParticleHeight()
      Gets the per-particle height parameter.
      Returns:
      the particle height RangeAttribute
    • setParticleHeight

      public void setParticleHeight(RangeAttribute<Float> particleHeight)
      Sets the per-particle height parameter.
      Parameters:
      particleHeight - the particle height parameter to set
    • getParticleTTL

      public RangeAttribute<Long> getParticleTTL()
      Gets the particle time-to-live (TTL) parameter, in milliseconds.
      Returns:
      the particle TTL RangeAttribute
    • setParticleTTL

      public void setParticleTTL(RangeAttribute<Long> particleTTL)
      Sets the particle time-to-live (TTL) parameter, in milliseconds.
      Parameters:
      particleTTL - the particle TTL parameter to set
    • getTexts

      public List<String> getTexts()
      Gets the list of text strings used by text-rendering particles.
      Returns:
      the list of texts
    • setTexts

      public void setTexts(List<String> texts)
      Sets the list of text strings used by text-rendering particles.
      Parameters:
      texts - the list of texts
    • getParticleType

      public ParticleType getParticleType()
      Gets the particle type (shape) used when spawning particles.
      Returns:
      the particle type
    • setParticleType

      public void setParticleType(ParticleType particleType)
      Sets the particle type (shape) used when spawning particles.
      Parameters:
      particleType - the particle type to set
    • getParticleWidth

      public RangeAttribute<Float> getParticleWidth()
      Gets the per-particle width parameter.
      Returns:
      the particle width RangeAttribute
    • setParticleWidth

      public void setParticleWidth(RangeAttribute<Float> particleWidth)
      Sets the per-particle width parameter.
      Parameters:
      particleWidth - the particle width parameter to set
    • getParticleOffsetX

      public RangeAttribute<Float> getParticleOffsetX()
      Gets the horizontal spawn offset parameter relative to the emitter origin.
      Returns:
      the horizontal offset RangeAttribute
    • setParticleOffsetX

      public void setParticleOffsetX(RangeAttribute<Float> x)
      Sets the horizontal spawn offset parameter relative to the emitter origin.
      Parameters:
      x - the horizontal offset parameter to set
    • getParticleOffsetY

      public RangeAttribute<Float> getParticleOffsetY()
      Gets the vertical spawn offset parameter relative to the emitter origin.
      Returns:
      the vertical offset RangeAttribute
    • setParticleOffsetY

      public void setParticleOffsetY(RangeAttribute<Float> y)
      Sets the vertical spawn offset parameter relative to the emitter origin.
      Parameters:
      y - the vertical offset parameter to set
    • getSpawnAmount

      public int getSpawnAmount()
      Gets the number of particles that are spawned per spawn tick.
      Returns:
      the spawn amount
    • setSpawnAmount

      public void setSpawnAmount(int spawnAmount)
      Sets the number of particles that are spawned per spawn tick.
      Parameters:
      spawnAmount - the spawn amount to set
    • getSpawnRate

      public int getSpawnRate()
      Gets the spawn rate in milliseconds between spawn ticks.
      Returns:
      the spawn rate
    • setSpawnRate

      public void setSpawnRate(int spawnRate)
      Sets the spawn rate in milliseconds between spawn ticks.
      Parameters:
      spawnRate - the spawn rate to set
    • getSpritesheet

      public String getSpritesheet()
      Gets the name of the spritesheet used by sprite-based particles.
      Returns:
      the spritesheet name
    • setSpritesheet

      public void setSpritesheet(String spritesheetName)
      Sets the name of the spritesheet used by sprite-based particles.
      Parameters:
      spritesheetName - the spritesheet name
    • setSpritesheet

      public void setSpritesheet(Spritesheet spritesheet)
      Sets the spritesheet used by sprite-based particles using a Spritesheet reference.
      Parameters:
      spritesheet - the spritesheet whose name will be stored
    • getUpdateRate

      public int getUpdateRate()
      Gets the update rate of the emitter in milliseconds.
      Returns:
      the update rate
    • setUpdateRate

      public void setUpdateRate(int updateRate)
      Sets the update rate of the emitter in milliseconds. A value of 0 is ignored.
      Parameters:
      updateRate - the update rate to set
    • getWidth

      public float getWidth()
      Gets the width of the emitter in pixels.
      Returns:
      the emitter width
    • setWidth

      public void setWidth(float width)
      Sets the width of the emitter in pixels.
      Parameters:
      width - the emitter width to set
    • isAnimatingSprite

      public boolean isAnimatingSprite()
      Returns whether sprite-based particles are animated.
      Returns:
      true if sprite animation is enabled
    • isLoopingSprite

      public boolean isLoopingSprite()
      Returns whether sprite-based particle animations are looped.
      Returns:
      true if sprite looping is enabled
    • isFading

      public boolean isFading()
      Returns whether particles fade out over their lifetime.
      Returns:
      true if particles fade
    • isFadingOnCollision

      public boolean isFadingOnCollision()
      Returns whether particles fade upon collision.
      Returns:
      true if particles fade on collision
    • isOutlineOnly

      public boolean isOutlineOnly()
      Returns whether shape-based particles are rendered as outlines only.
      Returns:
      true if outline-only rendering is enabled
    • setOutlineOnly

      public void setOutlineOnly(boolean outlineOnly)
      Sets whether shape-based particles are rendered as outlines only.
      Parameters:
      outlineOnly - true to enable outline-only rendering
    • isAntiAliased

      public boolean isAntiAliased()
      Returns whether particles are rendered with anti-aliasing.
      Returns:
      true if anti-aliasing is enabled
    • setAnimateSprite

      public void setAnimateSprite(boolean animateSprite)
      Sets whether sprite-based particles are animated.
      Parameters:
      animateSprite - true to enable sprite animation
    • setLoopSprite

      public void setLoopSprite(boolean loopSprite)
      Sets whether sprite-based particle animations are looped.
      Parameters:
      loopSprite - true to enable sprite looping
    • setColor

      public void setColor(Color color)
      Sets a single color used for spawning particles, replacing any previously configured colors.
      Parameters:
      color - the color to set
    • initDefaults

      public void initDefaults()
      Initializes all configurable emitter and particle parameters to their DEFAULT_* values.
    • setDeltaRotation

      public void setDeltaRotation(RangeAttribute<Float> deltaRotation)
      Sets the per-particle angle delta parameter.
      Parameters:
      deltaRotation - the angle delta parameter to set
    • setFade

      public void setFade(boolean fade)
      Sets whether particles fade out over their lifetime.
      Parameters:
      fade - true to enable fading
    • setFadeOnCollision

      public void setFadeOnCollision(boolean fadeOnCollision)
      Sets whether particles fade upon collision.
      Parameters:
      fadeOnCollision - true to enable fade-on-collision
    • setAntiAliasing

      public void setAntiAliasing(boolean antiAliasing)
      Sets whether particles are rendered with anti-aliasing.
      Parameters:
      antiAliasing - true to enable anti-aliasing
    • setText

      public void setText(String text)
      Sets a single text used by text-rendering particles, replacing any previously configured texts.
      Parameters:
      text - the text to set