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:
Kamron Batman 2022-03-20 19:20:54 -07:00 • committed by GitHub
parent daf89686d1
commit 23532db603
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 585 additions and 447 deletions

View file

@ -30,42 +30,35 @@ namespace Server.Spells.Seventh
if (SpellHelper.CheckTown(p, Caster) && CheckSequence())
{
SpellHelper.Turn(Caster, p);
SpellHelper.GetSurfaceTop(ref p);
var eastToWest = SpellHelper.GetEastToWest(Caster.Location, p);
var loc = new Point3D(p);
Effects.PlaySound(new Point3D(p), Caster.Map, 0x20B);
var eastToWest = SpellHelper.GetEastToWest(Caster.Location, loc);
TimeSpan duration;
Effects.PlaySound(loc, Caster.Map, 0x20B);
if (Core.AOS)
{
duration = TimeSpan.FromSeconds((15 + Caster.Skills.Magery.Fixed / 5) / 7.0);
}
else
{
// (28% of magery) + 2.0 seconds
duration = TimeSpan.FromSeconds(Caster.Skills.Magery.Value * 0.28 + 2.0);
}
TimeSpan duration = Core.AOS
? TimeSpan.FromSeconds((15 + Caster.Skills.Magery.Fixed / 5) / 7.0)
: TimeSpan.FromSeconds(Caster.Skills.Magery.Value * 0.28 + 2.0);
var itemID = eastToWest ? 0x3946 : 0x3956;
for (var i = -2; i <= 2; ++i)
{
var loc = new Point3D(eastToWest ? p.X + i : p.X, eastToWest ? p.Y : p.Y + i, p.Z);
var canFit = SpellHelper.AdjustField(ref loc, Caster.Map, 12, false);
var targetLoc = new Point3D(eastToWest ? loc.X + i : loc.X, eastToWest ? loc.Y : loc.Y + i, loc.Z);
var canFit = SpellHelper.AdjustField(ref targetLoc, Caster.Map, 12, false);
if (!canFit)
{
continue;
}
Item item = new InternalItem(loc, Caster.Map, duration, itemID, Caster);
Item item = new InternalItem(targetLoc, Caster.Map, duration, itemID, Caster);
item.ProcessDelta();
Effects.SendLocationParticles(
EffectItem.Create(loc, Caster.Map, EffectItem.DefaultDuration),
EffectItem.Create(targetLoc, Caster.Map, EffectItem.DefaultDuration),
0x376A,
9,
10,