diff --git a/Subsurface/Barotrauma.csproj b/Subsurface/Barotrauma.csproj index 75e2e93c9..09cabeebc 100644 --- a/Subsurface/Barotrauma.csproj +++ b/Subsurface/Barotrauma.csproj @@ -497,6 +497,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest @@ -1092,6 +1095,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest diff --git a/Subsurface/Content/Items/Door/dockingport.png b/Subsurface/Content/Items/Door/dockingport.png index 86d928cda..6538ddf08 100644 Binary files a/Subsurface/Content/Items/Door/dockingport.png and b/Subsurface/Content/Items/Door/dockingport.png differ diff --git a/Subsurface/Content/Items/Door/dockingport1.ogg b/Subsurface/Content/Items/Door/dockingport1.ogg new file mode 100644 index 000000000..3d9aea42e Binary files /dev/null and b/Subsurface/Content/Items/Door/dockingport1.ogg differ diff --git a/Subsurface/Content/Items/Door/dockingport2.ogg b/Subsurface/Content/Items/Door/dockingport2.ogg new file mode 100644 index 000000000..8795bf1fb Binary files /dev/null and b/Subsurface/Content/Items/Door/dockingport2.ogg differ diff --git a/Subsurface/Content/Items/Door/dockingport2.png b/Subsurface/Content/Items/Door/dockingport2.png new file mode 100644 index 000000000..2862aaf62 Binary files /dev/null and b/Subsurface/Content/Items/Door/dockingport2.png differ diff --git a/Subsurface/Content/Items/Door/doors.xml b/Subsurface/Content/Items/Door/doors.xml index 7834d3d90..3b709c5e1 100644 --- a/Subsurface/Content/Items/Door/doors.xml +++ b/Subsurface/Content/Items/Door/doors.xml @@ -88,11 +88,12 @@ linkable="true" pickdistance="150.0"> - + - - + + + @@ -105,6 +106,34 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Subsurface/Content/Items/Reactor/reactor.xml b/Subsurface/Content/Items/Reactor/reactor.xml index c1d0cab82..7561565af 100644 --- a/Subsurface/Content/Items/Reactor/reactor.xml +++ b/Subsurface/Content/Items/Reactor/reactor.xml @@ -67,8 +67,7 @@ - - + - - + @@ -100,8 +98,7 @@ - - + diff --git a/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs b/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs index ca39e4aee..71835eebe 100644 --- a/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs +++ b/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs @@ -734,6 +734,10 @@ namespace Barotrauma { ladderSimPos += character.SelectedConstruction.Submarine.SimPosition; } + else if (currentHull.Submarine != null && currentHull.Submarine != character.SelectedConstruction.Submarine) + { + ladderSimPos += character.SelectedConstruction.Submarine.SimPosition - currentHull.Submarine.SimPosition; + } MoveLimb(head, new Vector2(ladderSimPos.X - 0.27f * Dir, head.SimPosition.Y + 0.05f), 10.5f); MoveLimb(torso, new Vector2(ladderSimPos.X - 0.27f * Dir, torso.SimPosition.Y), 10.5f); @@ -742,7 +746,9 @@ namespace Barotrauma Vector2 handPos = new Vector2( ladderSimPos.X, - head.SimPosition.Y + 0.0f + movement.Y * 0.1f - ladderSimPos.Y); + head.SimPosition.Y + movement.Y * 0.1f - ladderSimPos.Y); + + handPos.Y = Math.Min(-0.5f, handPos.Y); MoveLimb(leftHand, new Vector2(handPos.X, @@ -815,8 +821,7 @@ namespace Barotrauma // - moving sideways // - reached the top or bottom of the ladder if (notClimbing || - (TargetMovement.Y < 0.0f && ConvertUnits.ToSimUnits(trigger.Height) + handPos.Y < HeadPosition * 1.5f) || - (TargetMovement.Y > 0.0f && handPos.Y > 0.1f)) + (TargetMovement.Y < 0.0f && ConvertUnits.ToSimUnits(trigger.Height) + handPos.Y < HeadPosition * 1.5f)) { Anim = Animation.None; character.SelectedConstruction = null; diff --git a/Subsurface/Source/Items/Components/DockingPort.cs b/Subsurface/Source/Items/Components/DockingPort.cs index 69347b7bc..43c5bda4f 100644 --- a/Subsurface/Source/Items/Components/DockingPort.cs +++ b/Subsurface/Source/Items/Components/DockingPort.cs @@ -20,23 +20,24 @@ namespace Barotrauma.Items.Components private static List list = new List(); private Sprite overlaySprite; - + private Vector2 distanceTolerance; private DockingPort dockingTarget; private float dockingState; + private int dockingDir; private Joint joint; - private int dockingDir; - private Hull[] hulls; private Body[] bodies; private Gap gap; + private bool docked; + [HasDefaultValue("32.0,32.0", false)] public string DistanceTolerance { @@ -58,22 +59,22 @@ namespace Barotrauma.Items.Components set; } - public override bool IsActive + public bool Docked { get { - return base.IsActive; + return docked; } set { - if (!IsActive && value) + if (!docked && value) { if (dockingTarget == null) AttemptDock(); if (dockingTarget == null) return; - base.IsActive = value; + docked = true; } - else if (IsActive && !value) + else if (docked && !value) { Undock(); } @@ -97,10 +98,12 @@ namespace Barotrauma.Items.Components } } + IsActive = true; + list.Add(this); } - private void AttemptDock() + private DockingPort FindAdjacentPort() { foreach (DockingPort port in list) { @@ -109,24 +112,41 @@ namespace Barotrauma.Items.Components if (Math.Abs(port.item.WorldPosition.X - item.WorldPosition.X) > distanceTolerance.X) continue; if (Math.Abs(port.item.WorldPosition.Y - item.WorldPosition.Y) > distanceTolerance.Y) continue; - Dock(port); - return; - + return port; } + + return null; + } + + private void AttemptDock() + { + var adjacentPort = FindAdjacentPort(); + if (adjacentPort != null) Dock(adjacentPort); } private void Dock(DockingPort target) { - if (dockingTarget!=null) + if (dockingTarget != null) { Undock(); } + PlaySound(ActionType.OnUse, item.WorldPosition); + + dockingTarget = target; dockingTarget.dockingTarget = this; - dockingTarget.IsActive = true; + dockingTarget.Docked = true; - dockingDir = Math.Sign(dockingTarget.item.WorldPosition.X - item.WorldPosition.X); + if (Character.Controlled != null && + (Character.Controlled.Submarine == dockingTarget.item.Submarine || Character.Controlled.Submarine == item.Submarine)) + { + GameMain.GameScreen.Cam.Shake = Vector2.Distance(dockingTarget.item.Submarine.Velocity, item.Submarine.Velocity); + } + + dockingDir = IsHorizontal ? + Math.Sign(dockingTarget.item.WorldPosition.X - item.WorldPosition.X) : + Math.Sign(item.WorldPosition.Y - dockingTarget.item.WorldPosition.Y); dockingTarget.dockingDir = -dockingDir; CreateJoint(false); @@ -184,59 +204,62 @@ namespace Barotrauma.Items.Components subs = new Submarine[] { dockingTarget.item.Submarine,item.Submarine }; } - hullRects[0] = new Rectangle(hullRects[0].Center.X, hullRects[0].Y, ((int)DockedDistance / 2), hullRects[0].Height); hullRects[1] = new Rectangle(hullRects[1].Center.X - ((int)DockedDistance / 2), hullRects[1].Y, ((int)DockedDistance / 2), hullRects[1].Height); - - for (int i = 0; i < 2;i++ ) { hullRects[i].Location -= (subs[i].WorldPosition - subs[i].HiddenSubPosition).ToPoint(); hulls[i] = new Hull(MapEntityPrefab.list.Find(m => m.Name == "Hull"), hullRects[i], subs[i]); hulls[i].AddToGrid(subs[i]); - for (int j = 0; j < 2; j++) { bodies[i + j * 2] = BodyFactory.CreateEdge(GameMain.World, ConvertUnits.ToSimUnits(new Vector2(hullRects[i].X, hullRects[i].Y - hullRects[i].Height * j)), ConvertUnits.ToSimUnits(new Vector2(hullRects[i].Right, hullRects[i].Y - hullRects[i].Height * j))); - - //bodies[i + j * 2] = BodyFactory.CreateRectangle(GameMain.World, ConvertUnits.ToSimUnits(hullRects[i].Width), 0.1f, 5.0f); - //bodies[i + j * 2].SetTransform(ConvertUnits.ToSimUnits(new Vector2(hullRects[i].Center.X, hullRects[i].Y - (hullRects[i].Height+5) * j)), 0.0f); } } - gap = new Gap(new Rectangle(hullRects[0].Right-2, hullRects[0].Y, 4, hullRects[0].Height), true, item.Submarine); - gap.linkedTo.Clear(); - gap.linkedTo.Add(hulls[0]); - gap.linkedTo.Add(hulls[1]); - - //var hullRect1 = new Rectangle(hullRects.Min(h => h.Center.X), hullRect.Y, ((int)DockedDistance / 2), hullRects[0].Height); - //var hullRect2 = new Rectangle(hullRects.Max(h => h.Center.X), hullRect.Y, ((int)DockedDistance / 2), hullRects[0].Height); - - //var sub1 = hullRect.Center.X < targetRect.Center.X ? item.Submarine : dockingTarget.item.Submarine; - //var sub2 = hullRect.Center.X > targetRect.Center.X ? item.Submarine : dockingTarget.item.Submarine; - - // hullRect1.Location -= (sub1.WorldPosition - sub1.HiddenSubPosition).ToPoint(); - //hulls[0] = new Hull(MapEntityPrefab.list.Find(m => m.Name == "Hull"), hullRect1, sub1); - //hulls[0].AddToGrid(sub1); - - //hullRect2.Location -= (sub2.WorldPosition - sub2.HiddenSubPosition).ToPoint(); - //hulls[1] = new Hull(MapEntityPrefab.list.Find(m => m.Name == "Hull"), hullRect2, sub2); - //hulls[1].AddToGrid(sub2); - + gap = new Gap(new Rectangle(hullRects[0].Right-2, hullRects[0].Y, 4, hullRects[0].Height), true, subs[0]); } else { - //hullRect = new Rectangle(hullRect.X, - // Math.Max(hullRect.Y - hullRect.Height / 2, targetRect.Y - targetRect.Height / 2), hullRect.Width, (int)DockedDistance); + if (hullRects[0].Center.Y > hullRects[1].Center.Y) + { + hullRects = new Rectangle[] { dockingTarget.item.WorldRect, item.WorldRect }; + subs = new Submarine[] { dockingTarget.item.Submarine, item.Submarine }; + } + + hullRects[0] = new Rectangle(hullRects[0].X, hullRects[0].Y + (int)(-hullRects[0].Height+DockedDistance)/2, hullRects[0].Width, ((int)DockedDistance / 2)); + hullRects[1] = new Rectangle(hullRects[1].X, hullRects[1].Y - hullRects[1].Height/2, hullRects[1].Width, ((int)DockedDistance / 2)); + + for (int i = 0; i < 2; i++) + { + hullRects[i].Location -= (subs[i].WorldPosition - subs[i].HiddenSubPosition).ToPoint(); + hulls[i] = new Hull(MapEntityPrefab.list.Find(m => m.Name == "Hull"), hullRects[i], subs[i]); + hulls[i].AddToGrid(subs[i]); + + //for (int j = 0; j < 2; j++) + //{ + // bodies[i + j * 2] = BodyFactory.CreateEdge(GameMain.World, + // ConvertUnits.ToSimUnits(new Vector2(hullRects[i].X + hullRects[i].Width * j, hullRects[i].Y)), + // ConvertUnits.ToSimUnits(new Vector2(hullRects[i].X + hullRects[i].Width * j, hullRects[i].Y-hullRects[i].Height))); + //} + } + + gap = new Gap(new Rectangle(hullRects[0].X, hullRects[0].Y+2, hullRects[0].Width, 4), true, subs[0]); + } + gap.linkedTo.Clear(); + gap.linkedTo.Add(hulls[0]); + gap.linkedTo.Add(hulls[1]); + foreach (Body body in bodies) { + if (body == null) continue; body.BodyType = BodyType.Static; body.Friction = 0.5f; @@ -248,62 +271,83 @@ namespace Barotrauma.Items.Components private void Undock() { - if (dockingTarget == null) return; + if (dockingTarget == null || !docked) return; - dockingTarget.dockingTarget = null; - dockingTarget.IsActive = false; + PlaySound(ActionType.OnUse, item.WorldPosition); + docked = false; + + dockingTarget.Undock(); dockingTarget = null; - GameMain.World.RemoveJoint(joint); - joint = null; - - hulls[0].Remove(); - hulls[1].Remove(); - - gap.Remove(); - gap = null; - - foreach (Body body in bodies) + if (joint != null) { - GameMain.World.RemoveBody(body); + GameMain.World.RemoveJoint(joint); + joint = null; } - bodies = null; + if (hulls != null) + { + hulls[0].Remove(); + hulls[1].Remove(); + hulls = null; + } - - //foreach (Gap g in hulls[0].ConnectedGaps) - //{ - // g.Remove(); - //} + if (gap != null) + { + gap.Remove(); + gap = null; + } - //foreach (Gap g in hulls[1].ConnectedGaps) - //{ - // g.Remove(); - //} + if (bodies!=null) + { + foreach (Body body in bodies) + { + if (body == null) continue; + GameMain.World.RemoveBody(body); + } + bodies = null; + } - - hulls = null; } public override void Update(float deltaTime, Camera cam) { - if (dockingTarget==null) + + + if (dockingTarget == null) { dockingState = MathHelper.Lerp(dockingState, 0.0f, deltaTime * 10.0f); - if (dockingState < 0.01f) base.IsActive = false; + if (dockingState < 0.01f) docked = false; + + item.SendSignal(0, "0", "state_out"); + + item.SendSignal(0, (FindAdjacentPort() != null) ? "1" : "0", "proximity_sensor"); + } else { - if (joint is DistanceJoint && Vector2.Distance(joint.WorldAnchorA, joint.WorldAnchorB) < 0.05f) + if (joint is DistanceJoint) { - GameMain.World.RemoveJoint(joint); + item.SendSignal(0, "0", "state_out"); - CreateJoint(true); - CreateHull(); + if (Vector2.Distance(joint.WorldAnchorA, joint.WorldAnchorB) < 0.05f) + { + GameMain.World.RemoveJoint(joint); + + PlaySound(ActionType.OnSecondaryUse, item.WorldPosition); + + CreateJoint(true); + CreateHull(); + } + dockingState = MathHelper.Lerp(dockingState, 0.5f, deltaTime * 10.0f); } + else + { + item.SendSignal(0, "1", "state_out"); - dockingState = MathHelper.Lerp(dockingState, 1.0f, deltaTime * 10.0f); + dockingState = MathHelper.Lerp(dockingState, 1.0f, deltaTime * 10.0f); + } } } @@ -315,10 +359,11 @@ namespace Barotrauma.Items.Components drawPos.Y = -drawPos.Y; var rect = overlaySprite.SourceRect; - drawPos.Y -= rect.Height / 2; - + if (IsHorizontal) { + drawPos.Y -= rect.Height / 2; + if (dockingDir == 1) { spriteBatch.Draw(overlaySprite.Texture, @@ -339,6 +384,8 @@ namespace Barotrauma.Items.Components } else { + drawPos.X -= rect.Width / 2; + if (dockingDir == 1) { spriteBatch.Draw(overlaySprite.Texture, @@ -363,5 +410,19 @@ namespace Barotrauma.Items.Components { list.Remove(this); } + + public override void ReceiveSignal(int stepsTaken, string signal, Connection connection, Item sender, float power = 0.0f) + { + switch (connection.Name) + { + case "toggle": + Docked = !docked; + break; + case "set_active": + case "set_state": + Docked = signal != "0"; + break; + } + } } } diff --git a/Subsurface/Source/Items/Components/Signal/SignalCheckComponent.cs b/Subsurface/Source/Items/Components/Signal/SignalCheckComponent.cs index b2e4133d9..82b7fa423 100644 --- a/Subsurface/Source/Items/Components/Signal/SignalCheckComponent.cs +++ b/Subsurface/Source/Items/Components/Signal/SignalCheckComponent.cs @@ -4,7 +4,7 @@ namespace Barotrauma.Items.Components { class SignalCheckComponent : ItemComponent { - private string output; + private string output, falseOutput; private string targetSignal; @@ -14,6 +14,12 @@ namespace Barotrauma.Items.Components get { return output; } set { output = value; } } + [InGameEditable, HasDefaultValue("0", true)] + public string FalseOutput + { + get { return falseOutput; } + set { falseOutput = value; } + } [InGameEditable, HasDefaultValue("", true)] public string TargetSignal @@ -32,7 +38,10 @@ namespace Barotrauma.Items.Components switch (connection.Name) { case "signal_in": - item.SendSignal(stepsTaken, (signal == targetSignal) ? output : "0", "signal_out"); + string signalOut = (signal == targetSignal) ? output : falseOutput; + + if (string.IsNullOrWhiteSpace(signalOut)) return; + item.SendSignal(stepsTaken, signalOut, "signal_out"); break; case "set_output": diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index 836cbec2f..2f79d7a0a 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -19,7 +19,7 @@ namespace Barotrauma public enum ActionType { - Always, OnPicked, OnUse, + Always, OnPicked, OnUse, OnSecondaryUse, OnWearing, OnContaining, OnContained, OnActive, OnFailure, OnBroken, OnFire, InWater, @@ -1248,6 +1248,7 @@ namespace Barotrauma { picked = true; ic.ApplyStatusEffects(ActionType.OnPicked, 1.0f, picker); + ic.PlaySound(ActionType.OnPicked, picker.WorldPosition); if (picker==Character.Controlled) GUIComponent.MouseOn = null; diff --git a/Subsurface/Source/Map/Gap.cs b/Subsurface/Source/Map/Gap.cs index 621b15049..a908aed27 100644 --- a/Subsurface/Source/Map/Gap.cs +++ b/Subsurface/Source/Map/Gap.cs @@ -173,8 +173,6 @@ namespace Barotrauma { Vector2 center = new Vector2(WorldRect.X + rect.Width / 2.0f, -(WorldRect.Y - rect.Height/ 2.0f)); - - GUI.DrawLine(sb, center, center + new Vector2(flowForce.X, -flowForce.Y)/10.0f, Color.Red); GUI.DrawLine(sb, center + Vector2.One * 5.0f, center + new Vector2(lerpedFlowForce.X, -lerpedFlowForce.Y) / 10.0f + Vector2.One * 5.0f, Color.Orange); @@ -329,6 +327,18 @@ namespace Barotrauma if (linkedTo.Count < 2) return; Hull hull1 = (Hull)linkedTo[0]; Hull hull2 = (Hull)linkedTo[1]; + + Vector2 subOffset = Vector2.Zero; + if (hull1.Submarine != Submarine) + { + subOffset =Submarine.Position - hull1.Submarine.Position; + } + else if (hull2.Submarine != Submarine) + { + + subOffset = hull2.Submarine.Position - Submarine.Position; + + } if (hull1.Volume == 0.0 && hull2.Volume == 0.0) return; @@ -341,13 +351,14 @@ namespace Barotrauma //horizontal gap (such as a regular door) if (isHorizontal) { - higherSurface = Math.Max(hull1.Surface,hull2.Surface); - float delta=0.0f; + higherSurface = Math.Max(hull1.Surface, hull2.Surface + subOffset.Y); + float delta=0.0f; + //water level is above the lower boundary of the gap - if (Math.Max(hull1.Surface+hull1.WaveY[hull1.WaveY.Length - 1], hull2.Surface+hull2.WaveY[0]) > rect.Y - size) + if (Math.Max(hull1.Surface+hull1.WaveY[hull1.WaveY.Length - 1], hull2.Surface + subOffset.Y +hull2.WaveY[0]) > rect.Y - size) { - int dir = (hull1.Pressure > hull2.Pressure) ? 1 : -1; + int dir = (hull1.Pressure > hull2.Pressure+subOffset.Y) ? 1 : -1; //water flowing from the righthand room to the lefthand room if (dir == -1) @@ -360,38 +371,42 @@ namespace Barotrauma flowTargetHull = hull1; //make sure not to move more than what the room contains - delta = Math.Min((hull2.Pressure - hull1.Pressure) * 5.0f * sizeModifier, Math.Min(hull2.Volume, hull2.FullVolume)); + delta = Math.Min(((hull2.Pressure + subOffset.Y) - hull1.Pressure) * 5.0f * sizeModifier, Math.Min(hull2.Volume, hull2.FullVolume)); //make sure not to place more water to the target room than it can hold delta = Math.Min(delta, hull1.FullVolume + Hull.MaxCompress - (hull1.Volume)); hull1.Volume += delta; hull2.Volume -= delta; if (hull1.Volume > hull1.FullVolume) - hull1.Pressure = Math.Max(hull1.Pressure, (hull1.Pressure + hull2.Pressure) / 2); + { + hull1.Pressure = Math.Max(hull1.Pressure, (hull1.Pressure + hull2.Pressure+subOffset.Y) / 2); + } flowForce = new Vector2(-delta, 0.0f); } else if (dir == 1) { if (!(hull1.Volume > 0.0f)) return; - lowerSurface = hull2.Surface - hull2.WaveY[1]; + //lowerSurface = hull2.Surface - hull2.WaveY[1]; flowTargetHull = hull2; //make sure not to move more than what the room contains - delta = Math.Min((hull1.Pressure - hull2.Pressure) * 5.0f * sizeModifier, Math.Min(hull1.Volume, hull1.FullVolume)); + delta = Math.Min((hull1.Pressure - (hull2.Pressure + subOffset.Y)) * 5.0f * sizeModifier, Math.Min(hull1.Volume, hull1.FullVolume)); //make sure not to place more water to the target room than it can hold delta = Math.Min(delta, hull2.FullVolume + Hull.MaxCompress - (hull2.Volume)); hull1.Volume -= delta; hull2.Volume += delta; if (hull2.Volume > hull2.FullVolume) - hull2.Pressure = Math.Max(hull2.Pressure, (hull1.Pressure + hull2.Pressure) / 2); + { + hull2.Pressure = Math.Max(hull2.Pressure, ((hull1.Pressure-subOffset.Y) + hull2.Pressure) / 2); + } flowForce = new Vector2(delta, 0.0f); } - if (delta>100.0f) + if (delta>100.0f && subOffset == Vector2.Zero) { float avg = (hull1.Surface + hull2.Surface) / 2.0f; //float avgVel = (hull2.WaveVel[1] + hull1.WaveVel[hull1.WaveY.Length - 2]) / 2.0f; @@ -625,10 +640,9 @@ namespace Barotrauma GapList.Remove(this); - foreach (MapEntity entity in linkedTo) + foreach (Hull hull in Hull.hullList) { - var hull = entity as Hull; - if (hull.ConnectedGaps.Contains(this)) hull.ConnectedGaps.Remove(this); + hull.ConnectedGaps.Remove(this); } } diff --git a/Subsurface/Source/Map/Hull.cs b/Subsurface/Source/Map/Hull.cs index f0f2c8793..ff79a1a69 100644 --- a/Subsurface/Source/Map/Hull.cs +++ b/Subsurface/Source/Map/Hull.cs @@ -53,6 +53,7 @@ namespace Barotrauma private bool update; + private Sound currentFlowSound; private int soundIndex; private float soundVolume; @@ -392,12 +393,24 @@ namespace Barotrauma foreach (Gap gap in ConnectedGaps) { float gapFlow = gap.LerpedFlowForce.Length(); + +#if DEBUG + var asd = MapEntity.FindEntityByID(gap.ID); + + if (asd != gap) + { + int adslkmfdlasfk = 9; + } +#endif + + if (gapFlow > strongestFlow) { strongestFlow = gapFlow; } } + if (strongestFlow>0.1f) { soundVolume = soundVolume + ((strongestFlow < 100.0f) ? -deltaTime * 0.5f : deltaTime * 0.5f); @@ -406,13 +419,24 @@ namespace Barotrauma int index = (int)Math.Floor(strongestFlow / 100.0f); index = Math.Min(index, 2); - soundIndex = SoundPlayer.flowSounds[index].Loop(soundIndex, soundVolume, WorldPosition, 2000.0f); + var flowSound = SoundPlayer.flowSounds[index]; + if (flowSound != currentFlowSound && soundIndex > -1) + { + Sounds.SoundManager.Stop(soundIndex); + currentFlowSound = null; + soundIndex = -1; + } + + currentFlowSound = flowSound; + + soundIndex = currentFlowSound.Loop(soundIndex, soundVolume, WorldPosition, 2000.0f); } else { if (soundIndex > -1) { Sounds.SoundManager.Stop(soundIndex); + currentFlowSound = null; soundIndex = -1; } } diff --git a/Subsurface/Source/Map/Lights/ConvexHull.cs b/Subsurface/Source/Map/Lights/ConvexHull.cs index 7453f2246..f9312bf65 100644 --- a/Subsurface/Source/Map/Lights/ConvexHull.cs +++ b/Subsurface/Source/Map/Lights/ConvexHull.cs @@ -375,7 +375,18 @@ namespace Barotrauma.Lights Vector2 lightSourcePos = light.Position; - if (light.Submarine==null && parentEntity != null && parentEntity.Submarine != null) lightSourcePos -= parentEntity.Submarine.Position; + if (parentEntity != null && parentEntity.Submarine != null) + { + if (light.Submarine == null) + { + lightSourcePos -= parentEntity.Submarine.Position; + } + else if (light.Submarine != parentEntity.Submarine) + { + lightSourcePos += (light.Submarine.Position-parentEntity.Submarine.Position); + } + + } CachedShadow cachedShadow = null; if (!cachedShadows.TryGetValue(light, out cachedShadow) || diff --git a/Subsurface/Source/Map/Lights/LightManager.cs b/Subsurface/Source/Map/Lights/LightManager.cs index 21093cc70..cde8e7f5c 100644 --- a/Subsurface/Source/Map/Lights/LightManager.cs +++ b/Subsurface/Source/Map/Lights/LightManager.cs @@ -95,6 +95,7 @@ namespace Barotrauma.Lights foreach (LightSource light in lights) { if (light.Color.A < 0.01f || light.Range < 1.0f) continue; + //!!!!!!!!!!!!!!!! if (light.hullsInRange == null) light.UpdateHullsInRange(); if (!light.hullsInRange.Any() || !MathUtils.CircleIntersectsRectangle(light.WorldPosition, light.Range, viewRect)) continue; diff --git a/Subsurface/Source/Map/Lights/LightSource.cs b/Subsurface/Source/Map/Lights/LightSource.cs index 46e04bf90..030f7e8e2 100644 --- a/Subsurface/Source/Map/Lights/LightSource.cs +++ b/Subsurface/Source/Map/Lights/LightSource.cs @@ -86,7 +86,7 @@ namespace Barotrauma.Lights { range = MathHelper.Clamp(value, 0.0f, 2048.0f); - if (Math.Abs(prevHullUpdateRange - range) < 5.0f) return; + if (Math.Abs(prevHullUpdateRange - range) < 10.0f) return; UpdateHullsInRange(); prevHullUpdateRange = range; @@ -143,18 +143,24 @@ namespace Barotrauma.Lights foreach (ConvexHull ch in ConvexHull.list) { - if (Submarine == null && ch.ParentEntity.Submarine != null) + Vector2 lightPos = position; + + if (Submarine==null) { - if (MathUtils.CircleIntersectsRectangle(position - ch.ParentEntity.Submarine.Position, range, ch.BoundingBox)) + if (ch.ParentEntity.Submarine != null) { - hullsInRange.Add(ch); + lightPos -= ch.ParentEntity.Submarine.Position; } } - else if (MathUtils.CircleIntersectsRectangle(position, range, ch.BoundingBox)) + else if (ch.ParentEntity.Submarine != null && ch.ParentEntity.Submarine != Submarine) + { + lightPos -= (ch.ParentEntity.Submarine.Position - Submarine.Position); + } + + if (MathUtils.CircleIntersectsRectangle(lightPos, range, ch.BoundingBox)) { hullsInRange.Add(ch); } - } } diff --git a/Subsurface/Source/Map/Structure.cs b/Subsurface/Source/Map/Structure.cs index 7a91e11a3..49f9d5219 100644 --- a/Subsurface/Source/Map/Structure.cs +++ b/Subsurface/Source/Map/Structure.cs @@ -349,6 +349,14 @@ namespace Barotrauma GameMain.World.RemoveBody(b); } + foreach (WallSection s in sections) + { + if (s.gap != null) + { + s.gap.Remove(); + s.gap = null; + } + } if (convexHulls != null) convexHulls.ForEach(x => x.Remove()); } diff --git a/Subsurface/Submarines/Shuttle Mark I.sub b/Subsurface/Submarines/Shuttle Mark I.sub index 68dfd9d49..1de548faa 100644 Binary files a/Subsurface/Submarines/Shuttle Mark I.sub and b/Subsurface/Submarines/Shuttle Mark I.sub differ diff --git a/Subsurface/Submarines/Vellamo.sub b/Subsurface/Submarines/Vellamo.sub index 3245978b5..f515d63eb 100644 Binary files a/Subsurface/Submarines/Vellamo.sub and b/Subsurface/Submarines/Vellamo.sub differ