Beispiel #1
0
        public void SpawnGlowingLight(Sector sector)
        {
            var glowing = new GlowingLight(world);

            world.Thinkers.Add(glowing);

            glowing.Sector    = sector;
            glowing.MinLight  = FindMinSurroundingLight(sector, sector.LightLevel);
            glowing.MaxLight  = sector.LightLevel;
            glowing.Direction = -1;

            sector.Special = 0;
        }
Beispiel #2
0
            private void UnArchiveSpecials(World world)
            {
                var thinkers = world.Thinkers;
                var sa       = world.SectorAction;

                // Read in saved thinkers.
                while (true)
                {
                    var tclass = (SpecialClass)data[ptr++];
                    switch (tclass)
                    {
                    case SpecialClass.EndSpecials:
                        // End of list.
                        return;

                    case SpecialClass.Ceiling:
                        PadPointer();
                        var ceiling = new CeilingMove(world);
                        ceiling.ThinkerState       = ReadThinkerState(data, ptr + 8);
                        ceiling.Type               = (CeilingMoveType)BitConverter.ToInt32(data, ptr + 12);
                        ceiling.Sector             = world.Map.Sectors[BitConverter.ToInt32(data, ptr + 16)];
                        ceiling.Sector.SpecialData = ceiling;
                        ceiling.BottomHeight       = new Fixed(BitConverter.ToInt32(data, ptr + 20));
                        ceiling.TopHeight          = new Fixed(BitConverter.ToInt32(data, ptr + 24));
                        ceiling.Speed              = new Fixed(BitConverter.ToInt32(data, ptr + 28));
                        ceiling.Crush              = BitConverter.ToInt32(data, ptr + 32) != 0;
                        ceiling.Direction          = BitConverter.ToInt32(data, ptr + 36);
                        ceiling.Tag          = BitConverter.ToInt32(data, ptr + 40);
                        ceiling.OldDirection = BitConverter.ToInt32(data, ptr + 44);
                        ptr += 48;

                        thinkers.Add(ceiling);
                        sa.AddActiveCeiling(ceiling);
                        break;

                    case SpecialClass.Door:
                        PadPointer();
                        var door = new VerticalDoor(world);
                        door.ThinkerState       = ReadThinkerState(data, ptr + 8);
                        door.Type               = (VerticalDoorType)BitConverter.ToInt32(data, ptr + 12);
                        door.Sector             = world.Map.Sectors[BitConverter.ToInt32(data, ptr + 16)];
                        door.Sector.SpecialData = door;
                        door.TopHeight          = new Fixed(BitConverter.ToInt32(data, ptr + 20));
                        door.Speed              = new Fixed(BitConverter.ToInt32(data, ptr + 24));
                        door.Direction          = BitConverter.ToInt32(data, ptr + 28);
                        door.TopWait            = BitConverter.ToInt32(data, ptr + 32);
                        door.TopCountDown       = BitConverter.ToInt32(data, ptr + 36);
                        ptr += 40;

                        thinkers.Add(door);
                        break;

                    case SpecialClass.Floor:
                        PadPointer();
                        var floor = new FloorMove(world);
                        floor.ThinkerState       = ReadThinkerState(data, ptr + 8);
                        floor.Type               = (FloorMoveType)BitConverter.ToInt32(data, ptr + 12);
                        floor.Crush              = BitConverter.ToInt32(data, ptr + 16) != 0;
                        floor.Sector             = world.Map.Sectors[BitConverter.ToInt32(data, ptr + 20)];
                        floor.Sector.SpecialData = floor;
                        floor.Direction          = BitConverter.ToInt32(data, ptr + 24);
                        floor.NewSpecial         = (SectorSpecial)BitConverter.ToInt32(data, ptr + 28);
                        floor.Texture            = BitConverter.ToInt32(data, ptr + 32);
                        floor.FloorDestHeight    = new Fixed(BitConverter.ToInt32(data, ptr + 36));
                        floor.Speed              = new Fixed(BitConverter.ToInt32(data, ptr + 40));
                        ptr += 44;

                        thinkers.Add(floor);
                        break;

                    case SpecialClass.Plat:
                        PadPointer();
                        var plat = new Platform(world);
                        plat.ThinkerState       = ReadThinkerState(data, ptr + 8);
                        plat.Sector             = world.Map.Sectors[BitConverter.ToInt32(data, ptr + 12)];
                        plat.Sector.SpecialData = plat;
                        plat.Speed     = new Fixed(BitConverter.ToInt32(data, ptr + 16));
                        plat.Low       = new Fixed(BitConverter.ToInt32(data, ptr + 20));
                        plat.High      = new Fixed(BitConverter.ToInt32(data, ptr + 24));
                        plat.Wait      = BitConverter.ToInt32(data, ptr + 28);
                        plat.Count     = BitConverter.ToInt32(data, ptr + 32);
                        plat.Status    = (PlatformState)BitConverter.ToInt32(data, ptr + 36);
                        plat.OldStatus = (PlatformState)BitConverter.ToInt32(data, ptr + 40);
                        plat.Crush     = BitConverter.ToInt32(data, ptr + 44) != 0;
                        plat.Tag       = BitConverter.ToInt32(data, ptr + 48);
                        plat.Type      = (PlatformType)BitConverter.ToInt32(data, ptr + 52);
                        ptr           += 56;

                        thinkers.Add(plat);
                        sa.AddActivePlatform(plat);
                        break;

                    case SpecialClass.Flash:
                        PadPointer();
                        var flash = new LightFlash(world);
                        flash.ThinkerState = ReadThinkerState(data, ptr + 8);
                        flash.Sector       = world.Map.Sectors[BitConverter.ToInt32(data, ptr + 12)];
                        flash.Count        = BitConverter.ToInt32(data, ptr + 16);
                        flash.MaxLight     = BitConverter.ToInt32(data, ptr + 20);
                        flash.MinLight     = BitConverter.ToInt32(data, ptr + 24);
                        flash.MaxTime      = BitConverter.ToInt32(data, ptr + 28);
                        flash.MinTime      = BitConverter.ToInt32(data, ptr + 32);
                        ptr += 36;

                        thinkers.Add(flash);
                        break;

                    case SpecialClass.Strobe:
                        PadPointer();
                        var strobe = new StrobeFlash(world);
                        strobe.ThinkerState = ReadThinkerState(data, ptr + 8);
                        strobe.Sector       = world.Map.Sectors[BitConverter.ToInt32(data, ptr + 12)];
                        strobe.Count        = BitConverter.ToInt32(data, ptr + 16);
                        strobe.MinLight     = BitConverter.ToInt32(data, ptr + 20);
                        strobe.MaxLight     = BitConverter.ToInt32(data, ptr + 24);
                        strobe.DarkTime     = BitConverter.ToInt32(data, ptr + 28);
                        strobe.BrightTime   = BitConverter.ToInt32(data, ptr + 32);
                        ptr += 36;

                        thinkers.Add(strobe);
                        break;

                    case SpecialClass.Glow:
                        PadPointer();
                        var glow = new GlowingLight(world);
                        glow.ThinkerState = ReadThinkerState(data, ptr + 8);
                        glow.Sector       = world.Map.Sectors[BitConverter.ToInt32(data, ptr + 12)];
                        glow.MinLight     = BitConverter.ToInt32(data, ptr + 16);
                        glow.MaxLight     = BitConverter.ToInt32(data, ptr + 20);
                        glow.Direction    = BitConverter.ToInt32(data, ptr + 24);
                        ptr += 28;

                        thinkers.Add(glow);
                        break;

                    default:
                        throw new Exception("Unknown special in savegame!");
                    }
                }
            }