public ThreeDFloor(Sector sector, IEnumerable <Sector> potentialsectors) { if (sector == null) { throw new Exception("Sector can't be null"); } this.sector = sector; taggedsectors = new List <Sector>(); topflat = sector.CeilTexture; bottomflat = sector.FloorTexture; topheight = sector.CeilHeight; bottomheight = sector.FloorHeight; brightness = sector.Brightness; tags = new List <int>(); floorslope = sector.FloorSlope; floorslopeoffset = sector.FloorSlopeOffset; ceilingslope = sector.CeilSlope; ceilingslopeoffset = sector.CeilSlopeOffset; foreach (Sidedef sd in sector.Sidedefs) { if (sd.Line.Action == 160) { bordertexture = sd.MiddleTexture; udmftag = sd.Line.Args[0]; type = sd.Line.Args[1]; flags = sd.Line.Args[2]; alpha = sd.Line.Args[3]; linedefproperties = new LinedefProperties(sd.Line); sectorproperties = new SectorProperties(sector); foreach (Sector s in BuilderPlug.GetSectorsByTag(potentialsectors, sd.Line.Args[0])) { if (!taggedsectors.Contains(s)) { taggedsectors.Add(s); } } } } }
public ThreeDFloor() { sector = null; taggedsectors = new List <Sector>(); topflat = General.Settings.DefaultCeilingTexture; bottomflat = General.Settings.DefaultFloorTexture; topheight = General.Settings.DefaultCeilingHeight; bottomheight = General.Settings.DefaultFloorHeight; bordertexture = General.Settings.DefaultTexture; type = 1; flags = 0; tags = new List <int>(); floorslope = new Vector3D(0.0f, 0.0f, 0.0f); floorslopeoffset = 0.0f; ceilingslope = new Vector3D(0.0f, 0.0f, 0.0f); ceilingslopeoffset = 0.0f; linedefproperties = null; sectorproperties = null; alpha = 255; }
public bool CreateGeometry(List <int> tagblacklist, List <DrawnVertex> alldrawnvertices, LinedefProperties ldprops, SectorProperties sectorprops, bool forcenewtag, out int newtag) { List <Vertex> vertices = new List <Vertex>(); Vector3D slopetopthingpos = new Vector3D(0, 0, 0); Vector3D slopebottomthingpos = new Vector3D(0, 0, 0); Line2D slopeline = new Line2D(0, 0, 0, 0); newtag = -1; // We need 5 vertices to draw the control sector if (alldrawnvertices.Count < 5) { General.Interface.DisplayStatus(StatusType.Warning, "Could not draw new sector: not enough vertices"); return(false); } // Get the first 5 vertices in the list and also remove them from the list, so that creating further // control sectors won't use them List <DrawnVertex> drawnvertices = alldrawnvertices.GetRange(0, 5); alldrawnvertices.RemoveRange(0, 5); // drawnvertices = BuilderPlug.Me.ControlSectorArea.GetNewControlSectorVertices(); if (Tools.DrawLines(drawnvertices) == false) { General.Interface.DisplayStatus(StatusType.Warning, "Could not draw new sector"); return(false); } sector = General.Map.Map.GetMarkedSectors(true)[0]; if (sectorprops != null) { sectorprops.Apply(new List <Sector>() { sector }, false); } sector.FloorHeight = bottomheight; sector.CeilHeight = topheight; sector.SetFloorTexture(bottomflat); sector.SetCeilTexture(topflat); sector.Brightness = brightness; sector.FloorSlope = floorslope; sector.FloorSlopeOffset = floorslopeoffset; sector.CeilSlope = ceilingslope; sector.CeilSlopeOffset = ceilingslopeoffset; foreach (Sidedef sd in sector.Sidedefs) { sd.Line.Front.SetTextureMid(bordertexture); } if (!sector.Fields.ContainsKey("user_managed_3d_floor")) { sector.Fields.Add("user_managed_3d_floor", new UniValue(UniversalType.Boolean, true)); } sector.Fields["comment"] = new UniValue(UniversalType.String, "[!]DO NOT DELETE! This sector is managed by the 3D floor plugin."); // With multiple tag support in UDMF only one tag is needed, so bind it right away if (General.Map.UDMF == true) { if (isnew || forcenewtag) { newtag = udmftag = BuilderPlug.Me.ControlSectorArea.GetNewSectorTag(tagblacklist); tagblacklist.Add(udmftag); } BindTag(udmftag, ldprops); } return(true); }
public void BindTag(int tag, LinedefProperties ldprops) { Linedef line = null; // try to find an line without an action foreach (Sidedef sd in sector.Sidedefs) { if (sd.Line.Action == 0 && sd.Line.Tag == 0 && line == null) { line = sd.Line; } // if a line of the control sector already has the tag // nothing has to be done if (sd.Line.Args[0] == tag) { return; } } // no lines without an action, so a line has to get split // find the longest line to split if (line == null) { line = sector.Sidedefs.First().Line; foreach (Sidedef sd in sector.Sidedefs) { if (sd.Line.Length > line.Length) { line = sd.Line; } } // Lines may not have a length of less than 1 after splitting if (line.Length / 2 < 1) { throw new Exception("Can't split more lines in Sector " + line.Front.Sector.Index.ToString() + "."); } Vertex v = General.Map.Map.CreateVertex(line.Line.GetCoordinatesAt(0.5f)); v.SnapToAccuracy(); line = line.Split(v); General.Map.Map.Update(); General.Interface.RedrawDisplay(); } if (ldprops != null) { ldprops.Apply(new List <Linedef>() { line }, false); } line.Action = 160; line.Args[0] = tag; line.Args[1] = type; line.Args[2] = flags; line.Args[3] = alpha; }