UltimateZoneBuilder/Source/Plugins/BuilderModes/VisualModes/EffectGlowingFlat.cs
MaxED 76559ae881 Added GZDoom's glowing flats (http://www.zdoom.org/wiki/GLDEFS#Glowing_flats) support to Classic and Visual modes.
MAPINFO: added "DoomEdNum" and "SpawnNums" blocks support.
MAPINFO: added "#include" directive support.
MAPINFO: added "$gzdb_skip" special comment support.
DECORATE: "spawnthing" Game Configuration block is now updated using "SpawnID" actor property.
Game configurations: added "class" property to the most of ZDoom things.
Actions: removed "Reload MAPINFO" action.
Documentation: merged "GLDEFS and MODELDEF support", "(Z)MAPINFO support" and "TEXTURES support" topics into "(G)ZDoom text lumps support", added info about the other text lumps GZDB can use.
2015-04-14 11:33:57 +00:00

93 lines
2.7 KiB
C#

using CodeImp.DoomBuilder.Map;
using CodeImp.DoomBuilder.Rendering;
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class EffectGlowingFlat : SectorEffect
{
private readonly Sector sector;
// Level planes
private SectorLevel ceillevel;
private SectorLevel floorlevel;
// Constructor
public EffectGlowingFlat(SectorData data, Sector sourcesector) : base(data)
{
sector = sourcesector;
// New effect added: This sector needs an update!
if(data.Mode.VisualSectorExists(data.Sector))
{
BaseVisualSector vs = (BaseVisualSector)data.Mode.GetVisualSector(data.Sector);
vs.UpdateSectorGeometry(false);
}
}
public override void Update()
{
// Create ceiling glow effect?
if(General.Map.Data.GlowingFlats.ContainsKey(sector.LongCeilTexture))
{
// Create ceiling level?
if(ceillevel == null)
{
ceillevel = new SectorLevel(data.Ceiling);
ceillevel.type = SectorLevelType.Glow;
ceillevel.disablelighting = true;
data.AddSectorLevel(ceillevel);
}
// Update ceiling level
data.CeilingGlow = General.Map.Data.GlowingFlats[sector.LongCeilTexture];
ceillevel.brightnessbelow = -1; // We need this plane for clipping only,
ceillevel.color = 0; // so we need to reset all shading and coloring
ceillevel.plane = data.Ceiling.plane;
ceillevel.plane.Offset -= data.CeilingGlow.Height;
data.CeilingGlowPlane = ceillevel.plane;
}
else
{
data.CeilingGlow = null;
}
// Create floor glow effect?
if(General.Map.Data.GlowingFlats.ContainsKey(sector.LongFloorTexture))
{
// Create floor level?
if(floorlevel == null)
{
floorlevel = new SectorLevel(data.Floor);
floorlevel.type = SectorLevelType.Glow;
floorlevel.disablelighting = true;
data.AddSectorLevel(floorlevel);
}
// Update floor level
data.FloorGlow = General.Map.Data.GlowingFlats[sector.LongFloorTexture];
floorlevel.plane = data.Floor.plane.GetInverted();
floorlevel.plane.Offset += data.FloorGlow.Height;
if(floorlevel.plane.Offset < data.Ceiling.plane.Offset)
{
floorlevel.brightnessbelow = -1; // We need this plane for clipping only,
floorlevel.color = 0; // so we need to reset all shading and coloring
floorlevel.colorbelow = new PixelColor(0, 0, 0, 0);
}
else
{
// If glow plane is above real ceiling, apply ceiling colouring
floorlevel.brightnessbelow = data.Ceiling.brightnessbelow;
floorlevel.color = data.Ceiling.color;
floorlevel.colorbelow = data.Ceiling.colorbelow;
}
data.FloorGlowPlane = floorlevel.plane;
}
else
{
data.FloorGlow = null;
}
}
}
}