public static int GetGZLightTypeByClass(ActorStructure actor) { int idx = -1; ActorStructure p = actor; while (p != null) { idx = Array.IndexOf(gzLightClasses, p.ClassName.ToLowerInvariant()); if (idx != -1) { // found dynamic light type. alter it by actor flags. // +MISSILEMORE makes it additive. // +MISSILEEVENMORE makes it subtractive. // +INCOMBAT makes it attenuated. int light = gzLights[idx]; if (idx < GZ_LIGHT_TYPES[3]) { int baseType = light % 10; int dispType = light - baseType; if (actor.GetFlagValue("MISSILEMORE", false)) { dispType = 9810; } else if (actor.GetFlagValue("MISSILEEVENMORE", false)) { dispType = 9820; } else if (actor.GetFlagValue("INCOMBAT", false)) { dispType = 9830; } return(dispType + baseType); } else { return(light); } } p = p.BaseClass; } return(0); }
// [ZZ] this is for proper inheritance of lights. // technically this can be found by parsing gzdoom.pk3/mapinfo/common.txt, but I wouldn't do that without a good reason for now. public static LightData GetGZLightTypeByClass(ActorStructure actor) { ActorStructure p = actor; while (p != null) { // found dynamic light type. alter it by actor flags. // +MISSILEMORE makes it additive. // +MISSILEEVENMORE makes it subtractive. // +INCOMBAT makes it attenuated. LightData ld = GetLightDataByClass(p.ClassName); if (ld != null) { if (ld.LightDef != LightDef.VAVOOM_GENERIC && ld.LightDef != LightDef.VAVOOM_COLORED) // not vavoom { int baseType = ld.LightNum % 10; int dispType = ld.LightNum - baseType; if (actor.GetFlagValue("MISSILEMORE", false) || actor.GetFlagValue("DYNAMICLIGHT.ADDITIVE", false)) { dispType = 9810; } else if (actor.GetFlagValue("MISSILEEVENMORE", false) || actor.GetFlagValue("DYNAMICLIGHT.SUBTRACTIVE", false)) { dispType = 9820; } else if (actor.GetFlagValue("INCOMBAT", false) || actor.GetFlagValue("DYNAMICLIGHT.ATTENUATE", false)) { dispType = 9830; } if (!actor.GetFlagValue("DYNAMICLIGHT.SPOT", false) && dispType >= 9840) { dispType -= 40; } if (actor.GetFlagValue("DYNAMICLIGHT.SPOT", false) && dispType < 9840) { dispType += 40; } return(GetLightDataByNum(dispType + baseType)); } else { return(null); } } p = p.BaseClass; } return(null); }
} //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; } }
// 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; }