public static SkyDesc Read(DatReader datReader) { SkyDesc obj = new SkyDesc(); obj.TickSize = datReader.ReadUInt64(); obj.LightTickSize = datReader.ReadUInt64(); uint numDayGroups = datReader.ReadUInt32(); for (uint i = 0; i < numDayGroups; i++) { obj.DayGroups.Add(DayGroup.Read(datReader)); } return(obj); }
public static XpTable ReadFromDat() { // Check the FileCache so we don't need to hit the FileSystem repeatedly if (DatManager.PortalDat.FileCache.ContainsKey(0x0E000018)) { return((XpTable)DatManager.PortalDat.FileCache[0x0E000018]); } else { DatReader datReader = DatManager.PortalDat.GetReaderForFile(0x0E000018); XpTable xp = new XpTable(); datReader.Offset += 4; // Skip the ID. We know what it is. // The counts for each "Table" are at the top of the file. int abilityCount = datReader.ReadInt32(); int vitalCount = datReader.ReadInt32(); int trainedSkillCount = datReader.ReadInt32(); int specializedSkillCount = datReader.ReadInt32(); uint levelCount = datReader.ReadUInt32(); xp.AbilityXpChart = ReadExperienceChart(abilityCount, ref datReader); xp.VitalXpChart = ReadExperienceChart(vitalCount, ref datReader); xp.TrainedSkillXpChart = ReadExperienceChart(trainedSkillCount, ref datReader); xp.SpecializedSkillXpChart = ReadExperienceChart(specializedSkillCount, ref datReader); // The level table is a little different since it has UInt64 data types. LevelingChart levelingXpChart = new LevelingChart(); ulong prevRank = 0; datReader.Offset += 8; // skip level 0 // Start from 1 because dat includes level 0. for (uint i = 1; i <= levelCount; i++) { CharacterLevel characterLevel = new CharacterLevel(); characterLevel.Level = i; characterLevel.TotalXp = datReader.ReadUInt64(); characterLevel.FromPreviousLevel = characterLevel.TotalXp - prevRank; // Store this to use it in the next loop... prevRank = characterLevel.TotalXp; levelingXpChart.Levels.Add(characterLevel); } // The final section is skill credits... It has the same count as levels. int cumulativeSkillPoints = 0; datReader.Offset += 4; // skip level 0 for (int i = 0; i < levelCount; i++) { int skillPoint = datReader.ReadInt32(); cumulativeSkillPoints += skillPoint; levelingXpChart.Levels[i].GrantsSkillPoint = skillPoint == 1; levelingXpChart.Levels[i].CumulativeSkillPoints = cumulativeSkillPoints; } xp.LevelingXpChart = levelingXpChart; // Store this object in the FileCache DatManager.PortalDat.FileCache[0x0E000018] = xp; return(xp); } }
public static GameTime Read(DatReader datReader) { GameTime obj = new GameTime(); obj.ZeroTimeOfYear = datReader.ReadUInt64(); obj.ZeroYear = datReader.ReadUInt32(); obj.DayLength = datReader.ReadUInt32(); obj.DaysPerYear = datReader.ReadUInt32(); obj.YearSpec = datReader.ReadPString(); datReader.AlignBoundary(); uint numTimesOfDay = datReader.ReadUInt32(); for (uint i = 0; i < numTimesOfDay; i++) { obj.TimesOfDay.Add(TimeOfDay.Read(datReader)); } uint numDaysOfTheWeek = datReader.ReadUInt32(); for (uint i = 0; i < numDaysOfTheWeek; i++) { obj.DaysOfTheWeek.Add(datReader.ReadPString()); datReader.AlignBoundary(); } uint numSeasons = datReader.ReadUInt32(); for (uint i = 0; i < numSeasons; i++) { obj.Seasons.Add(Season.Read(datReader)); } return(obj); }
public static XpTable ReadFromDat() { if (instance == null) // We'll store the XP data into the instance the first time it's loaded. No need to read it multiple times. { DatReader datReader = DatManager.PortalDat.GetReaderForFile(0x0E000018); XpTable xp = new XpTable(); datReader.Offset += 4; // Skip the ID. We know what it is. // The counts for each "Table" are at the top of the file. int abilityCount = datReader.ReadInt32(); int vitalCount = datReader.ReadInt32(); int trainedSkillCount = datReader.ReadInt32(); int specializedSkillCount = datReader.ReadInt32(); uint levelCount = datReader.ReadUInt32(); xp.AbilityXpChart = ReadExperienceChart(abilityCount, ref datReader); xp.VitalXpChart = ReadExperienceChart(vitalCount, ref datReader); xp.TrainedSkillXpChart = ReadExperienceChart(trainedSkillCount, ref datReader); xp.SpecializedSkillXpChart = ReadExperienceChart(specializedSkillCount, ref datReader); // The level table is a little different since it has UInt64 data types. LevelingChart levelingXpChart = new LevelingChart(); ulong prevRank = 0; datReader.Offset += 8; // skip level 0 // Start from 1 because dat includes level 0. for (uint i = 1; i <= levelCount; i++) { CharacterLevel characterLevel = new CharacterLevel(); characterLevel.Level = i; characterLevel.TotalXp = datReader.ReadUInt64(); characterLevel.FromPreviousLevel = characterLevel.TotalXp - prevRank; // Store this to use it in the next loop... prevRank = characterLevel.TotalXp; levelingXpChart.Levels.Add(characterLevel); } // The final section is skill credits... It has the same count as levels. int cumulativeSkillPoints = 0; datReader.Offset += 4; // skip level 0 for (int i = 0; i < levelCount; i++) { int skillPoint = datReader.ReadInt32(); cumulativeSkillPoints += skillPoint; levelingXpChart.Levels[i].GrantsSkillPoint = skillPoint == 1; levelingXpChart.Levels[i].CumulativeSkillPoints = cumulativeSkillPoints; } xp.LevelingXpChart = levelingXpChart; instance = xp; } return(instance); }