diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj index 972088085..52a82f5dc 100644 --- a/Subsurface/Barotrauma.csproj +++ b/Subsurface/Barotrauma.csproj @@ -571,10 +571,17 @@ PreserveNewest + + PreserveNewest + Designer + PreserveNewest Designer + + PreserveNewest + PreserveNewest @@ -854,12 +861,6 @@ PreserveNewest - - PreserveNewest - - - PreserveNewest - PreserveNewest @@ -1139,6 +1140,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/Subsurface/Content/Items/Tools/tools.xml b/Subsurface/Content/Items/Tools/tools.xml index 2cabcfb7b..2715ebadc 100644 --- a/Subsurface/Content/Items/Tools/tools.xml +++ b/Subsurface/Content/Items/Tools/tools.xml @@ -266,6 +266,8 @@ + + diff --git a/Subsurface/Content/Items/Weapons/bigexplosion.ogg b/Subsurface/Content/Items/Weapons/bigexplosion.ogg new file mode 100644 index 000000000..5e77693d0 Binary files /dev/null and b/Subsurface/Content/Items/Weapons/bigexplosion.ogg differ diff --git a/Subsurface/Content/Items/Weapons/depthcharge.xml b/Subsurface/Content/Items/Weapons/depthcharge.xml new file mode 100644 index 000000000..7e9e32f6b --- /dev/null +++ b/Subsurface/Content/Items/Weapons/depthcharge.xml @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Subsurface/Content/Items/Weapons/railgun.xml b/Subsurface/Content/Items/Weapons/railgun.xml index 401da541e..6e00a6e75 100644 --- a/Subsurface/Content/Items/Weapons/railgun.xml +++ b/Subsurface/Content/Items/Weapons/railgun.xml @@ -32,7 +32,7 @@ linkable="true" pickdistance="150"> - + @@ -54,13 +54,12 @@ linkable="true" pickdistance="150"> - + - - + - + diff --git a/Subsurface/Content/Items/Weapons/railguncontroller.png b/Subsurface/Content/Items/Weapons/railguncontroller.png deleted file mode 100644 index 725051347..000000000 Binary files a/Subsurface/Content/Items/Weapons/railguncontroller.png and /dev/null differ diff --git a/Subsurface/Content/Items/Weapons/railgunetc.png b/Subsurface/Content/Items/Weapons/railgunetc.png new file mode 100644 index 000000000..980f272ae Binary files /dev/null and b/Subsurface/Content/Items/Weapons/railgunetc.png differ diff --git a/Subsurface/Content/Items/Weapons/railgunloader.png b/Subsurface/Content/Items/Weapons/railgunloader.png deleted file mode 100644 index 76cbaf2db..000000000 Binary files a/Subsurface/Content/Items/Weapons/railgunloader.png and /dev/null differ diff --git a/Subsurface/Source/Items/Components/Projectile.cs b/Subsurface/Source/Items/Components/Projectile.cs index e82bfe08f..c36601c20 100644 --- a/Subsurface/Source/Items/Components/Projectile.cs +++ b/Subsurface/Source/Items/Components/Projectile.cs @@ -172,6 +172,7 @@ namespace Barotrauma.Items.Components } ApplyStatusEffects(ActionType.OnUse, 1.0f); + ApplyStatusEffects(ActionType.OnImpact, 1.0f); item.body.FarseerBody.OnCollision -= OnProjectileCollision; diff --git a/Subsurface/Source/Items/Components/Turret.cs b/Subsurface/Source/Items/Components/Turret.cs index f4d7925bd..5f91fae90 100644 --- a/Subsurface/Source/Items/Components/Turret.cs +++ b/Subsurface/Source/Items/Components/Turret.cs @@ -75,8 +75,19 @@ namespace Barotrauma.Items.Components { IsActive = true; - barrelSprite = new Sprite(Path.GetDirectoryName(item.Prefab.ConfigFile) + "/" +element.Attribute("barrelsprite").Value, - ToolBox.GetAttributeVector2(element, "origin", Vector2.Zero)); + string barrelSpritePath = ToolBox.GetAttributeString(element, "barrelsprite", ""); + + if (!string.IsNullOrWhiteSpace(barrelSpritePath)) + { + if (!barrelSpritePath.Contains("/")) + { + barrelSpritePath = Path.Combine(Path.GetDirectoryName(item.Prefab.ConfigFile), barrelSpritePath); + } + + barrelSprite = new Sprite( + barrelSpritePath, + ToolBox.GetAttributeVector2(element, "origin", Vector2.Zero)); + } } public override void Draw(SpriteBatch spriteBatch, bool editing = false) @@ -85,10 +96,13 @@ namespace Barotrauma.Items.Components if (item.Submarine != null) drawPos += item.Submarine.DrawPosition; drawPos.Y = -drawPos.Y; - barrelSprite.Draw(spriteBatch, - drawPos + barrelPos, Color.White, - rotation + MathHelper.PiOver2, 1.0f, - SpriteEffects.None, item.Sprite.Depth+0.01f); + if (barrelSprite!=null) + { + barrelSprite.Draw(spriteBatch, + drawPos + barrelPos, Color.White, + rotation + MathHelper.PiOver2, 1.0f, + SpriteEffects.None, item.Sprite.Depth+0.01f); + } if (!editing) return; @@ -169,6 +183,8 @@ namespace Barotrauma.Items.Components Item projectile = projectiles[0].Item; + projectile.Drop(); + projectile.body.ResetDynamics(); projectile.body.Enabled = true; projectile.SetTransform(ConvertUnits.ToSimUnits(new Vector2(item.WorldRect.X + barrelPos.X, item.WorldRect.Y - barrelPos.Y)), -rotation); @@ -298,7 +314,7 @@ namespace Barotrauma.Items.Components { base.RemoveComponentSpecific(); - barrelSprite.Remove(); + if (barrelSprite != null) barrelSprite.Remove(); } private List GetLoadedProjectiles(bool returnFirst = false) diff --git a/Subsurface/Source/Map/Lights/ConvexHull.cs b/Subsurface/Source/Map/Lights/ConvexHull.cs index bc37d6308..be5443e8e 100644 --- a/Subsurface/Source/Map/Lights/ConvexHull.cs +++ b/Subsurface/Source/Map/Lights/ConvexHull.cs @@ -13,7 +13,7 @@ namespace Barotrauma.Lights public Vector2 LightPos; - public int ShadowVertexCount;//, PenumbraVertexCount; + public int ShadowVertexCount, PenumbraVertexCount; public CachedShadow(VertexPositionColor[] shadowVertices, Vector2 lightPos, int shadowVertexCount, int penumbraVertexCount) { @@ -24,7 +24,7 @@ namespace Barotrauma.Lights ShadowBuffer.SetData(shadowVertices, 0, shadowVertices.Length); ShadowVertexCount = shadowVertexCount; - //PenumbraVertexCount = penumbraVertexCount; + PenumbraVertexCount = penumbraVertexCount; LightPos = lightPos; } @@ -46,7 +46,8 @@ namespace Barotrauma.Lights { public static List list = new List(); static BasicEffect shadowEffect; - + static BasicEffect penumbraEffect; + private Dictionary cachedShadows; private Vector2[] vertices; @@ -56,6 +57,7 @@ namespace Barotrauma.Lights private bool[] backFacing; private VertexPositionColor[] shadowVertices; + private VertexPositionTexture[] penumbraVertices; int shadowVertexCount; @@ -87,21 +89,21 @@ namespace Barotrauma.Lights shadowEffect = new BasicEffect(GameMain.CurrGraphicsDevice); shadowEffect.VertexColorEnabled = true; } - //if (penumbraEffect == null) - //{ - // penumbraEffect = new BasicEffect(GameMain.CurrGraphicsDevice); - // penumbraEffect.TextureEnabled = true; - // //shadowEffect.VertexColorEnabled = true; - // penumbraEffect.LightingEnabled = false; - // penumbraEffect.Texture = TextureLoader.FromFile("Content/Lights/penumbra.png"); - //} + if (penumbraEffect == null) + { + penumbraEffect = new BasicEffect(GameMain.CurrGraphicsDevice); + penumbraEffect.TextureEnabled = true; + //shadowEffect.VertexColorEnabled = true; + penumbraEffect.LightingEnabled = false; + penumbraEffect.Texture = TextureLoader.FromFile("Content/Lights/penumbra.png"); + } parentEntity = parent; cachedShadows = new Dictionary(); shadowVertices = new VertexPositionColor[6 * 2]; - //penumbraVertices = new VertexPositionTexture[6]; + penumbraVertices = new VertexPositionTexture[6]; //vertices = points; primitiveCount = points.Length; @@ -151,7 +153,7 @@ namespace Barotrauma.Lights vertices = points; losVertices = points; - int margin = 7; + int margin = 0; if (Math.Abs(points[0].X - points[2].X) < Math.Abs(points[0].Y - points[1].Y)) { @@ -283,6 +285,54 @@ namespace Barotrauma.Lights svCount += 2; currentIndex = (currentIndex + 1) % primitiveCount; } + + if (los) + { + CalculatePenumbraVertices(startingIndex, endingIndex, lightSourcePos, los); + } + } + + private void CalculatePenumbraVertices(int startingIndex, int endingIndex, Vector2 lightSourcePos, bool los) + { + for (int n = 0; n < 4; n += 3) + { + Vector3 penumbraStart = new Vector3((n == 0) ? vertices[startingIndex] : vertices[endingIndex], 0.0f); + + penumbraVertices[n] = new VertexPositionTexture(); + penumbraVertices[n].Position = penumbraStart; + penumbraVertices[n].TextureCoordinate = new Vector2(0.0f, 1.0f); + //penumbraVertices[0].te = fow ? Color.Black : Color.Transparent; + + for (int i = 0; i < 2; i++) + { + penumbraVertices[n + i + 1] = new VertexPositionTexture(); + Vector3 vertexDir = penumbraStart - new Vector3(lightSourcePos, 0); + vertexDir.Normalize(); + + Vector3 normal = (i == 0) ? new Vector3(-vertexDir.Y, vertexDir.X, 0.0f) : new Vector3(vertexDir.Y, -vertexDir.X, 0.0f) * 0.05f; + if (n > 0) normal = -normal; + + vertexDir = penumbraStart - (new Vector3(lightSourcePos, 0) - normal * 20.0f); + vertexDir.Normalize(); + penumbraVertices[n + i + 1].Position = new Vector3(lightSourcePos, 0) + vertexDir * 9000; + + if (los) + { + penumbraVertices[n + i + 1].TextureCoordinate = (i == 0) ? new Vector2(0.05f, 0.0f) : new Vector2(1.0f, 0.0f); + } + else + { + penumbraVertices[n + i + 1].TextureCoordinate = (i == 0) ? new Vector2(1.0f, 0.0f) : Vector2.Zero; + } + } + + if (n > 0) + { + var temp = penumbraVertices[4]; + penumbraVertices[4] = penumbraVertices[5]; + penumbraVertices[5] = temp; + } + } } public void DrawShadows(GraphicsDevice graphicsDevice, Camera cam, LightSource light, Matrix transform, bool los = true) @@ -345,24 +395,37 @@ namespace Barotrauma.Lights if (los) { shadowEffect.CurrentTechnique.Passes[0].Apply(); - graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, shadowVertices, 0, shadowVertexCount * 2 - 2); + graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleStrip, shadowVertices, 0, shadowVertexCount * 2 - 2, VertexPositionColor.VertexDeclaration); } else { shadowEffect.CurrentTechnique.Passes[0].Apply(); graphicsDevice.DrawPrimitives(PrimitiveType.TriangleStrip, 0, shadowVertexCount * 2 - 2); - } + } + } + + + if (los) + { + penumbraEffect.World = shadowEffect.World; + penumbraEffect.CurrentTechnique.Passes[0].Apply(); + +#if WINDOWS + graphicsDevice.DrawUserPrimitives(PrimitiveType.TriangleList, penumbraVertices, 0, 2, VertexPositionTexture.VertexDeclaration); +#endif + } + } public void Remove() { - - ClearCachedShadows(); list.Remove(this); } + + } } diff --git a/Subsurface/Source/Map/Lights/LightManager.cs b/Subsurface/Source/Map/Lights/LightManager.cs index 4cebf7238..21093cc70 100644 --- a/Subsurface/Source/Map/Lights/LightManager.cs +++ b/Subsurface/Source/Map/Lights/LightManager.cs @@ -69,47 +69,6 @@ namespace Barotrauma.Lights lights.Remove(light); } - public void DrawLOS(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam, Effect effect) - { - if (!LosEnabled || ViewTarget==null) return; - - //Vector2 pos = ViewTarget.WorldPosition; - - //Rectangle camView = new Rectangle(cam.WorldView.X, cam.WorldView.Y - cam.WorldView.Height, cam.WorldView.Width, cam.WorldView.Height); - - //Matrix shadowTransform = cam.ShaderTransform - // * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f; - - //graphics.SetRenderTarget(losTexture); - //graphics.Clear(Color.Transparent); - - //foreach (ConvexHull convexHull in ConvexHull.list) - //{ - // if (!convexHull.Intersects(camView)) continue; - // //if (!camView.Intersects(convexHull.BoundingBox)) continue; - - // convexHull.DrawShadows(graphics, cam, pos, shadowTransform); - //} - - //graphics.SetRenderTarget(null); - - //if (!ObstructVision) return; - - //spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.Multiplicative); - //spriteBatch.Draw(losTexture, Vector2.Zero); - //spriteBatch.End(); - - - - spriteBatch.Begin(SpriteSortMode.Deferred, ObstructVision ? CustomBlendStates.Multiplicative : BlendState.AlphaBlend, null, null, null, effect); - //effect.CurrentTechnique.Passes[0].Apply(); - spriteBatch.Draw(losTexture, Vector2.Zero, Color.White); - spriteBatch.End(); - - ObstructVision = false; - - } - public void OnMapLoaded() { foreach (LightSource light in lights) @@ -191,11 +150,11 @@ namespace Barotrauma.Lights graphics.SetRenderTarget(losTexture); + spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, cam.Transform); + if (ObstructVision) { - graphics.Clear(Color.Black); - - spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, cam.Transform); + //graphics.Clear(Color.Black); Vector2 diff = lookAtPosition - ViewTarget.WorldPosition; diff.Y = -diff.Y; @@ -205,14 +164,16 @@ namespace Barotrauma.Lights spriteBatch.Draw(visionCircle, new Vector2(ViewTarget.WorldPosition.X, -ViewTarget.WorldPosition.Y), null, Color.White, rotation, new Vector2(LightSource.LightTexture.Width*0.2f, LightSource.LightTexture.Height/2), scale, SpriteEffects.None, 0.0f); - spriteBatch.End(); + } else { - graphics.Clear(Color.Transparent); + graphics.Clear(Color.White); } + spriteBatch.End(); + //-------------------------------------- if (LosEnabled && ViewTarget != null) @@ -232,7 +193,6 @@ namespace Barotrauma.Lights convexHull.DrawShadows(graphics, cam, pos, shadowTransform); } } - graphics.SetRenderTarget(null); } @@ -253,7 +213,16 @@ namespace Barotrauma.Lights spriteBatch.End(); } + public void DrawLOS(GraphicsDevice graphics, SpriteBatch spriteBatch, Camera cam, Effect effect) + { + if (!LosEnabled || ViewTarget == null) return; + spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.Multiplicative, null, null, null); + spriteBatch.Draw(losTexture, Vector2.Zero, Color.White); + spriteBatch.End(); + + ObstructVision = false; + } public void ClearLights() { diff --git a/Subsurface/Source/Map/StructurePrefab.cs b/Subsurface/Source/Map/StructurePrefab.cs index 03f683c42..abedc550c 100644 --- a/Subsurface/Source/Map/StructurePrefab.cs +++ b/Subsurface/Source/Map/StructurePrefab.cs @@ -94,7 +94,7 @@ namespace Barotrauma MapEntityCategory category; - if (!Enum.TryParse(ToolBox.GetAttributeString(element, "category", "Misc"), true, out category)) + if (!Enum.TryParse(ToolBox.GetAttributeString(element, "category", "Structure"), true, out category)) { category = MapEntityCategory.Structure; }