- disabled unnecessary hull updates during loading (items/gaps find the hull when everything is loaded instead of every time a hull is created or moved)

- fixed item.Submarine not being set in item.FindHull
This commit is contained in:
Regalis11
2016-05-14 23:01:57 +03:00
parent d884f84346
commit c546c42a8b
5 changed files with 47 additions and 24 deletions

View File

@@ -319,7 +319,7 @@ namespace Barotrauma
rect = newRect;
FindHull();
if (submarine==null || !submarine.Loading) FindHull();
condition = 100.0f;
@@ -474,7 +474,7 @@ namespace Barotrauma
ic.Move(amount);
}
if (body != null) FindHull();
if (body != null && (Submarine==null || !Submarine.Loading)) FindHull();
}
public Rectangle TransformTrigger(Rectangle trigger, bool world = false)
@@ -512,11 +512,10 @@ namespace Barotrauma
CurrentHull = Hull.FindHull(WorldPosition, CurrentHull);
if (body!=null)
{
body.Submarine = CurrentHull == null ? null : Submarine.Loaded;
Submarine = CurrentHull == null ? null : Submarine.Loaded;
body.Submarine = Submarine;
}
return CurrentHull;
}

View File

@@ -603,8 +603,9 @@ namespace Barotrauma
public override void OnMapLoaded()
{
UpdateHulls();
FindHulls();
}
public override XElement Save(XDocument doc)
{
XElement element = new XElement("Gap");

View File

@@ -85,8 +85,11 @@ namespace Barotrauma
{
base.Rect = value;
Item.UpdateHulls();
Gap.UpdateHulls();
if (Submarine == null || !Submarine.Loading)
{
Item.UpdateHulls();
Gap.UpdateHulls();
}
}
}
@@ -205,14 +208,15 @@ namespace Barotrauma
hullList.Add(this);
ConnectedGaps = new List<Gap>();
Item.UpdateHulls();
Gap.UpdateHulls();
if (submarine==null || !submarine.Loading)
{
Item.UpdateHulls();
Gap.UpdateHulls();
}
Volume = 0.0f;
InsertToList();
}
@@ -279,16 +283,22 @@ namespace Barotrauma
rect.X += (int)amount.X;
rect.Y += (int)amount.Y;
Item.UpdateHulls();
Gap.UpdateHulls();
if (Submarine==null || !Submarine.Loading)
{
Item.UpdateHulls();
Gap.UpdateHulls();
}
}
public override void Remove()
{
base.Remove();
Item.UpdateHulls();
Gap.UpdateHulls();
if (Submarine == null || !Submarine.Loading)
{
Item.UpdateHulls();
Gap.UpdateHulls();
}
List<FireSource> fireSourcesToRemove = new List<FireSource>(fireSources);
foreach (FireSource fireSource in fireSourcesToRemove)

View File

@@ -627,16 +627,14 @@ namespace Barotrauma
if (linked != null) e.linkedTo.Add(linked);
}
}
for (int i = 0; i < mapEntityList.Count; i++)
{
if (mapEntityList[i].Submarine != null) mapEntityList[i].Move(Submarine.HiddenSubPosition);
}
for (int i = 0; i<mapEntityList.Count; i++)
{
mapEntityList[i].OnMapLoaded();
}
Item.UpdateHulls();
Gap.UpdateHulls();
}

View File

@@ -71,6 +71,12 @@ namespace Barotrauma
get { return lastPickedFraction; }
}
public bool Loading
{
get;
private set;
}
public bool GodMode
{
get;
@@ -676,7 +682,8 @@ namespace Barotrauma
public void Load()
{
Unload();
//string file = filePath;
Loading = true;
XDocument doc = OpenDoc(filePath);
if (doc == null || doc.Root == null) return;
@@ -758,6 +765,14 @@ namespace Barotrauma
loaded = this;
Hull.GenerateEntityGrid();
for (int i = 0; i < MapEntity.mapEntityList.Count; i++)
{
if (MapEntity.mapEntityList[i].Submarine != this) continue;
MapEntity.mapEntityList[i].Move(HiddenSubPosition);
}
Loading = false;
MapEntity.MapLoaded();