Skip to content

Commit

Permalink
Merge branch 'main' into Refactor/BaseAI-Movement-Bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Bohicatv authored Jan 26, 2025
2 parents bfb9100 + ea36423 commit 6fd30b5
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions Projects/UOContent/Items/Aquarium/Aquarium.cs
Original file line number Diff line number Diff line change
Expand Up @@ -551,25 +551,25 @@ public int FoodNumber() =>

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();
if (amount > toKill.Count)
{
amount = toKill.Count;
}

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);
Expand Down

0 comments on commit 6fd30b5

Please sign in to comment.