// Insert middle texture
        public virtual void OnInsert()
        {
            // No middle texture yet?
            if (!Sidedef.MiddleRequired() && (string.IsNullOrEmpty(Sidedef.MiddleTexture) || (Sidedef.MiddleTexture[0] == '-')))
            {
                // Make it now
                mode.CreateUndo("Create middle texture");
                mode.SetActionResult("Created middle texture.");
                General.Settings.FindDefaultDrawSettings();
                Sidedef.SetTextureMid(General.Settings.DefaultTexture);

                // Update
                Sector.Changed = true;

                // Other side as well
                if (string.IsNullOrEmpty(Sidedef.Other.MiddleTexture) || (Sidedef.Other.MiddleTexture[0] == '-'))
                {
                    Sidedef.Other.SetTextureMid(General.Settings.DefaultTexture);

                    // Update
                    VisualSector othersector = mode.GetVisualSector(Sidedef.Other.Sector);
                    if (othersector is BaseVisualSector)
                    {
                        (othersector as BaseVisualSector).Changed = true;
                    }
                }
            }
        }
Exemplo n.º 2
0
 // Copy properties
 public virtual void OnCopyProperties()
 {
     BuilderPlug.Me.CopiedThingProps = new ThingProperties(Thing);
     mode.SetActionResult("Copied thing properties.");
 }
        public void OnChangeTargetHeight(int amount)
        {
            VisualSlope pivothandle = null;
            List <IVisualEventReceiver> selectedsectors = mode.GetSelectedObjects(true, false, false, false, false);
            List <SectorLevel>          levels          = new List <SectorLevel>();

            if (selectedsectors.Count == 0)
            {
                levels.Add(level);
            }
            else
            {
                foreach (BaseVisualGeometrySector bvgs in selectedsectors)
                {
                    levels.Add(bvgs.Level);
                }

                if (!levels.Contains(level))
                {
                    levels.Add(level);
                }
            }

            // Try to find a slope handle the user set to be the pivot handle
            // TODO: doing this every time is kind of stupid. Maybe store the pivot handle in the mode?
            foreach (KeyValuePair <Sector, List <VisualSlope> > kvp in mode.AllSlopeHandles)
            {
                foreach (VisualSidedefSlope handle in kvp.Value)
                {
                    if (handle.Pivot)
                    {
                        pivothandle = handle;
                        break;
                    }
                }
            }

            // User didn't set a pivot handle, try to find the smart pivot handle
            if (pivothandle == null)
            {
                pivothandle = GetSmartPivotHandle(this, mode);
            }

            // Still no pivot handle, cancle
            if (pivothandle == null)
            {
                return;
            }

            pivothandle.SmartPivot = true;

            mode.CreateUndo("Change slope");

            Plane originalplane = level.plane;
            Plane pivotplane    = ((VisualSidedefSlope)pivothandle).Level.plane;

            // Build a new plane. p1 and p2 are the points of the slope handle that is modified, p3 is on the line of the pivot handle
            Vector3D p1 = new Vector3D(sidedef.Line.Start.Position, (float)Math.Round(originalplane.GetZ(sidedef.Line.Start.Position)));
            Vector3D p2 = new Vector3D(sidedef.Line.End.Position, (float)Math.Round(originalplane.GetZ(sidedef.Line.End.Position)));
            Vector3D p3 = new Vector3D(((VisualSidedefSlope)pivothandle).Sidedef.Line.Line.GetCoordinatesAt(0.5f), (float)Math.Round(pivotplane.GetZ(((VisualSidedefSlope)pivothandle).Sidedef.Line.Line.GetCoordinatesAt(0.5f))));

            // Move the points of the handle up/down
            p1 += new Vector3D(0f, 0f, amount);
            p2 += new Vector3D(0f, 0f, amount);

            Plane plane = new Plane(p1, p2, p3, true);

            // Apply slope to surfaces
            foreach (SectorLevel l in levels)
            {
                ApplySlope(l, plane, mode);
            }

            mode.SetActionResult("Changed slope.");
        }
Exemplo n.º 4
0
        // Flood-fill textures
        public virtual void OnTextureFloodfill()
        {
            if (BuilderPlug.Me.CopiedFlat != null)
            {
                string oldtexture     = GetTextureName();
                long   oldtexturelong = Lump.MakeLongName(oldtexture);
                string newtexture     = BuilderPlug.Me.CopiedFlat;
                if (newtexture != oldtexture)
                {
                    // Get the texture
                    ImageData newtextureimage = General.Map.Data.GetFlatImage(newtexture);
                    if (newtextureimage != null)
                    {
                        bool fillceilings = (this is VisualCeiling);

                        if (fillceilings)
                        {
                            mode.CreateUndo("Flood-fill ceilings with " + newtexture);
                            mode.SetActionResult("Flood-filled ceilings with " + newtexture + ".");
                        }
                        else
                        {
                            mode.CreateUndo("Flood-fill floors with " + newtexture);
                            mode.SetActionResult("Flood-filled floors with " + newtexture + ".");
                        }

                        mode.Renderer.SetCrosshairBusy(true);
                        General.Interface.RedrawDisplay();

                        if (mode.IsSingleSelection)
                        {
                            // Clear all marks, this will align everything it can
                            General.Map.Map.ClearMarkedSectors(false);
                        }
                        else
                        {
                            // Limit the alignment to selection only
                            General.Map.Map.ClearMarkedSectors(true);
                            List <Sector> sectors = mode.GetSelectedSectors();
                            foreach (Sector s in sectors)
                            {
                                s.Marked = false;
                            }
                        }

                        // Do the fill
                        Tools.FloodfillFlats(this.Sector.Sector, fillceilings, oldtexturelong, newtextureimage, false);

                        // Get the changed sectors
                        List <Sector> changes = General.Map.Map.GetMarkedSectors(true);
                        foreach (Sector s in changes)
                        {
                            // Update the visual sector
                            if (mode.VisualSectorExists(s))
                            {
                                BaseVisualSector vs = (mode.GetVisualSector(s) as BaseVisualSector);
                                if (fillceilings)
                                {
                                    vs.Ceiling.Setup();
                                }
                                else
                                {
                                    vs.Floor.Setup();
                                }
                            }
                        }

                        General.Map.Data.UpdateUsedTextures();
                        mode.Renderer.SetCrosshairBusy(false);
                        mode.ShowTargetInfo();
                    }
                }
            }
        }