Stair body + linkedsub flipping
This commit is contained in:
@@ -70,7 +70,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public Direction StairDirection
|
public Direction StairDirection
|
||||||
{
|
{
|
||||||
get { return prefab.StairDirection; }
|
get;
|
||||||
|
private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string Name
|
public override string Name
|
||||||
@@ -177,6 +178,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
isHorizontal = (rect.Width>rect.Height);
|
isHorizontal = (rect.Width>rect.Height);
|
||||||
|
|
||||||
|
StairDirection = prefab.StairDirection;
|
||||||
|
|
||||||
if (prefab.HasBody)
|
if (prefab.HasBody)
|
||||||
{
|
{
|
||||||
bodies = new List<Body>();
|
bodies = new List<Body>();
|
||||||
@@ -208,6 +211,21 @@ namespace Barotrauma
|
|||||||
sections[0] = new WallSection(rect);
|
sections[0] = new WallSection(rect);
|
||||||
|
|
||||||
if (StairDirection != Direction.None)
|
if (StairDirection != Direction.None)
|
||||||
|
{
|
||||||
|
CreateStairBodies();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (prefab.CastShadow)
|
||||||
|
{
|
||||||
|
GenerateConvexHull();
|
||||||
|
}
|
||||||
|
|
||||||
|
InsertToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CreateStairBodies()
|
||||||
{
|
{
|
||||||
bodies = new List<Body>();
|
bodies = new List<Body>();
|
||||||
|
|
||||||
@@ -231,16 +249,6 @@ namespace Barotrauma
|
|||||||
newBody.UserData = this;
|
newBody.UserData = this;
|
||||||
bodies.Add(newBody);
|
bodies.Add(newBody);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (prefab.CastShadow)
|
|
||||||
{
|
|
||||||
GenerateConvexHull();
|
|
||||||
}
|
|
||||||
|
|
||||||
InsertToList();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CreateSections()
|
private void CreateSections()
|
||||||
{
|
{
|
||||||
@@ -736,6 +744,20 @@ namespace Barotrauma
|
|||||||
return newBody;
|
return newBody;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void FlipX()
|
||||||
|
{
|
||||||
|
base.FlipX();
|
||||||
|
|
||||||
|
if (StairDirection != Direction.None)
|
||||||
|
{
|
||||||
|
StairDirection = StairDirection == Direction.Left ? Direction.Right : Direction.Left;
|
||||||
|
bodies.ForEach(b => GameMain.World.RemoveBody(b));
|
||||||
|
|
||||||
|
CreateStairBodies();
|
||||||
|
}
|
||||||
|
|
||||||
|
//todo: flip sprites & wall sections
|
||||||
|
}
|
||||||
|
|
||||||
public override XElement Save(XElement parentElement)
|
public override XElement Save(XElement parentElement)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -285,8 +285,6 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public static void Draw(SpriteBatch spriteBatch, bool editing = false)
|
public static void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||||
{
|
{
|
||||||
if (PlayerInput.KeyHit(InputType.Crouch)) Submarine.MainSub.FlipX();
|
|
||||||
|
|
||||||
for (int i = 0; i < MapEntity.mapEntityList.Count; i++ )
|
for (int i = 0; i < MapEntity.mapEntityList.Count; i++ )
|
||||||
{
|
{
|
||||||
MapEntity.mapEntityList[i].Draw(spriteBatch, editing);
|
MapEntity.mapEntityList[i].Draw(spriteBatch, editing);
|
||||||
@@ -501,8 +499,6 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (e.MoveWithLevel || e.Submarine != this || e is Item) continue;
|
if (e.MoveWithLevel || e.Submarine != this || e is Item) continue;
|
||||||
|
|
||||||
e.FlipX();
|
|
||||||
|
|
||||||
if (e is LinkedSubmarine)
|
if (e is LinkedSubmarine)
|
||||||
{
|
{
|
||||||
Submarine sub = ((LinkedSubmarine)e).Sub;
|
Submarine sub = ((LinkedSubmarine)e).Sub;
|
||||||
@@ -514,6 +510,10 @@ namespace Barotrauma
|
|||||||
sub.FlipX(parents);
|
sub.FlipX(parents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
e.FlipX();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
|
||||||
@@ -562,8 +562,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public void Update(float deltaTime)
|
public void Update(float deltaTime)
|
||||||
{
|
{
|
||||||
|
if (PlayerInput.KeyHit(InputType.Crouch) && (this == MainSub)) FlipX();
|
||||||
if (PlayerInput.KeyHit(InputType.Crouch)) FlipX();
|
|
||||||
|
|
||||||
if (Level.Loaded == null) return;
|
if (Level.Loaded == null) return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user