void CalculateUpkeepCost(BasePlayer player, string command, string[] args) { if (!permission.UserHasPermission(player.UserIDString, "tcmanager.upkeep") && !player.IsAdmin) { player.ChatMessage(Lang("NoCommandPermission", player.UserIDString)); return; } BuildingPrivlidge privilege = player.GetBuildingPrivilege(); if (!privilege) { player.ChatMessage(Lang("NoBuildingPrivilege", player.UserIDString)); return; } if (!privilege.IsAuthed(player) && !player.IsAdmin) { player.ChatMessage(Lang("NoAuthorization", player.UserIDString)); return; } if (args.Length == 0) // Default { List <ItemAmount> itemAmounts = Facepunch.Pool.GetList <ItemAmount>(); privilege.CalculateUpkeepCostAmounts(itemAmounts); player.ChatMessage(Lang("DefaultCostHeader", player.UserIDString)); player.ChatMessage(Lang("Line", player.UserIDString)); foreach (ItemAmount amount in itemAmounts) { player.ChatMessage(Lang("ItemCost", player.UserIDString, amount.itemDef.displayName.translated, Math.Ceiling(amount.amount))); } Facepunch.Pool.FreeList(ref itemAmounts); } else { BuildingGrade.Enum grade = BuildingGrade.Enum.None; switch (args[0].ToLower()) { case "0": grade = BuildingGrade.Enum.Twigs; break; case "1": grade = BuildingGrade.Enum.Wood; break; case "2": grade = BuildingGrade.Enum.Stone; break; case "3": grade = BuildingGrade.Enum.Metal; break; case "4": grade = BuildingGrade.Enum.TopTier; break; default: player.ChatMessage(Lang("UpkeepUsage", player.UserIDString)); return; } List <ItemAmount> itemAmounts = Facepunch.Pool.GetList <ItemAmount>(); BuildingManager.Building building = privilege.GetBuilding(); foreach (BuildingBlock block in building.buildingBlocks) { BuildingGrade.Enum original = block.grade; block.grade = grade; block.CalculateUpkeepCostAmounts(itemAmounts, privilege.CalculateUpkeepCostFraction()); block.grade = original; } player.ChatMessage(Lang("GradedCostHeader", player.UserIDString, grade)); player.ChatMessage(Lang("Line", player.UserIDString)); foreach (ItemAmount amount in itemAmounts) { player.ChatMessage(Lang("ItemCost", player.UserIDString, amount.itemDef.displayName.translated, Math.Ceiling(amount.amount))); } Facepunch.Pool.FreeList(ref itemAmounts); } }