Flipping sprites of staircases & engine
This commit is contained in:
@@ -40,6 +40,8 @@ namespace Barotrauma
|
||||
|
||||
public Hull CurrentHull;
|
||||
|
||||
public SpriteEffects SpriteEffects = SpriteEffects.None;
|
||||
|
||||
//components that determine the functionality of the item
|
||||
public List<ItemComponent> components;
|
||||
public List<IDrawableComponent> drawableComponents;
|
||||
@@ -798,16 +800,21 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override void FlipX()
|
||||
{
|
||||
base.FlipX();
|
||||
|
||||
foreach (ItemComponent component in components)
|
||||
}
|
||||
|
||||
public override void FlipX()
|
||||
{
|
||||
base.FlipX();
|
||||
|
||||
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)
|
||||
@@ -815,6 +822,9 @@ namespace Barotrauma
|
||||
Color color = (isSelected && editing) ? color = Color.Red : spriteColor;
|
||||
if (isHighlighted) color = Color.Orange;
|
||||
|
||||
SpriteEffects oldEffects = prefab.sprite.effects;
|
||||
prefab.sprite.effects ^= SpriteEffects;
|
||||
|
||||
if (prefab.sprite != null)
|
||||
{
|
||||
float depth = Sprite.Depth;
|
||||
@@ -822,7 +832,7 @@ namespace Barotrauma
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -855,6 +865,8 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
prefab.sprite.effects = oldEffects;
|
||||
|
||||
for (int i = 0; i < drawableComponents.Count; i++ )
|
||||
{
|
||||
drawableComponents[i].Draw(spriteBatch, editing);
|
||||
@@ -1733,32 +1745,32 @@ namespace Barotrauma
|
||||
Condition = (float)message.ReadByte()/2.55f;
|
||||
|
||||
Client sender = null;
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
|
||||
if (sender == null || sender.Character == null || !sender.Character.CanAccessItem(this))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
sender = GameMain.Server.ConnectedClients.Find(c => c.Connection == message.SenderConnection);
|
||||
if (sender == null || sender.Character == null || !sender.Character.CanAccessItem(this))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case NetworkEventType.DropItem:
|
||||
if (GameMain.Server != null)
|
||||
{
|
||||
Drop(sender.Character, false);
|
||||
if (body != null)
|
||||
{
|
||||
body.TargetPosition = sender.Character.SimPosition;
|
||||
body.MoveToTargetPosition();
|
||||
if (body != null)
|
||||
{
|
||||
body.TargetPosition = sender.Character.SimPosition;
|
||||
body.MoveToTargetPosition();
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
//client should not tell the server where the item should drop
|
||||
Drop(null, false);
|
||||
if (body != null)
|
||||
if (body != null)
|
||||
{
|
||||
body.ReadNetworkData(message, sendingTime);
|
||||
body.MoveToTargetPosition();
|
||||
|
||||
@@ -58,6 +58,8 @@ namespace Barotrauma
|
||||
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
|
||||
//(allows changing item names while keeping backwards compatibility with older sub files)
|
||||
public string[] Aliases
|
||||
@@ -116,6 +118,11 @@ namespace Barotrauma
|
||||
private set;
|
||||
}
|
||||
|
||||
public bool CanSpriteFlipX
|
||||
{
|
||||
get { return canSpriteFlipX; }
|
||||
}
|
||||
|
||||
public Vector2 Size
|
||||
{
|
||||
get { return size; }
|
||||
@@ -281,6 +288,9 @@ namespace Barotrauma
|
||||
spriteFolder = Path.GetDirectoryName(filePath);
|
||||
}
|
||||
|
||||
if (ToolBox.GetAttributeBool(subElement, "canflipx", false))
|
||||
canSpriteFlipX = true;
|
||||
|
||||
sprite = new Sprite(subElement, spriteFolder);
|
||||
size = sprite.size;
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user