// Flood-fill textures public virtual void OnTextureFloodfill() { if (BuilderPlug.Me.CopiedTexture != null) { string oldtexture = GetTextureName(); long oldtexturelong = Lump.MakeLongName(oldtexture); string newtexture = BuilderPlug.Me.CopiedTexture; if (newtexture != oldtexture) { mode.CreateUndo("Flood-fill textures with " + newtexture); mode.SetActionResult("Flood-filled textures with " + newtexture + "."); mode.Renderer.SetCrosshairBusy(true); General.Interface.RedrawDisplay(); // Get the texture ImageData newtextureimage = General.Map.Data.GetTextureImage(newtexture); if (newtextureimage != null) { if (mode.IsSingleSelection) { // Clear all marks, this will align everything it can General.Map.Map.ClearMarkedSidedefs(false); } else { // Limit the alignment to selection only General.Map.Map.ClearMarkedSidedefs(true); List <Sidedef> sides = mode.GetSelectedSidedefs(); foreach (Sidedef sd in sides) { sd.Marked = false; } } // Do the alignment Tools.FloodfillTextures(this.Sidedef, oldtexturelong, newtextureimage, false); // Get the changed sidedefs List <Sidedef> changes = General.Map.Map.GetMarkedSidedefs(true); foreach (Sidedef sd in changes) { // Update the parts for this sidedef! if (mode.VisualSectorExists(sd.Sector)) { BaseVisualSector vs = (mode.GetVisualSector(sd.Sector) as BaseVisualSector); VisualSidedefParts parts = vs.GetSidedefParts(sd); parts.SetupAllParts(); } } General.Map.Data.UpdateUsedTextures(); mode.Renderer.SetCrosshairBusy(false); mode.ShowTargetInfo(); } } } }
// Paste properties public virtual void OnPasteProperties() { if (BuilderPlug.Me.CopiedThingProps != null) { mode.CreateUndo("Paste thing properties"); mode.SetActionResult("Pasted thing properties."); BuilderPlug.Me.CopiedThingProps.Apply(Thing); Thing.UpdateConfiguration(); this.Rebuild(); mode.ShowTargetInfo(); } }
// This is called to update UV dragging protected virtual void UpdateDragUV() { float u_ray = 1.0f; // Calculate intersection position this.Level.plane.GetIntersection(General.Map.VisualCamera.Position, General.Map.VisualCamera.Target, ref u_ray); Vector3D intersect = General.Map.VisualCamera.Position + (General.Map.VisualCamera.Target - General.Map.VisualCamera.Position) * u_ray; // Calculate offsets Vector3D dragdelta = intersect - dragorigin; float offsetx = dragdelta.x; float offsety = dragdelta.y; // Apply offsets int newoffsetx = startoffsetx - (int)Math.Round(offsetx); int newoffsety = startoffsety + (int)Math.Round(offsety); mode.ApplyFlatOffsetChange(prevoffsetx - newoffsetx, prevoffsety - newoffsety); prevoffsetx = newoffsetx; prevoffsety = newoffsety; mode.ShowTargetInfo(); }