Exemplo n.º 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;
        }
Exemplo n.º 2
0
        // This updates this virtual the sector and neightbours if needed
        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 = GetSectorData();

            data.Reset();

            // Update sectors that rely on this sector
            foreach (KeyValuePair <Sector, bool> s in data.UpdateAlso)
            {
                if (mode.VisualSectorExists(s.Key))
                {
                    BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s.Key);
                    vs.UpdateSectorGeometry(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 = (mode.GetVisualThing(t) as BaseVisualThing);
                        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))
                        {
                            BaseVisualSector bvs = (BaseVisualSector)mode.GetVisualSector(sd.Other.Sector);
                            bvs.Changed = true;
                        }
                    }
                }
            }

            isupdating = false;
        }