Cleanup with resharper (mostly removing redundancies & using collection.Length/Count properties instead of the Count method)

This commit is contained in:
Regalis
2016-10-31 20:35:04 +02:00
parent 5cc605bc01
commit eb2c51c2f1
46 changed files with 93 additions and 200 deletions
@@ -117,8 +117,6 @@ namespace Barotrauma.Items.Components
foreach (FabricableItem fi in fabricableItems)
{
Color color = ((itemList.CountChildren % 2) == 0) ? Color.Transparent : Color.Black * 0.3f;
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, 0, 50), Color.Transparent, null, itemList)
{
UserData = fi,
@@ -435,7 +433,7 @@ namespace Barotrauma.Items.Components
ItemContainer container = item.GetComponent<ItemContainer>();
foreach (Tuple<ItemPrefab, int> ip in fabricableItem.RequiredItems)
{
if (Array.FindAll(container.Inventory.Items, it => it != null && it.Prefab == ip.Item1).Count() < ip.Item2) return false;
if (Array.FindAll(container.Inventory.Items, it => it != null && it.Prefab == ip.Item1).Length < ip.Item2) return false;
}
return true;
@@ -434,13 +434,12 @@ namespace Barotrauma.Items.Components
{
IsActive = true;
int width = GuiFrame.Rect.Width, height = GuiFrame.Rect.Height;
int x = GuiFrame.Rect.X;
int y = GuiFrame.Rect.Y;
GuiFrame.Draw(spriteBatch);
float xOffset = (graphTimer / (float)updateGraphInterval);
float xOffset = graphTimer / updateGraphInterval;
//GUI.DrawRectangle(spriteBatch, new Rectangle(x, y, width, height), Color.Black, true);
@@ -108,9 +108,7 @@ namespace Barotrauma.Items.Components
connectedList.Add(this);
ApplyStatusEffects(ActionType.OnActive, deltaTime, null);
List<Connection> alreadyChecked = new List<Connection>();
List<Connection> connections = item.Connections;
if (connections == null) return;
@@ -151,8 +149,6 @@ namespace Barotrauma.Items.Components
{
fullPower += powerContainer.CurrPowerOutput;
}
alreadyChecked.Add(recipient);
}
else
{
+1 -1
View File
@@ -92,7 +92,7 @@ namespace Barotrauma.Items.Components
List<Body>ropeList = PathManager.EvenlyDistributeShapesAlongPath(GameMain.World, ropePath, shape, BodyType.Dynamic, (int)(length/sectionLength));
ropeBodies = new PhysicsBody[ropeList.Count()];
ropeBodies = new PhysicsBody[ropeList.Count];
for (int i = 0; i<ropeBodies.Length; i++)
{
ropeList[i].Mass = 0.01f;
@@ -12,7 +12,7 @@ namespace Barotrauma.Items.Components
{
private static Texture2D panelTexture;
private static Sprite connector;
private static Sprite wireCorner, wireVertical, wireHorizontal;
private static Sprite wireVertical;
//how many wires can be linked to a single connector
public const int MaxLinked = 5;
@@ -67,9 +67,7 @@ namespace Barotrauma.Items.Components
connector = new Sprite(panelTexture, new Rectangle(470, 102, 19,43), Vector2.Zero, 0.0f);
connector.Origin = new Vector2(9.5f, 10.0f);
wireCorner = new Sprite(panelTexture, new Rectangle(448, 0, 64, 64), new Vector2(-32.0f, -32.0f), 0.0f);
wireVertical = new Sprite(panelTexture, new Rectangle(408, 1, 11, 102), Vector2.Zero, 0.0f);
wireHorizontal = new Sprite(panelTexture, new Rectangle(496, 64, 16, 16), new Vector2(-8.0f, -8.0f), 0.0f);
}
this.item = item;
@@ -242,9 +240,7 @@ namespace Barotrauma.Items.Components
Vector2 leftWirePos = new Vector2(x+5, y + 30);
int wireInterval = (height - 20) / Math.Max(totalWireCount,1);
float rightWireX = x + width;
float leftWireX = x;
foreach (Connection c in panel.Connections)
{
//if dragging a wire, let the Inventory know so that the wire can be
@@ -484,8 +484,8 @@ namespace Barotrauma.Items.Components
if (Nodes == null || Nodes.Count == 0) return componentElement;
string[] nodeCoords = new string[Nodes.Count() * 2];
for (int i = 0; i < Nodes.Count(); i++)
string[] nodeCoords = new string[Nodes.Count * 2];
for (int i = 0; i < Nodes.Count; i++)
{
nodeCoords[i * 2] = Nodes[i].X.ToString(CultureInfo.InvariantCulture);
nodeCoords[i * 2 + 1] = Nodes[i].Y.ToString(CultureInfo.InvariantCulture);
+2 -11
View File
@@ -64,7 +64,7 @@ namespace Barotrauma.Items.Components
this.item = item;
var sprites = element.Elements().Where(x => x.Name.ToString() == "sprite").ToList();
int spriteCount = sprites.Count();
int spriteCount = sprites.Count;
wearableSprites = new WearableSprite[spriteCount];
limbType = new LimbType[spriteCount];
limb = new Limb[spriteCount];
@@ -171,19 +171,10 @@ namespace Barotrauma.Items.Components
base.Update(deltaTime, cam);
item.SetTransform(picker.SimPosition, 0.0f);
Item[] containedItems = item.ContainedItems;
ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker);
PlaySound(ActionType.OnWearing, picker.WorldPosition);
//if (containedItems == null) return;
//for (int j = 0; j < containedItems.Length; j++)
//{
// if (containedItems[j] == null) continue;
// containedItems[j].ApplyStatusEffects(ActionType.OnWearing, deltaTime, picker);
//}
}
protected override void RemoveComponentSpecific()