Public Member Functions | |
| UTMessage (string message) | |
| Constructor: Saves the original message, verifies matching brackets, sets the completeness indicator, and does the main parsing of the message. If the message isn't complete, messageContents and messageKeys should be set to NONE so that they don't crash anything since they could have no values. | |
| override string | ToString () |
| Override for the System.Object ToString message. | |
| string | GetStringValue (string key) |
| The the value of a key as a string. | |
| string[] | GetSublistKeys (string sublist) |
| The keys of a sublist (for instance PlayerScores for individual players in a UTMessage.GAME message) are obtained as a string array. A sublist will end whenever we get a closing } that has been left in the list assuming the algorithm for parsing is the same as mentioned in the parsing algorithm.
If there are no keys, a UTAttributeTypeException should be thrown. It is on the head of the people who call this class to catch it. The message should read: "Error: programmer has misused getSublistKeys in the UTMessage class." | |
| UTVector | GetVector3Value (string key) |
| This is useful for methods that need to obtain the location, velocity, and other 3d values from a message. They will all be returned as floats. This method will throw a UTAttributeTypeException if the key doesn't have 3 floats attached as values to it. The error message for this exception is: "Error: programmer has misused getVector3Value in the UTMessage class.". | |
| int | GetIntValue (string key) |
| Obtain an integer value from a specific key name in the message. An example of an integer value would be score. This method will throw a UTAttributeTypeException if the value cannont be interpreted as an integer. The error message for this will be: "Error: programmer has misused getIntValue in the UTMessage class.". | |
| bool | GetBoolValue (string key) |
| float | GetFloatValue (string key) |
| Obtain a float value from a specific key name in the message. This method will throw a UTAttributeTypeException if the value cannont be interpreted as an integer. The error message for this will be: "Error: programmer has misused getFloatValue in the UTMessage class.". | |
| bool | IsProperMessage () |
| Let's the caller know if a message internal to this object is actually formatted correctly for sending/receiving. | |
| virtual void | SetMessage (string message) |
| This method allows us to reuse the UTMessage objects instead of always having to create new ones whenever we want new messages. The class clobbers the old string message with a new one and parses/checks the new message in a similar manny to what happens when the class is created. | |
| bool | IsType (string type) |
| Checks to see if two message types are the same. | |
Public Attributes | |
| const string | BEGIN = "BEG" |
| Beginning of a synchronous message set. | |
| const string | PLAYER = "PLR" |
| A message about an opponent player that is being seen. | |
| const string | NAVIGATION = "NAV" |
| A message about a navigation point that is within view. | |
| const string | INVENTORY = "INV" |
| A message about an inventory point that is within view. | |
| const string | DOMINATION = "DOM" |
| A message about a domination point within view. | |
| const string | FLAG = "FLG" |
| A message about a flag within view for a capture the flag game. | |
| const string | MOVER = "MOV" |
| A mover has been sited. | |
| const string | SELF = "SLF" |
| A self message containing information about the current bot information. | |
| const string | GAME = "GAM" |
| Game messages contain information about the current game. | |
| const string | END = "END" |
| The end of a set of synchronous messages. | |
| const string | DUPLICATE_NAME = "DUP" |
| This bot has the same name as one currently in the game. | |
| const string | INFO = "NFO" |
| A starting information message. | |
| const string | WALL = "WAL" |
| The bot has bumped into a wall head on. | |
| const string | BUMP = "BMP" |
| The bot has bumped another bot. | |
| const string | PROJECTILE = "PRJ" |
| The bot has an incoming projectile. | |
| const string | DAMAGE = "DAM" |
| The bot has taken damage. | |
| const string | DIE = "DIE" |
| The bot has just died. | |
| const string | KILL = "KIL" |
| The opponent has just died. | |
| const string | FINISHED = "FIN" |
| The game has finished. Another could start shortly. | |
| const string | PONG = "PONG" |
| Pong is the received message from the server after a "ping" is sent by the client. | |
| const string | FALL = "FALL" |
| The bot hit a dropoff. | |
| const string | ADDED_INVENTORY = "AIN" |
| The bot just picked something up. | |
| const string | GLOBAL_CHAT_RCV = "VMS" |
| Received for any message broadcast on the global chat channel. | |
| const string | TEAM_CHAT_RCV = "VMT" |
| Received for any message sent on the team chat channel. | |
| const string | TOKENIZED_MSG_RCV = "VMG" |
| Received for any message sent to another player. | |
| const string | FOOT_CHANGED_ZONES = "ZCF" |
| The bot's foot changed zones. | |
| const string | HEAD_CHANGED_ZONES = "ZCH" |
| The bot's head changed zones. | |
| const string | BOT_CHANGED_ZONES = "ZCB" |
| The whole bot changed zones. | |
| const string | CHANGED_WEAPON = "CWP" |
| The bot changed weapons. | |
| const string | HEAR_PICKUP = "HRP" |
| Something was picked up by another bot and this bot heard it. Very rarely heard. | |
| const string | HEAR_NOISE = "HRN" |
| The bot heard another bot. Very rare for this to happen. | |
| const string | HIT = "HIT" |
| Another player has been hurt. | |
| const string | PATH_NODES = "PTH" |
| A string of path nodes that your bot can travel to get from one location to another. Received after asking for a path to a particular node. | |
| const string | GET_PATH = "GETPATH" |
| Get a path to a particular node. | |
| const string | CHECK_REACH = "RCH" |
| Check the reachability of a node from this particular location. Reachability is done with a line-of-site check and so may have some problems for a bot who actually wants to get there. | |
| const string | NONE = "NONE" |
| const string | PING = "PING" |
| Ping is sent to a server in order to make sure a connection is working correctly. | |
| const string | MESSAGE = "MESSAGE" |
| We want to send out a chat message. | |
| const string | INITIALIZE = "INIT" |
| The client wants to initialize connecting it's bot to the server. | |
| const string | SETWALK = "SETWALK" |
| The client wants to set whether the bot is walking or running. Give with the argument of true for walking and anything else for running. | |
| const string | JUMP = "JUMP" |
| The client wants the bot to jump. | |
| const string | STRAFE = "STRAFE" |
| The client wants the strafe in a particular direction. | |
| const string | SHOOT = "SHOOT" |
| The client wants start shooting at something. | |
| const string | STOPSHOOT = "STOPSHOOT" |
| The client wants stop shooting at something. | |
| const string | CHANGEWEAPON = "CHANGEWEAPON" |
| The client wants change the bot's weapon. | |
| const string | CHECKREACH = "CHECKREACH" |
| The client wants change the bot's weapon. | |
| const string | STOP = "STOP" |
| The client wants to stop all movement of the bot. | |
| const string | RUNTO = "RUNTO" |
| The bot wants to run somewhere. | |
| const string | ROTATE = "ROTATE" |
| The bot wants to turn. Remember that if too many turn commands are sent at once, nothing will happen as the bot needs time to react. | |
| const string | TURNTO = "TURNTO" |
| Another version of rotating. | |
| const string | LOCATION = "LOCATION" |
| Attribute for location in x,y, and z coordinates. | |
| const string | ROTATION = "ROTATION" |
| Attribute for rotation in roll, pitch, and yaw coordinates. | |
| const string | VELOCITY = "VELOCITY" |
| Attribute for velocity in x, y, and z directions. | |
| const string | ID = "ID" |
| The bots ID. This should be different from a bots name. | |
| const string | REACHABLE = "REACHABLE" |
| Contains information about whether or not this node is reachable. | |
| const string | MSGCLASS = "CLASS" |
| Message class. Not often used. | |
| const string | TEAM = "TEAM" |
| Team information. | |
| const string | NAME = "NAME" |
| The bot name given by a client. | |
| const string | WEAPON = "WEAPON" |
| The current weapon. | |
| const string | HEALTH = "HEALTH" |
| The current health. | |
| const string | ARMOR = "ARMOR" |
| The current armor. | |
| const string | AMMO = "CURRENTAMMO" |
| The current ammo. | |
| const string | AGENT_KILLER = "KILLER" |
| The agent killer. Not really used. | |
| const string | AGENT_KILLER_DAMAGE_TYPE = "DAMAGETYPE" |
| The agent killed damage type. Not really used. | |
| const string | TARGET = "TARGET" |
| The target for attacks. | |
| const int | TEAM_RED = 0 |
| The red team in the game. | |
| const int | TEAM_BLUE = 1 |
| The blue team in the game. | |
| const int | TEAM_GREEN = 2 |
| The green team in the game. | |
| const int | TEAM_GOLD = 3 |
| The gold team in the game. | |
| const int | DONT_CARE = 255 |
| For games without teams or those who really don't care. | |
Protected Attributes | |
| string[] | messageKeys = null |
| An array of keys that represent everything that follows a { in a message. These can be considered the names of data in a message. | |
| string[] | messageContents = null |
| The contents associated with each key. Note that where there are contents within contents, they will exist as extra pieces of data in line rather than a nested structure in the array. | |
| bool | isSynch = true |
| We have synchronous (game info) and asynchronous (somebody died) info messages from the server. Most messages are synchronous and so isSynch starts out as true. | |
Properties | |
| bool | IsSynchronous |
| Need to see if a message is synchronous. | |
| string | MessageType |
| The message type of the name. | |
| string[] | Keys |
| string[] | Values |
Private Member Functions | |
| void | CleanContents () |
| bool | VerifyMatchingBrackets (string message) |
| Counts brackets and makes sure they match. Sets the complete variable to true if the brackets match. Using the ToCharArray method of the string class may be helpful for this method. | |
| void | PreParseMessage (string message) |
| Sets the type of the message and takes the main attributes of it and hands them off to be parsed. The way this is done in the answer (you can do it however you want as long as you document the algorithm) is that a Regex object is used with UTMessage.DELIMITER for its string in creation. This object is then used to Split the message into an array of strings based on when the "{" is seen since it always precedes a new piece/keyword in the message. The keywords are kept in a string array separate from the values that they have. All are stored as strings to make things easy at this end. Ending spaces and "}"'s are stripped off except the ending "}" that occurs in multi-part keywords where the actual keyword has a whole body of {}'s inside of it with no value. The fact that multi-part keywords will have a value of NONE and the sublist of the keyword will end with a "}" means that we can get various sublists relatively easily. | |
| void | SetSynchronous () |
| Sets up whether isSynch is true or false depending on the type of the message. This method must be called whenever the messageName gets set. | |
| string | CleanEndings (string message) |
| If the parsing method used above is used, it becomes necessary to strip the ending } values before trying to return the attribute/vale before the ending } of sublists. It should not be stripped off of the source message, but needs to be stripped before the attributes/values are returned to a caller. | |
Private Attributes | |
| string | messageName = NONE |
| All messages have a name. The name is equivalent to the type of the message such as GAM or FIN. Initially, all message names should be set to NONE. | |
| string | originalMessage = "" |
| The original string message. Useful when we want to dump printed information about a message. This message will be kept up-to-date with the rest of the message structure. | |
| const string | DELIMITER = "{" |
| The delimiter for a message. This can be set on the server side. | |
| bool | complete = false |
| Since we don't check for completeness of the message before this object is created, we'll note it inside the object - false means something's missing. | |
|
|
Constructor: Saves the original message, verifies matching brackets, sets the completeness indicator, and does the main parsing of the message. If the message isn't complete, messageContents and messageKeys should be set to NONE so that they don't crash anything since they could have no values.
|
|
|
|
|
|
If the parsing method used above is used, it becomes necessary to strip the ending } values before trying to return the attribute/vale before the ending } of sublists. It should not be stripped off of the source message, but needs to be stripped before the attributes/values are returned to a caller.
|
|
|
|
|
|
Obtain a float value from a specific key name in the message. This method will throw a UTAttributeTypeException if the value cannont be interpreted as an integer. The error message for this will be: "Error: programmer has misused getFloatValue in the UTMessage class.".
|
|
|
Obtain an integer value from a specific key name in the message. An example of an integer value would be score. This method will throw a UTAttributeTypeException if the value cannont be interpreted as an integer. The error message for this will be: "Error: programmer has misused getIntValue in the UTMessage class.".
|
|
|
The the value of a key as a string.
|
|
|
The keys of a sublist (for instance PlayerScores for individual players in a UTMessage.GAME message) are obtained as a string array. A sublist will end whenever we get a closing } that has been left in the list assuming the algorithm for parsing is the same as mentioned in the parsing algorithm. If there are no keys, a UTAttributeTypeException should be thrown. It is on the head of the people who call this class to catch it. The message should read: "Error: programmer has misused getSublistKeys in the UTMessage class."
|
|
|
This is useful for methods that need to obtain the location, velocity, and other 3d values from a message. They will all be returned as floats. This method will throw a UTAttributeTypeException if the key doesn't have 3 floats attached as values to it. The error message for this exception is: "Error: programmer has misused getVector3Value in the UTMessage class.".
|
|
|
Let's the caller know if a message internal to this object is actually formatted correctly for sending/receiving.
|
|
|
Checks to see if two message types are the same.
|
|
|
Sets the type of the message and takes the main attributes of it and hands them off to be parsed. The way this is done in the answer (you can do it however you want as long as you document the algorithm) is that a Regex object is used with UTMessage.DELIMITER for its string in creation. This object is then used to Split the message into an array of strings based on when the "{" is seen since it always precedes a new piece/keyword in the message. The keywords are kept in a string array separate from the values that they have. All are stored as strings to make things easy at this end. Ending spaces and "}"'s are stripped off except the ending "}" that occurs in multi-part keywords where the actual keyword has a whole body of {}'s inside of it with no value. The fact that multi-part keywords will have a value of NONE and the sublist of the keyword will end with a "}" means that we can get various sublists relatively easily.
|
|
|
This method allows us to reuse the UTMessage objects instead of always having to create new ones whenever we want new messages. The class clobbers the old string message with a new one and parses/checks the new message in a similar manny to what happens when the class is created.
|
|
|
Sets up whether isSynch is true or false depending on the type of the message. This method must be called whenever the messageName gets set.
|
|
|
Override for the System.Object ToString message.
|
|
|
Counts brackets and makes sure they match. Sets the complete variable to true if the brackets match. Using the ToCharArray method of the string class may be helpful for this method.
|
|
|
The bot just picked something up.
|
|
|
The agent killer. Not really used.
|
|
|
The agent killed damage type. Not really used.
|
|
|
The current ammo.
|
|
|
The current armor.
|
|
|
Beginning of a synchronous message set.
|
|
|
The whole bot changed zones.
|
|
|
The bot has bumped another bot.
|
|
|
The bot changed weapons.
|
|
|
The client wants change the bot's weapon.
|
|
|
Check the reachability of a node from this particular location. Reachability is done with a line-of-site check and so may have some problems for a bot who actually wants to get there.
|
|
|
The client wants change the bot's weapon.
|
|
|
Since we don't check for completeness of the message before this object is created, we'll note it inside the object - false means something's missing.
|
|
|
The bot has taken damage.
|
|
|
The delimiter for a message. This can be set on the server side.
|
|
|
The bot has just died.
|
|
|
A message about a domination point within view.
|
|
|
For games without teams or those who really don't care.
|
|
|
This bot has the same name as one currently in the game.
|
|
|
The end of a set of synchronous messages.
|
|
|
The bot hit a dropoff.
|
|
|
The game has finished. Another could start shortly.
|
|
|
A message about a flag within view for a capture the flag game.
|
|
|
The bot's foot changed zones.
|
|
|
Game messages contain information about the current game.
|
|
|
Get a path to a particular node.
|
|
|
Received for any message broadcast on the global chat channel.
|
|
|
The bot's head changed zones.
|
|
|
The current health.
|
|
|
The bot heard another bot. Very rare for this to happen.
|
|
|
Something was picked up by another bot and this bot heard it. Very rarely heard.
|
|
|
Another player has been hurt.
|
|
|
The bots ID. This should be different from a bots name.
|
|
|
A starting information message.
|
|
|
The client wants to initialize connecting it's bot to the server.
|
|
|
A message about an inventory point that is within view.
|
|
|
We have synchronous (game info) and asynchronous (somebody died) info messages from the server. Most messages are synchronous and so isSynch starts out as true.
|
|
|
The client wants the bot to jump.
|
|
|
The opponent has just died.
|
|
|
Attribute for location in x,y, and z coordinates.
|
|
|
We want to send out a chat message.
|
|
|
The contents associated with each key. Note that where there are contents within contents, they will exist as extra pieces of data in line rather than a nested structure in the array.
|
|
|
An array of keys that represent everything that follows a { in a message. These can be considered the names of data in a message.
|
|
|
All messages have a name. The name is equivalent to the type of the message such as GAM or FIN. Initially, all message names should be set to NONE.
|
|
|
A mover has been sited.
|
|
|
Message class. Not often used.
|
|
|
The bot name given by a client.
|
|
|
A message about a navigation point that is within view.
|
|
|
|
|
|
The original string message. Useful when we want to dump printed information about a message. This message will be kept up-to-date with the rest of the message structure.
|
|
|
A string of path nodes that your bot can travel to get from one location to another. Received after asking for a path to a particular node.
|
|
|
Ping is sent to a server in order to make sure a connection is working correctly.
|
|
|
A message about an opponent player that is being seen.
|
|
|
Pong is the received message from the server after a "ping" is sent by the client.
|
|
|
The bot has an incoming projectile.
|
|
|
Contains information about whether or not this node is reachable.
|
|
|
The bot wants to turn. Remember that if too many turn commands are sent at once, nothing will happen as the bot needs time to react.
|
|
|
Attribute for rotation in roll, pitch, and yaw coordinates.
|
|
|
The bot wants to run somewhere.
|
|
|
A self message containing information about the current bot information.
|
|
|
The client wants to set whether the bot is walking or running. Give with the argument of true for walking and anything else for running.
|
|
|
The client wants start shooting at something.
|
|
|
The client wants to stop all movement of the bot.
|
|
|
The client wants stop shooting at something.
|
|
|
The client wants the strafe in a particular direction.
|
|
|
The target for attacks.
|
|
|
Team information.
|
|
|
The blue team in the game.
|
|
|
Received for any message sent on the team chat channel.
|
|
|
The gold team in the game.
|
|
|
The green team in the game.
|
|
|
The red team in the game.
|