2010-09-11 20:14:36 +00:00
|
|
|
#region === Copyright (c) 2010 Pascal van der Heiden ===
|
|
|
|
|
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Globalization;
|
|
|
|
using System.Text;
|
|
|
|
using CodeImp.DoomBuilder.Geometry;
|
|
|
|
using CodeImp.DoomBuilder.Map;
|
|
|
|
using CodeImp.DoomBuilder.Rendering;
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
2012-11-27 21:12:20 +00:00
|
|
|
namespace CodeImp.DoomBuilder.BuilderModes
|
2010-09-11 20:14:36 +00:00
|
|
|
{
|
|
|
|
internal class Effect3DFloor : SectorEffect
|
|
|
|
{
|
|
|
|
// Linedef that is used to create this effect
|
|
|
|
// The sector can be found by linedef.Front.Sector
|
|
|
|
private Linedef linedef;
|
|
|
|
|
|
|
|
// Floor and ceiling planes
|
|
|
|
private SectorLevel floor;
|
|
|
|
private SectorLevel ceiling;
|
|
|
|
|
|
|
|
// Alpha transparency
|
|
|
|
private int alpha;
|
2010-09-15 18:17:38 +00:00
|
|
|
|
|
|
|
// Vavoom type?
|
|
|
|
private bool vavoomtype;
|
2010-09-11 20:14:36 +00:00
|
|
|
|
|
|
|
// Properties
|
|
|
|
public int Alpha { get { return alpha; } }
|
|
|
|
public SectorLevel Floor { get { return floor; } }
|
|
|
|
public SectorLevel Ceiling { get { return ceiling; } }
|
|
|
|
public Linedef Linedef { get { return linedef; } }
|
2010-09-15 18:17:38 +00:00
|
|
|
public bool VavoomType { get { return vavoomtype; } }
|
|
|
|
|
2010-09-11 20:14:36 +00:00
|
|
|
// Constructor
|
|
|
|
public Effect3DFloor(SectorData data, Linedef sourcelinedef) : base(data)
|
|
|
|
{
|
|
|
|
linedef = sourcelinedef;
|
2010-09-13 06:07:11 +00:00
|
|
|
|
|
|
|
// New effect added: This sector needs an update!
|
|
|
|
if(data.Mode.VisualSectorExists(data.Sector))
|
|
|
|
{
|
|
|
|
BaseVisualSector vs = (BaseVisualSector)data.Mode.GetVisualSector(data.Sector);
|
|
|
|
vs.UpdateSectorGeometry(true);
|
|
|
|
}
|
2010-09-11 20:14:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// This makes sure we are updated with the source linedef information
|
|
|
|
public override void Update()
|
|
|
|
{
|
|
|
|
SectorData sd = data.Mode.GetSectorData(linedef.Front.Sector);
|
|
|
|
if(!sd.Updated) sd.Update();
|
|
|
|
sd.AddUpdateSector(data.Sector, true);
|
|
|
|
|
2010-09-13 06:07:11 +00:00
|
|
|
// Check if this effect still exists
|
|
|
|
int sectortag = linedef.Args[0] + (linedef.Args[4] << 8);
|
|
|
|
if(linedef.IsDisposed || (linedef.Action != 160) || (sectortag != data.Sector.Tag))
|
|
|
|
{
|
|
|
|
// When the effect is no longer exists, we must remove it and update sectors
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2010-09-11 20:14:36 +00:00
|
|
|
if(floor == null)
|
|
|
|
{
|
|
|
|
floor = new SectorLevel(sd.Floor);
|
|
|
|
data.AddSectorLevel(floor);
|
|
|
|
}
|
|
|
|
|
|
|
|
if(ceiling == null)
|
|
|
|
{
|
|
|
|
ceiling = new SectorLevel(sd.Ceiling);
|
|
|
|
data.AddSectorLevel(ceiling);
|
|
|
|
}
|
|
|
|
|
|
|
|
// For non-vavoom types, we must switch the level types
|
|
|
|
int argtype = (linedef.Args[1] & 0x03);
|
|
|
|
if(argtype != 0)
|
|
|
|
{
|
2010-09-15 18:17:38 +00:00
|
|
|
vavoomtype = false;
|
2010-09-11 20:14:36 +00:00
|
|
|
alpha = linedef.Args[3];
|
|
|
|
sd.Ceiling.CopyProperties(floor);
|
|
|
|
sd.Floor.CopyProperties(ceiling);
|
|
|
|
floor.type = SectorLevelType.Floor;
|
2010-09-16 19:38:46 +00:00
|
|
|
floor.plane = sd.Ceiling.plane.GetInverted();
|
2010-09-11 20:14:36 +00:00
|
|
|
ceiling.type = SectorLevelType.Ceiling;
|
2010-09-16 19:38:46 +00:00
|
|
|
ceiling.plane = sd.Floor.plane.GetInverted();
|
|
|
|
|
|
|
|
// A 3D floor's color is always that of the sector it is placed in
|
|
|
|
floor.color = 0;
|
2010-09-11 20:14:36 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2010-09-15 18:17:38 +00:00
|
|
|
vavoomtype = true;
|
2010-09-16 19:38:46 +00:00
|
|
|
/*
|
|
|
|
sd.Ceiling.CopyProperties(floor);
|
|
|
|
sd.Floor.CopyProperties(ceiling);
|
|
|
|
*/
|
|
|
|
floor.type = SectorLevelType.Ceiling;
|
|
|
|
floor.plane = sd.Ceiling.plane;
|
|
|
|
ceiling.type = SectorLevelType.Floor;
|
|
|
|
ceiling.plane = sd.Floor.plane;
|
2010-09-11 20:14:36 +00:00
|
|
|
alpha = 255;
|
2010-09-16 19:38:46 +00:00
|
|
|
|
|
|
|
// A 3D floor's color is always that of the sector it is placed in
|
|
|
|
ceiling.color = 0;
|
2010-09-11 20:14:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Apply alpha
|
|
|
|
floor.alpha = alpha;
|
|
|
|
ceiling.alpha = alpha;
|
|
|
|
|
|
|
|
// Do not adjust light? (works only for non-vavoom types)
|
2010-09-15 18:17:38 +00:00
|
|
|
if(((linedef.Args[2] & 1) != 0) && !vavoomtype)
|
2010-09-11 20:14:36 +00:00
|
|
|
{
|
|
|
|
floor.brightnessbelow = -1;
|
|
|
|
floor.colorbelow = PixelColor.FromInt(0);
|
|
|
|
ceiling.color = 0;
|
|
|
|
ceiling.brightnessbelow = -1;
|
|
|
|
ceiling.colorbelow = PixelColor.FromInt(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|