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

+11 -7
View File
@@ -6,8 +6,11 @@ Texture xStencil;
sampler StencilSampler = sampler_state { Texture = <xStencil>; }; sampler StencilSampler = sampler_state { Texture = <xStencil>; };
float cutoff; float aCutoff;
float multiplier; float aMultiplier;
float cCutoff;
float cMultiplier;
float4 main(float4 position : SV_Position, float4 color : COLOR0, float2 texCoord : TEXCOORD0) : COLOR0 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); 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); float cDiff = stencilColor.a - cCutoff;
c = lerp(c, stencilColor, 1.0f - a);
return c * a; return float4(
lerp(stencilColor.rgb, c.rgb, clamp(cDiff * cMultiplier, 0.0f, 1.0f)),
min(aDiff * aMultiplier, c.a));
} }
technique StencilShader technique StencilShader
Binary file not shown.
+26
View File
@@ -87,6 +87,30 @@ namespace Barotrauma
get { return null; } 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 public virtual bool IsLinkable
{ {
get { return false; } get { return false; }
@@ -203,6 +227,8 @@ namespace Barotrauma
public virtual void Draw(SpriteBatch spriteBatch, bool editing, bool back=true) {} public virtual void Draw(SpriteBatch spriteBatch, bool editing, bool back=true) {}
public virtual void DrawDamage(SpriteBatch spriteBatch, Effect damageEffect) {}
public override void Remove() public override void Remove()
{ {
base.Remove(); base.Remove();
+57 -47
View File
@@ -43,7 +43,7 @@ namespace Barotrauma
class Structure : MapEntity, IDamageable class Structure : MapEntity, IDamageable
{ {
public static int wallSectionSize = 100; public static int wallSectionSize = 96;
public static List<Structure> WallList = new List<Structure>(); public static List<Structure> WallList = new List<Structure>();
List<ConvexHull> convexHulls; List<ConvexHull> convexHulls;
@@ -105,6 +105,30 @@ namespace Barotrauma
get { return prefab.MaxHealth; } 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 public override Rectangle Rect
{ {
get get
@@ -371,12 +395,19 @@ namespace Barotrauma
public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true) public override void Draw(SpriteBatch spriteBatch, bool editing, bool back = true)
{ {
if (prefab.sprite == null) return;
Draw(spriteBatch, editing, back, null); Draw(spriteBatch, editing, back, null);
} }
public override void DrawDamage(SpriteBatch spriteBatch, Effect damageEffect)
{
Draw(spriteBatch, false, false, damageEffect);
}
private static float prevCutoff; 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; if (prefab.sprite == null) return;
@@ -389,69 +420,48 @@ namespace Barotrauma
} }
Vector2 drawOffset = Submarine == null ? Vector2.Zero : Submarine.DrawPosition; Vector2 drawOffset = Submarine == null ? Vector2.Zero : Submarine.DrawPosition;
if (sections.Length == 1)
if (back && damageEffect == null)
{ {
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); if (prefab.BackgroundSprite != null)
return; {
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);
}
} }
foreach (WallSection s in sections) if (back == prefab.sprite.Depth > 0.5f || editing)
{ {
if (damageEffect != null) foreach (WallSection s in sections)
{ {
float newCutoff = Math.Min((s.damage / prefab.MaxHealth)*0.5f - 0.2f, 0.1f); if (damageEffect != null)
if (Math.Abs(newCutoff - prevCutoff) > 0.01f)
{ {
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)); 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)
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); 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);
s.isHighLighted = false;
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;
//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) 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) if (prefab.IsPlatform)
{ {
Limb limb; Limb limb;
+40 -12
View File
@@ -53,6 +53,12 @@ namespace Barotrauma
get { return size; } get { return size; }
} }
public Sprite BackgroundSprite
{
get;
private set;
}
public static void LoadAll(List<string> filePaths) public static void LoadAll(List<string> filePaths)
{ {
foreach (string filePath in filePaths) foreach (string filePath in filePaths)
@@ -74,22 +80,45 @@ namespace Barotrauma
StructurePrefab sp = new StructurePrefab(); StructurePrefab sp = new StructurePrefab();
sp.name = element.Name.ToString(); 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( //Rectangle sourceRect = new Rectangle(
(int)sourceVector.X, // (int)sourceVector.X,
(int)sourceVector.Y, // (int)sourceVector.Y,
(int)sourceVector.Z, // (int)sourceVector.Z,
(int)sourceVector.W); // (int)sourceVector.W);
if (element.Attribute("sprite") != null) //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);
//}
foreach (XElement subElement in element.Elements())
{ {
sp.sprite = new Sprite(element.Attribute("sprite").Value, sourceRect, Vector2.Zero); switch (subElement.Name.ToString())
{
case "sprite":
sp.sprite = new Sprite(subElement);
sp.sprite.Depth = ToolBox.GetAttributeFloat(element, "depth", 0.0f); if (ToolBox.GetAttributeBool(subElement, "fliphorizontal", false))
sp.sprite.effects = SpriteEffects.FlipHorizontally;
if (ToolBox.GetAttributeBool(subElement, "flipvertical", false))
sp.sprite.effects = SpriteEffects.FlipVertically;
if (ToolBox.GetAttributeBool(element, "fliphorizontal", false)) sp.sprite.effects = SpriteEffects.FlipHorizontally; break;
if (ToolBox.GetAttributeBool(element, "flipvertical", false)) sp.sprite.effects = SpriteEffects.FlipVertically; 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; MapEntityCategory category;
@@ -120,7 +149,6 @@ namespace Barotrauma
sp.castShadow = ToolBox.GetAttributeBool(element, "castshadow", false); sp.castShadow = ToolBox.GetAttributeBool(element, "castshadow", false);
sp.hasBody = ToolBox.GetAttributeBool(element, "body", false); sp.hasBody = ToolBox.GetAttributeBool(element, "body", false);
return sp; return sp;
+6 -8
View File
@@ -287,8 +287,7 @@ namespace Barotrauma
{ {
for (int i = 0; i < MapEntity.mapEntityList.Count; i++) for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
{ {
if (MapEntity.mapEntityList[i] is Structure) continue; if (MapEntity.mapEntityList[i].DrawOverWater)
if (MapEntity.mapEntityList[i].Sprite == null || MapEntity.mapEntityList[i].Sprite.Depth < 0.5f)
MapEntity.mapEntityList[i].Draw(spriteBatch, editing, false); MapEntity.mapEntityList[i].Draw(spriteBatch, editing, false);
} }
} }
@@ -297,12 +296,11 @@ namespace Barotrauma
{ {
for (int i = 0; i < MapEntity.mapEntityList.Count; i++) for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
{ {
var structure = MapEntity.mapEntityList[i] as Structure; if (MapEntity.mapEntityList[i].DrawDamageEffect)
if (structure == null || structure.Sprite.Depth > 0.5f) continue; MapEntity.mapEntityList[i].DrawDamage(spriteBatch, damageEffect);
structure.Draw(spriteBatch, editing, false, 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++) 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); MapEntity.mapEntityList[i].Draw(spriteBatch, editing, true);
} }
} }
+2 -7
View File
@@ -53,14 +53,11 @@ namespace Barotrauma
damageStencil = TextureLoader.FromFile("Content/Map/walldamage.png"); damageStencil = TextureLoader.FromFile("Content/Map/walldamage.png");
damageEffect = content.Load<Effect>("damageshader"); damageEffect = content.Load<Effect>("damageshader");
// damageEffect.Parameters["cutoff"].SetValue(0.5f);
damageEffect.Parameters["xStencil"].SetValue(damageStencil); 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); lightBlur = new BlurEffect(blurEffect, 0.001f, 0.001f);
} }
public override void Select() public override void Select()
@@ -344,8 +341,6 @@ namespace Barotrauma
null, null, null, null,
damageEffect, damageEffect,
cam.Transform); cam.Transform);
damageEffect.Parameters["cutoff"].SetValue(-0.2f);
damageEffect.Parameters["multiplier"].SetValue(5.0f);
Submarine.DrawDamageable(spriteBatch, damageEffect); Submarine.DrawDamageable(spriteBatch, damageEffect);