private void WriteV2SpoilerArea(Sanity.SCArea a, string tab, int depth)
        {
            Utilities.WriteSpoilerLine(tab + a.Map.MapId.ToString());

            //if (a.Map.MapId == MapId.TempleOfFiends && depth < 15) throw new RerollException();

            foreach (var p in a.PointsOfInterest)
            {
                switch (p.Type)
                {
                case Sanity.SCPointOfInterestType.Orb:
                    Utilities.WriteSpoilerLine(tab + " - " + a.Map.MapId.ToString() + " - " + p.Type.ToString() + " - " + p.BitFlagSet);
                    break;

                case Sanity.SCPointOfInterestType.Shop:
                    var shop = shopData.Shops.First(x => x.Index == p.ShopId - 1);
                    Utilities.WriteSpoilerLine(tab + " - " + a.Map.MapId.ToString() + " - " + p.Type.ToString() + " - " + shop.Type + "." + shop.Location + "." + p.ShopId.ToString() + " - " + p.BitFlagSet);
                    break;

                case Sanity.SCPointOfInterestType.Treasure:
                    var item = (Item)rom.Get(0x3100 + p.TreasureId, 1)[0];
                    Utilities.WriteSpoilerLine(tab + " - " + a.Map.MapId.ToString() + " - " + p.Type.ToString() + " - " + GetItemName(item) + " - " + p.BitFlagSet);
                    break;
                }
            }

            foreach (var a2 in a.ChildAreas)
            {
                WriteV2SpoilerArea(a2, tab + "\t", depth + 1);
            }
        }
        private void AddTele(SCArea currentArea, SCTeleport teleport, SCBitFlagSet bitFlagSet, bool topfloor)
        {
            var map      = scmaps[teleport.TargetMap];
            var entrance = map.Entrances.FirstOrDefault(e => e.Coords == teleport.TargetCoords);
            var area     = map.Areas.FirstOrDefault(area => area.Entrances.Contains(entrance));

            if (!Areas.Contains(area))
            {
                Areas.Add(area);

                if (currentArea != null)
                {
                    currentArea.ChildAreas.Add(area);
                    area.IsRoot = false;
                }
            }

            AddEntrance(area, entrance, bitFlagSet, topfloor);
        }
        private void AddEntrance(SCArea currentArea, SCEntrance entrance, SCBitFlagSet requirements, bool topfloor)
        {
            foreach (var poi in entrance.PointsOfInterest.Where(p => p.BitFlagSet.Count > 0))
            {
                poi.MapId = entrance.Map.MapId;
                SCPointOfInterest dungeonpoi;
                if (!poiDic.TryGetValue(poi, out dungeonpoi))
                {
                    dungeonpoi            = poi.Clone();
                    dungeonpoi.BitFlagSet = new SCBitFlagSet();
                    poiDic.Add(dungeonpoi, dungeonpoi);
                }

                bool changed = dungeonpoi.BitFlagSet.Merge(poi.BitFlagSet, requirements);

                if (changed)
                {
                    if (dungeonpoi.Type == SCPointOfInterestType.Tele)
                    {
                        AddTele(currentArea, dungeonpoi.Teleport, dungeonpoi.BitFlagSet, false);
                    }
                    else if (dungeonpoi.Type == SCPointOfInterestType.Exit)
                    {
                        if (!exits.Contains(dungeonpoi.Teleport))
                        {
                            exits.Add(dungeonpoi.Teleport);
                        }
                    }
                    else if (dungeonpoi.Type == SCPointOfInterestType.Warp && topfloor)
                    {
                        if (!exits.Contains(dungeonpoi.Teleport))
                        {
                            exits.Add(dungeonpoi.Teleport);
                        }
                    }
                }
            }
        }
Example #4
0
        private void ComposeArea(SCEntrance entrance, HashSet <SCCoords> doneEntrances)
        {
            var poiDic = entrance.PointsOfInterest
                         .Where(e => e.Type == SCPointOfInterestType.SmEntrance || e.Type == SCPointOfInterestType.OwEntrance)
                         .Where(e => e.BitFlagSet.Count > 0)
                         .Select(e => e.Coords)
                         .Distinct(new SCCoordsEqualityComparer())
                         .ToDictionary(e => e, new SCCoordsEqualityComparer());

            var entranceList = Entrances.Where(e => poiDic.ContainsKey(e.Coords)).ToList();

            foreach (var e in entranceList)
            {
                if (!doneEntrances.Contains(e.Coords))
                {
                    doneEntrances.Add(e.Coords);
                }
            }

            var area = new SCArea(this, entranceList);

            Areas.Add(area);
        }