Release 1.9.7.0 - Summer Update 2025
This commit is contained in:
@@ -57,6 +57,18 @@ namespace Barotrauma
|
||||
{
|
||||
ReplaceAttribute(element, attribute);
|
||||
}
|
||||
|
||||
//collect the names of the elements that we want to remove all instances of
|
||||
//(e.g. if a variant wants to remove all fabrication recipes)
|
||||
List<Identifier> elementNamesToRemove = new List<Identifier>();
|
||||
foreach (var subElement in replacement.Elements())
|
||||
{
|
||||
if (subElement.Name.ToString().Equals("clearall", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
elementNamesToRemove.AddRange(subElement.Elements().Select(e => e.Name.ToIdentifier()));
|
||||
}
|
||||
}
|
||||
|
||||
foreach (XElement replacementSubElement in replacement.Elements())
|
||||
{
|
||||
int index = replacement.Elements().ToList().FindAll(e => e.Name.ToString().Equals(replacementSubElement.Name.ToString(), StringComparison.OrdinalIgnoreCase)).IndexOf(replacementSubElement);
|
||||
@@ -67,7 +79,17 @@ namespace Barotrauma
|
||||
bool cleared = false;
|
||||
foreach (var subElement in element.Elements())
|
||||
{
|
||||
if (replacementSubElement.Name.ToString().Equals("clear", StringComparison.OrdinalIgnoreCase))
|
||||
if (elementNamesToRemove.Contains(subElement.NameAsIdentifier()))
|
||||
{
|
||||
if (!elementsToRemove.Contains(subElement)) { elementsToRemove.Add(subElement); }
|
||||
matchingElementFound = true;
|
||||
continue;
|
||||
}
|
||||
if (replacementSubElement.Name.ToString().Equals("clearall", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (replacementSubElement.Name.ToString().Equals("clear", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
matchingElementFound = true;
|
||||
newElementsFromBase.Clear();
|
||||
|
||||
@@ -45,6 +45,20 @@ namespace Barotrauma
|
||||
{
|
||||
OnSort = onSort;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// For iterating through the Prefabs in a deterministic order (e.g. for map generation). Sorting is not cached, so use sparingly.
|
||||
/// </summary>
|
||||
public IOrderedEnumerable<T> GetOrdered()
|
||||
{
|
||||
// UintIdentifier comparison is preferred to Identifier comparison that uses strings
|
||||
if ((typeof(T).IsAssignableFrom(typeof(PrefabWithUintIdentifier))))
|
||||
{
|
||||
return this.OrderBy(p => (p as PrefabWithUintIdentifier)!.UintIdentifier);
|
||||
}
|
||||
|
||||
return this.OrderBy(p => p.Identifier);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Method to be called when calling Add(T prefab, bool override).
|
||||
|
||||
Reference in New Issue
Block a user