continuity/Wonderking/Game/Reader/ItemReaderExtensions.cs
Timothy Schenk 76991338f3
All checks were successful
Build, Package and Push Images / preprocess (push) Successful in 1s
Build, Package and Push Images / build (push) Successful in 24s
Build, Package and Push Images / sonarqube (push) Has been skipped
Build, Package and Push Images / sbom-scan (push) Successful in 31s
Build, Package and Push Images / container-build (push) Successful in 1m10s
Build, Package and Push Images / container-sbom-scan (push) Successful in 33s
feat: memory and cpu usage reduction + startup time improved
2023-11-15 22:12:59 +01:00

96 lines
2.7 KiB
C#

using Wonderking.Game.Data.Item;
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
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
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;
}
}