Class Animated

java.lang.Object
net.mtrop.doom.texture.Animated
All Implemented Interfaces:
Iterable<Animated.Entry>, BinaryObject, Sizable

public class Animated extends Object implements BinaryObject, Iterable<Animated.Entry>, Sizable
This class represents the contents of a Boom Engine ANIMATED lump. This lump contains extended information regarding animated flats and textures.
Author:
Matthew Tropiano
  • Field Details

  • Constructor Details

    • Animated

      public Animated()
      Creates a new ANIMATED lump.
  • Method Details

    • flat

      public static Animated.Entry flat(String lastName, String firstName, int ticks)
      Creates a flat entry.
      Parameters:
      lastName - the last name in the sequence.
      firstName - the first name in the sequence.
      ticks - the amount of ticks between each frame.
      Returns:
      a new entry detailing an animated texture.
      Throws:
      IllegalArgumentException - if lastName or firstName is not a valid texture name, or frame ticks is less than 1.
    • texture

      public static Animated.Entry texture(String lastName, String firstName, int ticks)
      Creates a texture entry.
      Parameters:
      lastName - the last name in the sequence.
      firstName - the first name in the sequence.
      ticks - the amount of ticks between each frame.
      Returns:
      a new entry detailing an animated texture.
      Throws:
      IllegalArgumentException - if lastName or firstName is not a valid texture name, or frame ticks is less than 1.
    • texture

      public static Animated.Entry texture(String lastName, String firstName, int ticks, boolean decals)
      Creates a texture entry.
      Parameters:
      lastName - the last name in the sequence.
      firstName - the first name in the sequence.
      ticks - the amount of ticks between each frame.
      decals - if true, allows decals to be placed on this texture, false if not.
      Returns:
      a new entry detailing an animated texture.
      Throws:
      IllegalArgumentException - if lastName or firstName is not a valid texture name, or frame ticks is less than 1.
    • addEntry

      public void addEntry(Animated.Entry entry)
      Adds an entry to this Animated lump.
      Parameters:
      entry - the entry to add.
      See Also:
    • get

      public Animated.Entry get(int i)
      Returns an Animated entry at a specific index.
      Parameters:
      i - the index of the entry to return.
      Returns:
      the corresponding entry, or null if no corresponding entry for that index.
      Throws:
      IndexOutOfBoundsException - if the index is out of range (less than 0 or greater than or equal to getFlatCount()).
    • removeEntry

      public Animated.Entry removeEntry(int i)
      Removes an Animated entry at a specific index.
      Parameters:
      i - the index of the entry to remove.
      Returns:
      the corresponding removed entry, or null if no corresponding entry for that index.
      Throws:
      IndexOutOfBoundsException - if the index is out of range (less than 0 or greater than or equal to getSwitchCount()).
    • getEntryCount

      public int getEntryCount()
      Returns:
      the amount of switch entries in this lump.
    • readBytes

      public void readBytes(InputStream in) throws IOException
      Description copied from interface: BinaryObject
      Reads from an InputStream and sets this object's fields. Only reads the amount of bytes that it takes to read a single instance of the object. Note that not every object may have a consistent length!
      Specified by:
      readBytes in interface BinaryObject
      Parameters:
      in - the InputStream to read from.
      Throws:
      IOException - if a read error occurs.
    • writeBytes

      public void writeBytes(OutputStream out) throws IOException
      Description copied from interface: BinaryObject
      Writes this object to an OutputStream.
      Specified by:
      writeBytes in interface BinaryObject
      Parameters:
      out - the OutputStream to write to.
      Throws:
      IOException - if a write error occurs.
    • iterator

      public Iterator<Animated.Entry> iterator()
      Specified by:
      iterator in interface Iterable<Animated.Entry>
    • size

      public int size()
      Specified by:
      size in interface Sizable
      Returns:
      the amount of individual objects that this object contains.
    • isEmpty

      public boolean isEmpty()
      Description copied from interface: Sizable
      Returns if this object contains no objects. The general policy of this method is that this returns true if and only if Sizable.size() returns 0.
      Specified by:
      isEmpty in interface Sizable
      Returns:
      true if so, false otherwise.