From c064c5eb509e6bcd2a78664e2fe543e5ba9b8a03 Mon Sep 17 00:00:00 2001 From: Regalis Date: Thu, 3 Dec 2015 19:42:11 +0200 Subject: [PATCH] Very unfinished attempt at changing the coordinate system to work relative to the level and to move the sub instead of the whole level --- Subsurface/Barotrauma.csproj | 2 +- .../BackgroundSprite/BackgroundSprite.cs | 4 +- Subsurface/Source/Characters/Character.cs | 2 +- Subsurface/Source/Events/MonsterEvent.cs | 12 +- .../Source/Events/Quests/MonsterQuest.cs | 2 +- .../Source/Events/Quests/SalvageQuest.cs | 6 +- .../Source/Items/Components/Machines/Radar.cs | 224 +++++++++--------- Subsurface/Source/Map/Levels/Level.cs | 184 +++++++------- Subsurface/Source/Map/Levels/LevelRenderer.cs | 10 +- Subsurface/Source/Map/Lights/LightManager.cs | 6 +- Subsurface/Source/Map/Submarine.cs | 11 +- Subsurface/Source/Map/SubmarineBody.cs | 72 +++--- Subsurface/Source/Screens/GameScreen.cs | 12 +- Subsurface_Solution.v12.suo | Bin 800256 -> 800256 bytes 14 files changed, 278 insertions(+), 269 deletions(-) diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj index 890bf0651..7fad6b22c 100644 --- a/Subsurface/Barotrauma.csproj +++ b/Subsurface/Barotrauma.csproj @@ -74,7 +74,7 @@ - + diff --git a/Subsurface/Source/Characters/BackgroundSprite/BackgroundSprite.cs b/Subsurface/Source/Characters/BackgroundSprite/BackgroundSprite.cs index a13f75f2d..dead2e808 100644 --- a/Subsurface/Source/Characters/BackgroundSprite/BackgroundSprite.cs +++ b/Subsurface/Source/Characters/BackgroundSprite/BackgroundSprite.cs @@ -59,7 +59,7 @@ namespace Barotrauma this.position = position; - drawPosition = position + Level.Loaded.Position; + drawPosition = position; steeringManager = new SteeringManager(this); @@ -153,7 +153,7 @@ namespace Barotrauma if (velocity.X < 0.0f) rotation -= MathHelper.Pi; } - if (Level.Loaded != null) drawPosition = position + Level.Loaded.Position; + if (Level.Loaded != null) drawPosition = position;// +Level.Loaded.Position; if (depth > 0.0f) { diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index f6338ae59..53a9f3573 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -889,7 +889,7 @@ namespace Barotrauma if (Submarine.Loaded!=null && Level.Loaded !=null) { - protectedFromPressure = protectedFromPressure && (Position-Level.Loaded.Position).Y > SubmarineBody.DamageDepth; + protectedFromPressure = protectedFromPressure && Position.Y > SubmarineBody.DamageDepth; } if (!protectedFromPressure && diff --git a/Subsurface/Source/Events/MonsterEvent.cs b/Subsurface/Source/Events/MonsterEvent.cs index e16939bf2..3fb31e7d0 100644 --- a/Subsurface/Source/Events/MonsterEvent.cs +++ b/Subsurface/Source/Events/MonsterEvent.cs @@ -35,13 +35,13 @@ namespace Barotrauma for (int i = 0; i < amount; i++) { - Vector2 position = (randomWayPoint == null) ? Vector2.Zero : FarseerPhysics.ConvertUnits.ToSimUnits(randomWayPoint.Position + Level.Loaded.Position); + 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 = FarseerPhysics.ConvertUnits.ToSimUnits(Level.Loaded.Position.Y); + //} position.X += Rand.Range(-0.5f, 0.5f); position.Y += Rand.Range(-0.5f, 0.5f); diff --git a/Subsurface/Source/Events/Quests/MonsterQuest.cs b/Subsurface/Source/Events/Quests/MonsterQuest.cs index 860d926ed..d1e0ab8c6 100644 --- a/Subsurface/Source/Events/Quests/MonsterQuest.cs +++ b/Subsurface/Source/Events/Quests/MonsterQuest.cs @@ -31,7 +31,7 @@ namespace Barotrauma { Vector2 position = level.PositionsOfInterest[Rand.Int(level.PositionsOfInterest.Count, false)]; - monster = Character.Create(monsterFile, ConvertUnits.ToSimUnits(position+level.Position)); + monster = Character.Create(monsterFile, ConvertUnits.ToSimUnits(position)); } public override void Update(float deltaTime) diff --git a/Subsurface/Source/Events/Quests/SalvageQuest.cs b/Subsurface/Source/Events/Quests/SalvageQuest.cs index aaba18db4..b46c52dd7 100644 --- a/Subsurface/Source/Events/Quests/SalvageQuest.cs +++ b/Subsurface/Source/Events/Quests/SalvageQuest.cs @@ -47,8 +47,8 @@ namespace Barotrauma Vector2 tryPos = level.PositionsOfInterest[Rand.Int(level.PositionsOfInterest.Count, false)]; if (Submarine.PickBody( - tryPos + level.Position, - tryPos + level.Position - Vector2.UnitY*level.Size.Y, + tryPos, + tryPos - Vector2.UnitY*level.Size.Y, null, Physics.CollisionLevel) != null) { position = tryPos; @@ -65,7 +65,7 @@ namespace Barotrauma } while (tries < 10); - item = new Item(itemPrefab, position + level.Position); + item = new Item(itemPrefab, position); item.MoveWithLevel = true; item.body.FarseerBody.GravityScale = 0.5f; //item.MoveWithLevel = true; diff --git a/Subsurface/Source/Items/Components/Machines/Radar.cs b/Subsurface/Source/Items/Components/Machines/Radar.cs index 05a3e460b..ff74c3a86 100644 --- a/Subsurface/Source/Items/Components/Machines/Radar.cs +++ b/Subsurface/Source/Items/Components/Machines/Radar.cs @@ -116,159 +116,161 @@ namespace Barotrauma.Items.Components float simScale = 1.5f; - if (Level.Loaded != null) - { - List cells = Level.Loaded.GetCells(-Level.Loaded.Position, 7); + return; - foreach (VoronoiCell cell in cells) - { + //if (Level.Loaded != null) + //{ + // List cells = Level.Loaded.GetCells(Submarine.Loaded.Position, 7); - foreach (GraphEdge edge in cell.edges) - { - //if (!edge.isSolid) continue; - float cellDot = Vector2.Dot(cell.Center + Level.Loaded.Position, (edge.point1 + edge.point2) / 2.0f - cell.Center); - if (cellDot > 0) continue; + // foreach (VoronoiCell cell in cells) + // { - float facingDot = Vector2.Dot(Vector2.Normalize(edge.point1 - edge.point2), Vector2.Normalize(cell.Center + Level.Loaded.Position)); - facingDot = MathHelper.Clamp(facingDot, -1.0f, 1.0f); + // foreach (GraphEdge edge in cell.edges) + // { + // //if (!edge.isSolid) continue; + // float cellDot = Vector2.Dot(cell.Center + Level.Loaded.Position, (edge.point1 + edge.point2) / 2.0f - cell.Center); + // if (cellDot > 0) continue; - Vector2 point1 = (edge.point1 + Level.Loaded.Position); - Vector2 point2 = (edge.point2 + Level.Loaded.Position); + // float facingDot = Vector2.Dot(Vector2.Normalize(edge.point1 - edge.point2), Vector2.Normalize(cell.Center + Level.Loaded.Position)); + // facingDot = MathHelper.Clamp(facingDot, -1.0f, 1.0f); - float length = (point1 - point2).Length(); - for (float x=0; x radius) continue; - if (pointDist < prevPingRadius || pointDist > pingRadius) continue; + // float pointDist = point.Length() * displayScale; + + // if (pointDist > radius) continue; + // if (pointDist < prevPingRadius || pointDist > pingRadius) continue; - float step = 5.0f * (Math.Abs(facingDot)+1.0f); - float alpha = Rand.Range(1.5f, 2.0f); - for (float z = 0; z radius) continue; + // if (limb.SimPosition == Vector2.Zero || pointDist > radius) continue; - if (pointDist > radius) continue; - if (pointDist > prevPingRadius && pointDist < pingRadius) - { - var blip = new RadarBlip(pos - Level.Loaded.Position, 1.0f); - radarBlips.Add(blip); - } - } - } + // if (pointDist > radius) continue; + // if (pointDist > prevPingRadius && pointDist < pingRadius) + // { + // var blip = new RadarBlip(pos - Level.Loaded.Position, 1.0f); + // radarBlips.Add(blip); + // } + // } + //} - foreach (RadarBlip radarBlip in radarBlips) - { - DrawBlip(spriteBatch,radarBlip, center, Color.Green * radarBlip.FadeTimer, radius); - } - - prevPingRadius = pingRadius; - - if (screenOverlay!=null) - { - screenOverlay.Draw(spriteBatch, center, 0.0f, rect.Width/screenOverlay.size.X); - } + //foreach (RadarBlip radarBlip in radarBlips) + //{ + // DrawBlip(spriteBatch,radarBlip, center, Color.Green * radarBlip.FadeTimer, radius); + //} //prevPingRadius = pingRadius; - if (GameMain.GameSession == null) return; + //if (screenOverlay!=null) + //{ + // screenOverlay.Draw(spriteBatch, center, 0.0f, rect.Width/screenOverlay.size.X); + //} + + ////prevPingRadius = pingRadius; + + //if (GameMain.GameSession == null) return; - DrawMarker(spriteBatch, - (GameMain.GameSession.Map == null) ? "Start" : GameMain.GameSession.Map.CurrentLocation.Name, - (Level.Loaded.StartPosition + Level.Loaded.Position), displayScale, center, (rect.Width * 0.55f)); + //DrawMarker(spriteBatch, + // (GameMain.GameSession.Map == null) ? "Start" : GameMain.GameSession.Map.CurrentLocation.Name, + // (Level.Loaded.StartPosition + Level.Loaded.Position), displayScale, center, (rect.Width * 0.55f)); - DrawMarker(spriteBatch, - (GameMain.GameSession.Map == null) ? "End" : GameMain.GameSession.Map.SelectedLocation.Name, - (Level.Loaded.EndPosition + Level.Loaded.Position), displayScale, center, (rect.Width * 0.55f)); + //DrawMarker(spriteBatch, + // (GameMain.GameSession.Map == null) ? "End" : GameMain.GameSession.Map.SelectedLocation.Name, + // (Level.Loaded.EndPosition + Level.Loaded.Position), displayScale, center, (rect.Width * 0.55f)); - if (GameMain.GameSession.Quest != null) - { - var quest = GameMain.GameSession.Quest; + //if (GameMain.GameSession.Quest != null) + //{ + // var quest = GameMain.GameSession.Quest; - if (!string.IsNullOrWhiteSpace(quest.RadarLabel)) - { - DrawMarker(spriteBatch, - quest.RadarLabel, - quest.RadarPosition, displayScale, center, (rect.Width * 0.55f)); - } - } + // if (!string.IsNullOrWhiteSpace(quest.RadarLabel)) + // { + // DrawMarker(spriteBatch, + // quest.RadarLabel, + // quest.RadarPosition, displayScale, center, (rect.Width * 0.55f)); + // } + //} - if (!GameMain.DebugDraw) return; + //if (!GameMain.DebugDraw) return; - var steering = item.GetComponent(); - if (steering == null || steering.SteeringPath == null) return; + //var steering = item.GetComponent(); + //if (steering == null || steering.SteeringPath == null) return; - Vector2 prevPos = Vector2.Zero; + //Vector2 prevPos = Vector2.Zero; - foreach (WayPoint wp in steering.SteeringPath.Nodes) - { - Vector2 pos = (wp.Position - Submarine.Loaded.Position) * displayScale; - if (pos.Length() > radius) continue; + //foreach (WayPoint wp in steering.SteeringPath.Nodes) + //{ + // Vector2 pos = (wp.Position - Submarine.Loaded.Position) * displayScale; + // if (pos.Length() > radius) continue; - pos.Y = -pos.Y; - pos += center; + // pos.Y = -pos.Y; + // pos += center; - GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X -3 / 2, (int)pos.Y - 3, 6, 6), (steering.SteeringPath.CurrentNode==wp) ? Color.LightGreen : Color.Green, false); + // GUI.DrawRectangle(spriteBatch, new Rectangle((int)pos.X -3 / 2, (int)pos.Y - 3, 6, 6), (steering.SteeringPath.CurrentNode==wp) ? Color.LightGreen : Color.Green, false); - if (prevPos!=Vector2.Zero) - { - GUI.DrawLine(spriteBatch, pos, prevPos, Color.Green); - } + // if (prevPos!=Vector2.Zero) + // { + // GUI.DrawLine(spriteBatch, pos, prevPos, Color.Green); + // } - prevPos = pos; - } + // prevPos = pos; + //} - voltage = 0.0f; + //voltage = 0.0f; } private void DrawBlip(SpriteBatch spriteBatch, RadarBlip blip, Vector2 center, Color color, float radius) { - Vector2 pos = (blip.Position + Level.Loaded.Position) * displayScale; + Vector2 pos = (blip.Position) * displayScale; pos.Y = -pos.Y; if (pos.Length() > radius) diff --git a/Subsurface/Source/Map/Levels/Level.cs b/Subsurface/Source/Map/Levels/Level.cs index 8d8fc3c50..dc2f70655 100644 --- a/Subsurface/Source/Map/Levels/Level.cs +++ b/Subsurface/Source/Map/Levels/Level.cs @@ -77,15 +77,7 @@ namespace Barotrauma get; private set; } - - public Vector2 Position - { - get - { - return cells==null ? Vector2.Zero : ConvertUnits.ToDisplayUnits(cells[0].body.Position); - } - } - + public List PositionsOfInterest { get { return positionsOfInterest; } @@ -712,106 +704,106 @@ namespace Barotrauma return verticeList.ToArray(); } - public void SetPosition(Vector2 pos) - { - Vector2 amount = pos - Position; - Vector2 simAmount = ConvertUnits.ToSimUnits(amount); - //foreach (VoronoiCell cell in cells) - //{ - // if (cell.body == null) continue; - // cell.body.SleepingAllowed = false; - // cell.body.SetTransform(cell.body.Position + simAmount, cell.body.Rotation); - //} + //public void SetPosition(Vector2 pos) + //{ + // Vector2 amount = pos - Position; + // Vector2 simAmount = ConvertUnits.ToSimUnits(amount); + // //foreach (VoronoiCell cell in cells) + // //{ + // // if (cell.body == null) continue; + // // cell.body.SleepingAllowed = false; + // // cell.body.SetTransform(cell.body.Position + simAmount, cell.body.Rotation); + // //} - foreach (Body body in bodies) - { - body.SetTransform(body.Position + simAmount, body.Rotation); - } + // foreach (Body body in bodies) + // { + // body.SetTransform(body.Position + simAmount, body.Rotation); + // } - foreach (MapEntity mapEntity in MapEntity.mapEntityList) - { - Item item = mapEntity as Item; - if (item == null) - { - //if (!mapEntity.MoveWithLevel) continue; - //mapEntity.Move(amount); - } - else if (item.body != null) - { - if (item.CurrentHull != null) continue; - item.SetTransform(item.SimPosition+amount, item.body.Rotation); - } - } + // foreach (MapEntity mapEntity in MapEntity.mapEntityList) + // { + // Item item = mapEntity as Item; + // if (item == null) + // { + // //if (!mapEntity.MoveWithLevel) continue; + // //mapEntity.Move(amount); + // } + // else if (item.body != null) + // { + // if (item.CurrentHull != null) continue; + // item.SetTransform(item.SimPosition+amount, item.body.Rotation); + // } + // } - //WrappingWall.UpdateWallShift(Position, wrappingWalls); - } + // //WrappingWall.UpdateWallShift(Position, wrappingWalls); + //} - Vector2 prevVelocity; - public void Move(Vector2 amount) - { - Vector2 simVelocity = ConvertUnits.ToSimUnits(amount / (float)Physics.step); + //Vector2 prevVelocity; + //public void Move(Vector2 amount) + //{ + // Vector2 simVelocity = ConvertUnits.ToSimUnits(amount / (float)Physics.step); - foreach (Body body in bodies) - { - body.LinearVelocity = simVelocity; - } + // foreach (Body body in bodies) + // { + // body.LinearVelocity = simVelocity; + // } - foreach (Character character in Character.CharacterList) - { - foreach (Limb limb in character.AnimController.Limbs) - { - if (character.AnimController.CurrentHull != null) continue; + // foreach (Character character in Character.CharacterList) + // { + // foreach (Limb limb in character.AnimController.Limbs) + // { + // if (character.AnimController.CurrentHull != null) continue; - limb.body.LinearVelocity += simVelocity; - } - } + // limb.body.LinearVelocity += simVelocity; + // } + // } - foreach (Item item in Item.ItemList) - { - if (item.body==null || item.CurrentHull != null) continue; - item.body.LinearVelocity += simVelocity; - } + // foreach (Item item in Item.ItemList) + // { + // if (item.body==null || item.CurrentHull != null) continue; + // item.body.LinearVelocity += simVelocity; + // } - AtStartPosition = Vector2.Distance(startPosition, -Position) < ExitDistance; - AtEndPosition = Vector2.Distance(endPosition, -Position) < ExitDistance; + // AtStartPosition = Vector2.Distance(startPosition, -Position) < ExitDistance; + // AtEndPosition = Vector2.Distance(endPosition, -Position) < ExitDistance; - prevVelocity = simVelocity; + // prevVelocity = simVelocity; - WrappingWall.UpdateWallShift(-Position, wrappingWalls); - } + // WrappingWall.UpdateWallShift(-Position, wrappingWalls); + //} - public static void AfterWorldStep() - { - if (loaded == null) return; + //public static void AfterWorldStep() + //{ + // if (loaded == null) return; - loaded.ResetBodyVelocities(); - } + // loaded.ResetBodyVelocities(); + //} - private void ResetBodyVelocities() - { - if (prevVelocity == Vector2.Zero) return; - if (!MathUtils.IsValid(prevVelocity)) - { - prevVelocity = Vector2.Zero; - return; - } + //private void ResetBodyVelocities() + //{ + // if (prevVelocity == Vector2.Zero) return; + // if (!MathUtils.IsValid(prevVelocity)) + // { + // prevVelocity = Vector2.Zero; + // return; + // } - foreach (Character character in Character.CharacterList) - { - if (character.AnimController.CurrentHull != null) continue; + // foreach (Character character in Character.CharacterList) + // { + // if (character.AnimController.CurrentHull != null) continue; - foreach (Limb limb in character.AnimController.Limbs) - { - limb.body.LinearVelocity -= prevVelocity; - } - } + // foreach (Limb limb in character.AnimController.Limbs) + // { + // limb.body.LinearVelocity -= prevVelocity; + // } + // } - foreach (Item item in Item.ItemList) - { - if (item.body == null || item.CurrentHull != null) continue; - item.body.LinearVelocity -= prevVelocity; - } - } + // foreach (Item item in Item.ItemList) + // { + // if (item.body == null || item.CurrentHull != null) continue; + // item.body.LinearVelocity -= prevVelocity; + // } + //} public void Draw(SpriteBatch spriteBatch) { @@ -841,7 +833,7 @@ namespace Barotrauma System.Diagnostics.Debug.WriteLine("avgpos: " + avgPos / cells.Count); - System.Diagnostics.Debug.WriteLine("pos: " + Position); + //System.Diagnostics.Debug.WriteLine("pos: " + Position); } public List GetCells(Vector2 pos, int searchDepth = 2) @@ -911,10 +903,10 @@ namespace Barotrauma { if (onlySolid && !cell.edges[i].isSolid) continue; - Vector2 start = cell.edges[i].point1 + Position; + Vector2 start = cell.edges[i].point1; start.Y = -start.Y; - Vector2 end = cell.edges[i].point2 + Position; + Vector2 end = cell.edges[i].point2; end.Y = -end.Y; edges.Add(new Vector2[] { start, end }); @@ -932,7 +924,7 @@ namespace Barotrauma foreach (VoronoiCell cell in wrappingWalls[side, n].Cells) { - Vector2 offset = wrappingWalls[side, n].Offset + Position; + Vector2 offset = wrappingWalls[side, n].Offset; for (int i = 0; i < cell.edges.Count; i++) { if (onlySolid && !cell.edges[i].isSolid) continue; diff --git a/Subsurface/Source/Map/Levels/LevelRenderer.cs b/Subsurface/Source/Map/Levels/LevelRenderer.cs index c51393cae..0938c9a45 100644 --- a/Subsurface/Source/Map/Levels/LevelRenderer.cs +++ b/Subsurface/Source/Map/Levels/LevelRenderer.cs @@ -35,8 +35,8 @@ namespace Barotrauma public void Draw(SpriteBatch spriteBatch) { - Vector2 pos = level.EndPosition; - pos.Y = -pos.Y - level.Position.Y; + Vector2 pos = Vector2.Zero;// level.EndPosition; + //pos.Y = -pos.Y - level.Position.Y; if (GameMain.GameScreen.Cam.WorldView.Y < -pos.Y - 512) return; @@ -46,7 +46,7 @@ namespace Barotrauma int width = (int)(Math.Ceiling(GameMain.GameScreen.Cam.WorldView.Width / 512.0f + 2.0f) * 512.0f); spriteBatch.Draw(shaftTexture, - new Rectangle((int)(MathUtils.Round(pos.X, 512.0f) + level.Position.X % 512), (int)pos.Y, width, 512), + new Rectangle((int)(MathUtils.Round(pos.X, 512.0f) - Submarine.Loaded.Position.X % 512), (int)pos.Y, width, 512), new Rectangle(0, 0, width, 256), Color.White, 0.0f, Vector2.Zero, @@ -59,7 +59,7 @@ namespace Barotrauma if (vertices == null) return; if (vertices.Length <= 0) return; - basicEffect.World = Matrix.CreateTranslation(new Vector3(level.Position, 0.0f)) * cam.ShaderTransform + basicEffect.World = cam.ShaderTransform * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f; basicEffect.CurrentTechnique.Passes[0].Apply(); @@ -74,7 +74,7 @@ namespace Barotrauma for (int i = 0; i < 2; i++) { basicEffect.World = Matrix.CreateTranslation( - new Vector3(level.Position + level.WrappingWalls[side, i].Offset, 0.0f)) * + new Vector3(-Submarine.Loaded.Position + level.WrappingWalls[side, i].Offset, 0.0f)) * cam.ShaderTransform * Matrix.CreateOrthographic(GameMain.GraphicsWidth, GameMain.GraphicsHeight, -1, 1) * 0.5f; diff --git a/Subsurface/Source/Map/Lights/LightManager.cs b/Subsurface/Source/Map/Lights/LightManager.cs index d24be6d67..6248090e1 100644 --- a/Subsurface/Source/Map/Lights/LightManager.cs +++ b/Subsurface/Source/Map/Lights/LightManager.cs @@ -69,7 +69,7 @@ namespace Barotrauma.Lights foreach (ConvexHull convexHull in ConvexHull.list) { - if (!camView.Intersects(convexHull.BoundingBox)) continue; + //if (!camView.Intersects(convexHull.BoundingBox)) continue; convexHull.DrawShadows(graphics, cam, pos, shadowTransform); } @@ -109,7 +109,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.Position, light.Range, viewRect)) continue; //clear alpha to 1 ClearAlphaToOne(graphics, spriteBatch); @@ -128,7 +128,7 @@ namespace Barotrauma.Lights //draw the light shape //where Alpha is 0, nothing will be written - spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.MultiplyWithAlpha, null, null, null, null, cam.Transform); + spriteBatch.Begin(SpriteSortMode.Deferred, CustomBlendStates.MultiplyWithAlpha, null, null, null, null, Matrix.CreateTranslation(new Vector3(Submarine.Loaded.Position.X, -Submarine.Loaded.Position.Y, 0.0f)) * cam.Transform); light.Draw(spriteBatch); spriteBatch.End(); } diff --git a/Subsurface/Source/Map/Submarine.cs b/Subsurface/Source/Map/Submarine.cs index 9fd5853ed..5de6fd1db 100644 --- a/Subsurface/Source/Map/Submarine.cs +++ b/Subsurface/Source/Map/Submarine.cs @@ -23,7 +23,6 @@ namespace Barotrauma class Submarine : Entity { - public static string SavePath = "Data" + System.IO.Path.DirectorySeparatorChar + "SavedSubs"; public static List SavedSubmarines = new List(); @@ -99,7 +98,7 @@ namespace Barotrauma public Vector2 Position { - get { return (Level.Loaded == null) ? Vector2.Zero : -Level.Loaded.Position; } + get { return subBody.Position; } } public Vector2 Speed @@ -377,7 +376,9 @@ namespace Barotrauma public void SetPosition(Vector2 position) { if (!MathUtils.IsValid(position)) return; - Level.Loaded.SetPosition(-position); + + subBody.SetPosition(position); + //Level.Loaded.SetPosition(-position); //prevPosition = position; } @@ -385,7 +386,9 @@ namespace Barotrauma { if (amount == Vector2.Zero || !MathUtils.IsValid(amount)) return; - Level.Loaded.Move(-amount); + subBody.SetPosition(subBody.Position + amount); + + //Level.Loaded.Move(-amount); } public override bool FillNetworkData(Networking.NetworkEventType type, NetBuffer message, object data) diff --git a/Subsurface/Source/Map/SubmarineBody.cs b/Subsurface/Source/Map/SubmarineBody.cs index ba08ee4b4..3cb381dd9 100644 --- a/Subsurface/Source/Map/SubmarineBody.cs +++ b/Subsurface/Source/Map/SubmarineBody.cs @@ -71,6 +71,10 @@ namespace Barotrauma } } + public Vector2 Position + { + get { return ConvertUnits.ToDisplayUnits(body.Position); } + } public Vector2 Center { @@ -79,7 +83,7 @@ namespace Barotrauma public bool AtDamageDepth { - get { return sub.Position.Y < DamageDepth; } + get { return Position.Y < DamageDepth; } } public SubmarineBody(Submarine sub) @@ -187,34 +191,35 @@ namespace Barotrauma public void Update(float deltaTime) { - if (body.Position!=Vector2.Zero) + if (Position!=Vector2.Zero) { - UpdateColliding(); + //!!!!!!!!!!!!!!!! + //UpdateColliding(); } - Vector2 translateAmount = speed * deltaTime; - translateAmount += ConvertUnits.ToDisplayUnits(body.Position) * collisionRigidness; + //Vector2 translateAmount = speed * deltaTime; + //translateAmount += ConvertUnits.ToDisplayUnits(Position) * collisionRigidness; - if (targetPosition != Vector2.Zero && targetPosition != sub.Position) - { - float dist = Vector2.Distance(targetPosition, sub.Position); + //if (targetPosition != Vector2.Zero && targetPosition != Position) + //{ + // float dist = Vector2.Distance(targetPosition, Position); - if (dist>1000.0f) - { - sub.SetPosition(targetPosition); - targetPosition = Vector2.Zero; - } - else if (dist>50.0f) - { - translateAmount += (targetPosition - sub.Position) * 0.01f; - } - } - else - { - targetPosition = Vector2.Zero; - } + // if (dist>1000.0f) + // { + // sub.SetPosition(targetPosition); + // targetPosition = Vector2.Zero; + // } + // else if (dist>50.0f) + // { + // translateAmount += (targetPosition - Position) * 0.01f; + // } + //} + //else + //{ + // targetPosition = Vector2.Zero; + //} - sub.Translate(translateAmount); + //sub.Translate(translateAmount); //------------------------- @@ -232,14 +237,13 @@ namespace Barotrauma ApplyForce(totalForce); - UpdateDepthDamage(deltaTime); + //UpdateDepthDamage(deltaTime); //hullBodies[0].body.LinearVelocity = -hullBodies[0].body.Position; //hullBody.SetTransform(Vector2.Zero , 0.0f); - body.SetTransform(Vector2.Zero, 0.0f);// .LinearVelocity = -body.Position / (float)Physics.step; - body.LinearVelocity = Vector2.Zero; - + //body.SetTransform(Vector2.Zero, 0.0f);// .LinearVelocity = -body.Position / (float)Physics.step; + //body.LinearVelocity = Vector2.Zero; } private Vector2 CalculateBuoyancy() @@ -264,14 +268,19 @@ namespace Barotrauma public void ApplyForce(Vector2 force) { - Speed += force / mass; + body.ApplyForce(force/100.0f); + } + + public void SetPosition(Vector2 position) + { + body.SetTransform(ConvertUnits.ToSimUnits(position), 0.0f); } private void UpdateDepthDamage(float deltaTime) { - if (sub.Position.Y > DamageDepth) return; + if (Position.Y > DamageDepth) return; - float depth = DamageDepth - sub.Position.Y; + float depth = DamageDepth - Position.Y; depth = Math.Min(depth, 40000.0f); // float prevTimer = depthDamageTimer; @@ -311,6 +320,9 @@ namespace Barotrauma private void UpdateColliding() { + + return; + if (body.Position.LengthSquared()<0.00001f) return; Vector2 normal = Vector2.Normalize(body.Position); diff --git a/Subsurface/Source/Screens/GameScreen.cs b/Subsurface/Source/Screens/GameScreen.cs index 380c79b5e..f3b7ac947 100644 --- a/Subsurface/Source/Screens/GameScreen.cs +++ b/Subsurface/Source/Screens/GameScreen.cs @@ -118,7 +118,7 @@ namespace Barotrauma GameMain.World.Step((float)Physics.step); - Level.AfterWorldStep(); + //Level.AfterWorldStep(); Physics.accumulator -= Physics.step; } @@ -177,7 +177,7 @@ namespace Barotrauma spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearWrap); Vector2 backgroundPos = cam.Position; - if (Level.Loaded != null) backgroundPos -= Level.Loaded.Position; + //if (Level.Loaded != null) backgroundPos -= Level.Loaded.Position; backgroundPos.Y = -backgroundPos.Y; backgroundPos /= 20.0f; @@ -210,7 +210,7 @@ namespace Barotrauma BackgroundSpriteManager.Draw(spriteBatch); backgroundPos = new Vector2(cam.WorldView.X, cam.WorldView.Y) + dustOffset; - if (Level.Loaded != null) backgroundPos -= Level.Loaded.Position; + //if (Level.Loaded != null) backgroundPos -= Level.Loaded.Position; Rectangle viewRect = cam.WorldView; viewRect.Y = -viewRect.Y; @@ -229,7 +229,7 @@ namespace Barotrauma spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, null, null, null, null, - cam.Transform); + Matrix.CreateTranslation(new Vector3(Submarine.Loaded.Position.X, -Submarine.Loaded.Position.Y, 0.0f))*cam.Transform); Submarine.DrawBack(spriteBatch); @@ -315,7 +315,7 @@ namespace Barotrauma hull.Render(graphics, cam); } - Hull.renderer.Render(graphics, cam, renderTargetAir, Cam.ShaderTransform); + Hull.renderer.Render(graphics, cam, renderTargetAir,Cam.ShaderTransform); if (GameMain.GameSession != null && GameMain.GameSession.Level != null) { @@ -330,7 +330,7 @@ namespace Barotrauma spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend, SamplerState.LinearWrap, null, null, null, - cam.Transform); + Matrix.CreateTranslation(new Vector3(Submarine.Loaded.Position.X, -Submarine.Loaded.Position.Y, 0.0f))*cam.Transform); foreach (Character c in Character.CharacterList) c.DrawFront(spriteBatch); diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 5cd376d1f4f30af042213a2f574fba1185c3c9e9..e9dcb3c81d10607f0941619ce2db1f004a1fb279 100644 GIT binary patch delta 3379 zcmb7_3s98T7017Gzx(YjyDKipD~P(lDg}{%;$u?f<-{6`fJ6;-ETW*sYE=?^1O?GX zlO{$9pV_O`X?@Vu(2N1s@HJ{u#OSE4NlejbOA)np)Ea};iH|tK%+-d9h?SjW3a9fY&gPk>qPz`MySPS+-Ux>(&D7T`lm+=s~ zqp#ypT!zs<SlSRB4G zlpNq~P(yl8OD^x&D>IQ^&u7y`JwXe;JA`!2)v=Gra2Z0f!lo#%gXKW#Z`_l24BF05 zQD^-sQbJfL>7gkZ{tGa#EHDylauhON5yd&w-!T+=9C%08%L(sE$)j|=N9qD6`fd9e zOgBM3m;#EyDos(!AoZQ8t{<4uE)&W@P>OO2VxeBygx^@$RzQx1+~MnFUZ;Pv`h+nx zJZVhX?PHSb`;;*a;T-+zEvfNdXGn9DDDyIx*Y&Gb+Tu*J3ugt7)b|A>h@uLf>7y)E z6(tPrV()MksONR<#wOeJ>*M0|${ktSGOYS~aWslOE1IKNn5eVb%;Lv7AE?*8H$-G? zvj%xHvUd1+av0lD;2h+2I<^u2Ar|04H2s=i>=x$+tL}7c@u5UiJyPxXLf^*{q?^~d zt=Z4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