Class DoomThing

java.lang.Object
net.mtrop.doom.map.data.DoomThing
All Implemented Interfaces:
BinaryObject

public class DoomThing extends Object implements BinaryObject
Doom/Boom/MBF 10-byte format implementation of Thing.
Author:
Matthew Tropiano
  • Field Details

    • LENGTH

      public static final int LENGTH
      Byte length of this object.
      See Also:
    • x

      protected int x
      Thing X position.
    • y

      protected int y
      Thing Y position.
    • angle

      protected int angle
      Thing angle.
    • type

      protected int type
      Thing type (editor number).
    • flags

      protected int flags
      Behavior bitflags.
  • Constructor Details

    • DoomThing

      public DoomThing()
      Creates a new thing.
  • Method Details

    • 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.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • set

      public void set(int x, int y)
      Sets the coordinates of this thing.
      Parameters:
      x - the x-coordinate value.
      y - the y-coordinate value.
    • getX

      public int getX()
      Returns:
      the position X-coordinate.
    • setX

      public void setX(int x)
      Sets the position X-coordinate.
      Parameters:
      x - the new x-coordinate.
      Throws:
      IllegalArgumentException - if x is outside of the range -32768 to 32767.
    • getY

      public int getY()
      Returns:
      the position Y-coordinate.
    • setY

      public void setY(int y)
      Sets the position Y-coordinate.
      Parameters:
      y - the new y-coordinate.
      Throws:
      IllegalArgumentException - if y is outside of the range -32768 to 32767.
    • getAngle

      public int getAngle()
      Returns:
      the angle (in degrees).
    • setAngle

      public void setAngle(int angle)
      Sets the angle (in degrees).
      Parameters:
      angle - the new angle in degrees.
      Throws:
      IllegalArgumentException - if angle is outside of the range -32768 to 32767.
    • getType

      public int getType()
      Returns:
      thing type (a.k.a. editor number).
    • setType

      public void setType(int type)
      Sets thing type (a.k.a. editor number).
      Parameters:
      type - the new thing type.
      Throws:
      IllegalArgumentException - if type is outside of the range 0 to 65535.
    • getFlags

      public int getFlags()
      Returns:
      this linedef's full bitflags.
    • setFlags

      public void setFlags(int flags)
      Sets/replaces this linedef's full bitflags.
      Parameters:
      flags - the flags to set
    • isFlagSet

      public boolean isFlagSet(int flagType)
      Check's if a flag bit is set.
      Parameters:
      flagType - the flag type (constant).
      Returns:
      true if set, false if not.
      See Also:
    • setFlag

      public void setFlag(int flagType, boolean set)
      Sets/clears a bit flag.
      Parameters:
      flagType - the flag type (constant).
      set - if true, set the bit. If false, clear it.
      See Also: