1 using System.Collections.Generic;
2 using System.Collections.Immutable;
14 [
Serialize(
"",
IsPropertySaveable.Yes, description:
"Optional list of identifiers the item(s) must have. You might for example want to go through all tagged items inside a cabinet, but only remove specific types of items.")]
20 private readonly ImmutableHashSet<Identifier> itemIdentifierSplit;
28 itemIdentifierSplit =
ItemIdentifiers.ToIdentifiers().ToImmutableHashSet();
31 private bool isFinished =
false;
42 public override void Update(
float deltaTime)
44 if (isFinished) {
return; }
47 bool hasValidTargets =
false;
48 foreach (
Entity target
in targets)
52 hasValidTargets =
true;
56 if (!hasValidTargets) {
return; }
58 HashSet<Item> removedItems =
new HashSet<Item>();
59 foreach (
Entity target
in targets)
62 if (inventory !=
null)
64 while (removedItems.Count <
Amount)
68 !removedItems.Contains(it) &&
69 (itemIdentifierSplit.Count == 0 || itemIdentifierSplit.Contains(it.Prefab.Identifier)), recursive:
true);
70 if (item ==
null) {
break; }
72 removedItems.Add(item);
75 else if (target is
Item item)
77 if (itemIdentifierSplit.Count == 0 || itemIdentifierSplit.Contains(item.Prefab.Identifier))
80 removedItems.Add(item);
81 if (removedItems.Count >=
Amount) {
break; }
CharacterInventory Inventory
string? GetAttributeString(string key, string? def)
static EntitySpawner Spawner
void AddItemToRemoveQueue(Item item)
readonly ScriptedEvent ParentEvent
Item FindItem(Func< Item, bool > predicate, bool recursive)
Removes (deletes) a specific item or items.
override void Update(float deltaTime)
override bool IsFinished(ref string goTo)
Has the action finished.
RemoveItemAction(ScriptedEvent parentEvent, ContentXElement element)
IEnumerable< Entity > GetTargets(Identifier tag)