Esempio n. 1
0
        // This updates the VisualSectors and VisualThings that have their Changed property set
        private void UpdateChangedObjects()
        {
            foreach (KeyValuePair <Sector, VisualSector> vs in allsectors)
            {
                if (vs.Value != null)
                {
                    BaseVisualSector bvs = (BaseVisualSector)vs.Value;
                    if (bvs.Changed)
                    {
                        bvs.Rebuild();
                    }
                }
            }

            foreach (KeyValuePair <Thing, VisualThing> vt in allthings)
            {
                if (vt.Value != null)
                {
                    BaseVisualThing bvt = (BaseVisualThing)vt.Value;
                    if (bvt.Changed)
                    {
                        bvt.Rebuild();
                    }
                }
            }
        }
        // Texture offset change
        public virtual void OnChangeTextureOffset(int horizontal, int vertical, bool doSurfaceAngleCorrection)
        {
            if (horizontal == 0 && vertical == 0)
            {
                return;                                              //mxd
            }
            //mxd
            if (!General.Map.UDMF)
            {
                General.Interface.DisplayStatus(StatusType.Warning, "Floor/ceiling texture offsets cannot be changed in this map format!");
                return;
            }

            if ((General.Map.UndoRedo.NextUndo == null) || (General.Map.UndoRedo.NextUndo.TicketID != undoticket))
            {
                undoticket = mode.CreateUndo("Change texture offsets");
            }

            //mxd
            if (doSurfaceAngleCorrection)
            {
                Point p     = new Point(horizontal, vertical);
                float angle = Angle2D.RadToDeg(General.Map.VisualCamera.AngleXY);
                if (GeometryType == VisualGeometryType.CEILING)
                {
                    angle += level.sector.Fields.GetValue("rotationceiling", 0f);
                }
                else
                {
                    angle += level.sector.Fields.GetValue("rotationfloor", 0f);
                }

                angle = General.ClampAngle(angle);

                if (angle > 315 || angle < 46)
                {
                    //already correct
                }
                else if (angle > 225)
                {
                    vertical   = p.X;
                    horizontal = -p.Y;
                }
                else if (angle > 135)
                {
                    horizontal = -p.X;
                    vertical   = -p.Y;
                }
                else
                {
                    vertical   = -p.X;
                    horizontal = p.Y;
                }
            }

            // Apply offsets
            MoveTextureOffset(new Point(-horizontal, -vertical));

            // Update sector geometry
            Sector s = GetControlSector();

            if (s.Index != Sector.Sector.Index)
            {
                s.UpdateNeeded = true;
                s.UpdateCache();
                mode.GetSectorData(s).Update();
                BaseVisualSector vs = (BaseVisualSector)mode.GetVisualSector(s);
                vs.UpdateSectorGeometry(false);
                vs.Rebuild();
            }

            Sector.Sector.UpdateNeeded = true;
            Sector.Sector.UpdateCache();
            Sector.UpdateSectorGeometry(false);
            Sector.Rebuild();
        }