Exemplo n.º 1
0
        public bool Merge(SCBitFlagSet bitFlagSet)
        {
            bool result = false;

            foreach (var fl in bitFlagSet)
            {
                result |= Merge(fl);
            }

            return(result);
        }
Exemplo n.º 2
0
        public bool Merge(SCBitFlagSet bitFlagSet, SCBitFlagSet requirements)
        {
            bool result = false;

            foreach (var req in requirements)
            {
                foreach (var fl in bitFlagSet)
                {
                    result |= Merge(fl | req);
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        public SCBitFlagSet GetBitFlagSet()
        {
            CompactFlags();

            SCBitFlagSet result = new SCBitFlagSet();

            for (int i = 0; i < ExtFlagCount; i++)
            {
                if (ExtFlags[i] == (ushort)SCBitFlags.None)
                {
                    break;
                }
                result.Add((SCBitFlags)ExtFlags[i]);
            }

            return(result);
        }
        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);
                        }
                    }
                }
            }
        }
Exemplo n.º 6
0
 public SCBitFlagSet Restrict(SCBitFlagSet flags)
 {
     return(new SCBitFlagSet(this.Select(f1 => flags.Select(f2 => f1 | f2)).SelectMany(x => x)));
 }