Esempio n. 1
0
        // This makes sure we are updated with the source linedef information
        public override void Update()
        {
            // Find tagged sector
            Sector sourcesector = null;

            foreach (Sector s in General.Map.Map.Sectors)
            {
                if (s.Tag == thing.Args[0])
                {
                    sourcesector = s;
                    break;
                }
            }

            if (sourcesector != null)
            {
                SectorData sourcesectordata = data.Mode.GetSectorData(sourcesector);
                if (!sourcesectordata.Updated)
                {
                    sourcesectordata.Update();
                }

                if (thing.Type == 9510)
                {
                    data.Floor.plane = sourcesectordata.Floor.plane;
                }
                else if (thing.Type == 9511)
                {
                    data.Ceiling.plane = sourcesectordata.Ceiling.plane;
                }

                sourcesectordata.AddUpdateSector(data.Sector, true);
            }
        }
        // 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, false);

            if (level == null)
            {
                level = new SectorLevel(sd.Ceiling);
                data.AddSectorLevel(level);
            }

            // Update level
            sd.Ceiling.CopyProperties(level);
            level.type = SectorLevelType.Light;
        }
Esempio n. 3
0
        // This makes sure we are updated with the source linedef information
        public override void Update()
        {
            ThingData td = data.Mode.GetThingData(thing);
            Thing     t  = thing;

            // Find the tagged line
            Linedef ld = null;

            foreach (Linedef l in General.Map.Map.Linedefs)
            {
                if (l.Tag == t.Args[0])
                {
                    ld = l;
                    break;
                }
            }

            if (ld != null)
            {
                if (t.Type == 9500)
                {
                    // Slope the floor from the linedef to thing
                    t.DetermineSector(data.Mode.BlockMap);
                    if (t.Sector != null)
                    {
                        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);
                            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);
                            sd.Floor.plane = new Plane(v2, v1, v3, true);
                        }
                    }
                }
                else if (t.Type == 9501)
                {
                    // Slope the ceiling from the linedef to thing
                    t.DetermineSector(data.Mode.BlockMap);
                    if (t.Sector != null)
                    {
                        td.AddUpdateSector(t.Sector, true);
                        Vector3D v3 = new Vector3D(t.Position.x, t.Position.y, t.Position.z + t.Sector.CeilHeight);
                        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);
                            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);
                            if (!sd.Updated)
                            {
                                sd.Update();
                            }
                            sd.Ceiling.plane = new Plane(v2, v1, v3, false);
                        }
                    }
                }
            }
        }
Esempio n. 4
0
        // 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);

            // 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
            }

            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)
            {
                vavoomtype = false;
                alpha      = linedef.Args[3];
                sd.Ceiling.CopyProperties(floor);
                sd.Floor.CopyProperties(ceiling);
                floor.type    = SectorLevelType.Floor;
                floor.plane   = sd.Ceiling.plane.GetInverted();
                ceiling.type  = SectorLevelType.Ceiling;
                ceiling.plane = sd.Floor.plane.GetInverted();

                // A 3D floor's color is always that of the sector it is placed in
                floor.color = 0;
            }
            else
            {
                vavoomtype = true;

                /*
                 * 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;
                alpha         = 255;

                // A 3D floor's color is always that of the sector it is placed in
                ceiling.color = 0;
            }

            // Apply alpha
            floor.alpha   = alpha;
            ceiling.alpha = alpha;

            // Do not adjust light? (works only for non-vavoom types)
            if (((linedef.Args[2] & 1) != 0) && !vavoomtype)
            {
                floor.brightnessbelow   = -1;
                floor.colorbelow        = PixelColor.FromInt(0);
                ceiling.color           = 0;
                ceiling.brightnessbelow = -1;
                ceiling.colorbelow      = PixelColor.FromInt(0);
            }
        }
Esempio n. 5
0
        // This makes sure we are updated with the source linedef information
        public override void Update()
        {
            Linedef l = linedef;

            // Find the vertex furthest from the line
            Vertex foundv    = null;
            float  founddist = -1.0f;

            foreach (Sidedef sd in data.Sector.Sidedefs)
            {
                Vertex v = sd.IsFront ? sd.Line.Start : sd.Line.End;
                float  d = l.DistanceToSq(v.Position, false);
                if (d > founddist)
                {
                    foundv    = v;
                    founddist = d;
                }
            }

            // Align floor with back of line
            if ((l.Args[0] == 1) && (l.Front.Sector == data.Sector) && (l.Back != null))
            {
                Vector3D v1 = new Vector3D(l.Start.Position.x, l.Start.Position.y, l.Back.Sector.FloorHeight);
                Vector3D v2 = new Vector3D(l.End.Position.x, l.End.Position.y, l.Back.Sector.FloorHeight);
                Vector3D v3 = new Vector3D(foundv.Position.x, foundv.Position.y, data.Sector.FloorHeight);
                if (l.SideOfLine(v3) < 0.0f)
                {
                    data.Floor.plane = new Plane(v1, v2, v3, true);
                }
                else
                {
                    data.Floor.plane = new Plane(v2, v1, v3, true);
                }
                SectorData sd = data.Mode.GetSectorData(l.Back.Sector);
                sd.AddUpdateSector(data.Sector, true);
            }
            // Align floor with front of line
            else if ((l.Args[0] == 2) && (l.Back.Sector == data.Sector) && (l.Front != null))
            {
                Vector3D v1 = new Vector3D(l.Start.Position.x, l.Start.Position.y, l.Front.Sector.FloorHeight);
                Vector3D v2 = new Vector3D(l.End.Position.x, l.End.Position.y, l.Front.Sector.FloorHeight);
                Vector3D v3 = new Vector3D(foundv.Position.x, foundv.Position.y, data.Sector.FloorHeight);
                if (l.SideOfLine(v3) < 0.0f)
                {
                    data.Floor.plane = new Plane(v1, v2, v3, true);
                }
                else
                {
                    data.Floor.plane = new Plane(v2, v1, v3, true);
                }
                SectorData sd = data.Mode.GetSectorData(l.Front.Sector);
                sd.AddUpdateSector(data.Sector, true);
            }

            // Align ceiling with back of line
            if ((l.Args[1] == 1) && (l.Front.Sector == data.Sector) && (l.Back != null))
            {
                Vector3D v1 = new Vector3D(l.Start.Position.x, l.Start.Position.y, l.Back.Sector.CeilHeight);
                Vector3D v2 = new Vector3D(l.End.Position.x, l.End.Position.y, l.Back.Sector.CeilHeight);
                Vector3D v3 = new Vector3D(foundv.Position.x, foundv.Position.y, data.Sector.CeilHeight);
                if (l.SideOfLine(v3) > 0.0f)
                {
                    data.Ceiling.plane = new Plane(v1, v2, v3, false);
                }
                else
                {
                    data.Ceiling.plane = new Plane(v2, v1, v3, false);
                }
                SectorData sd = data.Mode.GetSectorData(l.Back.Sector);
                sd.AddUpdateSector(data.Sector, true);
            }
            // Align ceiling with front of line
            else if ((l.Args[1] == 2) && (l.Back.Sector == data.Sector) && (l.Front != null))
            {
                Vector3D v1 = new Vector3D(l.Start.Position.x, l.Start.Position.y, l.Front.Sector.CeilHeight);
                Vector3D v2 = new Vector3D(l.End.Position.x, l.End.Position.y, l.Front.Sector.CeilHeight);
                Vector3D v3 = new Vector3D(foundv.Position.x, foundv.Position.y, data.Sector.CeilHeight);
                if (l.SideOfLine(v3) > 0.0f)
                {
                    data.Ceiling.plane = new Plane(v1, v2, v3, false);
                }
                else
                {
                    data.Ceiling.plane = new Plane(v2, v1, v3, false);
                }
                SectorData sd = data.Mode.GetSectorData(l.Front.Sector);
                sd.AddUpdateSector(data.Sector, true);
            }
        }