fix: Aquarium no longer uses list to kill fish (#2090)

This commit is contained in:
Kamron Batman 2025-01-25 17:41:27 -08:00 committed by GitHub
parent d5160bd6db
commit a8b625b338
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -551,25 +551,21 @@ namespace Server.Items
public virtual void KillFish(int amount)
{
var toKill = new List<BaseFish>();
using var toKill = PooledRefList<Item>.Create();
for (var i = 0; i < Items.Count; i++)
{
if (Items[i] is BaseFish)
if (Items[i] is BaseFish { Dead: false } fish)
{
var fish = (BaseFish)Items[i];
if (!fish.Dead)
{
toKill.Add(fish);
}
toKill.Add(fish);
}
}
while (amount > 0 && toKill.Count > 0)
toKill.Shuffle();
for (var i = 0; i < amount; i++)
{
var kill = toKill.TakeRandomElement();
kill.Kill();
(toKill[i] as BaseFish)!.Kill();
amount -= 1;
LiveCreatures = Math.Max(LiveCreatures - 1, 0);