(20f37d9c7) Option to toggle structure drop shadows and edit the position of the shadow
This commit is contained in:
@@ -215,23 +215,24 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (Prefab.BackgroundSprite != null)
|
if (Prefab.BackgroundSprite != null)
|
||||||
{
|
{
|
||||||
bool drawDropShadow = Submarine != null && HasBody;
|
|
||||||
Vector2 dropShadowOffset = Vector2.Zero;
|
Vector2 dropShadowOffset = Vector2.Zero;
|
||||||
if (drawDropShadow)
|
if (UseDropShadow)
|
||||||
{
|
{
|
||||||
dropShadowOffset = Submarine.HiddenSubPosition - Position;
|
dropShadowOffset = DropShadowOffset;
|
||||||
if (dropShadowOffset != Vector2.Zero)
|
if (dropShadowOffset == Vector2.Zero)
|
||||||
{
|
{
|
||||||
if (IsHorizontal)
|
if (Submarine == null)
|
||||||
{
|
{
|
||||||
dropShadowOffset = new Vector2(0.0f, Math.Sign(dropShadowOffset.Y) * 10.0f);
|
dropShadowOffset = Vector2.UnitY * 10.0f;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dropShadowOffset = new Vector2(Math.Sign(dropShadowOffset.X) * 10.0f, 0.0f);
|
dropShadowOffset = IsHorizontal ?
|
||||||
|
new Vector2(0.0f, Math.Sign(Submarine.HiddenSubPosition.Y - Position.Y) * 10.0f) :
|
||||||
|
new Vector2(Math.Sign(Submarine.HiddenSubPosition.X - Position.X) * 10.0f, 0.0f);
|
||||||
}
|
}
|
||||||
dropShadowOffset.Y = -dropShadowOffset.Y;
|
|
||||||
}
|
}
|
||||||
|
dropShadowOffset.Y = -dropShadowOffset.Y;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DrawTiled)
|
if (DrawTiled)
|
||||||
@@ -251,7 +252,7 @@ namespace Barotrauma
|
|||||||
textureScale: TextureScale * Scale,
|
textureScale: TextureScale * Scale,
|
||||||
startOffset: backGroundOffset);
|
startOffset: backGroundOffset);
|
||||||
|
|
||||||
if (drawDropShadow)
|
if (UseDropShadow)
|
||||||
{
|
{
|
||||||
Prefab.BackgroundSprite.DrawTiled(
|
Prefab.BackgroundSprite.DrawTiled(
|
||||||
spriteBatch,
|
spriteBatch,
|
||||||
@@ -276,7 +277,7 @@ namespace Barotrauma
|
|||||||
rotate: 0,
|
rotate: 0,
|
||||||
spriteEffect: SpriteEffects);
|
spriteEffect: SpriteEffects);
|
||||||
|
|
||||||
if (drawDropShadow)
|
if (UseDropShadow)
|
||||||
{
|
{
|
||||||
Prefab.BackgroundSprite.Draw(
|
Prefab.BackgroundSprite.Draw(
|
||||||
spriteBatch,
|
spriteBatch,
|
||||||
|
|||||||
@@ -145,6 +145,20 @@ namespace Barotrauma
|
|||||||
set { spriteColor = value; }
|
set { spriteColor = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Editable, Serialize(false, true)]
|
||||||
|
public bool UseDropShadow
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serialize("0,0", true), Editable(ToolTip = "The position of the drop shadow relative to the structure. If set to zero, the shadow is positioned automatically so that it points towards the sub's center of mass.")]
|
||||||
|
public Vector2 DropShadowOffset
|
||||||
|
{
|
||||||
|
get;
|
||||||
|
private set;
|
||||||
|
}
|
||||||
|
|
||||||
public override Rectangle Rect
|
public override Rectangle Rect
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@@ -1139,6 +1153,13 @@ namespace Barotrauma
|
|||||||
if (element.GetAttributeBool("flippedx", false)) s.FlipX(false);
|
if (element.GetAttributeBool("flippedx", false)) s.FlipX(false);
|
||||||
if (element.GetAttributeBool("flippedy", false)) s.FlipY(false);
|
if (element.GetAttributeBool("flippedy", false)) s.FlipY(false);
|
||||||
SerializableProperty.DeserializeProperties(s, element);
|
SerializableProperty.DeserializeProperties(s, element);
|
||||||
|
|
||||||
|
//structures with a body drop a shadow by default
|
||||||
|
if (element.Attribute("usedropshadow") == null)
|
||||||
|
{
|
||||||
|
s.UseDropShadow = prefab.Body;
|
||||||
|
}
|
||||||
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user