Flipping sprites of staircases & engine
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
pickthroughwalls="true"
|
pickthroughwalls="true"
|
||||||
pickdistance="150">
|
pickdistance="150">
|
||||||
|
|
||||||
<Sprite texture ="engine.png" depth="0.8" sourcerect="0,0,373,113"/>
|
<Sprite texture ="engine.png" depth="0.8" sourcerect="0,0,373,113" canflipx="true"/>
|
||||||
|
|
||||||
<fixrequirement name="Mechanical repairs">
|
<fixrequirement name="Mechanical repairs">
|
||||||
<skill name="Construction" level="40"/>
|
<skill name="Construction" level="40"/>
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
pickthroughwalls="true"
|
pickthroughwalls="true"
|
||||||
pickdistance="150">
|
pickdistance="150">
|
||||||
|
|
||||||
<Sprite texture ="engine.png" depth="0.8" sourcerect="0,115,224,73"/>
|
<Sprite texture ="engine.png" depth="0.8" sourcerect="0,115,224,73" canflipx="true"/>
|
||||||
|
|
||||||
<fixrequirement name="Mechanical repairs">
|
<fixrequirement name="Mechanical repairs">
|
||||||
<skill name="Construction" level="30"/>
|
<skill name="Construction" level="30"/>
|
||||||
|
|||||||
@@ -49,19 +49,19 @@
|
|||||||
</medicalLabel>
|
</medicalLabel>
|
||||||
|
|
||||||
<arrowUp width="16" height="16">
|
<arrowUp width="16" height="16">
|
||||||
<sprite texture="Content/Map/structures2.png" sourcerect="129,460,16,16" depth ="0.99"/>
|
<sprite texture="Content/Map/structures2.png" sourcerect="129,460,16,16" depth ="0.99" canflipx="true"/>
|
||||||
</arrowUp>
|
</arrowUp>
|
||||||
|
|
||||||
<arrowDown width="16" height="16">
|
<arrowDown width="16" height="16">
|
||||||
<sprite texture="Content/Map/structures2.png" sourcerect="146,460,16,16" depth ="0.99"/>
|
<sprite texture="Content/Map/structures2.png" sourcerect="146,460,16,16" depth ="0.99" canflipx="true"/>
|
||||||
</arrowDown>
|
</arrowDown>
|
||||||
|
|
||||||
<arrowLeft width="16" height="16">
|
<arrowLeft width="16" height="16">
|
||||||
<sprite texture="Content/Map/structures2.png" sourcerect="129,477,16,16" depth ="0.99"/>
|
<sprite texture="Content/Map/structures2.png" sourcerect="129,477,16,16" depth ="0.99" canflipx="true"/>
|
||||||
</arrowLeft>
|
</arrowLeft>
|
||||||
|
|
||||||
<arrowRight width="16" height="16">
|
<arrowRight width="16" height="16">
|
||||||
<sprite texture="Content/Map/structures2.png" sourcerect="146,477,16,16" depth ="0.99"/>
|
<sprite texture="Content/Map/structures2.png" sourcerect="146,477,16,16" depth ="0.99" canflipx="true"/>
|
||||||
</arrowRight>
|
</arrowRight>
|
||||||
|
|
||||||
<leftwall description="A vertical wall with collision detection"
|
<leftwall description="A vertical wall with collision detection"
|
||||||
@@ -170,19 +170,19 @@
|
|||||||
</PipesBackground>
|
</PipesBackground>
|
||||||
|
|
||||||
<SlopeForward width="16" height="16" resizehorizontal="true" resizevertical="true">
|
<SlopeForward width="16" height="16" resizehorizontal="true" resizevertical="true">
|
||||||
<sprite texture="Content/Map/structures2.png" sourcerect="0,0,224,64" depth = "0.95" />
|
<sprite texture="Content/Map/structures2.png" sourcerect="0,0,224,64" depth = "0.95" canflipx="true"/>
|
||||||
</SlopeForward>
|
</SlopeForward>
|
||||||
|
|
||||||
<SlopeBack width="16" height="16" resizehorizontal="true" resizevertical="true">
|
<SlopeBack width="16" height="16" resizehorizontal="true" resizevertical="true">
|
||||||
<sprite texture="Content/Map/structures2.png" sourcerect="0,64,224,64" depth = "0.95" />
|
<sprite texture="Content/Map/structures2.png" sourcerect="0,64,224,64" depth = "0.95" canflipx="true"/>
|
||||||
</SlopeBack>
|
</SlopeBack>
|
||||||
|
|
||||||
<stairsright width="256" height="320" stairdirection="Right">
|
<stairsright width="256" height="320" stairdirection="Right">
|
||||||
<sprite texture="Content/Map/structures2.png" sourcerect="256,193,256,319" depth = "0.1" />
|
<sprite texture="Content/Map/structures2.png" sourcerect="256,193,256,319" depth = "0.1" canflipx="true"/>
|
||||||
</stairsright>
|
</stairsright>
|
||||||
|
|
||||||
<stairsleft width="256" height="320" stairdirection="Left">
|
<stairsleft width="256" height="320" stairdirection="Left">
|
||||||
<sprite texture="Content/Map/structures2.png" sourcerect="256,193,256,319" fliphorizontal="true" depth = "0.1" />
|
<sprite texture="Content/Map/structures2.png" sourcerect="256,193,256,319" fliphorizontal="true" depth = "0.1" canflipx="true"/>
|
||||||
</stairsleft>
|
</stairsleft>
|
||||||
|
|
||||||
<bunk width="173" height="129">
|
<bunk width="173" height="129">
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace Barotrauma
|
|||||||
TeamASub = Submarine.MainSubs[0];
|
TeamASub = Submarine.MainSubs[0];
|
||||||
TeamBSub = Submarine.MainSubs[1];
|
TeamBSub = Submarine.MainSubs[1];
|
||||||
TeamBSub.SetPosition(Level.Loaded.EndPosition - new Vector2(0.0f, 2000.0f));
|
TeamBSub.SetPosition(Level.Loaded.EndPosition - new Vector2(0.0f, 2000.0f));
|
||||||
//TeamASub.FlipX();
|
TeamBSub.FlipX();
|
||||||
|
|
||||||
foreach (Submarine submarine in Submarine.Loaded)
|
foreach (Submarine submarine in Submarine.Loaded)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -40,6 +40,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public Hull CurrentHull;
|
public Hull CurrentHull;
|
||||||
|
|
||||||
|
public SpriteEffects SpriteEffects = SpriteEffects.None;
|
||||||
|
|
||||||
//components that determine the functionality of the item
|
//components that determine the functionality of the item
|
||||||
public List<ItemComponent> components;
|
public List<ItemComponent> components;
|
||||||
public List<IDrawableComponent> drawableComponents;
|
public List<IDrawableComponent> drawableComponents;
|
||||||
@@ -798,16 +800,21 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void FlipX()
|
public override void FlipX()
|
||||||
{
|
{
|
||||||
base.FlipX();
|
base.FlipX();
|
||||||
|
|
||||||
foreach (ItemComponent component in components)
|
if (prefab.CanSpriteFlipX)
|
||||||
{
|
{
|
||||||
component.FlipX();
|
SpriteEffects ^= SpriteEffects.FlipHorizontally;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (ItemComponent component in components)
|
||||||
|
{
|
||||||
|
component.FlipX();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
|
||||||
@@ -815,6 +822,9 @@ namespace Barotrauma
|
|||||||
Color color = (isSelected && editing) ? color = Color.Red : spriteColor;
|
Color color = (isSelected && editing) ? color = Color.Red : spriteColor;
|
||||||
if (isHighlighted) color = Color.Orange;
|
if (isHighlighted) color = Color.Orange;
|
||||||
|
|
||||||
|
SpriteEffects oldEffects = prefab.sprite.effects;
|
||||||
|
prefab.sprite.effects ^= SpriteEffects;
|
||||||
|
|
||||||
if (prefab.sprite != null)
|
if (prefab.sprite != null)
|
||||||
{
|
{
|
||||||
float depth = Sprite.Depth;
|
float depth = Sprite.Depth;
|
||||||
@@ -822,7 +832,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
if (body == null)
|
if (body == null)
|
||||||
{
|
{
|
||||||
if (prefab.ResizeHorizontal || prefab.ResizeVertical)
|
if (prefab.ResizeHorizontal || prefab.ResizeVertical || SpriteEffects.HasFlag(SpriteEffects.FlipHorizontally) || SpriteEffects.HasFlag(SpriteEffects.FlipVertically))
|
||||||
{
|
{
|
||||||
prefab.sprite.DrawTiled(spriteBatch, new Vector2(DrawPosition.X-rect.Width/2, -(DrawPosition.Y+rect.Height/2)), new Vector2(rect.Width, rect.Height), color);
|
prefab.sprite.DrawTiled(spriteBatch, new Vector2(DrawPosition.X-rect.Width/2, -(DrawPosition.Y+rect.Height/2)), new Vector2(rect.Width, rect.Height), color);
|
||||||
}
|
}
|
||||||
@@ -855,6 +865,8 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prefab.sprite.effects = oldEffects;
|
||||||
|
|
||||||
for (int i = 0; i < drawableComponents.Count; i++ )
|
for (int i = 0; i < drawableComponents.Count; i++ )
|
||||||
{
|
{
|
||||||
drawableComponents[i].Draw(spriteBatch, editing);
|
drawableComponents[i].Draw(spriteBatch, editing);
|
||||||
@@ -1733,32 +1745,32 @@ namespace Barotrauma
|
|||||||
Condition = (float)message.ReadByte()/2.55f;
|
Condition = (float)message.ReadByte()/2.55f;
|
||||||
|
|
||||||
Client sender = null;
|
Client sender = null;
|
||||||
if (GameMain.Server != null)
|
if (GameMain.Server != null)
|
||||||
{
|
{
|
||||||
sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
|
sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
|
||||||
if (sender == null || sender.Character == null || !sender.Character.CanAccessItem(this))
|
if (sender == null || sender.Character == null || !sender.Character.CanAccessItem(this))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (type)
|
switch (type)
|
||||||
{
|
{
|
||||||
case NetworkEventType.DropItem:
|
case NetworkEventType.DropItem:
|
||||||
if (GameMain.Server != null)
|
if (GameMain.Server != null)
|
||||||
{
|
{
|
||||||
Drop(sender.Character, false);
|
Drop(sender.Character, false);
|
||||||
if (body != null)
|
if (body != null)
|
||||||
{
|
{
|
||||||
body.TargetPosition = sender.Character.SimPosition;
|
body.TargetPosition = sender.Character.SimPosition;
|
||||||
body.MoveToTargetPosition();
|
body.MoveToTargetPosition();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//client should not tell the server where the item should drop
|
//client should not tell the server where the item should drop
|
||||||
Drop(null, false);
|
Drop(null, false);
|
||||||
if (body != null)
|
if (body != null)
|
||||||
{
|
{
|
||||||
body.ReadNetworkData(message, sendingTime);
|
body.ReadNetworkData(message, sendingTime);
|
||||||
body.MoveToTargetPosition();
|
body.MoveToTargetPosition();
|
||||||
|
|||||||
@@ -58,6 +58,8 @@ namespace Barotrauma
|
|||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool canSpriteFlipX;
|
||||||
|
|
||||||
//if a matching itemprefab is not found when loading a sub, the game will attempt to find a prefab with a matching alias
|
//if a matching itemprefab is not found when loading a sub, the game will attempt to find a prefab with a matching alias
|
||||||
//(allows changing item names while keeping backwards compatibility with older sub files)
|
//(allows changing item names while keeping backwards compatibility with older sub files)
|
||||||
public string[] Aliases
|
public string[] Aliases
|
||||||
@@ -116,6 +118,11 @@ namespace Barotrauma
|
|||||||
private set;
|
private set;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CanSpriteFlipX
|
||||||
|
{
|
||||||
|
get { return canSpriteFlipX; }
|
||||||
|
}
|
||||||
|
|
||||||
public Vector2 Size
|
public Vector2 Size
|
||||||
{
|
{
|
||||||
get { return size; }
|
get { return size; }
|
||||||
@@ -281,6 +288,9 @@ namespace Barotrauma
|
|||||||
spriteFolder = Path.GetDirectoryName(filePath);
|
spriteFolder = Path.GetDirectoryName(filePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ToolBox.GetAttributeBool(subElement, "canflipx", false))
|
||||||
|
canSpriteFlipX = true;
|
||||||
|
|
||||||
sprite = new Sprite(subElement, spriteFolder);
|
sprite = new Sprite(subElement, spriteFolder);
|
||||||
size = sprite.size;
|
size = sprite.size;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -57,7 +57,9 @@ namespace Barotrauma
|
|||||||
bool isHorizontal;
|
bool isHorizontal;
|
||||||
|
|
||||||
public float lastUpdate;
|
public float lastUpdate;
|
||||||
|
|
||||||
|
public SpriteEffects SpriteEffects = SpriteEffects.None;
|
||||||
|
|
||||||
public override Sprite Sprite
|
public override Sprite Sprite
|
||||||
{
|
{
|
||||||
get { return prefab.sprite; }
|
get { return prefab.sprite; }
|
||||||
@@ -438,7 +440,10 @@ namespace Barotrauma
|
|||||||
Vector2.Zero, color, Point.Zero);
|
Vector2.Zero, color, Point.Zero);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SpriteEffects oldEffects = prefab.sprite.effects;
|
||||||
|
prefab.sprite.effects ^= SpriteEffects;
|
||||||
|
|
||||||
if (back == prefab.sprite.Depth > 0.5f || editing)
|
if (back == prefab.sprite.Depth > 0.5f || editing)
|
||||||
{
|
{
|
||||||
foreach (WallSection s in sections)
|
foreach (WallSection s in sections)
|
||||||
@@ -462,6 +467,8 @@ namespace Barotrauma
|
|||||||
prefab.sprite.DrawTiled(spriteBatch, new Vector2(s.rect.X + drawOffset.X, -(s.rect.Y + drawOffset.Y)), new Vector2(s.rect.Width, s.rect.Height), Vector2.Zero, color, offset);
|
prefab.sprite.DrawTiled(spriteBatch, new Vector2(s.rect.X + drawOffset.X, -(s.rect.Y + drawOffset.Y)), new Vector2(s.rect.Width, s.rect.Height), Vector2.Zero, color, offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
prefab.sprite.effects = oldEffects;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool OnWallCollision(Fixture f1, Fixture f2, Contact contact)
|
private bool OnWallCollision(Fixture f1, Fixture f2, Contact contact)
|
||||||
@@ -747,6 +754,11 @@ namespace Barotrauma
|
|||||||
public override void FlipX()
|
public override void FlipX()
|
||||||
{
|
{
|
||||||
base.FlipX();
|
base.FlipX();
|
||||||
|
|
||||||
|
if (prefab.CanSpriteFlipX)
|
||||||
|
{
|
||||||
|
SpriteEffects ^= SpriteEffects.FlipHorizontally;
|
||||||
|
}
|
||||||
|
|
||||||
if (StairDirection != Direction.None)
|
if (StairDirection != Direction.None)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
private bool isPlatform;
|
private bool isPlatform;
|
||||||
private Direction stairDirection;
|
private Direction stairDirection;
|
||||||
|
private bool canSpriteFlipX;
|
||||||
|
|
||||||
private float maxHealth;
|
private float maxHealth;
|
||||||
|
|
||||||
@@ -48,6 +49,11 @@ namespace Barotrauma
|
|||||||
get { return stairDirection; }
|
get { return stairDirection; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool CanSpriteFlipX
|
||||||
|
{
|
||||||
|
get { return canSpriteFlipX; }
|
||||||
|
}
|
||||||
|
|
||||||
public Vector2 Size
|
public Vector2 Size
|
||||||
{
|
{
|
||||||
get { return size; }
|
get { return size; }
|
||||||
@@ -107,6 +113,8 @@ namespace Barotrauma
|
|||||||
sp.sprite.effects = SpriteEffects.FlipHorizontally;
|
sp.sprite.effects = SpriteEffects.FlipHorizontally;
|
||||||
if (ToolBox.GetAttributeBool(subElement, "flipvertical", false))
|
if (ToolBox.GetAttributeBool(subElement, "flipvertical", false))
|
||||||
sp.sprite.effects = SpriteEffects.FlipVertically;
|
sp.sprite.effects = SpriteEffects.FlipVertically;
|
||||||
|
if (ToolBox.GetAttributeBool(subElement, "canflipx", false))
|
||||||
|
sp.canSpriteFlipX = true;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case "backgroundsprite":
|
case "backgroundsprite":
|
||||||
|
|||||||
@@ -562,7 +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) && (this == MainSub)) FlipX();
|
||||||
|
|
||||||
if (Level.Loaded == null) return;
|
if (Level.Loaded == null) return;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user