public Line(Linedef ld) { start = new Vector2D((int)ld.Start.Position.x, (int)ld.Start.Position.y); end = new Vector2D((int)ld.End.Position.x, (int)ld.End.Position.y); SectorProperties = new SectorProperties(); if (ld.Back != null) { SectorProperties.CeilingHeight = ld.Back.Sector.CeilHeight; SectorProperties.FloorHeight = ld.Back.Sector.FloorHeight; SectorProperties.Brightness = ld.Back.Sector.Brightness; SectorProperties.HighTexture = ld.Back.HighTexture != "-" ? ld.Back.HighTexture : ld.Back.MiddleTexture; SectorProperties.LowTexture = ld.Back.LowTexture != "-" ? ld.Back.LowTexture : ld.Back.MiddleTexture; } else if (ld.Front != null) { SectorProperties.CeilingHeight = ld.Front.Sector.CeilHeight; SectorProperties.FloorHeight = ld.Front.Sector.FloorHeight; SectorProperties.Brightness = ld.Front.Sector.Brightness; SectorProperties.HighTexture = ld.Front.HighTexture != "-" ? ld.Front.HighTexture : ld.Front.MiddleTexture; SectorProperties.LowTexture = ld.Front.LowTexture != "-" ? ld.Front.LowTexture : ld.Front.MiddleTexture; } else { SectorProperties.CeilingHeight = 128; SectorProperties.FloorHeight = 0; SectorProperties.Brightness = 192; SectorProperties.HighTexture = "-"; SectorProperties.LowTexture = "-"; } }
private SectorProperties GetSectorProperties(int lineIndex, int sectorIndex) { float delta = sectorIndex / (float)form.Subdivisions; delta += (1.0f - delta) / form.Subdivisions; SectorProperties sp = new SectorProperties(); sp.Brightness = IntepolateValue(sectorProps1[lineIndex].Brightness, sectorProps2[lineIndex].Brightness, delta, form.BrightnessMode); sp.FloorHeight = IntepolateValue(sectorProps1[lineIndex].FloorHeight, sectorProps2[lineIndex].FloorHeight, delta, form.FloorAlignMode); sp.CeilingHeight = IntepolateValue(sectorProps1[lineIndex].CeilingHeight, sectorProps2[lineIndex].CeilingHeight, delta, form.CeilingAlignMode); //textures sp.LowTexture = sectorProps1[lineIndex].LowTexture != "-" ? sectorProps1[lineIndex].LowTexture : sectorProps2[lineIndex].LowTexture; sp.HighTexture = sectorProps1[lineIndex].HighTexture != "-" ? sectorProps1[lineIndex].HighTexture : sectorProps2[lineIndex].HighTexture; return(sp); }
// Accepted public override void OnAccept() { Cursor.Current = Cursors.AppStarting; General.Settings.FindDefaultDrawSettings(); //get vertices List <List <Vector2D[]> > shapes = GetShapes(); List <List <List <DrawnVertex> > > drawShapes = new List <List <List <DrawnVertex> > >(); //set stitch range float stitchrange = BuilderPlug.Me.StitchRange; BuilderPlug.Me.StitchRange = 0.1f; for (int i = 0; i < shapes.Count; i++) { List <List <DrawnVertex> > shapesRow = new List <List <DrawnVertex> >(); for (int c = 0; c < shapes[i].Count; c++) { List <DrawnVertex> points = new List <DrawnVertex>(); for (int p = 0; p < shapes[i][c].Length; p++) { points.Add(DrawGeometryMode.GetCurrentPosition(shapes[i][c][p], true, false, false, false, renderer, points)); } shapesRow.Add(points); } drawShapes.Add(shapesRow); } //restore stitch range BuilderPlug.Me.StitchRange = stitchrange; //draw lines if (drawShapes.Count > 0) { // Make undo for the draw General.Map.UndoRedo.CreateUndo("Bridge (" + form.Subdivisions + " subdivisions)"); List <List <SectorProperties> > sectorProps = new List <List <SectorProperties> >(); List <List <HashSet <Sector> > > newSectors = new List <List <HashSet <Sector> > >(); //create sector properties collection //sector row for (int i = 0; i < drawShapes.Count; i++) { sectorProps.Add(new List <SectorProperties>()); //sector in row for (int c = 0; c < drawShapes[i].Count; c++) { sectorProps[i].Add(GetSectorProperties(i, c)); } } // Make the drawing //sector row for (int i = 0; i < drawShapes.Count; i++) { newSectors.Add(new List <HashSet <Sector> >()); //sector in row for (int c = 0; c < drawShapes[i].Count; c++) { if (!Tools.DrawLines(drawShapes[i][c], false, true)) { // Drawing failed // NOTE: I have to call this twice, because the first time only cancels this volatile mode General.Interface.DisplayStatus(StatusType.Warning, "Failed to create a Bezier Path..."); General.Map.UndoRedo.WithdrawUndo(); General.Map.UndoRedo.WithdrawUndo(); return; } HashSet <Sector> newsectors = General.Map.Map.GetUnselectedSectorsFromLinedefs(General.Map.Map.GetMarkedLinedefs(true)); newSectors[i].Add(newsectors); //set floor/ceiling heights and brightness foreach (Sector s in newsectors) { SectorProperties sp = sectorProps[i][c]; s.Brightness = sp.Brightness; s.FloorHeight = sp.FloorHeight; s.CeilHeight = (sp.CeilingHeight < sp.FloorHeight ? sp.FloorHeight + 8 : sp.CeilingHeight); } } } //apply textures //sector row for (int i = 0; i < newSectors.Count; i++) { //sector in row for (int c = 0; c < newSectors[i].Count; c++) { foreach (Sector s in newSectors[i][c]) { foreach (Sidedef sd in s.Sidedefs) { if (sd.LowRequired()) { sd.SetTextureLow(sectorProps[i][c].LowTexture); } if (sd.HighRequired()) { sd.SetTextureHigh(sectorProps[i][c].HighTexture); } } } } } //apply textures to front/back sides of shape //sector row for (int i = 0; i < newSectors.Count; i++) { //first/last sector in row for (int c = 0; c < newSectors[i].Count; c += newSectors[i].Count - 1) { foreach (Sector s in newSectors[i][c]) { foreach (Sidedef sd in s.Sidedefs) { if (sd.Other != null) { if (sd.Other.LowRequired() && sd.Other.LowTexture == "-") { sd.Other.SetTextureLow(sectorProps[i][c].LowTexture); } if (sd.Other.HighRequired() && sd.Other.HighTexture == "-") { sd.Other.SetTextureHigh(sectorProps[i][c].HighTexture); } } } } } } General.Interface.DisplayStatus(StatusType.Action, "Created a Bridge with " + form.Subdivisions + " subdivisions."); // Snap to map format accuracy General.Map.Map.SnapAllToAccuracy(); // Clear selection General.Map.Map.ClearAllSelected(); // Update cached values General.Map.Map.Update(); // Update the used textures General.Map.Data.UpdateUsedTextures(); // Map is changed General.Map.IsChanged = true; } //close form if (form != null) { form.Close(); } // Done Cursor.Current = Cursors.Default; // Return to original mode General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name); }