diff --git a/Subsurface/Content/Characters/Endworm/endworm.xml b/Subsurface/Content/Characters/Endworm/endworm.xml index a63bc2a19..eb183714c 100644 --- a/Subsurface/Content/Characters/Endworm/endworm.xml +++ b/Subsurface/Content/Characters/Endworm/endworm.xml @@ -1,5 +1,5 @@  - + diff --git a/Subsurface/Content/Characters/Moloch/moloch.xml b/Subsurface/Content/Characters/Moloch/moloch.xml index 2b5ebfe84..a1bcb33b2 100644 --- a/Subsurface/Content/Characters/Moloch/moloch.xml +++ b/Subsurface/Content/Characters/Moloch/moloch.xml @@ -1,5 +1,5 @@  - + diff --git a/Subsurface/Content/Items/Button/button.xml b/Subsurface/Content/Items/Button/button.xml index 6bf1cf042..3971265a6 100644 --- a/Subsurface/Content/Items/Button/button.xml +++ b/Subsurface/Content/Items/Button/button.xml @@ -8,6 +8,11 @@ + + + + + diff --git a/Subsurface/Content/Items/Diving/divinggear.xml b/Subsurface/Content/Items/Diving/divinggear.xml index aaea39e6c..67dc8e0ec 100644 --- a/Subsurface/Content/Items/Diving/divinggear.xml +++ b/Subsurface/Content/Items/Diving/divinggear.xml @@ -7,6 +7,10 @@ pickdistance="150" price="50"> + + + + @@ -26,6 +30,10 @@ price="50" description="Small enough to carry around in case of need, but won't protect you from the water pressure in the event of a full-blown hull breach."> + + + + @@ -101,6 +109,12 @@ price="50" description="A battery-powered underwater propulsion device."> + + + + + + diff --git a/Subsurface/Content/Items/Tools/tools.xml b/Subsurface/Content/Items/Tools/tools.xml index a9b318614..4df507e77 100644 --- a/Subsurface/Content/Items/Tools/tools.xml +++ b/Subsurface/Content/Items/Tools/tools.xml @@ -10,6 +10,11 @@ + + + + + @@ -56,6 +61,11 @@ price="100" description="Cuts through various materials using a jet of ionized oxygen."> + + + + + @@ -94,6 +104,10 @@ pickdistance="150" price="50"> + + + + @@ -113,6 +127,11 @@ price="100" description="A handheld carbon dioxide extinguisher."> + + + + + @@ -135,7 +154,7 @@ Tags="smallitem" pickdistance="200" price="10"> - + diff --git a/Subsurface/Source/Characters/Animation/Ragdoll.cs b/Subsurface/Source/Characters/Animation/Ragdoll.cs index e5ca45086..4bf6c609e 100644 --- a/Subsurface/Source/Characters/Animation/Ragdoll.cs +++ b/Subsurface/Source/Characters/Animation/Ragdoll.cs @@ -315,7 +315,7 @@ namespace Barotrauma //the collision is ignored if the lowest limb is under the platform if (lowestLimb==null || lowestLimb.Position.Y < structure.Rect.Y) return false; } - else if (structure.StairDirection!=Direction.None && lowestLimb != null) + else if (structure.StairDirection != Direction.None && lowestLimb != null) { float stairPosY = structure.StairDirection == Direction.Right ? lowestLimb.Position.X - structure.Rect.X : structure.Rect.Width - (lowestLimb.Position.X - structure.Rect.X); diff --git a/Subsurface/Source/Characters/Character.cs b/Subsurface/Source/Characters/Character.cs index 0ab519ce5..417abdda3 100644 --- a/Subsurface/Source/Characters/Character.cs +++ b/Subsurface/Source/Characters/Character.cs @@ -253,6 +253,12 @@ namespace Barotrauma } } + public bool DoesBleed + { + get; + private set; + } + public float PressureTimer { @@ -402,6 +408,8 @@ namespace Barotrauma maxHealth = ToolBox.GetAttributeFloat(doc.Root, "health", 100.0f); health = maxHealth; + DoesBleed = ToolBox.GetAttributeBool(doc.Root, "doesbleed", true); + needsAir = ToolBox.GetAttributeBool(doc.Root, "needsair", false); drowningTime = ToolBox.GetAttributeFloat(doc.Root, "drowningtime", 10.0f); @@ -958,7 +966,7 @@ namespace Barotrauma PressureProtection -= deltaTime*100.0f; } - Health -= bleeding; + Health -= bleeding*deltaTime; if (health <= 0.0f) Kill(CauseOfDeath.Bloodloss, false); } @@ -1093,9 +1101,11 @@ namespace Barotrauma //health -= attackResult.Damage; //if (health <= 0.0f && damageType == DamageType.Burn) Kill(CauseOfDeath.Burn); - - Bleeding += attackResult.Bleeding; - + if (DoesBleed) + { + Bleeding += attackResult.Bleeding; + } + return attackResult; } diff --git a/Subsurface/Source/DebugConsole.cs b/Subsurface/Source/DebugConsole.cs index 0f305bae9..985985281 100644 --- a/Subsurface/Source/DebugConsole.cs +++ b/Subsurface/Source/DebugConsole.cs @@ -359,6 +359,11 @@ namespace Barotrauma case "save": if (commands.Length < 2) break; + if (GameMain.EditMapScreen.CharacterMode) + { + GameMain.EditMapScreen.ToggleCharacterMode(); + } + string fileName = string.Join(" ", commands.Skip(1)); if (fileName.Contains("../")) { @@ -369,7 +374,7 @@ namespace Barotrauma if (WayPoint.WayPointList.Find(wp => !wp.MoveWithLevel && wp.SpawnType == SpawnType.Path)==null) { - DebugConsole.ThrowError("No waypoints found in the submarine. Did you forget to generate the waypoints?"); + DebugConsole.ThrowError("No waypoints found in the submarine. AI controlled crew members won't be able to navigate without waypoints."); } if (WayPoint.WayPointList.Find(wp => wp.SpawnType == SpawnType.Cargo) == null) diff --git a/Subsurface/Source/Events/ScriptedEvent.cs b/Subsurface/Source/Events/ScriptedEvent.cs index 73a6e75d5..6528cf79c 100644 --- a/Subsurface/Source/Events/ScriptedEvent.cs +++ b/Subsurface/Source/Events/ScriptedEvent.cs @@ -10,10 +10,10 @@ namespace Barotrauma { private static string configFile = "Content/randomevents.xml"; - const int MaxPreviousEvents = 6; - const float PreviouslyUsedWeight = 10.0f; + //const int MaxPreviousEvents = 6; + //const float PreviouslyUsedWeight = 10.0f; - static List previousEvents = new List(); + //static List previousEvents = new List(); protected string name; protected string description; @@ -109,16 +109,16 @@ namespace Barotrauma eventProbability[i] = ToolBox.GetAttributeInt(element, "commonness", 1); //if the event has been previously selected, it's less likely to be selected now - int previousEventIndex = previousEvents.FindIndex(x => x == i); - if (previousEventIndex >= 0) - { - //how many shifts ago was the event last selected - int eventDist = eventCount - previousEventIndex; + //int previousEventIndex = previousEvents.FindIndex(x => x == i); + //if (previousEventIndex >= 0) + //{ + // //how many shifts ago was the event last selected + // int eventDist = eventCount - previousEventIndex; - float weighting = (1.0f / eventDist) * PreviouslyUsedWeight; + // float weighting = (1.0f / eventDist) * PreviouslyUsedWeight; - eventProbability[i] *= weighting; - } + // eventProbability[i] *= weighting; + //} probabilitySum += eventProbability[i]; @@ -153,7 +153,7 @@ namespace Barotrauma ConstructorInfo constructor = t.GetConstructor(new[] { typeof(XElement) }); object instance = constructor.Invoke(new object[] { element }); - previousEvents.Add(i); + //previousEvents.Add(i); return (ScriptedEvent)instance; } diff --git a/Subsurface/Source/GameSession/GameSession.cs b/Subsurface/Source/GameSession/GameSession.cs index 5a515a208..d16c47c3e 100644 --- a/Subsurface/Source/GameSession/GameSession.cs +++ b/Subsurface/Source/GameSession/GameSession.cs @@ -78,15 +78,14 @@ namespace Barotrauma this.submarine = submarine; } - public GameSession(Submarine selectedSub, string saveFile, string filePath) + public GameSession(Submarine selectedSub, string saveFile, XDocument doc) : this(selectedSub, saveFile) { GameMain.GameSession = this; CrewManager = new CrewManager(); - XDocument doc = ToolBox.TryLoadXml(filePath); - if (doc == null) return; + selectedSub.Name = ToolBox.GetAttributeString(doc.Root, "submarine", selectedSub.Name); foreach (XElement subElement in doc.Root.Elements()) { diff --git a/Subsurface/Source/Items/Components/Machines/Steering.cs b/Subsurface/Source/Items/Components/Machines/Steering.cs index 2ae6cf44b..c9e4353e6 100644 --- a/Subsurface/Source/Items/Components/Machines/Steering.cs +++ b/Subsurface/Source/Items/Components/Machines/Steering.cs @@ -17,8 +17,12 @@ namespace Barotrauma.Items.Components private Vector2 currVelocity; private Vector2 targetVelocity; + private GUITickBox maintainPosTickBox; + private bool autoPilot; + private Vector2? posToMaintain; + private SteeringPath steeringPath; private PathFinder pathFinder; @@ -39,6 +43,9 @@ namespace Barotrauma.Items.Components autoPilot = value; + maintainPosTickBox.Enabled = autoPilot; + + if (autoPilot) { if (pathFinder==null) pathFinder = new PathFinder(WayPoint.WayPointList, false); @@ -46,6 +53,11 @@ namespace Barotrauma.Items.Components ConvertUnits.ToSimUnits(item.WorldPosition), ConvertUnits.ToSimUnits(Level.Loaded.EndPosition)); } + else + { + maintainPosTickBox.Selected = false; + posToMaintain = null; + } } } @@ -87,7 +99,6 @@ namespace Barotrauma.Items.Components IsActive = true; var tickBox = new GUITickBox(new Rectangle(0,25,20,20), "Autopilot", Alignment.TopLeft, GuiFrame); - tickBox.OnSelected = (GUITickBox box) => { AutoPilot = box.Selected; @@ -95,6 +106,10 @@ namespace Barotrauma.Items.Components return true; }; + + maintainPosTickBox = new GUITickBox(new Rectangle(0, 50, 20, 20), "Maintain position", Alignment.TopLeft, GuiFrame); + maintainPosTickBox.Enabled = false; + maintainPosTickBox.OnSelected = ToggleMaintainPosition; } public override void Update(float deltaTime, Camera cam) @@ -179,47 +194,95 @@ namespace Barotrauma.Items.Components private void UpdateAutoPilot(float deltaTime) { - autopilotRayCastTimer -= deltaTime; - - steeringPath.CheckProgress(ConvertUnits.ToSimUnits(item.WorldPosition), 10.0f); - - if (autopilotRayCastTimer<=0.0f && steeringPath.NextNode != null) + if (posToMaintain==null) { - Vector2 diff = ConvertUnits.ToSimUnits(steeringPath.NextNode.Position - item.WorldPosition); - bool nextVisible = true; - for (int x = -1; x < 2; x += 2) + autopilotRayCastTimer -= deltaTime; + + steeringPath.CheckProgress(ConvertUnits.ToSimUnits(item.WorldPosition), 10.0f); + + if (autopilotRayCastTimer<=0.0f && steeringPath.NextNode != null) { - for (int y = -1; y < 2; y += 2) + Vector2 diff = Vector2.Normalize(ConvertUnits.ToSimUnits(steeringPath.NextNode.Position - Submarine.Loaded.WorldPosition)); + + bool nextVisible = true; + for (int x = -1; x < 2; x += 2) { - Vector2 cornerPos = - new Vector2(Submarine.Borders.Width * x, Submarine.Borders.Height * y) / 2.0f; + for (int y = -1; y < 2; y += 2) + { + Vector2 cornerPos = + new Vector2(Submarine.Borders.Width * x, Submarine.Borders.Height * y) / 2.0f; - cornerPos = ConvertUnits.ToSimUnits(cornerPos * 1.2f + Submarine.Loaded.Position); + cornerPos = ConvertUnits.ToSimUnits(cornerPos * 1.2f + Submarine.Loaded.WorldPosition); - if (Submarine.PickBody(cornerPos, cornerPos + diff, null, Physics.CollisionLevel) == null) continue; + float dist = Vector2.Distance(cornerPos, steeringPath.NextNode.SimPosition); - nextVisible = false; - x = 2; - y = 2; + if (Submarine.PickBody(cornerPos, cornerPos + diff*dist, null, Physics.CollisionLevel) == null) continue; + + nextVisible = false; + x = 2; + y = 2; + } } + + if (nextVisible) steeringPath.SkipToNextNode(); + + autopilotRayCastTimer = AutopilotRayCastInterval; } - if (nextVisible) steeringPath.SkipToNextNode(); - - autopilotRayCastTimer = AutopilotRayCastInterval; + if (steeringPath.CurrentNode != null) + { + SteerTowardsPosition(steeringPath.CurrentNode.WorldPosition); + } + } + else + { + SteerTowardsPosition((Vector2)posToMaintain); } - if (steeringPath.CurrentNode != null) + } + + private void SteerTowardsPosition(Vector2 worldPosition) + { + float prediction = 10.0f; + + Vector2 futurePosition = ConvertUnits.ToDisplayUnits(item.Submarine.Velocity) * prediction; + Vector2 targetSpeed = ((worldPosition - item.WorldPosition) - futurePosition); + + if (targetSpeed.Length()>500.0f) { - float prediction = 5.0f; - - Vector2 futurePosition = ConvertUnits.ToDisplayUnits(item.Submarine.Velocity) * prediction; - Vector2 targetSpeed = ((steeringPath.CurrentNode.WorldPosition - item.WorldPosition) - futurePosition); - targetSpeed = Vector2.Normalize(targetSpeed); TargetVelocity = targetSpeed * 100.0f; } + else + { + targetVelocity = targetSpeed/5.0f; + } + + + } + + private bool ToggleMaintainPosition(GUITickBox tickBox) + { + item.NewComponentEvent(this, true, true); + + if (tickBox.Selected) + { + if (Submarine.Loaded == null) + { + posToMaintain = null; + } + else + { + posToMaintain = item.WorldPosition; + } + } + else + { + posToMaintain = null; + } + + return true; } public override void ReceiveSignal(string signal, Connection connection, Item sender, float power=0.0f) @@ -236,6 +299,15 @@ namespace Barotrauma.Items.Components message.Write(targetVelocity.Y); message.Write(autoPilot); + if (autoPilot) + { + message.Write(posToMaintain != null); + if (posToMaintain != null) + { + message.Write(((Vector2)posToMaintain).X); + message.Write(((Vector2)posToMaintain).Y); + } + } return true; } @@ -245,10 +317,22 @@ namespace Barotrauma.Items.Components Vector2 newTargetVelocity = Vector2.Zero; bool newAutoPilot = false; + Vector2? newPosToMaintain = null; + try { newTargetVelocity = new Vector2(message.ReadFloat(), message.ReadFloat()); newAutoPilot = message.ReadBoolean(); + if (newAutoPilot) + { + bool maintainPos = message.ReadBoolean(); + if (maintainPos) + { + newPosToMaintain = new Vector2( + message.ReadFloat(), + message.ReadFloat()); + } + } } catch @@ -258,6 +342,9 @@ namespace Barotrauma.Items.Components TargetVelocity = newTargetVelocity; AutoPilot = newAutoPilot; + + maintainPosTickBox.Selected = newPosToMaintain != null; + posToMaintain = newPosToMaintain; } } } diff --git a/Subsurface/Source/Map/Submarine.cs b/Subsurface/Source/Map/Submarine.cs index f2d4859a1..6ef3443e1 100644 --- a/Subsurface/Source/Map/Submarine.cs +++ b/Subsurface/Source/Map/Submarine.cs @@ -55,7 +55,7 @@ namespace Barotrauma public string Name { get { return name; } - //set { name = value; } + set { name = value; } } public static Vector2 LastPickedPosition diff --git a/Subsurface/Source/Map/SubmarineBody.cs b/Subsurface/Source/Map/SubmarineBody.cs index 335fb4265..6e1094c55 100644 --- a/Subsurface/Source/Map/SubmarineBody.cs +++ b/Subsurface/Source/Map/SubmarineBody.cs @@ -468,7 +468,7 @@ namespace Barotrauma Vector2 limbForce = direction * impact * 0.5f; float length = limbForce.Length(); - if (length > 10.0f) limbForce = (limbForce / length) * 10.0f; + if (length > 5.0f) limbForce = (limbForce / length) * 5.0f; foreach (Character c in Character.CharacterList) { diff --git a/Subsurface/Source/Networking/GameServer.cs b/Subsurface/Source/Networking/GameServer.cs index f6fdbd56c..143c2e9c8 100644 --- a/Subsurface/Source/Networking/GameServer.cs +++ b/Subsurface/Source/Networking/GameServer.cs @@ -181,14 +181,16 @@ namespace Barotrauma.Networking if (DateTime.Now > timeOut) { restRequestHandle.Abort(); - DebugConsole.ThrowError("Couldn't connect to master server (request timed out)"); - registeredToMaster = false; + DebugConsole.NewMessage("Couldn't connect to master server (request timed out)", Color.Red); + break; + //registeredToMaster = false; } - System.Diagnostics.Debug.WriteLine("took "+sw.ElapsedMilliseconds+" ms"); yield return CoroutineStatus.Running; } + System.Diagnostics.Debug.WriteLine("took "+sw.ElapsedMilliseconds+" ms"); + yield return CoroutineStatus.Success; } @@ -198,15 +200,13 @@ namespace Barotrauma.Networking if (response.ErrorException != null) { - DebugConsole.ThrowError("Error while registering to master server", response.ErrorException); - registeredToMaster = false; + DebugConsole.NewMessage("Error while registering to master server (" + response.ErrorException + ")", Color.Red); return; } if (response.StatusCode != System.Net.HttpStatusCode.OK) { DebugConsole.NewMessage("Error while reporting to master server (" + response.StatusCode + ": " + response.StatusDescription + ")", Color.Red); - //registeredToMaster = false; return; } } @@ -224,10 +224,14 @@ namespace Barotrauma.Networking { inGameHUD.Update((float)Physics.step); - //if all characters dead - if (AutoRestart && + bool isCrewDead = ConnectedClients.Find(c => c.Character != null && !c.Character.IsDead)==null && - (myCharacter == null || myCharacter.IsDead)) + (myCharacter == null || myCharacter.IsDead); + + //restart if all characters are dead or submarine is at the end of the level + if ((AutoRestart && isCrewDead) + || + (endRoundAtLevelEnd && Submarine.Loaded!=null && Submarine.Loaded.AtEndPosition)) { EndButtonHit(null, null); UpdateNetLobby(null,null); @@ -284,7 +288,7 @@ namespace Barotrauma.Networking { if (gameStarted) { - if (myCharacter != null) new NetworkEvent(NetworkEventType.EntityUpdate, myCharacter.ID, false); + if (myCharacter != null && !myCharacter.IsDead) new NetworkEvent(NetworkEventType.EntityUpdate, myCharacter.ID, false); foreach (Character c in Character.CharacterList) { diff --git a/Subsurface/Source/Networking/GameServerSettings.cs b/Subsurface/Source/Networking/GameServerSettings.cs index 5c5d76964..3daeadaa9 100644 --- a/Subsurface/Source/Networking/GameServerSettings.cs +++ b/Subsurface/Source/Networking/GameServerSettings.cs @@ -20,7 +20,7 @@ namespace Barotrauma.Networking { public bool ShowNetStats; - private TimeSpan refreshMasterInterval = new TimeSpan(0, 0, 40); + private TimeSpan refreshMasterInterval = new TimeSpan(0, 0, 30); private TimeSpan sparseUpdateInterval = new TimeSpan(0, 0, 0, 3); private SelectionMode subSelectionMode, modeSelectionMode; @@ -41,6 +41,8 @@ namespace Barotrauma.Networking private bool allowSpectating = true; + private bool endRoundAtLevelEnd = true; + public bool AutoRestart { get { return (ConnectedClients.Count == 0) ? false : autoRestart; } @@ -85,16 +87,22 @@ namespace Barotrauma.Networking private void CreateSettingsFrame() { - settingsFrame = new GUIFrame(new Rectangle(0,0,GameMain.GraphicsWidth,GameMain.GraphicsHeight), Color.Black*0.5f); + settingsFrame = new GUIFrame(new Rectangle(0, 0, GameMain.GraphicsWidth, GameMain.GraphicsHeight), Color.Black * 0.5f); - GUIFrame innerFrame = new GUIFrame(new Rectangle(0,0,400,400), null, Alignment.Center, GUI.Style, settingsFrame); + GUIFrame innerFrame = new GUIFrame(new Rectangle(0, 0, 400, 400), null, Alignment.Center, GUI.Style, settingsFrame); - var randomizeLevelBox = new GUITickBox(new Rectangle(0, 0, 20, 20), "Randomize level seed", Alignment.Left, innerFrame); + new GUITextBlock(new Rectangle(0, -15, 0, 20), "Server settings", GUI.Style, innerFrame, GUI.LargeFont); + + var randomizeLevelBox = new GUITickBox(new Rectangle(0, 30, 20, 20), "Randomize level seed", Alignment.Left, innerFrame); randomizeLevelBox.Selected = randomizeSeed; randomizeLevelBox.OnSelected = ToggleRandomizeSeed; + + var endBox = new GUITickBox(new Rectangle(0, 60, 20, 20), "End round when destination reached", Alignment.Left, innerFrame); + endBox.Selected = endRoundAtLevelEnd; + endBox.OnSelected = (GUITickBox) => { endRoundAtLevelEnd = GUITickBox.Selected; return true; }; - new GUITextBlock(new Rectangle(0, 35, 100, 20), "Submarine selection:", GUI.Style, innerFrame); - var selectionFrame = new GUIFrame(new Rectangle(0, 60, 300, 20), null, innerFrame); + new GUITextBlock(new Rectangle(0, 95, 100, 20), "Submarine selection:", GUI.Style, innerFrame); + var selectionFrame = new GUIFrame(new Rectangle(0, 120, 300, 20), null, innerFrame); for (int i = 0; i<3; i++) { var selectionTick = new GUITickBox(new Rectangle(i * 100, 0, 20, 20), ((SelectionMode)i).ToString(), Alignment.Left, selectionFrame); @@ -103,8 +111,8 @@ namespace Barotrauma.Networking selectionTick.UserData = (SelectionMode)i; } - new GUITextBlock(new Rectangle(0, 85, 100, 20), "Mode selection:", GUI.Style, innerFrame); - selectionFrame = new GUIFrame(new Rectangle(0, 110, 300, 20), null, innerFrame); + new GUITextBlock(new Rectangle(0, 145, 100, 20), "Mode selection:", GUI.Style, innerFrame); + selectionFrame = new GUIFrame(new Rectangle(0, 170, 300, 20), null, innerFrame); for (int i = 0; i<3; i++) { var selectionTick = new GUITickBox(new Rectangle(i*100, 0, 20, 20), ((SelectionMode)i).ToString(), Alignment.Left, selectionFrame); @@ -113,7 +121,7 @@ namespace Barotrauma.Networking selectionTick.UserData = (SelectionMode)i; } - var allowSpecBox = new GUITickBox(new Rectangle(0, 150, 20, 20), "Allow spectating", Alignment.Left, innerFrame); + var allowSpecBox = new GUITickBox(new Rectangle(0, 210, 20, 20), "Allow spectating", Alignment.Left, innerFrame); allowSpecBox.Selected = true; allowSpecBox.OnSelected = ToggleAllowSpectating; diff --git a/Subsurface/Source/Screens/EditMapScreen.cs b/Subsurface/Source/Screens/EditMapScreen.cs index b34b2255a..b0b02e5a1 100644 --- a/Subsurface/Source/Screens/EditMapScreen.cs +++ b/Subsurface/Source/Screens/EditMapScreen.cs @@ -292,7 +292,13 @@ namespace Barotrauma selectedTab = (int)obj; return true; } - + + + public void ToggleCharacterMode() + { + ToggleCharacterMode(null,null); + } + private bool ToggleCharacterMode(GUIButton button, object obj) { selectedTab = -1; @@ -397,28 +403,30 @@ namespace Barotrauma if (characterMode) { - if (Entity.FindEntityByID(dummyCharacter.ID)!=dummyCharacter) + if (dummyCharacter == null || Entity.FindEntityByID(dummyCharacter.ID)!=dummyCharacter) { ToggleCharacterMode(null, null); } - - foreach (MapEntity me in MapEntity.mapEntityList) + else { - me.IsHighlighted = false; - } - - if (dummyCharacter.SelectedConstruction==null) - { - Vector2 mouseSimPos = FarseerPhysics.ConvertUnits.ToSimUnits(dummyCharacter.CursorPosition); - foreach (Limb limb in dummyCharacter.AnimController.Limbs) + foreach (MapEntity me in MapEntity.mapEntityList) { - limb.body.SetTransform(mouseSimPos, 0.0f); + me.IsHighlighted = false; } - } - dummyCharacter.ControlLocalPlayer((float)deltaTime, cam, false); - dummyCharacter.Control((float)deltaTime, cam); - cam.TargetPos = Vector2.Zero; + if (dummyCharacter.SelectedConstruction==null) + { + Vector2 mouseSimPos = FarseerPhysics.ConvertUnits.ToSimUnits(dummyCharacter.CursorPosition); + foreach (Limb limb in dummyCharacter.AnimController.Limbs) + { + limb.body.SetTransform(mouseSimPos, 0.0f); + } + } + + dummyCharacter.ControlLocalPlayer((float)deltaTime, cam, false); + dummyCharacter.Control((float)deltaTime, cam); + cam.TargetPos = Vector2.Zero; + } } else { diff --git a/Subsurface/Source/Screens/MainMenuScreen.cs b/Subsurface/Source/Screens/MainMenuScreen.cs index 547c6382a..49e649c3f 100644 --- a/Subsurface/Source/Screens/MainMenuScreen.cs +++ b/Subsurface/Source/Screens/MainMenuScreen.cs @@ -480,9 +480,9 @@ namespace Barotrauma Directory.CreateDirectory(SaveUtil.TempPath); } - File.Copy(selectedSub.FilePath, Path.Combine(SaveUtil.TempPath, "map.sub"), true); + File.Copy(selectedSub.FilePath, Path.Combine(SaveUtil.TempPath, selectedSub.Name+".sub"), true); - selectedSub = new Submarine(Path.Combine(SaveUtil.TempPath, "map.sub"), ""); + selectedSub = new Submarine(Path.Combine(SaveUtil.TempPath, selectedSub.Name + ".sub"), ""); GameMain.GameSession = new GameSession(selectedSub, saveNameBox.Text, GameModePreset.list.Find(gm => gm.Name == "Single Player")); (GameMain.GameSession.gameMode as SinglePlayerMode).GenerateMap(seedBox.Text); @@ -515,7 +515,7 @@ namespace Barotrauma } catch (Exception e) { - DebugConsole.ThrowError("Loading map ''"+saveFile+"'' failed", e); + DebugConsole.ThrowError("Loading save ''"+saveFile+"'' failed", e); return false; } diff --git a/Subsurface/Source/Utils/SaveUtil.cs b/Subsurface/Source/Utils/SaveUtil.cs index dda2aa11a..7f4990037 100644 --- a/Subsurface/Source/Utils/SaveUtil.cs +++ b/Subsurface/Source/Utils/SaveUtil.cs @@ -25,30 +25,16 @@ namespace Barotrauma string tempPath = Path.Combine(SaveFolder, "temp"); - //if (Directory.Exists(tempPath)) - //{ - // Directory.Delete(tempPath, true); - //} - if (!Directory.Exists(tempPath)) { - // DecompressToDirectory(fileName, tempPath, null); - //} - //else - //{ Directory.CreateDirectory(tempPath); } - - - // - //Directory.CreateDirectory(Path.GetDirectoryName(filePath) + "\\temp"); - try { - if (Submarine.Loaded!=null) + if (Submarine.Loaded != null) { - Submarine.Loaded.SaveAs(Path.Combine(tempPath, "map.sub")); + Submarine.Loaded.SaveAs(Path.Combine(tempPath, Submarine.Loaded.Name+".sub")); } } catch (Exception e) @@ -83,8 +69,11 @@ namespace Barotrauma DecompressToDirectory(filePath, TempPath, null); - Submarine selectedMap = new Submarine(Path.Combine(TempPath, "map.sub"), "");// Submarine.Load(); - GameMain.GameSession = new GameSession(selectedMap, fileName, Path.Combine(TempPath, "gamesession.xml")); + XDocument doc = ToolBox.TryLoadXml(Path.Combine(TempPath, "gamesession.xml")); + + string subPath = Path.Combine(TempPath, ToolBox.GetAttributeString(doc.Root, "submarine", "")); + Submarine selectedMap = new Submarine(subPath, "");// Submarine.Load(); + GameMain.GameSession = new GameSession(selectedMap, fileName, doc); //Directory.Delete(tempPath, true); } diff --git a/Subsurface/Source/Utils/UpdaterUtil.cs b/Subsurface/Source/Utils/UpdaterUtil.cs index 97f11f4e0..41eb8c3a0 100644 --- a/Subsurface/Source/Utils/UpdaterUtil.cs +++ b/Subsurface/Source/Utils/UpdaterUtil.cs @@ -174,7 +174,7 @@ namespace Barotrauma string relativePath = GetRelativePath(file, currentDir); string dirRoot = relativePath.Split(Path.DirectorySeparatorChar).First(); - if (dirRoot == "Data") continue; + if (dirRoot != "Content" && dirRoot != "") continue; if (filesToKeep.Contains(relativePath)) continue; diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 522cba962..75965e6de 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ