protected override void WriteData(ESPWriter writer)
 {
     writer.Write((UInt32)MagicEffectFlags);
     writer.Write(BaseCost);
     AssociatedItem.WriteBinary(writer);
     writer.Write((Int32)MagicSchool);
     writer.Write((Int32)ResistanceType);
     writer.Write(Unknown);
     if (Unused == null)
     {
         writer.Write(new byte[2]);
     }
     else
     {
         writer.Write(Unused);
     }
     Light.WriteBinary(writer);
     writer.Write(ProjectileSpeed);
     EffectShader.WriteBinary(writer);
     ObjectDisplayShader.WriteBinary(writer);
     EffectSound.WriteBinary(writer);
     BoltSound.WriteBinary(writer);
     HitSound.WriteBinary(writer);
     AreaSound.WriteBinary(writer);
     writer.Write(ConstantEffectEnchantmentFactor);
     writer.Write(ConstantEffectBarterFactor);
     writer.Write((UInt32)Archetype);
     writer.Write((Int32)ActorValue);
 }
        protected override void WriteDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            ele.TryPathTo("Flags", true, out subEle);
            subEle.Value = MagicEffectFlags.ToString();

            ele.TryPathTo("BaseCost", true, out subEle);
            subEle.Value = BaseCost.ToString("G15");

            ele.TryPathTo("AssociatedItem", true, out subEle);
            AssociatedItem.WriteXML(subEle, master);

            ele.TryPathTo("MagicSchool", true, out subEle);
            subEle.Value = MagicSchool.ToString();

            ele.TryPathTo("ResistanceType", true, out subEle);
            subEle.Value = ResistanceType.ToString();

            ele.TryPathTo("Unknown", true, out subEle);
            subEle.Value = Unknown.ToString();

            WriteUnusedXML(ele, master);

            ele.TryPathTo("Light", true, out subEle);
            Light.WriteXML(subEle, master);

            ele.TryPathTo("ProjectileSpeed", true, out subEle);
            subEle.Value = ProjectileSpeed.ToString("G15");

            ele.TryPathTo("EffectShader", true, out subEle);
            EffectShader.WriteXML(subEle, master);

            ele.TryPathTo("ObjectDisplayShader", true, out subEle);
            ObjectDisplayShader.WriteXML(subEle, master);

            ele.TryPathTo("EffectSound", true, out subEle);
            EffectSound.WriteXML(subEle, master);

            ele.TryPathTo("BoltSound", true, out subEle);
            BoltSound.WriteXML(subEle, master);

            ele.TryPathTo("HitSound", true, out subEle);
            HitSound.WriteXML(subEle, master);

            ele.TryPathTo("AreaSound", true, out subEle);
            AreaSound.WriteXML(subEle, master);

            ele.TryPathTo("ConstantEffectEnchantmentFactor", true, out subEle);
            subEle.Value = ConstantEffectEnchantmentFactor.ToString("G15");

            ele.TryPathTo("ConstantEffectBarterFactor", true, out subEle);
            subEle.Value = ConstantEffectBarterFactor.ToString("G15");

            ele.TryPathTo("Archetype", true, out subEle);
            subEle.Value = Archetype.ToString();

            ele.TryPathTo("ActorValue", true, out subEle);
            subEle.Value = ActorValue.ToString();
        }
 protected override void ReadData(ESPReader reader)
 {
     using (MemoryStream stream = new MemoryStream(reader.ReadBytes(size)))
         using (ESPReader subReader = new ESPReader(stream, reader.Plugin))
         {
             try
             {
                 MagicEffectFlags = subReader.ReadEnum <MagicEffectFlags>();
                 BaseCost         = subReader.ReadSingle();
                 AssociatedItem.ReadBinary(subReader);
                 MagicSchool    = subReader.ReadEnum <MagicSchool>();
                 ResistanceType = subReader.ReadEnum <ActorValues>();
                 Unknown        = subReader.ReadUInt16();
                 Unused         = subReader.ReadBytes(2);
                 Light.ReadBinary(subReader);
                 ProjectileSpeed = subReader.ReadSingle();
                 EffectShader.ReadBinary(subReader);
                 ObjectDisplayShader.ReadBinary(subReader);
                 EffectSound.ReadBinary(subReader);
                 BoltSound.ReadBinary(subReader);
                 HitSound.ReadBinary(subReader);
                 AreaSound.ReadBinary(subReader);
                 ConstantEffectEnchantmentFactor = subReader.ReadSingle();
                 ConstantEffectBarterFactor      = subReader.ReadSingle();
                 Archetype  = subReader.ReadEnum <MagicEffectArchetype>();
                 ActorValue = subReader.ReadEnum <ActorValues>();
             }
             catch
             {
                 return;
             }
         }
 }
Exemplo n.º 4
0
        public static Record CreateRecord(string Tag)
        {
            Record outRecord;

            switch (Tag)
            {
            case "TES4":
                outRecord = new Header();
                break;

            case "GMST":
                outRecord = new GameSetting();
                break;

            case "TXST":
                outRecord = new TextureSet();
                break;

            case "MICN":
                outRecord = new MenuIcon();
                break;

            case "GLOB":
                outRecord = new GlobalVariable();
                break;

            case "CLAS":
                outRecord = new Class();
                break;

            case "FACT":
                outRecord = new Faction();
                break;

            case "HDPT":
                outRecord = new HeadPart();
                break;

            case "HAIR":
                outRecord = new Hair();
                break;

            case "EYES":
                outRecord = new Eyes();
                break;

            case "RACE":
                outRecord = new Race();
                break;

            case "SOUN":
                outRecord = new Sound();
                break;

            case "ASPC":
                outRecord = new AcousticSpace();
                break;

            case "MGEF":
                outRecord = new MagicEffect();
                break;

            case "SCPT":
                outRecord = new Script();
                break;

            case "LTEX":
                outRecord = new LandscapeTexture();
                break;

            case "ENCH":
                outRecord = new ObjectEffect();
                break;

            case "SPEL":
                outRecord = new ActorEffect();
                break;

            case "ACTI":
                outRecord = new ESPSharp.Records.Activator();
                break;

            case "TACT":
                outRecord = new TalkingActivator();
                break;

            case "TERM":
                outRecord = new Terminal();
                break;

            case "ARMO":
                outRecord = new Armor();
                break;

            case "BOOK":
                outRecord = new Book();
                break;

            case "CONT":
                outRecord = new Container();
                break;

            case "DOOR":
                outRecord = new Door();
                break;

            case "INGR":
                outRecord = new Ingredient();
                break;

            case "LIGH":
                outRecord = new Light();
                break;

            case "MISC":
                outRecord = new MiscItem();
                break;

            case "STAT":
                outRecord = new Static();
                break;

            case "SCOL":
                outRecord = new StaticCollection();
                break;

            case "MSTT":
                outRecord = new MoveableStatic();
                break;

            case "PWAT":
                outRecord = new PlaceableWater();
                break;

            case "GRAS":
                outRecord = new Grass();
                break;

            case "TREE":
                outRecord = new Tree();
                break;

            case "FURN":
                outRecord = new Furniture();
                break;

            case "WEAP":
                outRecord = new Weapon();
                break;

            case "AMMO":
                outRecord = new Ammunition();
                break;

            case "NPC_":
                outRecord = new NonPlayerCharacter();
                break;

            case "CREA":
                outRecord = new Creature();
                break;

            case "LVLC":
                outRecord = new LeveledCreature();
                break;

            case "LVLN":
                outRecord = new LeveledNPC();
                break;

            case "KEYM":
                outRecord = new Key();
                break;

            case "ALCH":
                outRecord = new Ingestible();
                break;

            case "IDLM":
                outRecord = new IdleMarker();
                break;

            case "NOTE":
                outRecord = new Note();
                break;

            case "COBJ":
                outRecord = new ConstructibleObject();
                break;

            case "PROJ":
                outRecord = new Projectile();
                break;

            case "LVLI":
                outRecord = new LeveledItem();
                break;

            case "WTHR":
                outRecord = new Weather();
                break;

            case "CLMT":
                outRecord = new Climate();
                break;

            case "REGN":
                outRecord = new Region();
                break;

            case "NAVI":
                outRecord = new NavigationMeshInfoMap();
                break;

            case "DIAL":
                outRecord = new DialogTopic();
                break;

            case "QUST":
                outRecord = new Quest();
                break;

            case "IDLE":
                outRecord = new IdleAnimation();
                break;

            case "PACK":
                outRecord = new Package();
                break;

            case "CSTY":
                outRecord = new CombatStyle();
                break;

            case "LSCR":
                outRecord = new LoadScreen();
                break;

            case "ANIO":
                outRecord = new AnimatedObject();
                break;

            case "WATR":
                outRecord = new Water();
                break;

            case "EFSH":
                outRecord = new EffectShader();
                break;

            case "EXPL":
                outRecord = new Explosion();
                break;

            case "DEBR":
                outRecord = new Debris();
                break;

            case "IMGS":
                outRecord = new ImageSpace();
                break;

            case "IMAD":
                outRecord = new ImageSpaceAdapter();
                break;

            case "FLST":
                outRecord = new FormList();
                break;

            case "PERK":
                outRecord = new Perk();
                break;

            case "BPTD":
                outRecord = new BodyPartData();
                break;

            case "ADDN":
                outRecord = new AddonNode();
                break;

            case "AVIF":
                outRecord = new ActorValueInformation();
                break;

            case "RADS":
                outRecord = new RadiationStage();
                break;

            case "CAMS":
                outRecord = new CameraShot();
                break;

            case "CPTH":
                outRecord = new CameraPath();
                break;

            case "VTYP":
                outRecord = new VoiceType();
                break;

            case "IPCT":
                outRecord = new Impact();
                break;

            case "IPDS":
                outRecord = new ImpactDataSet();
                break;

            case "ARMA":
                outRecord = new ArmorAddon();
                break;

            case "ECZN":
                outRecord = new EncounterZone();
                break;

            case "MESG":
                outRecord = new Message();
                break;

            case "RGDL":
                outRecord = new Ragdoll();
                break;

            case "DOBJ":
                outRecord = new DefaultObjectManager();
                break;

            case "LGTM":
                outRecord = new LightingTemplate();
                break;

            case "MUSC":
                outRecord = new MusicType();
                break;

            case "IMOD":
                outRecord = new ItemMod();
                break;

            case "REPU":
                outRecord = new Reputation();
                break;

            case "RCPE":
                outRecord = new Recipe();
                break;

            case "RCCT":
                outRecord = new RecipeCategory();
                break;

            case "CHIP":
                outRecord = new CasinoChip();
                break;

            case "CSNO":
                outRecord = new Casino();
                break;

            case "LSCT":
                outRecord = new LoadScreenType();
                break;

            case "MSET":
                outRecord = new MediaSet();
                break;

            case "ALOC":
                outRecord = new MediaLocationController();
                break;

            case "CHAL":
                outRecord = new Challenge();
                break;

            case "AMEF":
                outRecord = new AmmoEffect();
                break;

            case "CCRD":
                outRecord = new CaravanCard();
                break;

            case "CMNY":
                outRecord = new CaravanMoney();
                break;

            case "CDCK":
                outRecord = new CaravanDeck();
                break;

            case "DEHY":
                outRecord = new DehydrationStage();
                break;

            case "HUNG":
                outRecord = new HungerStage();
                break;

            case "SLPD":
                outRecord = new SleepDeprivationStage();
                break;

            case "CELL":
                outRecord = new Cell();
                break;

            case "WRLD":
                outRecord = new Worldspace();
                break;

            case "LAND":
                outRecord = new GenericRecord();
                break;

            case "NAVM":
                outRecord = new NavigationMesh();
                break;

            case "INFO":
                outRecord = new DialogResponse();
                break;

            case "REFR":
                outRecord = new Reference();
                break;

            case "ACHR":
                outRecord = new PlacedNPC();
                break;

            case "ACRE":
                outRecord = new PlacedCreature();
                break;

            case "PGRE":
                outRecord = new PlacedGrenade();
                break;

            case "PMIS":
                outRecord = new PlacedMissile();
                break;

            default:
                Console.WriteLine("Encountered unknown record: " + Tag);
                outRecord = new GenericRecord();
                break;
            }

            outRecord.Tag = Tag;

            return(outRecord);
        }
        protected override void ReadDataXML(XElement ele, ElderScrollsPlugin master)
        {
            XElement subEle;

            if (ele.TryPathTo("Flags", false, out subEle))
            {
                MagicEffectFlags = subEle.ToEnum <MagicEffectFlags>();
            }

            if (ele.TryPathTo("BaseCost", false, out subEle))
            {
                BaseCost = subEle.ToSingle();
            }

            if (ele.TryPathTo("AssociatedItem", false, out subEle))
            {
                AssociatedItem.ReadXML(subEle, master);
            }

            if (ele.TryPathTo("MagicSchool", false, out subEle))
            {
                MagicSchool = subEle.ToEnum <MagicSchool>();
            }

            if (ele.TryPathTo("ResistanceType", false, out subEle))
            {
                ResistanceType = subEle.ToEnum <ActorValues>();
            }

            if (ele.TryPathTo("Unknown", false, out subEle))
            {
                Unknown = subEle.ToUInt16();
            }

            ReadUnusedXML(ele, master);

            if (ele.TryPathTo("Light", false, out subEle))
            {
                Light.ReadXML(subEle, master);
            }

            if (ele.TryPathTo("ProjectileSpeed", false, out subEle))
            {
                ProjectileSpeed = subEle.ToSingle();
            }

            if (ele.TryPathTo("EffectShader", false, out subEle))
            {
                EffectShader.ReadXML(subEle, master);
            }

            if (ele.TryPathTo("ObjectDisplayShader", false, out subEle))
            {
                ObjectDisplayShader.ReadXML(subEle, master);
            }

            if (ele.TryPathTo("EffectSound", false, out subEle))
            {
                EffectSound.ReadXML(subEle, master);
            }

            if (ele.TryPathTo("BoltSound", false, out subEle))
            {
                BoltSound.ReadXML(subEle, master);
            }

            if (ele.TryPathTo("HitSound", false, out subEle))
            {
                HitSound.ReadXML(subEle, master);
            }

            if (ele.TryPathTo("AreaSound", false, out subEle))
            {
                AreaSound.ReadXML(subEle, master);
            }

            if (ele.TryPathTo("ConstantEffectEnchantmentFactor", false, out subEle))
            {
                ConstantEffectEnchantmentFactor = subEle.ToSingle();
            }

            if (ele.TryPathTo("ConstantEffectBarterFactor", false, out subEle))
            {
                ConstantEffectBarterFactor = subEle.ToSingle();
            }

            if (ele.TryPathTo("Archetype", false, out subEle))
            {
                Archetype = subEle.ToEnum <MagicEffectArchetype>();
            }

            if (ele.TryPathTo("ActorValue", false, out subEle))
            {
                ActorValue = subEle.ToEnum <ActorValues>();
            }
        }