コード例 #1
0
ファイル: BSPPortal.cs プロジェクト: shawarma-golem/ACE
        public static BSPPortal ReadPortal(DatReader datReader, BSPType treeType)
        {
            BSPPortal obj = new BSPPortal();

            obj.Type           = 0x504F5254; // PORT
            obj.SplittingPlane = Plane.Read(datReader);
            obj.PosNode        = BSPNode.Read(datReader, treeType);
            obj.NegNode        = BSPNode.Read(datReader, treeType);

            if (treeType == BSPType.Drawing)
            {
                obj.Sphere = CSphere.Read(datReader);

                uint numPolys   = datReader.ReadUInt32();
                uint numPortals = datReader.ReadUInt32();

                for (uint i = 0; i < numPolys; i++)
                {
                    obj.InPolys.Add(datReader.ReadUInt16());
                }

                for (uint i = 0; i < numPortals; i++)
                {
                    obj.InPortals.Add(PortalPoly.Read(datReader));
                }
            }

            return(obj);
        }
コード例 #2
0
ファイル: StopParticleHook.cs プロジェクト: jumpcakes/ACE
        public static StopParticleHook ReadHookType(DatReader datReader)
        {
            StopParticleHook sp = new StopParticleHook();

            sp.EmitterId = datReader.ReadUInt32();
            return(sp);
        }
コード例 #3
0
ファイル: Palette.cs プロジェクト: shawarma-golem/ACE
        public static Palette ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((Palette)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                Palette   obj       = new Palette();
                obj.Id = datReader.ReadUInt32();

                uint num_colors = datReader.ReadUInt32();
                for (uint i = 0; i < num_colors; i++)
                {
                    obj.Colors.Add(datReader.ReadUInt32());
                }

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = obj;

                return(obj);
            }
        }
コード例 #4
0
        public static DefaultScriptPartHook ReadHookType(DatReader datReader)
        {
            DefaultScriptPartHook dsp = new DefaultScriptPartHook();

            dsp.PartIndex = datReader.ReadUInt32();
            return(dsp);
        }
コード例 #5
0
ファイル: ContractTable.cs プロジェクト: shawarma-golem/ACE
        public static ContractTable ReadFromDat()
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(CONTRACT_TABLE_ID))
            {
                return((ContractTable)DatManager.PortalDat.FileCache[CONTRACT_TABLE_ID]);
            }
            else
            {
                DatReader     datReader = DatManager.PortalDat.GetReaderForFile(CONTRACT_TABLE_ID);
                ContractTable obj       = new ContractTable();

                obj.Id = datReader.ReadUInt32();

                ushort num_contracts = datReader.ReadUInt16();
                ushort table_size    = datReader.ReadUInt16(); // We don't need this since C# handles it's own memory
                for (ushort i = 0; i < num_contracts; i++)
                {
                    uint     key   = datReader.ReadUInt32();
                    Contract value = Contract.Read(datReader);
                    obj.Contracts.Add(key, value);
                }

                DatManager.PortalDat.FileCache[CONTRACT_TABLE_ID] = obj;
                return(obj);
            }
        }
コード例 #6
0
        public static SkyTimeOfDay Read(DatReader datReader)
        {
            SkyTimeOfDay obj = new SkyTimeOfDay();

            obj.Begin      = datReader.ReadSingle();
            obj.DirBright  = datReader.ReadSingle();
            obj.DirHeading = datReader.ReadSingle();
            obj.DirPitch   = datReader.ReadSingle();
            obj.DirColor   = datReader.ReadUInt32();

            obj.AmbBright = datReader.ReadSingle();
            obj.AmbColor  = datReader.ReadUInt32();

            obj.MinWorldFog   = datReader.ReadSingle();
            obj.MaxWorldFog   = datReader.ReadSingle();
            obj.WorldFogColor = datReader.ReadUInt32();
            obj.WorldFog      = datReader.ReadUInt32();

            uint num_sky_obj_replace = datReader.ReadUInt32();

            for (uint i = 0; i < num_sky_obj_replace; i++)
            {
                obj.SkyObjReplace.Add(SkyObjectReplace.Read(datReader));
            }

            return(obj);
        }
コード例 #7
0
ファイル: GeneratorTable.cs プロジェクト: shawarma-golem/ACE
        public static Generator ReadFromDat()
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(0x0E00000D))
            {
                return((Generator)DatManager.PortalDat.FileCache[0x0E00000D]);
            }
            else
            {
                Generator gen = new Generator();

                // Create the datReader for the proper file
                DatReader datReader = DatManager.PortalDat.GetReaderForFile(0x0E00000D);

                gen.Id           = datReader.ReadInt32();
                gen.Name         = "0E00000D";
                gen.Count        = 2;
                datReader.Offset = 16;

                Generator playDay       = new Generator();
                Generator weenieObjects = new Generator();
                gen.Items.Add(playDay.GetNextGenerator(datReader));       // Parse and add PlayDay hierarchy
                gen.Items.Add(weenieObjects.GetNextGenerator(datReader)); // Parse and add WeenieObjects hierarchy

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[0x0E00000D] = gen;
                return(gen);
            }
        }
コード例 #8
0
        public static BSPTree Read(DatReader datReader, BSPType treeType)
        {
            BSPTree obj = new BSPTree();

            obj.RootNode = BSPNode.Read(datReader, treeType);
            return(obj);
        }
コード例 #9
0
        public static CombatManeuverTable ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((CombatManeuverTable)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader           datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                CombatManeuverTable obj       = new CombatManeuverTable();

                obj.Id = datReader.ReadUInt32(); // This should always equal the fileId

                uint num_combat_maneuvers = datReader.ReadUInt32();
                for (uint i = 0; i < num_combat_maneuvers; i++)
                {
                    obj.CMT.Add(CombatManeuver.Read(datReader));
                }

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = obj;

                return(obj);
            }
        }
コード例 #10
0
        public static GfxObjDegradeInfo ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((GfxObjDegradeInfo)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader         datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                GfxObjDegradeInfo obj       = new GfxObjDegradeInfo();

                obj.Id = datReader.ReadUInt32();

                uint num_degrades = datReader.ReadUInt32();
                for (uint i = 0; i < num_degrades; i++)
                {
                    obj.Degrades.Add(GfxObjInfo.Read(datReader));
                }

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = obj;

                return(obj);
            }
        }
コード例 #11
0
ファイル: PhysicsScript.cs プロジェクト: shawarma-golem/ACE
        public static PhysicsScript ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((PhysicsScript)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader     datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                PhysicsScript obj       = new PhysicsScript();
                obj.Id = datReader.ReadUInt32();

                uint num_script_data = datReader.ReadUInt32();
                for (uint i = 0; i < num_script_data; i++)
                {
                    obj.ScriptData.Add(PhysicsScriptData.Read(datReader));
                }

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = obj;

                return(obj);
            }
        }
コード例 #12
0
ファイル: GameTime.cs プロジェクト: shawarma-golem/ACE
        public static GameTime Read(DatReader datReader)
        {
            GameTime obj = new GameTime();

            obj.ZeroTimeOfYear = datReader.ReadUInt64();
            obj.ZeroYear       = datReader.ReadUInt32();
            obj.DayLength      = datReader.ReadUInt32();
            obj.DaysPerYear    = datReader.ReadUInt32();
            obj.YearSpec       = datReader.ReadPString();
            datReader.AlignBoundary();

            uint numTimesOfDay = datReader.ReadUInt32();

            for (uint i = 0; i < numTimesOfDay; i++)
            {
                obj.TimesOfDay.Add(TimeOfDay.Read(datReader));
            }

            uint numDaysOfTheWeek = datReader.ReadUInt32();

            for (uint i = 0; i < numDaysOfTheWeek; i++)
            {
                obj.DaysOfTheWeek.Add(datReader.ReadPString());
                datReader.AlignBoundary();
            }

            uint numSeasons = datReader.ReadUInt32();

            for (uint i = 0; i < numSeasons; i++)
            {
                obj.Seasons.Add(Season.Read(datReader));
            }

            return(obj);
        }
コード例 #13
0
ファイル: SetLightHook.cs プロジェクト: shawarma-golem/ACE
        public static SetLightHook ReadHookType(DatReader datReader)
        {
            SetLightHook hook = new SetLightHook();

            hook.LightsOn = datReader.ReadInt32();
            return(hook);
        }
コード例 #14
0
        public static DestroyParticleHook ReadHookType(DatReader datReader)
        {
            DestroyParticleHook dp = new DestroyParticleHook();

            dp.EmitterId = datReader.ReadUInt32();
            return(dp);
        }
コード例 #15
0
ファイル: AnimationFrame.cs プロジェクト: cydrith/ACE
        public static AnimationFrame Read(uint numParts, DatReader datReader)
        {
            AnimationFrame a = new AnimationFrame();

            for (uint i = 0; i < numParts; i++)
            {
                Position p = new Position();
                // Origin
                p.PositionX = datReader.ReadSingle();
                p.PositionY = datReader.ReadSingle();
                p.PositionZ = datReader.ReadSingle();
                p.RotationW = datReader.ReadSingle();
                p.RotationX = datReader.ReadSingle();
                p.RotationY = datReader.ReadSingle();
                p.RotationZ = datReader.ReadSingle();
                a.Locations.Add(p);
            }

            uint numHooks = datReader.ReadUInt32();

            for (uint i = 0; i < numHooks; i++)
            {
                a.Hooks.Add(AnimationHook.Read(datReader));
            }

            return(a);
        }
コード例 #16
0
ファイル: Surface.cs プロジェクト: shawarma-golem/ACE
        public static Surface ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((Surface)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                Surface   obj       = new Surface();

                obj.Type = (SurfaceType)datReader.ReadUInt32();

                if (((uint)obj.Type & 6) > 0)
                {
                    obj.OrigTextureId = datReader.ReadUInt32();
                    obj.OrigPaletteId = datReader.ReadUInt32();
                }
                else
                {
                    obj.ColorValue = datReader.ReadUInt32();
                }

                obj.Translucency = datReader.ReadSingle();
                obj.Luminosity   = datReader.ReadSingle();
                obj.Diffuse      = datReader.ReadSingle();

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = obj;

                return(obj);
            }
        }
コード例 #17
0
        public void TestDAT()
        {
            var layout = RowLayout.CreateTyped(typeof(TestStruct));
            var t1     = new TestStruct();

            t1.Init(TimeSpan.MinValue);
            var t2 = new TestStruct();

            t2.Init(TimeSpan.MaxValue);
            var t3 = new TestStruct();

            t3.Init(DateTime.Now.TimeOfDay);
            var ms = new MemoryStream();
            var w  = new DatWriter(layout, ms);

            w.Write(t1);
            w.Write(t2);
            w.Write(t3);
            w.Close();
            var ms2  = new MemoryStream(ms.ToArray());
            var r    = new DatReader(ms2);
            var list = r.ReadList <TestStruct>();

            Assert.AreEqual(3, list.Count);
            Assert.AreEqual(t1, list[0]);
            Assert.AreEqual(t2, list[1]);
            Assert.AreEqual(t3, list[2]);
        }
コード例 #18
0
ファイル: PaletteSet.cs プロジェクト: shawarma-golem/ACE
        public static PaletteSet ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((PaletteSet)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader  datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                PaletteSet p         = new PaletteSet();
                p.PaletteSetId = datReader.ReadUInt32();

                uint numpalettesets = datReader.ReadUInt32();
                for (int i = 0; i < numpalettesets; i++)
                {
                    p.PaletteList.Add(datReader.ReadUInt32());
                }

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = p;

                return(p);
            }
        }
コード例 #19
0
        public static NoDrawHook ReadHookType(DatReader datReader)
        {
            NoDrawHook nd = new NoDrawHook();

            nd.NoDraw = datReader.ReadUInt32();
            return(nd);
        }
コード例 #20
0
        public static MotionData Read(DatReader datReader)
        {
            MotionData md = new Entity.MotionData();

            byte numAnims = datReader.ReadByte();

            md.Bitfield  = datReader.ReadByte();
            md.Bitfield2 = datReader.ReadByte();
            datReader.AlignBoundary();

            for (byte i = 0; i < numAnims; i++)
            {
                AnimData animData = new AnimData();
                animData.AnimId    = datReader.ReadUInt32();
                animData.LowFrame  = datReader.ReadUInt32();
                animData.HighFrame = datReader.ReadUInt32();
                animData.Framerate = datReader.ReadSingle();
                md.Anims.Add(animData);
            }

            if ((md.Bitfield2 & 1) > 0)
            {
                md.Velocity = new AceVector3(datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle());
            }

            if ((md.Bitfield2 & 2) > 0)
            {
                md.Omega = new AceVector3(datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle());
            }

            return(md);
        }
コード例 #21
0
ファイル: FileList.cs プロジェクト: spazmodica/acrender
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="datReader">Data file for which the file list needs to
 /// be constructed.</param>
 public FileList(DatReader datReader)
 {
     Debug.Assert(datReader != null);
     m_sourceHash = datReader.GetFileNameHash();
     m_datReader  = datReader;
     m_fileGroups = new Dictionary <int, FileGroup>();
 }
コード例 #22
0
        public static Scene ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((Scene)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader datReader = DatManager.PortalDat.GetReaderForFile(fileId);

                Scene obj = new Scene();

                obj.SceneId = datReader.ReadUInt32();

                uint num_objects = datReader.ReadUInt32();
                for (uint i = 0; i < num_objects; i++)
                {
                    obj.Objects.Add(ObjectDesc.Read(datReader));
                }

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = obj;

                return(obj);
            }
        }
コード例 #23
0
        public static Environment ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((Environment)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader   datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                Environment obj       = new Environment();

                obj.Id = datReader.ReadUInt32(); // this will match fileId

                uint numCells = datReader.ReadUInt32();

                for (uint i = 0; i < numCells; i++)
                {
                    uint cellstuctId = datReader.ReadUInt32();
                    obj.Cells.Add(cellstuctId, CellStruct.Read(datReader));
                }

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = obj;

                return(obj);
            }
        }
コード例 #24
0
        public static PhysicsScriptTable ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((PhysicsScriptTable)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader          datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                PhysicsScriptTable obj       = new PhysicsScriptTable();
                obj.Id = datReader.ReadUInt32();

                uint script_table_length = datReader.ReadUInt32();
                for (uint i = 0; i < script_table_length; i++)
                {
                    uint key = datReader.ReadUInt32();
                    PhysicsScriptTableData value = PhysicsScriptTableData.Read(datReader);
                    obj.ScriptTable.Add(key, value);
                }

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = obj;

                return(obj);
            }
        }
コード例 #25
0
ファイル: Wave.cs プロジェクト: shawarma-golem/ACE
        public static Wave ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((Wave)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                Wave      obj       = new Wave();

                obj.Id = datReader.ReadUInt32();

                int headerSize = datReader.ReadInt32() - 2; // not sure why this is required, it just is.
                int dataSize   = datReader.ReadInt32();

                obj.Header = datReader.ReadBytes(headerSize);
                obj.Data   = datReader.ReadBytes(dataSize);

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[fileId] = obj;

                return(obj);
            }
        }
コード例 #26
0
ファイル: SetOmegaHook.cs プロジェクト: shawarma-golem/ACE
        public static SetOmegaHook ReadHookType(DatReader datReader)
        {
            SetOmegaHook so = new SetOmegaHook();

            so.Axis = new AceVector3(datReader.ReadSingle(), datReader.ReadSingle(), datReader.ReadSingle());
            return(so);
        }
コード例 #27
0
        public static SoundHook ReadHookType(DatReader datReader)
        {
            SoundHook s = new SoundHook();

            s.Id = datReader.ReadUInt32();
            return(s);
        }
コード例 #28
0
ファイル: XpTable.cs プロジェクト: leclaist/ACE
        public static XpTable ReadFromDat()
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(0x0E000018))
            {
                return((XpTable)DatManager.PortalDat.FileCache[0x0E000018]);
            }
            else
            {
                DatReader datReader = DatManager.PortalDat.GetReaderForFile(0x0E000018);
                XpTable   xp        = new XpTable();

                datReader.Offset += 4; // Skip the ID. We know what it is.

                // The counts for each "Table" are at the top of the file.
                int  abilityCount          = datReader.ReadInt32();
                int  vitalCount            = datReader.ReadInt32();
                int  trainedSkillCount     = datReader.ReadInt32();
                int  specializedSkillCount = datReader.ReadInt32();
                uint levelCount            = datReader.ReadUInt32();

                xp.AbilityXpChart          = ReadExperienceChart(abilityCount, ref datReader);
                xp.VitalXpChart            = ReadExperienceChart(vitalCount, ref datReader);
                xp.TrainedSkillXpChart     = ReadExperienceChart(trainedSkillCount, ref datReader);
                xp.SpecializedSkillXpChart = ReadExperienceChart(specializedSkillCount, ref datReader);

                // The level table is a little different since it has UInt64 data types.
                LevelingChart levelingXpChart = new LevelingChart();
                ulong         prevRank        = 0;
                datReader.Offset += 8; // skip level 0
                // Start from 1 because dat includes level 0.
                for (uint i = 1; i <= levelCount; i++)
                {
                    CharacterLevel characterLevel = new CharacterLevel();
                    characterLevel.Level             = i;
                    characterLevel.TotalXp           = datReader.ReadUInt64();
                    characterLevel.FromPreviousLevel = characterLevel.TotalXp - prevRank;
                    // Store this to use it in the next loop...
                    prevRank = characterLevel.TotalXp;
                    levelingXpChart.Levels.Add(characterLevel);
                }

                // The final section is skill credits... It has the same count as levels.
                int cumulativeSkillPoints = 0;
                datReader.Offset += 4; // skip level 0
                for (int i = 0; i < levelCount; i++)
                {
                    int skillPoint = datReader.ReadInt32();
                    cumulativeSkillPoints += skillPoint;
                    levelingXpChart.Levels[i].GrantsSkillPoint      = skillPoint == 1;
                    levelingXpChart.Levels[i].CumulativeSkillPoints = cumulativeSkillPoints;
                }

                xp.LevelingXpChart = levelingXpChart;

                // Store this object in the FileCache
                DatManager.PortalDat.FileCache[0x0E000018] = xp;
                return(xp);
            }
        }
コード例 #29
0
 static void ConvertDat(string path, string outBase = null)
 {
     if (outBase == null)
     {
         outBase = Path.GetDirectoryName(path);
     }
     Directory.CreateDirectory(outBase);
     using (Stream fs = Utils.CheckDecompress(File.OpenRead(path)))
         using (DatReader dat = new DatReader(fs))
         {
             for (int i = 0; i < dat.EntriesCount; ++i)
             {
                 using (MemoryStream subfile = new MemoryStream(dat.GetData(i)))
                 {
                     string outPath = Path.Combine(outBase, Path.GetFileName(path + $"_{i}.png"));
                     Console.WriteLine(outPath);
                     try
                     {
                         TxmConversion.ConvertTxmToPng(subfile, outPath);
                     }
                     catch (NotSupportedException)
                     {
                         File.WriteAllBytes(path + $"_{i}.txm", subfile.ToArray());
                         throw;
                     }
                 }
             }
         }
 }
コード例 #30
0
        /// <summary>
        /// Reads and returns just the X,Y,Z portal of a Position
        /// </summary>
        public static Position ReadPositionFrame(DatReader datReader)
        {
            Position p = new Position();

            p.ReadFrame(datReader);
            return(p);
        }