Represents a spawn point.
Example #1
0
        /// <summary>
        /// Loads the file from the specified stream.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        public override void Load(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream, Encoding.GetEncoding("EUC-KR"));

            int blockCount = reader.ReadInt32();

            for (int i = 0; i < blockCount; i++) {
                ZoneBlock type = (ZoneBlock)reader.ReadInt32();
                int offset = reader.ReadInt32();

                long nextBlock = stream.Position;
                stream.Seek(offset, SeekOrigin.Begin);

                switch (type) {
                    case ZoneBlock.Info:
                        Type = (ZoneType)reader.ReadInt32();
                        Width = reader.ReadInt32();
                        Height = reader.ReadInt32();
                        GridCount = reader.ReadInt32();
                        GridSize = reader.ReadSingle();
                        StartPosition = new IntVector2(reader.ReadInt32(), reader.ReadInt32());

                        for (int w = 0; w < Width; w++) {
                            for (int h = 0; h < Height; h++) {
                                Positions[w, h].IsUsed = reader.ReadBoolean();
                                Positions[w, h].Position = reader.ReadVector2();
                            }
                        }
                        break;
                    case ZoneBlock.SpawnPoints:
                        int spawnCount = reader.ReadInt32();

                        for (int j = 0; j < spawnCount; j++) {
                            SpawnPoint spawnPoint = new SpawnPoint();
                            spawnPoint.Position = reader.ReadVector3();
                            spawnPoint.Name = reader.ReadByteString();

                            SpawnPoints.Add(spawnPoint);
                        }
                        break;
                    case ZoneBlock.Textures:
                        int textureCount = reader.ReadInt32();

                        for (int j = 0; j < textureCount; j++) {
                            Textures.Add(reader.ReadByteString());
                        }
                        break;
                    case ZoneBlock.Tiles:
                        int tileCount = reader.ReadInt32();

                        for (int j = 0; j < tileCount; j++) {
                            ZoneTile tile = new ZoneTile();
                            tile.Layer1 = reader.ReadInt32();
                            tile.Layer2 = reader.ReadInt32();
                            tile.Offset1 = reader.ReadInt32();
                            tile.Offset2 = reader.ReadInt32();
                            tile.BlendingEnabled = reader.ReadInt32() != 0;
                            tile.Rotation = (TileRotation)reader.ReadInt32();
                            tile.TileType = reader.ReadInt32();

                            Tiles.Add(tile);
                        }
                        break;
                    case ZoneBlock.Economy:
                        Name = reader.ReadByteString();
                        IsUnderground = reader.ReadInt32() != 0;
                        BackgroundMusicFilePath = reader.ReadByteString();
                        SkyFilePath = reader.ReadByteString();
                        EconomyCheckRate = reader.ReadInt32();
                        PopulationBase = reader.ReadInt32();
                        PopulationGrowthRate = reader.ReadInt32();
                        MetalConsumption = reader.ReadInt32();
                        StoneConsumption = reader.ReadInt32();
                        WoodConsumption = reader.ReadInt32();
                        LeatherConsumption = reader.ReadInt32();
                        ClothConsumption = reader.ReadInt32();
                        AlchemyConsumption = reader.ReadInt32();
                        ChemicalConsumption = reader.ReadInt32();
                        IndustrialConsumption = reader.ReadInt32();
                        MedicineConsumption = reader.ReadInt32();
                        FoodConsumption = reader.ReadInt32();
                        break;
                }

                if (i < blockCount - 1) {
                    stream.Seek(nextBlock, SeekOrigin.Begin);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Loads the file from the specified stream.
        /// </summary>
        /// <param name="stream">The stream to read from.</param>
        public override void Load(Stream stream)
        {
            BinaryReader reader = new BinaryReader(stream, Encoding.GetEncoding("EUC-KR"));

            int blockCount = reader.ReadInt32();

            for (int i = 0; i < blockCount; i++)
            {
                ZoneBlock type   = (ZoneBlock)reader.ReadInt32();
                int       offset = reader.ReadInt32();

                long nextBlock = stream.Position;
                stream.Seek(offset, SeekOrigin.Begin);

                switch (type)
                {
                case ZoneBlock.Info:
                    Type          = (ZoneType)reader.ReadInt32();
                    Width         = reader.ReadInt32();
                    Height        = reader.ReadInt32();
                    GridCount     = reader.ReadInt32();
                    GridSize      = reader.ReadSingle();
                    StartPosition = new IntVector2(reader.ReadInt32(), reader.ReadInt32());

                    for (int w = 0; w < Width; w++)
                    {
                        for (int h = 0; h < Height; h++)
                        {
                            Positions[w, h].IsUsed   = reader.ReadBoolean();
                            Positions[w, h].Position = reader.ReadVector2();
                        }
                    }
                    break;

                case ZoneBlock.SpawnPoints:
                    int spawnCount = reader.ReadInt32();

                    for (int j = 0; j < spawnCount; j++)
                    {
                        SpawnPoint spawnPoint = new SpawnPoint();
                        spawnPoint.Position = reader.ReadVector3();
                        spawnPoint.Name     = reader.ReadByteString();

                        SpawnPoints.Add(spawnPoint);
                    }
                    break;

                case ZoneBlock.Textures:
                    int textureCount = reader.ReadInt32();

                    for (int j = 0; j < textureCount; j++)
                    {
                        Textures.Add(reader.ReadByteString());
                    }
                    break;

                case ZoneBlock.Tiles:
                    int tileCount = reader.ReadInt32();

                    for (int j = 0; j < tileCount; j++)
                    {
                        ZoneTile tile = new ZoneTile();
                        tile.Layer1          = reader.ReadInt32();
                        tile.Layer2          = reader.ReadInt32();
                        tile.Offset1         = reader.ReadInt32();
                        tile.Offset2         = reader.ReadInt32();
                        tile.BlendingEnabled = reader.ReadInt32() != 0;
                        tile.Rotation        = (TileRotation)reader.ReadInt32();
                        tile.TileType        = reader.ReadInt32();

                        Tiles.Add(tile);
                    }
                    break;

                case ZoneBlock.Economy:
                    Name                    = reader.ReadByteString();
                    IsUnderground           = reader.ReadInt32() != 0;
                    BackgroundMusicFilePath = reader.ReadByteString();
                    SkyFilePath             = reader.ReadByteString();
                    EconomyCheckRate        = reader.ReadInt32();
                    PopulationBase          = reader.ReadInt32();
                    PopulationGrowthRate    = reader.ReadInt32();
                    MetalConsumption        = reader.ReadInt32();
                    StoneConsumption        = reader.ReadInt32();
                    WoodConsumption         = reader.ReadInt32();
                    LeatherConsumption      = reader.ReadInt32();
                    ClothConsumption        = reader.ReadInt32();
                    AlchemyConsumption      = reader.ReadInt32();
                    ChemicalConsumption     = reader.ReadInt32();
                    IndustrialConsumption   = reader.ReadInt32();
                    MedicineConsumption     = reader.ReadInt32();
                    FoodConsumption         = reader.ReadInt32();
                    break;
                }

                if (i < blockCount - 1)
                {
                    stream.Seek(nextBlock, SeekOrigin.Begin);
                }
            }
        }