Limbs with no sprite don't cause the game to crash anymore, lightsources attached to a limb are drawn at the interpolated position (= DrawPosition) of the limb, lightTexture origin is flipped on the X-axis when parent limb flips

This commit is contained in:
Regalis
2016-12-17 14:24:54 +02:00
parent b01b38da68
commit 311f388358
5 changed files with 60 additions and 31 deletions
+21 -2
View File
@@ -185,7 +185,8 @@ namespace Barotrauma.Lights
if (NeedsHullUpdate)
{
var fullChList = ConvexHull.HullLists.Find(x => x.Submarine == sub);
chList.List = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox));
if (fullChList != null)
chList.List = fullChList.List.FindAll(ch => MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox));
}
}
//light is outside, convexhull inside a sub
@@ -299,7 +300,7 @@ namespace Barotrauma.Lights
if (ParentSub != null) drawPos += ParentSub.DrawPosition;
drawPos.Y = -drawPos.Y;
if (range > 1.0f)
{
if (overrideLightTexture == null)
@@ -326,6 +327,24 @@ namespace Barotrauma.Lights
}
}
public void FlipX()
{
SpriteEffect = SpriteEffect == SpriteEffects.None ? SpriteEffects.FlipHorizontally : SpriteEffects.None;
if (LightSprite != null)
{
Vector2 lightOrigin = LightSprite.Origin;
lightOrigin.X = LightSprite.SourceRect.Width - lightOrigin.X;
LightSprite.Origin = lightOrigin;
}
if (overrideLightTexture != null)
{
Vector2 lightOrigin = overrideLightTexture.Origin;
lightOrigin.X = overrideLightTexture.SourceRect.Width - lightOrigin.X;
overrideLightTexture.Origin = lightOrigin;
}
}
public void Remove()
{
if (LightSprite != null) LightSprite.Remove();