//private const int dataVersion = 2; //private const float randomSkillRange = 0.15f; //private const float randomSkillMin = 0.4f; //public const float m_maxSkillLevel = 100f; //public const float m_skillCurve = 2f; //public bool m_useSkillCap; //private Player m_player; public void Save(ZPackage pkg) { pkg.Write(2); pkg.Write(this.SkillData.Count); foreach (KeyValuePair <Skills.SkillType, Skills.Skill> keyValuePair in this.SkillData) { pkg.Write((int)keyValuePair.Key); pkg.Write(keyValuePair.Value.m_level); pkg.Write(keyValuePair.Value.m_accumulator); } }
public void Save(ZPackage pkg) { pkg.Write(24); pkg.Write(this.GetMaxHealth()); pkg.Write(this.GetHealth()); pkg.Write(this.GetMaxStamina()); pkg.Write(this.m_firstSpawn); pkg.Write(this.m_timeSinceDeath); pkg.Write(this.m_guardianPower); pkg.Write(this.m_guardianPowerCooldown); this.m_inventory.Save(pkg); pkg.Write(this.m_knownRecipes.Count); foreach (string knownRecipe in this.m_knownRecipes) { pkg.Write(knownRecipe); } pkg.Write(this.m_knownStations.Count); foreach (KeyValuePair <string, int> knownStation in this.m_knownStations) { pkg.Write(knownStation.Key); pkg.Write(knownStation.Value); } pkg.Write(this.m_knownMaterial.Count); foreach (string data in this.m_knownMaterial) { pkg.Write(data); } pkg.Write(this.m_shownTutorials.Count); foreach (string shownTutorial in this.m_shownTutorials) { pkg.Write(shownTutorial); } pkg.Write(this.m_uniques.Count); foreach (string unique in this.m_uniques) { pkg.Write(unique); } pkg.Write(this.m_trophies.Count); foreach (string trophy in this.m_trophies) { pkg.Write(trophy); } pkg.Write(this.m_knownBiome.Count); foreach (Biome biome in this.m_knownBiome) { pkg.Write((int)biome); } pkg.Write(this.m_knownTexts.Count); foreach (KeyValuePair <string, string> knownText in this.m_knownTexts) { pkg.Write(knownText.Key); pkg.Write(knownText.Value); } pkg.Write(this.m_beardItem); pkg.Write(this.m_hairItem); pkg.Write(this.m_skinColor * (m_skinColorGlow + 1)); pkg.Write(this.m_hairColor * (m_hairColorGlow + 1)); pkg.Write(this.ModelIndex); pkg.Write(this.m_foods.Count); foreach (Player.Food food in this.m_foods) { pkg.Write(food.m_name); pkg.Write(food.m_health); pkg.Write(food.m_stamina); } this.Skills.Save(pkg); }
public void Save(ZPackage pkg) { pkg.Write(this.currentVersion); pkg.Write(this.m_inventory.Count(i => !string.IsNullOrWhiteSpace(i.m_name))); foreach (ItemData itemData in this.m_inventory.Where(i => !string.IsNullOrWhiteSpace(i.m_name))) { pkg.Write(itemData.m_name); pkg.Write(itemData.m_stack); pkg.Write(itemData.m_durability); pkg.Write(itemData.m_gridPos); pkg.Write(itemData.m_equiped); pkg.Write(itemData.m_quality); pkg.Write(itemData.m_variant); pkg.Write(itemData.m_crafterID); pkg.Write(itemData.m_crafterName); } }
//public void SaveLogoutPoint() //{ // if (!(bool)(UnityEngine.Object)Player.m_localPlayer || Player.m_localPlayer.IsDead() || Player.m_localPlayer.InIntro()) // return; // this.SetLogoutPoint(Player.m_localPlayer.transform.position); //} private bool SavePlayerToDisk() { string str1 = this.m_filename; string str2 = this.m_filename + ".old"; string str3 = this.m_filename + ".new"; ZPackage zpackage = new ZPackage(); zpackage.Write(Version.m_playerVersion); zpackage.Write(this.m_playerStats.m_kills); zpackage.Write(this.m_playerStats.m_deaths); zpackage.Write(this.m_playerStats.m_crafts); zpackage.Write(this.m_playerStats.m_builds); zpackage.Write(this.m_worldData.Count); foreach (KeyValuePair <long, PlayerProfile.WorldPlayerData> keyValuePair in this.m_worldData) { zpackage.Write(keyValuePair.Key); zpackage.Write(keyValuePair.Value.m_haveCustomSpawnPoint); zpackage.Write(keyValuePair.Value.m_spawnPoint); zpackage.Write(keyValuePair.Value.m_haveLogoutPoint); zpackage.Write(keyValuePair.Value.m_logoutPoint); zpackage.Write(keyValuePair.Value.m_haveDeathPoint); zpackage.Write(keyValuePair.Value.m_deathPoint); zpackage.Write(keyValuePair.Value.m_homePoint); zpackage.Write(keyValuePair.Value.m_mapData != null); if (keyValuePair.Value.m_mapData != null) { zpackage.Write(keyValuePair.Value.m_mapData); } } zpackage.Write(this.m_playerName); zpackage.Write(this.m_playerID); zpackage.Write(this.m_startSeed); if (this.m_playerData != null) { zpackage.Write(true); zpackage.Write(this.m_playerData); } else { zpackage.Write(false); } byte[] hash = zpackage.GenerateHash(); byte[] array = zpackage.GetArray(); FileStream fileStream = File.Create(str3); BinaryWriter binaryWriter = new BinaryWriter((Stream)fileStream); binaryWriter.Write(array.Length); binaryWriter.Write(array); binaryWriter.Write(hash.Length); binaryWriter.Write(hash); binaryWriter.Flush(); fileStream.Flush(true); fileStream.Close(); fileStream.Dispose(); if (File.Exists(str1)) { if (File.Exists(str2)) { File.Delete(str2); } File.Move(str1, str2); } File.Move(str3, str1); return(true); }