Interface Weighted<T>

Type Parameters:
T - The type of the element
All Known Implementing Classes:
Sound, WeighedSoundEvents

public interface Weighted<T>
The Weighted interface represents an element with a weight in a weighted collection. It is used to provide weighted selection and retrieval of elements.
  • Method Summary

    Modifier and Type
    Method
    Description
    getSound(RandomSource pRandomSource)
    Retrieves the sound associated with the element.
    int
     
    void
    Preloads the sound if required by the sound engine.
  • Method Details

    • getWeight

      int getWeight()
    • getSound

      T getSound(RandomSource pRandomSource)
      Retrieves the sound associated with the element. The sound is obtained using the provided random source.

      Parameters:
      pRandomSource - the random source used for sound selection
      Returns:
      The sound associated with the element
    • preloadIfRequired

      void preloadIfRequired(SoundEngine pEngine)
      Preloads the sound if required by the sound engine. This method is called to preload the sound associated with the element into the sound engine, ensuring it is ready for playback.
      Parameters:
      pEngine - the sound engine used for sound preloading