Moar progress, fixed shadow/los/submarine misalignment issues
This commit is contained in:
@@ -318,7 +318,7 @@ namespace Barotrauma.Items.Components
|
||||
}
|
||||
|
||||
Vector2 pos = new Vector2(item.Rect.Center.X, item.Rect.Y);
|
||||
if (item.Submarine != null) pos += item.Submarine.Position;
|
||||
if (item.Submarine != null) pos += item.Submarine.DrawPosition;
|
||||
pos.Y = -pos.Y;
|
||||
|
||||
spriteBatch.Draw(doorSprite.Texture, pos,
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace Barotrauma.Items.Components
|
||||
[HasDefaultValue(0.0f, false)]
|
||||
public float Range
|
||||
{
|
||||
get { return ConvertUnits.ToDisplayUnits(range); }
|
||||
set { range = ConvertUnits.ToSimUnits(value); }
|
||||
get { return range; }
|
||||
set { range = value; }
|
||||
}
|
||||
|
||||
[HasDefaultValue(0.0f, false)]
|
||||
@@ -61,8 +61,8 @@ namespace Barotrauma.Items.Components
|
||||
[HasDefaultValue("0.0,0.0", false)]
|
||||
public string BarrelPos
|
||||
{
|
||||
get { return ToolBox.Vector2ToString(ConvertUnits.ToDisplayUnits(barrelPos)); }
|
||||
set { barrelPos = ConvertUnits.ToSimUnits(ToolBox.ParseToVector2(value)); }
|
||||
get { return ToolBox.Vector2ToString(barrelPos); }
|
||||
set { barrelPos = ToolBox.ParseToVector2(value); }
|
||||
}
|
||||
|
||||
public Vector2 TransformedBarrelPos
|
||||
@@ -72,7 +72,7 @@ namespace Barotrauma.Items.Components
|
||||
Matrix bodyTransform = Matrix.CreateRotationZ(item.body.Rotation);
|
||||
Vector2 flippedPos = barrelPos;
|
||||
if (item.body.Dir < 0.0f) flippedPos.X = -flippedPos.X;
|
||||
return (Vector2.Transform(flippedPos, bodyTransform) + item.body.SimPosition);
|
||||
return (Vector2.Transform(flippedPos, bodyTransform));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -115,7 +115,6 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
IsActive = true;
|
||||
|
||||
Vector2 targetPosition = item.body.SimPosition;
|
||||
//targetPosition = targetPosition.X, -targetPosition.Y);
|
||||
|
||||
float degreeOfSuccess = DegreeOfSuccess(character)/100.0f;
|
||||
@@ -126,6 +125,7 @@ namespace Barotrauma.Items.Components
|
||||
return false;
|
||||
}
|
||||
|
||||
Vector2 targetPosition = item.WorldPosition;
|
||||
targetPosition += new Vector2(
|
||||
(float)Math.Cos(item.body.Rotation),
|
||||
(float)Math.Sin(item.body.Rotation)) * range * item.body.Dir;
|
||||
@@ -137,14 +137,18 @@ namespace Barotrauma.Items.Components
|
||||
ignoredBodies.Add(limb.body.FarseerBody);
|
||||
}
|
||||
|
||||
Vector2 rayStart = item.WorldPosition + TransformedBarrelPos;
|
||||
Vector2 rayEnd = targetPosition;
|
||||
|
||||
Body targetBody = Submarine.PickBody(
|
||||
ConvertUnits.ToSimUnits(rayStart - Submarine.Loaded.Position),
|
||||
ConvertUnits.ToSimUnits(rayEnd - Submarine.Loaded.Position), ignoredBodies);
|
||||
|
||||
Body targetBody = Submarine.PickBody(TransformedBarrelPos, targetPosition, ignoredBodies);
|
||||
pickedPosition = Submarine.LastPickedPosition;
|
||||
|
||||
if (ExtinquishAmount > 0.0f)
|
||||
{
|
||||
Vector2 displayPos = ConvertUnits.ToDisplayUnits(TransformedBarrelPos + (targetPosition-TransformedBarrelPos)*Submarine.LastPickedFraction*0.9f);
|
||||
Vector2 displayPos = rayStart + (rayEnd-rayStart)*Submarine.LastPickedFraction*0.9f;
|
||||
Hull hull = Hull.FindHull(displayPos, item.CurrentHull);
|
||||
if (hull != null) hull.Extinquish(deltaTime, ExtinquishAmount, displayPos);
|
||||
}
|
||||
@@ -224,7 +228,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(particles))
|
||||
{
|
||||
GameMain.ParticleManager.CreateParticle(particles, ConvertUnits.ToDisplayUnits(TransformedBarrelPos),
|
||||
GameMain.ParticleManager.CreateParticle(particles, item.WorldPosition+TransformedBarrelPos,
|
||||
-item.body.Rotation + ((item.body.Dir>0.0f) ? 0.0f : MathHelper.Pi), ParticleSpeed);
|
||||
}
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
GameMain.ParticleManager.CreateParticle("bubbles", item.Position,
|
||||
GameMain.ParticleManager.CreateParticle("bubbles", item.WorldPosition,
|
||||
-currForce / 5.0f + new Vector2(Rand.Range(-100.0f, 100.0f), Rand.Range(-50f, 50f)),
|
||||
0.0f, item.CurrentHull);
|
||||
}
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private void GetHull()
|
||||
{
|
||||
hull1 = Hull.FindHull(item.Position, item.CurrentHull);
|
||||
hull1 = Hull.FindHull(item.WorldPosition, item.CurrentHull);
|
||||
}
|
||||
|
||||
public override void DrawHUD(SpriteBatch spriteBatch, Character character)
|
||||
|
||||
@@ -163,7 +163,7 @@ namespace Barotrauma.Items.Components
|
||||
Vector2 baseVel = Rand.Vector(300.0f);
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
var particle = GameMain.ParticleManager.CreateParticle("spark", item.Position,
|
||||
var particle = GameMain.ParticleManager.CreateParticle("spark", item.WorldPosition,
|
||||
baseVel + Rand.Vector(100.0f), 0.0f, item.CurrentHull);
|
||||
|
||||
if (particle != null) particle.Size *= Rand.Range(0.5f, 1.0f);
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
float prediction = 5.0f;
|
||||
|
||||
Vector2 futurePosition = Submarine.Loaded.Speed * prediction;
|
||||
Vector2 futurePosition = ConvertUnits.ToDisplayUnits(Submarine.Loaded.Velocity) * prediction;
|
||||
Vector2 targetSpeed = ((steeringPath.CurrentNode.Position - Submarine.Loaded.Position) - futurePosition);
|
||||
|
||||
targetSpeed = Vector2.Normalize(targetSpeed);
|
||||
|
||||
@@ -67,7 +67,7 @@ namespace Barotrauma.Items.Components
|
||||
Vector2 baseVel = Rand.Vector(300.0f);
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
var particle = GameMain.ParticleManager.CreateParticle("spark", pt.item.Position,
|
||||
var particle = GameMain.ParticleManager.CreateParticle("spark", pt.item.WorldPosition,
|
||||
baseVel + Rand.Vector(100.0f), 0.0f, item.CurrentHull);
|
||||
|
||||
if (particle != null) particle.Size *= Rand.Range(0.5f, 1.0f);
|
||||
|
||||
@@ -4,31 +4,17 @@ namespace Barotrauma.Items.Components
|
||||
{
|
||||
class OxygenDetector : ItemComponent
|
||||
{
|
||||
private Hull hull;
|
||||
|
||||
public OxygenDetector(Item item, XElement element)
|
||||
: base (item, element)
|
||||
{
|
||||
hull = Hull.FindHull(item.Position);
|
||||
|
||||
IsActive = true;
|
||||
}
|
||||
|
||||
public override void OnMapLoaded()
|
||||
{
|
||||
hull = Hull.FindHull(item.Position);
|
||||
}
|
||||
|
||||
public override void Move(Microsoft.Xna.Framework.Vector2 amount)
|
||||
{
|
||||
hull = Hull.FindHull(item.Position);
|
||||
}
|
||||
|
||||
public override void Update(float deltaTime, Camera cam)
|
||||
{
|
||||
if (hull == null) return;
|
||||
|
||||
item.SendSignal(((int)hull.OxygenPercentage).ToString(), "signal_out");
|
||||
if (item.CurrentHull == null) return;
|
||||
|
||||
item.SendSignal(((int)item.CurrentHull.OxygenPercentage).ToString(), "signal_out");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -41,11 +41,10 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void Move(Vector2 amount)
|
||||
{
|
||||
//amount = FarseerPhysics.ConvertUnits.ToDisplayUnits(amount);
|
||||
//for (int i = 0; i<Nodes.Count; i++)
|
||||
//{
|
||||
// Nodes[i] += amount;
|
||||
//}
|
||||
for (int i = 0; i < Nodes.Count; i++)
|
||||
{
|
||||
Nodes[i] += amount;
|
||||
}
|
||||
}
|
||||
|
||||
public Connection OtherConnection(Connection connection)
|
||||
@@ -348,9 +347,11 @@ namespace Barotrauma.Items.Components
|
||||
MapEntity.DisableSelect = true;
|
||||
Nodes[(int)selectedNodeIndex] = GameMain.EditMapScreen.Cam.ScreenToWorld(PlayerInput.MousePosition);
|
||||
|
||||
Vector2 pos = Nodes[(int)selectedNodeIndex];
|
||||
Vector2 nodeWorldPos = Nodes[(int)selectedNodeIndex];
|
||||
|
||||
Nodes[(int)selectedNodeIndex] = RoundNode(Nodes[(int)selectedNodeIndex], Hull.FindHull(Nodes[(int)selectedNodeIndex]));
|
||||
if (item.Submarine != null) nodeWorldPos += item.Submarine.Position;
|
||||
|
||||
Nodes[(int)selectedNodeIndex] = RoundNode(Nodes[(int)selectedNodeIndex], Hull.FindHull(nodeWorldPos));
|
||||
MapEntity.SelectEntity(item);
|
||||
}
|
||||
}
|
||||
@@ -362,6 +363,12 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
private void DrawSection(SpriteBatch spriteBatch, Vector2 start, Vector2 end, Color color)
|
||||
{
|
||||
if (item.Submarine!=null)
|
||||
{
|
||||
start += item.Submarine.DrawPosition;
|
||||
end += item.Submarine.DrawPosition;
|
||||
}
|
||||
|
||||
start.Y = -start.Y;
|
||||
end.Y = -end.Y;
|
||||
|
||||
|
||||
@@ -81,8 +81,12 @@ namespace Barotrauma.Items.Components
|
||||
|
||||
public override void Draw(SpriteBatch spriteBatch, bool editing)
|
||||
{
|
||||
Vector2 drawPos = new Vector2(item.Rect.X, item.Rect.Y);
|
||||
if (item.Submarine != null) drawPos += item.Submarine.DrawPosition;
|
||||
drawPos.Y = -drawPos.Y;
|
||||
|
||||
barrelSprite.Draw(spriteBatch,
|
||||
new Vector2(item.Rect.X, -item.Rect.Y) + barrelPos, Color.White,
|
||||
drawPos + barrelPos, Color.White,
|
||||
rotation + MathHelper.PiOver2, 1.0f,
|
||||
SpriteEffects.None, item.Sprite.Depth+0.01f);
|
||||
}
|
||||
|
||||
@@ -378,9 +378,8 @@ namespace Barotrauma
|
||||
|
||||
if (ItemList != null && body != null)
|
||||
{
|
||||
amount = ConvertUnits.ToSimUnits(amount);
|
||||
//Vector2 pos = new Vector2(rect.X + rect.Width / 2.0f, rect.Y - rect.Height / 2.0f);
|
||||
body.SetTransform(body.SimPosition+amount, body.Rotation);
|
||||
body.SetTransform(body.SimPosition+ConvertUnits.ToSimUnits(amount), body.Rotation);
|
||||
}
|
||||
foreach (ItemComponent ic in components)
|
||||
{
|
||||
@@ -409,7 +408,7 @@ namespace Barotrauma
|
||||
|
||||
public virtual Hull FindHull()
|
||||
{
|
||||
CurrentHull = Hull.FindHull((body == null) ? Position : ConvertUnits.ToDisplayUnits(body.SimPosition), CurrentHull);
|
||||
CurrentHull = Hull.FindHull(WorldPosition, CurrentHull);
|
||||
if (body!=null)
|
||||
{
|
||||
body.Submarine = CurrentHull == null ? null : Submarine.Loaded;
|
||||
|
||||
Reference in New Issue
Block a user