From b5c4eb8e21e8b86de1081e984abbcad83a930ea5 Mon Sep 17 00:00:00 2001 From: Lucas Nicodemus Date: Sat, 21 Jan 2012 23:52:17 -0700 Subject: [PATCH] More XML documentation! --- TShockAPI/Utils.cs | 100 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 96 insertions(+), 4 deletions(-) diff --git a/TShockAPI/Utils.cs b/TShockAPI/Utils.cs index f75013b5..05579b95 100644 --- a/TShockAPI/Utils.cs +++ b/TShockAPI/Utils.cs @@ -143,8 +143,8 @@ namespace TShockAPI /// /// Sends message to all users with 'logs' permission. /// - /// - /// + /// Message to send + /// Color of the message public void SendLogs(string log, Color color) { Log.Info(log); @@ -175,9 +175,9 @@ namespace TShockAPI } /// - /// + /// Finds a player ID based on name /// - /// + /// Player name /// public List FindPlayer(string ply) { @@ -197,6 +197,15 @@ namespace TShockAPI return found; } + /// + /// Gets a random clear tile in range + /// + /// Bound X + /// Bound Y + /// Range on the X axis + /// Range on the Y axis + /// X location + /// Y location public void GetRandomClearTileWithInRange(int startTileX, int startTileY, int tileXRange, int tileYRange, out int tileX, out int tileY) { @@ -216,16 +225,33 @@ namespace TShockAPI } while (TileValid(tileX, tileY) && !TileClear(tileX, tileY)); } + /// + /// Determines if a tile is valid + /// + /// Location X + /// Location Y + /// If the tile is valid private bool TileValid(int tileX, int tileY) { return tileX >= 0 && tileX <= Main.maxTilesX && tileY >= 0 && tileY <= Main.maxTilesY; } + /// + /// Clears a tile + /// + /// Location X + /// Location Y + /// The state of the tile private bool TileClear(int tileX, int tileY) { return !Main.tile[tileX, tileY].active; } + /// + /// Gets a list of items by ID or name + /// + /// Item ID or name + /// List of Items public List GetItemByIdOrName(string idOrName) { int type = -1; @@ -236,6 +262,11 @@ namespace TShockAPI return GetItemByName(idOrName); } + /// + /// Gets an item by ID + /// + /// ID + /// Item public Item GetItemById(int id) { Item item = new Item(); @@ -243,6 +274,11 @@ namespace TShockAPI return item; } + /// + /// Gets items by name + /// + /// name + /// List of Items public List GetItemByName(string name) { //Method #1 - must be exact match, allows support for different pickaxes/hammers/swords etc @@ -273,6 +309,11 @@ namespace TShockAPI return found; } + /// + /// Gets an NPC by ID or Name + /// + /// + /// List of NPCs public List GetNPCByIdOrName(string idOrName) { int type = -1; @@ -283,6 +324,11 @@ namespace TShockAPI return GetNPCByName(idOrName); } + /// + /// Gets an NPC by ID + /// + /// ID + /// NPC public NPC GetNPCById(int id) { NPC npc = new NPC(); @@ -290,6 +336,11 @@ namespace TShockAPI return npc; } + /// + /// Gets a NPC by name + /// + /// Name + /// List of matching NPCs public List GetNPCByName(string name) { //Method #1 - must be exact match, allows support for different coloured slimes @@ -314,16 +365,31 @@ namespace TShockAPI return found; } + /// + /// Gets a buff name by id + /// + /// ID + /// name public string GetBuffName(int id) { return (id > 0 && id < Main.maxBuffs) ? Main.buffName[id] : "null"; } + /// + /// Gets the description of a buff + /// + /// ID + /// description public string GetBuffDescription(int id) { return (id > 0 && id < Main.maxBuffs) ? Main.buffTip[id] : "null"; } + /// + /// Gets a list of buffs by name + /// + /// name + /// Matching list of buff ids public List GetBuffByName(string name) { for (int i = 1; i < Main.maxBuffs; i++) @@ -340,6 +406,11 @@ namespace TShockAPI return found; } + /// + /// Gets a prefix based on its id + /// + /// ID + /// Prefix name public string GetPrefixById(int id) { var item = new Item(); @@ -349,6 +420,11 @@ namespace TShockAPI return item.name.Trim(); } + /// + /// Gets a list of prefixes by name + /// + /// Name + /// List of prefix IDs public List GetPrefixByName(string name) { Item item = new Item(); @@ -377,6 +453,11 @@ namespace TShockAPI return found; } + /// + /// Gets a prefix by ID or name + /// + /// ID or name + /// List of prefix IDs public List GetPrefixByIdOrName(string idOrName) { int type = -1; @@ -624,6 +705,12 @@ namespace TShockAPI return true; } + /// + /// Searches for a projectile by identity and owner + /// + /// identity + /// owner + /// projectile ID public int SearchProjectile(short identity, int owner) { for (int i = 0; i < Main.maxProjectiles; i++) @@ -634,6 +721,11 @@ namespace TShockAPI return 1000; } + /// + /// Sanitizes input strings + /// + /// string + /// sanitized string public string SanitizeString(string str) { var returnstr = str.ToCharArray();