UltimateZoneBuilder/Source/Plugins/BuilderModes/VisualModes/SectorLevelComparer.cs
MaxED 5fe89efc7c Visual mode: added support for "Transfer Brightness Level" (50) effect type parameter (arg 1).
Visual mode: added support for "Transfer Floor Brightness" (210) effect.
Visual mode: added support for "Transfer Ceiling Brightness" (211) effect.
Visual mode: changed the way thing brightness is calculated. Should be closer to GZDoom now.
Sector Edit Form: you can now enter "++" or "--" into "Height Offset" input to raise or lower sectors by their height.
Cosmetic fix in ZDoom_linedefs.cfg.
2015-04-01 12:51:26 +00:00

48 lines
1.5 KiB
C#

#region === Copyright (c) 2010 Pascal van der Heiden ===
using System;
using System.Collections.Generic;
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Map;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
{
internal class SectorLevelComparer : IComparer<SectorLevel>
{
// Center of sector to use for plane comparison
public Vector2D center;
// Constructor
public SectorLevelComparer(Sector s)
{
this.center = new Vector2D(s.BBox.Left + s.BBox.Width / 2, s.BBox.Top + s.BBox.Height / 2);
}
// Comparer
public int Compare(SectorLevel x, SectorLevel y)
{
if(x == y) return 0; //mxd
float diff = (float)Math.Round(x.plane.GetZ(center) - y.plane.GetZ(center), 3);
if(diff == 0)
{
//mxd. Push light levels above floor and ceiling levels when height is the same
if(x.type != SectorLevelType.Light) return (y.type == SectorLevelType.Light ? -1 : 0);
if(y.type != SectorLevelType.Light) return (x.type == SectorLevelType.Light ? 1 : 0);
//mxd. Push light levels without lighttype (those should be lower levels of type 1 Transfer Brightness effect) above other ones
if(x.type == SectorLevelType.Light && y.type == SectorLevelType.Light)
{
if(x.lighttype == y.lighttype) return 0; //TODO: how this should be handled?
if(x.lighttype == LightLevelType.TYPE1_BOTTOM) return 1;
return -1;
}
return 0;
}
return Math.Sign(diff);
}
}
}