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

View File

@@ -249,7 +249,7 @@ namespace Barotrauma
if (c.Position.X < position.X - range || c.Position.X > position.X + size.X + range) continue;
if (c.Position.Y < position.Y - size.Y || c.Position.Y > hull.Rect.Y) continue;
float dmg = (float)Math.Sqrt(size.X) * deltaTime / c.AnimController.Limbs.Count();
float dmg = (float)Math.Sqrt(size.X) * deltaTime / c.AnimController.Limbs.Length;
foreach (Limb limb in c.AnimController.Limbs)
{
if (limb.WearingItems.Find(w => w!=null && w.WearableComponent.Item.FireProof)!=null) continue;

View File

@@ -311,7 +311,7 @@ namespace Barotrauma
positionsOfInterest.Add(new InterestingPosition(tunnel.Last(), PositionType.Cave));
if (tunnel.Count() > 4) positionsOfInterest.Add(new InterestingPosition(tunnel[tunnel.Count() / 2], PositionType.Cave));
if (tunnel.Count > 4) positionsOfInterest.Add(new InterestingPosition(tunnel[tunnel.Count / 2], PositionType.Cave));
pathCells.AddRange(newPathCells);
}

View File

@@ -271,8 +271,6 @@ namespace Barotrauma.RuinGeneration
foreach (Corridor corridor in corridors)
{
List<Line> corridorWalls = new List<Line>();
corridor.CreateWalls();
foreach (BTRoom leaf in rooms)
@@ -361,7 +359,7 @@ namespace Barotrauma.RuinGeneration
var prop = RuinStructure.GetRandom(RuinStructureType.Prop, alignments[Rand.Int(alignments.Length, false)]);
Vector2 size = (prop.Prefab is StructurePrefab) ? (prop.Prefab as StructurePrefab).Size : Vector2.Zero;
Vector2 size = (prop.Prefab is StructurePrefab) ? ((StructurePrefab)prop.Prefab).Size : Vector2.Zero;
var shape = shapes[Rand.Int(shapes.Count, false)];
@@ -385,7 +383,7 @@ namespace Barotrauma.RuinGeneration
if (prop.Prefab is ItemPrefab)
{
var item = new Item(prop.Prefab as ItemPrefab, position, null);
var item = new Item((ItemPrefab)prop.Prefab, position, null);
item.MoveWithLevel = true;
}
else

View File

@@ -182,7 +182,7 @@ namespace Barotrauma.Lights
{
ClearCachedShadows();
for (int i = 0; i < vertices.Count(); i++)
for (int i = 0; i < vertices.Length; i++)
{
vertices[i] += amount;
losVertices[i] += amount;

View File

@@ -98,8 +98,8 @@ namespace Barotrauma.Lights
public LightSource (XElement element)
: this(Vector2.Zero, 100.0f, Color.White, null)
{
float range = ToolBox.GetAttributeFloat(element, "range", 100.0f);
Color color = new Color(ToolBox.GetAttributeVector4(element, "color", Vector4.One));
range = ToolBox.GetAttributeFloat(element, "range", 100.0f);
color = new Color(ToolBox.GetAttributeVector4(element, "color", Vector4.One));
CastShadows = ToolBox.GetAttributeBool(element, "castshadows", true);

View File

@@ -95,10 +95,7 @@ namespace Barotrauma
(int)sl.wallVertices.Max(v => v.Y + position.Y),
(int)sl.wallVertices.Max(v => v.X + position.X),
(int)sl.wallVertices.Min(v => v.Y + position.Y));
int width = sl.rect.Width - sl.rect.X;
int height = sl.rect.Y - sl.rect.Height;
sl.rect = new Rectangle((int)position.X, (int)position.Y, 1, 1);
return sl;

View File

@@ -180,7 +180,7 @@ namespace Barotrauma
{
base.Move(amount);
for (int i = 0; i < sections.Count(); i++)
for (int i = 0; i < sections.Length; i++)
{
Rectangle r = sections[i].rect;
r.X += (int)amount.X;
@@ -867,7 +867,7 @@ namespace Barotrauma
(int)(rect.Y - Submarine.HiddenSubPosition.Y) + "," +
rect.Width + "," + rect.Height));
for (int i = 0; i < sections.Count(); i++)
for (int i = 0; i < sections.Length; i++)
{
if (sections[i].damage == 0.0f) continue;
@@ -985,7 +985,7 @@ namespace Barotrauma
// int sectionCount = message.ReadByte();
for (int i = 0; i<sections.Count(); i++)
for (int i = 0; i<sections.Length; i++)
{
//byte sectionIndex = message.ReadByte();
float damage = message.ReadRangedSingle(0.0f, 1.0f, 8) * Health;

View File

@@ -162,7 +162,7 @@ namespace Barotrauma
{
get
{
return subBody ==null ? Vector2.Zero : subBody.Position;
return subBody == null ? Vector2.Zero : subBody.Position;
}
}
@@ -481,7 +481,7 @@ namespace Barotrauma
if (Vector2.Distance(rayStart, rayEnd) < 0.01f)
{
closestFraction = 0.01f;
lastPickedPosition = rayEnd;
return null;
}
@@ -517,7 +517,7 @@ namespace Barotrauma
//movement ----------------------------------------------------
private bool flippedX = false;
private bool flippedX;
public bool FlippedX
{
get { return flippedX; }
@@ -634,9 +634,7 @@ namespace Barotrauma
public void SetPosition(Vector2 position)
{
if (!MathUtils.IsValid(position)) return;
Vector2 prevPos = subBody.Position;
subBody.SetPosition(position);
foreach (Submarine sub in loaded)
@@ -665,7 +663,7 @@ namespace Barotrauma
{
Submarine closest = null;
float closestDist = 0.0f;
foreach (Submarine sub in Submarine.loaded)
foreach (Submarine sub in loaded)
{
float dist = Vector2.Distance(worldPosition, sub.WorldPosition);
if (closest == null || dist < closestDist)

View File

@@ -397,7 +397,7 @@ namespace Barotrauma
int particleAmount = (int)(wallImpact*10.0f);
for (int i = 0; i < particleAmount; i++)
{
var particle = GameMain.ParticleManager.CreateParticle("iceshards",
GameMain.ParticleManager.CreateParticle("iceshards",
ConvertUnits.ToDisplayUnits(particlePos[0]) + Rand.Vector(Rand.Range(1.0f, 50.0f)),
Rand.Vector(Rand.Range(50.0f,500.0f)) + Velocity);
}