Walls have an additional background sprite below the destructible sprite, separate parameters for rgb and alpha lerping in the damage shader

This commit is contained in:
Regalis
2016-09-19 21:51:37 +03:00
parent b24359464b
commit f8368f464a
11 changed files with 348 additions and 215 deletions

View File

@@ -1,167 +1,239 @@
<prefabs>
<largehorizontalback sprite="Content/Map/testroom.png" sourcerect="0,0,896,64" depth ="0.9"
description="A decorative structure with no collision detection"
width = "128" height ="64" resizehorizontal="true"/>
<largehorizontalback description="A decorative structure with no collision detection"
width="128" height = "64" resizehorizontal="true">
<sprite texture="Content/Map/testroom.png" sourcerect="0,0,896,64" depth="0.9"/>
</largehorizontalback>
<smallhorizontalback sprite="Content/Map/testroom.png" sourcerect="0,64,896,32" depth ="0.9"
description="A decorative structure with no collision detection"
width = "128" height ="32" resizehorizontal="true"/>
<smallhorizontalback description="A decorative structure with no collision detection"
width="128" height="32" resizehorizontal="true">
<sprite texture="Content/Map/testroom.png" sourcerect="0,64,896,32" depth="0.9"/>
</smallhorizontalback>
<largeverticalback sprite="Content/Map/testroom.png" sourcerect="0,96,64,448" depth ="0.9"
description="A decorative structure with no collision detection"
width = "64" height ="128" resizevertical="true"/>
<largeverticalback2 sprite="Content/Map/testroom.png" sourcerect="64,96,64,448" depth ="0.9"
description="A decorative structure with no collision detection"
width = "64" height ="128" resizevertical="true"/>
<smallverticalback sprite="Content/Map/testroom.png" sourcerect="128,96,32,352" depth ="0.9"
description="A decorative structure with no collision detection"
width = "32" height ="128" resizevertical="true"/>
<smallverticalback2 sprite="Content/Map/testroom.png" sourcerect="160,96,32,352" depth ="0.9"
description="A decorative structure with no collision detection"
width = "32" height ="128" resizevertical="true"/>
<engineeringLabel sprite="Content/Map/testroom.png" sourcerect="448,322,153,16" depth ="0.99"
width = "153" height ="16"/>
<largeverticalback description="A decorative structure with no collision detection"
width="64" height="128" resizevertical="true">
<sprite texture="Content/Map/testroom.png" sourcerect="0,96,64,448" depth ="0.9"/>
</largeverticalback>
<commandLabel sprite="Content/Map/testroom.png" sourcerect="448,339,128,16" depth ="0.99"
width = "128" height ="16"/>
<largeverticalback2 description="A decorative structure with no collision detection"
width="64" height="128" resizevertical="true">
<sprite texture="Content/Map/testroom.png" sourcerect="64,96,64,448" depth="0.9"/>
</largeverticalback2>
<airlockLabel sprite="Content/Map/testroom.png" sourcerect="448,356,199,16" depth ="0.99"
width = "99" height ="16"/>
<smallverticalback description="A decorative structure with no collision detection"
width="32" height="128" resizevertical="true">
<sprite texture="Content/Map/testroom.png" sourcerect="128,96,32,352" depth ="0.9"/>
</smallverticalback>
<smallverticalback2 description="A decorative structure with no collision detection"
width="32" height="128" resizevertical="true">
<sprite texture="Content/Map/testroom.png" sourcerect="160,96,32,352" depth="0.9"/>
</smallverticalback2>
<engineeringLabel width="153" height="16">
<sprite texture="Content/Map/structures2.png" sourcerect="0,426,153,16" depth ="0.99"/>
</engineeringLabel>
<commandLabel width="128" height="16">
<sprite texture="Content/Map/structures2.png" sourcerect="0,443,128,16" depth ="0.99"/>
</commandLabel>
<airlockLabel width = "99" height ="16">
<sprite texture="Content/Map/structures2.png" sourcerect="0,460,199,16" depth ="0.99"/>
</airlockLabel>
<cabinsLabel width="83" height="16">
<sprite texture="Content/Map/structures2.png" sourcerect="0,477,83,16" depth ="0.99"/>
</cabinsLabel>
<medicalLabel width="110" height="16">
<sprite texture="Content/Map/structures2.png" sourcerect="0,494,110,16" depth="0.99"/>
</medicalLabel>
<arrowUp width="16" height="16">
<sprite texture="Content/Map/structures2.png" sourcerect="129,460,16,16" depth ="0.99"/>
</arrowUp>
<arrowDown width="16" height="16">
<sprite texture="Content/Map/structures2.png" sourcerect="146,460,16,16" depth ="0.99"/>
</arrowDown>
<arrowLeft width="16" height="16">
<sprite texture="Content/Map/structures2.png" sourcerect="129,477,16,16" depth ="0.99"/>
</arrowLeft>
<arrowRight width="16" height="16">
<sprite texture="Content/Map/structures2.png" sourcerect="146,477,16,16" depth ="0.99"/>
</arrowRight>
<leftwall description="A vertical wall with collision detection"
width = "32" height ="64" resizevertical="true" body="true" castshadow="true" health="500">
<sprite texture="Content/Map/testroom.png" sourcerect="953,214,32,576" depth ="0.05" fliphorizontal="true"/>
<backgroundsprite texture="Content/Map/testroom.png" sourcerect="989,214,32,576" depth ="0.85" fliphorizontal="true"/>
</leftwall>
<rightwall description="A vertical wall with collision detection"
width="32" height="64" resizevertical="true" body="true" castshadow="true" health="500">
<sprite texture="Content/Map/testroom.png" sourcerect="953,214,32,576" depth ="0.05" />
<backgroundsprite texture="Content/Map/testroom.png" sourcerect="989,214,32,576" depth ="0.85"/>
</rightwall>
<topwall description="A horizontal wall with collision detection"
width = "64" height ="32" resizehorizontal="true" body="true" castshadow="true" health="500">
<sprite texture="Content/Map/testroom.png" sourcerect="0,989,576,32" depth ="0.06"/>
<backgroundsprite texture="Content/Map/testroom.png" sourcerect="0,953,576,32" depth ="0.85"/>
</topwall>
<TopWallHeavy description="A horizontal wall with collision detection"
width = "96" height ="96" resizehorizontal="true" body="true" castshadow="true" health="1000">
<sprite texture="Content/Map/testroom.png" sourcerect="197,347,480,96" depth ="0.06" />
<backgroundsprite texture="Content/Map/testroom.png" sourcerect="197,446,480,96" depth ="0.85" />
</TopWallHeavy>
<LeftWallHeavy description="A vertical wall with collision detection"
width = "96" height ="96" resizevertical="true" body="true" castshadow="true" health="1000">
<sprite texture="Content/Map/testroom.png" sourcerect="0,546,96,384" depth ="0.06" fliphorizontal="true" />
<backgroundsprite texture="Content/Map/testroom.png" sourcerect="98,546,96,384" depth ="0.85" fliphorizontal="true" />
</LeftWallHeavy>
<RightWallHeavy description="A vertical wall with collision detection"
width = "96" height ="96" resizevertical="true" body="true" castshadow="true" health="1000">
<sprite texture="Content/Map/testroom.png" sourcerect="0,546,96,384" depth ="0.06" />
<backgroundsprite texture="Content/Map/testroom.png" sourcerect="98,546,96,384" depth ="0.85" />
</RightWallHeavy>
<CableHolderHorizontal width="32" height="24" resizehorizontal="true">
<sprite texture="Content/Map/testroom.png" sourcerect="478,902,96,24" depth = "0.85" />
</CableHolderHorizontal>
<cabinsLabel sprite="Content/Map/testroom.png" sourcerect="448,373,83,16" depth ="0.99"
width = "83" height ="16"/>
<CableHolderVertical width="24" height="32" resizevertical="true">
<sprite texture="Content/Map/testroom.png" sourcerect="550,804,24,96" depth = "0.85" />
</CableHolderVertical>
<medicalLabel sprite="Content/Map/testroom.png" sourcerect="448,390,110,16" depth ="0.99"
width = "110" height ="16"/>
<topwindow width="128" height="49" body="true" health="100">
<sprite texture="Content/Map/testroom.png" sourcerect="208,880,128,48" depth ="0.05"/>
<backgroundsprite texture="Content/Map/testroom.png" sourcerect="344,880,128,48" depth ="0.85"/>
</topwindow>
<arrowUp sprite="Content/Map/testroom.png" sourcerect="577,356,16,16" depth ="0.99"
width = "16" height ="16"/>
<verticalwindow width="128" height ="224" body="true" health="100">
<sprite texture="Content/Map/testroom.png" sourcerect="368,576,128,224" depth ="0.05"/>
<backgroundsprite texture="Content/Map/testroom.png" sourcerect="239,576,128,224" depth ="0.85"/>
</verticalwindow>
<arrowDown sprite="Content/Map/testroom.png" sourcerect="594,356,16,16" depth ="0.99"
width = "16" height ="16"/>
<horizontalresizablewindow width="128" height ="64" body="true" health="100" resizehorizontal="true">
<sprite texture="Content/Map/testroom.png" sourcerect="207,803,128,64" depth ="0.06"/>
<backgroundsprite texture="Content/Map/testroom.png" sourcerect="337,803,128,64" depth ="0.06"/>
</horizontalresizablewindow>
<arrowLeft sprite="Content/Map/testroom.png" sourcerect="577,373,16,16" depth ="0.99"
width = "16" height ="16"/>
<verticalresizablewindow width = "64" height ="128" body="true" health="100" resizevertical="true">
<sprite texture="Content/Map/testroom.png" sourcerect="896,80,64,128" depth ="0.06"/>
<backgroundsprite texture="Content/Map/testroom.png" sourcerect="961,80,64,128" depth ="0.06"/>
</verticalresizablewindow>
<arrowRight sprite="Content/Map/testroom.png" sourcerect="597,373,16,16" depth ="0.99"
width = "16" height ="16"/>
<smallhorizontalback description="A decorative structure with no collision detection"
width = "128" height ="32" resizehorizontal="true">
<sprite texture="Content/Map/testroom.png" sourcerect="0,65,896,32" depth ="0.4" />
</smallhorizontalback>
<leftwall sprite="Content/Map/testroom.png" sourcerect="990,274,32,512" depth ="0.05" castshadow="true"
description="A vertical wall with collision detection"
width = "32" height ="64" resizevertical="true" fliphorizontal="true" body="true" health="500"/>
<largeplatform width = "64" height ="64" resizehorizontal="true" body="true" platform="true">
<sprite texture="Content/Map/testroom.png" sourcerect="896,0,128,64" depth="0.9" />
</largeplatform>
<rightwall sprite="Content/Map/testroom.png" sourcerect="990,274,32,512" depth ="0.05" castshadow="true"
description="A vertical wall with collision detection"
width = "32" height ="64" resizevertical="true" body="true" health="500"/>
<platform width = "64" height ="26" resizehorizontal="true" body="true" platform="true">
<sprite texture="Content/Map/testroom.png" sourcerect="896,53,128,32" depth ="0.9" />
</platform>
<topwall sprite="Content/Map/testroom.png" sourcerect="3,989,512,32" depth ="0.06" castshadow="true"
description="A horizontal wall with collision detection"
width = "64" height ="32" resizehorizontal="true" body="true" health="500"/>
<roughbgwall width="64" height="64" resizehorizontal="true" resizevertical="true">
<sprite texture="Content/Map/testroom.png" sourcerect="200,104,240,240" depth = "1.0" />
</roughbgwall>
<TopWallHeavy sprite="Content/Map/testroom.png" sourcerect="193,414,512,96" depth ="0.06" castshadow="true"
description="A horizontal wall with collision detection"
width = "96" height ="96" resizehorizontal="true" body="true" health="1000"/>
<LeftWallHeavy sprite="Content/Map/testroom.png" sourcerect="0,546,96,384" depth ="0.06" castshadow="true"
description="A horizontal wall with collision detection"
width = "96" height ="96" fliphorizontal="true" resizevertical="true" body="true" health="1000"/>
<cleanbgwall width="64" height="64" resizehorizontal="true" resizevertical="true">
<sprite texture="Content/Map/testroom.png" sourcerect="448,96,448,224" depth = "1.0"/>
</cleanbgwall>
<RightWallHeavy sprite="Content/Map/testroom.png" sourcerect="0,546,96,384" depth ="0.06" castshadow="true"
description="A horizontal wall with collision detection"
width = "96" height ="96" resizevertical="true" body="true" health="1000"/>
<CableHolderHorizontal sprite="Content/Map/testroom.png" sourcerect="199,348,96,24" depth = "0.85"
width="32" height="24" resizehorizontal="true"/>
<CableHolderVertical sprite="Content/Map/testroom.png" sourcerect="705,416,24,96" depth = "0.85"
width="24" height="32" resizevertical="true"/>
<bgpanels width="64" height="64" resizehorizontal="true" resizevertical="true">
<sprite texture="Content/Map/testroom.png" sourcerect="720,336,224,224" depth = "1.0" />
</bgpanels>
<topwindow sprite="Content/Map/testroom.png" sourcerect="625,327,128,80" depth ="0.05"
width = "128" height ="49" body="true" health="100"/>
<bgpanelswindow width="64" height="64" resizehorizontal="true" resizevertical="true">
<sprite texture="Content/Map/testroom.png" sourcerect="724,560,224,224" depth = "1.0" />
</bgpanelswindow>
<verticalwindow sprite="Content/Map/testroom.png" sourcerect="399,560,128,224" depth ="0.05"
width = "128" height ="224" body="true" health="100"/>
<bgorangepanels width="64" height="64" resizehorizontal="true" resizevertical="true">
<sprite texture="Content/Map/testroom.png" sourcerect="576,798,446,224" depth = "1.0" />
</bgorangepanels>
<horizontalresizablewindow sprite="Content/Map/testroom.png" sourcerect="896,208,128,64" depth ="0.06"
width = "128" height ="64" body="true" health="100" resizehorizontal="true"/>
<bgorangepanelwindow width="64" height="64" resizehorizontal="true" resizevertical="true">
<sprite texture="Content/Map/testroom.png" sourcerect="501,560,224,224" depth = "1.0" />
</bgorangepanelwindow>
<verticalresizablewindow sprite="Content/Map/testroom.png" sourcerect="896,80,64,128" depth ="0.06"
width = "64" height ="128" body="true" health="100" resizevertical="true"/>
<PipesBackground width="64" height="64" resizehorizontal="true" resizevertical="true">
<sprite texture="Content/Map/structures2.png" sourcerect="320,0,192,192" depth = "1.0" />
</PipesBackground>
<smallhorizontalback sprite="Content/Map/testroom.png" sourcerect="0,65,896,32" depth ="0.4"
description="A decorative structure with no collision detection"
width = "128" height ="32" resizehorizontal="true"/>
<SlopeForward width="16" height="16" resizehorizontal="true" resizevertical="true">
<sprite texture="Content/Map/structures2.png" sourcerect="0,0,224,64" depth = "0.95" />
</SlopeForward>
<largeplatform sprite="Content/Map/testroom.png" sourcerect="896,0,128,64" depth="0.9"
width = "64" height ="64" resizehorizontal="true" body="true" platform="true"/>
<SlopeBack width="16" height="16" resizehorizontal="true" resizevertical="true">
<sprite texture="Content/Map/structures2.png" sourcerect="0,64,224,64" depth = "0.95" />
</SlopeBack>
<platform sprite="Content/Map/testroom.png" sourcerect="896,53,128,32" depth ="0.9"
width = "64" height ="26" resizehorizontal="true" body="true" platform="true"/>
<stairsright width="256" height="320" stairdirection="Right">
<sprite texture="Content/Map/structures2.png" sourcerect="256,193,256,319" depth = "0.1" />
</stairsright>
<roughbgwall sprite="Content/Map/testroom.png" sourcerect="200,104,240,240" depth = "1.0"
width="64" height="64" resizehorizontal="true" resizevertical="true"/>
<stairsleft width="256" height="320" stairdirection="Left">
<sprite texture="Content/Map/structures2.png" sourcerect="256,193,256,319" fliphorizontal="true" depth = "0.1" />
</stairsleft>
<cleanbgwall sprite="Content/Map/testroom.png" sourcerect="448,96,448,224" depth = "1.0"
width="64" height="64" resizehorizontal="true" resizevertical="true"/>
<bunk width="173" height="129">
<sprite texture="Content/Map/structures2.png" sourcerect="0,129,173,129" depth = "0.9"/>
</bunk>
<bgpanels sprite="Content/Map/testroom.png" sourcerect="768,320,224,224" depth = "1.0"
width="64" height="64" resizehorizontal="true" resizevertical="true"/>
<bgpanelswindow sprite="Content/Map/testroom.png" sourcerect="752,560,224,224" depth = "1.0"
width="64" height="64" resizehorizontal="true" resizevertical="true"/>
<RuinWallHorizontal category="Alien" castshadow="true"
width="128" height="128" resizehorizontal="true" body="true" health="500">
<sprite texture="Content/Map/ruins.png" sourcerect="0,896,832,128" depth ="0.06"/>
</RuinWallHorizontal>
<bgorangepanels sprite="Content/Map/testroom.png" sourcerect="576,798,446,224" depth = "1.0"
width="64" height="64" resizehorizontal="true" resizevertical="true"/>
<RuinWallVertical category="Alien" castshadow="true"
width="128" height="128" resizevertical="true" body="true" health="500">
<sprite texture="Content/Map/ruins.png" sourcerect="896,192,128,832" depth ="0.061"/>
</RuinWallVertical>
<bgorangepanelwindow sprite="Content/Map/testroom.png" sourcerect="528,563,224,224" depth = "1.0"
width="64" height="64" resizehorizontal="true" resizevertical="true"/>
<RuinWallHorizontalSmall category="Alien" castshadow="true"
width="128" height="54" resizehorizontal="true" body="true" health="500">
<sprite texture="Content/Map/ruins.png" sourcerect="0,842,832,54" depth ="0.062"/>
</RuinWallHorizontalSmall>
<PipesBackground sprite="Content/Map/testroom.png" sourcerect="381,795,192,192" depth = "1.0"
width="64" height="64" resizehorizontal="true" resizevertical="true"/>
<RuinWallVerticalSmall category="Alien" castshadow="true"
width= "54" height="128" resizevertical="true" body="true" health="500">
<sprite texture="Content/Map/ruins.png" sourcerect="842,192,54,832" depth ="0.063"/>
</RuinWallVerticalSmall>
<SlopeForward sprite="Content/Map/structures2.png" sourcerect="0,0,224,64"
width="16" height="16" resizehorizontal="true" resizevertical="true" depth = "0.95"/>
<SlopeBack sprite="Content/Map/structures2.png" sourcerect="0,64,224,64"
width="16" height="16" resizehorizontal="true" resizevertical="true" depth = "0.95"/>
<RuinBack category="Alien"
width="64" height="64" resizehorizontal="true" resizevertical="true">
<sprite texture="Content/Map/ruins.png" sourcerect="0,0,512,512" depth ="0.98"/>
</RuinBack>
<stairsright sprite="Content/Map/testroom.png" sourcerect="100,667,256,320"
width="256" height="320" depth = "0.1" stairdirection="Right"/>
<RuinBackCarvings category="Alien"
width="64" height="64" resizehorizontal="true" resizevertical="true">
<sprite texture="Content/Map/ruins.png" sourcerect="512,0,233,512" depth ="0.981" />
</RuinBackCarvings>
<stairsleft sprite="Content/Map/testroom.png" fliphorizontal="true" sourcerect="100,667,256,320"
width="256" height="320" depth = "0.1" stairdirection="Left"/>
<RuinBlock category="Alien"
width="514" height="296">
<sprite texture="Content/Map/ruins.png" sourcerect="0,513,514,296" depth ="0.99" />
</RuinBlock>
<bunk sprite="Content/Map/testroom.png" sourcerect="130,514,173,129"
width="173" height="129" depth = "0.9"/>
<RuinFractalBall category="Alien"
width="512" height="512">
<sprite texture="Content/Map/ruins2.png" sourcerect="0,0,512,512" depth ="0.971" />
</RuinFractalBall>
<RuinWallHorizontal category="Alien" sprite="Content/Map/ruins.png" sourcerect="0,896,832,128" depth ="0.06" castshadow="true"
width = "128" height ="128" resizehorizontal="true" body="true" health="500"/>
<RuinWallVertical category="Alien" sprite="Content/Map/ruins.png" sourcerect="896,192,128,832" depth ="0.061" castshadow="true"
width = "128" height ="128" resizevertical="true" body="true" health="500"/>
<RuinWallHorizontalSmall category="Alien" sprite="Content/Map/ruins.png" sourcerect="0,842,832,54" depth ="0.062" castshadow="true"
width = "128" height ="54" resizehorizontal="true" body="true" health="500"/>
<RuinWallVerticalSmall category="Alien" sprite="Content/Map/ruins.png" sourcerect="842,192,54,832" depth ="0.063" castshadow="true"
width = "54" height ="128" resizevertical="true" body="true" health="500"/>
<RuinBack category="Alien" sprite="Content/Map/ruins.png" sourcerect="0,0,512,512" depth ="0.98"
width="64" height="64" resizehorizontal="true" resizevertical="true"/>
<RuinBackCarvings category="Alien" sprite="Content/Map/ruins.png" sourcerect="512,0,233,512" depth ="0.981"
width="64" height="64" resizehorizontal="true" resizevertical="true"/>
<RuinBlock category="Alien" sprite="Content/Map/ruins.png" sourcerect="0,513,514,296" depth ="0.99"
width="514" height="296"/>
<RuinFractalBall category="Alien" sprite="Content/Map/ruins2.png" sourcerect="0,0,512,512" depth ="0.971"
width="512" height="512"/>
<RuinClaw category="Alien" sprite="Content/Map/ruins2.png" sourcerect="512,517,126,270" depth ="0.97"
width="126" height="270"/>
<RuinClaw category="Alien"
width="126" height="270">
<sprite texture="Content/Map/ruins2.png" sourcerect="512,517,126,270" depth ="0.97"/>
</RuinClaw>
</prefabs>

Binary file not shown.

Before

Width:  |  Height:  |  Size: 41 KiB

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 MiB

After

Width:  |  Height:  |  Size: 2.6 MiB

View File

@@ -6,8 +6,11 @@ Texture xStencil;
sampler StencilSampler = sampler_state { Texture = <xStencil>; };
float cutoff;
float multiplier;
float aCutoff;
float aMultiplier;
float cCutoff;
float cMultiplier;
float4 main(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0
{
@@ -15,14 +18,15 @@ float4 main(float4 position : SV_Position, float4 color : COLOR0, float2 texCoor
float4 stencilColor = tex2D(StencilSampler, texCoord);
float a = stencilColor.a - cutoff;
float aDiff = stencilColor.a - aCutoff;
clip(a);
clip(aDiff);
a = min(a * multiplier, 1.0f);
c = lerp(c, stencilColor, 1.0f - a);
float cDiff = stencilColor.a - cCutoff;
return c * a;
return float4(
lerp(stencilColor.rgb, c.rgb, clamp(cDiff * cMultiplier, 0.0f, 1.0f)),
min(aDiff * aMultiplier, c.a));
}
technique StencilShader

Binary file not shown.

View File

@@ -86,6 +86,30 @@ namespace Barotrauma
{
get { return null; }
}
public virtual bool DrawBelowWater
{
get
{
return Sprite != null && Sprite.Depth > 0.5f;
}
}
public virtual bool DrawOverWater
{
get
{
return !DrawBelowWater;
}
}
public virtual bool DrawDamageEffect
{
get
{
return false;
}
}
public virtual bool IsLinkable
{
@@ -203,6 +227,8 @@ namespace Barotrauma
public virtual void Draw(SpriteBatch spriteBatch, bool editing, bool back=true) {}
public virtual void DrawDamage(SpriteBatch spriteBatch, Effect damageEffect) {}
public override void Remove()
{
base.Remove();

View File

@@ -43,7 +43,7 @@ namespace Barotrauma
class Structure : MapEntity, IDamageable
{
public static int wallSectionSize = 100;
public static int wallSectionSize = 96;
public static List<Structure> WallList = new List<Structure>();
List<ConvexHull> convexHulls;
@@ -105,6 +105,30 @@ namespace Barotrauma
get { return prefab.MaxHealth; }
}
public override bool DrawBelowWater
{
get
{
return base.DrawBelowWater || prefab.BackgroundSprite != null;
}
}
public override bool DrawOverWater
{
get
{
return !DrawDamageEffect;
}
}
public override bool DrawDamageEffect
{
get
{
return prefab.HasBody;
}
}
public override Rectangle Rect
{
get
@@ -371,12 +395,19 @@ namespace Barotrauma
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
{
if (prefab.sprite == null) return;
Draw(spriteBatch, editing, back, null);
}
public override void DrawDamage(SpriteBatch spriteBatch, Effect damageEffect)
{
Draw(spriteBatch, false, false, damageEffect);
}
private static float prevCutoff;
public void Draw(SpriteBatch spriteBatch, bool editing, bool back = true, Effect damageEffect = null)
private void Draw(SpriteBatch spriteBatch, bool editing, bool back = true, Effect damageEffect = null)
{
if (prefab.sprite == null) return;
@@ -389,69 +420,48 @@ namespace Barotrauma
}
Vector2 drawOffset = Submarine == null ? Vector2.Zero : Submarine.DrawPosition;
if (sections.Length == 1)
{
prefab.sprite.DrawTiled(spriteBatch, new Vector2(rect.X + drawOffset.X, -(rect.Y + drawOffset.Y)), new Vector2(rect.Width, rect.Height), Vector2.Zero, color, Point.Zero);
return;
}
foreach (WallSection s in sections)
if (back && damageEffect == null)
{
if (damageEffect != null)
if (prefab.BackgroundSprite != null)
{
float newCutoff = Math.Min((s.damage / prefab.MaxHealth)*0.5f - 0.2f, 0.1f);
if (Math.Abs(newCutoff - prevCutoff) > 0.01f)
prefab.BackgroundSprite.DrawTiled(
spriteBatch,
new Vector2(rect.X + drawOffset.X, -(rect.Y + drawOffset.Y)),
new Vector2(rect.Width, rect.Height),
Vector2.Zero, color, Point.Zero);
}
}
if (back == prefab.sprite.Depth > 0.5f || editing)
{
foreach (WallSection s in sections)
{
if (damageEffect != null)
{
damageEffect.Parameters["cutoff"].SetValue(newCutoff);
float newCutoff = Math.Min((s.damage / prefab.MaxHealth), 0.65f);
damageEffect.CurrentTechnique.Passes[0].Apply();
if (Math.Abs(newCutoff - prevCutoff) > 0.01f)
{
damageEffect.Parameters["aCutoff"].SetValue(newCutoff);
damageEffect.Parameters["cCutoff"].SetValue(newCutoff*1.2f);
prevCutoff = newCutoff;
damageEffect.CurrentTechnique.Passes[0].Apply();
prevCutoff = newCutoff;
}
}
}
Point offset = new Point(Math.Abs(rect.Location.X - s.rect.Location.X), Math.Abs(rect.Location.Y - s.rect.Location.Y));
if (sections.Length != 1)
Point offset = new Point(Math.Abs(rect.Location.X - s.rect.Location.X), Math.Abs(rect.Location.Y - s.rect.Location.Y));
prefab.sprite.DrawTiled(spriteBatch, new Vector2(s.rect.X + drawOffset.X, -(s.rect.Y + drawOffset.Y)), new Vector2(s.rect.Width, s.rect.Height), Vector2.Zero, color, offset);
if (s.isHighLighted)
{
GUI.DrawRectangle(spriteBatch,
new Vector2(s.rect.X + drawOffset.X, -(s.rect.Y + drawOffset.Y)), new Vector2(s.rect.Width, s.rect.Height),
new Color((s.damage / prefab.MaxHealth), 1.0f - (s.damage / prefab.MaxHealth), 0.0f, 1.0f), true);
s.isHighLighted = false;
}
s.isHighLighted = false;
//if (s.damage < 0.01f) continue;
//GUI.DrawRectangle(spriteBatch,
// new Vector2(s.rect.X + drawOffset.X, -(s.rect.Y + drawOffset.Y)), new Vector2(s.rect.Width, s.rect.Height),
// Color.Black * (s.damage / prefab.MaxHealth), true);
}
/*
if(_convexHulls == null) return;
var rand = new Random(32434324);
foreach (var hull in _convexHulls)
{
if (sections.Count(x => x.hull == hull) <= 1)
continue;
var col = new Color((int) (255 * rand.NextDouble()), (int)(255 * rand.NextDouble()), (int)(255 * rand.NextDouble()), 255);
GUI.DrawRectangle(spriteBatch,new Vector2 (hull.BoundingBox.X + drawOffset.X, -(hull.BoundingBox.Y + drawOffset.Y)), new Vector2(hull.BoundingBox.Width, hull.BoundingBox.Height),col,true );
}*/
}
private bool OnWallCollision(Fixture f1, Fixture f2, Contact contact)
{
//Structure structure = f1.Body.UserData as Structure;
//if (f2.Body.UserData as Item != null)
//{
// if (prefab.IsPlatform || prefab.StairDirection != Direction.None) return false;
//}
if (prefab.IsPlatform)
{
Limb limb;

View File

@@ -52,6 +52,12 @@ namespace Barotrauma
{
get { return size; }
}
public Sprite BackgroundSprite
{
get;
private set;
}
public static void LoadAll(List<string> filePaths)
{
@@ -74,22 +80,45 @@ namespace Barotrauma
StructurePrefab sp = new StructurePrefab();
sp.name = element.Name.ToString();
Vector4 sourceVector = ToolBox.GetAttributeVector4(element, "sourcerect", new Vector4(0,0,1,1));
//Vector4 sourceVector = ToolBox.GetAttributeVector4(element, "sourcerect", new Vector4(0,0,1,1));
Rectangle sourceRect = new Rectangle(
(int)sourceVector.X,
(int)sourceVector.Y,
(int)sourceVector.Z,
(int)sourceVector.W);
//Rectangle sourceRect = new Rectangle(
// (int)sourceVector.X,
// (int)sourceVector.Y,
// (int)sourceVector.Z,
// (int)sourceVector.W);
if (element.Attribute("sprite") != null)
{
sp.sprite = new Sprite(element.Attribute("sprite").Value, sourceRect, Vector2.Zero);
//if (element.Attribute("sprite") != null)
//{
// sp.sprite = new Sprite(element.Attribute("sprite").Value, sourceRect, Vector2.Zero);
sp.sprite.Depth = ToolBox.GetAttributeFloat(element, "depth", 0.0f);
// sp.sprite.Depth = ToolBox.GetAttributeFloat(element, "depth", 0.0f);
if (ToolBox.GetAttributeBool(element, "fliphorizontal", false)) sp.sprite.effects = SpriteEffects.FlipHorizontally;
if (ToolBox.GetAttributeBool(element, "flipvertical", false)) sp.sprite.effects = SpriteEffects.FlipVertically;
//}
foreach (XElement subElement in element.Elements())
{
switch (subElement.Name.ToString())
{
case "sprite":
sp.sprite = new Sprite(subElement);
if (ToolBox.GetAttributeBool(subElement, "fliphorizontal", false))
sp.sprite.effects = SpriteEffects.FlipHorizontally;
if (ToolBox.GetAttributeBool(subElement, "flipvertical", false))
sp.sprite.effects = SpriteEffects.FlipVertically;
break;
case "backgroundsprite":
sp.BackgroundSprite = new Sprite(subElement);
if (ToolBox.GetAttributeBool(subElement, "fliphorizontal", false))
sp.BackgroundSprite.effects = SpriteEffects.FlipHorizontally;
if (ToolBox.GetAttributeBool(subElement, "flipvertical", false))
sp.BackgroundSprite.effects = SpriteEffects.FlipVertically;
break;
}
}
MapEntityCategory category;
@@ -119,8 +148,7 @@ namespace Barotrauma
sp.stairDirection = (Direction)Enum.Parse(typeof(Direction), ToolBox.GetAttributeString(element, "stairdirection", "None"), true);
sp.castShadow = ToolBox.GetAttributeBool(element, "castshadow", false);
sp.hasBody = ToolBox.GetAttributeBool(element, "body", false);
return sp;

View File

@@ -287,8 +287,7 @@ namespace Barotrauma
{
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
{
if (MapEntity.mapEntityList[i] is Structure) continue;
if (MapEntity.mapEntityList[i].Sprite == null || MapEntity.mapEntityList[i].Sprite.Depth < 0.5f)
if (MapEntity.mapEntityList[i].DrawOverWater)
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, false);
}
}
@@ -297,12 +296,11 @@ namespace Barotrauma
{
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
{
var structure = MapEntity.mapEntityList[i] as Structure;
if (structure == null || structure.Sprite.Depth > 0.5f) continue;
structure.Draw(spriteBatch, editing, false, damageEffect);
if (MapEntity.mapEntityList[i].DrawDamageEffect)
MapEntity.mapEntityList[i].DrawDamage(spriteBatch, damageEffect);
}
damageEffect.Parameters["cutoff"].SetValue(0.5f);
damageEffect.Parameters["aCutoff"].SetValue(0.0f);
damageEffect.Parameters["cCutoff"].SetValue(0.0f);
}
@@ -310,7 +308,7 @@ namespace Barotrauma
{
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
{
if (MapEntity.mapEntityList[i].Sprite == null || MapEntity.mapEntityList[i].Sprite.Depth >= 0.5f)
if (MapEntity.mapEntityList[i].DrawBelowWater)
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, true);
}
}

View File

@@ -53,14 +53,11 @@ namespace Barotrauma
damageStencil = TextureLoader.FromFile("Content/Map/walldamage.png");
damageEffect = content.Load<Effect>("damageshader");
// damageEffect.Parameters["cutoff"].SetValue(0.5f);
damageEffect.Parameters["xStencil"].SetValue(damageStencil);
damageEffect.Parameters["aMultiplier"].SetValue(50.0f);
damageEffect.Parameters["cMultiplier"].SetValue(200.0f);
lightBlur = new BlurEffect(blurEffect, 0.001f, 0.001f);
}
public override void Select()
@@ -344,8 +341,6 @@ namespace Barotrauma
null, null,
damageEffect,
cam.Transform);
damageEffect.Parameters["cutoff"].SetValue(-0.2f);
damageEffect.Parameters["multiplier"].SetValue(5.0f);
Submarine.DrawDamageable(spriteBatch, damageEffect);