public List <D2Stat> GetStats(D2Unit unit) { if (unit == null) { return(null); } if (unit.StatListNode.IsNull) { return(null); } var node = reader.Read <D2StatListEx>(unit.StatListNode); // Get the best available stat array. D2StatArray statArray = node.BaseStats; if (node.ListFlags.HasFlag(StatListFlag.HasCompleteStats)) { statArray = node.FullStats; } // Empty list. if (node.FullStats.Length == 0) { return(new List <D2Stat>()); } // Return the array data and return as list. var stats = reader.ReadArray <D2Stat>(statArray.Address, statArray.Length); return(new List <D2Stat>(stats)); }
public ItemReader(ProcessMemoryReader reader, D2MemoryTable memory) : base(reader, memory) { cachedItemData = new Dictionary <IntPtr, D2ItemData>(); cachedDescriptions = new Dictionary <int, D2ItemDescription>(); globals = reader.Read <D2GlobalData>(reader.ReadAddress32(memory.Address.GlobalData, AddressingMode.Relative)); lowQualityTable = reader.Read <D2SafeArray>(memory.Address.LowQualityItems, AddressingMode.Relative); descriptionTable = reader.Read <D2SafeArray>(memory.Address.ItemDescriptions, AddressingMode.Relative); magicModifiers = reader.Read <ModifierTable>(memory.Address.MagicModifierTable, AddressingMode.Relative); rareModifiers = reader.Read <ModifierTable>(memory.Address.RareModifierTable, AddressingMode.Relative); if (globals != null) { opNestings = reader.ReadArray <ushort>(globals.OpStatNesting, (int)globals.OpStatNestingCount); if (ItemStatCost == null && !globals.ItemStatCost.IsNull) { ItemStatCost = reader.ReadArray <D2ItemStatCost>(globals.ItemStatCost, (int)globals.ItemStatCostCount); } } }