コード例 #1
0
        //create selection of lights. This is called only once
        private void SetupSelection()
        {
            selection = new List <Thing>();

            //check things
            if (editingModeName == "BaseVisualMode")
            {
                visualSelection = new List <VisualThing>();
                List <VisualThing> selectedVisualThings = ((VisualMode)General.Editing.Mode).GetSelectedVisualThings(false);

                foreach (VisualThing t in selectedVisualThings)
                {
                    if (GZGeneral.GetGZLightTypeByThing(t.Thing) != -1)
                    {
                        selection.Add(t.Thing);
                        visualSelection.Add(t);
                    }
                }
            }
            else
            {
                ICollection <Thing> list = General.Map.Map.GetSelectedThings(true);
                foreach (Thing t in list)
                {
                    if (GZGeneral.GetGZLightTypeByThing(t) != -1)
                    {
                        selection.Add(t);
                    }
                }
            }
        }
コード例 #2
0
        public static List <Line3D> GetDynamicLightShapes(IEnumerable <Thing> things, bool highlight)
        {
            List <Line3D> circles = new List <Line3D>();

            if (General.Map.DOOM)
            {
                return(circles);
            }

            const int linealpha = 128;

            foreach (Thing t in things)
            {
                int lightid = GZGeneral.GetGZLightTypeByThing(t);
                if (lightid == -1)
                {
                    continue;
                }

                // TODO: this basically duplicates VisualThing.UpdateLight()...
                // Determine light radiii
                int primaryradius;
                int secondaryradius = 0;

                if (lightid < GZGeneral.GZ_LIGHT_TYPES[3])                //if it's gzdoom light
                {
                    int n;
                    if (lightid < GZGeneral.GZ_LIGHT_TYPES[0])
                    {
                        n = 0;
                    }
                    else if (lightid < GZGeneral.GZ_LIGHT_TYPES[1])
                    {
                        n = 10;
                    }
                    else if (lightid < GZGeneral.GZ_LIGHT_TYPES[2])
                    {
                        n = 20;
                    }
                    else
                    {
                        n = 30;
                    }
                    DynamicLightType lightType = (DynamicLightType)(t.DynamicLightType - 9800 - n);

                    if (lightType == DynamicLightType.SECTOR)
                    {
                        if (t.Sector == null)
                        {
                            t.DetermineSector();
                        }
                        int scaler = (t.Sector != null ? t.Sector.Brightness / 4 : 2);
                        primaryradius = t.Args[3] * scaler;
                    }
                    else
                    {
                        primaryradius = t.Args[3] * 2;                         //works... that.. way in GZDoom
                        if (lightType > 0)
                        {
                            secondaryradius = t.Args[4] * 2;
                        }
                    }
                }
                else                 //it's one of vavoom lights
                {
                    primaryradius = t.Args[0] * 8;
                }

                // Check radii...
                if (primaryradius < 1 && secondaryradius < 1)
                {
                    continue;
                }

                // Determine light color
                PixelColor color;
                if (highlight)
                {
                    color = General.Colors.Highlight.WithAlpha(linealpha);
                }
                else
                {
                    switch (t.DynamicLightType)
                    {
                    case 1502:                             // Vavoom light
                        color = new PixelColor(linealpha, 255, 255, 255);
                        break;

                    case 1503:                             // Vavoom colored light
                        color = new PixelColor(linealpha, (byte)t.Args[1], (byte)t.Args[2], (byte)t.Args[3]);
                        break;

                    default:
                        color = new PixelColor(linealpha, (byte)t.Args[0], (byte)t.Args[1], (byte)t.Args[2]);
                        break;
                    }
                }

                // Add lines if visible
                if (primaryradius > 0)
                {
                    circles.AddRange(MakeCircleLines(t.Position, color, primaryradius, CIRCLE_SIDES));
                }
                if (secondaryradius > 0)
                {
                    circles.AddRange(MakeCircleLines(t.Position, color, secondaryradius, CIRCLE_SIDES));
                }
            }

            // Done
            return(circles);
        }