diff --git a/Subsurface/Content/Items/Artifacts/artifact.png b/Subsurface/Content/Items/Artifacts/artifact.png index 4d342d912..929a58777 100644 Binary files a/Subsurface/Content/Items/Artifacts/artifact.png and b/Subsurface/Content/Items/Artifacts/artifact.png differ diff --git a/Subsurface/Content/Items/Artifacts/artifacts.xml b/Subsurface/Content/Items/Artifacts/artifacts.xml index 111daf9f2..39eac13db 100644 --- a/Subsurface/Content/Items/Artifacts/artifacts.xml +++ b/Subsurface/Content/Items/Artifacts/artifacts.xml @@ -4,10 +4,25 @@ name="Skyholder Artifact" pickdistance="150"> - + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Subsurface/Content/Quests.xml b/Subsurface/Content/Quests.xml index 1adbaed14..f2009bf67 100644 --- a/Subsurface/Content/Quests.xml +++ b/Subsurface/Content/Quests.xml @@ -11,6 +11,17 @@ itemname="Skyholder Artifact"> + + + targets) { if (explosion != null) explosion.Explode(entity.SimPosition); + if (Fire) new FireSource(ConvertUnits.ToDisplayUnits(entity.SimPosition)); if (sound != null) sound.Play(1.0f, 1000.0f, ConvertUnits.ToDisplayUnits(entity.SimPosition)); diff --git a/Subsurface/Source/CoroutineManager.cs b/Subsurface/Source/CoroutineManager.cs index d536edad9..a9bb06ee5 100644 --- a/Subsurface/Source/CoroutineManager.cs +++ b/Subsurface/Source/CoroutineManager.cs @@ -73,7 +73,9 @@ namespace Barotrauma catch (Exception e) { - DebugConsole.ThrowError("Coroutine "+Coroutines[i]+" threw an exception: "+e.Message); +#if DEBUG + DebugConsole.ThrowError("Coroutine " + Coroutines[i] + " threw an exception: " + e.Message); +#endif Coroutines.RemoveAt(i); } diff --git a/Subsurface/Source/DebugConsole.cs b/Subsurface/Source/DebugConsole.cs index 448528576..0702b12a5 100644 --- a/Subsurface/Source/DebugConsole.cs +++ b/Subsurface/Source/DebugConsole.cs @@ -308,8 +308,7 @@ namespace Barotrauma DebugConsole.ThrowError("Illegal symbols in filename (../)"); return; } - Submarine.SaveCurrent(fileName +".sub"); - NewMessage("map saved", Color.Green); + if (Submarine.SaveCurrent(fileName +".sub")) NewMessage("map saved", Color.Green); break; case "loadmap": case "loadsub": diff --git a/Subsurface/Source/Events/Quests/MonsterQuest.cs b/Subsurface/Source/Events/Quests/MonsterQuest.cs index 7a62dd2d4..08f308a14 100644 --- a/Subsurface/Source/Events/Quests/MonsterQuest.cs +++ b/Subsurface/Source/Events/Quests/MonsterQuest.cs @@ -10,9 +10,11 @@ namespace Barotrauma { class MonsterQuest : Quest { - string monsterFile; + private string monsterFile; - Character monster; + private int state; + + private Character monster; public override Vector2 RadarPosition { @@ -31,6 +33,18 @@ namespace Barotrauma monster = new AICharacter(monsterFile, ConvertUnits.ToSimUnits(position+level.Position)); } + + public override void Update(float deltaTime) + { + switch (state) + { + case 0: + if (!monster.IsDead) return; + ShowMessage(state); + state = 1; + break; + } + } public override void End() { diff --git a/Subsurface/Source/Events/Quests/Quest.cs b/Subsurface/Source/Events/Quests/Quest.cs index 3e21fab28..5ee6c592a 100644 --- a/Subsurface/Source/Events/Quests/Quest.cs +++ b/Subsurface/Source/Events/Quests/Quest.cs @@ -25,6 +25,9 @@ namespace Barotrauma protected string radarLabel; + protected List headers; + protected List messages; + private int reward; public string Name @@ -69,6 +72,15 @@ namespace Barotrauma failureMessage = ToolBox.GetAttributeString(element, "failuremessage", ""); radarLabel = ToolBox.GetAttributeString(element, "radarlabel", ""); + + messages = new List(); + headers = new List(); + foreach (XElement subElement in element.Elements()) + { + if (subElement.Name.ToString().ToLower() != "message") continue; + headers.Add(ToolBox.GetAttributeString(subElement, "header", "")); + messages.Add(ToolBox.GetAttributeString(subElement, "text", "")); + } } public static Quest LoadRandom(Location[] locations, Random rand) @@ -142,8 +154,17 @@ namespace Barotrauma return null; } - public virtual void Start(Level level) + public virtual void Start(Level level) { } + + public virtual void Update(float deltaTime) { } + + public void ShowMessage(int index) { + if (index >= headers.Count && index >= messages.Count) return; + + new GUIMessageBox( + index < headers.Count ? headers[index] : "", + index < messages.Count ? messages[index] : ""); } /// diff --git a/Subsurface/Source/Events/Quests/SalvageQuest.cs b/Subsurface/Source/Events/Quests/SalvageQuest.cs index d7a3ae9ba..aaba18db4 100644 --- a/Subsurface/Source/Events/Quests/SalvageQuest.cs +++ b/Subsurface/Source/Events/Quests/SalvageQuest.cs @@ -14,6 +14,8 @@ namespace Barotrauma private Item item; + private int state; + public override Vector2 RadarPosition { get @@ -69,6 +71,23 @@ namespace Barotrauma //item.MoveWithLevel = true; } + public override void Update(float deltaTime) + { + switch (state) + { + case 0: + if (item.CurrentHull == null) return; + ShowMessage(state); + state = 1; + break; + case 1: + if (!Level.Loaded.AtEndPosition && !Level.Loaded.AtStartPosition) return; + ShowMessage(state); + state = 2; + break; + } + } + public override void End() { item.Remove(); diff --git a/Subsurface/Source/GameSession/GameModes/QuestMode.cs b/Subsurface/Source/GameSession/GameModes/QuestMode.cs index b02038dbc..acdac5151 100644 --- a/Subsurface/Source/GameSession/GameModes/QuestMode.cs +++ b/Subsurface/Source/GameSession/GameModes/QuestMode.cs @@ -38,12 +38,12 @@ namespace Barotrauma new GUIMessageBox(quest.Name, quest.Description, 400, 400); - quest.Start(Level.Loaded); + //quest.Start(Level.Loaded); } public override void End(string endMessage = "") { - quest.End(); + //quest.End(); base.End(endMessage); } diff --git a/Subsurface/Source/GameSession/GameModes/TutorialMode.cs b/Subsurface/Source/GameSession/GameModes/TutorialMode.cs index 415a456ac..53b0f5150 100644 --- a/Subsurface/Source/GameSession/GameModes/TutorialMode.cs +++ b/Subsurface/Source/GameSession/GameModes/TutorialMode.cs @@ -14,7 +14,7 @@ namespace Barotrauma public readonly CrewManager CrewManager; private GUIComponent infoBox; - + public static void StartTutorial() { Submarine.Load("Content/Map/TutorialSub.sub", ""); @@ -63,6 +63,7 @@ namespace Barotrauma CrewManager.AddCharacter(character); + //CoroutineManager.StartCoroutine(QuitChecker()); CoroutineManager.StartCoroutine(UpdateState()); } @@ -84,8 +85,9 @@ namespace Barotrauma if (infoBox!=null) infoBox.Update(deltaTime); } + private IEnumerable UpdateState() - { + { Submarine.Loaded.SetPosition(new Vector2(Submarine.Loaded.Position.X, 38500.0f)); //spawn some fish next to the player diff --git a/Subsurface/Source/GameSession/GameSession.cs b/Subsurface/Source/GameSession/GameSession.cs index ae784e255..d3ace9f02 100644 --- a/Subsurface/Source/GameSession/GameSession.cs +++ b/Subsurface/Source/GameSession/GameSession.cs @@ -172,6 +172,7 @@ namespace Barotrauma guiRoot.Update(deltaTime); if (gameMode != null) gameMode.Update(deltaTime); + if (Quest != null) Quest.Update(deltaTime); } public void Draw(SpriteBatch spriteBatch) diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index 7f902edb7..f48d5977a 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -18,7 +18,7 @@ namespace Barotrauma public enum ActionType { - OnPicked, OnWearing, OnContaining, OnContained, OnActive, OnUse, OnFailure, OnBroken, OnFire + Always, OnPicked, OnWearing, OnContaining, OnContained, OnActive, OnUse, OnFailure, OnBroken, OnFire } class Item : MapEntity, IDamageable, IPropertyObject diff --git a/Subsurface/Source/Map/Levels/Level.cs b/Subsurface/Source/Map/Levels/Level.cs index 98455b9cc..44b91ef75 100644 --- a/Subsurface/Source/Map/Levels/Level.cs +++ b/Subsurface/Source/Map/Levels/Level.cs @@ -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); } diff --git a/Subsurface/Source/Map/Lights/LightManager.cs b/Subsurface/Source/Map/Lights/LightManager.cs index 8633e2722..3dc367e43 100644 --- a/Subsurface/Source/Map/Lights/LightManager.cs +++ b/Subsurface/Source/Map/Lights/LightManager.cs @@ -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(); } diff --git a/Subsurface/Source/Map/Submarine.cs b/Subsurface/Source/Map/Submarine.cs index baf5dcc31..5289b6029 100644 --- a/Subsurface/Source/Map/Submarine.cs +++ b/Subsurface/Source/Map/Submarine.cs @@ -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 SavedSubmarines = new List(); @@ -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 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(); diff --git a/Subsurface/Source/Map/SubmarineBody.cs b/Subsurface/Source/Map/SubmarineBody.cs index 20dad48f6..dc03390e7 100644 --- a/Subsurface/Source/Map/SubmarineBody.cs +++ b/Subsurface/Source/Map/SubmarineBody.cs @@ -129,6 +129,11 @@ namespace Barotrauma private List GenerateConvexHull() { + if (!Structure.wallList.Any()) + { + return new List() { new Vector2(-1.0f, 1.0f), new Vector2(1.0f, 1.0f), new Vector2(0.0f, -1.0f) }; + } + List points = new List(); Vector2 leftMost = Vector2.Zero; diff --git a/Subsurface/Source/Map/WaterRenderer.cs b/Subsurface/Source/Map/WaterRenderer.cs index b1a1382bc..c774a3ee2 100644 --- a/Subsurface/Source/Map/WaterRenderer.cs +++ b/Subsurface/Source/Map/WaterRenderer.cs @@ -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(); } diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs index f53399678..dce192bf7 100644 --- a/Subsurface/Source/Screens/GameScreen.cs +++ b/Subsurface/Source/Screens/GameScreen.cs @@ -174,7 +174,7 @@ namespace Barotrauma graphics.SetRenderTarget(renderTarget); graphics.Clear(new Color(11, 18, 26, 255)); - spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearWrap); + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap); Vector2 backgroundPos = cam.Position; if (Level.Loaded != null) backgroundPos -= Level.Loaded.Position; @@ -203,8 +203,8 @@ namespace Barotrauma spriteBatch.End(); spriteBatch.Begin(SpriteSortMode.BackToFront, - BlendState.AlphaBlend, - SamplerState.LinearWrap, null, null, null, + BlendState.NonPremultiplied, + SamplerState.LinearWrap, DepthStencilState.Default, null, null, cam.Transform); BackgroundSpriteManager.Draw(spriteBatch); @@ -237,29 +237,27 @@ namespace Barotrauma spriteBatch.End(); - GameMain.LightManager.DrawLightMap(spriteBatch, cam); //---------------------------------------------------------------------------------------- //draw the rendertarget and particles that are only supposed to be drawn in water into renderTargetWater - graphics.SetRenderTarget(renderTargetWater); - spriteBatch.Begin(SpriteSortMode.Immediate, - BlendState.AlphaBlend); + spriteBatch.Begin(SpriteSortMode.Deferred, + BlendState.Opaque); spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), new Color(0.75f, 0.8f, 0.9f, 1.0f)); spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, - BlendState.AlphaBlend, - null, DepthStencilState.DepthRead, null, null, + spriteBatch.Begin(SpriteSortMode.Deferred, + BlendState.NonPremultiplied, + null, DepthStencilState.Default, null, null, cam.Transform); GameMain.ParticleManager.Draw(spriteBatch, true, Particles.ParticleBlendState.AlphaBlend); spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, - null, DepthStencilState.DepthRead, null, null, + null, DepthStencilState.Default, null, null, cam.Transform); GameMain.ParticleManager.Draw(spriteBatch, true, Particles.ParticleBlendState.Additive); spriteBatch.End(); @@ -268,19 +266,19 @@ namespace Barotrauma //draw the rendertarget and particles that are only supposed to be drawn in air into renderTargetAir graphics.SetRenderTarget(renderTargetAir); - spriteBatch.Begin(SpriteSortMode.Immediate, - BlendState.AlphaBlend); + spriteBatch.Begin(SpriteSortMode.Deferred, + BlendState.Opaque); spriteBatch.Draw(renderTarget, new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.White); spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, - BlendState.AlphaBlend, + spriteBatch.Begin(SpriteSortMode.Deferred, + BlendState.NonPremultiplied, null, DepthStencilState.DepthRead, null, null, cam.Transform); GameMain.ParticleManager.Draw(spriteBatch, false, Particles.ParticleBlendState.AlphaBlend); spriteBatch.End(); - spriteBatch.Begin(SpriteSortMode.Immediate, + spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.Additive, null, DepthStencilState.DepthRead, null, null, cam.Transform); diff --git a/Subsurface/Source/Utils/SaveUtil.cs b/Subsurface/Source/Utils/SaveUtil.cs index 327d8919b..abfd0e901 100644 --- a/Subsurface/Source/Utils/SaveUtil.cs +++ b/Subsurface/Source/Utils/SaveUtil.cs @@ -10,13 +10,13 @@ namespace Barotrauma { public class SaveUtil { - private const string SaveFolder = "Data/Saves/"; + private static string SaveFolder = "Data"+Path.DirectorySeparatorChar+"Saves"; public delegate void ProgressDelegate(string sMessage); public static void SaveGame(string fileName) { - fileName = SaveFolder + fileName; + fileName = Path.Combine(SaveFolder, fileName); string tempPath = Path.Combine(SaveFolder, "temp"); diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 2aac01813..dc61639bc 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ