updated linq calls to zero allocation zlinq

This commit is contained in:
Sebastian Bularca
2026-04-02 09:12:37 +02:00
parent 36d3f112ef
commit 530ffef338
16 changed files with 131 additions and 131 deletions

View File

@@ -1,7 +1,7 @@
using Jovian.Logger;
using System;
using System.Collections.Generic;
using System.Linq;
using ZLinq;
using UnityEngine;
namespace Nox.Game {
@@ -45,7 +45,7 @@ namespace Nox.Game {
}
public IReadOnlyCollection<IPerk> GetAll() {
return perkPool.Values.ToList();
return perkPool.Values.AsValueEnumerable().ToList();
}
public IPerk GetById(Guid perkId) {
@@ -55,14 +55,14 @@ namespace Nox.Game {
public IReadOnlyCollection<IPerk> GetPerksFor(IEntityDefinition character) {
if(character == null) {
return perkPool.Values.ToList();
return perkPool.Values.AsValueEnumerable().ToList();
}
var ownedPerkIds = character.Perks.perks
var ownedPerkIds = character.Perks.perks.AsValueEnumerable()
.Select(p => p.Id)
.ToHashSet();
return perkPool.Values.Where(p => !ownedPerkIds.Contains(p.Id)).ToList();
return perkPool.Values.AsValueEnumerable().Where(p => !ownedPerkIds.Contains(p.Id)).ToList();
}
public bool TryAddPerk(IEntityDefinition character, Guid perkId) {
@@ -74,7 +74,7 @@ namespace Nox.Game {
GlobalLogger.LogException("Cannot add a perk with an empty Id!", LogCategory.GameLogic);
}
if(character.Perks.perks.Any(p => p != null && p.Id == perkId)) {
if(character.Perks.perks.AsValueEnumerable().Any(p => p != null && p.Id == perkId)) {
return false;
}