예제 #1
0
 public static void Postfix(string name)
 {
     try
     {
         File.Delete(SavingData.GetBiomeSavePath(name));
     }
     catch
     {
     }
 }
예제 #2
0
        public static void Prefix(World world)
        {
            if (world.m_menu)
            {
                return;
            }

            FileStream biomeStream = null;

            try
            {
                biomeStream = File.OpenRead(SavingData.GetBiomeSavePath(world));
            }
            catch
            {
                if (biomeStream == null)
                {
                    UnityEngine.Debug.Log("No biome data found.");
                    WorldGenOptions.GenOptions.hasBiomeData = false;
                    WorldGenOptions.GenOptions.usingData    = WorldGenOptions.GenOptions.defaultData;
                    return;
                }
            }
            UnityEngine.Debug.Log("Biome data found for " + world.m_name + ".");
            WorldGenOptions.GenOptions.hasBiomeData = true;
            WorldGenData data = new WorldGenData();

            try
            {
                BinaryReader reader  = new BinaryReader(biomeStream);
                int          count   = reader.ReadInt32();
                ZPackage     package = new ZPackage(reader.ReadBytes(count));
                data.ReadBiomeData(ref package);
            }
            catch
            {
                ZLog.LogWarning("Incomplete biome data for " + world.m_name);
            }
            finally
            {
                if (biomeStream != null)
                {
                    biomeStream.Dispose();
                }
                WorldGenOptions.GenOptions.usingData = data;
            }
        }
예제 #3
0
        public static void Postfix(ref World __instance, string name)
        {
            if (name == "menu")
            {
                return;
            }
            ZPackage biomePackage = new ZPackage();

            WorldGenOptions.GenOptions.savedData.WriteBiomeData(ref biomePackage);

            string biomePath = SavingData.GetBiomeSavePath(__instance);

            byte[]       biomeArray        = biomePackage.GetArray();
            FileStream   biomeStream       = File.Create(biomePath);
            BinaryWriter biomeBinaryWriter = new BinaryWriter(biomeStream);

            biomeBinaryWriter.Write(biomeArray.Length);
            biomeBinaryWriter.Write(biomeArray);
            biomeBinaryWriter.Flush();
            biomeStream.Flush(true);
            biomeStream.Close();
            biomeStream.Dispose();
        }