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

70 lines
2.4 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;
private Sidedef sidedef;
2010-09-11 20:14:36 +00:00
// Constructor
public EffectThingLineSlope(SectorData data, Thing sourcething, Sidedef sourcesidedef) : base(data)
2010-09-11 20:14:36 +00:00
{
thing = sourcething;
sidedef = sourcesidedef;
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()
{
//mxd. Skip if arg0 is 0.
if(thing.Args[0] == 0) return;
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;
Linedef ld = sidedef.Line;
2010-09-13 06:07:11 +00:00
2010-09-11 20:14:36 +00:00
if(ld != null)
{
if(t.Type == 9500)
{
SectorData sd = data.Mode.GetSectorData(sidedef.Sector);
Vector3D v1 = new Vector3D(ld.Start.Position.x, ld.Start.Position.y, sd.Floor.plane.GetZ(ld.Start.Position));
Vector3D v2 = new Vector3D(ld.End.Position.x, ld.End.Position.y, sd.Floor.plane.GetZ(ld.End.Position));
Vector3D v3 = new Vector3D(t.Position.x, t.Position.y, t.Position.z + sd.Floor.plane.GetZ(t.Position));
sd.AddUpdateSector(data.Sector, true);
if (!sd.Updated) sd.Update();
td.AddUpdateSector(sidedef.Sector, true);
sd.Floor.plane = new Plane(v1, v2, v3, true);
2010-09-11 20:14:36 +00:00
}
else if(t.Type == 9501)
{
SectorData sd = data.Mode.GetSectorData(sidedef.Sector);
Vector3D v1 = new Vector3D(ld.Start.Position.x, ld.Start.Position.y, sd.Ceiling.plane.GetZ(ld.Start.Position));
Vector3D v2 = new Vector3D(ld.End.Position.x, ld.End.Position.y, sd.Ceiling.plane.GetZ(ld.End.Position));
Vector3D v3 = new Vector3D(t.Position.x, t.Position.y, t.Position.z + sd.Ceiling.plane.GetZ(t.Position));
sd.AddUpdateSector(data.Sector, true);
if (!sd.Updated) sd.Update();
td.AddUpdateSector(sidedef.Sector, true);
sd.Ceiling.plane = new Plane(v1, v2, v3, false);
2010-09-11 20:14:36 +00:00
}
}
}
}
}