(d95fc9893) Fixed crashing when dragging waypoints in the sub editor due to waypoints not being assigned a prefab

This commit is contained in:
Joonas Rikkonen
2019-03-29 17:23:47 +02:00
parent af1f8be4fa
commit 296ec8bab8
3 changed files with 16 additions and 7 deletions
@@ -101,8 +101,14 @@ namespace Barotrauma
}
}
public WayPoint(Rectangle newRect, Submarine submarine)
: base (null, submarine)
: this (MapEntityPrefab.Find(null, "waypoint"), newRect, submarine)
{
}
public WayPoint(MapEntityPrefab prefab, Rectangle newRect, Submarine submarine)
: base (prefab, submarine)
{
rect = newRect;
linkedTo = new ObservableCollection<MapEntity>();
@@ -602,11 +608,14 @@ namespace Barotrauma
int.Parse(element.Attribute("y").Value),
(int)Submarine.GridSize.X, (int)Submarine.GridSize.Y);
WayPoint w = new WayPoint(rect, submarine);
w.ID = (ushort)int.Parse(element.Attribute("ID").Value);
Enum.TryParse(element.GetAttributeString("spawn", "Path"), out SpawnType spawnType);
WayPoint w = new WayPoint(MapEntityPrefab.Find(null, spawnType == SpawnType.Path ? "waypoint" : "spawnpoint"), rect, submarine)
{
ID = (ushort)int.Parse(element.Attribute("ID").Value)
};
Enum.TryParse(element.GetAttributeString("spawn", "Path"), out w.spawnType);
w.spawnType = spawnType;
string idCardDescString = element.GetAttributeString("idcarddesc", "");
if (!string.IsNullOrWhiteSpace(idCardDescString))