fix: Cleans up LINQ calls. (#965)
- [X] Removes several `ToList()` uses with `PooledRefQueue` - [X] Adds a `PeekRandom` to PooledRefQueue - [X] Updates EV/BS so they dispel each other in a more efficient manner. - [X] Fixes Firebomb so it works like a normal firefield. - [X] Fixes field spells so they aren't unnecessarily using a Point3D ref more than necessary. - [X] Removes extra allocation in campfire by using reverse loop. - [X] Removes other LINQ calls that aren't needed.
This commit is contained in:
parent
daf89686d1
commit
23532db603
40 changed files with 585 additions and 447 deletions
|
|
@ -180,6 +180,22 @@ namespace Server.Collections
|
|||
return _array[_head];
|
||||
}
|
||||
|
||||
public T PeekRandom()
|
||||
{
|
||||
if (_size == 0)
|
||||
{
|
||||
ThrowForEmptyQueue();
|
||||
}
|
||||
|
||||
var index = _head + Utility.Random(_size);
|
||||
if (index >= _array.Length)
|
||||
{
|
||||
index -= _array.Length;
|
||||
}
|
||||
|
||||
return _array[index];
|
||||
}
|
||||
|
||||
public bool TryPeek([MaybeNullWhen(false)] out T result)
|
||||
{
|
||||
if (_size == 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue