예제 #1
0
        public TextureAnimation(TextureLookup textures, FlatLookup flats)
        {
            try
            {
                Console.Write("Load texture animation info: ");

                var list = new List <TextureAnimationInfo>();

                foreach (var animDef in DoomInfo.TextureAnimation)
                {
                    int picNum;
                    int basePic;
                    if (animDef.IsTexture)
                    {
                        if (textures.GetNumber(animDef.StartName) == -1)
                        {
                            continue;
                        }

                        picNum  = textures.GetNumber(animDef.EndName);
                        basePic = textures.GetNumber(animDef.StartName);
                    }
                    else
                    {
                        if (flats.GetNumber(animDef.StartName) == -1)
                        {
                            continue;
                        }

                        picNum  = flats.GetNumber(animDef.EndName);
                        basePic = flats.GetNumber(animDef.StartName);
                    }

                    var anim = new TextureAnimationInfo(
                        animDef.IsTexture,
                        picNum,
                        basePic,
                        picNum - basePic + 1,
                        animDef.Speed);

                    if (anim.NumPics < 2)
                    {
                        throw new Exception("Bad animation cycle from " + animDef.StartName + " to " + animDef.EndName + "!");
                    }

                    list.Add(anim);
                }

                animations = list.ToArray();

                Console.WriteLine("OK");
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed");
                ExceptionDispatchInfo.Throw(e);
            }
        }
예제 #2
0
 public CommonResource(params string[] wadPaths)
 {
     try
     {
         wad      = new Wad(wadPaths);
         palette  = new Palette(wad);
         colorMap = new ColorMap(wad);
         textures = new TextureLookup(wad);
         flats    = new FlatLookup(wad);
         sprites  = new SpriteLookup(wad);
     }
     catch (Exception e)
     {
         ExceptionDispatchInfo.Capture(e).Throw();
     }
 }
예제 #3
0
        public static Sector FromData(byte[] data, int offset, int number, FlatLookup flats)
        {
            var floorHeight     = BitConverter.ToInt16(data, offset);
            var ceilingHeight   = BitConverter.ToInt16(data, offset + 2);
            var floorFlatName   = DoomInterop.ToString(data, offset + 4, 8);
            var ceilingFlatName = DoomInterop.ToString(data, offset + 12, 8);
            var lightLevel      = BitConverter.ToInt16(data, offset + 20);
            var special         = BitConverter.ToInt16(data, offset + 22);
            var tag             = BitConverter.ToInt16(data, offset + 24);

            return(new Sector(
                       number,
                       Fixed.FromInt(floorHeight),
                       Fixed.FromInt(ceilingHeight),
                       flats.GetNumber(floorFlatName),
                       flats.GetNumber(ceilingFlatName),
                       lightLevel,
                       (SectorSpecial)special,
                       tag));
        }
예제 #4
0
        public static Sector[] FromWad(Wad wad, int lump, FlatLookup flats)
        {
            var length = wad.GetLumpSize(lump);

            if (length % dataSize != 0)
            {
                throw new Exception();
            }

            var data    = wad.ReadLump(lump);
            var count   = length / dataSize;
            var sectors = new Sector[count];;

            for (var i = 0; i < count; i++)
            {
                var offset = dataSize * i;
                sectors[i] = FromData(data, offset, i, flats);
            }

            return(sectors);
        }
예제 #5
0
        public CommonResource(string[] wadPaths, bool loadDehLump)
        {
            try
            {
                wad = new Wad(wadPaths);

                if (loadDehLump)
                {
                    DeHackEd.ReadDeHackEdLump(wad);
                }

                palette   = new Palette(wad);
                colorMap  = new ColorMap(wad);
                textures  = new TextureLookup(wad);
                flats     = new FlatLookup(wad);
                sprites   = new SpriteLookup(wad);
                animation = new TextureAnimation(textures, flats);
            }
            catch (Exception e)
            {
                ExceptionDispatchInfo.Throw(e);
            }
        }
예제 #6
0
        public Map(Wad wad, TextureLookup textures, FlatLookup flats, World world)
        {
            this.textures = textures;
            this.flats    = flats;
            this.world    = world;

            var options = world.Options;

            string name;

            if (wad.Names.Contains("doom") || wad.Names.Contains("doom1"))
            {
                name = "E" + options.Episode + "M" + options.Map;
            }
            else
            {
                name = "MAP" + options.Map.ToString("00");
            }

            var map = wad.GetLumpNumber(name);

            vertices   = Vertex.FromWad(wad, map + 4);
            sectors    = Sector.FromWad(wad, map + 8, flats);
            sides      = SideDef.FromWad(wad, map + 3, textures, sectors);
            lines      = LineDef.FromWad(wad, map + 2, vertices, sides);
            segs       = Seg.FromWad(wad, map + 5, vertices, lines);
            subsectors = Subsector.FromWad(wad, map + 6, segs);
            nodes      = Node.FromWad(wad, map + 7, subsectors);
            things     = MapThing.FromWad(wad, map + 1);
            blockMap   = BlockMap.FromWad(wad, map + 10, lines);
            reject     = Reject.FromWad(wad, map + 9, sectors);

            GroupLines();

            skyTexture = GetSkyTextureByMapName(name);
        }
예제 #7
0
        public Map(Wad wad, TextureLookup textures, FlatLookup flats, TextureAnimation animation, World world)
        {
            try
            {
                this.textures  = textures;
                this.flats     = flats;
                this.animation = animation;
                this.world     = world;

                var options = world.Options;

                string name;
                if (wad.GameMode == GameMode.Commercial)
                {
                    name = "MAP" + options.Map.ToString("00");
                }
                else
                {
                    name = "E" + options.Episode + "M" + options.Map;
                }

                Console.Write("Load map '" + name + "': ");

                var map = wad.GetLumpNumber(name);

                if (map == -1)
                {
                    throw new Exception("Map '" + name + "' was not found!");
                }

                vertices   = Vertex.FromWad(wad, map + 4);
                sectors    = Sector.FromWad(wad, map + 8, flats);
                sides      = SideDef.FromWad(wad, map + 3, textures, sectors);
                lines      = LineDef.FromWad(wad, map + 2, vertices, sides);
                segs       = Seg.FromWad(wad, map + 5, vertices, lines);
                subsectors = Subsector.FromWad(wad, map + 6, segs);
                nodes      = Node.FromWad(wad, map + 7, subsectors);
                things     = MapThing.FromWad(wad, map + 1);
                blockMap   = BlockMap.FromWad(wad, map + 10, lines);
                reject     = Reject.FromWad(wad, map + 9, sectors);

                GroupLines();

                skyTexture = GetSkyTextureByMapName(name);

                if (options.GameMode == GameMode.Commercial)
                {
                    switch (options.MissionPack)
                    {
                    case MissionPack.Plutonia:
                        title = DoomInfo.MapTitles.Plutonia[options.Map - 1];
                        break;

                    case MissionPack.Tnt:
                        title = DoomInfo.MapTitles.Tnt[options.Map - 1];
                        break;

                    default:
                        title = DoomInfo.MapTitles.Doom2[options.Map - 1];
                        break;
                    }
                }
                else
                {
                    title = DoomInfo.MapTitles.Doom[options.Episode - 1][options.Map - 1];
                }

                Console.WriteLine("OK");
            }
            catch (Exception e)
            {
                Console.WriteLine("Failed");
                ExceptionDispatchInfo.Throw(e);
            }
        }