Package net.mtrop.doom.map.data
Class HexenThing
java.lang.Object
net.mtrop.doom.map.data.HexenThing
- All Implemented Interfaces:
BinaryObject
Hexen 20-byte format implementation of Thing.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.mtrop.doom.object.BinaryObject
BinaryObject.InlineScanner<BO extends BinaryObject>, BinaryObject.Reflect, BinaryObject.Scanner<BO extends BinaryObject>, BinaryObject.Shared, BinaryObject.Transformer<BO extends BinaryObject>
-
Field Summary
Modifier and TypeFieldDescriptionprotected int
Thing angle.protected int[]
Thing action special arguments.protected int
Behavior bitflags.protected int
Thing Z position relative to sector plane.protected int
Thing ID.static final int
Byte length of this object.protected int
Thing action special.protected int
Thing type (editor number).protected int
Thing X position.protected int
Thing Y position. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionint
getAngle()
int
getArgument
(int n) Gets a special argument.int[]
Gets the special arguments copied into a new array.int
getFlags()
int
int
getId()
int
int
getType()
int
getX()
int
getY()
boolean
isFlagSet
(int flagType) Check's if a flag bit is set.void
readBytes
(InputStream in) Reads from anInputStream
and sets this object's fields.void
set
(int x, int y) Sets the coordinates of this thing.void
setAngle
(int angle) Sets the angle (in degrees).void
setArguments
(int... arguments) Sets the special arguments.void
setFlag
(int flagType, boolean set) Sets/clears a bit flag.void
setFlags
(int flags) Sets/replaces this linedef's full bitflags.void
setHeight
(int height) Sets the Z position relative to sector plane.void
setId
(int id) Sets the thing's id.void
setSpecial
(int special) Sets the special action for this thing.void
setType
(int type) Sets thing type (a.k.a.void
setX
(int x) Sets the position X-coordinate.void
setY
(int y) Sets the position Y-coordinate.toString()
void
writeBytes
(OutputStream out) Writes this object to anOutputStream
.
-
Field Details
-
LENGTH
public static final int LENGTHByte length of this object.- See Also:
-
id
protected int idThing ID. -
height
protected int heightThing Z position relative to sector plane. -
special
protected int specialThing action special. -
arguments
protected int[] argumentsThing action special arguments. -
x
protected int xThing X position. -
y
protected int yThing Y position. -
angle
protected int angleThing angle. -
type
protected int typeThing type (editor number). -
flags
protected int flagsBehavior bitflags.
-
-
Constructor Details
-
HexenThing
public HexenThing()Creates a new thing.
-
-
Method Details
-
getHeight
public int getHeight()- Returns:
- the Z position relative to sector plane.
- Since:
- 2.9.0, for naming clarity/uniformity.
-
setHeight
public void setHeight(int height) Sets the Z position relative to sector plane.- Parameters:
height
- the new height.- Throws:
IllegalArgumentException
- ifz
is not between -32768 and 32767.- Since:
- 2.9.0, for naming clarity/uniformity.
-
getId
public int getId()- Returns:
- the thing's id (for tagged specials).
-
setId
public void setId(int id) Sets the thing's id.- Parameters:
id
- the new id.- Throws:
IllegalArgumentException
- ifid
is not between 0 and 65535.
-
getSpecial
public int getSpecial()- Returns:
- the special action for this thing.
-
setSpecial
public void setSpecial(int special) Sets the special action for this thing.- Parameters:
special
- the thing special to call on activation.- Throws:
IllegalArgumentException
- if special is outside the range 0 to 255.
-
getArguments
public int[] getArguments()Gets the special arguments copied into a new array.- Returns:
- gets the array of special arguments.
-
getArgument
public int getArgument(int n) Gets a special argument.- Parameters:
n
- the argument index (up to 4)- Returns:
- the argument value.
- Throws:
ArrayIndexOutOfBoundsException
- ifn
is less than 0 or greater than 4.
-
setArguments
public void setArguments(int... arguments) Sets the special arguments.- Parameters:
arguments
- the argument values to set.- Throws:
IllegalArgumentException
- if length of arguments is greater than 5, or any argument is less than 0 or greater than 255.
-
readBytes
Description copied from interface:BinaryObject
Reads from anInputStream
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 interfaceBinaryObject
- Parameters:
in
- theInputStream
to read from.- Throws:
IOException
- if a read error occurs.
-
writeBytes
Description copied from interface:BinaryObject
Writes this object to anOutputStream
.- Specified by:
writeBytes
in interfaceBinaryObject
- Parameters:
out
- theOutputStream
to write to.- Throws:
IOException
- if a write error occurs.
-
toString
-
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:
-