public static ItemStat Read(IBitReader reader, ushort id) { var itemStat = new ItemStat(); var property = Core.MetaData.ItemStatCostData.GetById(id); if (property == null) { throw new Exception($"No ItemStatCost record found for id: {id} at bit {reader.Position - 9}"); } itemStat.Id = id; itemStat.Stat = property["Stat"].Value; int saveParamBitCount = property["Save Param Bits"].ToInt32(); int encode = property["Encode"].ToInt32(); if (saveParamBitCount != 0) { int saveParam = reader.ReadInt32(saveParamBitCount); //todo is there a better way to identify skill tab stats. switch (property["descfunc"].ToInt32()) { case 14: //+[value] to [skilltab] Skill Levels ([class] Only) : stat id 188 itemStat.SkillTab = saveParam & 0x7; itemStat.SkillLevel = (saveParam >> 3) & 0x1fff; break; default: break; } switch (encode) { case 2: //chance to cast skill case 3: //skill charges itemStat.SkillLevel = saveParam & 0x3f; itemStat.SkillId = (saveParam >> 6) & 0x3ff; break; case 1: case 4: //by times default: itemStat.Param = saveParam; break; } } int saveBits = reader.ReadInt32(property["Save Bits"].ToInt32()); saveBits -= property["Save Add"].ToInt32(); switch (encode) { case 3: //skill charges itemStat.MaxCharges = (saveBits >> 8) & 0xff; itemStat.Value = saveBits & 0xff; break; default: itemStat.Value = saveBits; break; } return(itemStat); }
public GpsElement Decode(IBitReader reader) { int x = reader != null?reader.ReadInt32() : throw new ArgumentNullException(nameof(reader)); int y = reader.ReadInt32(); short altitude = reader.ReadInt16(); short angle = reader.ReadInt16(); byte satellites = reader.ReadByte(); short speed = reader.ReadInt16(); return(new GpsElement(x, y, altitude, speed, angle, satellites)); }
internal void Read(IBitReader reader) { reader.PushFrameLength(24); this._Unknown = reader.ReadInt32(); var skillRankCount = reader.ReadUInt16(); this._SkillRanks.Clear(); for (int k = 0; k < skillRankCount; k++) { this._SkillRanks.Add(reader.ReadInt32()); } reader.PopFrameLength(); }
public GpsElementExt Decode(IBitReader reader) { int x = reader != null?reader.ReadInt32() : throw new ArgumentNullException(nameof(reader)); int y = reader.ReadInt32(); short altitude = (short)Math.Round(reader.ReadInt16() / 10.0); short angle = (short)Math.Round(reader.ReadUInt16() / 100.0); byte satellites = reader.ReadByte(); short speed = reader.ReadInt16(); IoProperty ioProperty = IoProperty.Create(500001, reader.ReadByte()); return(new GpsElementExt(new GpsElement(x, y, altitude, speed, angle, satellites), new IoElement(0, new List <IoProperty>(1) { ioProperty }))); }
internal void Read(IBitReader reader) { reader.PushFrameLength(24); this._ProfileId = reader.ReadInt32(); var powerCount = reader.ReadUInt16(); this._Powers.Clear(); for (int i = 0; i < powerCount; i++) { var power = new PresetPower(); power.Read(reader); this._Powers.Add(power); } reader.PopFrameLength(); }
public Command Decode(IBitReader reader) { byte num = reader != null?reader.ReadByte() : throw new ArgumentNullException(nameof(reader)); Command command; if (CommandIdToType.ContainsKey(num)) { command = ((Command)Activator.CreateInstance(CommandIdToType[num])).Decode(num, reader); } else { command = new Command(num); int count = reader.ReadInt32(); command.Data = reader.ReadBytes(count); } return(command); }
public AvlData Decode(IBitReader reader) { int num1 = reader != null?reader.ReadInt32() : throw new ArgumentNullException(nameof(reader)); int index = 3 & num1 >> 30; AvlDataPriority priority = Priorities[index]; long num2 = num1 & 1073741823; DateTime dateTime = GHepoch.AddSeconds(num2); GhGlobalMask mask = (GhGlobalMask)reader.ReadByte(); GpsElement gps = GpsElement.Default; IoElement ioElement = new IoElement(); if (mask.HasFlag(GhGlobalMask.GpsElement)) { GpsElementExt gpsElementExt = GhGpsElementEncoding.Instance.Decode(reader); gps = gpsElementExt.GPS; ioElement = gpsElementExt.IO; } IList <IoProperty> properties1 = GetProperties(reader, mask, GhGlobalMask.IoInt8, GhIoElementEncoding.Int8); IList <IoProperty> properties2 = GetProperties(reader, mask, GhGlobalMask.IoInt16, GhIoElementEncoding.Int16); IList <IoProperty> properties3 = GetProperties(reader, mask, GhGlobalMask.IoInt32, GhIoElementEncoding.Int32); List <IoProperty> ioPropertyList = new List <IoProperty>(); ioPropertyList.AddRange(ioElement); ioPropertyList.AddRange(properties1 ?? Enumerable.Empty <IoProperty>()); ioPropertyList.AddRange(properties2 ?? Enumerable.Empty <IoProperty>()); ioPropertyList.AddRange(properties3 ?? Enumerable.Empty <IoProperty>()); int eventId = 0; if (priority == AvlDataPriority.Panic) { IoProperty ioProperty = IoProperty.Create(204, (byte)1); ioPropertyList.Add(ioProperty); eventId = ioPropertyList.SingleOrDefault(x => x.Id == 222) == IoProperty.Default ? 204 : 222; } IoElement data = new IoElement(eventId, ioPropertyList); return(new AvlData(priority, dateTime, gps, data)); }
public static Attributes Read(IBitReader reader) { var itemStatCost = Core.MetaData.ItemStatCostData; var attributes = new Attributes { Header = reader.ReadUInt16() }; ushort id = reader.ReadUInt16(9); while (id != 0x1ff) { var property = itemStatCost.GetById(id); int attribute = reader.ReadInt32(property?["CSvBits"].ToInt32() ?? 0); int valShift = property?["ValShift"].ToInt32() ?? 0; if (valShift > 0) { attribute >>= valShift; } attributes.Stats.Add(property?["Stat"].Value ?? string.Empty, attribute); id = reader.ReadUInt16(9); } reader.Align(); return(attributes); }
internal void Read(IBitReader reader, uint version) { this._Level = reader.ReadInt32(); this._IsNew = version >= 5 && reader.ReadBoolean(); }
internal void Read(IBitReader reader) { this._Bools.Clear(); this._Ints.Clear(); this._Floats.Clear(); this._Transforms.Clear(); this._Unknown.Clear(); reader.PushFrameLength(24); var version = reader.ReadUInt16(); if (version >= 2) { var marker = reader.ReadString(); if (marker != "BioMetrics_PlotStartMarker") { throw new SaveFormatException(); } } if (version >= 1) { var falseCount = reader.ReadUInt32(version >= 4 ? 31 : 16); for (int i = 0; i < falseCount; i++) { var key = reader.ReadGuid(); this._Bools.Add(key, false); } var trueCount = reader.ReadUInt32(version >= 4 ? 31 : 16); for (int i = 0; i < trueCount; i++) { var key = reader.ReadGuid(); this._Bools.Add(key, true); } var intCount = reader.ReadUInt16(); for (int i = 0; i < intCount; i++) { var key = reader.ReadGuid(); var value = reader.ReadInt32(); this._Ints.Add(key, value); } var floatCount = reader.ReadUInt16(); for (int i = 0; i < floatCount; i++) { var key = reader.ReadGuid(); var value = reader.ReadFloat32(); this._Floats.Add(key, value); } var transformCount = reader.ReadUInt16(); for (int i = 0; i < transformCount; i++) { var key = reader.ReadGuid(); var value = reader.ReadTransform(); this._Transforms.Add(key, value); } } if (version >= 3) { var unknownCount = reader.ReadUInt16(); for (int i = 0; i < unknownCount; i++) { reader.PushFrameLength(24); var key = reader.ReadUInt32(); var value = reader.ReadGuid(); reader.PopFrameLength(); this._Unknown.Add(key, value); } } reader.PopFrameLength(); }
public void Read(IBitReader reader, ushort baseVersion, bool excludeProfiles, bool excludePresets) { this._Level = reader.ReadInt32(); this._Unknown1 = reader.ReadFloat32(); this._Unknown2 = reader.ReadUInt32(); // skill points? if (baseVersion < 5) { return; } var version = reader.ReadUInt32(); if (version > 6) { throw new SaveFormatException("unsupported version"); } if (version >= 2 && version <= 3) { reader.SkipBits(32); } if (version >= 3) { this._Unknown3 = reader.ReadUInt32(); // skill points? } var skillGroupCount = reader.ReadUInt16(); this._SkillGroups.Clear(); for (int i = 0; i < skillGroupCount; i++) { var skillGroup = new Data.SkillGroup(); skillGroup.Read(reader); this._SkillGroups.Add(skillGroup); } if (excludeProfiles == false) { this._CurrentProfileId = reader.ReadInt32(); var profileCount = reader.ReadUInt16(); this._Profiles.Clear(); for (int i = 0; i < profileCount; i++) { var profile = new Data.Profile(); profile.Read(reader, version); this._Profiles.Add(profile); } } if (excludePresets == false) { this._CurrentPresetIndex = reader.ReadInt32(); var presetCount = reader.ReadUInt16(); this._Presets.Clear(); for (int i = 0; i < presetCount; i++) { var preset = new Data.Preset(); preset.Read(reader); this._Presets.Add(preset); } } }
public virtual void Read(IBitReader reader, ushort version) { this._Quantity = reader.ReadInt32(); this._IsNew = reader.ReadBoolean(); this._Rarity = reader.ReadInt32(); }
internal void Read(IBitReader reader, uint version) { this._ActiveSkills.Clear(); if (version >= 11) { reader.PushFrameLength(24); this._Level = reader.ReadInt32(); this._SkillPointCount = reader.ReadInt32(); this._LowestPurchasableSkillCost = reader.ReadInt32(); this._SkillPointPerLevel = reader.ReadInt32(); this._CharacterId = reader.ReadInt32(); this._MaximumShields = reader.ReadInt32(); this._MaximumHealth = reader.ReadInt32(); var activeSkillCount = reader.ReadUInt16(); for (int i = 0; i < activeSkillCount; i++) { reader.PushFrameLength(24); var activeSkill = new PartyMemberActiveSkill(); activeSkill.LineHash = reader.ReadInt32(); activeSkill.LineRank = reader.ReadInt32(); activeSkill.GroupHash = reader.ReadInt32(); activeSkill.GroupTypeId = reader.ReadInt32(); this._ActiveSkills.Add(activeSkill); reader.PopFrameLength(); } reader.PopFrameLength(); } else { reader.PushFrameLength(24); throw new NotImplementedException(); reader.PopFrameLength(); } }