Build 0.20.4.0
This commit is contained in:
@@ -108,6 +108,8 @@ namespace Barotrauma
|
||||
public readonly bool IsWallUpgrade;
|
||||
public readonly LocalizedString Name;
|
||||
|
||||
private readonly object mutex = new object();
|
||||
|
||||
public readonly IEnumerable<Identifier> ItemTags;
|
||||
|
||||
public UpgradeCategory(ContentXElement element, UpgradeModulesFile file) : base(element, file)
|
||||
@@ -119,7 +121,6 @@ namespace Barotrauma
|
||||
ItemTags = selfItemTags.CollectionConcat(prefabsThatAllowUpgrades);
|
||||
|
||||
Identifier nameIdentifier = element.GetAttributeIdentifier("nameidentifier", Identifier.Empty);
|
||||
|
||||
if (!nameIdentifier.IsEmpty)
|
||||
{
|
||||
Name = TextManager.Get($"{nameIdentifier}");
|
||||
@@ -132,10 +133,13 @@ namespace Barotrauma
|
||||
|
||||
public void DeterminePrefabsThatAllowUpgrades()
|
||||
{
|
||||
prefabsThatAllowUpgrades.Clear();
|
||||
prefabsThatAllowUpgrades.UnionWith(ItemPrefab.Prefabs
|
||||
.Where(it => it.GetAllowedUpgrades().Contains(Identifier))
|
||||
.Select(it => it.Identifier));
|
||||
lock (mutex)
|
||||
{
|
||||
prefabsThatAllowUpgrades.Clear();
|
||||
prefabsThatAllowUpgrades.UnionWith(ItemPrefab.Prefabs
|
||||
.Where(it => it.GetAllowedUpgrades().Contains(Identifier))
|
||||
.Select(it => it.Identifier));
|
||||
}
|
||||
}
|
||||
|
||||
public bool CanBeApplied(MapEntity item, UpgradePrefab? upgradePrefab)
|
||||
@@ -153,26 +157,11 @@ namespace Barotrauma
|
||||
|
||||
if (upgradePrefab != null && upgradePrefab.IsDisallowed(item)) { return false; }
|
||||
|
||||
return item.Prefab.GetAllowedUpgrades().Contains(Identifier) ||
|
||||
ItemTags.Any(tag => item.Prefab.Tags.Contains(tag) || item.Prefab.Identifier == tag);
|
||||
}
|
||||
|
||||
public bool CanBeApplied(XElement element, UpgradePrefab prefab)
|
||||
{
|
||||
if ("Structure" == element.NameAsIdentifier()) { return IsWallUpgrade; }
|
||||
|
||||
Identifier identifier = element.GetAttributeIdentifier("identifier", Identifier.Empty);
|
||||
if (identifier.IsEmpty) { return false; }
|
||||
|
||||
ItemPrefab? item = ItemPrefab.Find(null, identifier);
|
||||
if (item == null) { return false; }
|
||||
|
||||
Identifier[] disallowedUpgrades = element.GetAttributeIdentifierArray("disallowedupgrades", Array.Empty<Identifier>());
|
||||
|
||||
if (disallowedUpgrades.Any(s => s == Identifier || s == prefab.Identifier)) { return false; }
|
||||
|
||||
return item.GetAllowedUpgrades().Contains(Identifier) ||
|
||||
ItemTags.Any(tag => item.Tags.Contains(tag) || item.Identifier == tag);
|
||||
lock (mutex)
|
||||
{
|
||||
return item.Prefab.GetAllowedUpgrades().Contains(Identifier) ||
|
||||
ItemTags.Any(tag => item.Prefab.Tags.Contains(tag) || item.Prefab.Identifier == tag);
|
||||
}
|
||||
}
|
||||
|
||||
public static UpgradeCategory? Find(Identifier identifier)
|
||||
|
||||
Reference in New Issue
Block a user