Thermal artifact, mid-quest message popups, sortmode from immediate to deferred, saving bugfixes

This commit is contained in:
Regalis
2015-11-19 19:21:48 +02:00
parent 9b08201972
commit 35f05376b0
21 changed files with 155 additions and 56 deletions

View File

@@ -815,11 +815,13 @@ namespace Barotrauma
public void Draw(SpriteBatch spriteBatch)
{
if (renderer == null) return;
renderer.Draw(spriteBatch);
}
public void Render(GraphicsDevice graphicsDevice, Camera cam)
{
if (renderer == null) return;
renderer.Render(graphicsDevice, cam, vertices);
}

View File

@@ -76,7 +76,7 @@ namespace Barotrauma.Lights
if (!ObstructVision) return;
spriteBatch.Begin(SpriteSortMode.Immediate, CustomBlendStates.Multiplicative);
spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.Multiplicative);
spriteBatch.Draw(losTexture, Vector2.Zero);
spriteBatch.End();
@@ -128,13 +128,13 @@ namespace Barotrauma.Lights
//draw the light shape
//where Alpha is 0, nothing will be written
spriteBatch.Begin(SpriteSortMode.Immediate, CustomBlendStates.MultiplyWithAlpha, null, null, null, null, cam.Transform);
spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.MultiplyWithAlpha, null, null, null, null, cam.Transform);
light.Draw(spriteBatch);
spriteBatch.End();
}
ClearAlphaToOne(graphics, spriteBatch);
spriteBatch.Begin(SpriteSortMode.Immediate, CustomBlendStates.MultiplyWithAlpha, null, null, null, null, cam.Transform);
spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.MultiplyWithAlpha, null, null, null, null, cam.Transform);
foreach (LightSource light in lights)
{
@@ -161,7 +161,7 @@ namespace Barotrauma.Lights
graphics.SetRenderTarget(losTexture);
graphics.Clear(Color.Black);
spriteBatch.Begin(SpriteSortMode.Immediate, null, null, null, null, null, cam.Transform);
spriteBatch.Begin(SpriteSortMode.Deferred, null, null, null, null, null, cam.Transform);
Vector2 diff = lookAtPosition - ViewPos;
diff.Y = -diff.Y;
@@ -185,7 +185,7 @@ namespace Barotrauma.Lights
private void ClearAlphaToOne(GraphicsDevice graphics, SpriteBatch spriteBatch)
{
spriteBatch.Begin(SpriteSortMode.Immediate, CustomBlendStates.WriteToAlpha);
spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.WriteToAlpha);
spriteBatch.Draw(alphaClearTexture, new Rectangle(0, 0,graphics.Viewport.Width, graphics.Viewport.Height), Color.White);
spriteBatch.End();
}
@@ -195,7 +195,7 @@ namespace Barotrauma.Lights
if (!LightingEnabled) return;
//multiply scene with lightmap
spriteBatch.Begin(SpriteSortMode.Immediate, CustomBlendStates.Multiplicative);
spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.Multiplicative);
spriteBatch.Draw(lightMap, Vector2.Zero, Color.White);
spriteBatch.End();
}

View File

@@ -22,7 +22,8 @@ namespace Barotrauma
class Submarine : Entity
{
public const string SavePath = "Data/SavedSubs";
public static string SavePath = "Data" + System.IO.Path.DirectorySeparatorChar + "SavedSubs";
public static List<Submarine> SavedSubmarines = new List<Submarine>();
@@ -102,8 +103,12 @@ namespace Barotrauma
public Vector2 Speed
{
get { return subBody.Speed; }
set { subBody.Speed = value; }
get { return subBody==null ? Vector2.Zero : subBody.Speed; }
set
{
if (subBody == null) return;
subBody.Speed = value;
}
}
public List<Vector2> HullVertices
@@ -433,18 +438,13 @@ namespace Barotrauma
//saving/loading ----------------------------------------------------
public void Save()
public bool Save()
{
SaveAs(filePath);
return SaveAs(filePath);
}
public void SaveAs(string filePath)
public bool SaveAs(string filePath)
{
//if (filePath=="")
//{
// DebugConsole.ThrowError("No save file selected");
// return;
//}
XDocument doc = new XDocument(new XElement("Submarine"));
doc.Root.Add(new XAttribute("name", name));
@@ -464,13 +464,13 @@ namespace Barotrauma
catch (Exception e)
{
DebugConsole.ThrowError("Saving submarine ''" + filePath + "'' failed!", e);
return false;
}
//doc.Save(filePath);
return true;
}
public static void SaveCurrent(string fileName)
public static bool SaveCurrent(string fileName)
{
if (loaded==null)
{
@@ -478,7 +478,7 @@ namespace Barotrauma
// return;
}
loaded.SaveAs(SavePath+"/"+fileName);
return loaded.SaveAs(SavePath+System.IO.Path.DirectorySeparatorChar+fileName);
}
public static void Preload()
@@ -646,7 +646,12 @@ namespace Barotrauma
loaded = this;
}
public static Submarine Load(string fileName, string folder = SavePath)
public static Submarine Load(string fileName)
{
return Load(fileName, SavePath);
}
public static Submarine Load(string fileName, string folder)
{
Unload();

View File

@@ -129,6 +129,11 @@ namespace Barotrauma
private List<Vector2> GenerateConvexHull()
{
if (!Structure.wallList.Any())
{
return new List<Vector2>() { new Vector2(-1.0f, 1.0f), new Vector2(1.0f, 1.0f), new Vector2(0.0f, -1.0f) };
}
List<Vector2> points = new List<Vector2>();
Vector2 leftMost = Vector2.Zero;

View File

@@ -57,12 +57,12 @@ namespace Barotrauma
public void RenderBack(SpriteBatch spriteBatch, RenderTarget2D texture, float blurAmount = 0.0f)
{
spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap);
spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Opaque, SamplerState.LinearWrap, null, null, waterEffect);
waterEffect.CurrentTechnique = waterEffect.Techniques["WaterShader"];
waterEffect.Parameters["xWavePos"].SetValue(wavePos);
waterEffect.Parameters["xBlurDistance"].SetValue(blurAmount);
waterEffect.CurrentTechnique.Passes[0].Apply();
//waterEffect.CurrentTechnique.Passes[0].Apply();
wavePos.X += 0.0001f;
wavePos.Y += 0.0001f;
@@ -74,7 +74,6 @@ namespace Barotrauma
spriteBatch.Draw(texture, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White);
#endif
spriteBatch.End();
}