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
@@ -63,12 +63,7 @@ namespace FarseerPhysics.Collision.Shapes
{ {
ShapeType = ShapeType.Chain; ShapeType = ShapeType.Chain;
_radius = Settings.PolygonRadius; _radius = Settings.PolygonRadius;
if (!(vertices != null && vertices.Count >= 2))
{
int lkmsdgkldf = 1;
}
Debug.Assert(vertices != null && vertices.Count >= 2); 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 Debug.Assert(vertices[0] != vertices[vertices.Count - 1]); // FPE. See http://www.box2d.org/forum/viewtopic.php?f=4&t=7973&p=35363
@@ -1,10 +1,7 @@
using Barotrauma.Items.Components; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma namespace Barotrauma
{ {
@@ -137,7 +134,7 @@ namespace Barotrauma
List<GUIComponent> prevCharacterFrames = new List<GUIComponent>(); List<GUIComponent> prevCharacterFrames = new List<GUIComponent>();
foreach (GUIComponent child in frame.children) foreach (GUIComponent child in frame.children)
{ {
if (child.UserData as Character == null) continue; if (!(child.UserData is Character)) continue;
prevCharacterFrames.Add(child); prevCharacterFrames.Add(child);
} }
@@ -155,8 +152,6 @@ namespace Barotrauma
int spacing = 5; int spacing = 5;
int rows = (int)Math.Ceiling((double)aliveCharacters.Count / charactersPerRow);
int i = 0; int i = 0;
foreach (Character character in aliveCharacters) foreach (Character character in aliveCharacters)
{ {
@@ -164,7 +159,7 @@ namespace Barotrauma
//if (i >= aliveCharacters.Count - charactersPerRow && aliveCharacters.Count % charactersPerRow > 0) rowCharacterCount = aliveCharacters.Count % charactersPerRow; //if (i >= aliveCharacters.Count - charactersPerRow && aliveCharacters.Count % charactersPerRow > 0) rowCharacterCount = aliveCharacters.Count % charactersPerRow;
// rowCharacterCount = Math.Min(rowCharacterCount, aliveCharacters.Count - i); // 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)); int x = startX + (150 + spacing) * (i % Math.Min(charactersPerRow, aliveCharacters.Count));
@@ -229,7 +224,6 @@ namespace Barotrauma
{ {
Order order = userData as Order; Order order = userData as Order;
List<Character> selectedCharacters = new List<Character>();
foreach (GUIComponent child in frame.children) foreach (GUIComponent child in frame.children)
{ {
var characterButton = child as GUIButton; var characterButton = child as GUIButton;
@@ -258,7 +252,7 @@ namespace Barotrauma
var humanAi = character.AIController as HumanAIController; var humanAi = character.AIController as HumanAIController;
if (humanAi == null) return; 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); 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); var orderFrame = new GUIFrame(new Rectangle(-5, characterFrame.Rect.Height, characterFrame.Rect.Width, 30 + order.Options.Length * 15), null, characterFrame);
@@ -71,7 +71,7 @@ namespace Barotrauma
targetMemories = new Dictionary<AITarget, AITargetMemory>(); targetMemories = new Dictionary<AITarget, AITargetMemory>();
XDocument doc = ToolBox.TryLoadXml(file); XDocument doc = ToolBox.TryLoadXml(file);
if (doc == null) return; if (doc == null || doc.Root == null) return;
XElement aiElement = doc.Root.Element("ai"); XElement aiElement = doc.Root.Element("ai");
if (aiElement == null) return; if (aiElement == null) return;
@@ -474,7 +474,7 @@ namespace Barotrauma
} }
else if (closestStructure!=null) else if (closestStructure!=null)
{ {
valueModifier = valueModifier / (closestStructure as IDamageable).Health; valueModifier = valueModifier / ((IDamageable)closestStructure).Health;
} }
else else
{ {
@@ -1,9 +1,5 @@
using FarseerPhysics; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma namespace Barotrauma
{ {
@@ -1,9 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using FarseerPhysics;
using Barotrauma.Items.Components; using Barotrauma.Items.Components;
namespace Barotrauma namespace Barotrauma
@@ -66,7 +66,7 @@ namespace Barotrauma
} }
var pickedBody = Submarine.PickBody(character.SimPosition, enemy.SimPosition, ignoredBodies); 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); weapon.Use(deltaTime, character);
} }
@@ -1,9 +1,6 @@
using Barotrauma.Items.Components; using System;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
namespace Barotrauma namespace Barotrauma
{ {
@@ -59,10 +56,6 @@ namespace Barotrauma
} }
else else
{ {
var pathSteering = character.AIController.SteeringManager as IndoorsSteeringManager;
Hull bestHull = null; Hull bestHull = null;
float bestValue = currenthullSafety; 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.X- hull.Position.X));
hullValue -= (float)Math.Sqrt(Math.Abs(character.Position.Y - hull.Position.Y)*2.0f); 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; bestHull = hull;
bestValue = hullValue; bestValue = hullValue;
@@ -1,8 +1,6 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
namespace Barotrauma namespace Barotrauma
{ {
@@ -2,9 +2,6 @@
using FarseerPhysics; using FarseerPhysics;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma namespace Barotrauma
{ {
@@ -1,8 +1,6 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
namespace Barotrauma namespace Barotrauma
{ {
@@ -119,7 +117,7 @@ namespace Barotrauma
public override bool IsDuplicate(AIObjective otherObjective) public override bool IsDuplicate(AIObjective otherObjective)
{ {
return (otherObjective as AIObjectiveIdle != null); return (otherObjective is AIObjectiveIdle);
} }
} }
} }
@@ -1,8 +1,5 @@
using Barotrauma.Items.Components; using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
namespace Barotrauma namespace Barotrauma
{ {
+1 -1
View File
@@ -35,7 +35,7 @@ namespace Barotrauma
PrefabList = new List<Order>(); PrefabList = new List<Order>();
XDocument doc = ToolBox.TryLoadXml(ConfigFile); XDocument doc = ToolBox.TryLoadXml(ConfigFile);
if (doc == null) return; if (doc == null || doc.Root == null) return;
foreach (XElement orderElement in doc.Root.Elements()) foreach (XElement orderElement in doc.Root.Elements())
{ {
@@ -1,5 +1,4 @@
using FarseerPhysics; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -80,7 +79,7 @@ namespace Barotrauma
public delegate float? GetNodePenaltyHandler(PathNode node, PathNode prevNode); public delegate float? GetNodePenaltyHandler(PathNode node, PathNode prevNode);
public GetNodePenaltyHandler GetNodePenalty; public GetNodePenaltyHandler GetNodePenalty;
List<PathNode> nodes; private List<PathNode> nodes;
private bool insideSubmarine; private bool insideSubmarine;
@@ -181,12 +180,13 @@ namespace Barotrauma
endNode = node; endNode = node;
if (startNode != null) break; if (startNode != null) break;
} }
}
if (startNode==null || endNode==null)
{ if (startNode == null || endNode == null)
DebugConsole.ThrowError("Pathfinding error, couldn't find matching pathnodes to waypoints"); {
return new SteeringPath(); DebugConsole.ThrowError("Pathfinding error, couldn't find matching pathnodes to waypoints");
} return new SteeringPath();
} }
return FindPath(startNode, endNode); return FindPath(startNode, endNode);
@@ -151,7 +151,7 @@ namespace Barotrauma
} }
else if (closestBody.UserData is Item) else if (closestBody.UserData is Item)
{ {
Item item = closestBody.UserData as Item; Item item = (Item)closestBody.UserData;
avoidSteering = Vector2.Normalize(Submarine.LastPickedPosition - item.SimPosition); avoidSteering = Vector2.Normalize(Submarine.LastPickedPosition - item.SimPosition);
} }
else else
@@ -747,12 +747,13 @@ namespace Barotrauma
torso.body.ApplyForce((climbForce * 40.0f + subSpeed*50.0f) * torso.Mass); torso.body.ApplyForce((climbForce * 40.0f + subSpeed*50.0f) * torso.Mass);
head.body.SmoothRotate(0.0f); head.body.SmoothRotate(0.0f);
Rectangle trigger = character.SelectedConstruction.Prefab.Triggers.FirstOrDefault(); if (!character.SelectedConstruction.Prefab.Triggers.Any())
if (trigger == null)
{ {
character.SelectedConstruction = null; character.SelectedConstruction = null;
return; return;
} }
Rectangle trigger = character.SelectedConstruction.Prefab.Triggers.FirstOrDefault();
trigger = character.SelectedConstruction.TransformTrigger(trigger); trigger = character.SelectedConstruction.TransformTrigger(trigger);
bool notClimbing = false; bool notClimbing = false;
@@ -301,7 +301,7 @@ namespace Barotrauma
{ {
Structure structure = f2.Body.UserData as Structure; 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 //always collides with bodies other than structures
if (structure == null) if (structure == null)
@@ -385,7 +385,7 @@ namespace Barotrauma
avgVelocity = avgVelocity / Limbs.Count(); 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); float impact = Vector2.Dot(avgVelocity, -normal);
-13
View File
@@ -128,19 +128,6 @@ namespace Barotrauma
public AttackResult DoDamage(IDamageable attacker, IDamageable target, Vector2 worldPosition, float deltaTime, bool playSound = true) 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) if (particleEmitterPrefab != null)
{ {
particleEmitterPrefab.Emit(worldPosition); particleEmitterPrefab.Emit(worldPosition);
@@ -1,8 +1,4 @@
using System; using System.Xml.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Barotrauma namespace Barotrauma
{ {
@@ -1,7 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Barotrauma namespace Barotrauma
+8 -18
View File
@@ -365,11 +365,6 @@ namespace Barotrauma
public delegate void OnDeathHandler(Character character, CauseOfDeath causeOfDeath); public delegate void OnDeathHandler(Character character, CauseOfDeath causeOfDeath);
public OnDeathHandler OnDeath; 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) public static Character Create(CharacterInfo characterInfo, Vector2 position, bool isNetworkPlayer = false, bool hasAi=true)
{ {
return Create(characterInfo.File, position, characterInfo, isNetworkPlayer, hasAi); return Create(characterInfo.File, position, characterInfo, isNetworkPlayer, hasAi);
@@ -387,23 +382,18 @@ namespace Barotrauma
return enemyCharacter; return enemyCharacter;
} }
else
if (hasAi && !isNetworkPlayer)
{ {
if (hasAi && !isNetworkPlayer) var character = new AICharacter(file, position, characterInfo, isNetworkPlayer);
{ var ai = new HumanAIController(character);
var character = new AICharacter(file, position, characterInfo, isNetworkPlayer); character.SetAI(ai);
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) protected Character(string file, Vector2 position, CharacterInfo characterInfo = null, bool isNetworkPlayer = false)
@@ -187,7 +187,7 @@ namespace Barotrauma
public GUIFrame CreateInfoFrame(GUIFrame frame) 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; SpriteFont font = frame.Rect.Width<280 ? GUI.SmallFont : GUI.Font;
@@ -1,5 +1,4 @@
using Microsoft.Xna.Framework; using System.Collections.Generic;
using System.Collections.Generic;
using System.Xml.Linq; using System.Xml.Linq;
namespace Barotrauma namespace Barotrauma
+2 -5
View File
@@ -1,8 +1,5 @@
using Microsoft.Xna.Framework; using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Barotrauma namespace Barotrauma
@@ -10,7 +7,7 @@ namespace Barotrauma
class Job class Job
{ {
private JobPrefab prefab; private readonly JobPrefab prefab;
private Dictionary<string, Skill> skills; private Dictionary<string, Skill> skills;
@@ -160,7 +160,7 @@ namespace Barotrauma
foreach (string filePath in filePaths) foreach (string filePath in filePaths)
{ {
XDocument doc = ToolBox.TryLoadXml(filePath); XDocument doc = ToolBox.TryLoadXml(filePath);
if (doc == null) return; if (doc == null || doc.Root == null) return;
foreach (XElement element in doc.Root.Elements()) foreach (XElement element in doc.Root.Elements())
{ {
@@ -1,17 +1,13 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Barotrauma namespace Barotrauma
{ {
class SkillPrefab class SkillPrefab
{ {
string name; private string name;
string description; private string description;
private Vector2 levelRange; private Vector2 levelRange;
+4 -5
View File
@@ -1,5 +1,4 @@
using FarseerPhysics; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@@ -274,20 +273,20 @@ namespace Barotrauma
Type type = value.GetType(); Type type = value.GetType();
if (type == typeof(float) || 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; float floatValue = Convert.ToSingle(value) * deltaTime;
if (!setValue) floatValue += (float)property.GetValue(); if (!setValue) floatValue += (float)property.GetValue();
property.TrySetValue(floatValue); 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); int intValue = (int)((int)value * deltaTime);
if (!setValue) intValue += (int)property.GetValue(); if (!setValue) intValue += (int)property.GetValue();
property.TrySetValue(intValue); property.TrySetValue(intValue);
} }
else if (type == typeof(bool) && value.GetType() == typeof(bool)) else if (type == typeof(bool) && value is bool)
{ {
property.TrySetValue((bool)value); property.TrySetValue((bool)value);
} }
+1 -3
View File
@@ -1,8 +1,6 @@
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
namespace Barotrauma namespace Barotrauma
{ {
@@ -14,7 +12,7 @@ namespace Barotrauma
// Keeps track of all running coroutines, and runs them till the end. // Keeps track of all running coroutines, and runs them till the end.
static class CoroutineManager 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; public static float DeltaTime;
+1 -6
View File
@@ -1,9 +1,4 @@
using FarseerPhysics; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Barotrauma namespace Barotrauma
+5 -5
View File
@@ -36,7 +36,7 @@ namespace Barotrauma
int amount = Rand.Range(minAmount, maxAmount, false); int amount = Rand.Range(minAmount, maxAmount, false);
monsters = new AICharacter[amount]; monsters = new Character[amount];
for (int i = 0; i < amount; i++) for (int i = 0; i < amount; i++)
{ {
@@ -64,14 +64,14 @@ namespace Barotrauma
if (isFinished) return; if (isFinished) return;
bool monstersDead = true; 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; monstersDead = false;
break; break;
} }
if (monstersDead) Finished(); if (monstersDead) Finished();
@@ -1,5 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Xml.Linq; using System.Xml.Linq;
+2 -7
View File
@@ -1,7 +1,6 @@
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System; using System;
using System.Linq;
namespace Barotrauma namespace Barotrauma
{ {
@@ -22,11 +21,7 @@ namespace Barotrauma
{ {
get get
{ {
foreach (Task task in tasks) return tasks.Any(task => task.Priority >= CriticalPriority);
{
if (task.Priority >= CriticalPriority) return true;
}
return false;
} }
} }
-3
View File
@@ -1,8 +1,5 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Barotrauma namespace Barotrauma
+8 -8
View File
@@ -57,9 +57,9 @@ namespace Barotrauma
public static void Init(ContentManager content) public static void Init(ContentManager content)
{ {
GUI.Font = ToolBox.TryLoadFont("SpriteFont1", content); Font = ToolBox.TryLoadFont("SpriteFont1", content);
GUI.SmallFont = ToolBox.TryLoadFont("SmallFont", content); SmallFont = ToolBox.TryLoadFont("SmallFont", content);
GUI.LargeFont = ToolBox.TryLoadFont("LargeFont", content); LargeFont = ToolBox.TryLoadFont("LargeFont", content);
cursor = new Sprite("Content/UI/cursor.png", Vector2.Zero); 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); pauseMenu = new GUIFrame(new Rectangle(0, 0, 200, 300), null, Alignment.Center, Style);
int y = 0; 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; button.OnClicked = TogglePauseMenu;
y += 60; y += 60;
@@ -114,7 +114,7 @@ namespace Barotrauma
SinglePlayerMode spMode = GameMain.GameSession.gameMode as SinglePlayerMode; SinglePlayerMode spMode = GameMain.GameSession.gameMode as SinglePlayerMode;
if (spMode != null) 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 += TogglePauseMenu;
button.OnClicked += GameMain.GameSession.LoadPrevious; button.OnClicked += GameMain.GameSession.LoadPrevious;
@@ -127,7 +127,7 @@ namespace Barotrauma
SinglePlayerMode spMode = GameMain.GameSession.gameMode as SinglePlayerMode; SinglePlayerMode spMode = GameMain.GameSession.gameMode as SinglePlayerMode;
if (spMode != null) 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 += QuitClicked;
button.OnClicked += TogglePauseMenu; button.OnClicked += TogglePauseMenu;
button.UserData = "save"; 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 += QuitClicked;
button.OnClicked += TogglePauseMenu; 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) 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) if (backgroundColor != null)
{ {
Vector2 textSize = font.MeasureString(text); Vector2 textSize = font.MeasureString(text);
+2 -3
View File
@@ -1,5 +1,4 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System;
using System.Linq; using System.Linq;
namespace Barotrauma namespace Barotrauma
@@ -23,8 +22,8 @@ namespace Barotrauma
this.rect = rect; this.rect = rect;
this.alignment = alignment; this.alignment = alignment;
if (color!=null) this.color = (Color)color; if (color != null) this.color = (Color)color;
if (parent != null) if (parent != null)
{ {
+4 -9
View File
@@ -1,20 +1,15 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma namespace Barotrauma
{ {
class GUIMessage class GUIMessage
{ {
ColoredText coloredText; private ColoredText coloredText;
Vector2 pos; private Vector2 pos;
float lifeTime; private float lifeTime;
Vector2 size;
private Vector2 size;
public string Text public string Text
{ {
-19
View File
@@ -1,5 +1,4 @@
using System.Xml.Linq; using System.Xml.Linq;
using Microsoft.Xna.Framework;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@@ -22,24 +21,6 @@ namespace Barotrauma
return; 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()) foreach (XElement subElement in doc.Root.Elements())
{ {
GUIComponentStyle componentStyle = new GUIComponentStyle(subElement); GUIComponentStyle componentStyle = new GUIComponentStyle(subElement);
+1 -1
View File
@@ -93,7 +93,7 @@ namespace Barotrauma
{ {
} }
protected override void UpdateDimensions(GUIComponent parent) protected override void UpdateDimensions(GUIComponent parent = null)
{ {
base.UpdateDimensions(parent); base.UpdateDimensions(parent);
+1 -1
View File
@@ -24,7 +24,7 @@ namespace Barotrauma
public static bool WindowActive public static bool WindowActive
{ {
get { return Instance == null ? true : GameMain.Instance.IsActive; } get { return Instance != null && Instance.IsActive; }
} }
public static bool DebugDraw; public static bool DebugDraw;
@@ -1,8 +1,5 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma namespace Barotrauma
{ {
@@ -1,8 +1,6 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Graphics;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Reflection;
namespace Barotrauma namespace Barotrauma
{ {
@@ -1,8 +1,5 @@
using System; using Barotrauma.Networking;
using System.Linq;
using Barotrauma.Networking;
using System.Collections.Generic; using System.Collections.Generic;
using Microsoft.Xna.Framework;
namespace Barotrauma namespace Barotrauma
{ {
@@ -1,8 +1,4 @@
using Microsoft.Xna.Framework; using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma.Tutorials namespace Barotrauma.Tutorials
{ {
@@ -1,11 +1,4 @@
using FarseerPhysics; using Microsoft.Xna.Framework.Graphics;
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 Barotrauma.Tutorials; using Barotrauma.Tutorials;
namespace Barotrauma namespace Barotrauma
@@ -1,9 +1,6 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma.Tutorials namespace Barotrauma.Tutorials
{ {
@@ -1,8 +1,6 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
namespace Barotrauma namespace Barotrauma
@@ -23,7 +21,7 @@ namespace Barotrauma
infoTexts = new Dictionary<string, List<string>>(); infoTexts = new Dictionary<string, List<string>>();
XDocument doc = ToolBox.TryLoadXml(file); XDocument doc = ToolBox.TryLoadXml(file);
if (doc == null) return; if (doc == null || doc.Root == null) return;
foreach (XElement subElement in doc.Root.Elements()) foreach (XElement subElement in doc.Root.Elements())
{ {
+1 -21
View File
@@ -1,30 +1,10 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq; using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Barotrauma namespace Barotrauma
{ {
class ShiftSummary 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 Location startLocation, endLocation;
private GameSession gameSession; private GameSession gameSession;
@@ -51,7 +31,7 @@ namespace Barotrauma
{ {
bool singleplayer = GameMain.NetworkMember == null; 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; bool progress = Submarine.Loaded.AtEndPosition;
GUIFrame frame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.8f); GUIFrame frame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.8f);
@@ -98,8 +98,10 @@ namespace Barotrauma
/// <summary> /// <summary>
/// If there is room, puts the item in the inventory and returns true, otherwise returns false /// If there is room, puts the item in the inventory and returns true, otherwise returns false
/// </summary> /// </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 //try to place the item in LimBlot.Any slot if that's allowed
if (allowedSlots.Contains(LimbSlot.Any)) if (allowedSlots.Contains(LimbSlot.Any))
{ {
@@ -159,11 +161,8 @@ namespace Barotrauma
bool combined = false; bool combined = false;
if (Items[index].Combine(item)) if (Items[index].Combine(item))
{ {
if (Items[index]==null) System.Diagnostics.Debug.Assert(Items[index] != null);
{
System.Diagnostics.Debug.Assert(false);
return false;
}
Inventory otherInventory = Items[index].ParentInventory; Inventory otherInventory = Items[index].ParentInventory;
if (otherInventory != null && otherInventory.Owner!=null && createNetworkEvent) if (otherInventory != null && otherInventory.Owner!=null && createNetworkEvent)
{ {
@@ -1,8 +1,4 @@
using System; using System.Xml.Linq;
using System.Collections.Generic;
using System.Xml.Linq;
using FarseerPhysics;
using FarseerPhysics.Dynamics;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Barotrauma.Particles; using Barotrauma.Particles;
@@ -95,23 +91,8 @@ namespace Barotrauma.Items.Components
return true; 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; IsActive = false;
} }
@@ -105,7 +105,7 @@ namespace Barotrauma.Items.Components
item.body.ApplyLinearImpulse( item.body.ApplyLinearImpulse(
new Vector2((float)Math.Cos(projectile.body.Rotation), (float)Math.Sin(projectile.body.Rotation)) * item.body.Mass * -50.0f); 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); item.RemoveContained(projectile);
@@ -10,13 +10,13 @@ namespace Barotrauma.Items.Components
{ {
class RepairTool : ItemComponent 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; private string particles;
@@ -1,5 +1,4 @@
using FarseerPhysics; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using System.Xml.Linq; using System.Xml.Linq;
namespace Barotrauma.Items.Components namespace Barotrauma.Items.Components
@@ -301,7 +301,7 @@ namespace Barotrauma.Items.Components
soundList.Add(itemSound); soundList.Add(itemSound);
break; break;
default: default:
ItemComponent ic = ItemComponent.Load(subElement, item, item.ConfigFile, false); ItemComponent ic = Load(subElement, item, item.ConfigFile, false);
if (ic == null) break; if (ic == null) break;
ic.Parent = this; ic.Parent = this;
@@ -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; if (hideItems || (item.body != null && !item.body.Enabled)) return;
+1 -1
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; if (character == null) return false;
@@ -215,7 +215,7 @@ namespace Barotrauma.Items.Components
character.AnimController.Anim = AnimController.Animation.None; character.AnimController.Anim = AnimController.Animation.None;
} }
public override bool Select(Character activator = null) public override bool Select(Character activator)
{ {
if (activator == null) return false; if (activator == null) return false;
@@ -117,7 +117,7 @@ namespace Barotrauma.Items.Components
} }
else else
{ {
if (!container.Inventory.Items.Any(i => i != null)) return; if (container.Inventory.Items.All(i => i == null)) return;
activateButton.Text = "Cancel"; activateButton.Text = "Cancel";
} }
@@ -90,7 +90,7 @@ namespace Barotrauma.Items.Components
for (int i = 0; i < 5; i++) 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)), -currForce / 5.0f + new Vector2(Rand.Range(-100.0f, 100.0f), Rand.Range(-50f, 50f)),
0.0f, item.CurrentHull); 0.0f, item.CurrentHull);
} }
@@ -150,7 +150,7 @@ namespace Barotrauma.Items.Components
} }
text += "Required time: " + targetItem.RequiredTime + " s"; text += "Required time: " + targetItem.RequiredTime + " s";
GUITextBlock textBlock = new GUITextBlock( new GUITextBlock(
new Rectangle(0, 50, 0, 25), new Rectangle(0, 50, 0, 25),
text, text,
Color.Transparent, Color.White, Color.Transparent, Color.White,
@@ -153,7 +153,6 @@ namespace Barotrauma.Items.Components
public override void DrawHUD(SpriteBatch spriteBatch, Character character) public override void DrawHUD(SpriteBatch spriteBatch, Character character)
{ {
int width = GuiFrame.Rect.Width, height = GuiFrame.Rect.Height;
int x = GuiFrame.Rect.X; int x = GuiFrame.Rect.X;
int y = GuiFrame.Rect.Y; int y = GuiFrame.Rect.Y;
@@ -94,19 +94,14 @@ namespace Barotrauma.Items.Components
public override void DrawHUD(SpriteBatch spriteBatch, Character character) 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.Update(1.0f / 60.0f);
GuiFrame.Draw(spriteBatch); GuiFrame.Draw(spriteBatch);
if (voltage < minVoltage) return; if (voltage < minVoltage) return;
int radius = GuiFrame.Rect.Height / 2 - 30; 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)); 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; private List<RadarBlip> radarBlips;
@@ -202,20 +197,15 @@ namespace Barotrauma.Items.Components
float pointDist = (limb.WorldPosition - item.WorldPosition).Length() * displayScale; float pointDist = (limb.WorldPosition - item.WorldPosition).Length() * displayScale;
if (limb.SimPosition == Vector2.Zero || pointDist > radius) continue; if (limb.SimPosition == Vector2.Zero || pointDist > radius) continue;
if (pointDist > radius) continue; if (pointDist > radius) continue;
if (pointDist > prevPingRadius && pointDist < pingRadius) if (pointDist > prevPingRadius && pointDist < pingRadius)
{ {
float limbSize = limb.Mass;
for (int i = 0; i<=limb.Mass/100.0f; i++) for (int i = 0; i<=limb.Mass/100.0f; i++)
{ {
var blip = new RadarBlip(limb.WorldPosition+Rand.Vector(limb.Mass/10.0f), 1.0f); var blip = new RadarBlip(limb.WorldPosition+Rand.Vector(limb.Mass/10.0f), 1.0f);
radarBlips.Add(blip); radarBlips.Add(blip);
} }
} }
} }
} }
@@ -379,12 +379,12 @@ namespace Barotrauma.Items.Components
public override bool Pick(Character picker) 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, GUI.DrawRectangle(spriteBatch,
new Vector2(item.Rect.X + item.Rect.Width / 2 - 6, -item.Rect.Y + 29), new Vector2(item.Rect.X + item.Rect.Width / 2 - 6, -item.Rect.Y + 29),
@@ -224,9 +224,9 @@ namespace Barotrauma.Items.Components
//if (connection.IsPower) voltage = power; //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, GUI.DrawRectangle(spriteBatch,
new Vector2(item.DrawPosition.X- 4, -item.DrawPosition.Y), new Vector2(item.DrawPosition.X- 4, -item.DrawPosition.Y),
@@ -1,6 +1,4 @@
using System; using System;
using System.Globalization;
using System.IO;
using System.Xml.Linq; using System.Xml.Linq;
namespace Barotrauma.Items.Components 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 (currPowerConsumption == 0.0f) voltage = 0.0f;
if (connection.IsPower) voltage = power; if (connection.IsPower) voltage = power;
@@ -1,6 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.Xml.Linq; using System.Xml.Linq;
using FarseerPhysics; using FarseerPhysics;
using FarseerPhysics.Dynamics; using FarseerPhysics.Dynamics;
@@ -18,9 +17,9 @@ namespace Barotrauma.Items.Components
private PrismaticJoint stickJoint; private PrismaticJoint stickJoint;
private Body stickTarget; private Body stickTarget;
Attack attack; private Attack attack;
public List<Body> ignoredBodies; public List<Body> IgnoredBodies;
public Character User; public Character User;
@@ -48,7 +47,7 @@ namespace Barotrauma.Items.Components
public Projectile(Item item, XElement element) public Projectile(Item item, XElement element)
: base (item, element) : base (item, element)
{ {
ignoredBodies = new List<Body>(); IgnoredBodies = new List<Body>();
//launchImpulse = ToolBox.GetAttributeFloat(element, "launchimpulse", 10.0f); //launchImpulse = ToolBox.GetAttributeFloat(element, "launchimpulse", 10.0f);
//characterUsable = ToolBox.GetAttributeBool(element, "characterusable", false); //characterUsable = ToolBox.GetAttributeBool(element, "characterusable", false);
@@ -65,24 +64,10 @@ namespace Barotrauma.Items.Components
//doesStick = ToolBox.GetAttributeBool(element, "doesstick", false); //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) public override bool Use(float deltaTime, Character character = null)
{ {
if (character != null && !characterUsable) return false; if (character != null && !characterUsable) return false;
//ApplyStatusEffects(ActionType.OnUse, 1.0f, Character);
Launch(new Vector2( Launch(new Vector2(
(float)Math.Cos(item.body.Rotation), (float)Math.Cos(item.body.Rotation),
(float)Math.Sin(item.body.Rotation)) * launchImpulse * item.body.Mass); (float)Math.Sin(item.body.Rotation)) * launchImpulse * item.body.Mass);
@@ -103,26 +88,25 @@ namespace Barotrauma.Items.Components
item.Drop(); item.Drop();
if (stickJoint != null && doesStick) if (stickJoint == null || !doesStick) return;
{
if (stickTarget != null)
{
try
{
item.body.FarseerBody.RestoreCollisionWith(stickTarget);
}
catch (Exception e)
{
#if DEBUG
DebugConsole.ThrowError("Failed to restore collision with stickTarget", e);
#endif
}
stickTarget = null; if (stickTarget != null)
{
try
{
item.body.FarseerBody.RestoreCollisionWith(stickTarget);
} }
GameMain.World.RemoveJoint(stickJoint); catch (Exception e)
stickJoint = null; {
#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) 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) 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); AttackResult attackResult = new AttackResult(0.0f, 0.0f);
if (attack != null) if (attack != null)
@@ -185,7 +169,7 @@ namespace Barotrauma.Items.Components
item.body.CollisionCategories = Physics.CollisionMisc; item.body.CollisionCategories = Physics.CollisionMisc;
item.body.CollidesWith = Physics.CollisionWall | Physics.CollisionLevel; item.body.CollidesWith = Physics.CollisionWall | Physics.CollisionLevel;
ignoredBodies.Clear(); IgnoredBodies.Clear();
f2.Body.ApplyLinearImpulse(item.body.LinearVelocity * item.body.Mass); f2.Body.ApplyLinearImpulse(item.body.LinearVelocity * item.body.Mass);
@@ -220,9 +204,7 @@ namespace Barotrauma.Items.Components
} }
} }
return (f2.CollisionCategories != Physics.CollisionCharacter); return f2.CollisionCategories != Physics.CollisionCharacter;
//return false;
} }
private bool StickToTarget(Body targetBody, Vector2 axis) private bool StickToTarget(Body targetBody, Vector2 axis)
+2 -2
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; if (!IsActive) return;
@@ -1,9 +1,6 @@
using FarseerPhysics; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Barotrauma.Lights; using Barotrauma.Lights;
using System; using System;
using System.IO;
using System.Xml.Linq; using System.Xml.Linq;
namespace Barotrauma.Items.Components namespace Barotrauma.Items.Components
@@ -135,16 +132,7 @@ namespace Barotrauma.Items.Components
voltage = 0.0f; 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() protected override void RemoveComponentSpecific()
{ {
base.RemoveComponentSpecific(); base.RemoveComponentSpecific();
@@ -1,8 +1,4 @@
using System; using System.Xml.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Barotrauma.Items.Components namespace Barotrauma.Items.Components
{ {
@@ -1,8 +1,4 @@
using System; using System.Xml.Linq;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;
namespace Barotrauma.Items.Components namespace Barotrauma.Items.Components
{ {
@@ -1,5 +1,4 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Xml.Linq; using System.Xml.Linq;
+2 -2
View File
@@ -79,7 +79,7 @@ namespace Barotrauma.Items.Components
ToolBox.GetAttributeVector2(element, "origin", Vector2.Zero)); 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); Vector2 drawPos = new Vector2(item.Rect.X, item.Rect.Y);
if (item.Submarine != null) drawPos += item.Submarine.DrawPosition; 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; if (Math.Abs(MathUtils.GetShortestAngle(enemyAngle, turretAngle)) > 0.01f) return false;
var pickedBody = Submarine.PickBody(ConvertUnits.ToSimUnits(item.WorldPosition), closestEnemy.SimPosition, null); 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); if (objective.Option.ToLower()=="fire at will") Use(deltaTime, character);
+16 -9
View File
@@ -363,8 +363,8 @@ namespace Barotrauma
{ {
if (sendingTime < lastUpdate) return; if (sendingTime < lastUpdate) return;
List<ushort> newItemIDs = new List<ushort>(); //List<ushort> newItemIDs = new List<ushort>();
List<Item> droppedItems = new List<Item>(); //List<Item> droppedItems = new List<Item>();
List<Item> prevItems = new List<Item>(Items); List<Item> prevItems = new List<Item>(Items);
for (int i = 0; i < capacity; i++) for (int i = 0; i < capacity; i++)
@@ -389,15 +389,22 @@ namespace Barotrauma
var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection); var sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
if (sender != null && sender.Character != null) 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) foreach (Item item in Items)
{ {
if (item == null || prevItems.Contains(item)) continue; if (item == null) continue;
GameServer.Log(sender.Character + " placed " + item.Name + " in " + Owner.ToString(), Color.Orange); 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);
}
} }
} }
} }
+4 -6
View File
@@ -1,14 +1,12 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
namespace Barotrauma namespace Barotrauma
{ {
class ItemSpawner class ItemSpawner
{ {
private Queue<Pair<ItemPrefab, object>> spawnQueue; private readonly Queue<Pair<ItemPrefab, object>> spawnQueue;
public ItemSpawner() public ItemSpawner()
{ {
@@ -68,7 +66,7 @@ namespace Barotrauma
{ {
var item = new Item(itemInfo.First, Vector2.Zero, null); 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); inventory.TryPutItem(item, null, false);
items.Add(item); items.Add(item);
@@ -138,7 +136,7 @@ namespace Barotrauma
class ItemRemover class ItemRemover
{ {
private Queue<Item> removeQueue; private readonly Queue<Item> removeQueue;
public ItemRemover() public ItemRemover()
{ {
@@ -191,7 +189,7 @@ namespace Barotrauma
ushort itemId = message.ReadUInt16(); ushort itemId = message.ReadUInt16();
var item = MapEntity.FindEntityByID(itemId); var item = MapEntity.FindEntityByID(itemId);
if (item == null || item as Item != null) continue; if (item == null || item is Item) continue;
item.Remove(); item.Remove();
} }
+1 -3
View File
@@ -1,6 +1,4 @@
using Microsoft.Xna.Framework;
using FarseerPhysics;
using Microsoft.Xna.Framework;
using Barotrauma.Lights; using Barotrauma.Lights;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
-2
View File
@@ -165,8 +165,6 @@ namespace Barotrauma
for (int i = 0; i < count; i++ ) 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 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); Vector2 speed = new Vector2((spawnPos.X - (WorldPosition.X + size.X / 2.0f)), (float)Math.Sqrt(size.X) * Rand.Range(10.0f, 15.0f) * growModifier);
+1 -1
View File
@@ -115,7 +115,7 @@ namespace Barotrauma
public static void UpdateHulls() public static void UpdateHulls()
{ {
foreach (Gap g in Gap.GapList) foreach (Gap g in GapList)
{ {
g.FindHulls(); g.FindHulls();
} }
@@ -1,5 +1,4 @@
using System; using System;
using System.IO;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content; using Microsoft.Xna.Framework.Content;
@@ -112,21 +112,16 @@ namespace Barotrauma.Lights
private void CalculateDimensions() private void CalculateDimensions()
{ {
Vector2 center = Vector2.Zero;
float? minX = null, minY = null, maxX = null, maxY = null; float? minX = null, minY = null, maxX = null, maxY = null;
for (int i = 0; i < vertices.Length; i++) for (int i = 0; i < vertices.Length; i++)
{ {
center += vertices[i];
if (minX == null || vertices[i].X < minX) minX = vertices[i].X; if (minX == null || vertices[i].X < minX) minX = vertices[i].X;
if (minY == null || vertices[i].Y < minY) minY = vertices[i].Y; if (minY == null || vertices[i].Y < minY) minY = vertices[i].Y;
if (maxX == null || vertices[i].X > maxX) maxX = vertices[i].X; if (maxX == null || vertices[i].X > maxX) maxX = vertices[i].X;
if (maxY == null || vertices[i].Y > minY) maxY = vertices[i].Y; 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)); boundingBox = new Rectangle((int)minX, (int)minY, (int)(maxX - minX), (int)(maxY - minY));
} }
-3
View File
@@ -1,8 +1,5 @@
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma namespace Barotrauma
{ {
+2 -2
View File
@@ -151,11 +151,11 @@ namespace Barotrauma
protected bool ResizeHorizontal protected bool ResizeHorizontal
{ {
get { return prefab == null ? false : prefab.ResizeHorizontal; } get { return prefab != null && prefab.ResizeHorizontal; }
} }
protected bool ResizeVertical protected bool ResizeVertical
{ {
get { return prefab == null ? false : prefab.ResizeVertical; } get { return prefab != null && prefab.ResizeVertical; }
} }
public virtual string Name public virtual string Name
+7 -9
View File
@@ -1,9 +1,7 @@
using System; using System;
using System.Diagnostics;
using System.Xml.Linq; using System.Xml.Linq;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System.Collections.Generic; using System.Collections.Generic;
namespace Barotrauma namespace Barotrauma
@@ -13,17 +11,17 @@ namespace Barotrauma
//public static List<StructurePrefab> list = new List<StructurePrefab>(); //public static List<StructurePrefab> list = new List<StructurePrefab>();
//does the structure have a physics body //does the structure have a physics body
bool hasBody; private bool hasBody;
bool castShadow; private bool castShadow;
bool isPlatform; private bool isPlatform;
Direction stairDirection; private Direction stairDirection;
float maxHealth; private float maxHealth;
//default size //default size
Vector2 size; private Vector2 size;
public bool HasBody public bool HasBody
{ {
@@ -55,7 +53,7 @@ namespace Barotrauma
foreach (string filePath in filePaths) foreach (string filePath in filePaths)
{ {
XDocument doc = ToolBox.TryLoadXml(filePath); XDocument doc = ToolBox.TryLoadXml(filePath);
if (doc == null) return; if (doc == null || doc.Root == null) return;
foreach (XElement el in doc.Root.Elements()) foreach (XElement el in doc.Root.Elements())
{ {
+1 -1
View File
@@ -165,7 +165,7 @@ namespace Barotrauma
public bool AtDamageDepth public bool AtDamageDepth
{ {
get { return subBody == null ? false : subBody.AtDamageDepth; } get { return subBody != null && subBody.AtDamageDepth; }
} }
public override string ToString() public override string ToString()
+4 -5
View File
@@ -310,7 +310,7 @@ namespace Barotrauma
if (hull.Rect.Width<minDist*3.0f) 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); new Vector2(hull.Rect.X + hull.Rect.Width / 2.0f, hull.Rect.Y - hull.Rect.Height + heightFromFloor), SpawnType.Path, Submarine.Loaded);
continue; continue;
} }
@@ -396,7 +396,7 @@ namespace Barotrauma
} }
List<Structure> stairList = new List<Structure>(); List<Structure> stairList = new List<Structure>();
foreach (MapEntity me in MapEntity.mapEntityList) foreach (MapEntity me in mapEntityList)
{ {
Structure stairs = me as Structure; Structure stairs = me as Structure;
if (stairs == null) continue; 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[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); ladderPoints[1] = new WayPoint(new Vector2(item.Rect.Center.X, item.Rect.Y-1.0f), SpawnType.Path, Submarine.Loaded);
WayPoint prevPoint = ladderPoints[0]; WayPoint prevPoint = ladderPoints[0];
Vector2 prevPos = prevPoint.SimPosition; Vector2 prevPos = prevPoint.SimPosition;
@@ -457,7 +456,7 @@ namespace Barotrauma
if (pickedBody.UserData is Item) if (pickedBody.UserData is Item)
{ {
var door = (pickedBody.UserData as Item).GetComponent<Door>(); var door = ((Item)pickedBody.UserData).GetComponent<Door>();
if (door != null) if (door != null)
{ {
WayPoint newPoint = new WayPoint(door.Item.Position, SpawnType.Path, Submarine.Loaded); WayPoint newPoint = new WayPoint(door.Item.Position, SpawnType.Path, Submarine.Loaded);
+1 -1
View File
@@ -128,7 +128,7 @@ namespace Barotrauma.Networking
GUIMessageBox upnpBox = new GUIMessageBox("Please wait...", "Attempting UPnP port forwarding", new string[] {"Cancel"} ); GUIMessageBox upnpBox = new GUIMessageBox("Please wait...", "Attempting UPnP port forwarding", new string[] {"Cancel"} );
upnpBox.Buttons[0].OnClicked = upnpBox.Close; 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 while (server.UPnP.Status == UPnPStatus.Discovering
&& GUIMessageBox.VisibleBox == upnpBox)// && upnpTimeout>DateTime.Now) && GUIMessageBox.VisibleBox == upnpBox)// && upnpTimeout>DateTime.Now)
{ {
@@ -53,7 +53,7 @@ namespace Barotrauma.Networking
public bool AutoRestart public bool AutoRestart
{ {
get { return (ConnectedClients.Count == 0) ? false : autoRestart; } get { return (ConnectedClients.Count != 0) && autoRestart; }
set set
{ {
autoRestart = value; autoRestart = value;
@@ -1,7 +1,4 @@
using Lidgren.Network; namespace Barotrauma.Networking
using System;
namespace Barotrauma.Networking
{ {
static class NetBufferExtensions static class NetBufferExtensions
{ {
+1 -6
View File
@@ -1,9 +1,4 @@
using System; namespace Barotrauma.Networking
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma.Networking
{ {
static class NetConfig static class NetConfig
{ {
+2 -2
View File
@@ -109,7 +109,7 @@ namespace Barotrauma.Networking
public NetworkEvent(NetworkEventType type, ushort id, bool allowClientSend, object data = null) 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; eventType = type;
@@ -168,7 +168,7 @@ namespace Barotrauma.Networking
try try
{ {
NetworkEvent.ReadData(message, sendingTime, resend); ReadData(message, sendingTime, resend);
} }
catch catch
{ {
+2 -3
View File
@@ -3,7 +3,6 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Text;
namespace Barotrauma.Networking namespace Barotrauma.Networking
{ {
@@ -19,12 +18,12 @@ namespace Barotrauma.Networking
private GUIListBox listBox; private GUIListBox listBox;
private Queue<ColoredText> lines; private readonly Queue<ColoredText> lines;
public int LinesPerFile public int LinesPerFile
{ {
get { return linesPerFile; } get { return linesPerFile; }
set { linesPerFile = Math.Max(10, linesPerFile); } set { linesPerFile = Math.Max(value, 10); }
} }
public ServerLog(string serverName) public ServerLog(string serverName)
@@ -32,7 +32,7 @@ namespace Barotrauma.Particles
particles = new Particle[MaxParticles]; particles = new Particle[MaxParticles];
XDocument doc = ToolBox.TryLoadXml(configFile); XDocument doc = ToolBox.TryLoadXml(configFile);
if (doc == null) return; if (doc == null || doc.Root == null) return;
prefabs = new Dictionary<string, ParticlePrefab>(); prefabs = new Dictionary<string, ParticlePrefab>();
+2 -7
View File
@@ -206,12 +206,7 @@ namespace Barotrauma
{ {
var frame = c.CreateCharacterFrame(hireList, c.Name + " (" + c.Job.Name + ")", c); var frame = c.CreateCharacterFrame(hireList, c.Name + " (" + c.Job.Name + ")", c);
//GUITextBlock textBlock = new GUITextBlock( new GUITextBlock(
// new Rectangle(0, 0, 0, 25),
// c.Name + " (" + c.Job.Name + ")", GUI.Style, hireList);
//textBlock.UserData = c;
var textBlock = new GUITextBlock(
new Rectangle(0, 0, 0, 25), new Rectangle(0, 0, 0, 25),
c.Salary.ToString(), c.Salary.ToString(),
null, null, null, null,
@@ -475,7 +470,7 @@ namespace Barotrauma
GUIComponent prevInfoFrame = null; GUIComponent prevInfoFrame = null;
foreach (GUIComponent child in bottomPanel[selectedRightPanel].children) foreach (GUIComponent child in bottomPanel[selectedRightPanel].children)
{ {
if (child.UserData as CharacterInfo == null) continue; if (!(child.UserData is CharacterInfo)) continue;
prevInfoFrame = child; prevInfoFrame = child;
} }
+1 -4
View File
@@ -208,16 +208,13 @@ namespace Barotrauma
otherButton.Selected = false; otherButton.Selected = false;
} }
if (Screen.Selected != this) Select(); if (Selected != this) Select();
return true; return true;
} }
public void SelectTab(Tab tab) public void SelectTab(Tab tab)
{ {
int oldTab = selectedTab;
if (GameMain.Config.UnsavedSettings) if (GameMain.Config.UnsavedSettings)
{ {
var applyBox = new GUIMessageBox("Apply changes?", "Do you want to apply the settings or discard the changes?", var applyBox = new GUIMessageBox("Apply changes?", "Do you want to apply the settings or discard the changes?",
+2 -2
View File
@@ -246,7 +246,7 @@ namespace Barotrauma
//traitor probability ------------------------------------------------------------------ //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]; traitorProbabilityButtons = new GUIButton[2];
@@ -1000,7 +1000,7 @@ namespace Barotrauma
//msg.Write(durationBar.BarScroll); //msg.Write(durationBar.BarScroll);
msg.Write(LevelSeed); 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(GameMain.Server == null ? 0.0f : GameMain.Server.AutoRestartTimer);
msg.Write((byte)(playerList.CountChildren)); msg.Write((byte)(playerList.CountChildren));
+1 -2
View File
@@ -45,11 +45,10 @@ namespace Barotrauma
private IEnumerable<object> UpdateColorFade(Color from, Color to, float duration) private IEnumerable<object> UpdateColorFade(Color from, Color to, float duration)
{ {
while (Screen.Selected != this) while (Selected != this)
{ {
yield return CoroutineStatus.Running; yield return CoroutineStatus.Running;
} }
float timer = 0.0f; float timer = 0.0f;
@@ -1,12 +1,7 @@
using System; using System;
using Lidgren.Network;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Barotrauma.Networking; using Barotrauma.Networking;
using FarseerPhysics;
using FarseerPhysics.Factories;
using FarseerPhysics.Dynamics;
using System.IO;
using System.Collections.Generic; using System.Collections.Generic;
using RestSharp; using RestSharp;
+6 -15
View File
@@ -1,5 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.Xna.Framework; using Microsoft.Xna.Framework;
using OpenTK.Audio.OpenAL; using OpenTK.Audio.OpenAL;
using OpenTK.Audio; using OpenTK.Audio;
@@ -12,22 +11,14 @@ namespace Barotrauma.Sounds
{ {
public const int DefaultSourceCount = 16; public const int DefaultSourceCount = 16;
private static List<int> alSources = new List<int>(); private static readonly List<int> alSources = new List<int>();
private static int[] alBuffers = new int[DefaultSourceCount]; private static readonly int[] alBuffers = new int[DefaultSourceCount];
private static int lowpassFilterId; private static int lowpassFilterId;
private static AudioContext AC;
//private static float overrideLowPassGain; private static OggStreamer oggStreamer;
private static OggStream oggStream;
//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;
public static float MasterVolume = 1.0f; public static float MasterVolume = 1.0f;
-3
View File
@@ -1,7 +1,4 @@
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma namespace Barotrauma
{ {
+1 -5
View File
@@ -1,9 +1,5 @@
using Lidgren.Network; using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework;
using System; using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Barotrauma namespace Barotrauma
{ {
-2
View File
@@ -1,8 +1,6 @@
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.IO.Compression; using System.IO.Compression;
using System.Linq;
using System.Text; using System.Text;
using System.Xml.Linq; using System.Xml.Linq;
+1 -4
View File
@@ -1,10 +1,7 @@
using System.Drawing; using System.IO;
using System.Drawing.Imaging;
using System.IO;
using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Graphics;
using Color = Microsoft.Xna.Framework.Color; using Color = Microsoft.Xna.Framework.Color;
using System; using System;
using Microsoft.Xna.Framework;
namespace Barotrauma namespace Barotrauma
{ {