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
@@ -118,10 +118,7 @@ namespace Barotrauma
}
if (canOpenDoors && !character.LockHands) CheckDoorsInPath();
float allowedDistance = character.AnimController.InWater ? 1.0f : 0.6f;
//if (currentPath.CurrentNode!=null && currentPath.CurrentNode.SimPosition.Y > character.SimPosition.Y+1.0f) allowedDistance*=0.5f;
Vector2 pos = host.SimPosition;
if (character != null && currentPath.CurrentNode != null)
@@ -159,9 +156,7 @@ namespace Barotrauma
}
if (currentPath.CurrentNode == null) return Vector2.Zero;
var hull = character.AnimController.CurrentHull;
if (character.AnimController.Anim == AnimController.Animation.Climbing)
{
Vector2 diff = currentPath.CurrentNode.SimPosition - pos;
@@ -163,7 +163,6 @@ namespace Barotrauma
case NetworkEventType.ImportantEntityUpdate:
Vector2 limbPos = AnimController.MainLimb.SimPosition;
float rotation = AnimController.MainLimb.Rotation;
try
{
@@ -160,10 +160,7 @@ namespace Barotrauma
void UpdateSineAnim(float deltaTime)
{
movement = TargetMovement*swimSpeed;
Limb torso = GetLimb(LimbType.Torso);
Limb head = GetLimb(LimbType.Head);
MainLimb.pullJoint.Enabled = true;
MainLimb.pullJoint.WorldAnchorB = collider.SimPosition;
@@ -193,7 +190,7 @@ namespace Barotrauma
}
for (int i = 0; i < Limbs.Count(); i++)
for (int i = 0; i < Limbs.Length; i++)
{
if (Limbs[i].SteerForce <= 0.0f) continue;
@@ -23,15 +23,7 @@ namespace Barotrauma
private float inWaterTimer;
private bool swimming;
protected override float HeadPosition
{
get
{
return Crouching ? base.HeadPosition : base.HeadPosition;
}
}
protected override float TorsoPosition
{
get
@@ -255,7 +247,7 @@ namespace Barotrauma
if (limb.inWater) limbsInWater++;
}
float slowdownFactor = (float)limbsInWater / (float)Limbs.Count();
float slowdownFactor = (float)limbsInWater / (float)Limbs.Length;
float maxSpeed = Math.Max(TargetMovement.Length() - slowdownFactor, 1.0f);
// if (character.SelectedCharacter!=null) maxSpeed = Math.Min(maxSpeed, 1.0f);
@@ -430,7 +422,7 @@ namespace Barotrauma
}
else
{
float movementFactor = (movement.X / 4.0f) * movement.X * Math.Sign(movement.X);
//float movementFactor = (movement.X / 4.0f) * movement.X * Math.Sign(movement.X);
for (int i = -1; i < 2; i += 2)
{
@@ -578,7 +578,7 @@ namespace Barotrauma
{
dir = (dir == Direction.Left) ? Direction.Right : Direction.Left;
for (int i = 0; i < limbJoints.Count(); i++)
for (int i = 0; i < limbJoints.Length; i++)
{
float lowerLimit = -limbJoints[i].UpperLimit;
float upperLimit = -limbJoints[i].LowerLimit;
@@ -591,7 +591,7 @@ namespace Barotrauma
}
for (int i = 0; i < Limbs.Count(); i++)
for (int i = 0; i < Limbs.Length; i++)
{
if (Limbs[i] == null) continue;
@@ -834,7 +834,7 @@ namespace Barotrauma
{
//create a splash particle
var p = GameMain.ParticleManager.CreateParticle("watersplash",
GameMain.ParticleManager.CreateParticle("watersplash",
new Vector2(limb.Position.X, limbHull.Surface) + limbHull.Submarine.Position,
new Vector2(0.0f, Math.Abs(-limb.LinearVelocity.Y * 20.0f)),
0.0f, limbHull);
+6 -6
View File
@@ -576,9 +576,9 @@ namespace Barotrauma
var soundElements = doc.Root.Elements("sound").ToList();
if (soundElements.Any())
{
sounds = new Sound[soundElements.Count()];
soundStates = new AIController.AiState[soundElements.Count()];
soundRange = new float[soundElements.Count()];
sounds = new Sound[soundElements.Count];
soundStates = new AIController.AiState[soundElements.Count];
soundRange = new float[soundElements.Count];
int i = 0;
foreach (XElement soundElement in soundElements)
{
@@ -801,7 +801,7 @@ namespace Barotrauma
{
attackPos = Submarine.LastPickedPosition;
if (body != null && body.UserData is Submarine)
if (body.UserData is Submarine)
{
var sub = ((Submarine)body.UserData);
@@ -1439,10 +1439,10 @@ namespace Barotrauma
if (sounds == null || !sounds.Any()) return;
var matchingSoundStates = soundStates.Where(x => x == state).ToList();
int selectedSound = Rand.Int(matchingSoundStates.Count());
int selectedSound = Rand.Int(matchingSoundStates.Count);
int n = 0;
for (int i = 0; i < sounds.Count(); i++)
for (int i = 0; i < sounds.Length; i++)
{
if (soundStates[i] != state) continue;
if (n == selectedSound && sounds[i]!=null)
@@ -1,8 +1,5 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma
{
+6 -6
View File
@@ -92,8 +92,8 @@ namespace Barotrauma
type = (ActionType)Enum.Parse(typeof(ActionType), split[0], true);
string[] containingNames = split[1].Split(',');
onContainingNames = new string[containingNames.Count()];
for (int i =0; i < containingNames.Count(); i++)
onContainingNames = new string[containingNames.Length];
for (int i =0; i < containingNames.Length; i++)
{
onContainingNames[i] = containingNames[i].Trim();
}
@@ -116,8 +116,8 @@ namespace Barotrauma
break;
case "targetnames":
string[] names = attribute.Value.Split(',');
targetNames = new string[names.Count()];
for (int i=0; i < names.Count(); i++ )
targetNames = new string[names.Length];
for (int i=0; i < names.Length; i++ )
{
targetNames[i] = names[i].Trim();
}
@@ -134,7 +134,7 @@ namespace Barotrauma
}
}
int count = propertyAttributes.Count();
int count = propertyAttributes.Count;
propertyNames = new string[count];
propertyEffects = new object[count];
@@ -227,7 +227,7 @@ namespace Barotrauma
foreach (IPropertyObject target in targets)
{
for (int i = 0; i < propertyNames.Count(); i++)
for (int i = 0; i < propertyNames.Length; i++)
{
ObjectProperty property;