fix: Removes GetObjectsInRange and fixes boat planks closing (#1579)

## BREAKING CHANGE

- Deletes `map.GetObjectsInRange` and `map.GetObejctsInBounds`

### Notes

Developers are expected to enumerate mobiles and items separately now using `map.GetMobilesInRange` and `map.GetItemsInRange`. This helps keep the code streamlined so we don't have to maintain multiple copies of ref struct enumerators that do the same thing.


### Fixes

- [X] Fixes bug with planks closing
- [X] Fixes issue with iterating items/mobiles from a null map
This commit is contained in:
Kamron Batman 2023-11-03 13:45:18 -07:00 • committed by GitHub
parent cb1638591b
commit 977fdc2c5a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 543 additions and 461 deletions

View file

@ -17,7 +17,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using Server.Collections;
using Server.Items;
namespace Server;
@ -32,32 +31,13 @@ public static class PooledEnumeration
static PooledEnumeration()
{
EntitySelector = SelectEntities;
MultiSelector = SelectMultis;
MultiTileSelector = SelectMultiTiles;
}
public static Selector<IEntity> EntitySelector { get; set; }
public static Selector<Mobile> MobileSelector { get; set; }
public static Selector<BaseMulti> MultiSelector { get; set; }
public static Selector<StaticTile[]> MultiTileSelector { get; set; }
public static IEnumerable<IEntity> SelectEntities(Map.Sector s, Rectangle2D bounds)
{
var entities = new List<IEntity>(s.Mobiles.Count + s.Items.Count);
foreach (var mob in s.Mobiles)
{
entities.Add(mob);
}
foreach (var item in s.Items)
{
entities.Add(item);
}
return entities;
}
public static IEnumerable<BaseMulti> SelectMultis(Map.Sector s, Rectangle2D bounds)
{
var entities = new List<BaseMulti>(s.Multis.Count);
@ -126,9 +106,6 @@ public static class PooledEnumeration
}
}
public static PooledEnumerable<IEntity> GetEntities(Map map, Rectangle2D bounds) =>
PooledEnumerable<IEntity>.Instantiate(map, bounds, EntitySelector ?? SelectEntities);
public static PooledEnumerable<BaseMulti> GetMultis(Map map, Rectangle2D bounds) =>
PooledEnumerable<BaseMulti>.Instantiate(map, bounds, MultiSelector ?? SelectMultis);