fix: Adds multis to map iterators, fixes searching empty nested containers (#1581)

### Summary
Eliminates `IPooledEnumerable<BaseMulti>` and `eable.Free()` from `Map` for multis. This drastically simplifies code that iterates in range, for example:

```cs
foreach (var m in m.GetMultisInRange(5))
{
}
```
The code above no longer requires an eable and calling `Free()`.


### Bug Fixes
- [X] Fixes an issue with searching through nested empty containers.
This commit is contained in:
Kamron Batman 2023-11-05 08:17:34 -08:00 committed by GitHub
parent 1f04a13f67
commit ca3df9cfa7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 960 additions and 860 deletions

View file

@ -240,38 +240,27 @@ public class TileMatrix
{
var tiles = GetStaticBlock(x >> 3, y >> 3);
if (multis)
if (!multis)
{
var eable = _map.GetMultiTilesAt(x, y);
if (eable == PooledEnumeration.NullEnumerable<StaticTile[]>.Instance)
{
return tiles[x & 0x7][y & 0x7];
}
var any = false;
foreach (var multiTiles in eable)
{
if (!any)
{
any = true;
}
m_TilesList.AddRange(multiTiles);
}
if (!any)
{
return tiles[x & 0x7][y & 0x7];
}
m_TilesList.AddRange(tiles[x & 0x7][y & 0x7]);
return m_TilesList.ToArray();
return tiles[x & 0x7][y & 0x7];
}
return tiles[x & 0x7][y & 0x7];
var any = false;
foreach (var multiTiles in _map.GetMultiTilesAt(x, y))
{
any = true;
m_TilesList.AddRange(multiTiles);
}
if (!any)
{
return tiles[x & 0x7][y & 0x7];
}
m_TilesList.AddRange(tiles[x & 0x7][y & 0x7]);
return m_TilesList.ToArray();
}
[MethodImpl(MethodImplOptions.Synchronized)]