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:
parent
cb1638591b
commit
977fdc2c5a
21 changed files with 543 additions and 461 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue