BarotraumaServer compiles
Cleanup + fixes coming up next
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
using FarseerPhysics;
|
||||
using FarseerPhysics.Collision.Shapes;
|
||||
using FarseerPhysics.Common;
|
||||
using FarseerPhysics.Dynamics;
|
||||
using FarseerPhysics.Dynamics.Joints;
|
||||
using FarseerPhysics.Factories;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
|
||||
namespace Barotrauma.Items.Components
|
||||
{
|
||||
partial class Rope : ItemComponent, IDrawableComponent
|
||||
{
|
||||
public void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||
{
|
||||
if (!IsActive) return;
|
||||
|
||||
RevoluteJoint firstJoint = null;
|
||||
|
||||
for (int i = 0; i < ropeBodies.Length - 1; i++)
|
||||
{
|
||||
if (!ropeBodies[i].Enabled) continue;
|
||||
|
||||
if (firstJoint == null) firstJoint = ropeJoints[i];
|
||||
|
||||
DrawSection(spriteBatch, ropeJoints[i].WorldAnchorA, ropeJoints[i + 1].WorldAnchorA, i);
|
||||
}
|
||||
|
||||
if (gunJoint == null || firstJoint == null) return;
|
||||
|
||||
DrawSection(spriteBatch, gunJoint.WorldAnchorA, firstJoint.WorldAnchorA, 0);
|
||||
|
||||
}
|
||||
|
||||
private void DrawSection(SpriteBatch spriteBatch, Vector2 start, Vector2 end, int i)
|
||||
{
|
||||
start.Y = -start.Y;
|
||||
end.Y = -end.Y;
|
||||
|
||||
spriteBatch.Draw(sprite.Texture,
|
||||
ConvertUnits.ToDisplayUnits(start), null, Color.White,
|
||||
MathUtils.VectorToAngle(end - start),
|
||||
new Vector2(0.0f, sprite.size.Y / 2.0f),
|
||||
new Vector2((ConvertUnits.ToDisplayUnits(Vector2.Distance(start, end))) / sprite.Texture.Width, 1.0f),
|
||||
SpriteEffects.None,
|
||||
sprite.Depth + i * 0.00001f);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user