forked from Shardstone/trail-into-darkness
updated linq calls to zero allocation zlinq
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user