continuity/Wonderking/Game/Reader/ItemReaderExtensions.cs

86 lines
2.7 KiB
C#
Raw Normal View History

2024-02-07 15:40:36 +00:00
// Licensed to Timothy Schenk under the GNU AGPL Version 3 License.
2023-11-20 18:58:30 +00:00
2023-11-13 20:12:12 +00:00
using Wonderking.Game.Data.Item;
2023-11-13 20:12:12 +00:00
namespace Wonderking.Game.Reader;
public static class ItemReaderExtensions {
public static Stats ReadStats(this BinaryReader reader) {
return new Stats {
Strength = reader.ReadInt32(), //125
Dexterity = reader.ReadInt32(), //129
Intelligence = reader.ReadInt32(), //133
Vitality = reader.ReadInt32(), //137
Luck = reader.ReadInt32(), //141
2023-11-19 16:07:28 +00:00
Wisdom = reader.ReadInt32() //145
};
}
public static ElementalStats ReadElementalStats(this BinaryReader reader) {
return new ElementalStats {
MinimumFireDamage = reader.ReadInt32(), //149
MinimumWaterDamage = reader.ReadInt32(), //153
MinimumDarkDamage = reader.ReadInt32(), //157
MinimumHolyDamage = reader.ReadInt32(), //161
MaximumFireDamage = reader.ReadInt32(), //165
MaximumWaterDamage = reader.ReadInt32(), //169
MaximumDarkDamage = reader.ReadInt32(), //173
MaximumHolyDamage = reader.ReadInt32(), //177
ElementFire = reader.ReadUInt32(), //181
ElementWater = reader.ReadUInt32(), //185
ElementDark = reader.ReadUInt32(), //189
ElementHoly = reader.ReadUInt32(), //193
FireResistance = reader.ReadInt32(), //197
WaterResistance = reader.ReadInt32(), //201
DarkResistance = reader.ReadInt32(), //205
2023-11-19 16:07:28 +00:00
HolyResistance = reader.ReadInt32() //209
};
}
public static ContainedItem[] ReadContainedItems(this BinaryReader reader) {
var list = new ContainedItem[5];
//893
for (var i = 0; i < 5; i++) {
list[i].ID = reader.ReadInt16();
}
//903
for (var i = 0; i < 5; i++) {
list[i].ObtainChance = reader.ReadSingle();
}
return list;
}
public static CraftMaterial[] ReadCraftMaterial(this BinaryReader reader) {
var mats = new CraftMaterial[4];
//329
for (var i = 0; i < 4; ++i) {
mats[i].ID = reader.ReadUInt32();
}
//345
for (var i = 0; i < 4; ++i) {
mats[i].ID = reader.ReadUInt32();
}
return mats;
}
public static ItemOptions ReadItemOptions(this BinaryReader reader) {
var options = new ItemOptions();
options.OptionAvailable = reader.ReadInt32() == 1; //819
var optionIDs = new List<uint>(4);
//823
for (var i = 0; i < 3; i++) {
optionIDs.Add(reader.ReadUInt32());
}
options.OptionIDs = optionIDs.ToArray();
return options;
}
}