Example #1
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;
        }
Example #2
0
 // Edit button released
 public virtual void OnEditEnd()
 {
     if (General.Interface.IsActiveWindow)
     {
         List <Thing> things = mode.GetSelectedThings();
         DialogResult result = General.Interface.ShowEditThings(things);
         if (result == DialogResult.OK)
         {
             foreach (Thing t in things)
             {
                 VisualThing vt = mode.GetVisualThing(t);
                 if (vt != null)
                 {
                     (vt as BaseVisualThing).Changed = true;
                 }
             }
         }
     }
 }
        // Sector brightness change
        public virtual void OnChangeTargetBrightness(bool up)
        {
            if (!Sector.Changed)
            {
                // Change brightness
                mode.CreateUndo("Change sector brightness", UndoGroup.SectorBrightnessChange, Sector.Sector.FixedIndex);

                if (up)
                {
                    Sector.Sector.Brightness = General.Map.Config.BrightnessLevels.GetNextHigher(Sector.Sector.Brightness);
                }
                else
                {
                    Sector.Sector.Brightness = General.Map.Config.BrightnessLevels.GetNextLower(Sector.Sector.Brightness);
                }

                mode.SetActionResult("Changed sector brightness to " + Sector.Sector.Brightness + ".");

                Sector.Sector.UpdateCache();

                // Rebuild sector
                Sector.UpdateSectorGeometry(false);

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