Esempio n. 1
0
        public static PhysicsScriptData Read(DatReader datReader)
        {
            PhysicsScriptData obj = new PhysicsScriptData();

            obj.StartTime = datReader.ReadDouble();
            obj.Hook      = AnimationHook.Read(datReader);

            return(obj);
        }
Esempio n. 2
0
        public static SpellTable ReadFromDat()
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(0x0E00000E))
            {
                return((SpellTable)DatManager.PortalDat.FileCache[0x0E00000E]);
            }
            else
            {
                // Create the datReader for the proper file
                DatReader  datReader = DatManager.PortalDat.GetReaderForFile(0x0E00000E);
                SpellTable spells    = new SpellTable();

                spells.FileId = datReader.ReadUInt32();
                uint spellCount = datReader.ReadUInt16();
                spells.SpellBaseHash = datReader.ReadUInt16();

                for (uint i = 0; i < spellCount; i++)
                {
                    SpellBase newSpell = new SpellBase();
                    uint      spellId  = datReader.ReadUInt32();
                    newSpell.Name = datReader.ReadObfuscatedString();
                    datReader.AlignBoundary();
                    newSpell.Desc = datReader.ReadObfuscatedString();
                    datReader.AlignBoundary();
                    newSpell.School            = (MagicSchool)datReader.ReadUInt32();
                    newSpell.Icon              = datReader.ReadUInt32();
                    newSpell.Category          = datReader.ReadUInt32();
                    newSpell.Bitfield          = datReader.ReadUInt32();
                    newSpell.BaseMana          = datReader.ReadUInt32();
                    newSpell.BaseRangeConstant = datReader.ReadSingle();
                    newSpell.BaseRangeMod      = datReader.ReadSingle();
                    newSpell.Power             = datReader.ReadUInt32();
                    newSpell.SpellEconomyMod   = datReader.ReadSingle();
                    newSpell.FormulaVersion    = datReader.ReadUInt32();
                    newSpell.ComponentLoss     = datReader.ReadUInt32();
                    newSpell.MetaSpellType     = (SpellType)datReader.ReadUInt32();
                    newSpell.MetaSpellId       = datReader.ReadUInt32();

                    switch (newSpell.MetaSpellType)
                    {
                    case SpellType.Enchantment:
                    case SpellType.FellowEnchantment:
                    {
                        newSpell.Duration        = datReader.ReadDouble();
                        newSpell.DegradeModifier = datReader.ReadSingle();
                        newSpell.DegradeLimit    = datReader.ReadSingle();
                        break;
                    }

                    case SpellType.PortalSummon:
                    {
                        newSpell.PortalLifetime = datReader.ReadDouble();
                        break;
                    }
                    }

                    // Components : Load them first, then decrypt them. More efficient to hash all at once.
                    List <uint> rawComps = new List <uint>();
                    for (uint j = 0; j < 8; j++)
                    {
                        uint comp = datReader.ReadUInt32();
                        // We will only add the comp if it is valid
                        if (comp > 0)
                        {
                            rawComps.Add(comp);
                        }
                    }
                    // Get the decryped component values
                    newSpell.Formula = DecryptFormula(rawComps, newSpell.Name, newSpell.Desc);

                    newSpell.CasterEffect           = datReader.ReadUInt32();
                    newSpell.TargetEffect           = datReader.ReadUInt32();
                    newSpell.FizzleEffect           = datReader.ReadUInt32();
                    newSpell.RecoveryInterval       = datReader.ReadDouble();
                    newSpell.RecoveryAmount         = datReader.ReadSingle();
                    newSpell.DisplayOrder           = datReader.ReadUInt32();
                    newSpell.NonComponentTargetType = datReader.ReadUInt32();
                    newSpell.ManaMod = datReader.ReadUInt32();

                    spells.Spells.Add(spellId, newSpell);
                }

                DatManager.PortalDat.FileCache[0x0E00000E] = spells;
                return(spells);
            }
        }
Esempio n. 3
0
        public static ParticleEmitterInfo ReadFromDat(uint fileId)
        {
            // Check the FileCache so we don't need to hit the FileSystem repeatedly
            if (DatManager.PortalDat.FileCache.ContainsKey(fileId))
            {
                return((ParticleEmitterInfo)DatManager.PortalDat.FileCache[fileId]);
            }
            else
            {
                DatReader           datReader = DatManager.PortalDat.GetReaderForFile(fileId);
                ParticleEmitterInfo obj       = new ParticleEmitterInfo();

                obj.Id = datReader.ReadUInt32();

                uint unknown = datReader.ReadUInt32();

                obj.EmitterType  = (EmitterType)datReader.ReadInt32();
                obj.ParticleType = (ParticleType)datReader.ReadInt32();

                obj.GfxObjId   = datReader.ReadUInt32();
                obj.HwGfxObjId = datReader.ReadUInt32();

                obj.Birthrate = datReader.ReadDouble();

                obj.MaxParticles     = datReader.ReadInt32();
                obj.InitialParticles = datReader.ReadInt32();
                obj.TotalParticles   = datReader.ReadInt32();

                obj.TotalSeconds = datReader.ReadDouble();
                obj.LifespanRand = datReader.ReadDouble();
                obj.Lifespan     = datReader.ReadDouble();

                obj.SortingSphere = datReader.ReadUInt32();

                obj.OffsetDir = PositionExtensions.ReadPositionFrame(datReader);
                obj.MinOffset = datReader.ReadSingle();
                obj.MaxOffset = datReader.ReadSingle();

                obj.A = PositionExtensions.ReadPositionFrame(datReader);
                obj.B = PositionExtensions.ReadPositionFrame(datReader);
                obj.C = PositionExtensions.ReadPositionFrame(datReader);

                obj.MinA = datReader.ReadSingle();
                obj.MaxA = datReader.ReadSingle();
                obj.MinB = datReader.ReadSingle();
                obj.MaxB = datReader.ReadSingle();
                obj.MinC = datReader.ReadSingle();
                obj.MaxC = datReader.ReadSingle();

                obj.ScaleRand  = datReader.ReadSingle();
                obj.StartScale = datReader.ReadSingle();
                obj.FinalScale = datReader.ReadSingle();
                obj.TransRand  = datReader.ReadSingle();
                obj.StartTrans = datReader.ReadSingle();
                obj.FinalTrans = datReader.ReadSingle();

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

                return(obj);
            }
        }