Some cleanup using ReSharper (mostly removing redundancies)

This commit is contained in:
Regalis
2016-03-12 15:32:34 +02:00
parent ae4e4d8f34
commit d1580328ed
99 changed files with 197 additions and 483 deletions

View File

@@ -63,12 +63,7 @@ namespace FarseerPhysics.Collision.Shapes
{
ShapeType = ShapeType.Chain;
_radius = Settings.PolygonRadius;
if (!(vertices != null && vertices.Count >= 2))
{
int lkmsdgkldf = 1;
}
Debug.Assert(vertices != null && vertices.Count >= 2);
Debug.Assert(vertices[0] != vertices[vertices.Count - 1]); // FPE. See http://www.box2d.org/forum/viewtopic.php?f=4&t=7973&p=35363

View File

@@ -1,10 +1,7 @@
using Barotrauma.Items.Components;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma
{
@@ -137,7 +134,7 @@ namespace Barotrauma
List<GUIComponent> prevCharacterFrames = new List<GUIComponent>();
foreach (GUIComponent child in frame.children)
{
if (child.UserData as Character == null) continue;
if (!(child.UserData is Character)) continue;
prevCharacterFrames.Add(child);
}
@@ -155,8 +152,6 @@ namespace Barotrauma
int spacing = 5;
int rows = (int)Math.Ceiling((double)aliveCharacters.Count / charactersPerRow);
int i = 0;
foreach (Character character in aliveCharacters)
{
@@ -164,7 +159,7 @@ namespace Barotrauma
//if (i >= aliveCharacters.Count - charactersPerRow && aliveCharacters.Count % charactersPerRow > 0) rowCharacterCount = aliveCharacters.Count % charactersPerRow;
// rowCharacterCount = Math.Min(rowCharacterCount, aliveCharacters.Count - i);
int startX = (int)-(150 * rowCharacterCount + spacing * (rowCharacterCount - 1)) / 2;
int startX = -(150 * rowCharacterCount + spacing * (rowCharacterCount - 1)) / 2;
int x = startX + (150 + spacing) * (i % Math.Min(charactersPerRow, aliveCharacters.Count));
@@ -229,7 +224,6 @@ namespace Barotrauma
{
Order order = userData as Order;
List<Character> selectedCharacters = new List<Character>();
foreach (GUIComponent child in frame.children)
{
var characterButton = child as GUIButton;
@@ -258,7 +252,7 @@ namespace Barotrauma
var humanAi = character.AIController as HumanAIController;
if (humanAi == null) return;
var existingOrder = characterFrame.children.Find(c => c.UserData as Order != null);
var existingOrder = characterFrame.children.Find(c => c.UserData is Order);
if (existingOrder != null) characterFrame.RemoveChild(existingOrder);
var orderFrame = new GUIFrame(new Rectangle(-5, characterFrame.Rect.Height, characterFrame.Rect.Width, 30 + order.Options.Length * 15), null, characterFrame);

View File

@@ -71,7 +71,7 @@ namespace Barotrauma
targetMemories = new Dictionary<AITarget, AITargetMemory>();
XDocument doc = ToolBox.TryLoadXml(file);
if (doc == null) return;
if (doc == null || doc.Root == null) return;
XElement aiElement = doc.Root.Element("ai");
if (aiElement == null) return;
@@ -474,7 +474,7 @@ namespace Barotrauma
}
else if (closestStructure!=null)
{
valueModifier = valueModifier / (closestStructure as IDamageable).Health;
valueModifier = valueModifier / ((IDamageable)closestStructure).Health;
}
else
{

View File

@@ -1,9 +1,5 @@
using FarseerPhysics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma
{

View File

@@ -1,9 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using FarseerPhysics;
using Barotrauma.Items.Components;
namespace Barotrauma

View File

@@ -66,7 +66,7 @@ namespace Barotrauma
}
var pickedBody = Submarine.PickBody(character.SimPosition, enemy.SimPosition, ignoredBodies);
if (pickedBody != null && pickedBody.UserData as Limb == null) return;
if (pickedBody != null && !(pickedBody.UserData is Limb)) return;
weapon.Use(deltaTime, character);
}

View File

@@ -1,9 +1,6 @@
using Barotrauma.Items.Components;
using Microsoft.Xna.Framework;
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma
{
@@ -59,10 +56,6 @@ namespace Barotrauma
}
else
{
var pathSteering = character.AIController.SteeringManager as IndoorsSteeringManager;
Hull bestHull = null;
float bestValue = currenthullSafety;
@@ -75,7 +68,7 @@ namespace Barotrauma
hullValue -= (float)Math.Sqrt(Math.Abs(character.Position.X- hull.Position.X));
hullValue -= (float)Math.Sqrt(Math.Abs(character.Position.Y - hull.Position.Y)*2.0f);
if (bestHull==null || hullValue > bestValue)
if (bestHull == null || hullValue > bestValue)
{
bestHull = hull;
bestValue = hullValue;

View File

@@ -1,8 +1,6 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma
{

View File

@@ -2,9 +2,6 @@
using FarseerPhysics;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma
{

View File

@@ -1,8 +1,6 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma
{
@@ -119,7 +117,7 @@ namespace Barotrauma
public override bool IsDuplicate(AIObjective otherObjective)
{
return (otherObjective as AIObjectiveIdle != null);
return (otherObjective is AIObjectiveIdle);
}
}
}

View File

@@ -1,8 +1,5 @@
using Barotrauma.Items.Components;
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma
{

View File

@@ -35,7 +35,7 @@ namespace Barotrauma
PrefabList = new List<Order>();
XDocument doc = ToolBox.TryLoadXml(ConfigFile);
if (doc == null) return;
if (doc == null || doc.Root == null) return;
foreach (XElement orderElement in doc.Root.Elements())
{

View File

@@ -1,5 +1,4 @@
using FarseerPhysics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.Linq;
@@ -80,7 +79,7 @@ namespace Barotrauma
public delegate float? GetNodePenaltyHandler(PathNode node, PathNode prevNode);
public GetNodePenaltyHandler GetNodePenalty;
List<PathNode> nodes;
private List<PathNode> nodes;
private bool insideSubmarine;
@@ -181,12 +180,13 @@ namespace Barotrauma
endNode = node;
if (startNode != null) break;
}
}
if (startNode==null || endNode==null)
{
DebugConsole.ThrowError("Pathfinding error, couldn't find matching pathnodes to waypoints");
return new SteeringPath();
}
if (startNode == null || endNode == null)
{
DebugConsole.ThrowError("Pathfinding error, couldn't find matching pathnodes to waypoints");
return new SteeringPath();
}
return FindPath(startNode, endNode);

View File

@@ -151,7 +151,7 @@ namespace Barotrauma
}
else if (closestBody.UserData is Item)
{
Item item = closestBody.UserData as Item;
Item item = (Item)closestBody.UserData;
avoidSteering = Vector2.Normalize(Submarine.LastPickedPosition - item.SimPosition);
}
else

View File

@@ -747,12 +747,13 @@ namespace Barotrauma
torso.body.ApplyForce((climbForce * 40.0f + subSpeed*50.0f) * torso.Mass);
head.body.SmoothRotate(0.0f);
Rectangle trigger = character.SelectedConstruction.Prefab.Triggers.FirstOrDefault();
if (trigger == null)
if (!character.SelectedConstruction.Prefab.Triggers.Any())
{
character.SelectedConstruction = null;
return;
}
Rectangle trigger = character.SelectedConstruction.Prefab.Triggers.FirstOrDefault();
trigger = character.SelectedConstruction.TransformTrigger(trigger);
bool notClimbing = false;

View File

@@ -301,7 +301,7 @@ namespace Barotrauma
{
Structure structure = f2.Body.UserData as Structure;
if (f2.Body.UserData as Submarine != null && character.Submarine == f2.Body.UserData as Submarine) return false;
if (f2.Body.UserData is Submarine && character.Submarine == (Submarine)f2.Body.UserData) return false;
//always collides with bodies other than structures
if (structure == null)
@@ -385,7 +385,7 @@ namespace Barotrauma
avgVelocity = avgVelocity / Limbs.Count();
if (character.Submarine == null && f2.Body.UserData is Submarine) avgVelocity -= (f2.Body.UserData as Submarine).Velocity;
if (character.Submarine == null && f2.Body.UserData is Submarine) avgVelocity -= ((Submarine)f2.Body.UserData).Velocity;
float impact = Vector2.Dot(avgVelocity, -normal);

View File

@@ -128,19 +128,6 @@ namespace Barotrauma
public AttackResult DoDamage(IDamageable attacker, IDamageable target, Vector2 worldPosition, float deltaTime, bool playSound = true)
{
float damageAmount = 0.0f;
//DamageSoundType damageSoundType = DamageSoundType.None;
if (target as Character == null)
{
damageAmount = structureDamage;
}
else
{
damageAmount = damage;
}
if (particleEmitterPrefab != null)
{
particleEmitterPrefab.Emit(worldPosition);

View File

@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Xml.Linq;
namespace Barotrauma
{

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Barotrauma

View File

@@ -365,11 +365,6 @@ namespace Barotrauma
public delegate void OnDeathHandler(Character character, CauseOfDeath causeOfDeath);
public OnDeathHandler OnDeath;
public static Character Create(string file, Vector2 position)
{
return Create(file, position, null);
}
public static Character Create(CharacterInfo characterInfo, Vector2 position, bool isNetworkPlayer = false, bool hasAi=true)
{
return Create(characterInfo.File, position, characterInfo, isNetworkPlayer, hasAi);
@@ -387,23 +382,18 @@ namespace Barotrauma
return enemyCharacter;
}
else
if (hasAi && !isNetworkPlayer)
{
if (hasAi && !isNetworkPlayer)
{
var character = new AICharacter(file, position, characterInfo, isNetworkPlayer);
var ai = new HumanAIController(character);
character.SetAI(ai);
var character = new AICharacter(file, position, characterInfo, isNetworkPlayer);
var ai = new HumanAIController(character);
character.SetAI(ai);
return character;
return character;
}
else
{
return new Character(file, position, characterInfo, isNetworkPlayer);
}
}
return new Character(file, position, characterInfo, isNetworkPlayer);
}
protected Character(string file, Vector2 position, CharacterInfo characterInfo = null, bool isNetworkPlayer = false)

View File

@@ -187,7 +187,7 @@ namespace Barotrauma
public GUIFrame CreateInfoFrame(GUIFrame frame)
{
GUIImage image = new GUIImage(new Rectangle(0,0,30,30), HeadSprite, Alignment.TopLeft, frame);
new GUIImage(new Rectangle(0,0,30,30), HeadSprite, Alignment.TopLeft, frame);
SpriteFont font = frame.Rect.Width<280 ? GUI.SmallFont : GUI.Font;

View File

@@ -1,5 +1,4 @@
using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Xml.Linq;
namespace Barotrauma

View File

@@ -1,8 +1,5 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Barotrauma
@@ -10,7 +7,7 @@ namespace Barotrauma
class Job
{
private JobPrefab prefab;
private readonly JobPrefab prefab;
private Dictionary<string, Skill> skills;

View File

@@ -160,7 +160,7 @@ namespace Barotrauma
foreach (string filePath in filePaths)
{
XDocument doc = ToolBox.TryLoadXml(filePath);
if (doc == null) return;
if (doc == null || doc.Root == null) return;
foreach (XElement element in doc.Root.Elements())
{

View File

@@ -1,17 +1,13 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Barotrauma
{
class SkillPrefab
{
string name;
private string name;
string description;
private string description;
private Vector2 levelRange;

View File

@@ -1,5 +1,4 @@
using FarseerPhysics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -274,20 +273,20 @@ namespace Barotrauma
Type type = value.GetType();
if (type == typeof(float) ||
(type == typeof(int) && property.GetValue().GetType() == typeof(float)))
(type == typeof(int) && property.GetValue() is float))
{
float floatValue = Convert.ToSingle(value) * deltaTime;
if (!setValue) floatValue += (float)property.GetValue();
property.TrySetValue(floatValue);
}
else if (type == typeof(int) && value.GetType()==typeof(int))
else if (type == typeof(int) && value is int)
{
int intValue = (int)((int)value * deltaTime);
if (!setValue) intValue += (int)property.GetValue();
property.TrySetValue(intValue);
}
else if (type == typeof(bool) && value.GetType() == typeof(bool))
else if (type == typeof(bool) && value is bool)
{
property.TrySetValue((bool)value);
}

View File

@@ -1,8 +1,6 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma
{
@@ -14,7 +12,7 @@ namespace Barotrauma
// Keeps track of all running coroutines, and runs them till the end.
static class CoroutineManager
{
static List<IEnumerator<object>> Coroutines = new List<IEnumerator<object>>();
static readonly List<IEnumerator<object>> Coroutines = new List<IEnumerator<object>>();
public static float DeltaTime;

View File

@@ -1,9 +1,4 @@
using FarseerPhysics;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using System.Xml.Linq;
namespace Barotrauma

View File

@@ -36,7 +36,7 @@ namespace Barotrauma
int amount = Rand.Range(minAmount, maxAmount, false);
monsters = new AICharacter[amount];
monsters = new Character[amount];
for (int i = 0; i < amount; i++)
{
@@ -64,14 +64,14 @@ namespace Barotrauma
if (isFinished) return;
bool monstersDead = true;
for (int i = 0; i < monsters.Length; i++)
foreach (Character monster in monsters)
{
if (monsters[i].IsDead) continue;
if (monster.IsDead) continue;
if (!isStarted && Vector2.Distance(monsters[i].WorldPosition, Submarine.Loaded.WorldPosition) < 5000.0f) isStarted = true;
if (!isStarted && Vector2.Distance(monster.WorldPosition, Submarine.Loaded.WorldPosition) < 5000.0f) isStarted = true;
monstersDead = false;
break;
break;
}
if (monstersDead) Finished();

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Xml.Linq;

View File

@@ -1,7 +1,6 @@
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Linq;
namespace Barotrauma
{
@@ -22,11 +21,7 @@ namespace Barotrauma
{
get
{
foreach (Task task in tasks)
{
if (task.Priority >= CriticalPriority) return true;
}
return false;
return tasks.Any(task => task.Priority >= CriticalPriority);
}
}

View File

@@ -1,8 +1,5 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Barotrauma

View File

@@ -57,9 +57,9 @@ namespace Barotrauma
public static void Init(ContentManager content)
{
GUI.Font = ToolBox.TryLoadFont("SpriteFont1", content);
GUI.SmallFont = ToolBox.TryLoadFont("SmallFont", content);
GUI.LargeFont = ToolBox.TryLoadFont("LargeFont", content);
Font = ToolBox.TryLoadFont("SpriteFont1", content);
SmallFont = ToolBox.TryLoadFont("SmallFont", content);
LargeFont = ToolBox.TryLoadFont("LargeFont", content);
cursor = new Sprite("Content/UI/cursor.png", Vector2.Zero);
}
@@ -104,7 +104,7 @@ namespace Barotrauma
pauseMenu = new GUIFrame(new Rectangle(0, 0, 200, 300), null, Alignment.Center, Style);
int y = 0;
var button = new GUIButton(new Rectangle(0, y, 0, 30), "Resume", Alignment.CenterX, GUI.Style, pauseMenu);
var button = new GUIButton(new Rectangle(0, y, 0, 30), "Resume", Alignment.CenterX, Style, pauseMenu);
button.OnClicked = TogglePauseMenu;
y += 60;
@@ -114,7 +114,7 @@ namespace Barotrauma
SinglePlayerMode spMode = GameMain.GameSession.gameMode as SinglePlayerMode;
if (spMode != null)
{
button = new GUIButton(new Rectangle(0, y, 0, 30), "Load previous", Alignment.CenterX, GUI.Style, pauseMenu);
button = new GUIButton(new Rectangle(0, y, 0, 30), "Load previous", Alignment.CenterX, Style, pauseMenu);
button.OnClicked += TogglePauseMenu;
button.OnClicked += GameMain.GameSession.LoadPrevious;
@@ -127,7 +127,7 @@ namespace Barotrauma
SinglePlayerMode spMode = GameMain.GameSession.gameMode as SinglePlayerMode;
if (spMode != null)
{
button = new GUIButton(new Rectangle(0, y, 0, 30), "Save & quit", Alignment.CenterX, GUI.Style, pauseMenu);
button = new GUIButton(new Rectangle(0, y, 0, 30), "Save & quit", Alignment.CenterX, Style, pauseMenu);
button.OnClicked += QuitClicked;
button.OnClicked += TogglePauseMenu;
button.UserData = "save";
@@ -137,7 +137,7 @@ namespace Barotrauma
}
button = new GUIButton(new Rectangle(0, y, 0, 30), "Quit", Alignment.CenterX, GUI.Style, pauseMenu);
button = new GUIButton(new Rectangle(0, y, 0, 30), "Quit", Alignment.CenterX, Style, pauseMenu);
button.OnClicked += QuitClicked;
button.OnClicked += TogglePauseMenu;
}
@@ -193,7 +193,7 @@ namespace Barotrauma
public static void DrawString(SpriteBatch sb, Vector2 pos, string text, Color color, Color? backgroundColor=null, int backgroundPadding=0, SpriteFont font = null)
{
if (font == null) font = GUI.Font;
if (font == null) font = Font;
if (backgroundColor != null)
{
Vector2 textSize = font.MeasureString(text);

View File

@@ -1,5 +1,4 @@
using Microsoft.Xna.Framework;
using System;
using System.Linq;
namespace Barotrauma
@@ -23,8 +22,8 @@ namespace Barotrauma
this.rect = rect;
this.alignment = alignment;
if (color!=null) this.color = (Color)color;
if (color != null) this.color = (Color)color;
if (parent != null)
{

View File

@@ -1,20 +1,15 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma
{
class GUIMessage
{
ColoredText coloredText;
Vector2 pos;
private ColoredText coloredText;
private Vector2 pos;
float lifeTime;
Vector2 size;
private float lifeTime;
private Vector2 size;
public string Text
{

View File

@@ -1,5 +1,4 @@
using System.Xml.Linq;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
@@ -22,24 +21,6 @@ namespace Barotrauma
return;
}
//smallPadding = ToolBox.GetAttributeVector4(doc.Root, "smallpadding", Vector4.Zero);
//largePadding = ToolBox.GetAttributeVector4(doc.Root, "largepadding", Vector4.Zero);
//Vector4 colorVector = ToolBox.GetAttributeVector4(doc.Root, "backgroundcolor", new Vector4(0.0f,0.0f,0.0f,1.0f));
//backGroundColor = new Color(colorVector.X, colorVector.Y, colorVector.Z, colorVector.W);
//colorVector = ToolBox.GetAttributeVector4(doc.Root, "foregroundcolor", new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
//foreGroundColor = new Color(colorVector.X, colorVector.Y, colorVector.Z, colorVector.W);
//colorVector = ToolBox.GetAttributeVector4(doc.Root, "textcolor", new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
//textColor = new Color(colorVector.X, colorVector.Y, colorVector.Z, colorVector.W);
//colorVector = ToolBox.GetAttributeVector4(doc.Root, "hovercolor", new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
//hoverColor = new Color(colorVector.X, colorVector.Y, colorVector.Z, colorVector.W);
//colorVector = ToolBox.GetAttributeVector4(doc.Root, "selectedcolor", new Vector4(0.0f, 0.0f, 0.0f, 1.0f));
//selectedColor = new Color(colorVector.X, colorVector.Y, colorVector.Z, colorVector.W);
foreach (XElement subElement in doc.Root.Elements())
{
GUIComponentStyle componentStyle = new GUIComponentStyle(subElement);

View File

@@ -93,7 +93,7 @@ namespace Barotrauma
{
}
protected override void UpdateDimensions(GUIComponent parent)
protected override void UpdateDimensions(GUIComponent parent = null)
{
base.UpdateDimensions(parent);

View File

@@ -24,7 +24,7 @@ namespace Barotrauma
public static bool WindowActive
{
get { return Instance == null ? true : GameMain.Instance.IsActive; }
get { return Instance != null && Instance.IsActive; }
}
public static bool DebugDraw;

View File

@@ -1,8 +1,5 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma
{

View File

@@ -1,8 +1,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Reflection;
namespace Barotrauma
{

View File

@@ -1,8 +1,5 @@
using System;
using System.Linq;
using Barotrauma.Networking;
using Barotrauma.Networking;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
namespace Barotrauma
{

View File

@@ -1,8 +1,4 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections.Generic;
namespace Barotrauma.Tutorials
{

View File

@@ -1,11 +1,4 @@
using FarseerPhysics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Barotrauma.Items.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Barotrauma.Tutorials;
namespace Barotrauma

View File

@@ -1,9 +1,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma.Tutorials
{

View File

@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Barotrauma
@@ -23,7 +21,7 @@ namespace Barotrauma
infoTexts = new Dictionary<string, List<string>>();
XDocument doc = ToolBox.TryLoadXml(file);
if (doc == null) return;
if (doc == null || doc.Root == null) return;
foreach (XElement subElement in doc.Root.Elements())
{

View File

@@ -1,30 +1,10 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Barotrauma
{
class ShiftSummary
{
//class Casualty
//{
// public readonly CharacterInfo character;
// public readonly CauseOfDeath causeOfDeath;
// public readonly string description;
// public Casualty(CharacterInfo characterInfo, CauseOfDeath causeOfDeath, string description)
// {
// this.character = characterInfo;
// this.causeOfDeath = causeOfDeath;
// this.description = description;
// }
//}
private Location startLocation, endLocation;
private GameSession gameSession;
@@ -51,7 +31,7 @@ namespace Barotrauma
{
bool singleplayer = GameMain.NetworkMember == null;
bool gameOver = !gameSession.CrewManager.characters.Any(c => !c.IsDead);
bool gameOver = gameSession.CrewManager.characters.All(c => c.IsDead);
bool progress = Submarine.Loaded.AtEndPosition;
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.8f);

View File

@@ -98,8 +98,10 @@ namespace Barotrauma
/// <summary>
/// If there is room, puts the item in the inventory and returns true, otherwise returns false
/// </summary>
public override bool TryPutItem(Item item, List<LimbSlot> allowedSlots, bool createNetworkEvent = true)
public override bool TryPutItem(Item item, List<LimbSlot> allowedSlots = null, bool createNetworkEvent = true)
{
if (allowedSlots == null) return false;
//try to place the item in LimBlot.Any slot if that's allowed
if (allowedSlots.Contains(LimbSlot.Any))
{
@@ -159,11 +161,8 @@ namespace Barotrauma
bool combined = false;
if (Items[index].Combine(item))
{
if (Items[index]==null)
{
System.Diagnostics.Debug.Assert(false);
return false;
}
System.Diagnostics.Debug.Assert(Items[index] != null);
Inventory otherInventory = Items[index].ParentInventory;
if (otherInventory != null && otherInventory.Owner!=null && createNetworkEvent)
{

View File

@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Xml.Linq;
using FarseerPhysics;
using FarseerPhysics.Dynamics;
using System.Xml.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Barotrauma.Particles;
@@ -95,23 +91,8 @@ namespace Barotrauma.Items.Components
return true;
}
public override void Draw(SpriteBatch spriteBatch, bool editing)
public override void Draw(SpriteBatch spriteBatch, bool editing = false)
{
if (!IsActive) return;
//Vector2 particleSpeed = new Vector2(
// (float)Math.Cos(item.body.Rotation),
// (float)Math.Sin(item.body.Rotation)) *item.body.Dir * 0.1f;
//Vector2 startPos = ConvertUnits.ToDisplayUnits(item.body.Position);
//Vector2 endPos = ConvertUnits.ToDisplayUnits(pickedPosition);
//endPos = new Vector2(endPos.X + Game1.localRandom.Next(-2, 2), endPos.Y + Game1.localRandom.Next(-2, 2));
//GUI.DrawLine(spriteBatch, startPos, endPos, Color.Orange, 0.0f);
IsActive = false;
}

View File

@@ -105,7 +105,7 @@ namespace Barotrauma.Items.Components
item.body.ApplyLinearImpulse(
new Vector2((float)Math.Cos(projectile.body.Rotation), (float)Math.Sin(projectile.body.Rotation)) * item.body.Mass * -50.0f);
projectileComponent.ignoredBodies = limbBodies;
projectileComponent.IgnoredBodies = limbBodies;
item.RemoveContained(projectile);

View File

@@ -10,13 +10,13 @@ namespace Barotrauma.Items.Components
{
class RepairTool : ItemComponent
{
List<string> fixableEntities;
private List<string> fixableEntities;
float range;
private float range;
Vector2 pickedPosition;
private Vector2 pickedPosition;
Vector2 barrelPos;
private Vector2 barrelPos;
private string particles;

View File

@@ -1,5 +1,4 @@
using FarseerPhysics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using System.Xml.Linq;
namespace Barotrauma.Items.Components

View File

@@ -301,7 +301,7 @@ namespace Barotrauma.Items.Components
soundList.Add(itemSound);
break;
default:
ItemComponent ic = ItemComponent.Load(subElement, item, item.ConfigFile, false);
ItemComponent ic = Load(subElement, item, item.ConfigFile, false);
if (ic == null) break;
ic.Parent = this;

View File

@@ -152,9 +152,9 @@ namespace Barotrauma.Items.Components
}
}
public override void Draw(SpriteBatch spriteBatch, bool editing)
public override void Draw(SpriteBatch spriteBatch, bool editing = false)
{
base.Draw(spriteBatch);
base.Draw(spriteBatch, editing);
if (hideItems || (item.body != null && !item.body.Enabled)) return;

View File

@@ -10,7 +10,7 @@ namespace Barotrauma.Items.Components
{
}
public override bool Select(Character character = null)
public override bool Select(Character character)
{
if (character == null) return false;

View File

@@ -215,7 +215,7 @@ namespace Barotrauma.Items.Components
character.AnimController.Anim = AnimController.Animation.None;
}
public override bool Select(Character activator = null)
public override bool Select(Character activator)
{
if (activator == null) return false;

View File

@@ -117,7 +117,7 @@ namespace Barotrauma.Items.Components
}
else
{
if (!container.Inventory.Items.Any(i => i != null)) return;
if (container.Inventory.Items.All(i => i == null)) return;
activateButton.Text = "Cancel";
}

View File

@@ -90,7 +90,7 @@ namespace Barotrauma.Items.Components
for (int i = 0; i < 5; i++)
{
var bubbles = GameMain.ParticleManager.CreateParticle("bubbles", item.WorldPosition - (Vector2.UnitX * item.Rect.Width/2),
GameMain.ParticleManager.CreateParticle("bubbles", item.WorldPosition - (Vector2.UnitX * item.Rect.Width/2),
-currForce / 5.0f + new Vector2(Rand.Range(-100.0f, 100.0f), Rand.Range(-50f, 50f)),
0.0f, item.CurrentHull);
}

View File

@@ -150,7 +150,7 @@ namespace Barotrauma.Items.Components
}
text += "Required time: " + targetItem.RequiredTime + " s";
GUITextBlock textBlock = new GUITextBlock(
new GUITextBlock(
new Rectangle(0, 50, 0, 25),
text,
Color.Transparent, Color.White,

View File

@@ -153,7 +153,6 @@ namespace Barotrauma.Items.Components
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
{
int width = GuiFrame.Rect.Width, height = GuiFrame.Rect.Height;
int x = GuiFrame.Rect.X;
int y = GuiFrame.Rect.Y;

View File

@@ -94,19 +94,14 @@ namespace Barotrauma.Items.Components
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
{
int x = GuiFrame.Rect.X;
int y = GuiFrame.Rect.Y;
GuiFrame.Update(1.0f / 60.0f);
GuiFrame.Draw(spriteBatch);
if (voltage < minVoltage) return;
int radius = GuiFrame.Rect.Height / 2 - 30;
DrawRadar(spriteBatch, new Rectangle((int)GuiFrame.Center.X - radius, (int)GuiFrame.Center.Y - radius, radius * 2, radius * 2));
//voltage = 0.0f;
}
private List<RadarBlip> radarBlips;
@@ -202,20 +197,15 @@ namespace Barotrauma.Items.Components
float pointDist = (limb.WorldPosition - item.WorldPosition).Length() * displayScale;
if (limb.SimPosition == Vector2.Zero || pointDist > radius) continue;
if (pointDist > radius) continue;
if (pointDist > prevPingRadius && pointDist < pingRadius)
{
float limbSize = limb.Mass;
for (int i = 0; i<=limb.Mass/100.0f; i++)
{
var blip = new RadarBlip(limb.WorldPosition+Rand.Vector(limb.Mass/10.0f), 1.0f);
radarBlips.Add(blip);
}
}
}
}

View File

@@ -379,12 +379,12 @@ namespace Barotrauma.Items.Components
public override bool Pick(Character picker)
{
return (picker != null);
return picker != null;
}
public override void Draw(SpriteBatch spriteBatch, bool editing)
public override void Draw(SpriteBatch spriteBatch, bool editing = false)
{
base.Draw(spriteBatch);
base.Draw(spriteBatch, editing);
GUI.DrawRectangle(spriteBatch,
new Vector2(item.Rect.X + item.Rect.Width / 2 - 6, -item.Rect.Y + 29),

View File

@@ -224,9 +224,9 @@ namespace Barotrauma.Items.Components
//if (connection.IsPower) voltage = power;
}
public override void Draw(SpriteBatch spriteBatch, bool editing)
public override void Draw(SpriteBatch spriteBatch, bool editing = false)
{
base.Draw(spriteBatch);
base.Draw(spriteBatch, editing);
GUI.DrawRectangle(spriteBatch,
new Vector2(item.DrawPosition.X- 4, -item.DrawPosition.Y),

View File

@@ -1,6 +1,4 @@
using System;
using System.Globalization;
using System.IO;
using System.Xml.Linq;
namespace Barotrauma.Items.Components
@@ -85,7 +83,7 @@ namespace Barotrauma.Items.Components
}
}
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power)
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power = 0)
{
if (currPowerConsumption == 0.0f) voltage = 0.0f;
if (connection.IsPower) voltage = power;

View File

@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Xml.Linq;
using FarseerPhysics;
using FarseerPhysics.Dynamics;
@@ -18,9 +17,9 @@ namespace Barotrauma.Items.Components
private PrismaticJoint stickJoint;
private Body stickTarget;
Attack attack;
private Attack attack;
public List<Body> ignoredBodies;
public List<Body> IgnoredBodies;
public Character User;
@@ -48,7 +47,7 @@ namespace Barotrauma.Items.Components
public Projectile(Item item, XElement element)
: base (item, element)
{
ignoredBodies = new List<Body>();
IgnoredBodies = new List<Body>();
//launchImpulse = ToolBox.GetAttributeFloat(element, "launchimpulse", 10.0f);
//characterUsable = ToolBox.GetAttributeBool(element, "characterusable", false);
@@ -65,24 +64,10 @@ namespace Barotrauma.Items.Components
//doesStick = ToolBox.GetAttributeBool(element, "doesstick", false);
}
//public override void ConstructionActivate(Construction c, Vector2 modifier)
//{
// for (int i = 0; i < item.linkedTo.Count; i++)
// item.linkedTo[i].RemoveLinked((MapEntity)item);
// item.linkedTo.Clear();
// ApplyStatusEffects(StatusEffect.Type.OnUse, 1.0f, null);
// Launch(modifier+Vector2.Normalize(modifier)*launchImpulse);
//}
public override bool Use(float deltaTime, Character character = null)
{
if (character != null && !characterUsable) return false;
//ApplyStatusEffects(ActionType.OnUse, 1.0f, Character);
Launch(new Vector2(
(float)Math.Cos(item.body.Rotation),
(float)Math.Sin(item.body.Rotation)) * launchImpulse * item.body.Mass);
@@ -103,26 +88,25 @@ namespace Barotrauma.Items.Components
item.Drop();
if (stickJoint != null && doesStick)
{
if (stickTarget != null)
{
try
{
item.body.FarseerBody.RestoreCollisionWith(stickTarget);
}
catch (Exception e)
{
#if DEBUG
DebugConsole.ThrowError("Failed to restore collision with stickTarget", e);
#endif
}
if (stickJoint == null || !doesStick) return;
stickTarget = null;
if (stickTarget != null)
{
try
{
item.body.FarseerBody.RestoreCollisionWith(stickTarget);
}
GameMain.World.RemoveJoint(stickJoint);
stickJoint = null;
catch (Exception e)
{
#if DEBUG
DebugConsole.ThrowError("Failed to restore collision with stickTarget", e);
#endif
}
stickTarget = null;
}
GameMain.World.RemoveJoint(stickJoint);
stickJoint = null;
}
public override void Update(float deltaTime, Camera cam)
@@ -160,7 +144,7 @@ namespace Barotrauma.Items.Components
private bool OnProjectileCollision(Fixture f1, Fixture f2, Contact contact)
{
if (ignoredBodies.Contains(f2.Body)) return false;
if (IgnoredBodies.Contains(f2.Body)) return false;
AttackResult attackResult = new AttackResult(0.0f, 0.0f);
if (attack != null)
@@ -185,7 +169,7 @@ namespace Barotrauma.Items.Components
item.body.CollisionCategories = Physics.CollisionMisc;
item.body.CollidesWith = Physics.CollisionWall | Physics.CollisionLevel;
ignoredBodies.Clear();
IgnoredBodies.Clear();
f2.Body.ApplyLinearImpulse(item.body.LinearVelocity * item.body.Mass);
@@ -220,9 +204,7 @@ namespace Barotrauma.Items.Components
}
}
return (f2.CollisionCategories != Physics.CollisionCharacter);
//return false;
return f2.CollisionCategories != Physics.CollisionCharacter;
}
private bool StickToTarget(Body targetBody, Vector2 axis)

View File

@@ -239,9 +239,9 @@ namespace Barotrauma.Items.Components
}
}
public override void Draw(SpriteBatch spriteBatch, bool editing)
public override void Draw(SpriteBatch spriteBatch, bool editing = false)
{
base.Draw(spriteBatch);
base.Draw(spriteBatch, editing);
if (!IsActive) return;

View File

@@ -1,9 +1,6 @@
using FarseerPhysics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using Barotrauma.Lights;
using System;
using System.IO;
using System.Xml.Linq;
namespace Barotrauma.Items.Components
@@ -135,16 +132,7 @@ namespace Barotrauma.Items.Components
voltage = 0.0f;
}
public override void Draw(SpriteBatch spriteBatch, bool editing)
{
if (!editing) return;
//Vector2 center = new Vector2(item.Rect.Center.X, -item.Rect.Y + item.Rect.Height/2.0f);
//GUI.DrawLine(spriteBatch, center - Vector2.One * range, center + Vector2.One * range, lightColor);
}
protected override void RemoveComponentSpecific()
{
base.RemoveComponentSpecific();

View File

@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Xml.Linq;
namespace Barotrauma.Items.Components
{

View File

@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
using System.Xml.Linq;
namespace Barotrauma.Items.Components
{

View File

@@ -1,5 +1,4 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Xml.Linq;

View File

@@ -79,7 +79,7 @@ namespace Barotrauma.Items.Components
ToolBox.GetAttributeVector2(element, "origin", Vector2.Zero));
}
public override void Draw(SpriteBatch spriteBatch, bool editing)
public override void Draw(SpriteBatch spriteBatch, bool editing = false)
{
Vector2 drawPos = new Vector2(item.Rect.X, item.Rect.Y);
if (item.Submarine != null) drawPos += item.Submarine.DrawPosition;
@@ -270,7 +270,7 @@ namespace Barotrauma.Items.Components
if (Math.Abs(MathUtils.GetShortestAngle(enemyAngle, turretAngle)) > 0.01f) return false;
var pickedBody = Submarine.PickBody(ConvertUnits.ToSimUnits(item.WorldPosition), closestEnemy.SimPosition, null);
if (pickedBody != null && pickedBody.UserData as Limb == null) return false;
if (pickedBody != null && !(pickedBody.UserData is Limb)) return false;
if (objective.Option.ToLower()=="fire at will") Use(deltaTime, character);

View File

@@ -363,8 +363,8 @@ namespace Barotrauma
{
if (sendingTime < lastUpdate) return;
List<ushort> newItemIDs = new List<ushort>();
List<Item> droppedItems = new List<Item>();
//List<ushort> newItemIDs = new List<ushort>();
//List<Item> droppedItems = new List<Item>();
List<Item> prevItems = new List<Item>(Items);
for (int i = 0; i < capacity; i++)
@@ -389,15 +389,22 @@ namespace Barotrauma
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
if (sender != null && sender.Character != null)
{
foreach (Item item in droppedItems)
{
GameServer.Log(sender.Character + " removed " + item.Name + " from " + Owner.ToString(), Color.Orange);
}
foreach (Item item in Items)
{
if (item == null || prevItems.Contains(item)) continue;
GameServer.Log(sender.Character + " placed " + item.Name + " in " + Owner.ToString(), Color.Orange);
if (item == null) continue;
if (!prevItems.Contains(item))
{
GameServer.Log(sender.Character + " placed " + item.Name + " in " + Owner, Color.Orange);
}
}
foreach (Item item in prevItems)
{
if (item == null) continue;
if (!Items.Contains(item))
{
GameServer.Log(sender.Character + " removed " + item.Name + " from " + Owner.ToString(), Color.Orange);
}
}
}
}

View File

@@ -1,14 +1,12 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma
{
class ItemSpawner
{
private Queue<Pair<ItemPrefab, object>> spawnQueue;
private readonly Queue<Pair<ItemPrefab, object>> spawnQueue;
public ItemSpawner()
{
@@ -68,7 +66,7 @@ namespace Barotrauma
{
var item = new Item(itemInfo.First, Vector2.Zero, null);
var inventory = itemInfo.Second as Inventory;
var inventory = (Inventory)itemInfo.Second;
inventory.TryPutItem(item, null, false);
items.Add(item);
@@ -138,7 +136,7 @@ namespace Barotrauma
class ItemRemover
{
private Queue<Item> removeQueue;
private readonly Queue<Item> removeQueue;
public ItemRemover()
{
@@ -191,7 +189,7 @@ namespace Barotrauma
ushort itemId = message.ReadUInt16();
var item = MapEntity.FindEntityByID(itemId);
if (item == null || item as Item != null) continue;
if (item == null || item is Item) continue;
item.Remove();
}

View File

@@ -1,6 +1,4 @@
using FarseerPhysics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using Barotrauma.Lights;
using System;
using System.Collections.Generic;

View File

@@ -165,8 +165,6 @@ namespace Barotrauma
for (int i = 0; i < count; i++ )
{
float normalizedPos = 0.5f-(i / count);
Vector2 spawnPos = new Vector2(WorldPosition.X + Rand.Range(0.0f, size.X), Rand.Range(WorldPosition.Y - size.Y, WorldPosition.Y) + 10.0f);
Vector2 speed = new Vector2((spawnPos.X - (WorldPosition.X + size.X / 2.0f)), (float)Math.Sqrt(size.X) * Rand.Range(10.0f, 15.0f) * growModifier);

View File

@@ -115,7 +115,7 @@ namespace Barotrauma
public static void UpdateHulls()
{
foreach (Gap g in Gap.GapList)
foreach (Gap g in GapList)
{
g.FindHulls();
}

View File

@@ -1,5 +1,4 @@
using System;
using System.IO;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;

View File

@@ -112,21 +112,16 @@ namespace Barotrauma.Lights
private void CalculateDimensions()
{
Vector2 center = Vector2.Zero;
float? minX = null, minY = null, maxX = null, maxY = null;
for (int i = 0; i < vertices.Length; i++)
{
center += vertices[i];
if (minX == null || vertices[i].X < minX) minX = vertices[i].X;
if (minY == null || vertices[i].Y < minY) minY = vertices[i].Y;
if (maxX == null || vertices[i].X > maxX) maxX = vertices[i].X;
if (maxY == null || vertices[i].Y > minY) maxY = vertices[i].Y;
}
center /= vertices.Length;
boundingBox = new Rectangle((int)minX, (int)minY, (int)(maxX - minX), (int)(maxY - minY));
}

View File

@@ -1,8 +1,5 @@
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma
{

View File

@@ -151,11 +151,11 @@ namespace Barotrauma
protected bool ResizeHorizontal
{
get { return prefab == null ? false : prefab.ResizeHorizontal; }
get { return prefab != null && prefab.ResizeHorizontal; }
}
protected bool ResizeVertical
{
get { return prefab == null ? false : prefab.ResizeVertical; }
get { return prefab != null && prefab.ResizeVertical; }
}
public virtual string Name

View File

@@ -1,9 +1,7 @@
using System;
using System.Diagnostics;
using System.Xml.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System.Collections.Generic;
namespace Barotrauma
@@ -13,17 +11,17 @@ namespace Barotrauma
//public static List<StructurePrefab> list = new List<StructurePrefab>();
//does the structure have a physics body
bool hasBody;
private bool hasBody;
bool castShadow;
private bool castShadow;
bool isPlatform;
Direction stairDirection;
private bool isPlatform;
private Direction stairDirection;
float maxHealth;
private float maxHealth;
//default size
Vector2 size;
private Vector2 size;
public bool HasBody
{
@@ -55,7 +53,7 @@ namespace Barotrauma
foreach (string filePath in filePaths)
{
XDocument doc = ToolBox.TryLoadXml(filePath);
if (doc == null) return;
if (doc == null || doc.Root == null) return;
foreach (XElement el in doc.Root.Elements())
{

View File

@@ -165,7 +165,7 @@ namespace Barotrauma
public bool AtDamageDepth
{
get { return subBody == null ? false : subBody.AtDamageDepth; }
get { return subBody != null && subBody.AtDamageDepth; }
}
public override string ToString()

View File

@@ -310,7 +310,7 @@ namespace Barotrauma
if (hull.Rect.Width<minDist*3.0f)
{
var wayPoint = new WayPoint(
new WayPoint(
new Vector2(hull.Rect.X + hull.Rect.Width / 2.0f, hull.Rect.Y - hull.Rect.Height + heightFromFloor), SpawnType.Path, Submarine.Loaded);
continue;
}
@@ -396,7 +396,7 @@ namespace Barotrauma
}
List<Structure> stairList = new List<Structure>();
foreach (MapEntity me in MapEntity.mapEntityList)
foreach (MapEntity me in mapEntityList)
{
Structure stairs = me as Structure;
if (stairs == null) continue;
@@ -439,8 +439,7 @@ namespace Barotrauma
ladderPoints[0] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y - item.Rect.Height + heightFromFloor), SpawnType.Path, Submarine.Loaded);
ladderPoints[1] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y-1.0f), SpawnType.Path, Submarine.Loaded);
WayPoint prevPoint = ladderPoints[0];
Vector2 prevPos = prevPoint.SimPosition;
@@ -457,7 +456,7 @@ namespace Barotrauma
if (pickedBody.UserData is Item)
{
var door = (pickedBody.UserData as Item).GetComponent<Door>();
var door = ((Item)pickedBody.UserData).GetComponent<Door>();
if (door != null)
{
WayPoint newPoint = new WayPoint(door.Item.Position, SpawnType.Path, Submarine.Loaded);

View File

@@ -128,7 +128,7 @@ namespace Barotrauma.Networking
GUIMessageBox upnpBox = new GUIMessageBox("Please wait...", "Attempting UPnP port forwarding", new string[] {"Cancel"} );
upnpBox.Buttons[0].OnClicked = upnpBox.Close;
DateTime upnpTimeout = DateTime.Now + new TimeSpan(0,0,5);
//DateTime upnpTimeout = DateTime.Now + new TimeSpan(0,0,5);
while (server.UPnP.Status == UPnPStatus.Discovering
&& GUIMessageBox.VisibleBox == upnpBox)// && upnpTimeout>DateTime.Now)
{

View File

@@ -53,7 +53,7 @@ namespace Barotrauma.Networking
public bool AutoRestart
{
get { return (ConnectedClients.Count == 0) ? false : autoRestart; }
get { return (ConnectedClients.Count != 0) && autoRestart; }
set
{
autoRestart = value;

View File

@@ -1,7 +1,4 @@
using Lidgren.Network;
using System;
namespace Barotrauma.Networking
namespace Barotrauma.Networking
{
static class NetBufferExtensions
{

View File

@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma.Networking
namespace Barotrauma.Networking
{
static class NetConfig
{

View File

@@ -109,7 +109,7 @@ namespace Barotrauma.Networking
public NetworkEvent(NetworkEventType type, ushort id, bool allowClientSend, object data = null)
{
if (!allowClientSend && GameMain.Server != null) return;
if (!allowClientSend && GameMain.Server == null) return;
eventType = type;
@@ -168,7 +168,7 @@ namespace Barotrauma.Networking
try
{
NetworkEvent.ReadData(message, sendingTime, resend);
ReadData(message, sendingTime, resend);
}
catch
{

View File

@@ -3,7 +3,6 @@ using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
namespace Barotrauma.Networking
{
@@ -19,12 +18,12 @@ namespace Barotrauma.Networking
private GUIListBox listBox;
private Queue<ColoredText> lines;
private readonly Queue<ColoredText> lines;
public int LinesPerFile
{
get { return linesPerFile; }
set { linesPerFile = Math.Max(10, linesPerFile); }
set { linesPerFile = Math.Max(value, 10); }
}
public ServerLog(string serverName)

View File

@@ -32,7 +32,7 @@ namespace Barotrauma.Particles
particles = new Particle[MaxParticles];
XDocument doc = ToolBox.TryLoadXml(configFile);
if (doc == null) return;
if (doc == null || doc.Root == null) return;
prefabs = new Dictionary<string, ParticlePrefab>();

View File

@@ -206,12 +206,7 @@ namespace Barotrauma
{
var frame = c.CreateCharacterFrame(hireList, c.Name + " (" + c.Job.Name + ")", c);
//GUITextBlock textBlock = new GUITextBlock(
// new Rectangle(0, 0, 0, 25),
// c.Name + " (" + c.Job.Name + ")", GUI.Style, hireList);
//textBlock.UserData = c;
var textBlock = new GUITextBlock(
new GUITextBlock(
new Rectangle(0, 0, 0, 25),
c.Salary.ToString(),
null, null,
@@ -475,7 +470,7 @@ namespace Barotrauma
GUIComponent prevInfoFrame = null;
foreach (GUIComponent child in bottomPanel[selectedRightPanel].children)
{
if (child.UserData as CharacterInfo == null) continue;
if (!(child.UserData is CharacterInfo)) continue;
prevInfoFrame = child;
}

View File

@@ -208,16 +208,13 @@ namespace Barotrauma
otherButton.Selected = false;
}
if (Screen.Selected != this) Select();
if (Selected != this) Select();
return true;
}
public void SelectTab(Tab tab)
{
int oldTab = selectedTab;
if (GameMain.Config.UnsavedSettings)
{
var applyBox = new GUIMessageBox("Apply changes?", "Do you want to apply the settings or discard the changes?",

View File

@@ -246,7 +246,7 @@ namespace Barotrauma
//traitor probability ------------------------------------------------------------------
var traitorText = new GUITextBlock(new Rectangle(columnX, 180, 20, 20), "Traitors:", GUI.Style, infoFrame);
new GUITextBlock(new Rectangle(columnX, 180, 20, 20), "Traitors:", GUI.Style, infoFrame);
traitorProbabilityButtons = new GUIButton[2];
@@ -1000,7 +1000,7 @@ namespace Barotrauma
//msg.Write(durationBar.BarScroll);
msg.Write(LevelSeed);
msg.Write(GameMain.Server == null ? false : GameMain.Server.AutoRestart);
msg.Write(GameMain.Server != null && GameMain.Server.AutoRestart);
msg.Write(GameMain.Server == null ? 0.0f : GameMain.Server.AutoRestartTimer);
msg.Write((byte)(playerList.CountChildren));

View File

@@ -45,11 +45,10 @@ namespace Barotrauma
private IEnumerable<object> UpdateColorFade(Color from, Color to, float duration)
{
while (Screen.Selected != this)
while (Selected != this)
{
yield return CoroutineStatus.Running;
}
float timer = 0.0f;

View File

@@ -1,12 +1,7 @@
using System;
using Lidgren.Network;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Barotrauma.Networking;
using FarseerPhysics;
using FarseerPhysics.Factories;
using FarseerPhysics.Dynamics;
using System.IO;
using System.Collections.Generic;
using RestSharp;

View File

@@ -1,5 +1,4 @@
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.Xna.Framework;
using OpenTK.Audio.OpenAL;
using OpenTK.Audio;
@@ -12,22 +11,14 @@ namespace Barotrauma.Sounds
{
public const int DefaultSourceCount = 16;
private static List<int> alSources = new List<int>();
private static int[] alBuffers = new int[DefaultSourceCount];
private static readonly List<int> alSources = new List<int>();
private static readonly int[] alBuffers = new int[DefaultSourceCount];
private static int lowpassFilterId;
private static AudioContext AC;
//private static float overrideLowPassGain;
//public static float OverrideLowPassGain
//{
// get { return overrideLowPassGain; }
// set { overrideLowPassGain = MathHelper.Clamp(overrideLowPassGain, 0.0f, 1.0f); }
//}
static AudioContext AC;
public static OggStreamer oggStreamer;
public static OggStream oggStream;
private static OggStreamer oggStreamer;
private static OggStream oggStream;
public static float MasterVolume = 1.0f;

View File

@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma
{

View File

@@ -1,9 +1,5 @@
using Lidgren.Network;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma
{

View File

@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Text;
using System.Xml.Linq;

View File

@@ -1,10 +1,7 @@
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.IO;
using Microsoft.Xna.Framework.Graphics;
using Color = Microsoft.Xna.Framework.Color;
using System;
using Microsoft.Xna.Framework;
namespace Barotrauma
{