- The commonness of scripted events can be overridden for specific level types (e.g. some monsters can be set to spawn more frequently in specific types of levels).

- The sub can be moved from location to another in the map view by double clicking in debug builds.
- Level wall color can be changed in level generation parameters.
- Fixed level geometry not being rendered if the ocean floor is visible (which isn't a problem in most level types, but there can be levels where the ocean floor is so close to the actual level that they can both be visible at the same time).
- Background sprite scale is taken into account when calculating particle emitter positions.
- Fixed limb lights being rendered even if the character is disabled.
This commit is contained in:
Joonas Rikkonen
2017-08-22 18:58:45 +03:00
parent d772049cc0
commit 15a31c5291
9 changed files with 83 additions and 28 deletions
@@ -255,7 +255,7 @@ namespace Barotrauma
{ {
if (s.Prefab.ParticleEmitterPrefab != null) if (s.Prefab.ParticleEmitterPrefab != null)
{ {
Vector2 emitterPos = new Vector2(s.Prefab.EmitterPosition.X, s.Prefab.EmitterPosition.Y); Vector2 emitterPos = new Vector2(s.Prefab.EmitterPosition.X, s.Prefab.EmitterPosition.Y) * s.Scale;
if (s.Rotation != 0.0f || s.Prefab.SwingAmount != 0.0f) if (s.Rotation != 0.0f || s.Prefab.SwingAmount != 0.0f)
{ {
@@ -261,14 +261,24 @@ namespace Barotrauma
{ {
if (wallVertices == null) return; if (wallVertices == null) return;
bool renderLevel = cam.WorldView.Y >= 0.0f;
bool renderSeaFloor = cam.WorldView.Y - cam.WorldView.Height < level.SeaFloorTopPos + 1024;
if (!renderLevel && !renderSeaFloor) return;
wallEdgeEffect.World = cam.ShaderTransform wallEdgeEffect.World = cam.ShaderTransform
* Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 100) * 0.5f; * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 100) * 0.5f;
wallCenterEffect.World = wallEdgeEffect.World; wallCenterEffect.World = wallEdgeEffect.World;
//render the solid center of the wall cells
graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap; graphicsDevice.SamplerStates[0] = SamplerState.LinearWrap;
wallCenterEffect.CurrentTechnique.Passes[0].Apply(); wallCenterEffect.CurrentTechnique.Passes[0].Apply();
if (GameMain.GameScreen.Cam.WorldView.Y - GameMain.GameScreen.Cam.WorldView.Height < level.SeaFloorTopPos + 1024)
if (renderLevel)
{
graphicsDevice.SetVertexBuffer(bodyVertices);
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Math.Floor(bodyVertices.VertexCount / 3.0f));
}
if (renderSeaFloor)
{ {
foreach (LevelWall wall in level.ExtraWalls) foreach (LevelWall wall in level.ExtraWalls)
{ {
@@ -276,16 +286,16 @@ namespace Barotrauma
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Math.Floor(wall.BodyVertices.VertexCount / 3.0f)); graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Math.Floor(wall.BodyVertices.VertexCount / 3.0f));
} }
} }
else
{
graphicsDevice.SetVertexBuffer(bodyVertices);
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Math.Floor(bodyVertices.VertexCount / 3.0f));
}
//render the edges of the wall cells
wallEdgeEffect.CurrentTechnique.Passes[0].Apply(); wallEdgeEffect.CurrentTechnique.Passes[0].Apply();
if (GameMain.GameScreen.Cam.WorldView.Y - GameMain.GameScreen.Cam.WorldView.Height < level.SeaFloorTopPos + 1024) if (renderLevel)
{
wallEdgeEffect.CurrentTechnique.Passes[0].Apply();
graphicsDevice.SetVertexBuffer(wallVertices);
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Math.Floor(wallVertices.VertexCount / 3.0f));
}
if (renderSeaFloor)
{ {
foreach (LevelWall wall in level.ExtraWalls) foreach (LevelWall wall in level.ExtraWalls)
{ {
@@ -293,11 +303,6 @@ namespace Barotrauma
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Math.Floor(wall.WallVertices.VertexCount / 3.0f)); graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Math.Floor(wall.WallVertices.VertexCount / 3.0f));
} }
} }
else
{
graphicsDevice.SetVertexBuffer(wallVertices);
graphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, (int)Math.Floor(wallVertices.VertexCount / 3.0f));
}
} }
public void Dispose() public void Dispose()
@@ -151,7 +151,7 @@ namespace Barotrauma.Lights
foreach (LightSource light in lights) foreach (LightSource light in lights)
{ {
if (light.Color.A < 1 || light.Range < 1.0f || !light.CastShadows) continue; if (light.Color.A < 1 || light.Range < 1.0f || !light.CastShadows || !light.Enabled) continue;
if (!MathUtils.CircleIntersectsRectangle(light.WorldPosition, light.Range, viewRect)) continue; if (!MathUtils.CircleIntersectsRectangle(light.WorldPosition, light.Range, viewRect)) continue;
light.Draw(spriteBatch, lightEffect, transform); light.Draw(spriteBatch, lightEffect, transform);
@@ -116,6 +116,8 @@ namespace Barotrauma.Lights
} }
} }
public bool Enabled = true;
public LightSource (XElement element) public LightSource (XElement element)
: this(Vector2.Zero, 100.0f, Color.White, null) : this(Vector2.Zero, 100.0f, Color.White, null)
{ {
@@ -49,6 +49,13 @@ namespace Barotrauma
GameMain.LobbyScreen.SelectLocation(highlightedLocation, connection); GameMain.LobbyScreen.SelectLocation(highlightedLocation, connection);
} }
} }
#if DEBUG
if (PlayerInput.DoubleClicked() && highlightedLocation != null)
{
currentLocation = highlightedLocation;
}
#endif
} }
} }
@@ -116,9 +123,11 @@ namespace Barotrauma
new Vector2(0, 30), SpriteEffects.None, 0.01f); new Vector2(0, 30), SpriteEffects.None, 0.01f);
} }
//TODO: remove if (GameMain.DebugDraw)
Vector2 center = rectCenter + (connection.CenterPos + offset) * scale; {
GUI.DrawString(spriteBatch, center, connection.Biome.Name, Color.White); Vector2 center = rectCenter + (connection.CenterPos + offset) * scale;
GUI.DrawString(spriteBatch, center, connection.Biome.Name, Color.White);
}
} }
rect.Inflate(8, 8); rect.Inflate(8, 8);
@@ -41,6 +41,12 @@ namespace Barotrauma
{ {
limb.body.Enabled = enabled; limb.body.Enabled = enabled;
} }
#if CLIENT
if (limb.LightSource != null)
{
limb.LightSource.Enabled = enabled;
}
#endif
} }
AnimController.Collider.Enabled = value; AnimController.Collider.Enabled = value;
} }
@@ -1,4 +1,5 @@
using System; using System;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Xml.Linq; using System.Xml.Linq;
@@ -15,6 +16,8 @@ namespace Barotrauma
protected bool isFinished; protected bool isFinished;
public Dictionary<string, int> OverrideCommonness;
public string Name public string Name
{ {
get { return name; } get { return name; }
@@ -65,6 +68,22 @@ namespace Barotrauma
commonness = ToolBox.GetAttributeInt(element, "commonness", 1); commonness = ToolBox.GetAttributeInt(element, "commonness", 1);
MusicType = ToolBox.GetAttributeString(element, "musictype", "default"); MusicType = ToolBox.GetAttributeString(element, "musictype", "default");
OverrideCommonness = new Dictionary<string, int>();
foreach (XElement subElement in element.Elements())
{
switch (subElement.Name.ToString().ToLowerInvariant())
{
case "overridecommonness":
string levelType = ToolBox.GetAttributeString(subElement, "leveltype", "");
if (!OverrideCommonness.ContainsKey(levelType))
{
OverrideCommonness.Add(levelType, ToolBox.GetAttributeInt(subElement, "commonness", 1));
}
break;
}
}
} }
@@ -71,10 +71,10 @@ namespace Barotrauma
private List<Ruin> ruins; private List<Ruin> ruins;
private Color backgroundColor; private Color backgroundColor;
private Color wallColor;
private LevelGenerationParams generationParams; private LevelGenerationParams generationParams;
public Vector2 StartPosition public Vector2 StartPosition
{ {
get { return startPosition; } get { return startPosition; }
@@ -146,6 +146,11 @@ namespace Barotrauma
get { return backgroundColor; } get { return backgroundColor; }
} }
public Color WallColor
{
get { return wallColor; }
}
public Level(string seed, float difficulty, LevelGenerationParams generationParams) public Level(string seed, float difficulty, LevelGenerationParams generationParams)
{ {
this.seed = seed; this.seed = seed;
@@ -450,7 +455,7 @@ namespace Barotrauma
} }
ruins = new List<Ruin>(); ruins = new List<Ruin>();
for (int i = 0; i<generationParams.RuinCount; i++) for (int i = 0; i < generationParams.RuinCount; i++)
{ {
GenerateRuin(mainPath); GenerateRuin(mainPath);
} }
@@ -464,8 +469,8 @@ namespace Barotrauma
bodies = CaveGenerator.GeneratePolygons(cellsWithBody, out triangles); bodies = CaveGenerator.GeneratePolygons(cellsWithBody, out triangles);
#if CLIENT #if CLIENT
renderer.SetBodyVertices(CaveGenerator.GenerateRenderVerticeList(triangles).ToArray(), Color.White); renderer.SetBodyVertices(CaveGenerator.GenerateRenderVerticeList(triangles).ToArray(), generationParams.WallColor);
renderer.SetWallVertices(CaveGenerator.GenerateWallShapes(cells), Color.White); renderer.SetWallVertices(CaveGenerator.GenerateWallShapes(cells), generationParams.WallColor);
#endif #endif
TopBarrier = BodyFactory.CreateEdge(GameMain.World, TopBarrier = BodyFactory.CreateEdge(GameMain.World,
@@ -96,6 +96,12 @@ namespace Barotrauma
set; set;
} }
public Color WallColor
{
get;
set;
}
[HasDefaultValue(1000, false)] [HasDefaultValue(1000, false)]
public int BackgroundSpriteAmount public int BackgroundSpriteAmount
{ {
@@ -277,6 +283,9 @@ namespace Barotrauma
Vector3 colorVector = ToolBox.GetAttributeVector3(element, "BackgroundColor", new Vector3(50, 46, 20)); Vector3 colorVector = ToolBox.GetAttributeVector3(element, "BackgroundColor", new Vector3(50, 46, 20));
BackgroundColor = new Color((int)colorVector.X, (int)colorVector.Y, (int)colorVector.Z); BackgroundColor = new Color((int)colorVector.X, (int)colorVector.Y, (int)colorVector.Z);
colorVector = ToolBox.GetAttributeVector3(element, "WallColor", new Vector3(255,255,255));
WallColor = new Color((int)colorVector.X, (int)colorVector.Y, (int)colorVector.Z);
VoronoiSiteInterval = ToolBox.GetAttributeVector2(element, "VoronoiSiteInterval", new Vector2(3000, 3000)); VoronoiSiteInterval = ToolBox.GetAttributeVector2(element, "VoronoiSiteInterval", new Vector2(3000, 3000));
VoronoiSiteVariance = ToolBox.GetAttributeVector2(element, "VoronoiSiteVariance", new Vector2(voronoiSiteInterval.X, voronoiSiteInterval.Y) * 0.4f); VoronoiSiteVariance = ToolBox.GetAttributeVector2(element, "VoronoiSiteVariance", new Vector2(voronoiSiteInterval.X, voronoiSiteInterval.Y) * 0.4f);