Fixed lightcomponent sprites & broken sprites not being mirrored. Closes #893
This commit is contained in:
@@ -2,6 +2,7 @@
|
|||||||
using Barotrauma.Networking;
|
using Barotrauma.Networking;
|
||||||
using Lidgren.Network;
|
using Lidgren.Network;
|
||||||
using Microsoft.Xna.Framework;
|
using Microsoft.Xna.Framework;
|
||||||
|
using Microsoft.Xna.Framework.Graphics;
|
||||||
|
|
||||||
namespace Barotrauma.Items.Components
|
namespace Barotrauma.Items.Components
|
||||||
{
|
{
|
||||||
@@ -9,7 +10,7 @@ namespace Barotrauma.Items.Components
|
|||||||
{
|
{
|
||||||
private LightSource light;
|
private LightSource light;
|
||||||
|
|
||||||
public void Draw(Microsoft.Xna.Framework.Graphics.SpriteBatch spriteBatch, bool editing = false)
|
public void Draw(SpriteBatch spriteBatch, bool editing = false)
|
||||||
{
|
{
|
||||||
if (light.LightSprite != null && (item.body == null || item.body.Enabled))
|
if (light.LightSprite != null && (item.body == null || item.body.Enabled))
|
||||||
{
|
{
|
||||||
@@ -17,6 +18,15 @@ namespace Barotrauma.Items.Components
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void FlipX()
|
||||||
|
{
|
||||||
|
if (light?.LightSprite != null)
|
||||||
|
{
|
||||||
|
light.LightSpriteEffect = light.LightSpriteEffect == SpriteEffects.None ?
|
||||||
|
SpriteEffects.FlipHorizontally : SpriteEffects.None;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void ClientRead(ServerNetObject type, NetBuffer msg, float sendingTime)
|
public void ClientRead(ServerNetObject type, NetBuffer msg, float sendingTime)
|
||||||
{
|
{
|
||||||
IsOn = msg.ReadBoolean();
|
IsOn = msg.ReadBoolean();
|
||||||
|
|||||||
@@ -74,9 +74,14 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
SpriteEffects oldEffects = selectedSprite.effects;
|
SpriteEffects oldEffects = selectedSprite.effects;
|
||||||
selectedSprite.effects ^= SpriteEffects;
|
selectedSprite.effects ^= SpriteEffects;
|
||||||
|
SpriteEffects oldBrokenSpriteEffects = SpriteEffects.None;
|
||||||
|
if (fadeInBrokenSprite != null)
|
||||||
|
{
|
||||||
|
oldBrokenSpriteEffects = fadeInBrokenSprite.Sprite.effects;
|
||||||
|
fadeInBrokenSprite.Sprite.effects ^= SpriteEffects;
|
||||||
|
}
|
||||||
|
|
||||||
float depth = GetDrawDepth();
|
float depth = GetDrawDepth();
|
||||||
|
|
||||||
if (body == null)
|
if (body == null)
|
||||||
{
|
{
|
||||||
if (prefab.ResizeHorizontal || prefab.ResizeVertical || SpriteEffects.HasFlag(SpriteEffects.FlipHorizontally) || SpriteEffects.HasFlag(SpriteEffects.FlipVertically))
|
if (prefab.ResizeHorizontal || prefab.ResizeVertical || SpriteEffects.HasFlag(SpriteEffects.FlipHorizontally) || SpriteEffects.HasFlag(SpriteEffects.FlipVertically))
|
||||||
@@ -91,7 +96,6 @@ namespace Barotrauma
|
|||||||
selectedSprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y), color, 0.0f, 1.0f, SpriteEffects.None, depth);
|
selectedSprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y), color, 0.0f, 1.0f, SpriteEffects.None, depth);
|
||||||
fadeInBrokenSprite?.Sprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y), color * fadeInBrokenSpriteAlpha, 0.0f, 1.0f, SpriteEffects.None, depth - 0.000001f);
|
fadeInBrokenSprite?.Sprite.Draw(spriteBatch, new Vector2(DrawPosition.X, -DrawPosition.Y), color * fadeInBrokenSpriteAlpha, 0.0f, 1.0f, SpriteEffects.None, depth - 0.000001f);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (body.Enabled)
|
else if (body.Enabled)
|
||||||
{
|
{
|
||||||
@@ -122,9 +126,12 @@ namespace Barotrauma
|
|||||||
}
|
}
|
||||||
|
|
||||||
selectedSprite.effects = oldEffects;
|
selectedSprite.effects = oldEffects;
|
||||||
|
if (fadeInBrokenSprite != null)
|
||||||
|
{
|
||||||
|
fadeInBrokenSprite.Sprite.effects = oldEffects;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
List<IDrawableComponent> staticDrawableComponents = new List<IDrawableComponent>(drawableComponents); //static list to compensate for drawable toggling
|
List<IDrawableComponent> staticDrawableComponents = new List<IDrawableComponent>(drawableComponents); //static list to compensate for drawable toggling
|
||||||
for (int i = 0; i < staticDrawableComponents.Count; i++)
|
for (int i = 0; i < staticDrawableComponents.Count; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user