Cleanup with resharper (mostly removing redundancies & using collection.Length/Count properties instead of the Count method)
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
//string str = sb.ToString();
|
||||
byte[] bytes = new byte[hashes.Count()*16];
|
||||
byte[] bytes = new byte[hashes.Count*16];
|
||||
for (int i = 0; i < hashes.Count; i++ )
|
||||
{
|
||||
hashes[i].CopyTo(bytes, i*16);
|
||||
|
||||
@@ -39,7 +39,7 @@ namespace Barotrauma
|
||||
LoadItemAsChild(subElement, null);
|
||||
}
|
||||
|
||||
if (requiredDeliveryAmount == 0) requiredDeliveryAmount = items.Count();
|
||||
if (requiredDeliveryAmount == 0) requiredDeliveryAmount = items.Count;
|
||||
}
|
||||
|
||||
private void LoadItemAsChild(XElement element, Item parent)
|
||||
|
||||
@@ -124,7 +124,7 @@ namespace Barotrauma
|
||||
|
||||
public int CountChildren
|
||||
{
|
||||
get { return children.Count(); }
|
||||
get { return children.Count; }
|
||||
}
|
||||
|
||||
public virtual Color Color
|
||||
|
||||
@@ -382,38 +382,14 @@ namespace Barotrauma
|
||||
//base.Draw(spriteBatch);
|
||||
|
||||
frame.Draw(spriteBatch);
|
||||
//GUI.DrawRectangle(spriteBatch, rect, color*alpha, true);
|
||||
|
||||
int x = rect.X, y = rect.Y;
|
||||
|
||||
if (!scrollBarHidden)
|
||||
{
|
||||
scrollBar.Draw(spriteBatch);
|
||||
if (scrollBar.IsHorizontal)
|
||||
{
|
||||
x -= (int)((totalSize - rect.Width) * scrollBar.BarScroll);
|
||||
}
|
||||
else
|
||||
{
|
||||
y -= (int)((totalSize - rect.Height) * scrollBar.BarScroll);
|
||||
}
|
||||
}
|
||||
|
||||
if (!scrollBarHidden) scrollBar.Draw(spriteBatch);
|
||||
|
||||
for (int i = 0; i < children.Count; i++)
|
||||
{
|
||||
GUIComponent child = children[i];
|
||||
if (child == frame || !child.Visible) continue;
|
||||
|
||||
if (scrollBar.IsHorizontal)
|
||||
{
|
||||
x += child.Rect.Width + spacing;
|
||||
}
|
||||
else
|
||||
{
|
||||
y += child.Rect.Height + spacing;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (scrollBar.IsHorizontal)
|
||||
{
|
||||
if (child.Rect.Right < rect.X) continue;
|
||||
@@ -421,7 +397,6 @@ namespace Barotrauma
|
||||
|
||||
if (child.Rect.X < rect.X && child.Rect.Right >= rect.X)
|
||||
{
|
||||
x = rect.X;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -432,7 +407,6 @@ namespace Barotrauma
|
||||
|
||||
if (child.Rect.Y < rect.Y && child.Rect.Y + child.Rect.Height >= rect.Y)
|
||||
{
|
||||
y = rect.Y;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -169,26 +169,16 @@ namespace Barotrauma
|
||||
|
||||
private void MoveButton()
|
||||
{
|
||||
//if (!enabled) return false;
|
||||
//if (barSize == 1.0f) return false;
|
||||
|
||||
int newX = bar.Rect.X - frame.Rect.X, newY = bar.Rect.Y - frame.Rect.Y;
|
||||
float moveAmount;
|
||||
if (isHorizontal)
|
||||
{
|
||||
moveAmount = PlayerInput.MouseSpeed.X;
|
||||
barScroll += moveAmount / (frame.Rect.Width - bar.Rect.Width);
|
||||
//newX = Math.Min(Math.Max(newX + moveAmount, 0), frame.Rect.Width - bar.Rect.Width);
|
||||
|
||||
//barScroll = (float)newX / ((float)frame.Rect.Width - (float)bar.Rect.Width);
|
||||
}
|
||||
else
|
||||
{
|
||||
moveAmount = PlayerInput.MouseSpeed.Y;
|
||||
barScroll += moveAmount / (frame.Rect.Height - bar.Rect.Height);
|
||||
//newY = Math.Min(Math.Max(newY+moveAmount, 0), frame.Rect.Height - bar.Rect.Height);
|
||||
|
||||
//barScroll = (float)newY / ((float)frame.Rect.Height - (float)bar.Rect.Height);
|
||||
}
|
||||
|
||||
BarScroll = barScroll;
|
||||
|
||||
@@ -234,7 +234,7 @@ namespace Barotrauma
|
||||
while (!SoundPlayer.Initialized)
|
||||
{
|
||||
i++;
|
||||
TitleScreen.LoadState = Math.Min((float)TitleScreen.LoadState + 40.0f / 41, 70.0f);
|
||||
TitleScreen.LoadState = Math.Min((float)TitleScreen.LoadState + 0.5f*i, 70.0f);
|
||||
yield return CoroutineStatus.Running;
|
||||
}
|
||||
|
||||
|
||||
@@ -261,7 +261,6 @@ namespace Barotrauma
|
||||
{
|
||||
if (leavingSub != Submarine.MainSub && !leavingSub.DockedTo.Contains(Submarine.MainSub))
|
||||
{
|
||||
Submarine oldMainSub = Submarine.MainSub;
|
||||
Submarine.MainSub = leavingSub;
|
||||
|
||||
GameMain.GameSession.Submarine = leavingSub;
|
||||
|
||||
@@ -186,18 +186,21 @@ namespace Barotrauma
|
||||
foreach (XAttribute attribute in subElement.Attributes())
|
||||
{
|
||||
InputType inputType;
|
||||
Keys key;
|
||||
int mouseButton;
|
||||
if (Enum.TryParse(attribute.Name.ToString(), true, out inputType))
|
||||
{
|
||||
int mouseButton;
|
||||
if (int.TryParse(attribute.Value.ToString(), out mouseButton))
|
||||
{
|
||||
keyMapping[(int)inputType] = new KeyOrMouse(mouseButton);
|
||||
}
|
||||
else if (Enum.TryParse(attribute.Value.ToString(), true, out key))
|
||||
else
|
||||
{
|
||||
keyMapping[(int)inputType] = new KeyOrMouse(key);
|
||||
}
|
||||
Keys key;
|
||||
if (Enum.TryParse(attribute.Value.ToString(), true, out key))
|
||||
{
|
||||
keyMapping[(int)inputType] = new KeyOrMouse(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -184,11 +184,6 @@ namespace Barotrauma
|
||||
placed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (placed)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -435,7 +435,7 @@ namespace Barotrauma
|
||||
int itemCapacity = container.Capacity;
|
||||
|
||||
var slot = slots[slotIndex];
|
||||
Rectangle containerRect = new Rectangle(slot.Rect.X - 5, slot.Rect.Y - (40 + 10) * itemCapacity - 5,
|
||||
new Rectangle(slot.Rect.X - 5, slot.Rect.Y - (40 + 10) * itemCapacity - 5,
|
||||
slot.Rect.Width + 10, slot.Rect.Height + (40 + 10) * itemCapacity + 10);
|
||||
|
||||
Rectangle subRect = slot.Rect;
|
||||
|
||||
@@ -507,11 +507,11 @@ namespace Barotrauma
|
||||
{
|
||||
if (parentInventory.Owner is Character)
|
||||
{
|
||||
CurrentHull = (parentInventory.Owner as Character).AnimController.CurrentHull;
|
||||
CurrentHull = ((Character)parentInventory.Owner).AnimController.CurrentHull;
|
||||
}
|
||||
else if (parentInventory.Owner is Item)
|
||||
{
|
||||
CurrentHull = (parentInventory.Owner as Item).CurrentHull;
|
||||
CurrentHull = ((Item)parentInventory.Owner).CurrentHull;
|
||||
}
|
||||
|
||||
Submarine = parentInventory.Owner.Submarine;
|
||||
@@ -969,7 +969,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
editingHUD = new GUIFrame(new Rectangle(x, y, width, 70 + (editableProperties.Count() + requiredItemCount) * 30), GUI.Style);
|
||||
editingHUD = new GUIFrame(new Rectangle(x, y, width, 70 + (editableProperties.Count + requiredItemCount) * 30), GUI.Style);
|
||||
editingHUD.Padding = new Vector4(10, 10, 0, 0);
|
||||
editingHUD.UserData = this;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -668,12 +668,10 @@ namespace Barotrauma.Networking
|
||||
}
|
||||
|
||||
if (!gameStarted) return;
|
||||
|
||||
List<Character> crew = new List<Character>();
|
||||
|
||||
foreach (Character c in Character.CharacterList)
|
||||
{
|
||||
if (!c.IsRemotePlayer || !c.IsHumanoid || c.Info==null) continue;
|
||||
crew.Add(c);
|
||||
}
|
||||
|
||||
//GameMain.GameSession.CrewManager.CreateCrewFrame(crew);
|
||||
@@ -772,13 +770,7 @@ namespace Barotrauma.Networking
|
||||
GameMain.GameSession.StartShift(levelSeed,loadSecondSub);
|
||||
|
||||
if (respawnAllowed) respawnManager = new RespawnManager(this, GameMain.NetLobbyScreen.SelectedShuttle);
|
||||
|
||||
|
||||
//myCharacter = ReadCharacterData(inc);
|
||||
//Character.Controlled = myCharacter;
|
||||
|
||||
List<Character> crew = new List<Character>();
|
||||
|
||||
|
||||
byte characterCount = inc.ReadByte();
|
||||
for (int i = 0; i < characterCount; i++)
|
||||
{
|
||||
@@ -819,7 +811,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
if (Screen.Selected == GameMain.GameScreen)
|
||||
{
|
||||
var cinematic = new TransitionCinematic(Submarine.MainSub, GameMain.GameScreen.Cam, endPreviewLength);
|
||||
new TransitionCinematic(Submarine.MainSub, GameMain.GameScreen.Cam, endPreviewLength);
|
||||
|
||||
float secondsLeft = endPreviewLength;
|
||||
|
||||
@@ -1053,9 +1045,7 @@ namespace Barotrauma.Networking
|
||||
if (votedClient == null) return false;
|
||||
|
||||
votedClient.AddKickVote(new Client(name, ID));
|
||||
|
||||
if (votedClient == null) return false;
|
||||
|
||||
|
||||
Vote(VoteType.Kick, votedClient);
|
||||
|
||||
button.Enabled = false;
|
||||
|
||||
@@ -1130,7 +1130,7 @@ namespace Barotrauma.Networking
|
||||
{
|
||||
float endPreviewLength = 10.0f;
|
||||
|
||||
var cinematic = new TransitionCinematic(Submarine.MainSub, GameMain.GameScreen.Cam, endPreviewLength);
|
||||
new TransitionCinematic(Submarine.MainSub, GameMain.GameScreen.Cam, endPreviewLength);
|
||||
|
||||
float secondsLeft = endPreviewLength;
|
||||
|
||||
@@ -1217,18 +1217,10 @@ namespace Barotrauma.Networking
|
||||
|
||||
private void UpdateCrewFrame()
|
||||
{
|
||||
List<Character> crew = new List<Character>();
|
||||
|
||||
foreach (Client c in connectedClients)
|
||||
{
|
||||
if (c.Character == null || !c.inGame) continue;
|
||||
|
||||
crew.Add(c.Character);
|
||||
}
|
||||
|
||||
if (myCharacter != null) crew.Add(myCharacter);
|
||||
|
||||
//if (GameMain.GameSession!=null) GameMain.GameSession.CrewManager.CreateCrewFrame(crew);
|
||||
}
|
||||
|
||||
public override void KickPlayer(string playerName, bool ban, bool range = false)
|
||||
@@ -1376,7 +1368,7 @@ namespace Barotrauma.Networking
|
||||
|
||||
int resentMessages = 0;
|
||||
|
||||
int clientListHeight = connectedClients.Count() * 40;
|
||||
int clientListHeight = connectedClients.Count * 40;
|
||||
float scrollBarHeight = (height - 110) / (float)Math.Max(clientListHeight, 110);
|
||||
|
||||
if (clientListScrollBar.BarSize != scrollBarHeight)
|
||||
|
||||
@@ -119,8 +119,9 @@ namespace Barotrauma.Networking
|
||||
|
||||
text = text.ToLower();
|
||||
|
||||
foreach (GUITextBlock textBlock in listBox.children)
|
||||
foreach (GUIComponent child in listBox.children)
|
||||
{
|
||||
var textBlock = child as GUITextBlock;
|
||||
if (textBlock == null) continue;
|
||||
|
||||
textBlock.Visible = textBlock.Text.ToLower().Contains(text);
|
||||
|
||||
@@ -152,10 +152,10 @@ namespace Barotrauma
|
||||
EditLimb(spriteBatch);
|
||||
|
||||
|
||||
int x = 0, y = 0;
|
||||
int y = 0;
|
||||
for (int i = 0; i < textures.Count; i++ )
|
||||
{
|
||||
x = GameMain.GraphicsWidth - textures[i].Width;
|
||||
int x = GameMain.GraphicsWidth - textures[i].Width;
|
||||
spriteBatch.Draw(textures[i], new Vector2(x, y), Color.White);
|
||||
|
||||
foreach (Limb limb in editingCharacter.AnimController.Limbs)
|
||||
|
||||
@@ -304,7 +304,7 @@ namespace Barotrauma
|
||||
|
||||
for (int i = 0; i<dummyCharacter.Inventory.SlotPositions.Length; i++)
|
||||
{
|
||||
dummyCharacter.Inventory.SlotPositions[i].X += false ? -1000 : leftPanel.Rect.Width+10;
|
||||
dummyCharacter.Inventory.SlotPositions[i].X += leftPanel.Rect.Width+10;
|
||||
}
|
||||
|
||||
Character.Controlled = dummyCharacter;
|
||||
@@ -472,16 +472,14 @@ namespace Barotrauma
|
||||
var deleteButton = new GUIButton(new Rectangle(0, 0, 70, 20), "Delete", Alignment.BottomLeft, GUI.Style, loadFrame);
|
||||
deleteButton.Enabled = false;
|
||||
deleteButton.UserData = "delete";
|
||||
deleteButton.OnClicked = (GUIButton btn, object userdata) =>
|
||||
deleteButton.OnClicked = (btn, userdata) =>
|
||||
{
|
||||
var subListBox = loadFrame.GetChild<GUIListBox>();
|
||||
|
||||
if (subList.Selected!=null)
|
||||
{
|
||||
Submarine sub = subList.Selected.UserData as Submarine;
|
||||
try
|
||||
{
|
||||
System.IO.File.Delete(sub.FilePath);
|
||||
File.Delete(sub.FilePath);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace Barotrauma
|
||||
null, null, null, null,
|
||||
cam.Transform);
|
||||
|
||||
Submarine.DrawBack(spriteBatch,false,s => s is Structure && ((s as Structure).resizeHorizontal || (s as Structure).resizeVertical));
|
||||
Submarine.DrawBack(spriteBatch,false,s => s is Structure && (((Structure)s).resizeHorizontal || ((Structure)s).resizeVertical));
|
||||
|
||||
spriteBatch.End();
|
||||
|
||||
@@ -258,7 +258,7 @@ namespace Barotrauma
|
||||
null, null, null, null,
|
||||
cam.Transform);
|
||||
|
||||
Submarine.DrawBack(spriteBatch, false, s => (!(s is Structure)) || (!(s as Structure).resizeHorizontal && !(s as Structure).resizeHorizontal));
|
||||
Submarine.DrawBack(spriteBatch, false, s => !(s is Structure) || (!((Structure)s).resizeHorizontal && !((Structure)s).resizeHorizontal));
|
||||
|
||||
foreach (Character c in Character.CharacterList) c.Draw(spriteBatch);
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Barotrauma
|
||||
|
||||
var subsToShow = Submarine.SavedSubmarines.Where(s => !s.HasTag(SubmarineTag.HideInMenus));
|
||||
|
||||
foreach (Submarine sub in Submarine.SavedSubmarines)
|
||||
foreach (Submarine sub in subsToShow)
|
||||
{
|
||||
var textBlock = new GUITextBlock(
|
||||
new Rectangle(0, 0, 0, 25),
|
||||
|
||||
@@ -9,12 +9,10 @@ using FarseerPhysics.Dynamics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
partial class NetLobbyScreen : Screen
|
||||
class NetLobbyScreen : Screen
|
||||
{
|
||||
private GUIFrame menu;
|
||||
private GUIFrame infoFrame;
|
||||
@@ -1062,10 +1060,10 @@ namespace Barotrauma
|
||||
//}
|
||||
|
||||
GameModePreset modePreset = obj as GameModePreset;
|
||||
missionTypeBlock.Visible = modePreset.Name == "Mission";
|
||||
|
||||
if (modePreset == null) return false;
|
||||
|
||||
missionTypeBlock.Visible = modePreset.Name == "Mission";
|
||||
|
||||
valueChanged = true;
|
||||
|
||||
return true;
|
||||
|
||||
@@ -176,13 +176,13 @@ namespace Barotrauma
|
||||
passwordBox.Enabled = false;
|
||||
passwordBox.UserData = "password";
|
||||
|
||||
var nameText = new GUITextBlock(new Rectangle(columnX[0], 0, 0, 0), serverName, GUI.Style, serverFrame);
|
||||
new GUITextBlock(new Rectangle(columnX[0], 0, 0, 0), serverName, GUI.Style, serverFrame);
|
||||
|
||||
int playerCount = 0, maxPlayers = 1;
|
||||
int.TryParse(currPlayersStr, out playerCount);
|
||||
int.TryParse(maxPlayersStr, out maxPlayers);
|
||||
|
||||
var playerCountText = new GUITextBlock(new Rectangle(columnX[1], 0, 0, 0), playerCount + "/" + maxPlayers, GUI.Style, serverFrame);
|
||||
new GUITextBlock(new Rectangle(columnX[1], 0, 0, 0), playerCount + "/" + maxPlayers, GUI.Style, serverFrame);
|
||||
|
||||
var gameStartedBox = new GUITickBox(new Rectangle(columnX[2] + (columnX[3] - columnX[2])/ 2, 0, 20, 20), "", Alignment.TopLeft, serverFrame);
|
||||
gameStartedBox.Selected = gameStarted == "1";
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace Barotrauma
|
||||
|
||||
if (xDamageSounds.Any())
|
||||
{
|
||||
damageSounds = new DamageSound[xDamageSounds.Count()];
|
||||
damageSounds = new DamageSound[xDamageSounds.Count];
|
||||
int i = 0;
|
||||
foreach (XElement element in xDamageSounds)
|
||||
{
|
||||
@@ -249,7 +249,7 @@ namespace Barotrauma
|
||||
|
||||
if (suitableMusic.Count > 0 && !suitableMusic.Contains(currentMusic))
|
||||
{
|
||||
int index = Rand.Int(suitableMusic.Count());
|
||||
int index = Rand.Int(suitableMusic.Count);
|
||||
|
||||
if (currentMusic == null || suitableMusic[index].file != currentMusic.file)
|
||||
{
|
||||
@@ -355,7 +355,7 @@ namespace Barotrauma
|
||||
var sounds = damageSounds.Where(x => damage >= x.damageRange.X && damage <= x.damageRange.Y && x.damageType == damageType).ToList();
|
||||
if (!sounds.Any()) return;
|
||||
|
||||
int selectedSound = Rand.Int(sounds.Count());
|
||||
int selectedSound = Rand.Int(sounds.Count);
|
||||
|
||||
sounds[selectedSound].sound.Play(1.0f, range, position);
|
||||
Debug.WriteLine("playing: " + sounds[selectedSound].sound);
|
||||
|
||||
@@ -510,7 +510,7 @@ namespace Barotrauma
|
||||
StreamReader file = new StreamReader(filePath);
|
||||
|
||||
var lines = File.ReadLines(filePath).ToList();
|
||||
int lineCount = lines.Count();
|
||||
int lineCount = lines.Count;
|
||||
|
||||
if (lineCount == 0)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user