public ObjectDesc(ushort type, XElement elem)
        {
            XElement n;

            ObjectType              = type;
            ObjectId                = elem.Attribute("id").Value;
            Class                   = elem.Element("Class").Value;
            Group                   = (n = elem.Element("Group")) != null ? n.Value : null;
            DisplayId               = (n = elem.Element("DisplayId")) != null ? n.Value : null;
            DungeonName             = (n = elem.Element("DungeonName")) != null ? n.Value : DisplayId;
            Character               = Class.Equals("Character");
            Player                  = elem.Element("Player") != null;
            Enemy                   = elem.Element("Enemy") != null;
            OccupySquare            = elem.Element("OccupySquare") != null;
            FullOccupy              = elem.Element("FullOccupy") != null;
            EnemyOccupySquare       = elem.Element("EnemyOccupySquare") != null;
            Static                  = elem.Element("Static") != null;
            BlocksSight             = elem.Element("BlocksSight") != null;
            NoMiniMap               = elem.Element("NoMiniMap") != null;
            ProtectFromGroundDamage = elem.Element("ProtectFromGroundDamage") != null;
            ProtectFromSink         = elem.Element("ProtectFromSink") != null;
            Flying                  = elem.Element("Flying") != null;
            ShowName                = elem.Element("ShowName") != null;
            DontFaceAttacks         = elem.Element("DontFaceAttacks") != null;

            if (elem.Element("Restricted") != null)
            {
                Restricted = true;
            }

            if ((n = elem.Element("Size")) != null)
            {
                MinSize  = MaxSize = Utils.FromString(n.Value);
                SizeStep = 0;
            }
            else
            {
                MinSize = (n = elem.Element("MinSize")) != null?
                          Utils.FromString(n.Value) : 100;

                MaxSize = (n = elem.Element("MaxSize")) != null?
                          Utils.FromString(n.Value) : 100;

                SizeStep = (n = elem.Element("SizeStep")) != null?
                           Utils.FromString(n.Value) : 0;
            }

            Projectiles = elem.Elements("Projectile")
                          .Select(i => new ProjectileDesc(i)).ToArray();

            if ((n = elem.Element("MaxHitPoints")) != null)
            {
                MaxHP = Utils.FromString(n.Value);
            }
            if ((n = elem.Element("Defense")) != null)
            {
                Defense = Utils.FromString(n.Value);
            }
            if ((n = elem.Element("Terrain")) != null)
            {
                Terrain = n.Value;
            }
            if ((n = elem.Element("SpawnProbability")) != null)
            {
                SpawnProbability = float.Parse(n.Value);
            }
            if ((n = elem.Element("Spawn")) != null)
            {
                Spawn = new SpawnCount(n);
            }

            God   = elem.Element("God") != null;
            Cube  = elem.Element("Cube") != null;
            Quest = elem.Element("Quest") != null;
            if ((n = elem.Element("Level")) != null)
            {
                Level = Utils.FromString(n.Value);
            }
            else
            {
                Level = null;
            }

            Tags = new TagList();
            if (elem.Elements("Tag").Any())
            {
                foreach (XElement i in elem.Elements("Tag"))
                {
                    Tags.Add(new Tag(i));
                }
            }

            ArmorBreakImmune = elem.Element("ArmorBreakImmune") != null;
            CurseImmune      = elem.Element("CurseImmune") != null;
            DazedImmune      = elem.Element("DazedImmune") != null;
            ParalyzeImmune   = elem.Element("ParalyzeImmune") != null;
            PetrifyImmune    = elem.Element("PetrifyImmune") != null;
            SlowedImmune     = elem.Element("SlowedImmune") != null;
            StasisImmune     = elem.Element("StasisImmune") != null;
            StunImmune       = elem.Element("StunImmune") != null;

            Oryx = elem.Element("Oryx") != null;
            Hero = elem.Element("Hero") != null;

            if ((n = elem.Element("PerRealmMax")) != null)
            {
                PerRealmMax = Utils.FromString(n.Value);
            }
            else
            {
                PerRealmMax = null;
            }
            if ((n = elem.Element("XpMult")) != null)
            {
                ExpMultiplier = float.Parse(n.Value);
            }
            else
            {
                ExpMultiplier = null;
            }

            IsPet           = elem.Element("Pet") != null;
            IsPetSkin       = elem.Element("PetSkin") != null;
            IsPetProjectile = elem.Element("PetProjectile") != null;
            IsPetBehavior   = elem.Element("PetBehavior") != null;
            IsPetAbility    = elem.Element("PetAbility") != null;
            Connects        = elem.Element("Connects") != null;
            TrollWhiteBag   = elem.Element("TrollWhiteBag") != null;
        }
示例#2
0
        public ObjectDesc(ushort type, XElement e)
        {
            ObjectType        = type;
            ObjectId          = e.GetAttribute <string>("id");
            DisplayId         = e.GetValue <string>("DisplayId");
            DisplayName       = string.IsNullOrWhiteSpace(DisplayId) ? ObjectId : DisplayId;
            Class             = e.GetValue <string>("Class");
            Static            = e.HasElement("Static");
            OccupySquare      = e.HasElement("OccupySquare");
            FullOccupy        = e.HasElement("FullOccupy");
            EnemyOccupySquare = e.HasElement("EnemyOccupySquare");
            BlocksSight       = e.HasElement("BlocksSight");
            Container         = e.HasElement("Container");
            if (e.HasElement("SlotTypes"))
            {
                SlotTypes = e.GetValue <string>("SlotTypes").CommaToArray <int>();
            }
            CanPutNormalObjects    = e.HasElement("CanPutNormalObjects");
            CanPutSoulboundObjects = e.HasElement("CanPutSoulboundObjects");
            Loot          = e.HasElement("Loot");
            Size          = e.GetValue <int>("Size", 100);
            Enemy         = e.HasElement("Enemy");
            MaxHP         = e.GetValue <int>("MaxHitPoints");
            Defense       = e.GetValue <int>("Defense");
            ExpMultiplier = e.GetValue <float>("XpMult", 1.0f);
            if (e.HasElement("MinSize") && e.HasElement("MaxSize"))
            {
                MinSize  = e.GetValue <int>("MinSize");
                MaxSize  = e.GetValue <int>("MaxSize");
                SizeStep = e.GetValue <int>("SizeStep", 1);
            }
            else
            {
                MinSize  = MaxSize = Size;
                SizeStep = 0;
            }
            Character    = Class.Equals("Character");
            SpawnPoint   = e.HasElement("SpawnPoint");
            Group        = e.GetValue <string>("Group");
            Quest        = e.HasElement("Quest");
            Level        = e.GetValue <int>("Level");
            God          = e.HasElement("God");
            NoArticle    = e.HasElement("NoArticle");
            StasisImmune = e.HasElement("StasisImmune");
            StunImmune   = e.HasElement("StunImmune");
            SpawnProb    = e.GetValue <float>("SpawnProb");
            if (e.HasElement("Spawn"))
            {
                Spawn = new SpawnCount(e.Element("Spawn"));
            }
            Terrain                 = (TerrainType)Enum.Parse(typeof(TerrainType), e.GetValue <string>("Terrain", "None"));
            Encounter               = e.HasElement("Encounter");
            PerRealmMax             = e.GetValue <int>("PerRealmMax");
            Hero                    = e.HasElement("Hero");
            Cube                    = e.HasElement("Cube");
            Oryx                    = e.HasElement("Oryx");
            Player                  = e.HasElement("Player");
            KeepDamageRecord        = e.HasElement("KeepDamageRecord");
            Connects                = e.HasElement("Connects");
            ProtectFromGroundDamage = e.HasElement("ProtectFromGroundDamage");
            ProtectFromSink         = e.HasElement("ProtectFromSink");

            var projs = new List <ProjectileDesc>();

            foreach (var i in e.Elements("Projectile"))
            {
                projs.Add(new ProjectileDesc(i));
            }
            Projectiles = projs.ToArray();
        }