v0.14.6.0
This commit is contained in:
@@ -20,11 +20,7 @@ namespace Barotrauma
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(ItemIdentifier))
|
||||
{
|
||||
ItemIdentifier = element.GetAttributeString("itemidentifiers", "");
|
||||
}
|
||||
if (string.IsNullOrWhiteSpace(ItemIdentifier))
|
||||
{
|
||||
DebugConsole.ThrowError($"Error in event \"{parentEvent.Prefab.Identifier}\" - RemoveItemAction without an item identifier.");
|
||||
ItemIdentifier = element.GetAttributeString("itemidentifiers", null) ?? element.GetAttributeString("identifier", "");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,7 +43,7 @@ namespace Barotrauma
|
||||
bool hasValidTargets = false;
|
||||
foreach (Entity target in targets)
|
||||
{
|
||||
if (target is Character character && character.Inventory != null)
|
||||
if (target is Character character && character.Inventory != null || target is Item)
|
||||
{
|
||||
hasValidTargets = true;
|
||||
break;
|
||||
@@ -55,20 +51,31 @@ namespace Barotrauma
|
||||
}
|
||||
if (!hasValidTargets) { return; }
|
||||
|
||||
List<Item> usedItems = new List<Item>();
|
||||
HashSet<Item> removedItems = new HashSet<Item>();
|
||||
foreach (Entity target in targets)
|
||||
{
|
||||
Inventory inventory = (target as Character)?.Inventory;
|
||||
if (inventory == null) { continue; }
|
||||
while (usedItems.Count < Amount)
|
||||
if (inventory != null)
|
||||
{
|
||||
var item = inventory.FindItem(it =>
|
||||
it != null &&
|
||||
!usedItems.Contains(it) &&
|
||||
it.Prefab.Identifier.Equals(ItemIdentifier, StringComparison.InvariantCultureIgnoreCase), recursive: true);
|
||||
if (item == null) { break; }
|
||||
Entity.Spawner.AddToRemoveQueue(item);
|
||||
usedItems.Add(item);
|
||||
while (removedItems.Count < Amount)
|
||||
{
|
||||
var item = inventory.FindItem(it =>
|
||||
it != null &&
|
||||
!removedItems.Contains(it) &&
|
||||
(string.IsNullOrEmpty(ItemIdentifier) || it.Prefab.Identifier.Equals(ItemIdentifier, StringComparison.InvariantCultureIgnoreCase)), recursive: true);
|
||||
if (item == null) { break; }
|
||||
Entity.Spawner.AddToRemoveQueue(item);
|
||||
removedItems.Add(item);
|
||||
}
|
||||
}
|
||||
else if (target is Item item)
|
||||
{
|
||||
if (string.IsNullOrEmpty(ItemIdentifier) || item.Prefab.Identifier.Equals(ItemIdentifier, StringComparison.InvariantCultureIgnoreCase))
|
||||
{
|
||||
Entity.Spawner.AddToRemoveQueue(item);
|
||||
removedItems.Add(item);
|
||||
if (removedItems.Count >= Amount) { break; }
|
||||
}
|
||||
}
|
||||
}
|
||||
isFinished = true;
|
||||
|
||||
Reference in New Issue
Block a user