(5a377a8ee) Unstable v0.9.1000.0
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Barotrauma.IO;
|
||||
using System.Linq;
|
||||
using System.Xml.Linq;
|
||||
|
||||
@@ -55,7 +55,7 @@ namespace Barotrauma
|
||||
DisplayEntities = new List<Pair<MapEntityPrefab, Rectangle>>();
|
||||
foreach (XElement entityElement in doc.Root.Elements())
|
||||
{
|
||||
string identifier = entityElement.GetAttributeString("identifier", "");
|
||||
string identifier = entityElement.GetAttributeString("identifier", entityElement.Name.ToString().ToLowerInvariant());
|
||||
MapEntityPrefab mapEntity = List.FirstOrDefault(p => p.Identifier == identifier);
|
||||
if (mapEntity == null)
|
||||
{
|
||||
@@ -64,9 +64,9 @@ namespace Barotrauma
|
||||
}
|
||||
|
||||
Rectangle rect = entityElement.GetAttributeRect("rect", Rectangle.Empty);
|
||||
if (mapEntity != null && !entityElement.GetAttributeBool("hideinassemblypreview", false))
|
||||
if (mapEntity != null && !entityElement.Elements().Any(e => e.Name.LocalName.Equals("wire", StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
DisplayEntities.Add(new Pair<MapEntityPrefab, Rectangle>(mapEntity, rect));
|
||||
if (!entityElement.GetAttributeBool("hideinassemblypreview", false)) { DisplayEntities.Add(new Pair<MapEntityPrefab, Rectangle>(mapEntity, rect)); }
|
||||
minX = Math.Min(minX, rect.X);
|
||||
minY = Math.Min(minY, rect.Y - rect.Height);
|
||||
maxX = Math.Max(maxX, rect.Right);
|
||||
@@ -74,7 +74,9 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
Bounds = new Rectangle(minX, minY, maxX - minX, maxY - minY);
|
||||
Bounds = minX == int.MaxValue ?
|
||||
new Rectangle(0, 0, 1, 1) :
|
||||
new Rectangle(minX, minY, maxX - minX, maxY - minY);
|
||||
|
||||
Prefabs.Add(this, false);
|
||||
}
|
||||
@@ -89,7 +91,7 @@ namespace Barotrauma
|
||||
CreateInstance(rect.Location.ToVector2(), Submarine.MainSub);
|
||||
}
|
||||
|
||||
public List<MapEntity> CreateInstance(Vector2 position, Submarine sub)
|
||||
public List<MapEntity> CreateInstance(Vector2 position, Submarine sub, bool selectPrefabs = false)
|
||||
{
|
||||
List<MapEntity> entities = MapEntity.LoadAll(sub, configElement, FilePath);
|
||||
if (entities.Count == 0) return entities;
|
||||
@@ -107,10 +109,10 @@ namespace Barotrauma
|
||||
|
||||
MapEntity.MapLoaded(entities, true);
|
||||
#if CLIENT
|
||||
if (Screen.Selected == GameMain.SubEditorScreen)
|
||||
if (Screen.Selected == GameMain.SubEditorScreen && selectPrefabs)
|
||||
{
|
||||
MapEntity.SelectedList.Clear();
|
||||
entities.ForEach(e => MapEntity.AddSelection(e));
|
||||
entities.ForEach(MapEntity.AddSelection);
|
||||
}
|
||||
#endif
|
||||
return entities;
|
||||
|
||||
Reference in New Issue
Block a user