Example #1
0
        //mxd. This checks if the thing has model override and whether pitch/roll values should be used
        internal void UpdateCache()
        {
            if (General.Map.Data == null)
            {
                return;
            }

            // Check if the thing has model override
            if (General.Map.Data.ModeldefEntries.ContainsKey(type))
            {
                ModelData md = General.Map.Data.ModeldefEntries[type];
                if ((md.LoadState == ModelLoadState.None && General.Map.Data.ProcessModel(type)) || md.LoadState != ModelLoadState.None)
                {
                    rendermode = (General.Map.Data.ModeldefEntries[type].IsVoxel ? ThingRenderMode.VOXEL : ThingRenderMode.MODEL);
                }
            }
            else // reset rendermode if we SUDDENLY became a sprite out of a model. otherwise it crashes violently.
            {
                ThingTypeInfo ti = General.Map.Data.GetThingInfo(Type);
                rendermode = (ti != null) ? ti.RenderMode : ThingRenderMode.NORMAL;
            }

            // Update radian versions of pitch and roll
            switch (rendermode)
            {
            case ThingRenderMode.MODEL:
                float     pmult = General.Map.Config.BuggyModelDefPitch ? 1 : -1;
                ModelData md    = General.Map.Data.ModeldefEntries[type];
                rollrad  = (md.UseActorRoll ? Angle2D.DegToRad(roll) : 0);
                pitchrad = ((md.InheritActorPitch || md.UseActorPitch) ? Angle2D.DegToRad(pmult * (md.InheritActorPitch ? -pitch : pitch)) : 0);
                break;

            case ThingRenderMode.FLATSPRITE:
                rollrad  = Angle2D.DegToRad(roll);
                pitchrad = Angle2D.DegToRad(pitch);
                break;

            case ThingRenderMode.WALLSPRITE:
                rollrad  = Angle2D.DegToRad(roll);
                pitchrad = 0;
                break;

            case ThingRenderMode.NORMAL:
                rollrad  = (rollsprite ? Angle2D.DegToRad(roll) : 0);
                pitchrad = 0;
                break;

            case ThingRenderMode.VOXEL:
                rollrad  = 0;
                pitchrad = 0;
                break;

            default: throw new NotImplementedException("Unknown ThingRenderMode");
            }
        }
Example #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
        }
Example #3
0
        // Constructor
        internal ThingTypeInfo(int index, ThingTypeInfo other)
        {
            // Initialize
            this.index     = index;
            this.category  = other.category;
            this.title     = other.title;
            this.actor     = other.actor;
            this.classname = other.classname;             //mxd
            this.isknown   = true;
            this.args      = new ArgumentInfo[Linedef.NUM_ARGS];
            for (int i = 0; i < Linedef.NUM_ARGS; i++)
            {
                this.args[i] = other.args[i];
            }

            // Copy properties
            this.sprite      = other.sprite;
            this.spriteframe = new SpriteFrameInfo[other.spriteframe.Length]; //mxd
            other.spriteframe.CopyTo(this.spriteframe, 0);                    //mxd
            this.color           = other.color;
            this.alpha           = other.alpha;                               //mxd
            this.alphabyte       = other.alphabyte;                           //mxd
            this.renderstyle     = other.renderstyle;                         //mxd
            this.bright          = other.bright;                              //mxd
            this.arrow           = other.arrow;
            this.radius          = other.radius;
            this.height          = other.height;
            this.distancechecksq = other.distancechecksq;             //mxd
            this.hangs           = other.hangs;
            this.blocking        = other.blocking;
            this.errorcheck      = other.errorcheck;
            this.fixedsize       = other.fixedsize;
            this.fixedrotation   = other.fixedrotation;                                                                     //mxd
            this.absolutez       = other.absolutez;
            this.xybillboard     = other.xybillboard;                                                                       //mxd
            this.spritescale     = new SizeF(other.spritescale.Width, other.spritescale.Height);
            this.flagsrename     = new Dictionary <string, Dictionary <string, string> >(StringComparer.OrdinalIgnoreCase); //mxd

            //mxd. Copy GZDoom rendering properties
            this.rendermode = other.rendermode;
            this.rollsprite = other.rollsprite;
            this.rollcenter = other.rollcenter;

            //
            this.dynamiclighttype = other.dynamiclighttype;

            //
            this.optional = other.optional;

            // We have no destructor
            GC.SuppressFinalize(this);
        }
Example #4
0
        //mxd. This checks if the thing has model override and whether pitch/roll values should be used
        internal void UpdateCache()
        {
            if (General.Map.Data == null)
            {
                return;
            }

            // Check if the thing has model override
            if (General.Map.Data.ModeldefEntries.ContainsKey(type))
            {
                ModelData md = General.Map.Data.ModeldefEntries[type];
                if ((md.LoadState == ModelLoadState.None && General.Map.Data.ProcessModel(type)) || md.LoadState != ModelLoadState.None)
                {
                    rendermode = (General.Map.Data.ModeldefEntries[type].IsVoxel ? ThingRenderMode.VOXEL : ThingRenderMode.MODEL);
                }
            }

            // Update radian versions of pitch and roll
            switch (rendermode)
            {
            case ThingRenderMode.MODEL:
                ModelData md = General.Map.Data.ModeldefEntries[type];
                rollrad  = (md.UseActorRoll ? Angle2D.DegToRad(roll) : 0);
                pitchrad = ((md.InheritActorPitch || md.UseActorPitch) ? Angle2D.DegToRad(md.InheritActorPitch ? -pitch : pitch) : 0);
                break;

            case ThingRenderMode.FLATSPRITE:
                rollrad  = Angle2D.DegToRad(roll);
                pitchrad = Angle2D.DegToRad(pitch);
                break;

            case ThingRenderMode.WALLSPRITE:
                rollrad  = Angle2D.DegToRad(roll);
                pitchrad = 0;
                break;

            case ThingRenderMode.NORMAL:
                rollrad  = (rollsprite ? Angle2D.DegToRad(roll) : 0);
                pitchrad = 0;
                break;

            case ThingRenderMode.VOXEL:
                rollrad  = 0;
                pitchrad = 0;
                break;

            default: throw new NotImplementedException("Unknown ThingRenderMode");
            }
        }
Example #5
0
        // This updates the settings from configuration
        public void UpdateConfiguration()
        {
            // Lookup settings
            ThingTypeInfo ti = General.Map.Data.GetThingInfo(type);

            // Apply size
            dynamiclighttype = (Array.IndexOf(GZBuilder.GZGeneral.GZ_LIGHTS, type) != -1) ? type : ti.DynamicLightType;
            size             = ti.Radius;
            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
        }
Example #6
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;
            }
        }