Пример #1
0
        // This resets this sector data and all sectors that require updating after me

        /*public void Reset()
         * {
         *      if(isupdating) return;
         *      isupdating = true;
         *
         *      // This is set to false so that this sector is rebuilt the next time it is needed!
         *      updated = false;
         *
         *      // The visual sector associated is now outdated
         *      if(mode.VisualSectorExists(sector))
         *      {
         *              BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(sector);
         *              vs.UpdateSectorGeometry(false);
         *      }
         *
         *      // Also reset the sectors that depend on this sector
         *      foreach(KeyValuePair<Sector, bool> s in updatesectors)
         *      {
         *              SectorData sd = mode.GetSectorData(s.Key);
         *              sd.Reset();
         *      }
         *
         *      isupdating = false;
         * }*/

        //mxd. This marks this sector data and all sector datas that require updating as not updated
        public void Reset(bool resetneighbours)
        {
            if (isupdating)
            {
                return;
            }
            isupdating = true;

            // This is set to false so that this sector is rebuilt the next time it is needed!
            updated = false;

            // The visual sector associated is now outdated
            if (mode.VisualSectorExists(sector))
            {
                BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(sector);
                vs.Changed = true;
            }

            // Reset the sectors that depend on this sector
            if (resetneighbours)
            {
                foreach (KeyValuePair <Sector, bool> s in updatesectors)
                {
                    SectorData sd = mode.GetSectorDataEx(s.Key);
                    if (sd != null)
                    {
                        sd.Reset(s.Value);
                    }
                }
            }

            isupdating = false;
        }
Пример #2
0
        // This gets sectors which surround given sectors
        internal static IEnumerable <Sector> GetSectorsAround(BaseVisualMode mode, IEnumerable <Sector> selected)
        {
            HashSet <int>    processedsectors = new HashSet <int>();
            HashSet <Vertex> verts            = new HashSet <Vertex>();
            List <Sector>    result           = new List <Sector>();

            foreach (Sector s in selected)
            {
                processedsectors.Add(s.Index);
                foreach (Sidedef side in s.Sidedefs)
                {
                    if (!verts.Contains(side.Line.Start))
                    {
                        verts.Add(side.Line.Start);
                    }
                    if (!verts.Contains(side.Line.End))
                    {
                        verts.Add(side.Line.End);
                    }
                }
            }

            foreach (Vertex v in verts)
            {
                foreach (Linedef l in v.Linedefs)
                {
                    if (l.Front != null && l.Front.Sector != null && !processedsectors.Contains(l.Front.Sector.Index))
                    {
                        result.Add(l.Front.Sector);
                        processedsectors.Add(l.Front.Sector.Index);

                        // Add extrafloors as well
                        SectorData sd = mode.GetSectorDataEx(l.Front.Sector);
                        if (sd != null && sd.ExtraFloors.Count > 0)
                        {
                            foreach (Effect3DFloor effect in sd.ExtraFloors)
                            {
                                if (!processedsectors.Contains(effect.Linedef.Front.Sector.Index))
                                {
                                    result.Add(effect.Linedef.Front.Sector);
                                    processedsectors.Add(effect.Linedef.Front.Sector.Index);
                                }
                            }
                        }
                    }
                    if (l.Back != null && l.Back.Sector != null && !processedsectors.Contains(l.Back.Sector.Index))
                    {
                        result.Add(l.Back.Sector);
                        processedsectors.Add(l.Back.Sector.Index);

                        // Add extrafloors as well
                        SectorData sd = mode.GetSectorDataEx(l.Back.Sector);
                        if (sd != null && sd.ExtraFloors.Count > 0)
                        {
                            foreach (Effect3DFloor effect in sd.ExtraFloors)
                            {
                                if (!processedsectors.Contains(effect.Linedef.Front.Sector.Index))
                                {
                                    result.Add(effect.Linedef.Front.Sector);
                                    processedsectors.Add(effect.Linedef.Front.Sector.Index);
                                }
                            }
                        }
                    }
                }
            }

            return(result);
        }
Пример #3
0
        // This updates this virtual the sector and neightbours if needed
        override public void UpdateSectorGeometry(bool includeneighbours)
        {
            if (isupdating)
            {
                return;
            }

            isupdating = true;
            changed    = true;

            // Not sure what from this part we need, so commented out for now
            SectorData data = mode.GetSectorDataEx(this.Sector); //mxd

            if (data != null)                                    //mxd
            {
                data.Reset(false);

                // Update sectors that rely on this sector
                foreach (KeyValuePair <Sector, bool> s in data.UpdateAlso)
                {
                    SectorData other = mode.GetSectorDataEx(s.Key);
                    if (other != null)
                    {
                        other.Reset(s.Value);
                    }
                }
            }

            // Go for all things in this sector
            foreach (Thing t in General.Map.Map.Things)
            {
                if (t.Sector == this.Sector)
                {
                    if (mode.VisualThingExists(t))
                    {
                        // Update thing
                        BaseVisualThing vt = (BaseVisualThing)mode.GetVisualThing(t);
                        vt.Changed = true;
                    }
                }
            }

            if (includeneighbours)
            {
                // Also rebuild surrounding sectors, because outside sidedefs may need to be adjusted
                foreach (Sidedef sd in this.Sector.Sidedefs)
                {
                    if (sd.Other != null)
                    {
                        if (mode.VisualSectorExists(sd.Other.Sector))
                        {
                            SectorData other = mode.GetSectorDataEx(sd.Other.Sector);

                            if (other != null)
                            {
                                other.Reset(other.UpdateAlso.Count > 0 ? true : false);                                 // biwa. Make sure to reset the update status of dependend sectors. This fixes #250, where 3D floors where not updated when the control sector was sloped using line action 181
                            }
                            else
                            {
                                BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(sd.Other.Sector);
                                vs.Changed = true;
                            }
                        }
                    }
                }
            }

            Sector.UpdateFogColor();             //mxd
            isupdating = false;
        }