public ItemBuffMemory(StashItem stashItem, int endOfSection) { (_stashItem, _endOfSection) = (stashItem, endOfSection); int count = Count; var firstBuff = Offsets.FirstItemBuff; for (int i = 0; i < count; i++) { var buffId = MemoryUtilities.Read <uint>(Bytes, firstBuff + (i * 16) + 4); List.Add(Amalur.GetBuff(buffId)); } }
public Item(GameSave gameSave, int typeIdOffset, int offset, int dataLength, int itemBuffsOffset, int itemBuffsLength, int itemGemsOffset, int itemGemsLength) { (_gameSave, TypeIdOffset, ItemOffset) = (gameSave, typeIdOffset, offset); _levelShiftOffset = (byte)(8 * gameSave.Body[TypeIdOffset + 10]); ItemBytes = _gameSave.Body.AsSpan(offset, dataLength).ToArray(); ItemSockets = new ItemSockets(gameSave, itemGemsOffset, itemGemsLength); ItemBuffs = new ItemBuffMemory(gameSave, itemBuffsOffset, itemBuffsLength); PlayerBuffs = new List <Buff>(BuffCount); for (int i = 0; i < PlayerBuffs.Capacity; i++) { PlayerBuffs.Add(Amalur.GetBuff(MemoryUtilities.Read <uint>(ItemBytes, Offsets.FirstBuff + i * 8))); } if (HasCustomName) { ItemName = Encoding.UTF8.GetString(ItemBytes, Offsets.Name, NameLength); } }
internal CoreEffectMemory(Span <byte> buffer) { ReadOnlySpan <byte> bytes = Amalur.Bytes; ReadOnlySpan <byte> coreEffectSequence = new byte[] { 0x84, 0x60, 0x28, 0x00, 0x00 }; coreEffectSequence.CopyTo(buffer.Slice(8)); ItemIndex = bytes.IndexOf(buffer); ReadOnlySpan <byte> span = bytes.Slice(ItemIndex); int count = span[Offsets.EffectCount]; DataLength = Offsets.FirstEffect + (count * 24) + 8; Bytes = span.Slice(0, DataLength).ToArray(); var firstDisplayEffect = Offsets.FirstEffect + (count * 16) + 8; for (int i = 0; i < count; i++) { List.Add(MemoryUtilities.Read <uint>(span, firstDisplayEffect + i * 8)); } }
public Stash(GameSave gameSave, int offset) { (_gameSave, _offset) = (gameSave, offset); Items.Capacity = Count; Span <byte> data = _gameSave.Body.AsSpan(_offset, DataLength); if (Items.Capacity > 0) { var indices = GetAllIndices(data, gameSave.IsRemaster); for (int i = 0; i < indices.Count - 1; i++) { if (Amalur.ItemDefinitions.ContainsKey(MemoryUtilities.Read <uint>(_gameSave.Body, _offset + indices[i]))) { var itemStart = indices[i]; var gems = Array.Empty <Gem>(); if (_gameSave.Body[_offset + indices[i + 1] - 1] != 0xFF) { var gemList = new List <Gem>(); var ix = _offset + indices[i + 1] - 4; uint handle; while ((handle = MemoryUtilities.Read <uint>(_gameSave.Body, ix)) > 4u) { ix -= 4; } for (uint j = 0; j < handle; j++) { i++; if (Amalur.GemDefinitions.ContainsKey(MemoryUtilities.Read <uint>(_gameSave.Body, _offset + indices[i]))) { gemList.Add(new Gem(_gameSave, _offset + indices[i])); } } gems = gemList.ToArray(); } var item = CreateStashItem(gameSave, _offset + itemStart, (i + 1 == indices.Count ? DataLength : indices[i + 1]) - itemStart, gems); Items.Add(item); } } // ok we might read this twice, who cares. if (Amalur.ItemDefinitions.ContainsKey(MemoryUtilities.Read <uint>(_gameSave.Body, _offset + indices[^ 1])))
public StashItem(GameSave gameSave, int offset, int dataLength, Gem[] gems) { ItemOffset = offset; Bytes = gameSave.Body.AsSpan(offset, dataLength).ToArray(); PlayerBuffs.Capacity = BuffCount; var firstBuff = Offsets.FirstBuff; for (int i = 0; i < PlayerBuffs.Capacity; i++) { PlayerBuffs.Add(Amalur.GetBuff(MemoryUtilities.Read <uint>(Bytes, firstBuff + (i * 8)))); } if (HasCustomName) { ItemName = Encoding.UTF8.GetString(Bytes, Offsets.Name, NameLength); } Gems = gems; // socket section is either FF // or 20 02, followed by int32 count, and int32 handle per gem. int socketsStart = gems.Length == 0 ? Bytes.Length - 1 : gems[0].ItemOffset - offset - (4 * (1 + gems.Length)) - 2; ItemBuffs = Bytes[Offsets.HasItemBuffs] == 0x14 ? new ItemBuffMemory(this, socketsStart) : Definition.ItemBuffs; }