diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj index 52a82f5dc..181e4e0e0 100644 --- a/Subsurface/Barotrauma.csproj +++ b/Subsurface/Barotrauma.csproj @@ -117,7 +117,7 @@ - + diff --git a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs index 2a9b649c1..d5dbbfff1 100644 --- a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs +++ b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGetItem.cs @@ -58,6 +58,8 @@ namespace Barotrauma if (targetItem == null) return; } + if (moveToTarget == null) return; + if (Vector2.Distance(character.Position, moveToTarget.Position) < targetItem.PickDistance*2.0f) { int targetSlot = -1; diff --git a/Subsurface/Source/Characters/BackgroundSprite/BackgroundSpriteManager.cs b/Subsurface/Source/Characters/BackgroundSprite/BackgroundSpriteManager.cs index 457ecad00..a69c83229 100644 --- a/Subsurface/Source/Characters/BackgroundSprite/BackgroundSpriteManager.cs +++ b/Subsurface/Source/Characters/BackgroundSprite/BackgroundSpriteManager.cs @@ -92,7 +92,7 @@ namespace Barotrauma int x = (int)Math.Floor(((Vector2)pos).X / GridSize); if (x<0 || x >= sprites.GetLength(0)) continue; int y = (int)Math.Floor(((Vector2)pos).Y / GridSize); - if (y<0 || 1 >= sprites.GetLength(1)) continue; + if (y<0 || y >= sprites.GetLength(1)) continue; sprites[x,y].Add(newSprite); } diff --git a/Subsurface/Source/GUI/TitleScreen.cs b/Subsurface/Source/GUI/LoadingScreen.cs similarity index 100% rename from Subsurface/Source/GUI/TitleScreen.cs rename to Subsurface/Source/GUI/LoadingScreen.cs diff --git a/Subsurface/Source/GameSession/GameSession.cs b/Subsurface/Source/GameSession/GameSession.cs index ecffffafa..20d2660fd 100644 --- a/Subsurface/Source/GameSession/GameSession.cs +++ b/Subsurface/Source/GameSession/GameSession.cs @@ -146,6 +146,7 @@ namespace Barotrauma TaskManager.StartShift(level); GameMain.GameScreen.ColorFade(Color.Black, Color.TransparentBlack, 5.0f); + SoundPlayer.SwitchMusic(); } public void EndShift(string endMessage) diff --git a/Subsurface/Source/Map/Levels/LevelRenderer.cs b/Subsurface/Source/Map/Levels/LevelRenderer.cs index 088977214..8f4a8a9b3 100644 --- a/Subsurface/Source/Map/Levels/LevelRenderer.cs +++ b/Subsurface/Source/Map/Levels/LevelRenderer.cs @@ -182,7 +182,7 @@ namespace Barotrauma spriteBatch.Draw(shaftTexture, new Rectangle((int)(MathUtils.Round(pos.X, 512.0f)), (int)pos.Y, width, 512), new Rectangle(0, 0, width, 256), - Color.White, 0.0f, + level.BackgroundColor, 0.0f, Vector2.Zero, SpriteEffects.None, 0.0f); } diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs index b045ef892..f5c818939 100644 --- a/Subsurface/Source/Screens/GameScreen.cs +++ b/Subsurface/Source/Screens/GameScreen.cs @@ -310,12 +310,19 @@ namespace Barotrauma Submarine.DrawFront(spriteBatch); - if (Level.Loaded!=null) Level.Loaded.DrawFront(spriteBatch); - spriteBatch.End(); GameMain.LightManager.DrawLightMap(spriteBatch, cam, lightBlur.Effect); + spriteBatch.Begin(SpriteSortMode.BackToFront, + BlendState.AlphaBlend, SamplerState.LinearWrap, + null, null, null, + cam.Transform); + + if (Level.Loaded!=null) Level.Loaded.DrawFront(spriteBatch); + + spriteBatch.End(); + if (Character.Controlled != null) { GameMain.LightManager.DrawLOS(graphics, spriteBatch, cam, lightBlur.Effect); diff --git a/Subsurface/Source/Sounds/SoundPlayer.cs b/Subsurface/Source/Sounds/SoundPlayer.cs index fd73d1850..07f4da930 100644 --- a/Subsurface/Source/Sounds/SoundPlayer.cs +++ b/Subsurface/Source/Sounds/SoundPlayer.cs @@ -229,44 +229,7 @@ namespace Barotrauma { if (musicClips == null) return; - Task criticalTask = null; - if (GameMain.GameSession!=null && GameMain.GameSession.TaskManager != null) - { - foreach (Task task in GameMain.GameSession.TaskManager.Tasks) - { - if (!task.IsStarted) continue; - if (criticalTask == null || task.Priority > criticalTask.Priority) - { - criticalTask = task; - } - } - } - - List suitableMusic = null; - if (OverrideMusicType != null) - { - suitableMusic = musicClips.Where(x => x != null && x.type == OverrideMusicType).ToList(); - } - else if (Character.Controlled != null && Level.Loaded != null && Level.Loaded.Ruins.Any(r => r.Area.Contains(Character.Controlled.WorldPosition))) - { - suitableMusic = musicClips.Where(x => x != null && x.type == "ruins").ToList(); - } - else if (Submarine.Loaded != null && Submarine.Loaded.AtDamageDepth) - { - suitableMusic = musicClips.Where(x => x != null && x.type == "deep").ToList(); - } - else if (criticalTask == null) - { - suitableMusic = musicClips.Where(x => x != null && x.type == "default").ToList(); - } - else - { - suitableMusic = musicClips.Where(x => - x != null && - x.type == criticalTask.MusicType && - x.priorityRange.X < criticalTask.Priority && - x.priorityRange.Y > criticalTask.Priority).ToList(); - } + List suitableMusic = GetSuitableMusicClips(); if (suitableMusic.Count > 0 && !suitableMusic.Contains(currentMusic)) { @@ -297,6 +260,56 @@ namespace Barotrauma } } + public static void SwitchMusic() + { + var suitableMusic = GetSuitableMusicClips(); + + if (suitableMusic.Count > 1) + { + targetMusic = suitableMusic.Find(m => m != currentMusic); + } + } + + private static List GetSuitableMusicClips() + { + Task criticalTask = null; + if (GameMain.GameSession != null && GameMain.GameSession.TaskManager != null) + { + foreach (Task task in GameMain.GameSession.TaskManager.Tasks) + { + if (!task.IsStarted) continue; + if (criticalTask == null || task.Priority > criticalTask.Priority) + { + criticalTask = task; + } + } + } + + if (OverrideMusicType != null) + { + return musicClips.Where(x => x != null && x.type == OverrideMusicType).ToList(); + } + else if (Character.Controlled != null && Level.Loaded != null && Level.Loaded.Ruins.Any(r => r.Area.Contains(Character.Controlled.WorldPosition))) + { + return musicClips.Where(x => x != null && x.type == "ruins").ToList(); + } + else if (Submarine.Loaded != null && Submarine.Loaded.AtDamageDepth) + { + return musicClips.Where(x => x != null && x.type == "deep").ToList(); + } + else if (criticalTask == null) + { + return musicClips.Where(x => x != null && x.type == "default").ToList(); + } + + return musicClips.Where(x => + x != null && + x.type == criticalTask.MusicType && + x.priorityRange.X < criticalTask.Priority && + x.priorityRange.Y > criticalTask.Priority).ToList(); + + } + public static void PlaySplashSound(Vector2 worldPosition, float strength) { int splashIndex = MathHelper.Clamp((int)(strength + Rand.Range(-2,2)), 0, SplashSounds.Length-1);