Interface Destructible

All Known Subinterfaces:
Asset, TextureBase
All Known Implementing Classes:
AnimationData, Application, AssetPool, AssetPoolEventDispatcher, AudioDevice, AudioPlayer, AudioSource, AudioSourcePool, BorderImage, ButtonNode, CameraControlData, CameraData, Component, ComponentManager, ConfigOption, DynamicText, ECSManager, Entity, EntityManager, EntityQuery, EntityQueryPool, EventDispatcher, Font, FontPool, FrameBufferObject, FrameNode, Gamepad, GridGroup, Image, ImageNode, ImagePool, Input, LayoutNode, LayoutNodeStyle, ModEntry, ModManager, MultiTileRenderer, Node, NodeEventDispatcher, NodeRoot, NodeStyle, NodeStyleBase, ObservableProperty, ParticleBurstEmitter, ParticleEmitter, ParticleFlowEmitter, ParticleRenderer, RectRenderer, Renderer, Scene, SelectionProperty, Shader, ShaderPool, ShaderProgram, SimpleEventDispatcher, SingleSelectionProperty, SpriteRenderer, StyleSheet, StyleSheetPool, SystemManager, TextAssetPool, TextInputNode, TextNode, Texture, TextureArray, TextureArrayLayer, TexturePool, TileRenderer, Timer.Interval, Timer.RandomInterval, Timer.TimedAction, Timer.Timeout, TooltipNode, Transform, VertexArrayObject, VertexBufferObject, Window, World

public interface Destructible
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Destroys this object.
    static <D extends Destructible>
    D
    destroy(D destructible)
    Destroys the destructible and returns null.
    static <D extends Destructible>
    void
    destroyAll(Collection<D> destructibles)
    Destroys all objects in a collection.
    static <D extends Destructible>
    void
    destroyAndClear(Collection<D> destructibles)
    Destroys all objects in a collection and clears the collection.
  • Method Details

    • destroy

      void destroy()
      Destroys this object.
    • destroy

      static <D extends Destructible> D destroy(D destructible)
      Destroys the destructible and returns null.

      Example usage:

               
               Entity entity = world.addEntity(prefab);
      
               // Then, in some method that might get called repeatedly
               entity = Destructible.destroy(entity);
      
               // Which is the equivalent of this:
               if (entity != null) {
                   entity.destroy();
                   entity = null;
               }
               
           

      Type Parameters:
      D - The type of destructible
      Parameters:
      destructible - The destructible to destroy or null
      Returns:
      null
    • destroyAndClear

      static <D extends Destructible> void destroyAndClear(Collection<D> destructibles)
      Destroys all objects in a collection and clears the collection. This method can also be used for objects that remove themselves from the collection during their destruction process, as it will clone and clear the original collection before iterating over it.
      Type Parameters:
      D - The type of objects in the collection
      Parameters:
      destructibles - The objects to destroy
    • destroyAll

      static <D extends Destructible> void destroyAll(Collection<D> destructibles)
      Destroys all objects in a collection.

      Use this method if the destroy methods of the items depend on being able to remove themselves from the collection. Which would cause a concurrent modification exception if done using a simple for-each loop.

      Type Parameters:
      D - The type of objects in the collection
      Parameters:
      destructibles - The objects to destroy