示例#1
0
        /// <summary>
        /// Initiates loading of world objects.
        /// </summary>
        public void Init()
        {
            Iffs         = new FAR1Provider <Iff>(ContentManager, new IffCodec(), "objectdata\\objects\\objiff.far");
            Sprites      = new FAR1Provider <Iff>(ContentManager, new IffCodec(), new Regex(".*\\\\objspf.*\\.far"));
            TuningTables = new FAR1Provider <OTF>(ContentManager, new OTFCodec(), new Regex(".*\\\\objotf.*\\.far"));

            Iffs.Init();
            TuningTables.Init();
            Sprites.Init();

            /** Load packingslip **/
            Entries = new Dictionary <ulong, GameObjectReference>();
            Cache   = new Dictionary <ulong, GameObject>();

            var packingslip = new XmlDataDocument();

            packingslip.Load(ContentManager.GetPath("packingslips\\objecttable.xml"));
            var objectInfos = packingslip.GetElementsByTagName("I");

            foreach (XmlNode objectInfo in objectInfos)
            {
                ulong FileID = Convert.ToUInt32(objectInfo.Attributes["g"].Value, 16);
                Entries.Add(FileID, new GameObjectReference(this)
                {
                    ID       = FileID,
                    FileName = objectInfo.Attributes["n"].Value
                });
            }
        }
示例#2
0
        public void Init()
        {
            this.Stations     = new List <AudioReference>();
            this.StationsById = new Dictionary <uint, AudioReference>();
            this.Modes        = new List <AudioReference>();

            var stationsRegEx = new Regex(@"music\\stations\\.*\.mp3");

            foreach (var file in ContentManager.AllFiles)
            {
                if (stationsRegEx.IsMatch(file))
                {
                    var reference = new AudioReference {
                        Type = AudioType.RADIO_STATION, FilePath = ContentManager.GetPath(file)
                    };
                    Stations.Add(reference);
                    var idString = Path.GetFileNameWithoutExtension(file);
                    idString = idString.Substring(idString.LastIndexOf("_") + 1);
                    var id = Convert.ToUInt32(idString, 16);
                    reference.ID = id;
                    StationsById.Add(id, reference);
                }
            }

            TSOAudio = new DBPF(ContentManager.GetPath("TSOAudio.dat"));
            tsov2    = new DBPF(ContentManager.GetPath("tsov2.dat"));
            Stings   = new DBPF(ContentManager.GetPath("Stings.dat"));
            EP5Samps = new DBPF(ContentManager.GetPath("EP5Samps.dat"));
            EP2      = new DBPF(ContentManager.GetPath("EP2.dat"));
            Hitlists = new DBPF(ContentManager.GetPath("HitListsTemp.dat"));

            SFXCache     = new Dictionary <uint, GCHandle>();
            TracksById   = new Dictionary <uint, Track>();
            HitlistsById = new Dictionary <uint, Hitlist>();

            AddTracksFrom(TSOAudio);
        }
        /// <summary>
        /// Initiates loading of floors.
        /// </summary>
        public void Init()
        {
            /**
             * TODO: We can make this lazy load a bit better. Inside the far archives we
             * could just keep far entry pointers rather than processing them. Assuming each file
             * in the far only contains 1 floor style. If its variable this may not be possible
             */

            this.ById   = new Dictionary <ushort, Floor>();
            this.Floors = new List <Floor>();

            var floorGlobalsPath = ContentManager.GetPath("objectdata/globals/floors.iff");
            var floorGlobals     = new Iff(floorGlobalsPath);

            /** There is a small handful of floors in a global file for some reason **/
            ushort floorID = 1;

            for (ushort i = 1; i < 30; i++)
            {
                var far    = floorGlobals.Get <SPR2>(i);
                var medium = floorGlobals.Get <SPR2>((ushort)(i + 256));
                var near   = floorGlobals.Get <SPR2>((ushort)(2048));

                this.AddFloor(new Floor
                {
                    ID     = floorID,
                    Far    = far,
                    Medium = medium,
                    Near   = near
                });
                floorID++;
            }

            floorID = 256;

            var archives = new string[]
            {
                "housedata/floors/floors.far",
                "housedata/floors2/floors2.far",
                "housedata/floors3/floors3.far",
                "housedata/floors4/floors4.far"
            };

            for (var i = 0; i < archives.Length; i++)
            {
                var archivePath = ContentManager.GetPath(archives[i]);
                var archive     = new FAR1Archive(archivePath);
                var entries     = archive.GetAllEntries();

                foreach (var entry in entries)
                {
                    var iff   = new Iff();
                    var bytes = archive.GetEntry(entry);
                    using (var stream = new MemoryStream(bytes))
                    {
                        iff.Read(stream);
                    }

                    var far    = iff.Get <SPR2>(1);
                    var medium = iff.Get <SPR2>(257);
                    var near   = iff.Get <SPR2>(513);

                    AddFloor(new Floor {
                        ID     = floorID,
                        Near   = near,
                        Medium = medium,
                        Far    = far
                    });
                    floorID++;
                }
            }
        }
        /// <summary>
        /// Initiates loading of walls.
        /// </summary>
        public void Init()
        {
            /**
             * See floor for suggestions for implementation that doesn't load everything.
             */

            this.ById       = new Dictionary <ushort, Wall>();
            this.Walls      = new List <Wall>();
            this.StyleById  = new Dictionary <ushort, WallStyle>();
            this.WallStyles = new List <WallStyle>();

            var wallGlobalsPath = ContentManager.GetPath("objectdata/globals/walls.iff");
            var wallGlobals     = new Iff(wallGlobalsPath);

            /** Get wall styles from globals file **/
            ushort wallID = 1;

            for (ushort i = 2; i < 512; i += 2)
            {
                var far    = wallGlobals.Get <SPR>((ushort)(i));
                var medium = wallGlobals.Get <SPR>((ushort)(i + 512));
                var near   = wallGlobals.Get <SPR>((ushort)(i + 1024));

                var fard    = wallGlobals.Get <SPR>((ushort)(i + 1));
                var mediumd = wallGlobals.Get <SPR>((ushort)(i + 513));
                var neard   = wallGlobals.Get <SPR>((ushort)(i + 1025));

                if (fard == null)
                { //no walls down, just render exactly the same
                    fard    = far;
                    mediumd = medium;
                    neard   = near;
                }

                this.AddWallStyle(new WallStyle
                {
                    ID              = wallID,
                    WallsUpFar      = far,
                    WallsUpMedium   = medium,
                    WallsUpNear     = near,
                    WallsDownFar    = fard,
                    WallsDownMedium = mediumd,
                    WallsDownNear   = neard
                });

                wallID++;
            }

            DynamicStyleID = 256; //styles loaded from objects start at 256. The objd reference is dynamically altered to reference this new id,
            //so only refresh wall cache at same time as obj cache! (do this on lot unload)

            /** Get wall patterns from globals file **/

            wallID = 0;
            for (ushort i = 0; i < 256; i++)
            {
                var far    = wallGlobals.Get <SPR>((ushort)(i + 1536));
                var medium = wallGlobals.Get <SPR>((ushort)(i + 1536 + 256));
                var near   = wallGlobals.Get <SPR>((ushort)(i + 1536 + 512));

                this.AddWall(new Wall
                {
                    ID     = wallID,
                    Far    = far,
                    Medium = medium,
                    Near   = near,
                });

                wallID++;
            }

            Junctions = new Wall
            {
                ID     = wallID,
                Far    = wallGlobals.Get <SPR>(4096),
                Medium = wallGlobals.Get <SPR>(4097),
                Near   = wallGlobals.Get <SPR>(4098),
            };

            wallID = 256;

            var archives = new string[]
            {
                "housedata/walls/walls.far",
                "housedata/walls2/walls2.far",
                "housedata/walls3/walls3.far",
                "housedata/walls4/walls4.far"
            };

            for (var i = 0; i < archives.Length; i++)
            {
                var archivePath = ContentManager.GetPath(archives[i]);
                var archive     = new FAR1Archive(archivePath);
                var entries     = archive.GetAllEntries();

                foreach (var entry in entries)
                {
                    var iff   = new Iff();
                    var bytes = archive.GetEntry(entry);
                    using (var stream = new MemoryStream(bytes))
                    {
                        iff.Read(stream);
                    }

                    var far    = iff.Get <SPR>(1);
                    var medium = iff.Get <SPR>(1793);
                    var near   = iff.Get <SPR>(2049);

                    AddWall(new Wall {
                        ID     = wallID,
                        Near   = near,
                        Medium = medium,
                        Far    = far
                    });
                    wallID++;
                }
            }
        }