- Fixed structure-gap links not being saved

- Saving gap orientation
- Waypoint generation works with small hulls and even if SubBody doesn't exist
- Fixed charactermode when a editing mid-round
- Fixed powercontainer charge progressbar position
This commit is contained in:
Regalis
2016-01-24 21:28:27 +02:00
parent 28af6fa1f4
commit 278371638e
12 changed files with 107 additions and 17 deletions
+12 -2
View File
@@ -560,7 +560,9 @@ namespace Barotrauma
{
XElement element = new XElement("Gap");
element.Add(new XAttribute("ID", ID));
element.Add(
new XAttribute("ID", ID),
new XAttribute("horizontal", isHorizontal ? "true" : "false"));
element.Add(new XAttribute("rect",
(int)(rect.X - Submarine.HiddenSubPosition.X) + "," +
@@ -608,7 +610,15 @@ namespace Barotrauma
int.Parse(element.Attribute("height").Value));
}
Gap g = new Gap(rect, submarine);
bool isHorizontal = rect.Height > rect.Width;
var horizontalAttribute = element.Attribute("horizontal");
if (horizontalAttribute!=null)
{
isHorizontal = horizontalAttribute.Value.ToString() == "true";
}
Gap g = new Gap(rect, isHorizontal, submarine);
g.ID = (ushort)int.Parse(element.Attribute("ID").Value);
g.linkedToID = new List<ushort>();
+28
View File
@@ -178,6 +178,34 @@ namespace Barotrauma
InsertToList();
}
public static Rectangle GetBorders()
{
if (!hullList.Any()) return Rectangle.Empty;
Rectangle rect = hullList[0].rect;
foreach (Hull hull in hullList)
{
if (hull.Rect.X < rect.X)
{
rect.Width += rect.X - hull.rect.X;
rect.X = hull.rect.X;
}
if (hull.rect.Right > rect.Right) rect.Width = hull.rect.Right - rect.X;
if (hull.rect.Y > rect.Y)
{
rect.Height += hull.rect.Y - rect.Y;
rect.Y = hull.rect.Y;
}
if (hull.rect.Y - hull.rect.Height < rect.Y - rect.Height) rect.Height = rect.Y - (hull.rect.Y - hull.rect.Height);
}
return rect;
}
public static void GenerateEntityGrid()
{
entityGrid = new EntityGrid(Submarine.Borders, 200.0f);
+5
View File
@@ -147,6 +147,11 @@ namespace Barotrauma
newRect.Width = (int)Math.Max(newRect.Width, Submarine.GridSize.X);
newRect.Height = (int)Math.Max(newRect.Height, Submarine.GridSize.Y);
if (Submarine.Loaded != null)
{
newRect.Location -= Submarine.Loaded.Position.ToPoint();
}
if (PlayerInput.GetMouseState.LeftButton == ButtonState.Released)
{
object[] lobject = new object[] { this, newRect };
+27 -5
View File
@@ -21,6 +21,8 @@ namespace Barotrauma
public float damage;
public Gap gap;
public int GapIndex;
public float lastSentDamage;
public bool isHighLighted;
@@ -613,9 +615,17 @@ namespace Barotrauma
{
if (sections[i].damage == 0.0f) continue;
element.Add(new XElement("section",
new XAttribute("i", i),
new XAttribute("damage", sections[i].damage)));
var sectionElement =
new XElement("section",
new XAttribute("i", i),
new XAttribute("damage", sections[i].damage));
if (sections[i].gap!=null)
{
sectionElement.Add(new XAttribute("gap", sections[i].gap.ID));
}
element.Add(sectionElement);
}
doc.Root.Add(element);
@@ -660,15 +670,27 @@ namespace Barotrauma
switch (subElement.Name.ToString())
{
case "section":
if (subElement.Attribute("i") == null) continue;
int index = ToolBox.GetAttributeInt(subElement, "i", -1);
if (index == -1) continue;
s.sections[int.Parse(subElement.Attribute("i").Value)].damage =
s.sections[index].damage =
ToolBox.GetAttributeFloat(subElement, "damage", 0.0f);
s.sections[index].GapIndex = ToolBox.GetAttributeInt(subElement, "gap", -1);
break;
}
}
}
public override void OnMapLoaded()
{
foreach (WallSection s in sections)
{
if (s.GapIndex == -1) continue;
s.gap = FindEntityByID((ushort)s.GapIndex) as Gap;
}
}
public override bool FillNetworkData(NetworkEventType type, NetBuffer message, object data)
+24 -3
View File
@@ -328,10 +328,31 @@ namespace Barotrauma
float outSideWaypointInterval = 200.0f;
int outsideWaypointDist = 100;
Rectangle borders = new Rectangle(Submarine.Borders.X - outsideWaypointDist, Submarine.Borders.Y + outsideWaypointDist,
Submarine.Borders.Width + outsideWaypointDist*2, Submarine.Borders.Height+outsideWaypointDist*2);
Rectangle borders = Hull.GetBorders();
borders.X -= outsideWaypointDist;
borders.Y += outsideWaypointDist;
borders.Width += outsideWaypointDist * 2;
borders.Height += outsideWaypointDist * 2;
borders.Location -= Submarine.HiddenSubPosition.ToPoint();
if (borders.Width <= outSideWaypointInterval*2)
{
borders.Inflate(outSideWaypointInterval*2 - borders.Width, 0);
}
if (borders.Height <= outSideWaypointInterval * 2)
{
int inflateAmount = (int)(outSideWaypointInterval * 2) - borders.Height;
borders.Y += inflateAmount / 2;
borders.Height += inflateAmount;
}
WayPoint[,] cornerWaypoint = new WayPoint[2,2];
for (int i = 0; i<2; i++)
{
for (float x = borders.X + outSideWaypointInterval; x < borders.Right - outSideWaypointInterval; x += outSideWaypointInterval)
@@ -351,7 +372,7 @@ namespace Barotrauma
cornerWaypoint[i, 1] = WayPoint.WayPointList[WayPointList.Count - 1];
}
for (int i = 0; i < 2; i++)
{
WayPoint wayPoint = null;