示例#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
        // This updates the settings from configuration
        public void UpdateConfiguration()
        {
            // Lookup settings
            ThingTypeInfo ti = General.Map.Data.GetThingInfo(type);

            // Apply size
            dynamiclighttype = GZGeneral.GetGZLightTypeByClass(ti.Actor);
            if (dynamiclighttype == null)
            {
                dynamiclighttype = ti.DynamicLightType;
            }
            //General.ErrorLogger.Add(ErrorType.Warning, string.Format("thing dynamiclighttype is {0}; class is {1}", dynamiclighttype, ti.Actor.ClassName));
            size        = ti.Radius;
            rendersize  = ti.RenderRadius;
            height      = ti.Height;        //mxd
            fixedsize   = ti.FixedSize;
            spritescale = ti.SpriteScale;   //mxd

            //mxd. Apply radius and height overrides?
            for (int i = 0; i < ti.Args.Length; i++)
            {
                if (ti.Args[i] == null)
                {
                    continue;
                }
                if (ti.Args[i].Type == (int)UniversalType.ThingRadius && args[i] > 0)
                {
                    size = args[i];
                }
                else if (ti.Args[i].Type == (int)UniversalType.ThingHeight && args[i] > 0)
                {
                    height = args[i];
                }
            }

            // Color valid?
            if ((ti.Color >= 0) && (ti.Color < ColorCollection.NUM_THING_COLORS))
            {
                // Apply color
                color = General.Colors.Colors[ti.Color + ColorCollection.THING_COLORS_OFFSET];
            }
            else
            {
                // Unknown thing color
                color = General.Colors.Colors[ColorCollection.THING_COLORS_OFFSET];
            }

            directional = ti.Arrow;      //mxd
            rendermode  = ti.RenderMode; //mxd
            rollsprite  = ti.RollSprite; //mxd
            UpdateCache();               //mxd
        }
示例#3
0
        // Constructor
        internal ThingTypeInfo(ThingCategory cat, int index, Configuration cfg, IDictionary <string, EnumList> enums)
        {
            string key = index.ToString(CultureInfo.InvariantCulture);

            // Initialize
            this.index           = index;
            this.category        = cat;
            this.args            = new ArgumentInfo[Linedef.NUM_ARGS];
            this.isknown         = true;
            this.actor           = null;
            this.bright          = false;        //mxd
            this.distancechecksq = int.MaxValue; //mxd

            // Read properties
            this.title         = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".title", "<" + key + ">");
            this.sprite        = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".sprite", cat.Sprite);
            this.color         = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".color", cat.Color);
            this.alpha         = General.Clamp(cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".alpha", cat.Alpha), 0f, 1f); //mxd
            this.alphabyte     = (byte)(this.alpha * 255);                                                                           //mxd
            this.renderstyle   = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".renderstyle", cat.RenderStyle).ToLower();  //mxd
            this.arrow         = (cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".arrow", cat.Arrow) != 0);
            this.radius        = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".width", cat.Radius);
            this.height        = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".height", cat.Height);
            this.hangs         = (cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".hangs", cat.Hangs) != 0);
            this.blocking      = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".blocking", cat.Blocking);
            this.errorcheck    = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".error", cat.ErrorCheck);
            this.fixedsize     = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".fixedsize", cat.FixedSize);
            this.fixedrotation = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".fixedrotation", cat.FixedRotation);             //mxd
            this.absolutez     = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".absolutez", cat.AbsoluteZ);
            float sscale = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".spritescale", cat.SpriteScale);

            this.spritescale = new SizeF(sscale, sscale);
            this.locksprite  = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".locksprite", false);            //mxd
            this.classname   = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".class", String.Empty);          //mxd
            this.thinglink   = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".thinglink", 0);

            //mxd. Read flagsrename
            this.flagsrename = new Dictionary <string, Dictionary <string, string> >(StringComparer.OrdinalIgnoreCase);
            IDictionary maindic = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".flagsrename", new Hashtable());

            foreach (DictionaryEntry de in maindic)
            {
                string ioname = de.Key.ToString().ToLowerInvariant();
                switch (ioname)
                {
                case "doommapsetio":
                case "hexenmapsetio":
                case "universalmapsetio":
                    IDictionary flagdic = de.Value as IDictionary;
                    if (flagdic == null)
                    {
                        continue;
                    }
                    flagsrename.Add(ioname, new Dictionary <string, string>());
                    foreach (DictionaryEntry fe in flagdic)
                    {
                        flagsrename[ioname].Add(fe.Key.ToString(), fe.Value.ToString());
                    }
                    break;

                default: throw new NotImplementedException("Unsupported MapSetIO");
                }
            }

            // Read the args
            for (int i = 0; i < Linedef.NUM_ARGS; i++)
            {
                this.args[i] = new ArgumentInfo(cfg, "thingtypes." + cat.Name + "." + key, i, enums);
            }

            // Safety
            if (this.radius < 4f || this.fixedsize)
            {
                this.radius = THING_FIXED_SIZE;
            }
            if (this.hangs && this.absolutez)
            {
                this.hangs = false;                                          //mxd
            }
            //mxd. Create sprite frame
            this.spriteframe = new[] { new SpriteFrameInfo {
                                           Sprite = sprite, SpriteLongName = Lump.MakeLongName(sprite, true)
                                       } };

            // [ZZ] optional thing sprite.
            this.optional = cfg.ReadSetting("thingtypes." + cat.Name + "." + key + ".optional", cat.Optional);

            // [ZZ] generate internal light data
            this.dynamiclighttype = GZGeneral.GetLightDataByNum(index);

            // We have no destructor
            GC.SuppressFinalize(this);
        }
示例#4
0
        }                                                                                                          //mxd

        internal void ModifyByDecorateActor(ActorStructure actor, bool replacetitle)
        {
            // Keep reference to actor
            this.actor     = actor;
            this.classname = actor.ClassName;             //mxd

            // Set the title
            if (actor.HasPropertyWithValue("$title"))
            {
                title = actor.GetPropertyAllValues("$title");
            }
            else if (actor.HasPropertyWithValue("tag"))
            {
                string tag = actor.GetPropertyAllValues("tag");
                if (!tag.StartsWith("\"$"))
                {
                    title = tag;                                        //mxd. Don't use LANGUAGE keywords.
                }
            }

            if (string.IsNullOrEmpty(title) || replacetitle)
            {
                title = actor.ClassName;
            }

            //mxd. Color override?
            if (actor.HasPropertyWithValue("$color"))
            {
                int ci = actor.GetPropertyValueInt("$color", 0);
                color = (ci == 0 || ci > 19 ? 18 : ci);
            }

            //mxd. Custom argument titles?
            for (int i = 0; i < args.Length; i++)
            {
                ArgumentInfo arg = actor.GetArgumentInfo(i);
                if (arg != null)
                {
                    args[i] = arg;
                }
            }

            //mxd. Some SLADE compatibility
            if (actor.HasProperty("$angled"))
            {
                this.arrow = true;
            }
            else if (actor.HasProperty("$notangled"))
            {
                this.arrow = false;
            }

            //mxd. Marked as obsolete?
            if (actor.HasPropertyWithValue("$obsolete"))
            {
                obsoletemessage = actor.GetPropertyValueString("$obsolete", 0, true);
                obsolete        = true;
                color           = 4;       //red
            }

            // Remove doublequotes from title
            title = ZDTextParser.StripQuotes(title);             //mxd

            // Set sprite
            StateStructure.FrameInfo info = actor.FindSuitableSprite(); //mxd
            if (!locksprite && info != null)                            //mxd. Added locksprite property
            {
                sprite = info.Sprite;
            }
            else if (string.IsNullOrEmpty(sprite))           //mxd
            {
                sprite = DataManager.INTERNAL_PREFIX + "unknownthing";
            }

            //mxd. Store dynamic light name
            lightname = (info != null ? info.LightName : string.Empty);

            //mxd. Create sprite frame
            this.spriteframe = new[] { new SpriteFrameInfo {
                                           Sprite = sprite, SpriteLongName = Lump.MakeLongName(sprite, true)
                                       } };

            // Set sprite scale (mxd. Scale is translated to xscale and yscale in ActorStructure)
            if (actor.HasPropertyWithValue("xscale"))
            {
                this.spritescale.Width = actor.GetPropertyValueFloat("xscale", 0);
            }

            if (actor.HasPropertyWithValue("yscale"))
            {
                this.spritescale.Height = actor.GetPropertyValueFloat("yscale", 0);
            }

            // Size
            if (actor.HasPropertyWithValue("radius"))
            {
                radius = actor.GetPropertyValueInt("radius", 0);
            }
            if (actor.HasPropertyWithValue("height"))
            {
                height = actor.GetPropertyValueInt("height", 0);
            }

            //mxd. DistanceCheck. The value is CVAR. Also we'll need squared value
            if (actor.HasPropertyWithValue("distancecheck"))
            {
                string cvarname = actor.GetPropertyValueString("distancecheck", 0);
                if (!General.Map.Data.CVars.Integers.ContainsKey(cvarname))
                {
                    General.ErrorLogger.Add(ErrorType.Error, "Error in actor \"" + title + "\":" + index + ". DistanceCheck property references undefined cvar \"" + cvarname + "\"");
                    distancechecksq = int.MaxValue;
                }
                else
                {
                    distancechecksq = (int)Math.Pow(General.Map.Data.CVars.Integers[cvarname], 2);
                }
            }

            //mxd. Renderstyle
            if (actor.HasPropertyWithValue("renderstyle") && !actor.HasProperty("$ignorerenderstyle"))
            {
                renderstyle = actor.GetPropertyValueString("renderstyle", 0, true).ToLower();
            }

            //mxd. Alpha
            if (actor.HasPropertyWithValue("alpha"))
            {
                this.alpha     = General.Clamp(actor.GetPropertyValueFloat("alpha", 0), 0f, 1f);
                this.alphabyte = (byte)(this.alpha * 255);
            }
            else if (actor.HasProperty("defaultalpha"))
            {
                this.alpha     = (General.Map.Config.BaseGame == GameType.HERETIC ? 0.4f : 0.6f);
                this.alphabyte = (byte)(this.alpha * 255);
            }

            //mxd. BRIGHT
            this.bright = (info != null && info.Bright) || actor.GetFlagValue("bright", false);

            // Safety
            if (this.radius < 4f || this.fixedsize)
            {
                this.radius = THING_FIXED_SIZE;
            }
            if (this.spritescale.Width == 0.0f)
            {
                this.spritescale.Width = 1.0f;
            }
            if (this.spritescale.Height == 0.0f)
            {
                this.spritescale.Height = 1.0f;
            }

            // Options
            hangs = actor.GetFlagValue("spawnceiling", hangs);
            int blockvalue = (blocking > 0) ? blocking : 2;

            blocking    = actor.GetFlagValue("solid", (blocking != 0)) ? blockvalue : 0;
            xybillboard = actor.GetFlagValue("forcexybillboard", false);             //mxd

            //mxd. GZDoom rendering flags
            if (actor.GetFlagValue("wallsprite", false))
            {
                rendermode = ThingRenderMode.WALLSPRITE;
            }
            if (actor.GetFlagValue("flatsprite", false))
            {
                // WALLSPRITE + FLATSPRITE = HORRIBLE GLITCHES in GZDoom
                if (rendermode == ThingRenderMode.WALLSPRITE)
                {
                    General.ErrorLogger.Add(ErrorType.Error, "Error in actor \"" + title + "\":" + index + ". WALLSPRITE and FLATSPRITE flags can not be combined");
                }
                else
                {
                    rendermode = ThingRenderMode.FLATSPRITE;
                }
            }
            //mxd. WALLSPRITE and FLATSPRITE support rolling without the ROLLSPRITE flag
            rollsprite = actor.GetFlagValue("rollsprite", (rendermode == ThingRenderMode.WALLSPRITE || rendermode == ThingRenderMode.FLATSPRITE));
            if (rollsprite)
            {
                rollcenter = actor.GetFlagValue("rollcenter", false);
            }

            //mxd
            if (blocking > THING_BLOCKING_NONE)
            {
                errorcheck = THING_ERROR_INSIDE_STUCK;
            }

            // [ZZ]
            dynamiclighttype = GZGeneral.GetGZLightTypeByClass(actor);
        }
        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);
        }