UltimateZoneBuilder/Source/Plugins/BuilderModes/VisualModes/EffectThingLineSlope.cs

112 lines
3.8 KiB
C#
Raw Normal View History

2010-09-11 20:14:36 +00:00
#region === Copyright (c) 2010 Pascal van der Heiden ===
using CodeImp.DoomBuilder.Geometry;
using CodeImp.DoomBuilder.Map;
#endregion
namespace CodeImp.DoomBuilder.BuilderModes
2010-09-11 20:14:36 +00:00
{
internal class EffectThingLineSlope : SectorEffect
{
// Thing used to create this effect
// The thing is in the sector that must receive the slope and the
// Thing's arg 0 indicates the linedef to start the slope at.
private Thing thing;
// Constructor
public EffectThingLineSlope(SectorData data, Thing sourcething) : base(data)
{
thing = sourcething;
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()
{
2010-09-15 09:08:40 +00:00
ThingData td = data.Mode.GetThingData(thing);
2010-09-11 20:14:36 +00:00
Thing t = thing;
2010-09-13 06:07:11 +00:00
2010-09-11 20:14:36 +00:00
// Find the tagged line
Linedef ld = null;
foreach(Linedef l in General.Map.Map.Linedefs)
{
if(l.Tags.Contains(t.Args[0]))
2010-09-11 20:14:36 +00:00
{
ld = l;
break;
}
}
if(ld != null)
{
if(t.Type == 9500)
{
// Slope the floor from the linedef to thing
t.DetermineSector(data.Mode.BlockMap);
2010-09-15 09:08:40 +00:00
if(t.Sector != null)
2010-09-11 20:14:36 +00:00
{
2010-09-15 09:08:40 +00:00
Vector3D v3 = new Vector3D(t.Position.x, t.Position.y, t.Position.z + t.Sector.FloorHeight);
if(ld.SideOfLine(t.Position) < 0.0f)
{
Vector3D v1 = new Vector3D(ld.Start.Position.x, ld.Start.Position.y, ld.Front.Sector.FloorHeight);
Vector3D v2 = new Vector3D(ld.End.Position.x, ld.End.Position.y, ld.Front.Sector.FloorHeight);
SectorData sd = data.Mode.GetSectorData(ld.Front.Sector);
sd.AddUpdateSector(data.Sector, true);
if(!sd.Updated) sd.Update();
td.AddUpdateSector(ld.Front.Sector, true);
2010-09-15 09:08:40 +00:00
sd.Floor.plane = new Plane(v1, v2, v3, true);
}
else
{
Vector3D v1 = new Vector3D(ld.Start.Position.x, ld.Start.Position.y, ld.Back.Sector.FloorHeight);
Vector3D v2 = new Vector3D(ld.End.Position.x, ld.End.Position.y, ld.Back.Sector.FloorHeight);
SectorData sd = data.Mode.GetSectorData(ld.Back.Sector);
sd.AddUpdateSector(data.Sector, true);
if(!sd.Updated) sd.Update();
td.AddUpdateSector(ld.Back.Sector, true);
2010-09-15 09:08:40 +00:00
sd.Floor.plane = new Plane(v2, v1, v3, true);
}
2010-09-11 20:14:36 +00:00
}
}
else if(t.Type == 9501)
{
// Slope the ceiling from the linedef to thing
t.DetermineSector(data.Mode.BlockMap);
2010-09-15 09:08:40 +00:00
if(t.Sector != null)
2010-09-11 20:14:36 +00:00
{
td.AddUpdateSector(t.Sector, true);
Vector3D v3 = new Vector3D(t.Position.x, t.Position.y, t.Position.z + t.Sector.CeilHeight);
2010-09-15 09:08:40 +00:00
if(ld.SideOfLine(t.Position) < 0.0f)
{
Vector3D v1 = new Vector3D(ld.Start.Position.x, ld.Start.Position.y, ld.Front.Sector.CeilHeight);
Vector3D v2 = new Vector3D(ld.End.Position.x, ld.End.Position.y, ld.Front.Sector.CeilHeight);
SectorData sd = data.Mode.GetSectorData(ld.Front.Sector);
sd.AddUpdateSector(data.Sector, true);
td.AddUpdateSector(ld.Front.Sector, true);
2010-09-15 09:08:40 +00:00
if(!sd.Updated) sd.Update();
sd.Ceiling.plane = new Plane(v1, v2, v3, false);
}
else
{
Vector3D v1 = new Vector3D(ld.Start.Position.x, ld.Start.Position.y, ld.Back.Sector.CeilHeight);
Vector3D v2 = new Vector3D(ld.End.Position.x, ld.End.Position.y, ld.Back.Sector.CeilHeight);
SectorData sd = data.Mode.GetSectorData(ld.Back.Sector);
sd.AddUpdateSector(data.Sector, true);
td.AddUpdateSector(ld.Back.Sector, true);
2010-09-15 09:08:40 +00:00
if(!sd.Updated) sd.Update();
sd.Ceiling.plane = new Plane(v2, v1, v3, false);
}
2010-09-11 20:14:36 +00:00
}
}
}
}
}
}