Esempio n. 1
0
        /// <inheritdoc />
        public void Process(ISegmentImporter importer, IImportedRegion convertibleRegion, SegmentRegion convertedRegion)
        {
            var matches = convertedRegion.GetTiles(tile => true);

            foreach (var tile in matches)
            {
                foreach (var direction in Direction.Cardinal)
                {
                    var neighbor = convertedRegion.GetTile(tile, direction);

                    if (neighbor != null)
                    {
                        var staticComponents = neighbor.GetComponents <StaticComponent>(component => _targets.Contains(component.Static));

                        if (staticComponents.Count() > 1)
                        {
                            throw new Exception("Encountered multiple counter candidates.");
                        }

                        foreach (var component in staticComponents)
                        {
                            neighbor.ReplaceComponent(component, new CounterComponent(component.Static, direction.Opposite));
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        /// <inheritdoc />
        public void Process(ISegmentImporter importer, IImportedRegion convertibleRegion, SegmentRegion convertedRegion)
        {
            var matches = convertedRegion.GetTiles(tile => true);

            foreach (var tile in matches)
            {
                var staticComponents = tile.GetComponents <StaticComponent>(component => _targets.Contains(component.Static));

                if (staticComponents.Count() > 1)
                {
                    throw new Exception("Encountered multiple web candidates.");
                }

                foreach (var component in staticComponents)
                {
                    tile.ReplaceComponent(component, new StaticComponent(component.Static));
                }
            }
        }
Esempio n. 3
0
        /// <inheritdoc />
        public void Process(ISegmentImporter importer, IImportedRegion convertibleRegion, SegmentRegion convertedRegion)
        {
            var matches = convertedRegion.GetTiles(tile => true);

            foreach (var tile in matches)
            {
                var staticComponents = tile.GetComponents <StaticComponent>(component => _targets.Contains(component.Static));

                if (staticComponents.Count() > 1)
                {
                    continue;
                }

                // TODO: Should we be able to have more than 1 floor tile? Is anything else just a decorator static?
                foreach (var component in staticComponents)
                {
                    tile.ReplaceComponent(component, new FloorComponent(component.Static, _movementCost));
                }
            }
        }
Esempio n. 4
0
        /// <inheritdoc />
        public void Process(ISegmentImporter importer, IImportedRegion convertibleRegion, SegmentRegion convertedRegion)
        {
            /* Get all the tiles available. Certain areas of water are not deep enough to drown. */
            var matches = convertedRegion.GetTiles(tile => true);

            foreach (var tile in matches)
            {
                var staticComponents = tile.GetComponents <StaticComponent>(component => _targets.Contains(component.Static));

                if (staticComponents.Count() > 1)
                {
                    throw new Exception("Encountered multiple water candidates.");
                }

                foreach (var component in staticComponents)
                {
                    tile.ReplaceComponent(component, new WaterComponent(component.Static, _depth));
                }
            }
        }
Esempio n. 5
0
        /// <inheritdoc />
        public void Process(ISegmentImporter importer, IImportedRegion convertibleRegion, SegmentRegion convertedRegion)
        {
            var matches = convertedRegion.GetTiles(tile => true);

            foreach (var tile in matches)
            {
                var staticComponents = tile.GetComponents <StaticComponent>(component => _targets.Contains(component.Static));

                if (staticComponents.Count() > 1)
                {
                    throw new Exception("Encountered multiple door candidates.");
                }

                foreach (var component in staticComponents)
                {
                    var closedId    = component.Static;
                    var openId      = GetOpenId(closedId);
                    var secretId    = GetSecretId(tile, closedId);
                    var destroyedId = GetDestroyedId(closedId);

                    tile.ReplaceComponent(component, new DoorComponent(closedId, openId, secretId, destroyedId));
                }
            }
        }
Esempio n. 6
0
        /// <inheritdoc />
        public void Process(ISegmentImporter importer, IImportedRegion convertibleRegion, SegmentRegion convertedRegion)
        {
            var matches = convertedRegion.GetTiles(tile =>
                                                   /* importer.HasDataFlag(tile, 10, 0x10)  Get those tiles which are marked with an altar flag. */

                                                   /* 1. If the tile has a counter, we do not create the altar. */
                                                   !tile.OfType <CounterComponent>().Any()
                                                   );

            foreach (var tile in matches)
            {
                var staticComponents = tile.GetComponents <StaticComponent>(component => _targets.Contains(component.Static));

                if (staticComponents.Count() > 1)
                {
                    throw new Exception("Encountered multiple altar candidates.");
                }

                foreach (var component in staticComponents)
                {
                    tile.ReplaceComponent(component, new AltarComponent(component.Static));
                }
            }
        }
Esempio n. 7
0
        /// <inheritdoc />
        public void Process(ISegmentImporter importer, IImportedRegion convertibleRegion, SegmentRegion convertedRegion)
        {
            var matches = convertedRegion.GetTiles(tile => true);

            /* First Pass */
            foreach (var tile in matches)
            {
                var staticComponents = tile.GetComponents <StaticComponent>(
                    component => _targets.Contains(component.Static)).ToList();

                if (staticComponents.Count() > 2)
                {
                    throw new Exception("Encountered multiple wall candidates.");
                }

                foreach (var component in staticComponents)
                {
                    tile.ReplaceComponent(component, new WallComponent(component.Static, GetDestroyedId(component.Static), GetRuinsId(component.Static)));
                }
            }

            /* Second Pass to catch corner walls as indestructible */
            foreach (var tile in matches)
            {
                if (tile.OfType <WallComponent>().Count() > 1)
                {
                    var north = convertedRegion.GetTile(tile, Direction.North);
                    var west  = convertedRegion.GetTile(tile, Direction.West);

                    var northIndestructible = north != null && north.OfType <WallComponent>().Any(wall => wall.IsIndestructible);
                    var westIndestructible  = west != null && west.OfType <WallComponent>().Any(wall => wall.IsIndestructible);

                    if (northIndestructible || westIndestructible)
                    {
                        foreach (var wall in tile.OfType <WallComponent>())
                        {
                            wall.IsIndestructible = true;
                        }

                        tile.UpdateTerrain();
                    }
                }
            }

            var pillars = new List <int>()
            {
                32, 33, 34, 143, 155, 159, 262, 355, 357, 359, 366, 407, 409, 417, 443, 463, 480
            };

            bool isPillar(WallComponent wall)
            {
                return(pillars.Contains(wall.Wall));
            }

            /* Third Pass to catch pillars */
            foreach (var tile in matches)
            {
                if (tile.OfType <WallComponent>().All(isPillar))
                {
                    var south = convertedRegion.GetTile(tile, Direction.South);
                    var east  = convertedRegion.GetTile(tile, Direction.East);

                    var southIndestructible = south != null && south.OfType <WallComponent>().Any(wall => wall.IsIndestructible);
                    var eastIndestructible  = east != null && east.OfType <WallComponent>().Any(wall => wall.IsIndestructible);

                    if (southIndestructible && eastIndestructible)
                    {
                        foreach (var wall in tile.OfType <WallComponent>())
                        {
                            wall.IsIndestructible = true;
                        }

                        tile.UpdateTerrain();
                    }
                }
            }
        }