Package net.mtrop.doom.texture
Class Switches
java.lang.Object
net.mtrop.doom.texture.Switches
- All Implemented Interfaces:
Iterable<Switches.Entry>
,BinaryObject
,Sizable
This class represents the contents of a Boom Engine SWITCHES
lump. This lump contains extended information regarding textures
used for in-game switches.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Entry for Switches.static enum
Enumeration of game types.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
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
addEntry
(String offName, String onName, Switches.Game game) Adds a switch entry to this lump.get
(int i) Returns a switch entry at a specific index.int
boolean
isEmpty()
Returns if this object contains no objects.iterator()
void
readBytes
(InputStream in) Reads from anInputStream
and sets this object's fields.removeEntry
(int i) Removes a switch entry at a specific index.int
size()
void
writeBytes
(OutputStream out) Writes this object to anOutputStream
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.mtrop.doom.object.BinaryObject
fromBytes, readFile, toBytes, writeFile, writeFile
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
entryList
List of entries.
-
-
Constructor Details
-
Switches
public Switches()Creates a new SWITCHES lump.
-
-
Method Details
-
get
Returns a switch 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
Removes a switch 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.
-
addEntry
Adds a switch entry to this lump. The names must be 8 characters or less.- Parameters:
offName
- the "off" name for the switch.onName
- the "on" name for the switch.game
- the game type that this switch works with.- Throws:
IllegalArgumentException
- if any of the texture names are invalid or game is null.
-
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.
-
iterator
- Specified by:
iterator
in interfaceIterable<Switches.Entry>
-
size
public int size() -
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 ifSizable.size()
returns 0.
-