Ejemplo n.º 1
0
        // This event is called when the plugin is initialized
        public override void OnInitialize()
        {
            base.OnInitialize();

            usehighlight = true;

            LoadSettings();

            slopevertexgroups = new List <SlopeVertexGroup>();

            //controlsectorarea = new ControlSectorArea(-512, 0, 512, 0, -128, -64, 128, 64, 64, 56);

            // This binds the methods in this class that have the BeginAction
            // and EndAction attributes with their actions. Without this, the
            // attributes are useless. Note that in classes derived from EditMode
            // this is not needed, because they are bound automatically when the
            // editing mode is engaged.
            General.Actions.BindMethods(this);

            menusform = new MenusForm();

            // TODO: Add DB2 version check so that old DB2 versions won't crash
            // General.ErrorLogger.Add(ErrorType.Error, "zomg!");

            // Keep a static reference
            me = this;

            // TMP
            drawlines  = new List <Line3D>();
            drawpoints = new List <Vector3D>();
        }
Ejemplo n.º 2
0
        public void Cleanup()
        {
            int taggedLines = 0;

            foreach (Sidedef sd in sector.Sidedefs)
            {
                if (sd.Line.Action == 160 && BuilderPlug.GetSectorsByTag(sd.Line.Args[0]).Count == 0)
                {
                    sd.Line.Action = 0;

                    for (int i = 0; i < 5; i++)
                    {
                        sd.Line.Args[i] = 0;
                    }
                }

                if (sd.Line.Action != 0)
                {
                    taggedLines++;
                }
            }

            if (taggedLines == 0)
            {
                DeleteControlSector(sector);
            }
        }
        public int GetNewSectorTag(List <int> tagblacklist)
        {
            List <int> usedtags = new List <int>();

            if (usecustomtagrange)
            {
                for (int i = firsttag; i <= lasttag; i++)
                {
                    if (!tagblacklist.Contains(i) && BuilderPlug.GetSectorsByTag(i).Count == 0)
                    {
                        return(i);
                    }
                }

                throw new Exception("No free tags in the custom range between " + firsttag.ToString() + " and " + lasttag.ToString() + ".");
            }

            return(General.Map.Map.GetNewTag(tagblacklist));
        }
Ejemplo n.º 4
0
        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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        // Mode engages
        public override void OnEngage()
        {
            base.OnEngage();

            if (BuilderPlug.Me.SlopeDataSector == null || BuilderPlug.Me.SlopeDataSector.IsDisposed)
            {
                SlopeDataSectorDialog sdsd = new SlopeDataSectorDialog();
                DialogResult          dr   = sdsd.ShowDialog();

                if (dr == DialogResult.Cancel)
                {
                    General.Editing.ChangeMode(General.Editing.PreviousStableMode.Name);
                }

                if (dr == DialogResult.OK)
                {
                    BuilderPlug.Me.SlopeDataSector = General.Map.Map.GetSelectedSectors(true).ToList()[0];
                    BuilderPlug.Me.StoreSlopeVertexGroupsInSector();
                }
            }

            renderer.SetPresentation(Presentation.Things);

            General.Interface.AddButton(BuilderPlug.Me.MenusForm.UpdateSlopes);

            // Convert geometry selection to sectors
            General.Map.Map.ConvertSelection(SelectionType.Sectors);

            // Get all 3D floors in the map
            threedfloors = BuilderPlug.GetThreeDFloors(General.Map.Map.Sectors.ToList());

            SetupLabels();

            foreach (SlopeVertexGroup svg in BuilderPlug.Me.SlopeVertexGroups)
            {
                svg.FindSectors();
            }

            // Update overlay surfaces, so that selected sectors are drawn correctly
            updateOverlaySurfaces();
        }
Ejemplo n.º 6
0
        private void GetTaggesSectors(Sector s, PlaneType pt)
        {
            // Check if the current sector is a 3D floor control sector. If that's the case also store the
            // tagged sector(s). They will be used for highlighting in slope mode
            foreach (Sidedef sd in s.Sidedefs)
            {
                if (sd.Line.Action == 160)
                {
                    foreach (Sector ts in BuilderPlug.GetSectorsByTag(sd.Line.Args[0]))
                    {
                        if (!taggedsectors.Contains(ts))
                        {
                            taggedsectors.Add(ts);
                        }

                        if (!sectorplanes.ContainsKey(ts))
                        {
                            sectorplanes.Add(ts, pt);
                        }
                    }
                }
            }
        }