continuity/Wonderking/Game/Reader/ItemReader.cs

104 lines
4.8 KiB
C#
Raw Normal View History

using Wonderking.Game.Data;
namespace Wonderking.Game.Reader;
public class ItemReader(string path) : DataReader<ItemObject>(path)
{
public override uint GetAmountOfEntries()
{
return (uint)((this.DatFileContent.Length - 9) / this.GetSizeOfEntry());
}
public override ItemObject GetEntry(uint entryId)
{
var item = new ItemObject();
var arraySegment = new ArraySegment<byte>(DatFileContent,
9 + (int)entryId * this.GetSizeOfEntry(), this.GetSizeOfEntry());
var reader = new BinaryReader(new MemoryStream(arraySegment.ToArray()));
item.ItemID = reader.ReadUInt32(); //9
item.Disabled = reader.ReadUInt32() == 1; //13
item.ItemType = reader.ReadUInt32(); //17
item.Unknown2 = reader.ReadBytes(4); //21
item.Unknown3 = reader.ReadBytes(4); //25
item.ClassNo1 = reader.ReadUInt32(); //29
item.ClassNo2 = reader.ReadUInt32(); //33
item.ClassNo3 = reader.ReadUInt32(); //37
item.ClassNo4 = reader.ReadUInt32(); //41
item.SlotNo1 = reader.ReadUInt32(); //45
item.SlotNo2 = reader.ReadUInt32(); //49
item.Unknown4 = reader.ReadBytes(4); //53
item.IsCash = reader.ReadUInt32(); //57
item.Unknown5 = reader.ReadBytes(4); //61
item.Price = reader.ReadUInt32(); //65
item.Unknown7 = reader.ReadBytes(4); //69
item.MaxNumber = reader.ReadUInt32(); //73
item.Unknown17 = reader.ReadBytes(12); //77
item.MaximumLevelRequirement = reader.ReadUInt32(); //89
item.SexNo = reader.ReadUInt32(); //93
item.WeaponSomething = reader.ReadUInt32(); //97
item.Unknown8 = reader.ReadBytes(4); //101
item.R2C = reader.ReadBytes(16); //105
item.Unknown9 = reader.ReadBytes(4); //121
item.Stats = reader.ReadStats(); //125
item.ElementalStats = reader.ReadElementalStats(); //149
item.R7C = reader.ReadBytes(4); //213
item.R8C = reader.ReadBytes(8); //217
item.Speed = reader.ReadSingle(); //225
item.Jump = reader.ReadSingle(); //229
item.StatDefense = reader.ReadInt32(); //233
item.MagicID = reader.ReadUInt32(); //237
item.Unknown13 = reader.ReadBytes(4); //241
item.Unknown14 = reader.ReadBytes(4); //245
item.AdditionalHealthRecoveryVolume = reader.ReadInt32(); //249
item.R9C_1 = reader.ReadBytes(4); //253
item.AdditionalManaRecoveryVolume = reader.ReadInt32(); //257
item.R9C_2 = reader.ReadBytes(4); //261
item.R10C = reader.ReadBytes(8); //265
item.AdditionalHealthPoints = reader.ReadInt32(); //273
item.AdditionalManaPoints = reader.ReadInt32(); //277
item.IsArrow = reader.ReadBoolean(); //281
item.Unknown18 = reader.ReadBytes(7); //282
item.AdditionalEvasionRate = reader.ReadInt32(); //289
item.HitRate = reader.ReadInt32(); //293
item.ChanceToHit = reader.ReadInt32(); //297
item.MagicalDamage = reader.ReadInt32(); //301
item.CriticalHitChance = reader.ReadInt32(); //305
item.R12C = reader.ReadBytes(4); //309
item.Unknown16 = reader.ReadBytes(4); //313
item.MinimalAttackDamage = reader.ReadInt32(); //317
item.MaximalAttackDamage = reader.ReadInt32(); //321
item.PhysicalDamage = reader.ReadInt32(); //325
item.CraftMaterial = reader.ReadCraftMaterial(); //329
item.CraftResultAmount = reader.ReadUInt32(); //361
item.R14C = reader.ReadBytes(4); //365
item.CraftResultItem = reader.ReadUInt32(); //369
item.R15C = reader.ReadBytes(4); //373
item.R16C = reader.ReadBytes(20); //377
item.InventoryX = reader.ReadInt32(); //397
item.InventoryY = reader.ReadInt32(); //401
item.InventoryWidth = reader.ReadInt32(); //405
item.InventoryHeight = reader.ReadInt32(); //409
item.SheetID = reader.ReadInt32(); //413
item.Name = reader.ReadString(20); //417
item.Description = reader.ReadString(85); //427
item.Unknown1 = reader.ReadBytes(175); //493
item.IsEnchantable = reader.ReadUInt32() == 1; //687
item.Unknown1_2 = reader.ReadBytes(104); //687
item.SetItems = reader.ReadArray<uint>(5);
item.SetID = reader.ReadUInt32(); //691
item.Options = reader.ReadItemOptions(); //819
item.Unknown19 = reader.ReadBytes(23); //835
item.PetID = reader.ReadByte(); //858
item.Unknown20 = reader.ReadBytes(20); //859
item.HitBoxScaling = reader.ReadByte(); //879
item.Unknown20_2 = reader.ReadBytes(13); //880
item.ContainedItems = reader.ReadContainedItems(); //893
item.IsQuestItem = reader.ReadBoolean(); //923
item.MinimumLevelRequirement = reader.ReadByte(); //924
item.Unknown21_2 = reader.ReadBytes(6); //925
reader.Dispose(); //931
return item;
}
}