public class CommandQueue
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private CrossfireComcListener |
crossfireComcListener
The listener to track comc commands.
|
private CrossfireServerConnection |
crossfireServerConnection
The server connection for sending ncom commands.
|
private GuiStateListener |
guiStateListener
The
GuiStateListener for detecting established or dropped
connections. |
private boolean |
isRunning
Whether a "run" command has been sent without a following "run_stop"
command.
|
private static int |
MAX_PENDING_COMMANDS
Maximum number of pending commands sent to the server.
|
private java.util.List<java.lang.Integer> |
pendingCommands
Records command ids of commands sent to the server for which no comc
commands has been received.
|
private int |
repeatCount
The default repeat counter for ncom commands.
|
Constructor and Description |
---|
CommandQueue(CrossfireServerConnection crossfireServerConnection,
GuiStateManager guiStateManager)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addToRepeatCount(int digit)
Adds a digit to the current repeat count.
|
boolean |
checkFire()
Returns whether the character is firing.
|
boolean |
checkRun()
Returns whether the character is running.
|
private void |
clear()
Forgets about sent commands.
|
private int |
getRepeatCount()
Returns the current repeat count and reset it to zero.
|
void |
resetRepeatCount()
Resets the current repeat count to zero.
|
void |
sendMove(int to,
int tag)
Sends a "move" command to the server.
|
void |
sendNcom(boolean mustSend,
int repeat,
java.lang.String command)
Sends an "ncom" command to the server.
|
void |
sendNcom(boolean mustSend,
java.lang.String command)
Sends an "ncom" command to the server.
|
boolean |
stopRunning()
Tells the server to stop running.
|
@NotNull private final CrossfireComcListener crossfireComcListener
@NotNull private final CrossfireServerConnection crossfireServerConnection
@NotNull private final GuiStateListener guiStateListener
GuiStateListener
for detecting established or dropped
connections.private boolean isRunning
private static final int MAX_PENDING_COMMANDS
@NotNull private final java.util.List<java.lang.Integer> pendingCommands
MAX_PENDING_COMMANDS
due to "must send" commands.private int repeatCount
public CommandQueue(@NotNull CrossfireServerConnection crossfireServerConnection, @NotNull GuiStateManager guiStateManager)
crossfireServerConnection
- the server connection for sending ncom
commandsguiStateManager
- the gui state manager to watchpublic void addToRepeatCount(int digit)
digit
- the digit (0-9) to addpublic boolean checkFire()
public boolean checkRun()
private void clear()
private int getRepeatCount()
public void resetRepeatCount()
public void sendMove(int to, int tag)
to
- the destination locationtag
- the item to movepublic void sendNcom(boolean mustSend, int repeat, @NotNull java.lang.String command)
mustSend
- if set, always send the command; if unset, drop the
command if the command queue is fullrepeat
- the repeat countcommand
- the command to sendsendNcom(boolean, String)
public void sendNcom(boolean mustSend, @NotNull java.lang.String command)
mustSend
- if set, always send the command; if unset, drop the
command if the command queue is fullcommand
- the command to sendsendNcom(boolean, int, String)
public boolean stopRunning()