fix: Changes Map.Sector.Items to link list. (#1547)
### Summary
Eliminates `IPooledEnumerable<T>` and `eable.Free()` from `Map` for items. This drastically simplifies code that iterates in range, for example:
```cs
foreach (var item in m.GetItemsInRange(5))
{
}
```
The code above no longer requires an eable and calling `Free()`.
This commit is contained in:
parent
1330c4a830
commit
24858f3989
42 changed files with 577 additions and 419 deletions
|
|
@ -1141,6 +1141,7 @@ namespace Server.Multis
|
|||
MovingCrate.DropItem(item);
|
||||
}
|
||||
|
||||
// TODO: Convert to a ref struct enumerator
|
||||
public List<Item> GetItems()
|
||||
{
|
||||
if (Map == null || Map == Map.Internal)
|
||||
|
|
@ -1152,8 +1153,14 @@ namespace Server.Multis
|
|||
var end = new Point2D(X + Components.Max.X + 1, Y + Components.Max.Y + 1);
|
||||
var rect = new Rectangle2D(start, end);
|
||||
|
||||
var eable = Map.GetItemsInBounds(rect);
|
||||
var list = eable.Where(item => item.Movable && IsInside(item)).ToList();
|
||||
var list = new List<Item>();
|
||||
foreach (var item in Map.GetItemsInBounds(rect))
|
||||
{
|
||||
if (item.Movable && IsInside(item))
|
||||
{
|
||||
list.Add(item);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
|
@ -3653,11 +3660,14 @@ namespace Server.Multis
|
|||
}
|
||||
|
||||
var mcl = Components;
|
||||
var eable =
|
||||
map.GetItemsInBounds<Guildstone>(new Rectangle2D(X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height));
|
||||
var bounds = new Rectangle2D(X + mcl.Min.X, Y + mcl.Min.Y, mcl.Width, mcl.Height);
|
||||
|
||||
var item = eable.FirstOrDefault(Contains);
|
||||
return item;
|
||||
foreach (var gs in map.GetItemsInBounds<Guildstone>(bounds))
|
||||
{
|
||||
return gs;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void ResetDynamicDecay()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue