Taking structure offset from origin into account when spawning the sub, repairtool automatically targets last section if welding the second-to-last

This commit is contained in:
Regalis
2016-02-20 14:12:04 +02:00
parent 058a269ecb
commit 8672a47a12
5 changed files with 19 additions and 10 deletions
+4 -1
View File
@@ -119,7 +119,10 @@ namespace Barotrauma
if (level != null)
{
level.Generate();
submarine.SetPosition(level.StartPosition - new Vector2(0.0f, 2000.0f));
Vector2 subOffsetFromCenter = new Vector2(Submarine.Borders.Center.X, Submarine.Borders.Y - Submarine.Borders.Height / 2);
submarine.SetPosition(level.StartPosition - subOffsetFromCenter - new Vector2(0.0f, 2000.0f));
GameMain.GameScreen.BackgroundCreatureManager.SpawnSprites(80);
}
@@ -170,13 +170,19 @@ namespace Barotrauma.Items.Components
//if the next section is small enough, apply the effect to it as well
//(to make it easier to fix a small "left-over" section)
int nextSectionLength = targetStructure.SectionLength(sectionIndex + 1);
if (nextSectionLength > 0 && nextSectionLength < Structure.wallSectionSize * 0.3f)
for (int i = -1; i<2; i+=2)
{
targetStructure.HighLightSection(sectionIndex + 1);
targetStructure.AddDamage(sectionIndex + 1, -StructureFixAmount * degreeOfSuccess);
int nextSectionLength = targetStructure.SectionLength(sectionIndex + i);
if ((sectionIndex==1 && i ==-1) ||
(sectionIndex==targetStructure.SectionCount-2 && i == 1) ||
(nextSectionLength > 0 && nextSectionLength < Structure.wallSectionSize * 0.3f))
{
targetStructure.HighLightSection(sectionIndex + i);
targetStructure.AddDamage(sectionIndex + i, -StructureFixAmount * degreeOfSuccess);
}
}
}
else if ((targetLimb = (targetBody.UserData as Limb)) != null)
{
@@ -239,11 +239,11 @@ namespace Barotrauma.Items.Components
DrawMarker(spriteBatch,
(GameMain.GameSession.Map == null) ? "Start" : GameMain.GameSession.Map.CurrentLocation.Name,
(Level.Loaded.StartPosition - (Submarine.Loaded.Position + Submarine.HiddenSubPosition)), displayScale, center, (rect.Width * 0.55f));
(Level.Loaded.StartPosition - item.WorldPosition), displayScale, center, (rect.Width * 0.55f));
DrawMarker(spriteBatch,
(GameMain.GameSession.Map == null) ? "End" : GameMain.GameSession.Map.SelectedLocation.Name,
(Level.Loaded.EndPosition - (Submarine.Loaded.Position+Submarine.HiddenSubPosition)), displayScale, center, (rect.Width * 0.55f));
(Level.Loaded.EndPosition - item.WorldPosition), displayScale, center, (rect.Width * 0.55f));
if (GameMain.GameSession.Mission != null)
{
@@ -253,7 +253,7 @@ namespace Barotrauma.Items.Components
{
DrawMarker(spriteBatch,
mission.RadarLabel,
mission.RadarPosition - (Submarine.Loaded.Position + Submarine.HiddenSubPosition), displayScale, center, (rect.Width * 0.55f));
mission.RadarPosition - item.WorldPosition, displayScale, center, (rect.Width * 0.55f));
}
}
+1 -1
View File
@@ -294,7 +294,7 @@ namespace Barotrauma
wayPoint.MoveWithLevel = true;
}
//startPosition = pathCells[0].Center;
startPosition.X = pathCells[0].Center.X;
//endPosition = pathCells[pathCells.Count - 1].Center;
foreach (List<Vector2> tunnel in smallTunnels)
@@ -305,7 +305,7 @@ namespace Barotrauma
var msgBox = new GUIMessageBox("Password required:", "", new string[] { "OK", "Cancel" });
var passwordBox = new GUITextBox(new Rectangle(0,40,150,25), Alignment.TopLeft, GUI.Style, msgBox.children[0]);
passwordBox.UserData = "password";
var okButton = msgBox.Buttons[0];
var cancelButton = msgBox.Buttons[1];