From f7f87b199fb1dae0fc8b9588f9a258f178dba0d3 Mon Sep 17 00:00:00 2001 From: Regalis11 Date: Sat, 6 Jun 2015 16:03:16 +0300 Subject: [PATCH 1/2] resharper cleanup --- Subsurface/Items/Components/OxygenGenerator.cs | 6 ++---- Subsurface/Items/Components/Signal/LightComponent.cs | 2 +- Subsurface/Physics/PhysicsBody.cs | 2 +- Subsurface/Screens/Screen.cs | 3 +-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Subsurface/Items/Components/OxygenGenerator.cs b/Subsurface/Items/Components/OxygenGenerator.cs index 1a43e3e52..f060f2be8 100644 --- a/Subsurface/Items/Components/OxygenGenerator.cs +++ b/Subsurface/Items/Components/OxygenGenerator.cs @@ -24,10 +24,8 @@ namespace Subsurface.Items.Components ventList = new List(); - item.linkedTo.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler( - delegate(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) - { GetVents(); } - ); + item.linkedTo.CollectionChanged += delegate(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) + { GetVents(); }; } public override void Update(float deltaTime, Camera cam) diff --git a/Subsurface/Items/Components/Signal/LightComponent.cs b/Subsurface/Items/Components/Signal/LightComponent.cs index 4c311b4b8..8563a9c8a 100644 --- a/Subsurface/Items/Components/Signal/LightComponent.cs +++ b/Subsurface/Items/Components/Signal/LightComponent.cs @@ -50,7 +50,7 @@ namespace Subsurface.Items.Components isActive = !isActive; break; case "set_state": - isActive = (signal == "0") ? false : true; + isActive = (signal != "0"); break; } } diff --git a/Subsurface/Physics/PhysicsBody.cs b/Subsurface/Physics/PhysicsBody.cs index 45de3635c..1955c4f63 100644 --- a/Subsurface/Physics/PhysicsBody.cs +++ b/Subsurface/Physics/PhysicsBody.cs @@ -190,7 +190,7 @@ namespace Subsurface else if (radius != 0.0f) { body = BodyFactory.CreateCircle(Game1.world, radius, density); - bodyShape = Shape.Circle; ; + bodyShape = Shape.Circle; } else { diff --git a/Subsurface/Screens/Screen.cs b/Subsurface/Screens/Screen.cs index 11b393f5d..97132c386 100644 --- a/Subsurface/Screens/Screen.cs +++ b/Subsurface/Screens/Screen.cs @@ -1,5 +1,4 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Graphics; namespace Subsurface { From 34b79c85d65520254593282ab497cffae4e107b9 Mon Sep 17 00:00:00 2001 From: Regalis11 Date: Sun, 7 Jun 2015 18:03:08 +0300 Subject: [PATCH 2/2] More resharper cleanup --- Subsurface/Characters/AI/EnemyAIController.cs | 23 ++++++++----------- Subsurface/Characters/AI/SteeringPath.cs | 2 +- Subsurface/Characters/Character.cs | 17 +++++++------- Subsurface/Characters/DelayedEffect.cs | 7 ++---- .../Characters/HumanoidAnimController.cs | 3 +-- Subsurface/Characters/Jobs/Job.cs | 6 ++--- Subsurface/Characters/Ragdoll.cs | 1 - Subsurface/Characters/StatusEffect.cs | 4 ---- Subsurface/GUI/GUI.cs | 8 +++---- Subsurface/GUI/GUIButton.cs | 2 +- Subsurface/GUI/GUIMessageBox.cs | 4 +--- Subsurface/GUI/GUITextBlock.cs | 2 +- Subsurface/Game1.cs | 1 - Subsurface/GameSession/CrewManager.cs | 2 +- Subsurface/GameSession/HireManager.cs | 2 -- .../{Interface1.cs => IPropertyObject.cs} | 5 +--- Subsurface/Items/Components/Controller.cs | 2 -- Subsurface/Items/Components/Door.cs | 2 +- Subsurface/Items/Components/Holdable.cs | 5 ++-- Subsurface/Items/Components/ItemComponent.cs | 11 +++------ Subsurface/Items/Components/Pickable.cs | 1 - Subsurface/Items/Components/PowerTransfer.cs | 5 +++- Subsurface/Items/Components/Pump.cs | 13 +++-------- Subsurface/Items/Components/RangedWeapon.cs | 2 +- Subsurface/Items/Components/Reactor.cs | 1 - Subsurface/Items/Components/RepairTool.cs | 9 +++++--- Subsurface/Items/Components/Rope.cs | 4 ++-- .../Items/Components/Signal/AndComponent.cs | 1 - .../Items/Components/Signal/Connection.cs | 3 +-- .../Components/Signal/ConnectionPanel.cs | 3 --- .../Items/Components/Signal/LightComponent.cs | 4 ---- .../Items/Components/Signal/NotComponent.cs | 6 +---- .../Items/Components/Signal/OxygenDetector.cs | 6 +---- .../Components/Signal/RegExFindComponent.cs | 9 +------- Subsurface/Items/Components/Signal/Wire.cs | 1 - Subsurface/Items/Components/Throwable.cs | 6 ----- Subsurface/Items/Components/Turret.cs | 3 +-- Subsurface/Items/Components/Wearable.cs | 2 -- Subsurface/Items/Item.cs | 8 ++----- Subsurface/Map/Entity.cs | 2 +- Subsurface/Map/Explosion.cs | 2 -- Subsurface/Map/Gap.cs | 2 +- Subsurface/Map/Hull.cs | 8 +++---- Subsurface/Map/Lights/ConvexHull.cs | 2 -- Subsurface/Map/Lights/LightManager.cs | 4 ---- Subsurface/Map/Map.cs | 6 ++--- Subsurface/Map/MapEntity.cs | 2 +- Subsurface/Map/MapEntityPrefab.cs | 2 +- Subsurface/Map/WaterRenderer.cs | 2 +- Subsurface/Map/WayPoint.cs | 2 +- Subsurface/Networking/GameClient.cs | 6 ++--- Subsurface/Networking/NetworkEvent.cs | 4 ++-- Subsurface/Physics/PhysicsBody.cs | 3 +-- Subsurface/Properties.cs | 9 ++++---- Subsurface/Screens/EditCharacterScreen.cs | 8 +------ Subsurface/Screens/GameScreen.cs | 1 - Subsurface/Screens/MainMenu.cs | 1 - Subsurface/Screens/NetLobbyScreen.cs | 6 ++--- Subsurface/Sounds/AmbientSoundManager.cs | 10 ++++---- Subsurface/Sounds/Sound.cs | 4 ++-- Subsurface/Sprite.cs | 10 ++++---- Subsurface/ToolBox.cs | 2 +- 62 files changed, 99 insertions(+), 195 deletions(-) rename Subsurface/{Interface1.cs => IPropertyObject.cs} (64%) diff --git a/Subsurface/Characters/AI/EnemyAIController.cs b/Subsurface/Characters/AI/EnemyAIController.cs index 3e18ecebf..8044270f4 100644 --- a/Subsurface/Characters/AI/EnemyAIController.cs +++ b/Subsurface/Characters/AI/EnemyAIController.cs @@ -331,7 +331,7 @@ namespace Subsurface selectedTarget = null; selectedTargetMemory = null; - this.targetValue = 0.0f; + targetValue = 0.0f; UpdateTargetMemories(); @@ -372,7 +372,7 @@ namespace Subsurface valueModifier = valueModifier * targetMemory.Priority / dist; //dist -= targetMemory.Priority; - if (Math.Abs(valueModifier) > Math.Abs(this.targetValue) && (dist < target.SightRange * sight || dist < target.SoundRange * hearing)) + if (Math.Abs(valueModifier) > Math.Abs(targetValue) && (dist < target.SightRange * sight || dist < target.SoundRange * hearing)) { Vector2 rayStart = character.animController.limbs[0].SimPosition; Vector2 rayEnd = target.Position; @@ -408,12 +408,12 @@ namespace Subsurface //float newTargetValue = valueModifier/dist; - if (selectedTarget == null || Math.Abs(valueModifier) > Math.Abs(this.targetValue)) + if (selectedTarget == null || Math.Abs(valueModifier) > Math.Abs(targetValue)) { selectedTarget = target; selectedTargetMemory = targetMemory; - this.targetValue = valueModifier; + targetValue = valueModifier; Debug.WriteLine(selectedTarget.entity+": "+targetValue); } } @@ -479,18 +479,13 @@ namespace Subsurface wallAttackPos.X = message.ReadFloat(); wallAttackPos.Y = message.ReadFloat(); - float wanderAngle = message.ReadFloat(); - float updateTargetsTimer = message.ReadFloat(); - float raycastTimer = message.ReadFloat(); - float coolDownTimer = message.ReadFloat(); + steeringManager.WanderAngle = message.ReadFloat(); + updateTargetsTimer = message.ReadFloat(); + raycastTimer = message.ReadFloat(); + coolDownTimer = message.ReadFloat(); int targetID = message.ReadInt32(); - - steeringManager.WanderAngle = wanderAngle; - this.updateTargetsTimer = updateTargetsTimer; - this.raycastTimer = raycastTimer; - this.coolDownTimer = coolDownTimer; - + if (targetID>-1) targetEntity = Entity.FindEntityByID(targetID) as IDamageable; diff --git a/Subsurface/Characters/AI/SteeringPath.cs b/Subsurface/Characters/AI/SteeringPath.cs index e3e8ee835..e07730aa9 100644 --- a/Subsurface/Characters/AI/SteeringPath.cs +++ b/Subsurface/Characters/AI/SteeringPath.cs @@ -30,7 +30,7 @@ namespace Subsurface public Vector2 GetNode(Vector2 pos) { if (nodes.Count == 0) return Vector2.Zero; - if (currentNode==null || currentNode==Vector2.Zero || Vector2.Distance(pos, currentNode) 0) + var xSounds = doc.Root.Elements("sound").ToList(); + if (xSounds.Any()) { sounds = new Sound[xSounds.Count()]; soundStates = new AIController.AiState[xSounds.Count()]; @@ -332,9 +331,9 @@ namespace Subsurface animController.FindHull(); - if (this.info.ID >= 0) + if (info.ID >= 0) { - ID = this.info.ID; + ID = info.ID; } characterList.Add(this); @@ -597,12 +596,12 @@ namespace Subsurface drowningBar = new GUIProgressBar(new Rectangle(Game1.GraphicsWidth / 2 - width / 2, 20, width, height), Color.Blue, 1.0f); } - drowningBar.BarSize = Character.Controlled.Oxygen / 100.0f; + drowningBar.BarSize = Controlled.Oxygen / 100.0f; if (drowningBar.BarSize < 1.0f) drowningBar.Draw(spriteBatch); - if (Character.Controlled.Inventory != null) - Character.Controlled.Inventory.Draw(spriteBatch); + if (Controlled.Inventory != null) + Controlled.Inventory.Draw(spriteBatch); if (closestItem!=null) { @@ -634,7 +633,7 @@ namespace Subsurface public void PlaySound(AIController.AiState state) { - if (sounds == null || sounds.Count()==0) return; + if (sounds == null || !sounds.Any()) return; var matchingSoundStates = soundStates.Where(x => x == state).ToList(); int selectedSound = Game1.localRandom.Next(matchingSoundStates.Count()); diff --git a/Subsurface/Characters/DelayedEffect.cs b/Subsurface/Characters/DelayedEffect.cs index c4231fff4..1ecb3098c 100644 --- a/Subsurface/Characters/DelayedEffect.cs +++ b/Subsurface/Characters/DelayedEffect.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; using System.Xml.Linq; namespace Subsurface @@ -39,7 +36,7 @@ namespace Subsurface this.character = character; this.limb = limb; - this.timer = delay; + timer = delay; list.Add(this); } diff --git a/Subsurface/Characters/HumanoidAnimController.cs b/Subsurface/Characters/HumanoidAnimController.cs index e2fe94c63..2b49680cd 100644 --- a/Subsurface/Characters/HumanoidAnimController.cs +++ b/Subsurface/Characters/HumanoidAnimController.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics; using System.Linq; using System.Xml.Linq; using FarseerPhysics; @@ -33,7 +32,7 @@ namespace Subsurface { case Physics.CollisionStairs: Structure structure = fixture.Body.UserData as Structure; - if (stairs == null && (!inWater || TargetMovement.Y>0.0f)) + if (stairs == null && (!inWater || TargetMovement.Y>0.0f) && structure!=null) { if (LowestLimb.SimPosition.Y(); XDocument doc = ToolBox.TryLoadXml(filePath); + if (doc == null) return; foreach (XElement element in doc.Root.Elements()) { diff --git a/Subsurface/Characters/Ragdoll.cs b/Subsurface/Characters/Ragdoll.cs index aabff7ca5..42d5b4e92 100644 --- a/Subsurface/Characters/Ragdoll.cs +++ b/Subsurface/Characters/Ragdoll.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Linq; using System.Xml.Linq; using FarseerPhysics; diff --git a/Subsurface/Characters/StatusEffect.cs b/Subsurface/Characters/StatusEffect.cs index fbede10d3..2fa7fca9c 100644 --- a/Subsurface/Characters/StatusEffect.cs +++ b/Subsurface/Characters/StatusEffect.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.ComponentModel; -using System.IO; using System.Linq; using System.Xml.Linq; @@ -9,8 +7,6 @@ namespace Subsurface { class StatusEffect { - - [Flags] public enum Target { diff --git a/Subsurface/GUI/GUI.cs b/Subsurface/GUI/GUI.cs index a37a1ff21..f0a743c63 100644 --- a/Subsurface/GUI/GUI.cs +++ b/Subsurface/GUI/GUI.cs @@ -48,13 +48,13 @@ namespace Subsurface set { lifeTime = value; } } - public GUIMessage(string text, Color color, Vector2 pos, float lifeTime) + public GUIMessage(string text, Color color, Vector2 position, float lifeTime) { - this.coloredText = new ColoredText(text, color); - this.pos = pos; + coloredText = new ColoredText(text, color); + pos = position; this.lifeTime = lifeTime; - this.size = GUI.font.MeasureString(text); + size = GUI.font.MeasureString(text); } } diff --git a/Subsurface/GUI/GUIButton.cs b/Subsurface/GUI/GUIButton.cs index 2df63df73..eed7ce64d 100644 --- a/Subsurface/GUI/GUIButton.cs +++ b/Subsurface/GUI/GUIButton.cs @@ -45,7 +45,7 @@ namespace Subsurface if (parent != null) parent.AddChild(this); - this.textBlock = new GUITextBlock(new Rectangle(0,0,0,0), text, Color.Transparent, Color.Black, (Alignment.CenterX | Alignment.CenterY), this); + textBlock = new GUITextBlock(new Rectangle(0,0,0,0), text, Color.Transparent, Color.Black, (Alignment.CenterX | Alignment.CenterY), this); } diff --git a/Subsurface/GUI/GUIMessageBox.cs b/Subsurface/GUI/GUIMessageBox.cs index 20f163138..f11d31889 100644 --- a/Subsurface/GUI/GUIMessageBox.cs +++ b/Subsurface/GUI/GUIMessageBox.cs @@ -1,8 +1,5 @@ using Microsoft.Xna.Framework; -using System; using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Subsurface { @@ -31,6 +28,7 @@ namespace Subsurface if (buttons == null || buttons.Length == 0) { DebugConsole.ThrowError("Creating a message box with no buttons isn't allowed"); + return; } new GUITextBlock(new Rectangle(0, 5, 0, 30), header, Color.Transparent, Color.White, textAlignment, frame, true); diff --git a/Subsurface/GUI/GUITextBlock.cs b/Subsurface/GUI/GUITextBlock.cs index cd6b8264a..b5ad340dc 100644 --- a/Subsurface/GUI/GUITextBlock.cs +++ b/Subsurface/GUI/GUITextBlock.cs @@ -119,7 +119,7 @@ namespace Subsurface if (wrap && rect.Width>0) { text = text.Replace("\n"," "); - this.text = ToolBox.WrapText(this.text, rect.Width); + text = ToolBox.WrapText(text, rect.Width); Vector2 newSize = MeasureText(); diff --git a/Subsurface/Game1.cs b/Subsurface/Game1.cs index 40837c7a5..e7620aed3 100644 --- a/Subsurface/Game1.cs +++ b/Subsurface/Game1.cs @@ -5,7 +5,6 @@ using FarseerPhysics; using FarseerPhysics.Dynamics; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; using Subsurface.Networking; using Subsurface.Particles; diff --git a/Subsurface/GameSession/CrewManager.cs b/Subsurface/GameSession/CrewManager.cs index 47438c8c9..78daf7c79 100644 --- a/Subsurface/GameSession/CrewManager.cs +++ b/Subsurface/GameSession/CrewManager.cs @@ -95,7 +95,7 @@ namespace Subsurface frame); textBlock.Padding = new Vector4(5.0f, 0.0f, 5.0f, 0.0f); - GUIImage face = new GUIImage(new Rectangle(-10,-10,0,0), character.animController.limbs[0].sprite, Alignment.Left, frame); + new GUIImage(new Rectangle(-10,-10,0,0), character.animController.limbs[0].sprite, Alignment.Left, frame); } public void KillCharacter(Character killedCharacter) diff --git a/Subsurface/GameSession/HireManager.cs b/Subsurface/GameSession/HireManager.cs index be669bbea..5877c0964 100644 --- a/Subsurface/GameSession/HireManager.cs +++ b/Subsurface/GameSession/HireManager.cs @@ -1,6 +1,4 @@ using System.Collections.Generic; -using System.Diagnostics; -using System.Linq; namespace Subsurface { diff --git a/Subsurface/Interface1.cs b/Subsurface/IPropertyObject.cs similarity index 64% rename from Subsurface/Interface1.cs rename to Subsurface/IPropertyObject.cs index 6e5970c01..618fad5c2 100644 --- a/Subsurface/Interface1.cs +++ b/Subsurface/IPropertyObject.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; namespace Subsurface { diff --git a/Subsurface/Items/Components/Controller.cs b/Subsurface/Items/Components/Controller.cs index dd2b3d65b..e5b455468 100644 --- a/Subsurface/Items/Components/Controller.cs +++ b/Subsurface/Items/Components/Controller.cs @@ -1,11 +1,9 @@ using System; using System.Collections.Generic; -using System.Diagnostics; using System.Xml.Linq; using FarseerPhysics; using FarseerPhysics.Dynamics.Joints; using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; namespace Subsurface.Items.Components { diff --git a/Subsurface/Items/Components/Door.cs b/Subsurface/Items/Components/Door.cs index 7b22a9c8a..2f5b47d9e 100644 --- a/Subsurface/Items/Components/Door.cs +++ b/Subsurface/Items/Components/Door.cs @@ -123,7 +123,7 @@ namespace Subsurface.Items.Components Vector2[] corners = GetConvexHullCorners(doorRect); convexHull = new ConvexHull(corners, Color.Black); - if (window!=null && window!=Rectangle.Empty) convexHull2 = new ConvexHull(corners, Color.Black); + if (window!=Rectangle.Empty) convexHull2 = new ConvexHull(corners, Color.Black); UpdateConvexHulls(); diff --git a/Subsurface/Items/Components/Holdable.cs b/Subsurface/Items/Components/Holdable.cs index da63930bc..84b375006 100644 --- a/Subsurface/Items/Components/Holdable.cs +++ b/Subsurface/Items/Components/Holdable.cs @@ -1,5 +1,4 @@ -using System.Diagnostics; -using System.Xml.Linq; +using System.Xml.Linq; using FarseerPhysics; using Microsoft.Xna.Framework; @@ -62,7 +61,7 @@ namespace Subsurface.Items.Components } [HasDefaultValue(0.0f, false)] - private float HoldAngle + public float HoldAngle { get { return MathHelper.ToDegrees(holdAngle); } set { holdAngle = MathHelper.ToRadians(value); } diff --git a/Subsurface/Items/Components/ItemComponent.cs b/Subsurface/Items/Components/ItemComponent.cs index 365b1fe3c..e57b3c3b9 100644 --- a/Subsurface/Items/Components/ItemComponent.cs +++ b/Subsurface/Items/Components/ItemComponent.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.ComponentModel; using System.Linq; using System.Reflection; using System.Xml.Linq; @@ -277,10 +276,10 @@ namespace Subsurface public bool HasRequiredContainedItems(bool addMessage) { - if (requiredItems.Count() == 0) return true; + if (!requiredItems.Any()) return true; Item[] containedItems = item.ContainedItems; - if (containedItems == null || containedItems.Count() == 0) return false; + if (containedItems == null || !containedItems.Any()) return false; foreach (RelatedItem ri in requiredItems) { @@ -298,7 +297,7 @@ namespace Subsurface public bool HasRequiredEquippedItems(Character character, bool addMessage) { - if (requiredItems.Count() == 0) return true; + if (!requiredItems.Any()) return true; foreach (RelatedItem ri in requiredItems) { @@ -325,10 +324,6 @@ namespace Subsurface return false; } } - else - { - continue; - } } return true; diff --git a/Subsurface/Items/Components/Pickable.cs b/Subsurface/Items/Components/Pickable.cs index 5e9d5ed37..c466126aa 100644 --- a/Subsurface/Items/Components/Pickable.cs +++ b/Subsurface/Items/Components/Pickable.cs @@ -1,5 +1,4 @@ using System; -using System.Diagnostics; using System.Xml.Linq; namespace Subsurface.Items.Components diff --git a/Subsurface/Items/Components/PowerTransfer.cs b/Subsurface/Items/Components/PowerTransfer.cs index d13d1b09e..f8691148f 100644 --- a/Subsurface/Items/Components/PowerTransfer.cs +++ b/Subsurface/Items/Components/PowerTransfer.cs @@ -3,6 +3,7 @@ using System.Xml.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; +using System.Globalization; namespace Subsurface.Items.Components { @@ -48,7 +49,9 @@ namespace Subsurface.Items.Components { pt.powerLoad += (fullLoad - pt.powerLoad) / inertia; pt.currPowerConsumption += (-fullPower - pt.currPowerConsumption) / inertia; - pt.Item.SendSignal((fullPower / Math.Max(fullLoad,1.0f)).ToString(), "power_out"); + pt.Item.SendSignal( + (fullPower / Math.Max(fullLoad,1.0f)).ToString(CultureInfo.InvariantCulture), + "power_out"); } else diff --git a/Subsurface/Items/Components/Pump.cs b/Subsurface/Items/Components/Pump.cs index 7530aa8b8..3b47a67c6 100644 --- a/Subsurface/Items/Components/Pump.cs +++ b/Subsurface/Items/Components/Pump.cs @@ -1,9 +1,4 @@ -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Graphics; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Specialized; using System.Xml.Linq; namespace Subsurface.Items.Components @@ -29,10 +24,8 @@ namespace Subsurface.Items.Components { //maxFlow = ToolBox.GetAttributeFloat(element, "maxflow", 100.0f); - item.linkedTo.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler( - delegate(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) - { GetHulls(); } - ); + item.linkedTo.CollectionChanged += delegate(object sender, NotifyCollectionChangedEventArgs e) + { GetHulls(); }; } public override void Update(float deltaTime, Camera cam) diff --git a/Subsurface/Items/Components/RangedWeapon.cs b/Subsurface/Items/Components/RangedWeapon.cs index b82968b7f..c82aeb818 100644 --- a/Subsurface/Items/Components/RangedWeapon.cs +++ b/Subsurface/Items/Components/RangedWeapon.cs @@ -61,7 +61,7 @@ namespace Subsurface.Items.Components } Item[] containedItems = item.ContainedItems; - if (containedItems == null || containedItems.Count()==0) return false; + if (containedItems == null || !containedItems.Any()) return false; foreach (Item projectile in containedItems) { diff --git a/Subsurface/Items/Components/Reactor.cs b/Subsurface/Items/Components/Reactor.cs index e2f4279b9..ca44980b5 100644 --- a/Subsurface/Items/Components/Reactor.cs +++ b/Subsurface/Items/Components/Reactor.cs @@ -5,7 +5,6 @@ using Lidgren.Network; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Subsurface.Networking; -using System.Globalization; namespace Subsurface.Items.Components { diff --git a/Subsurface/Items/Components/RepairTool.cs b/Subsurface/Items/Components/RepairTool.cs index be095919f..dd0012aaa 100644 --- a/Subsurface/Items/Components/RepairTool.cs +++ b/Subsurface/Items/Components/RepairTool.cs @@ -19,20 +19,23 @@ namespace Subsurface.Items.Components float structureFixAmount, limbFixAmount; [HasDefaultValue(100.0f, false)] - private float Range + public float Range { + get { return ConvertUnits.ToDisplayUnits(range); } set { range = ConvertUnits.ToSimUnits(value); } } [HasDefaultValue(1.0f, false)] - private float StructureFixAmount + public float StructureFixAmount { + get { return structureFixAmount; } set { structureFixAmount = value; } } [HasDefaultValue(1.0f, false)] - private float LimbFixAmount + public float LimbFixAmount { + get { return limbFixAmount; } set { limbFixAmount = value; } } diff --git a/Subsurface/Items/Components/Rope.cs b/Subsurface/Items/Components/Rope.cs index dc9300bc9..2d89415d5 100644 --- a/Subsurface/Items/Components/Rope.cs +++ b/Subsurface/Items/Components/Rope.cs @@ -282,7 +282,7 @@ namespace Subsurface.Items.Components isActive = true; this.projectile = projectile; - Projectile projectileComponent = projectile.GetComponent(); + //Projectile projectileComponent = projectile.GetComponent(); foreach (PhysicsBody b in ropeBodies) { @@ -313,7 +313,7 @@ namespace Subsurface.Items.Components { float rotation = (item.body.Dir == -1.0f) ? item.body.Rotation - MathHelper.Pi : item.body.Rotation; body.SetTransform(TransformedBarrelPos, rotation); - Vector2 axis = new Vector2((float)Math.Cos(rotation), (float)Math.Sin(rotation)); + //Vector2 axis = new Vector2((float)Math.Cos(rotation), (float)Math.Sin(rotation)); if (gunJoint != null) Game1.world.RemoveJoint(gunJoint); gunJoint = new DistanceJoint(item.body.FarseerBody, body, BarrelPos, diff --git a/Subsurface/Items/Components/Signal/AndComponent.cs b/Subsurface/Items/Components/Signal/AndComponent.cs index cc2dd9a09..97bdc4385 100644 --- a/Subsurface/Items/Components/Signal/AndComponent.cs +++ b/Subsurface/Items/Components/Signal/AndComponent.cs @@ -1,5 +1,4 @@ using System; -using System.Globalization; using System.Xml.Linq; namespace Subsurface.Items.Components diff --git a/Subsurface/Items/Components/Signal/Connection.cs b/Subsurface/Items/Components/Signal/Connection.cs index fe8330e78..bc07c0cae 100644 --- a/Subsurface/Items/Components/Signal/Connection.cs +++ b/Subsurface/Items/Components/Signal/Connection.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; using System.Linq; -using System.Text; using System.Xml.Linq; namespace Subsurface.Items.Components @@ -409,7 +408,7 @@ namespace Subsurface.Items.Components { if (wires[i] == null) continue; - Connection recipient = wires[i].OtherConnection(this); + //Connection recipient = wires[i].OtherConnection(this); //int connectionIndex = recipient.item.Connections.FindIndex(x => x == recipient); newElement.Add(new XElement("link", diff --git a/Subsurface/Items/Components/Signal/ConnectionPanel.cs b/Subsurface/Items/Components/Signal/ConnectionPanel.cs index f9361442e..884c82285 100644 --- a/Subsurface/Items/Components/Signal/ConnectionPanel.cs +++ b/Subsurface/Items/Components/Signal/ConnectionPanel.cs @@ -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; using System.Xml.Linq; namespace Subsurface.Items.Components diff --git a/Subsurface/Items/Components/Signal/LightComponent.cs b/Subsurface/Items/Components/Signal/LightComponent.cs index 8563a9c8a..f08a00cae 100644 --- a/Subsurface/Items/Components/Signal/LightComponent.cs +++ b/Subsurface/Items/Components/Signal/LightComponent.cs @@ -1,8 +1,4 @@ using Microsoft.Xna.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Xml.Linq; namespace Subsurface.Items.Components diff --git a/Subsurface/Items/Components/Signal/NotComponent.cs b/Subsurface/Items/Components/Signal/NotComponent.cs index c15aaff47..2583f8384 100644 --- a/Subsurface/Items/Components/Signal/NotComponent.cs +++ b/Subsurface/Items/Components/Signal/NotComponent.cs @@ -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 Subsurface.Items.Components { diff --git a/Subsurface/Items/Components/Signal/OxygenDetector.cs b/Subsurface/Items/Components/Signal/OxygenDetector.cs index 655584f02..9e8940764 100644 --- a/Subsurface/Items/Components/Signal/OxygenDetector.cs +++ b/Subsurface/Items/Components/Signal/OxygenDetector.cs @@ -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 Subsurface.Items.Components { diff --git a/Subsurface/Items/Components/Signal/RegExFindComponent.cs b/Subsurface/Items/Components/Signal/RegExFindComponent.cs index 2b7847a40..b9ee4e9d7 100644 --- a/Subsurface/Items/Components/Signal/RegExFindComponent.cs +++ b/Subsurface/Items/Components/Signal/RegExFindComponent.cs @@ -48,14 +48,7 @@ namespace Subsurface.Items.Components return; } - if (success) - { - item.SendSignal(output, "signal_out", item); - } - else - { - item.SendSignal("0", "signal_out", item); - } + item.SendSignal(success ? output : "0", "signal_out", item); break; case "set_output": diff --git a/Subsurface/Items/Components/Signal/Wire.cs b/Subsurface/Items/Components/Signal/Wire.cs index 9a651221a..ced4a556c 100644 --- a/Subsurface/Items/Components/Signal/Wire.cs +++ b/Subsurface/Items/Components/Signal/Wire.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.Globalization; using System.Linq; -using System.Text; using System.Xml.Linq; namespace Subsurface.Items.Components diff --git a/Subsurface/Items/Components/Throwable.cs b/Subsurface/Items/Components/Throwable.cs index 0a3382ba2..bf21e5e73 100644 --- a/Subsurface/Items/Components/Throwable.cs +++ b/Subsurface/Items/Components/Throwable.cs @@ -1,9 +1,5 @@ using FarseerPhysics; using Microsoft.Xna.Framework; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Xml.Linq; namespace Subsurface.Items.Components @@ -98,8 +94,6 @@ namespace Subsurface.Items.Components item.Drop(); item.body.ApplyLinearImpulse(throwVector * throwForce * item.body.Mass * 3.0f); } - - return; } } } diff --git a/Subsurface/Items/Components/Turret.cs b/Subsurface/Items/Components/Turret.cs index 45a133f75..aca69bcdf 100644 --- a/Subsurface/Items/Components/Turret.cs +++ b/Subsurface/Items/Components/Turret.cs @@ -4,7 +4,6 @@ using System.IO; using System.Xml.Linq; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System.Globalization; namespace Subsurface.Items.Components { @@ -152,7 +151,7 @@ namespace Subsurface.Items.Components currPowerConsumption = powerConsumption; float availablePower = 0.0f; - List batteries = new List(); + //List batteries = new List(); foreach (MapEntity e in item.linkedTo) { Item battery = e as Item; diff --git a/Subsurface/Items/Components/Wearable.cs b/Subsurface/Items/Components/Wearable.cs index 7c4a9a901..8f59f09f6 100644 --- a/Subsurface/Items/Components/Wearable.cs +++ b/Subsurface/Items/Components/Wearable.cs @@ -2,8 +2,6 @@ using System.IO; using System.Linq; using System.Xml.Linq; -using Microsoft.Xna.Framework; -using System.Diagnostics; namespace Subsurface.Items.Components { diff --git a/Subsurface/Items/Item.cs b/Subsurface/Items/Item.cs index b7285b9c5..a2b745a2e 100644 --- a/Subsurface/Items/Item.cs +++ b/Subsurface/Items/Item.cs @@ -437,7 +437,7 @@ namespace Subsurface body.ResetDynamics(); if (body.Position.Length() > 1000.0f) { - this.Remove(); + Remove(); return; } } @@ -955,7 +955,7 @@ namespace Subsurface { int index = components.IndexOf(ic); - new NetworkEvent(NetworkEventType.UpdateComponent, this.ID, isClient, index); + new NetworkEvent(NetworkEventType.UpdateComponent, ID, isClient, index); } public override void FillNetworkData(NetworkEventType type, NetOutgoingMessage message, object data) @@ -969,8 +969,6 @@ namespace Subsurface message.Write((int)data); components[(int)data].FillNetworkData(type, message); break; - default: - break; } } @@ -987,8 +985,6 @@ namespace Subsurface if (componentIndex < 0 || componentIndex > components.Count - 1) return; components[componentIndex].ReadNetworkData(type, message); break; - default: - break; } } diff --git a/Subsurface/Map/Entity.cs b/Subsurface/Map/Entity.cs index 9d8db2af0..6c197ba54 100644 --- a/Subsurface/Map/Entity.cs +++ b/Subsurface/Map/Entity.cs @@ -79,7 +79,7 @@ namespace Subsurface public virtual void Remove() { - dictionary.Remove(this.ID); + dictionary.Remove(ID); } } } diff --git a/Subsurface/Map/Explosion.cs b/Subsurface/Map/Explosion.cs index 268ca4911..bca9d1f92 100644 --- a/Subsurface/Map/Explosion.cs +++ b/Subsurface/Map/Explosion.cs @@ -2,8 +2,6 @@ using Microsoft.Xna.Framework; using System; using System.Collections.Generic; -using System.Linq; -using System.Text; using System.Xml.Linq; namespace Subsurface diff --git a/Subsurface/Map/Gap.cs b/Subsurface/Map/Gap.cs index 7ce9f5e6d..7c69c4f6d 100644 --- a/Subsurface/Map/Gap.cs +++ b/Subsurface/Map/Gap.cs @@ -195,7 +195,7 @@ namespace Subsurface GUI.DrawRectangle(sb, new Rectangle(rect.X, -rect.Y, rect.Width, rect.Height), clr); - if (isSelected && editing) + if (isSelected) { GUI.DrawRectangle(sb, new Vector2(rect.X - 5, -rect.Y - 5), diff --git a/Subsurface/Map/Hull.cs b/Subsurface/Map/Hull.cs index 8bd72fe13..5cc7c7af6 100644 --- a/Subsurface/Map/Hull.cs +++ b/Subsurface/Map/Hull.cs @@ -121,7 +121,7 @@ namespace Subsurface OxygenPercentage = (float)(Game1.random.NextDouble() * 100.0); - properties = TypeDescriptor.GetProperties(this.GetType()) + properties = TypeDescriptor.GetProperties(GetType()) .Cast() .ToDictionary(pr => pr.Name); @@ -193,7 +193,7 @@ namespace Subsurface { if (PlayerInput.LeftButtonDown()) { - waveY[(int)(position.X - rect.X) / Hull.WaveWidth] = 100.0f; + waveY[(int)(position.X - rect.X) / WaveWidth] = 100.0f; Volume = Volume + 1500.0f; } else if (PlayerInput.GetMouseState.RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) @@ -290,8 +290,8 @@ namespace Subsurface spriteBatch.DrawString(GUI.font, "Pressure: " + ((int)pressure - rect.Y).ToString() + " - Lethality: " + lethalPressure + - " - Oxygen: "+((int)OxygenPercentage).ToString(), new Vector2(rect.X+10, -rect.Y+10), Color.Black); - spriteBatch.DrawString(GUI.font, volume.ToString() +" / "+ FullVolume.ToString(), new Vector2(rect.X+10, -rect.Y+30), Color.Black); + " - Oxygen: "+((int)OxygenPercentage), new Vector2(rect.X+10, -rect.Y+10), Color.Black); + spriteBatch.DrawString(GUI.font, volume +" / "+ FullVolume, new Vector2(rect.X+10, -rect.Y+30), Color.Black); if (isSelected && editing) { diff --git a/Subsurface/Map/Lights/ConvexHull.cs b/Subsurface/Map/Lights/ConvexHull.cs index 026060d29..7c9409dd4 100644 --- a/Subsurface/Map/Lights/ConvexHull.cs +++ b/Subsurface/Map/Lights/ConvexHull.cs @@ -1,9 +1,7 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; using System.Collections.Generic; using System.Linq; -using System.Text; namespace Subsurface.Lights { diff --git a/Subsurface/Map/Lights/LightManager.cs b/Subsurface/Map/Lights/LightManager.cs index f8f7f306f..2cbd5b909 100644 --- a/Subsurface/Map/Lights/LightManager.cs +++ b/Subsurface/Map/Lights/LightManager.cs @@ -1,9 +1,5 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; namespace Subsurface.Lights { diff --git a/Subsurface/Map/Map.cs b/Subsurface/Map/Map.cs index ccd5a536b..b167034e8 100644 --- a/Subsurface/Map/Map.cs +++ b/Subsurface/Map/Map.cs @@ -251,7 +251,7 @@ namespace Subsurface public static bool InsideWall(Vector2 point) { - Body foundBody = Map.PickBody(point); + Body foundBody = PickBody(point); if (foundBody==null) return false; Structure wall = foundBody.UserData as Structure; @@ -286,7 +286,7 @@ namespace Subsurface try { - string docString = doc.ToString(); + //string docString = doc.ToString(); ToolBox.CompressStringToFile(filePath+".gz", doc.ToString()); } catch @@ -342,7 +342,7 @@ namespace Subsurface public Map(string filePath, string mapHash="") { this.filePath = filePath; - this.name = Path.GetFileNameWithoutExtension(filePath); + name = Path.GetFileNameWithoutExtension(filePath); if (mapHash != "") { diff --git a/Subsurface/Map/MapEntity.cs b/Subsurface/Map/MapEntity.cs index f05179937..34cfdbf1a 100644 --- a/Subsurface/Map/MapEntity.cs +++ b/Subsurface/Map/MapEntity.cs @@ -393,7 +393,7 @@ namespace Subsurface public virtual XElement Save(XDocument doc) { - DebugConsole.ThrowError("Saving entity " + this.GetType() + " failed."); + DebugConsole.ThrowError("Saving entity " + GetType() + " failed."); return null; } diff --git a/Subsurface/Map/MapEntityPrefab.cs b/Subsurface/Map/MapEntityPrefab.cs index 5112cca2c..e3cf2210f 100644 --- a/Subsurface/Map/MapEntityPrefab.cs +++ b/Subsurface/Map/MapEntityPrefab.cs @@ -75,7 +75,7 @@ namespace Subsurface { Vector2 placeSize = Map.gridSize; - if (placePosition == null || placePosition == Vector2.Zero) + if (placePosition == Vector2.Zero) { if (PlayerInput.GetMouseState.LeftButton == ButtonState.Pressed) placePosition = Map.MouseToWorldGrid(cam); diff --git a/Subsurface/Map/WaterRenderer.cs b/Subsurface/Map/WaterRenderer.cs index c094f9aab..93a68c249 100644 --- a/Subsurface/Map/WaterRenderer.cs +++ b/Subsurface/Map/WaterRenderer.cs @@ -32,7 +32,7 @@ namespace Subsurface public void TransformTexCoord(Matrix transform) { - this.texCoord = Vector2.Transform(this.texCoord, transform); + texCoord = Vector2.Transform(texCoord, transform); } } diff --git a/Subsurface/Map/WayPoint.cs b/Subsurface/Map/WayPoint.cs index 76078fe76..cb8b17421 100644 --- a/Subsurface/Map/WayPoint.cs +++ b/Subsurface/Map/WayPoint.cs @@ -89,7 +89,7 @@ namespace Subsurface wayPoints.Add(wayPoint); } - if (wayPoints.Count() == 0) return null; + if (!wayPoints.Any()) return null; return wayPoints[Game1.random.Next(wayPoints.Count())]; } diff --git a/Subsurface/Networking/GameClient.cs b/Subsurface/Networking/GameClient.cs index 4d7af6dca..5c52a6b20 100644 --- a/Subsurface/Networking/GameClient.cs +++ b/Subsurface/Networking/GameClient.cs @@ -40,11 +40,11 @@ namespace Subsurface.Networking } } - public GameClient(string name) + public GameClient(string newName) { - this.name = name; + name = newName; - this.characterInfo = new CharacterInfo("Content/Characters/Human/human.xml", name); + characterInfo = new CharacterInfo("Content/Characters/Human/human.xml", name); } public bool ConnectToServer(string hostIP) diff --git a/Subsurface/Networking/NetworkEvent.cs b/Subsurface/Networking/NetworkEvent.cs index 4ff49954e..5544e590a 100644 --- a/Subsurface/Networking/NetworkEvent.cs +++ b/Subsurface/Networking/NetworkEvent.cs @@ -60,7 +60,7 @@ namespace Subsurface.Networking if (Game1.server == null) return; } - this.eventType = type; + eventType = type; foreach (NetworkEvent e in events) { @@ -68,7 +68,7 @@ namespace Subsurface.Networking } this.id = id; - this.isClientEvent = isClient; + isClientEvent = isClient; this.data = data; diff --git a/Subsurface/Physics/PhysicsBody.cs b/Subsurface/Physics/PhysicsBody.cs index 1955c4f63..02513d8dd 100644 --- a/Subsurface/Physics/PhysicsBody.cs +++ b/Subsurface/Physics/PhysicsBody.cs @@ -1,5 +1,4 @@ -using System; -using System.Xml.Linq; +using System.Xml.Linq; using FarseerPhysics; using FarseerPhysics.Dynamics; using FarseerPhysics.Factories; diff --git a/Subsurface/Properties.cs b/Subsurface/Properties.cs index 670a2d7bc..caa2ea365 100644 --- a/Subsurface/Properties.cs +++ b/Subsurface/Properties.cs @@ -3,7 +3,6 @@ using System.Collections.Generic; using System.ComponentModel; using System.Globalization; using System.Linq; -using System.Text; using System.Xml.Linq; namespace Subsurface @@ -93,7 +92,7 @@ namespace Subsurface } else { - DebugConsole.ThrowError("Failed to set the value of the property ''" + Name + "'' of ''" + obj.ToString() + "'' to " + value.ToString()); + DebugConsole.ThrowError("Failed to set the value of the property ''" + Name + "'' of ''" + obj + "'' to " + value); DebugConsole.ThrowError("(Type not implemented)"); return false; @@ -146,7 +145,7 @@ namespace Subsurface foreach (var property in obj.ObjectProperties.Values) { - if (property.Attributes.OfType().Count() > 0) editableProperties.Add(property); + if (property.Attributes.OfType().Any()) editableProperties.Add(property); } return editableProperties; @@ -200,7 +199,7 @@ namespace Subsurface public static void SaveProperties(IPropertyObject obj, XElement element) { - var saveProperties = ObjectProperty.GetProperties(obj); + var saveProperties = GetProperties(obj); foreach (var property in saveProperties) { object value = property.GetValue(); @@ -220,7 +219,7 @@ namespace Subsurface if (dontSave) continue; string stringValue; - if (value.GetType() == typeof(float)) + if (value is float) { //do this to make sure the decimal point isn't converted to a comma or anything like that stringValue = ((float)value).ToString("G", CultureInfo.InvariantCulture); diff --git a/Subsurface/Screens/EditCharacterScreen.cs b/Subsurface/Screens/EditCharacterScreen.cs index da80d76e2..efe93490c 100644 --- a/Subsurface/Screens/EditCharacterScreen.cs +++ b/Subsurface/Screens/EditCharacterScreen.cs @@ -34,13 +34,7 @@ namespace Subsurface { get { return cam; } } - - public EditCharacterScreen() - { - - - } - + public override void Select() { base.Select(); diff --git a/Subsurface/Screens/GameScreen.cs b/Subsurface/Screens/GameScreen.cs index 173c82643..0444d78f5 100644 --- a/Subsurface/Screens/GameScreen.cs +++ b/Subsurface/Screens/GameScreen.cs @@ -3,7 +3,6 @@ using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using Subsurface.Lights; -using FarseerPhysics; namespace Subsurface { diff --git a/Subsurface/Screens/MainMenu.cs b/Subsurface/Screens/MainMenu.cs index 54a58cb1a..7037e87ef 100644 --- a/Subsurface/Screens/MainMenu.cs +++ b/Subsurface/Screens/MainMenu.cs @@ -1,5 +1,4 @@ using System; -using System.IO; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Subsurface.Networking; diff --git a/Subsurface/Screens/NetLobbyScreen.cs b/Subsurface/Screens/NetLobbyScreen.cs index bdd1a4727..4c68283c5 100644 --- a/Subsurface/Screens/NetLobbyScreen.cs +++ b/Subsurface/Screens/NetLobbyScreen.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.IO; using Lidgren.Network; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; @@ -128,8 +126,8 @@ namespace Subsurface textBox.Select(); - int oldMapIndex = 0; - if (mapList != null && mapList.SelectedData != null) oldMapIndex = mapList.SelectedIndex; + //int oldMapIndex = 0; + //if (mapList != null && mapList.SelectedData != null) oldMapIndex = mapList.SelectedIndex; new GUITextBlock(new Rectangle(0, 30, 0, 30), "Selected map:", Color.Transparent, Color.Black, Alignment.Left, infoFrame); mapList = new GUIListBox(new Rectangle(0, 60, 200, 200), Color.White, infoFrame); diff --git a/Subsurface/Sounds/AmbientSoundManager.cs b/Subsurface/Sounds/AmbientSoundManager.cs index 272686287..4ef624a7b 100644 --- a/Subsurface/Sounds/AmbientSoundManager.cs +++ b/Subsurface/Sounds/AmbientSoundManager.cs @@ -35,8 +35,6 @@ namespace Subsurface static class AmbientSoundManager { - private static Sound[] music = new Sound[4]; - public static Sound[] flowSounds = new Sound[3]; private static Sound waterAmbience; @@ -57,9 +55,9 @@ namespace Subsurface XDocument doc = ToolBox.TryLoadXml(filePath); if (doc == null) return; - var xDamageSounds = doc.Root.Elements("damagesound"); - - if (xDamageSounds.Count()>0) + var xDamageSounds = doc.Root.Elements("damagesound").ToList(); + + if (!xDamageSounds.Any()) { damageSounds = new DamageSound[xDamageSounds.Count()]; int i = 0; @@ -124,7 +122,7 @@ namespace Subsurface { damage = MathHelper.Clamp(damage, 0.0f, 100.0f); var sounds = damageSounds.Where(x => damage >= x.damageRange.X && damage <= x.damageRange.Y && x.damageType == damageType).ToList(); - if (sounds.Count() == 0) return; + if (!sounds.Any()) return; int selectedSound = Game1.localRandom.Next(sounds.Count()); diff --git a/Subsurface/Sounds/Sound.cs b/Subsurface/Sounds/Sound.cs index 82706c7aa..a0e0a6ca5 100644 --- a/Subsurface/Sounds/Sound.cs +++ b/Subsurface/Sounds/Sound.cs @@ -204,14 +204,14 @@ namespace Subsurface { loadedSounds.Remove(this); - System.Diagnostics.Debug.WriteLine(this.AlBufferId); + System.Diagnostics.Debug.WriteLine(AlBufferId); foreach (Sound s in loadedSounds) { if (s.oggSound == oggSound) return; } - SoundManager.ClearAlSource(this.AlBufferId); + SoundManager.ClearAlSource(AlBufferId); oggSound.Dispose(); } diff --git a/Subsurface/Sprite.cs b/Subsurface/Sprite.cs index 4ef6bdf49..85c4d754b 100644 --- a/Subsurface/Sprite.cs +++ b/Subsurface/Sprite.cs @@ -126,9 +126,9 @@ namespace Subsurface { this.texture = texture; - sourceRect = (sourceRectangle == null) ? new Rectangle(1, 1, texture.Width, texture.Height) : (Rectangle)sourceRectangle; + sourceRect = sourceRectangle ?? new Rectangle(1, 1, texture.Width, texture.Height); - offset = (newOffset == null) ? Vector2.Zero : (Vector2)newOffset; + offset = newOffset ?? Vector2.Zero; size = new Vector2(sourceRect.Width, sourceRect.Height); @@ -145,10 +145,10 @@ namespace Subsurface { file = newFile; texture = LoadTexture(file); + + sourceRect = sourceRectangle ?? new Rectangle(1, 1, texture.Width, texture.Height); - sourceRect = (sourceRectangle == null) ? new Rectangle(1,1,texture.Width,texture.Height) : (Rectangle)sourceRectangle; - - offset = (newOffset == null) ? Vector2.Zero : (Vector2)newOffset; + offset = newOffset ?? Vector2.Zero; size = new Vector2(sourceRect.Width, sourceRect.Height); diff --git a/Subsurface/ToolBox.cs b/Subsurface/ToolBox.cs index d92e39ab7..245368bd8 100644 --- a/Subsurface/ToolBox.cs +++ b/Subsurface/ToolBox.cs @@ -444,7 +444,7 @@ namespace Subsurface string randomLine = ""; StreamReader file = new StreamReader(filePath); - var lines = File.ReadLines(filePath); + var lines = File.ReadLines(filePath).ToList(); int lineCount = lines.Count(); if (lineCount == 0)