fix(core): Removes some uses of Linq (#421)
- [X] Removes some uses of linq - [X] Creates struct based enumerator for Skills - [X] Creates a struct based enumerator for TypeCache - [X] Changes HarvestDefinition to an init array instead of List - [X] Changes HeritageTokenGump Response from List to Array
This commit is contained in:
parent
52356866ed
commit
b921c38879
50 changed files with 1006 additions and 507 deletions
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Server.Network;
|
||||
using Server.Utilities;
|
||||
using QueuePool = Server.Utilities.RefPool<Server.Utilities.QueueRef<Server.Items.Container>>;
|
||||
|
|
@ -1457,7 +1456,11 @@ namespace Server.Items
|
|||
for (var j = 0; j < groups.Count; ++j)
|
||||
{
|
||||
var items = groups[j].ToArray();
|
||||
var total = items.Sum(t => t.Amount);
|
||||
var total = 0;
|
||||
foreach (var item in items)
|
||||
{
|
||||
total += item.Amount;
|
||||
}
|
||||
|
||||
if (total >= best)
|
||||
{
|
||||
|
|
@ -1531,9 +1534,27 @@ namespace Server.Items
|
|||
return best;
|
||||
}
|
||||
|
||||
public int GetAmount(Type type, bool recurse = true) => FindItemsByType(type, recurse).Sum(t => t.Amount);
|
||||
public int GetAmount(Type type, bool recurse = true)
|
||||
{
|
||||
var total = 0;
|
||||
foreach (var item in FindItemsByType(type, recurse))
|
||||
{
|
||||
total += item.Amount;
|
||||
}
|
||||
|
||||
public int GetAmount(Type[] types, bool recurse = true) => FindItemsByType(types, recurse).Sum(t => t.Amount);
|
||||
return total;
|
||||
}
|
||||
|
||||
public int GetAmount(Type[] types, bool recurse = true)
|
||||
{
|
||||
var total = 0;
|
||||
foreach (var item in FindItemsByType(types, recurse))
|
||||
{
|
||||
total += item.Amount;
|
||||
}
|
||||
|
||||
return total;
|
||||
}
|
||||
|
||||
public Item[] FindItemsByType(Type type, bool recurse = true)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ using System;
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Server.ContextMenus;
|
||||
using Server.Items;
|
||||
|
|
@ -3619,28 +3618,27 @@ namespace Server
|
|||
|
||||
var eable = map.GetItemsInRange(p, 0);
|
||||
|
||||
var items = eable.Where(
|
||||
item =>
|
||||
var items = new List<Item>();
|
||||
foreach (var item in eable)
|
||||
{
|
||||
if (item is BaseMulti || item.ItemID > TileData.MaxItemValue)
|
||||
{
|
||||
if (item is BaseMulti || item.ItemID > TileData.MaxItemValue)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var id = item.ItemData;
|
||||
|
||||
if (id.Surface)
|
||||
{
|
||||
var top = item.Z + id.CalcHeight;
|
||||
if (top <= maxZ && top >= z)
|
||||
{
|
||||
z = top;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
continue;
|
||||
}
|
||||
).ToList();
|
||||
|
||||
var id = item.ItemData;
|
||||
|
||||
if (id.Surface)
|
||||
{
|
||||
var top = item.Z + id.CalcHeight;
|
||||
if (top <= maxZ && top >= z)
|
||||
{
|
||||
z = top;
|
||||
}
|
||||
}
|
||||
|
||||
items.Add(item);
|
||||
}
|
||||
|
||||
eable.Free();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue