(6eeea9b7c) v0.9.10.0.0

This commit is contained in:
Joonas Rikkonen
2020-06-04 16:41:07 +03:00
parent ce4ccd99ac
commit eeac247a8e
366 changed files with 7772 additions and 3692 deletions
@@ -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;
@@ -10,11 +10,14 @@ namespace Barotrauma
{
partial class ItemAssemblyPrefab : MapEntityPrefab
{
private string name;
private readonly string name;
public override string Name { get { return name; } }
public static readonly PrefabCollection<ItemAssemblyPrefab> Prefabs = new PrefabCollection<ItemAssemblyPrefab>();
public static readonly string VanillaSaveFolder = Path.Combine("Content", "Items", "Assemblies");
public static readonly string SaveFolder = "ItemAssemblies";
private bool disposed = false;
public override void Dispose()
{
@@ -50,12 +53,25 @@ namespace Barotrauma
name = TextManager.Get("EntityName." + identifier, returnNull: true) ?? originalName;
Description = TextManager.Get("EntityDescription." + identifier, returnNull: true) ?? Description;
List<ushort> containedItemIDs = new List<ushort>();
foreach (XElement entityElement in doc.Root.Elements())
{
var containerElement = entityElement.Elements().FirstOrDefault(e => e.Name.LocalName.Equals("itemcontainer", StringComparison.OrdinalIgnoreCase));
if (containerElement == null) { continue; }
var itemIds = containerElement.GetAttributeIntArray("contained", new int[0]);
containedItemIDs.AddRange(itemIds.Select(id => (ushort)id));
}
int minX = int.MaxValue, minY = int.MaxValue;
int maxX = int.MinValue, maxY = int.MinValue;
DisplayEntities = new List<Pair<MapEntityPrefab, Rectangle>>();
foreach (XElement entityElement in doc.Root.Elements())
{
string identifier = entityElement.GetAttributeString("identifier", "");
ushort id = (ushort)entityElement.GetAttributeInt("ID", 0);
if (id > 0 && containedItemIDs.Contains(id)) { continue; }
string identifier = entityElement.GetAttributeString("identifier", entityElement.Name.ToString().ToLowerInvariant());
MapEntityPrefab mapEntity = List.FirstOrDefault(p => p.Identifier == identifier);
if (mapEntity == null)
{
@@ -64,9 +80,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 +90,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);
}
@@ -142,11 +160,14 @@ namespace Barotrauma
List<string> itemAssemblyFiles = new List<string>();
//find assembly files in the item assembly folder
string directoryPath = Path.Combine("Content", "Items", "Assemblies");
if (Directory.Exists(directoryPath))
//find assembly files in the item assembly folders
if (Directory.Exists(VanillaSaveFolder))
{
itemAssemblyFiles.AddRange(Directory.GetFiles(directoryPath));
itemAssemblyFiles.AddRange(Directory.GetFiles(VanillaSaveFolder));
}
if (Directory.Exists(SaveFolder))
{
itemAssemblyFiles.AddRange(Directory.GetFiles(SaveFolder));
}
//find assembly files in selected content packages