Ejemplo n.º 1
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++)
            {
                if (!actor.HasPropertyWithValue("$arg" + i))
                {
                    continue;
                }
                string argtitle       = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i));
                string argtooltip     = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "tooltip").Replace("\\n", Environment.NewLine));
                int    argtype        = actor.GetPropertyValueInt("$arg" + i + "type", 0);
                int    defaultvalue   = actor.GetPropertyValueInt("$arg" + i + "default", 0);
                string argenum        = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "enum"));
                string argrenderstyle = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "renderstyle"));
                string argrendercolor = ZDTextParser.StripQuotes(actor.GetPropertyAllValues("$arg" + i + "rendercolor"));
                args[i] = new ArgumentInfo(title, argtitle, argtooltip, argrenderstyle, argrendercolor, argtype, defaultvalue, argenum, General.Map.Config.Enums);
            }

            //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
            rollsprite = actor.GetFlagValue("rollsprite", false);
            if (rollsprite)
            {
                rollcenter = actor.GetFlagValue("rollcenter", false);
            }
            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;
                    dontflip   = actor.GetFlagValue("dontflip", false);
                }
            }

            //mxd
            if (blocking > THING_BLOCKING_NONE)
            {
                errorcheck = THING_ERROR_INSIDE_STUCK;
            }
        }
Ejemplo n.º 2
0
        // This updates the properties from a decorate actor
        internal void ModifyByDecorateActor(ActorStructure actor)
        {
            // Keep reference to actor
            this.actor = actor;

            // Set the title
            if (actor.HasPropertyWithValue("$title"))
            {
                title = actor.GetPropertyAllValues("$title");
            }
            else if (actor.HasPropertyWithValue("tag"))
            {
                title = actor.GetPropertyAllValues("tag");
            }
            else if (string.IsNullOrEmpty(title))
            {
                title = actor.ClassName;
            }

            // Remove doublequotes from title
            if ((title.Length > 2) && title.StartsWith("\"") && title.EndsWith("\""))
            {
                title = title.Substring(1, title.Length - 2);
            }

            // Set sprite
            string suitablesprite = actor.FindSuitableSprite();

            if (!string.IsNullOrEmpty(suitablesprite))
            {
                sprite = suitablesprite;
            }

            this.spritelongname = Lump.MakeLongName(this.sprite);

            // Set sprite scale
            if (actor.HasPropertyWithValue("scale"))
            {
                float scale = actor.GetPropertyValueFloat("scale", 0);
                this.spritescale = new SizeF(scale, scale);
            }
            else
            {
                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);
            }

            // Safety
            if (this.radius < 4f)
            {
                this.radius = 8f;
            }
            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;
        }