fix: Refactors getting static tiles to use enumerators (#1611)
### Summary
* Refactors getting static/multi tiles to not use allocations.
* `TileList` is now only used during bootstrapping and uses rented buffers to eliminate extra allocations.
* Replaces `StaticTile[] GetStaticTiles` with:
```cs
Map.StaticTileEnumerable GetStaticTiles(int x, int y);
Map.StaticTileEnumerable GetStaticAndMultiTiles(int x, int y);
Map.StaticTileEnumerable GetMultiTiles(int x, int y);
```
* Removes `Synchronized` and `lock` from TileMatrix. It is no longer considered a multi-thread safe system.
This commit is contained in:
parent
3b1637b2da
commit
f21c9687b2
23 changed files with 359 additions and 512 deletions
|
|
@ -97,7 +97,6 @@ public partial class Map
|
|||
|
||||
public ref struct MultiSectorEnumerator<T> where T : BaseMulti
|
||||
{
|
||||
private Point2D _location;
|
||||
private readonly Span<BaseMulti> _list;
|
||||
private int _index;
|
||||
private T _current;
|
||||
|
|
@ -105,8 +104,6 @@ public partial class Map
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public MultiSectorEnumerator(Map map, Point2D loc)
|
||||
{
|
||||
_location = loc;
|
||||
|
||||
_list = map == null
|
||||
? Span<BaseMulti>.Empty
|
||||
: CollectionsMarshal.AsSpan(map.GetSector(loc.m_X, loc.m_Y).Multis);
|
||||
|
|
@ -118,8 +115,6 @@ public partial class Map
|
|||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
public bool MoveNext()
|
||||
{
|
||||
ref var loc = ref _location;
|
||||
|
||||
while ((uint)_index < (uint)_list.Length)
|
||||
{
|
||||
var current = _list[_index++];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue