Some cleanup using ReSharper (mostly removing redundancies)
This commit is contained in:
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
using FarseerPhysics;
|
||||
using FarseerPhysics.Dynamics;
|
||||
using System.Xml.Linq;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Barotrauma.Particles;
|
||||
@@ -95,23 +91,8 @@ namespace Barotrauma.Items.Components
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||
{
|
||||
if (!IsActive) return;
|
||||
|
||||
//Vector2 particleSpeed = new Vector2(
|
||||
// (float)Math.Cos(item.body.Rotation),
|
||||
// (float)Math.Sin(item.body.Rotation)) *item.body.Dir * 0.1f;
|
||||
|
||||
|
||||
|
||||
|
||||
//Vector2 startPos = ConvertUnits.ToDisplayUnits(item.body.Position);
|
||||
//Vector2 endPos = ConvertUnits.ToDisplayUnits(pickedPosition);
|
||||
//endPos = new Vector2(endPos.X + Game1.localRandom.Next(-2, 2), endPos.Y + Game1.localRandom.Next(-2, 2));
|
||||
|
||||
//GUI.DrawLine(spriteBatch, startPos, endPos, Color.Orange, 0.0f);
|
||||
|
||||
IsActive = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace Barotrauma.Items.Components
|
||||
item.body.ApplyLinearImpulse(
|
||||
new Vector2((float)Math.Cos(projectile.body.Rotation), (float)Math.Sin(projectile.body.Rotation)) * item.body.Mass * -50.0f);
|
||||
|
||||
projectileComponent.ignoredBodies = limbBodies;
|
||||
projectileComponent.IgnoredBodies = limbBodies;
|
||||
|
||||
item.RemoveContained(projectile);
|
||||
|
||||
|
||||
@@ -10,13 +10,13 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
class RepairTool : ItemComponent
|
||||
{
|
||||
List<string> fixableEntities;
|
||||
private List<string> fixableEntities;
|
||||
|
||||
float range;
|
||||
private float range;
|
||||
|
||||
Vector2 pickedPosition;
|
||||
private Vector2 pickedPosition;
|
||||
|
||||
Vector2 barrelPos;
|
||||
private Vector2 barrelPos;
|
||||
|
||||
private string particles;
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using FarseerPhysics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
|
||||
@@ -301,7 +301,7 @@ namespace Barotrauma.Items.Components
|
||||
soundList.Add(itemSound);
|
||||
break;
|
||||
default:
|
||||
ItemComponent ic = ItemComponent.Load(subElement, item, item.ConfigFile, false);
|
||||
ItemComponent ic = Load(subElement, item, item.ConfigFile, false);
|
||||
if (ic == null) break;
|
||||
|
||||
ic.Parent = this;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -215,7 +215,7 @@ namespace Barotrauma.Items.Components
|
||||
character.AnimController.Anim = AnimController.Animation.None;
|
||||
}
|
||||
|
||||
public override bool Select(Character activator = null)
|
||||
public override bool Select(Character activator)
|
||||
{
|
||||
if (activator == null) return false;
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!container.Inventory.Items.Any(i => i != null)) return;
|
||||
if (container.Inventory.Items.All(i => i == null)) return;
|
||||
|
||||
activateButton.Text = "Cancel";
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
var bubbles = GameMain.ParticleManager.CreateParticle("bubbles", item.WorldPosition - (Vector2.UnitX * item.Rect.Width/2),
|
||||
GameMain.ParticleManager.CreateParticle("bubbles", item.WorldPosition - (Vector2.UnitX * item.Rect.Width/2),
|
||||
-currForce / 5.0f + new Vector2(Rand.Range(-100.0f, 100.0f), Rand.Range(-50f, 50f)),
|
||||
0.0f, item.CurrentHull);
|
||||
}
|
||||
|
||||
@@ -150,7 +150,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
text += "Required time: " + targetItem.RequiredTime + " s";
|
||||
|
||||
GUITextBlock textBlock = new GUITextBlock(
|
||||
new GUITextBlock(
|
||||
new Rectangle(0, 50, 0, 25),
|
||||
text,
|
||||
Color.Transparent, Color.White,
|
||||
|
||||
@@ -153,7 +153,6 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
||||
{
|
||||
int width = GuiFrame.Rect.Width, height = GuiFrame.Rect.Height;
|
||||
int x = GuiFrame.Rect.X;
|
||||
int y = GuiFrame.Rect.Y;
|
||||
|
||||
|
||||
@@ -94,19 +94,14 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
||||
{
|
||||
int x = GuiFrame.Rect.X;
|
||||
int y = GuiFrame.Rect.Y;
|
||||
|
||||
GuiFrame.Update(1.0f / 60.0f);
|
||||
GuiFrame.Draw(spriteBatch);
|
||||
|
||||
if (voltage < minVoltage) return;
|
||||
|
||||
|
||||
int radius = GuiFrame.Rect.Height / 2 - 30;
|
||||
DrawRadar(spriteBatch, new Rectangle((int)GuiFrame.Center.X - radius, (int)GuiFrame.Center.Y - radius, radius * 2, radius * 2));
|
||||
|
||||
//voltage = 0.0f;
|
||||
}
|
||||
|
||||
private List<RadarBlip> radarBlips;
|
||||
@@ -202,20 +197,15 @@ namespace Barotrauma.Items.Components
|
||||
float pointDist = (limb.WorldPosition - item.WorldPosition).Length() * displayScale;
|
||||
|
||||
if (limb.SimPosition == Vector2.Zero || pointDist > radius) continue;
|
||||
|
||||
|
||||
|
||||
if (pointDist > radius) continue;
|
||||
if (pointDist > prevPingRadius && pointDist < pingRadius)
|
||||
{
|
||||
float limbSize = limb.Mass;
|
||||
|
||||
for (int i = 0; i<=limb.Mass/100.0f; i++)
|
||||
{
|
||||
var blip = new RadarBlip(limb.WorldPosition+Rand.Vector(limb.Mass/10.0f), 1.0f);
|
||||
radarBlips.Add(blip);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -379,12 +379,12 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override bool Pick(Character picker)
|
||||
{
|
||||
return (picker != null);
|
||||
return picker != null;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
base.Draw(spriteBatch, editing);
|
||||
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(item.Rect.X + item.Rect.Width / 2 - 6, -item.Rect.Y + 29),
|
||||
|
||||
@@ -224,9 +224,9 @@ namespace Barotrauma.Items.Components
|
||||
//if (connection.IsPower) voltage = power;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||
{
|
||||
base.Draw(spriteBatch);
|
||||
base.Draw(spriteBatch, editing);
|
||||
|
||||
GUI.DrawRectangle(spriteBatch,
|
||||
new Vector2(item.DrawPosition.X- 4, -item.DrawPosition.Y),
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
@@ -85,7 +83,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power)
|
||||
public override void ReceiveSignal(string signal, Connection connection, Item sender, float power = 0)
|
||||
{
|
||||
if (currPowerConsumption == 0.0f) voltage = 0.0f;
|
||||
if (connection.IsPower) voltage = power;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Xml.Linq;
|
||||
using FarseerPhysics;
|
||||
using FarseerPhysics.Dynamics;
|
||||
@@ -18,9 +17,9 @@ namespace Barotrauma.Items.Components
|
||||
private PrismaticJoint stickJoint;
|
||||
private Body stickTarget;
|
||||
|
||||
Attack attack;
|
||||
private Attack attack;
|
||||
|
||||
public List<Body> ignoredBodies;
|
||||
public List<Body> IgnoredBodies;
|
||||
|
||||
public Character User;
|
||||
|
||||
@@ -48,7 +47,7 @@ namespace Barotrauma.Items.Components
|
||||
public Projectile(Item item, XElement element)
|
||||
: base (item, element)
|
||||
{
|
||||
ignoredBodies = new List<Body>();
|
||||
IgnoredBodies = new List<Body>();
|
||||
|
||||
//launchImpulse = ToolBox.GetAttributeFloat(element, "launchimpulse", 10.0f);
|
||||
//characterUsable = ToolBox.GetAttributeBool(element, "characterusable", false);
|
||||
@@ -65,24 +64,10 @@ namespace Barotrauma.Items.Components
|
||||
//doesStick = ToolBox.GetAttributeBool(element, "doesstick", false);
|
||||
}
|
||||
|
||||
//public override void ConstructionActivate(Construction c, Vector2 modifier)
|
||||
//{
|
||||
// for (int i = 0; i < item.linkedTo.Count; i++)
|
||||
// item.linkedTo[i].RemoveLinked((MapEntity)item);
|
||||
// item.linkedTo.Clear();
|
||||
|
||||
// ApplyStatusEffects(StatusEffect.Type.OnUse, 1.0f, null);
|
||||
|
||||
// Launch(modifier+Vector2.Normalize(modifier)*launchImpulse);
|
||||
|
||||
//}
|
||||
|
||||
public override bool Use(float deltaTime, Character character = null)
|
||||
{
|
||||
if (character != null && !characterUsable) return false;
|
||||
|
||||
//ApplyStatusEffects(ActionType.OnUse, 1.0f, Character);
|
||||
|
||||
Launch(new Vector2(
|
||||
(float)Math.Cos(item.body.Rotation),
|
||||
(float)Math.Sin(item.body.Rotation)) * launchImpulse * item.body.Mass);
|
||||
@@ -103,26 +88,25 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
item.Drop();
|
||||
|
||||
if (stickJoint != null && doesStick)
|
||||
{
|
||||
if (stickTarget != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
item.body.FarseerBody.RestoreCollisionWith(stickTarget);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Failed to restore collision with stickTarget", e);
|
||||
#endif
|
||||
}
|
||||
if (stickJoint == null || !doesStick) return;
|
||||
|
||||
stickTarget = null;
|
||||
if (stickTarget != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
item.body.FarseerBody.RestoreCollisionWith(stickTarget);
|
||||
}
|
||||
GameMain.World.RemoveJoint(stickJoint);
|
||||
stickJoint = null;
|
||||
catch (Exception e)
|
||||
{
|
||||
#if DEBUG
|
||||
DebugConsole.ThrowError("Failed to restore collision with stickTarget", e);
|
||||
#endif
|
||||
}
|
||||
|
||||
stickTarget = null;
|
||||
}
|
||||
GameMain.World.RemoveJoint(stickJoint);
|
||||
stickJoint = null;
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
@@ -160,7 +144,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private bool OnProjectileCollision(Fixture f1, Fixture f2, Contact contact)
|
||||
{
|
||||
if (ignoredBodies.Contains(f2.Body)) return false;
|
||||
if (IgnoredBodies.Contains(f2.Body)) return false;
|
||||
|
||||
AttackResult attackResult = new AttackResult(0.0f, 0.0f);
|
||||
if (attack != null)
|
||||
@@ -185,7 +169,7 @@ namespace Barotrauma.Items.Components
|
||||
item.body.CollisionCategories = Physics.CollisionMisc;
|
||||
item.body.CollidesWith = Physics.CollisionWall | Physics.CollisionLevel;
|
||||
|
||||
ignoredBodies.Clear();
|
||||
IgnoredBodies.Clear();
|
||||
|
||||
f2.Body.ApplyLinearImpulse(item.body.LinearVelocity * item.body.Mass);
|
||||
|
||||
@@ -220,9 +204,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
}
|
||||
|
||||
return (f2.CollisionCategories != Physics.CollisionCharacter);
|
||||
|
||||
//return false;
|
||||
return f2.CollisionCategories != Physics.CollisionCharacter;
|
||||
}
|
||||
|
||||
private bool StickToTarget(Body targetBody, Vector2 axis)
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
using FarseerPhysics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Barotrauma.Lights;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
@@ -135,16 +132,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
voltage = 0.0f;
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
{
|
||||
if (!editing) return;
|
||||
|
||||
//Vector2 center = new Vector2(item.Rect.Center.X, -item.Rect.Y + item.Rect.Height/2.0f);
|
||||
|
||||
//GUI.DrawLine(spriteBatch, center - Vector2.One * range, center + Vector2.One * range, lightColor);
|
||||
}
|
||||
|
||||
|
||||
protected override void RemoveComponentSpecific()
|
||||
{
|
||||
base.RemoveComponentSpecific();
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Xml.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Xml.Linq;
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ namespace Barotrauma.Items.Components
|
||||
ToolBox.GetAttributeVector2(element, "origin", Vector2.Zero));
|
||||
}
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||
{
|
||||
Vector2 drawPos = new Vector2(item.Rect.X, item.Rect.Y);
|
||||
if (item.Submarine != null) drawPos += item.Submarine.DrawPosition;
|
||||
@@ -270,7 +270,7 @@ namespace Barotrauma.Items.Components
|
||||
if (Math.Abs(MathUtils.GetShortestAngle(enemyAngle, turretAngle)) > 0.01f) return false;
|
||||
|
||||
var pickedBody = Submarine.PickBody(ConvertUnits.ToSimUnits(item.WorldPosition), closestEnemy.SimPosition, null);
|
||||
if (pickedBody != null && pickedBody.UserData as Limb == null) return false;
|
||||
if (pickedBody != null && !(pickedBody.UserData is Limb)) return false;
|
||||
|
||||
if (objective.Option.ToLower()=="fire at will") Use(deltaTime, character);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user