diff --git a/.vs/Subsurface_Solution/v14/.suo b/.vs/Subsurface_Solution/v14/.suo index bde16e095..7133c7cba 100644 Binary files a/.vs/Subsurface_Solution/v14/.suo and b/.vs/Subsurface_Solution/v14/.suo differ diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 82497a89a..fe249eae7 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -297,19 +297,13 @@ namespace Barotrauma { return Create(file, position, null); } - - public static Character Create(CharacterInfo characterInfo, WayPoint spawnPoint, bool isNetworkPlayer = false) - { - return Create(characterInfo.File, spawnPoint.WorldPosition, characterInfo, isNetworkPlayer); - } - - - public static Character Create(CharacterInfo characterInfo, Vector2 position, bool isNetworkPlayer = false) + + public static Character Create(CharacterInfo characterInfo, Vector2 position, bool isNetworkPlayer = false, bool hasAi=true) { return Create(characterInfo.File, position, characterInfo, isNetworkPlayer); } - public static Character Create(string file, Vector2 position, CharacterInfo characterInfo = null, bool isNetworkPlayer = false) + public static Character Create(string file, Vector2 position, CharacterInfo characterInfo = null, bool isNetworkPlayer = false, bool hasAi=true) { if (file != humanConfigFile) { @@ -321,11 +315,9 @@ namespace Barotrauma } else { - if (isNetworkPlayer) + if (hasAi) { - var netCharacter = new Character(file, position, characterInfo, isNetworkPlayer); - - return netCharacter; + return new Character(file, position, characterInfo, isNetworkPlayer); } else { diff --git a/Subsurface/Source/Events/MonsterEvent.cs b/Subsurface/Source/Events/MonsterEvent.cs index 3fb31e7d0..abd22b1be 100644 --- a/Subsurface/Source/Events/MonsterEvent.cs +++ b/Subsurface/Source/Events/MonsterEvent.cs @@ -36,12 +36,12 @@ namespace Barotrauma for (int i = 0; i < amount; i++) { Vector2 position = (randomWayPoint == null) ? Vector2.Zero : FarseerPhysics.ConvertUnits.ToSimUnits(randomWayPoint.Position); - + //!!!!!!!!!!!!!!!!!! - //if (spawnDeep) - //{ - // position.Y = FarseerPhysics.ConvertUnits.ToSimUnits(Level.Loaded.Position.Y); - //} + if (spawnDeep) + { + position.Y -= 100.0f; + } position.X += Rand.Range(-0.5f, 0.5f); position.Y += Rand.Range(-0.5f, 0.5f); diff --git a/Subsurface/Source/GameSession/CrewManager.cs b/Subsurface/Source/GameSession/CrewManager.cs index 06acb234f..b946c5e1a 100644 --- a/Subsurface/Source/GameSession/CrewManager.cs +++ b/Subsurface/Source/GameSession/CrewManager.cs @@ -213,7 +213,7 @@ namespace Barotrauma //WayPoint randomWayPoint = WayPoint.GetRandom(SpawnType.Human); //Vector2 position = (randomWayPoint == null) ? Vector2.Zero : randomWayPoint.SimPosition; - Character character = Character.Create(characterInfos[i], waypoints[i]); + Character character = Character.Create(characterInfos[i], waypoints[i].WorldPosition); Character.Controlled = character; if (!character.Info.StartItemsGiven) diff --git a/Subsurface/Source/Map/Lights/ConvexHull.cs b/Subsurface/Source/Map/Lights/ConvexHull.cs index 0ccb93247..404b97d99 100644 --- a/Subsurface/Source/Map/Lights/ConvexHull.cs +++ b/Subsurface/Source/Map/Lights/ConvexHull.cs @@ -125,6 +125,18 @@ namespace Barotrauma.Lights vertices = points; } + public bool Intersects(Rectangle rect) + { + Rectangle transformedBounds = boundingBox; + if (parentEntity != null && parentEntity.Submarine != null) + { + transformedBounds.X += (int)parentEntity.Submarine.Position.X; + transformedBounds.Y += (int)parentEntity.Submarine.Position.Y; + } + + return transformedBounds.Intersects(rect); + } + private void CalculateShadowVertices(Vector2 lightSourcePos, bool los = true) { //compute facing of each edge, using N*L diff --git a/Subsurface/Source/Map/Lights/LightManager.cs b/Subsurface/Source/Map/Lights/LightManager.cs index e2234977e..f8e5d554d 100644 --- a/Subsurface/Source/Map/Lights/LightManager.cs +++ b/Subsurface/Source/Map/Lights/LightManager.cs @@ -69,6 +69,7 @@ namespace Barotrauma.Lights foreach (ConvexHull convexHull in ConvexHull.list) { + if (!convexHull.Intersects(camView)) continue; //if (!camView.Intersects(convexHull.BoundingBox)) continue; convexHull.DrawShadows(graphics, cam, pos, shadowTransform); @@ -109,7 +110,7 @@ namespace Barotrauma.Lights foreach (LightSource light in lights) { if (light.hullsInRange.Count == 0 || light.Color.A < 0.01f || light.Range < 1.0f) continue; - //if (!MathUtils.CircleIntersectsRectangle(light.Position, light.Range, viewRect)) continue; + if (!MathUtils.CircleIntersectsRectangle(light.WorldPosition, light.Range, viewRect)) continue; //clear alpha to 1 ClearAlphaToOne(graphics, spriteBatch); @@ -121,7 +122,7 @@ namespace Barotrauma.Lights foreach (ConvexHull ch in light.hullsInRange) { - //if (!MathUtils.CircleIntersectsRectangle(light.Position, light.Range, ch.BoundingBox)) continue; + if (!MathUtils.CircleIntersectsRectangle(light.Position, light.Range, ch.BoundingBox)) continue; //draw shadow ch.DrawShadows(graphics, cam, light, shadowTransform, false); } diff --git a/Subsurface/Source/Map/MapEntity.cs b/Subsurface/Source/Map/MapEntity.cs index 4698ce31a..4f0633b3e 100644 --- a/Subsurface/Source/Map/MapEntity.cs +++ b/Subsurface/Source/Map/MapEntity.cs @@ -507,8 +507,10 @@ namespace Barotrauma } } - foreach (MapEntity e in mapEntityList) + for (int i = 0; i - { - return x.Name.CompareTo(y.Name); - }); + //mapEntityList.Sort((x, y) => + //{ + // return x.Name.CompareTo(y.Name); + //}); } diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index ee373c18c..17b01c8fd 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -757,13 +757,13 @@ namespace Barotrauma.Networking for (int i = 0; i < ConnectedClients.Count; i++) { ConnectedClients[i].Character = Character.Create( - ConnectedClients[i].characterInfo, assignedWayPoints[i], true); + ConnectedClients[i].characterInfo, assignedWayPoints[i].WorldPosition, true); ConnectedClients[i].Character.GiveJobItems(assignedWayPoints[i]); } if (characterInfo != null) { - myCharacter = Character.Create(characterInfo, assignedWayPoints[assignedWayPoints.Length - 1]); + myCharacter = Character.Create(characterInfo, assignedWayPoints[assignedWayPoints.Length - 1].WorldPosition); Character.Controlled = myCharacter; myCharacter.GiveJobItems(assignedWayPoints[assignedWayPoints.Length - 1]); diff --git a/Subsurface/Source/Screens/LobbyScreen.cs b/Subsurface/Source/Screens/LobbyScreen.cs index 373f0b185..aed41e4ae 100644 --- a/Subsurface/Source/Screens/LobbyScreen.cs +++ b/Subsurface/Source/Screens/LobbyScreen.cs @@ -1,7 +1,4 @@ -using FarseerPhysics; -using FarseerPhysics.Dynamics; -using FarseerPhysics.Factories; -using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using System; using System.Collections.Generic; @@ -362,7 +359,7 @@ namespace Barotrauma UpdateCharacterLists(); } - graphics.Clear(Color.CornflowerBlue); + graphics.Clear(Color.Black); //GameMain.GameScreen.DrawMap(graphics, spriteBatch); @@ -370,7 +367,7 @@ namespace Barotrauma Sprite backGround = GameMain.GameSession.Map.CurrentLocation.Type.Background; spriteBatch.Draw(backGround.Texture, Vector2.Zero, null, Color.White, 0.0f, Vector2.Zero, - Math.Max((float)GameMain.GraphicsWidth / backGround.SourceRect.Width, (float)GameMain.GraphicsHeight / backGround.SourceRect.Width), SpriteEffects.None, 0.0f); + Math.Max((float)GameMain.GraphicsWidth / backGround.SourceRect.Width, (float)GameMain.GraphicsHeight / backGround.SourceRect.Height), SpriteEffects.None, 0.0f); topPanel.Draw(spriteBatch);