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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user