ModernUO/Projects/UOContent/Items
Kamron Batman a4cabe2fa4
fix: Optimizes FindItemsByType by removing allocations. (#1515)
### Summary
Container enumeration is in dire need of optimization. Thanks to @stefanomerotta for initiating this work with PR #1443. This PR handles a small part of what Stefan started. Also included are some bug fixes.

### Method Signatures

```cs
// Use with foreach without moving/deleting items
FindItemsByTypeEnumerator<T> FindItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)

// Use with foreach when moving/deleting items
QueuedItemsEnumerator<T> EnumerateItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)

// Use when iterating multiple times or queuing
PooledRefQueue<T> QueueItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)

// Use when iterating multiples times or manipulating elements without traversing
PooledRefList<T> ListItemsByType<T>(bool recurse = true, Predicate<T> predicate = null)
```

* `FindItemsByType<T>` has changed from returning `List<T>` to `FindItemsByTypeEnumerator<T>` - This method is not safe to use in situations where an item may get consumed, deleted, or moved.

* `EnumerateItemsByType<T>` was added as a safe way to iterate and manipulate items.
  * **Note**: EnumerateItemsByType will _completely traverse the container_ before iteration starts because it uses `QueueItemsByType` under the hood.

* `QueueItemsByType<T>`  and `ListItemsByType<T>` was added to return a queue or list of items to iterate multiple times and manipulate the items. This isn't the most efficient since it uses a predicate and can result in 2 or 3 total iterations unnecessarily.

### Bug Fixes
- [X] Fishing had an error in the random check that may have caused slight bias.
2023-09-28 19:36:45 -07:00
..
Addons fix: Updates messages with clilocs (#1381) 2023-03-26 00:54:09 -07:00
Aquarium fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Armor fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
Body Parts feat: Adds SerializedCommandProperty (#1249) 2022-11-14 18:24:33 -08:00
Books chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
Bulletin Boards chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
Champion Artifacts fix: Fixes random bias & Adds back champion arties for UOML (#1235) 2022-11-09 16:33:27 -08:00
Clothing fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
Construction fix: Fixes doors as decorations & optimizes them (#1392) 2023-04-18 19:28:54 -07:00
Containers fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Decoration Artifacts fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
Deeds fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
Facial Formats UO Content (#201) 2020-08-27 18:30:38 -07:00
Farming fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
Food fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Games feat: Adds KR/EC client versions (No actual support yet). (#1506) 2023-09-18 23:53:18 -07:00
Gems fix: Codegens gems (#1059) 2022-06-13 17:38:46 -07:00
Guilds feat: Adds SerializedCommandProperty (#1249) 2022-11-14 18:24:33 -08:00
Jewels feat: Adds IAosItem for items with AosAttributes (#1268) 2022-11-23 10:49:30 -08:00
Lights feat: Adds SerializedCommandProperty (#1249) 2022-11-14 18:24:33 -08:00
Maps chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
Minor Artifacts fix: Fixes serious stacking issue (#1225) 2022-11-02 22:18:44 -07:00
Misc chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
New Haven Quest Rewards fix: Codegen new haven quest rewards (#1269) 2022-11-23 13:00:28 -08:00
PlantsFlowers/Potted fix: Codegens potted plants (#1270) 2022-11-23 13:04:30 -08:00
Quivers fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
Resources fix: Fixes scales, heritage items, and codegens holiday items (#1365) 2023-03-07 22:38:35 -08:00
Shields fix: Fixes crafter deserialize, cleans up bandages, and codegens misc items (#1350) 2023-02-25 00:54:12 -08:00
Skill Items fix: Optimizes FindItemsByType by removing allocations. (#1515) 2023-09-28 19:36:45 -07:00
Special fix: Renames WeightOverloading to StaminaSystem (#1495) 2023-09-06 18:58:45 -07:00
Suits fix: Codegens suits and adds StaffRobe to replace the others (#1468) 2023-08-23 20:25:54 -07:00
Talismans fix: Removes unused SetOldSaveFlag method (#1470) 2023-08-23 22:48:26 -07:00
Traps fix: Codegens healers and fixes flamespurt trap (#1475) 2023-08-25 21:20:13 -07:00
TreasureChests fix: Updates serialization to use v2.0 (#998) 2022-04-17 08:02:15 -07:00
Wands fix: Codegens traps (#1472) 2023-08-25 20:44:37 -07:00
Weapons fix: Fixes untamed creatures not entering houses (#1436) 2023-07-29 15:43:39 -07:00