//Copy code from SceneObjectSerializer.ProcessColor
        public static System.Drawing.Color DeSerializeColor(string colorString)
        {
            StringReader sr = new StringReader(colorString);
            XmlTextReader reader = new XmlTextReader(sr);

            System.Drawing.Color color = new System.Drawing.Color();

            reader.ReadStartElement("Color");
            if (reader.Name == "R")
            {
                float r = reader.ReadElementContentAsFloat("R", String.Empty);
                float g = reader.ReadElementContentAsFloat("G", String.Empty);
                float b = reader.ReadElementContentAsFloat("B", String.Empty);
                float a = reader.ReadElementContentAsFloat("A", String.Empty);
                color = System.Drawing.Color.FromArgb((int)a, (int)r, (int)g, (int)b);
                reader.ReadEndElement();
            }
            return color;
        }
Esempio n. 2
0
        /// <summary>
        /// Gets the location of the IP address.
        /// </summary>
        /// <param name="ip">The ip.</param>
        /// <returns></returns>
        public static GeolocateResult getLocation(IPAddress ip)
        {
            Stream s = HttpRequest.get("http://api.ipinfodb.com/v2/ip_query.php?key=" + Configuration.singleton()["ipinfodbApiKey"] + "&ip=" + ip + "&timezone=false");
            XmlTextReader xtr = new XmlTextReader(s);
            GeolocateResult result = new GeolocateResult();

            while (!xtr.EOF)
            {
                xtr.Read();
                switch (xtr.Name)
                {
                    case "Status":
                        result.status = xtr.ReadElementContentAsString();
                        break;
                    case "CountryCode":
                        result.countryCode = xtr.ReadElementContentAsString();
                        break;
                    case "CountryName":
                        result.country = xtr.ReadElementContentAsString();
                        break;
                    case "RegionCode":
                        result.regionCode = xtr.ReadElementContentAsString();
                        break;
                    case "RegionName":
                        result.region = xtr.ReadElementContentAsString();
                        break;
                    case "City":
                        result.city = xtr.ReadElementContentAsString();
                        break;
                    case "ZipPostalCode":
                        result.zipPostalCode = xtr.ReadElementContentAsString();
                        break;
                    case "Latitude":
                        result.latitude = xtr.ReadElementContentAsFloat();
                        break;
                    case "Longitude":
                        result.longitude = xtr.ReadElementContentAsFloat();
                        break;
                }
            }
            return result;
        }
Esempio n. 3
0
 public static void ReadGrandSlamAbility(ref XmlTextReader reader)
 {
     while (reader.Read())
     {
         if (reader.NodeType == XmlNodeType.Element)
         {
             if (reader.Name == XMLPropNames.strRadius)
                 mGrandSlamRadius = reader.ReadElementContentAsFloat();
             else if (reader.Name == XMLPropNames.strDamage)
                 mGrandSlamDamage = reader.ReadElementContentAsInt();
             else if (reader.Name == XMLPropNames.strStunDuration)
                 mGrandSlamStunDuration = reader.ReadElementContentAsInt();
             else if (reader.Name == XMLPropNames.strKnockBackSpeed)
                 mGrandSlamKnockBackSpeed = reader.ReadElementContentAsFloat();
         }
         else if (reader.NodeType == XmlNodeType.EndElement &&
                  reader.Name == XMLPropNames.strAbility)
             break;
     }
 }
Esempio n. 4
0
        public static void LoadBounty()
        {
            var multTable = new float[100];
            var getting = false;

            using (var reader = new XmlTextReader("formula.xml"))
            {
                while (reader.Read())
                {
                    switch (reader.Name)
                    {
                        case "LM":
                            if (!getting)
                                break;

                            var low = int.Parse(reader.GetAttribute("lower"));
                            var high = int.Parse(reader.GetAttribute("upper"));
                            var value = reader.ReadElementContentAsFloat();

                            for (; low <= high; low++)
                                multTable[low] = value;
                            break;

                        case "FORMULA_TABLE":
                            if (reader.GetAttribute("id") == "GettingExpLM")
                                getting = true;
                            else if (reader.GetAttribute("id") == "GettingBountyLM")
                                reader.Close();
                            break;
                    }
                }
            }

            for (var i = 1; i < 100; ++i)
            {
                var exp = (UInt32)((i * multTable[i] * 20.0f + .5));
                GettingExpTable[i] = exp + Convert.ToUInt32((i - 1) * multTable[i] * 10.0 + 0.5f);
            }
        }
Esempio n. 5
0
 public static void ReadSuperKnockBackAbility(ref XmlTextReader reader)
 {
     while (reader.Read())
     {
         if (reader.Name == XMLPropNames.strSpeed)
             mSuperKnockBackSpeed = reader.ReadElementContentAsFloat();
         else if (reader.Name == XMLPropNames.strDamage)
             mSuperKnockBackDamage = reader.ReadElementContentAsInt();
         else if (reader.NodeType == XmlNodeType.EndElement &&
                  reader.Name == XMLPropNames.strAbility)
             break;
     }
 }
Esempio n. 6
0
 private static void ProcessCollisionSoundVolume(SceneObjectPart obj, XmlTextReader reader)
 {
     obj.CollisionSoundVolume = reader.ReadElementContentAsFloat("CollisionSoundVolume", String.Empty);
 }
Esempio n. 7
0
 private static void ProcessShpLightIntensity(PrimitiveBaseShape shp, XmlTextReader reader)
 {
     shp.LightIntensity = reader.ReadElementContentAsFloat("LightIntensity", String.Empty);
 }
        static Quaternion ReadQuaternion(XmlTextReader reader, string name)
        {
            Quaternion quat = new Quaternion();

            reader.ReadStartElement(name);
            while (reader.NodeType != XmlNodeType.EndElement)
            {
                switch (reader.Name.ToLower())
                {
                    case "x":
                        quat.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
                        break;
                    case "y":
                        quat.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
                        break;
                    case "z":
                        quat.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
                        break;
                    case "w":
                        quat.W = reader.ReadElementContentAsFloat(reader.Name, String.Empty);
                        break;
                }
            }

            reader.ReadEndElement();

            return quat;
        }
 private static void ProcessGravityModifier(SceneObjectPart obj, XmlTextReader reader)
 {
     obj.GravityModifier = reader.ReadElementContentAsFloat("GravityModifier", String.Empty);
 }
 private static void ProcessFriction(SceneObjectPart obj, XmlTextReader reader)
 {
     obj.Friction = reader.ReadElementContentAsFloat("Friction", String.Empty);
 }
 private void ProcessShpLightFalloff(PrimitiveBaseShape shp, XmlTextReader reader)
 {
     shp.LightFalloff = reader.ReadElementContentAsFloat("LightFalloff", String.Empty);
 }
Esempio n. 12
0
        internal override void ReadXml(XmlTextReader reader)
        {
            while (reader.Read())
            {
                // End of invoice element, get out of here
                if (reader.Name == "usage" && reader.NodeType == XmlNodeType.EndElement)
                    break;

                if (reader.NodeType != XmlNodeType.Element) continue;

                DateTime dateVal;

                switch (reader.Name)
                {
                    case "amount":
                        Amount = reader.ReadElementContentAsInt();
                        break;

                    case "unit_amount_in_cents":
                        UnitAmountInCents = reader.ReadElementContentAsInt();
                        break;

                    case "merchant_tag":
                        MerchantTag = reader.ReadElementContentAsString();
                        break;

                    case "usage_percentage":
                        if (reader.GetAttribute("nil") == null)
                        {
                            UsagePercentage = reader.ReadElementContentAsFloat();
                        }
                        break;

                    case "recording_timestamp":
                        if (DateTime.TryParse(reader.ReadElementContentAsString(), out dateVal))
                            RecordingTimestamp = dateVal;
                        break;

                    case "usage_timestamp":
                        if (DateTime.TryParse(reader.ReadElementContentAsString(), out dateVal))
                            UsageTimestamp = dateVal;
                        break;

                    case "billed_at":
                        if (DateTime.TryParse(reader.ReadElementContentAsString(), out dateVal))
                            BilledAt = dateVal;
                        break;

                    case "created_at":
                        if (DateTime.TryParse(reader.ReadElementContentAsString(), out dateVal))
                            CreatedAt = dateVal;
                        break;

                    case "updated_at":
                        if (DateTime.TryParse(reader.ReadElementContentAsString(), out dateVal))
                            UpdatedAt = dateVal;
                        break;
                }
            }
        }
Esempio n. 13
0
        public static PrimObject LoadPrim(XmlTextReader reader)
        {
            PrimObject obj = new PrimObject();
            obj.Shape = new PrimObject.ShapeBlock();
            obj.Inventory = new PrimObject.InventoryBlock();

            reader.ReadStartElement("SceneObjectPart");
            obj.CreatorIdentity = ReadUUID(reader, "CreatorID").ToString();
            //warning CS0219: The variable `folderID' is assigned but its value is never used
            //UUID folderID = ReadUUID(reader, "FolderID");
            obj.Inventory.Serial = reader.ReadElementContentAsInt("InventorySerial", String.Empty);
            
            // FIXME: Parse TaskInventory
            obj.Inventory.Items = new PrimObject.InventoryBlock.ItemBlock[0];
            reader.ReadInnerXml();

            PrimFlags flags = (PrimFlags)reader.ReadElementContentAsInt("ObjectFlags", String.Empty);
            obj.UsePhysics = (flags & PrimFlags.Physics) != 0;
            obj.Phantom = (flags & PrimFlags.Phantom) != 0;
            obj.DieAtEdge = (flags & PrimFlags.DieAtEdge) != 0;
            obj.ReturnAtEdge = (flags & PrimFlags.ReturnAtEdge) != 0;
            obj.Temporary = (flags & PrimFlags.Temporary) != 0;
            obj.Sandbox = (flags & PrimFlags.Sandbox) != 0;

            obj.ID = ReadUUID(reader, "UUID");
            obj.LocalID = (uint)reader.ReadElementContentAsLong("LocalId", String.Empty);
            obj.Name = reader.ReadElementString("Name");
            obj.Material = reader.ReadElementContentAsInt("Material", String.Empty);
            
            reader.ReadInnerXml(); // RegionHandle

            obj.RemoteScriptAccessPIN = reader.ReadElementContentAsInt("ScriptAccessPin", String.Empty);

            Vector3 groupPosition = ReadVector(reader, "GroupPosition");
            Vector3 offsetPosition = ReadVector(reader, "OffsetPosition");
            obj.Rotation = ReadQuaternion(reader, "RotationOffset");
            obj.Velocity = ReadVector(reader, "Velocity");
            //warning CS0219: The variable `rotationalVelocity' is assigned but its value is never used
            //Vector3 rotationalVelocity = ReadVector(reader, "RotationalVelocity");
            obj.AngularVelocity = ReadVector(reader, "AngularVelocity");
            obj.Acceleration = ReadVector(reader, "Acceleration");
            obj.Description = reader.ReadElementString("Description");
            reader.ReadStartElement("Color");
            if (reader.Name == "R")
            {
                obj.TextColor.R = reader.ReadElementContentAsFloat("R", String.Empty);
                obj.TextColor.G = reader.ReadElementContentAsFloat("G", String.Empty);
                obj.TextColor.B = reader.ReadElementContentAsFloat("B", String.Empty);
                obj.TextColor.A = reader.ReadElementContentAsFloat("A", String.Empty);
                reader.ReadEndElement();
            }
            obj.Text = reader.ReadElementString("Text", String.Empty);
            obj.SitName = reader.ReadElementString("SitName", String.Empty);
            obj.TouchName = reader.ReadElementString("TouchName", String.Empty);

            obj.LinkNumber = reader.ReadElementContentAsInt("LinkNum", String.Empty);
            obj.ClickAction = reader.ReadElementContentAsInt("ClickAction", String.Empty);
            
            reader.ReadStartElement("Shape");
            obj.Shape.ProfileCurve = reader.ReadElementContentAsInt("ProfileCurve", String.Empty);

            byte[] teData = Convert.FromBase64String(reader.ReadElementString("TextureEntry"));
            Primitive.TextureEntry te = new Primitive.TextureEntry(teData, 0, teData.Length);
            obj.Faces = FromTextureEntry(te);

            reader.ReadInnerXml(); // ExtraParams

            obj.Shape.PathBegin = Primitive.UnpackBeginCut((ushort)reader.ReadElementContentAsInt("PathBegin", String.Empty));
            obj.Shape.PathCurve = reader.ReadElementContentAsInt("PathCurve", String.Empty);
            obj.Shape.PathEnd = Primitive.UnpackEndCut((ushort)reader.ReadElementContentAsInt("PathEnd", String.Empty));
            obj.Shape.PathRadiusOffset = Primitive.UnpackPathTwist((sbyte)reader.ReadElementContentAsInt("PathRadiusOffset", String.Empty));
            obj.Shape.PathRevolutions = Primitive.UnpackPathRevolutions((byte)reader.ReadElementContentAsInt("PathRevolutions", String.Empty));
            obj.Shape.PathScaleX = Primitive.UnpackPathScale((byte)reader.ReadElementContentAsInt("PathScaleX", String.Empty));
            obj.Shape.PathScaleY = Primitive.UnpackPathScale((byte)reader.ReadElementContentAsInt("PathScaleY", String.Empty));
            obj.Shape.PathShearX = Primitive.UnpackPathShear((sbyte)reader.ReadElementContentAsInt("PathShearX", String.Empty));
            obj.Shape.PathShearY = Primitive.UnpackPathShear((sbyte)reader.ReadElementContentAsInt("PathShearY", String.Empty));
            obj.Shape.PathSkew = Primitive.UnpackPathTwist((sbyte)reader.ReadElementContentAsInt("PathSkew", String.Empty));
            obj.Shape.PathTaperX = Primitive.UnpackPathTaper((sbyte)reader.ReadElementContentAsInt("PathTaperX", String.Empty));
            obj.Shape.PathTaperY = Primitive.UnpackPathShear((sbyte)reader.ReadElementContentAsInt("PathTaperY", String.Empty));
            obj.Shape.PathTwist = Primitive.UnpackPathTwist((sbyte)reader.ReadElementContentAsInt("PathTwist", String.Empty));
            obj.Shape.PathTwistBegin = Primitive.UnpackPathTwist((sbyte)reader.ReadElementContentAsInt("PathTwistBegin", String.Empty));
            obj.PCode = reader.ReadElementContentAsInt("PCode", String.Empty);
            obj.Shape.ProfileBegin = Primitive.UnpackBeginCut((ushort)reader.ReadElementContentAsInt("ProfileBegin", String.Empty));
            obj.Shape.ProfileEnd = Primitive.UnpackEndCut((ushort)reader.ReadElementContentAsInt("ProfileEnd", String.Empty));
            obj.Shape.ProfileHollow = Primitive.UnpackProfileHollow((ushort)reader.ReadElementContentAsInt("ProfileHollow", String.Empty));
            obj.Scale = ReadVector(reader, "Scale");
            obj.State = (byte)reader.ReadElementContentAsInt("State", String.Empty);

            ProfileShape profileShape = (ProfileShape)Enum.Parse(typeof(ProfileShape), reader.ReadElementString("ProfileShape"));
            HoleType holeType = (HoleType)Enum.Parse(typeof(HoleType), reader.ReadElementString("HollowShape"));
            obj.Shape.ProfileCurve = (int)profileShape | (int)holeType;

            UUID sculptTexture = ReadUUID(reader, "SculptTexture");
            SculptType sculptType = (SculptType)reader.ReadElementContentAsInt("SculptType", String.Empty);
            if (sculptTexture != UUID.Zero)
            {
                obj.Sculpt = new PrimObject.SculptBlock();
                obj.Sculpt.Texture = sculptTexture;
                obj.Sculpt.Type = (int)sculptType;
            }

            PrimObject.FlexibleBlock flexible = new PrimObject.FlexibleBlock();
            PrimObject.LightBlock light = new PrimObject.LightBlock();

            reader.ReadInnerXml(); // SculptData

            flexible.Softness = reader.ReadElementContentAsInt("FlexiSoftness", String.Empty);
            flexible.Tension = reader.ReadElementContentAsFloat("FlexiTension", String.Empty);
            flexible.Drag = reader.ReadElementContentAsFloat("FlexiDrag", String.Empty);
            flexible.Gravity = reader.ReadElementContentAsFloat("FlexiGravity", String.Empty);
            flexible.Wind = reader.ReadElementContentAsFloat("FlexiWind", String.Empty);
            flexible.Force.X = reader.ReadElementContentAsFloat("FlexiForceX", String.Empty);
            flexible.Force.Y = reader.ReadElementContentAsFloat("FlexiForceY", String.Empty);
            flexible.Force.Z = reader.ReadElementContentAsFloat("FlexiForceZ", String.Empty);

            light.Color.R = reader.ReadElementContentAsFloat("LightColorR", String.Empty);
            light.Color.G = reader.ReadElementContentAsFloat("LightColorG", String.Empty);
            light.Color.B = reader.ReadElementContentAsFloat("LightColorB", String.Empty);
            light.Color.A = reader.ReadElementContentAsFloat("LightColorA", String.Empty);
            light.Radius = reader.ReadElementContentAsFloat("LightRadius", String.Empty);
            light.Cutoff = reader.ReadElementContentAsFloat("LightCutoff", String.Empty);
            light.Falloff = reader.ReadElementContentAsFloat("LightFalloff", String.Empty);
            light.Intensity = reader.ReadElementContentAsFloat("LightIntensity", String.Empty);

            reader.ReadInnerXml(); // FlexiTension
            reader.ReadInnerXml(); // FlexiDrag
            reader.ReadInnerXml(); // FlexiGravity
            reader.ReadInnerXml(); // FlexiWind
            reader.ReadInnerXml(); // FlexiForceX
            reader.ReadInnerXml(); // FlexiForceY
            reader.ReadInnerXml(); // FlexiForceZ
            reader.ReadInnerXml(); // LightColorR
            reader.ReadInnerXml(); // LightColorG
            reader.ReadInnerXml(); // LightColorB
            reader.ReadInnerXml(); // LightColorA
            reader.ReadInnerXml(); // LightRadius
            reader.ReadInnerXml(); // LightCutoff
            reader.ReadInnerXml(); // LightFalloff
            reader.ReadInnerXml(); // LightIntensity
            bool hasFlexi = reader.ReadElementContentAsBoolean("FlexiEntry", String.Empty);
            bool hasLight = reader.ReadElementContentAsBoolean("LightEntry", String.Empty);
            reader.ReadInnerXml(); // SculptEntry

            if (hasFlexi)
                obj.Flexible = flexible;
            if (hasLight)
                obj.Light = light;

            reader.ReadEndElement();

            obj.Scale = ReadVector(reader, "Scale"); // Yes, again
            reader.ReadInnerXml(); // UpdateFlag

            reader.ReadInnerXml(); // SitTargetOrientation
            reader.ReadInnerXml(); // SitTargetPosition
            obj.SitOffset = ReadVector(reader, "SitTargetPositionLL");
            obj.SitRotation = ReadQuaternion(reader, "SitTargetOrientationLL");
            obj.ParentID = (uint)reader.ReadElementContentAsLong("ParentID", String.Empty);
            obj.CreationDate = Utils.UnixTimeToDateTime(reader.ReadElementContentAsInt("CreationDate", String.Empty));
            //obj.Category = reader.ReadElementContentAsInt("Category", String.Empty);
            //warning CS0219: The variable `category' is assigned but its value is never used
            //int category = reader.ReadElementContentAsInt("Category", String.Empty);
            obj.SalePrice = reader.ReadElementContentAsInt("SalePrice", String.Empty);
            obj.SaleType = reader.ReadElementContentAsInt("ObjectSaleType", String.Empty);
            //warning CS0219: The variable `ownershipCost' is assigned but its value is never used
            //int ownershipCost = reader.ReadElementContentAsInt("OwnershipCost", String.Empty);
            obj.GroupIdentity = ReadUUID(reader, "GroupID").ToString();
            obj.OwnerIdentity = ReadUUID(reader, "OwnerID").ToString();
            obj.LastOwnerIdentity = ReadUUID(reader, "LastOwnerID").ToString();
            obj.PermsBase = (uint)reader.ReadElementContentAsInt("BaseMask", String.Empty);
            obj.PermsOwner = (uint)reader.ReadElementContentAsInt("OwnerMask", String.Empty);
            obj.PermsGroup = (uint)reader.ReadElementContentAsInt("GroupMask", String.Empty);
            obj.PermsEveryone = (uint)reader.ReadElementContentAsInt("EveryoneMask", String.Empty);
            obj.PermsNextOwner = (uint)reader.ReadElementContentAsInt("NextOwnerMask", String.Empty);

            reader.ReadInnerXml(); // Flags
            reader.ReadInnerXml(); // CollisionSound
            reader.ReadInnerXml(); // CollisionSoundVolume

            reader.ReadEndElement();

            if (obj.ParentID == 0)
                obj.Position = groupPosition;
            else
                obj.Position = offsetPosition;

            return obj;
        }
Esempio n. 14
0
        public static void LoadNeed()
        {
            var multTable = new float[100];
            using (var reader = new XmlTextReader("formula.xml"))
            {
                while (reader.Read())
                {
                    switch (reader.Name)
                    {
                        case "LM":
                            var low = int.Parse(reader.GetAttribute("lower"));
                            var high = int.Parse(reader.GetAttribute("upper"));
                            var value = reader.ReadElementContentAsFloat();

                            for (; low <= high; low++)
                                multTable[low] = value;
                            break;

                        case "FORMULA_TABLE":
                            if (reader.GetAttribute("id") != "NeedExpLM")
                                reader.Close();
                            break;
                    }
                }
            }

            for (var i = 1; i < 100; ++i)
            {
                var exp = (UInt32)((double)(i * i) * multTable[i] * 100.0 + .5f);
                NeedExpTable[i] = Convert.ToUInt32(multTable[i - 1] + 2 * exp);
            }
        }
Esempio n. 15
0
 public static void ReadTornadoAbility(ref XmlTextReader reader)
 {
     while (reader.Read())
     {
         if (reader.NodeType == XmlNodeType.Element)
         {
             if (reader.Name == XMLPropNames.strSpeed)
                 mTornadoSpeed = reader.ReadElementContentAsFloat();
             else if (reader.Name == XMLPropNames.strDuration)
                 mTornadoDuration = reader.ReadElementContentAsInt();
             else if (reader.Name == XMLPropNames.strDegrees)
                 mTornadoDegrees = reader.ReadElementContentAsInt();
             else if (reader.Name == XMLPropNames.strDamage)
                 mTornadoDamage = reader.ReadElementContentAsInt();
             else if (reader.Name == XMLPropNames.strRange)
                 mTornadoRange = reader.ReadElementContentAsInt();
         }
         else if (reader.NodeType == XmlNodeType.EndElement &&
                  reader.Name == XMLPropNames.strAbility)
             break;
     }
 }
Esempio n. 16
0
File: Body.cs Progetto: bilwis/SH2RL
        public void ParseBodyDefinition(string filename)
        {
            Random rand = new Random();
            XmlTextReader reader = new XmlTextReader(filename);
            string name;
            float var = 1.0f;

            List<Organ> organ_defs = new List<Organ>();
            List<OrganConstructor> bp_organs = new List<OrganConstructor>();
            Dictionary<string, string> bp_parents = new Dictionary<string,string>();

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        switch (reader.Name)
                        {
                            case "name":
                                name = reader.ReadElementContentAsString();
                                break;
                            case "height":
                                height = reader.ReadElementContentAsFloat();
                                break;
                            case "width":
                                width = reader.ReadElementContentAsFloat();
                                break;
                            case "depth":
                                depth = reader.ReadElementContentAsFloat();
                                break;
                            case "variation":
                                var = reader.ReadElementContentAsFloat();
                                break;

                            case "organ_def":
                                Organ o = parseOrganDefinition(reader);
                                if (o == null)
                                    throw new Exception("Error while parsing body definition XML: Organ above line " + reader.LineNumber + " not correctly parsed.");
                                organ_defs.Add(o);
                                break;

                            case "body_part":
                                string guid = System.Guid.NewGuid().ToString();

                                string bp_name = "ERROR";
                                float surface = 0.0f;
                                float weight = 0.0f;
                                bool essential = false;

                                int rgb = 0;
                                string display_char = " ";

                                bool symetrical = false;
                                string parent_name = null;

                                bool readingOrgan = false;
                                OrganConstructor temp = new OrganConstructor();

                                bool bp_done = false;

                                while (reader.Read() && !bp_done)
                                {

                                    switch (reader.NodeType)
                                    {
                                        case XmlNodeType.Element:
                                            switch (reader.Name)
                                            {
                                                case "name":
                                                    if (!readingOrgan)
                                                        bp_name = reader.ReadElementContentAsString();
                                                    else
                                                        temp.alias = reader.ReadElementContentAsString();
                                                    break;
                                                case "surface":
                                                    surface = reader.ReadElementContentAsFloat();
                                                    break;
                                                case "weight":
                                                    weight = reader.ReadElementContentAsFloat();
                                                    break;
                                                case "essential":
                                                    essential = reader.ReadElementContentAsBoolean();
                                                    break;
                                                case "parent":
                                                    parent_name = reader.ReadElementContentAsString();
                                                    break;
                                                case "display_char":
                                                    display_char = reader.ReadElementContentAsString();
                                                    break;
                                                case "color":
                                                    string[] temp_col_arr = reader.ReadElementContentAsString().Split(',');
                                                    rgb = Util.EncodeRGB(Int32.Parse(temp_col_arr[0]), Int32.Parse(temp_col_arr[1]), Int32.Parse(temp_col_arr[2]));
                                                    break;
                                                case "symetrical":
                                                    symetrical = reader.ReadElementContentAsBoolean();
                                                    break;
                                                case "organ":
                                                    if (readingOrgan)
                                                        throw new Exception("Error while parsing body definition XML: Organ element not closed before line " + reader.LineNumber + ".");
                                                    readingOrgan = true;
                                                    temp = new OrganConstructor();
                                                    //set default
                                                    temp.hit_prob = 1.0f;
                                                    break;
                                                case "type":
                                                    temp.name = reader.ReadElementContentAsString();
                                                    break;
                                                case "thickness":
                                                    temp.thickness = reader.ReadElementContentAsFloat();
                                                    break;
                                                case "hit_prob":
                                                    temp.hit_prob = reader.ReadElementContentAsFloat();
                                                    break;
                                            }
                                            break;
                                        case XmlNodeType.EndElement:
                                            switch (reader.Name)
                                            {
                                                case "organ":
                                                    readingOrgan = false;
                                                    temp.bp_guid = guid;
                                                    bp_organs.Add(temp);
                                                    break;
                                                case "body_part":
                                                    BodyPart new_bp = new BodyPart(guid, bp_name, surface, weight, essential, symetrical, display_char[0], rgb);
                                                    bp_parents.Add(new_bp.GUID, parent_name);
                                                    parts.Add(new_bp.GUID, new_bp);
                                                    bp_done = true;
                                                    break;
                                            }
                                            break;
                                    }
                                }

                                break;
                        }
                        break;
                    case XmlNodeType.EndElement:
                        switch (reader.Name)
                        {

                        }
                        break;
                }
            }

            //load bp_organs into bodyparts, attach bodyparts to Body
            foreach (BodyPart p in parts.Values)
            {
                foreach (OrganConstructor oc in bp_organs)
                {
                    if (p.GUID == oc.bp_guid)
                    {
                        foreach (Organ o in organ_defs)
                        {
                            if (o.name == oc.name)
                            {
                                p.AddOrgan(new Organ(o, oc.thickness, oc.hit_prob, oc.alias));
                            }
                        }
                    }
                }
                if (bp_parents[p.GUID] != null)
                {
                    foreach (BodyPart par in parts.Values)
                    {
                        if (par.Name == bp_parents[p.GUID])
                            p.ConnectToBody(this, par);
                    }
                }
                else
                {
                    p.ConnectToBody(this);
                }
            }

            this.height = (float)(height + (var * (rand.NextDouble() - 0.5)));
            this.width = (float)(width + (var * (rand.NextDouble() - 0.5)));
            this.depth = (float)(depth + (var * (rand.NextDouble() - 0.5)));
            loaded = true;
        }
 private void ProcessShpFlexiWind(PrimitiveBaseShape shp, XmlTextReader reader)
 {
     shp.FlexiWind = reader.ReadElementContentAsFloat("FlexiWind", String.Empty);
 }
Esempio n. 18
0
        /// <summary>
        /// The get location.
        /// </summary>
        /// <param name="ip">
        /// The ip.
        /// </param>
        /// <returns>
        /// The <see cref="GeolocateResult"/>.
        /// </returns>
        public static GeolocateResult GetLocation(this IPAddress ip)
        {
            // FIXME: ServiceLocator - logger & privateconfig
            var config = ServiceLocator.Current.GetInstance<IPrivateConfiguration>();
            var logger = ServiceLocator.Current.GetInstance<ILogger>().CreateChildLogger("IPAddressExtensions");

            if (config.IpInfoDbApiKey == string.Empty)
            {
                logger.Error("API key is empty, please fix this in configuration.");
                return new GeolocateResult();
            }

            var requestData =
                HttpRequest.Get(
                    "http://api.ipinfodb.com/v3/ip-city/?key=" + config.IpInfoDbApiKey + "&ip=" + ip + "&format=xml");

            using (Stream s = requestData.ToStream())
            {
                var xtr = new XmlTextReader(s);

                var result = new GeolocateResult();

                while (!xtr.EOF)
                {
                    xtr.Read();
                    switch (xtr.Name)
                    {
                        case "statusCode":
                            result.Status = xtr.ReadElementContentAsString();
                            break;
                        case "countryCode":
                            result.CountryCode = xtr.ReadElementContentAsString();
                            break;
                        case "countryName":
                            result.Country = xtr.ReadElementContentAsString();
                            break;
                        case "regionName":
                            result.Region = xtr.ReadElementContentAsString();
                            break;
                        case "cityName":
                            result.City = xtr.ReadElementContentAsString();
                            break;
                        case "zipCode":
                            result.ZipPostalCode = xtr.ReadElementContentAsString();
                            break;
                        case "latitude":
                            result.Latitude = xtr.ReadElementContentAsFloat();
                            break;
                        case "longitude":
                            result.Longitude = xtr.ReadElementContentAsFloat();
                            break;
                    }
                }

                return result;
            }
        }
 private static void ProcessDensity(SceneObjectPart obj, XmlTextReader reader)
 {
     obj.Density = reader.ReadElementContentAsFloat("Density", String.Empty);
 }
        private void readSettingsFromXML(String directory, String fileName)
        {
            if (Directory.Exists(directory))
            {
                DirectoryInfo dirInfo = new DirectoryInfo(directory);

                FileInfo[] fileInfo = dirInfo.GetFiles(fileName + META_EXT);

                if (fileInfo.Length > 0)
                {
                    XmlTextReader reader;
                    reader = new XmlTextReader(fileInfo[0].FullName);
                    reader.WhitespaceHandling = WhitespaceHandling.None;

                    while (reader.Read())
                    {
                        if (reader.LocalName.Equals("Name"))
                        {
                            _mapMetadata.Name = reader.ReadElementContentAsString();
                        }

                        if (reader.LocalName.Equals("Description"))
                        {
                            _mapMetadata.Description = reader.ReadElementContentAsString();
                        }

                        if (reader.LocalName.Equals("SWLat"))
                        {
                            _mapMetadata.SWLat = reader.ReadElementContentAsFloat();
                        }
                        if (reader.LocalName.Equals("SWLong"))
                        {
                            _mapMetadata.SWLong = reader.ReadElementContentAsFloat();
                        }

                        if (reader.LocalName.Equals("SELat"))
                        {
                            _mapMetadata.SELat = reader.ReadElementContentAsFloat();
                        }
                        if (reader.LocalName.Equals("SELong"))
                        {
                            _mapMetadata.SELong = reader.ReadElementContentAsFloat();
                        }

                        if (reader.LocalName.Equals("NELat"))
                        {
                            _mapMetadata.NELat = reader.ReadElementContentAsFloat();
                        }
                        if (reader.LocalName.Equals("NELong"))
                        {
                            _mapMetadata.NELong = reader.ReadElementContentAsFloat();
                        }
                    }
                }
            }
        }
 private static void ProcessBounce(SceneObjectPart obj, XmlTextReader reader)
 {
     obj.Restitution = reader.ReadElementContentAsFloat("Bounce", String.Empty);
 }
Esempio n. 22
0
        public static PrimObject LoadPrim(XmlTextReader reader)
        {
            PrimObject obj = new PrimObject();
            obj.Shape = new PrimObject.ShapeBlock();
            obj.Inventory = new PrimObject.InventoryBlock();

            reader.ReadStartElement("SceneObjectPart");

            if (reader.Name == "AllowedDrop")
                obj.AllowedDrop = reader.ReadElementContentAsBoolean("AllowedDrop", String.Empty);
            else
                obj.AllowedDrop = true;

            obj.CreatorID = ReadUUID(reader, "CreatorID");
            obj.FolderID = ReadUUID(reader, "FolderID");
            obj.Inventory.Serial = reader.ReadElementContentAsInt("InventorySerial", String.Empty);

            #region Task Inventory

            List<PrimObject.InventoryBlock.ItemBlock> invItems = new List<PrimObject.InventoryBlock.ItemBlock>();

            reader.ReadStartElement("TaskInventory", String.Empty);
            while (reader.Name == "TaskInventoryItem")
            {
                PrimObject.InventoryBlock.ItemBlock item = new PrimObject.InventoryBlock.ItemBlock();
                reader.ReadStartElement("TaskInventoryItem", String.Empty);

                item.AssetID = ReadUUID(reader, "AssetID");
                item.PermsBase = (uint)reader.ReadElementContentAsInt("BasePermissions", String.Empty);
                item.CreationDate = Utils.UnixTimeToDateTime((uint)reader.ReadElementContentAsInt("CreationDate", String.Empty));
                item.CreatorID = ReadUUID(reader, "CreatorID");
                item.Description = reader.ReadElementContentAsString("Description", String.Empty);
                item.PermsEveryone = (uint)reader.ReadElementContentAsInt("EveryonePermissions", String.Empty);
                item.Flags = reader.ReadElementContentAsInt("Flags", String.Empty);
                item.GroupID = ReadUUID(reader, "GroupID");
                item.PermsGroup = (uint)reader.ReadElementContentAsInt("GroupPermissions", String.Empty);
                item.InvType = (InventoryType)reader.ReadElementContentAsInt("InvType", String.Empty);
                item.ID = ReadUUID(reader, "ItemID");
                UUID oldItemID = ReadUUID(reader, "OldItemID"); // TODO: Is this useful?
                item.LastOwnerID = ReadUUID(reader, "LastOwnerID");
                item.Name = reader.ReadElementContentAsString("Name", String.Empty);
                item.PermsNextOwner = (uint)reader.ReadElementContentAsInt("NextPermissions", String.Empty);
                item.OwnerID = ReadUUID(reader, "OwnerID");
                item.PermsOwner = (uint)reader.ReadElementContentAsInt("CurrentPermissions", String.Empty);
                UUID parentID = ReadUUID(reader, "ParentID");
                UUID parentPartID = ReadUUID(reader, "ParentPartID");
                item.PermsGranterID = ReadUUID(reader, "PermsGranter");
                item.PermsBase = (uint)reader.ReadElementContentAsInt("PermsMask", String.Empty);
                item.Type = (AssetType)reader.ReadElementContentAsInt("Type", String.Empty);

                reader.ReadEndElement();
                invItems.Add(item);
            }
            if (reader.NodeType == XmlNodeType.EndElement)
                reader.ReadEndElement();

            obj.Inventory.Items = invItems.ToArray();

            #endregion Task Inventory

            PrimFlags flags = (PrimFlags)reader.ReadElementContentAsInt("ObjectFlags", String.Empty);
            obj.UsePhysics = (flags & PrimFlags.Physics) != 0;
            obj.Phantom = (flags & PrimFlags.Phantom) != 0;
            obj.DieAtEdge = (flags & PrimFlags.DieAtEdge) != 0;
            obj.ReturnAtEdge = (flags & PrimFlags.ReturnAtEdge) != 0;
            obj.Temporary = (flags & PrimFlags.Temporary) != 0;
            obj.Sandbox = (flags & PrimFlags.Sandbox) != 0;

            obj.ID = ReadUUID(reader, "UUID");
            obj.LocalID = (uint)reader.ReadElementContentAsLong("LocalId", String.Empty);
            obj.Name = reader.ReadElementString("Name");
            obj.Material = reader.ReadElementContentAsInt("Material", String.Empty);

            if (reader.Name == "PassTouches")
                obj.PassTouches = reader.ReadElementContentAsBoolean("PassTouches", String.Empty);
            else
                obj.PassTouches = false;

            obj.RegionHandle = (ulong)reader.ReadElementContentAsLong("RegionHandle", String.Empty);
            obj.RemoteScriptAccessPIN = reader.ReadElementContentAsInt("ScriptAccessPin", String.Empty);

            if (reader.Name == "PlaySoundSlavePrims")
                reader.ReadInnerXml();
            if (reader.Name == "LoopSoundSlavePrims")
                reader.ReadInnerXml();

            Vector3 groupPosition = ReadVector(reader, "GroupPosition");
            Vector3 offsetPosition = ReadVector(reader, "OffsetPosition");
            obj.Rotation = ReadQuaternion(reader, "RotationOffset");
            obj.Velocity = ReadVector(reader, "Velocity");
            if (reader.Name == "RotationalVelocity")
                ReadVector(reader, "RotationalVelocity");
            obj.AngularVelocity = ReadVector(reader, "AngularVelocity");
            obj.Acceleration = ReadVector(reader, "Acceleration");
            obj.Description = reader.ReadElementString("Description");
            reader.ReadStartElement("Color");
            if (reader.Name == "R")
            {
                obj.TextColor.R = reader.ReadElementContentAsFloat("R", String.Empty);
                obj.TextColor.G = reader.ReadElementContentAsFloat("G", String.Empty);
                obj.TextColor.B = reader.ReadElementContentAsFloat("B", String.Empty);
                obj.TextColor.A = reader.ReadElementContentAsFloat("A", String.Empty);
                reader.ReadEndElement();
            }
            obj.Text = reader.ReadElementString("Text", String.Empty);
            obj.SitName = reader.ReadElementString("SitName", String.Empty);
            obj.TouchName = reader.ReadElementString("TouchName", String.Empty);

            obj.LinkNumber = reader.ReadElementContentAsInt("LinkNum", String.Empty);
            obj.ClickAction = reader.ReadElementContentAsInt("ClickAction", String.Empty);

            reader.ReadStartElement("Shape");
            obj.Shape.ProfileCurve = reader.ReadElementContentAsInt("ProfileCurve", String.Empty);

            byte[] teData = Convert.FromBase64String(reader.ReadElementString("TextureEntry"));
            obj.Textures = new Primitive.TextureEntry(teData, 0, teData.Length);

            reader.ReadInnerXml(); // ExtraParams

            obj.Shape.PathBegin = Primitive.UnpackBeginCut((ushort)reader.ReadElementContentAsInt("PathBegin", String.Empty));
            obj.Shape.PathCurve = reader.ReadElementContentAsInt("PathCurve", String.Empty);
            obj.Shape.PathEnd = Primitive.UnpackEndCut((ushort)reader.ReadElementContentAsInt("PathEnd", String.Empty));
            obj.Shape.PathRadiusOffset = Primitive.UnpackPathTwist((sbyte)reader.ReadElementContentAsInt("PathRadiusOffset", String.Empty));
            obj.Shape.PathRevolutions = Primitive.UnpackPathRevolutions((byte)reader.ReadElementContentAsInt("PathRevolutions", String.Empty));
            obj.Shape.PathScaleX = Primitive.UnpackPathScale((byte)reader.ReadElementContentAsInt("PathScaleX", String.Empty));
            obj.Shape.PathScaleY = Primitive.UnpackPathScale((byte)reader.ReadElementContentAsInt("PathScaleY", String.Empty));
            obj.Shape.PathShearX = Primitive.UnpackPathShear((sbyte)reader.ReadElementContentAsInt("PathShearX", String.Empty));
            obj.Shape.PathShearY = Primitive.UnpackPathShear((sbyte)reader.ReadElementContentAsInt("PathShearY", String.Empty));
            obj.Shape.PathSkew = Primitive.UnpackPathTwist((sbyte)reader.ReadElementContentAsInt("PathSkew", String.Empty));
            obj.Shape.PathTaperX = Primitive.UnpackPathTaper((sbyte)reader.ReadElementContentAsInt("PathTaperX", String.Empty));
            obj.Shape.PathTaperY = Primitive.UnpackPathShear((sbyte)reader.ReadElementContentAsInt("PathTaperY", String.Empty));
            obj.Shape.PathTwist = Primitive.UnpackPathTwist((sbyte)reader.ReadElementContentAsInt("PathTwist", String.Empty));
            obj.Shape.PathTwistBegin = Primitive.UnpackPathTwist((sbyte)reader.ReadElementContentAsInt("PathTwistBegin", String.Empty));
            obj.PCode = reader.ReadElementContentAsInt("PCode", String.Empty);
            obj.Shape.ProfileBegin = Primitive.UnpackBeginCut((ushort)reader.ReadElementContentAsInt("ProfileBegin", String.Empty));
            obj.Shape.ProfileEnd = Primitive.UnpackEndCut((ushort)reader.ReadElementContentAsInt("ProfileEnd", String.Empty));
            obj.Shape.ProfileHollow = Primitive.UnpackProfileHollow((ushort)reader.ReadElementContentAsInt("ProfileHollow", String.Empty));
            obj.Scale = ReadVector(reader, "Scale");
            obj.State = (byte)reader.ReadElementContentAsInt("State", String.Empty);

            ProfileShape profileShape = (ProfileShape)Enum.Parse(typeof(ProfileShape), reader.ReadElementString("ProfileShape"));
            HoleType holeType = (HoleType)Enum.Parse(typeof(HoleType), reader.ReadElementString("HollowShape"));
            obj.Shape.ProfileCurve = (int)profileShape | (int)holeType;

            UUID sculptTexture = ReadUUID(reader, "SculptTexture");
            SculptType sculptType = (SculptType)reader.ReadElementContentAsInt("SculptType", String.Empty);
            if (sculptTexture != UUID.Zero)
            {
                obj.Sculpt = new PrimObject.SculptBlock();
                obj.Sculpt.Texture = sculptTexture;
                obj.Sculpt.Type = (int)sculptType;
            }

            PrimObject.FlexibleBlock flexible = new PrimObject.FlexibleBlock();
            PrimObject.LightBlock light = new PrimObject.LightBlock();

            reader.ReadInnerXml(); // SculptData

            flexible.Softness = reader.ReadElementContentAsInt("FlexiSoftness", String.Empty);
            flexible.Tension = reader.ReadElementContentAsFloat("FlexiTension", String.Empty);
            flexible.Drag = reader.ReadElementContentAsFloat("FlexiDrag", String.Empty);
            flexible.Gravity = reader.ReadElementContentAsFloat("FlexiGravity", String.Empty);
            flexible.Wind = reader.ReadElementContentAsFloat("FlexiWind", String.Empty);
            flexible.Force.X = reader.ReadElementContentAsFloat("FlexiForceX", String.Empty);
            flexible.Force.Y = reader.ReadElementContentAsFloat("FlexiForceY", String.Empty);
            flexible.Force.Z = reader.ReadElementContentAsFloat("FlexiForceZ", String.Empty);

            light.Color.R = reader.ReadElementContentAsFloat("LightColorR", String.Empty);
            light.Color.G = reader.ReadElementContentAsFloat("LightColorG", String.Empty);
            light.Color.B = reader.ReadElementContentAsFloat("LightColorB", String.Empty);
            light.Color.A = reader.ReadElementContentAsFloat("LightColorA", String.Empty);
            light.Radius = reader.ReadElementContentAsFloat("LightRadius", String.Empty);
            light.Cutoff = reader.ReadElementContentAsFloat("LightCutoff", String.Empty);
            light.Falloff = reader.ReadElementContentAsFloat("LightFalloff", String.Empty);
            light.Intensity = reader.ReadElementContentAsFloat("LightIntensity", String.Empty);

            bool hasFlexi = reader.ReadElementContentAsBoolean("FlexiEntry", String.Empty);
            bool hasLight = reader.ReadElementContentAsBoolean("LightEntry", String.Empty);
            reader.ReadInnerXml(); // SculptEntry

            if (hasFlexi)
                obj.Flexible = flexible;
            if (hasLight)
                obj.Light = light;

            reader.ReadEndElement();

            obj.Scale = ReadVector(reader, "Scale"); // Yes, again
            reader.ReadInnerXml(); // UpdateFlag

            reader.ReadInnerXml(); // SitTargetOrientation
            reader.ReadInnerXml(); // SitTargetPosition
            obj.SitOffset = ReadVector(reader, "SitTargetPositionLL");
            obj.SitRotation = ReadQuaternion(reader, "SitTargetOrientationLL");
            obj.ParentID = (uint)reader.ReadElementContentAsLong("ParentID", String.Empty);
            obj.CreationDate = Utils.UnixTimeToDateTime(reader.ReadElementContentAsInt("CreationDate", String.Empty));
            int category = reader.ReadElementContentAsInt("Category", String.Empty);
            obj.SalePrice = reader.ReadElementContentAsInt("SalePrice", String.Empty);
            obj.SaleType = reader.ReadElementContentAsInt("ObjectSaleType", String.Empty);
            int ownershipCost = reader.ReadElementContentAsInt("OwnershipCost", String.Empty);
            obj.GroupID = ReadUUID(reader, "GroupID");
            obj.OwnerID = ReadUUID(reader, "OwnerID");
            obj.LastOwnerID = ReadUUID(reader, "LastOwnerID");
            obj.PermsBase = (uint)reader.ReadElementContentAsInt("BaseMask", String.Empty);
            obj.PermsOwner = (uint)reader.ReadElementContentAsInt("OwnerMask", String.Empty);
            obj.PermsGroup = (uint)reader.ReadElementContentAsInt("GroupMask", String.Empty);
            obj.PermsEveryone = (uint)reader.ReadElementContentAsInt("EveryoneMask", String.Empty);
            obj.PermsNextOwner = (uint)reader.ReadElementContentAsInt("NextOwnerMask", String.Empty);

            reader.ReadInnerXml(); // Flags

            obj.CollisionSound = ReadUUID(reader, "CollisionSound");
            obj.CollisionSoundVolume = reader.ReadElementContentAsFloat("CollisionSoundVolume", String.Empty);

            reader.ReadEndElement();

            if (obj.ParentID == 0)
                obj.Position = groupPosition;
            else
                obj.Position = offsetPosition;

            return obj;
        }
Esempio n. 23
0
        static Vector3 ReadVector(XmlTextReader reader, string name)
        {
            Vector3 vec;

            reader.ReadStartElement(name);
            vec.X = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // X or x
            vec.Y = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Y or y
            vec.Z = reader.ReadElementContentAsFloat(reader.Name, String.Empty); // Z or z
            reader.ReadEndElement();

            return vec;
        }
Esempio n. 24
0
        static Quaternion ReadQuaternion(XmlTextReader reader, string name)
        {
            Quaternion quat;

            reader.ReadStartElement(name);
            quat.X = reader.ReadElementContentAsFloat("X", String.Empty);
            quat.Y = reader.ReadElementContentAsFloat("Y", String.Empty);
            quat.Z = reader.ReadElementContentAsFloat("Z", String.Empty);
            quat.W = reader.ReadElementContentAsFloat("W", String.Empty);
            reader.ReadEndElement();

            return quat;
        }
Esempio n. 25
0
 private static void ProcessShpFlexiForceZ(PrimitiveBaseShape shp, XmlTextReader reader)
 {
     shp.FlexiForceZ = reader.ReadElementContentAsFloat("FlexiForceZ", String.Empty);
 }
Esempio n. 26
0
        static Vector3 ReadVector(XmlTextReader reader, string name)
        {
            Vector3 vec;

            reader.ReadStartElement(name);
            vec.X = reader.ReadElementContentAsFloat("X", String.Empty);
            vec.Y = reader.ReadElementContentAsFloat("Y", String.Empty);
            vec.Z = reader.ReadElementContentAsFloat("Z", String.Empty);
            reader.ReadEndElement();

            return vec;
        }
Esempio n. 27
0
 private static void ProcessColor(SceneObjectPart obj, XmlTextReader reader)
 {
     reader.ReadStartElement("Color");
     if (reader.Name == "R")
     {
         float r = reader.ReadElementContentAsFloat("R", String.Empty);
         float g = reader.ReadElementContentAsFloat("G", String.Empty);
         float b = reader.ReadElementContentAsFloat("B", String.Empty);
         float a = reader.ReadElementContentAsFloat("A", String.Empty);
         obj.Color = Color.FromArgb((int)a, (int)r, (int)g, (int)b);
         reader.ReadEndElement();
     }
 }
Esempio n. 28
0
File: Body.cs Progetto: bilwis/SH2RL
        private Organ parseOrganDefinition(XmlTextReader reader)
        {
            string name = "ERROR";
            bool exclusive = false;

            List<OrganPart> parts = new List<OrganPart>();
            OrganPart temp = new OrganPart();
            bool readingPart=false;

            temp.critical = false;  //default

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                        switch (reader.Name)
                        {
                            case "part":
                                if (readingPart)
                                    throw new Exception("Error while parsing body definition XML: New part element before end part element");
                                readingPart = true;
                                break;
                            case "name":
                                if (!readingPart)
                                    name = reader.ReadElementContentAsString();
                                else
                                    temp.name = reader.ReadElementContentAsString();
                                break;
                            case "exclusive":
                                exclusive = reader.ReadElementContentAsBoolean();
                                break;
                            case "hit_prob":
                                temp.hit_prob = reader.ReadElementContentAsFloat();
                                break;
                            case "pain":
                                temp.pain = reader.ReadElementContentAsFloat();
                                break;
                            case "blood_loss":
                                temp.blood_loss = reader.ReadElementContentAsFloat();
                                break;
                            case "resistance":
                                temp.resistance = reader.ReadElementContentAsFloat();
                                break;
                            case "on_hit_kill":
                                temp.critical = reader.ReadElementContentAsBoolean();
                                break;
                        }
                        break;
                    case XmlNodeType.EndElement:
                        switch (reader.Name)
                        {
                            case "part":
                                readingPart = false;
                                parts.Add(temp);
                                temp = new OrganPart();
                                break;
                            case "organ_def":
                                Organ self = new Organ(name, exclusive);
                                foreach (OrganPart op in parts)
                                {
                                    self.AddPart(op);
                                }
                                return self;
                        }
                        break;
                }
            }

            return null;
        }
        private void _DaemonPipe_OnReceiveLine(string line)
        {
            XmlTextReader reader = new XmlTextReader(new StringReader(line));

            while (reader.Read())
            {
                switch (reader.NodeType)
                {
                    case XmlNodeType.Element:
                    {
                        if (reader.Depth == 0)
                        {
                            isEvent = (reader.Name == "Event");

                            if (isEvent || reader.Name == "Response")
                            {
                                for (int i = 0; i < reader.AttributeCount; i++)
                                {
                                    reader.MoveToAttribute(i);

                                    switch (reader.Name)
                                    {
                                        case "action":
                                            actionString = reader.Value;
                                            break;
                                        case "type":
                                            eventTypeString = reader.Value;
                                            break;
                                    }
                                }
                            }
                        }
                        else
                        {
                            switch (reader.Name)
                            {
                                case "InputXml":
                                    cookie = -1;

                                    // Parse through here to get the cookie value
                                    reader.Read();
                                    if (reader.Name == "Request")
                                    {
                                        for (int i = 0; i < reader.AttributeCount; i++)
                                        {
                                            reader.MoveToAttribute(i);

                                            if (reader.Name == "requestId")
                                            {
                                                Int32.TryParse(reader.Value, out cookie);
                                                break;
                                            }
                                        }
                                    }

                                    if (cookie == -1)
                                    {
                                        Logger.Log("VoiceManager._DaemonPipe_OnReceiveLine(): Failed to parse InputXml for the cookie", Helpers.LogLevel.Warning, Client);
                                    }
                                    break;
                                case "CaptureDevices": _CaptureDevices.Clear();
                                    break;
                                case "RenderDevices": _RenderDevices.Clear();
                                    break;
                                case "StatusCode": statusCode = reader.ReadElementContentAsInt();
                                    break;
                                case "StatusString": statusString = reader.ReadElementContentAsString();
                                    break;
                                case "State": state = reader.ReadElementContentAsInt();
                                    break;
                                case "ConnectorHandle": connectorHandle = reader.ReadElementContentAsString();
                                    break;
                                case "AccountHandle": accountHandle = reader.ReadElementContentAsString();
                                    break;
                                case "SessionHandle": sessionHandle = reader.ReadElementContentAsString();
                                    break;
                                case "URI": uriString = reader.ReadElementContentAsString();
                                    break;
                                case "IsChannel": isChannel = reader.ReadElementContentAsBoolean();
                                    break;
                                case "Name": nameString = reader.ReadElementContentAsString();
                                    break;
                                case "ChannelName": nameString = reader.ReadElementContentAsString();
                                    break;
                                case "ParticipantURI": uriString = reader.ReadElementContentAsString();
                                    break;
                                case "DisplayName": displayNameString = reader.ReadElementContentAsString();
                                    break;
                                case "AccountName": nameString = reader.ReadElementContentAsString();
                                    break;
                                case "ParticipantType": participantType = reader.ReadElementContentAsInt();
                                    break;
                                case "IsLocallyMuted": isLocallyMuted = reader.ReadElementContentAsBoolean();
                                    break;
                                case "IsModeratorMuted": isModeratorMuted = reader.ReadElementContentAsBoolean();
                                    break;
                                case "IsSpeaking":
                                    isSpeaking = reader.ReadElementContentAsBoolean();
                                    break;
                                case "Volume": volume = reader.ReadElementContentAsInt();
                                    break;
                                case "Energy": energy = reader.ReadElementContentAsFloat();
                                    break;
                                case "MicEnergy": energy = reader.ReadElementContentAsFloat();
                                    break;
                                case "ChannelURI": uriString = reader.ReadElementContentAsString();
                                    break;
                                case "ChannelListResult": _ChannelMap[nameString] = uriString;
                                    break;
                                case "CaptureDevice":
                                    reader.Read();
                                    _CaptureDevices.Add(reader.ReadElementContentAsString());
                                    break;
                                case "CurrentCaptureDevice":
                                    reader.Read();
                                    nameString = reader.ReadElementContentAsString();
                                    break;
                                case "RenderDevice":
                                    reader.Read();
                                    _RenderDevices.Add(reader.ReadElementContentAsString());
                                    break;
                                case "CurrentRenderDevice":
                                    reader.Read();
                                    nameString = reader.ReadElementContentAsString();
                                    break;
                            }
                        }

                        break;
                    }
                    case XmlNodeType.EndElement:
                        if (reader.Depth == 0)
                            ProcessEvent();
                        break;
                }
            }

            if (isEvent)
            {
            }
        }
Esempio n. 30
0
 public static void ReadRoarAbility(ref XmlTextReader reader)
 {
     while (reader.Read())
     {
         if (reader.Name == XMLPropNames.strDegrees)
             mRoarDegrees = reader.ReadElementContentAsInt();
         else if (reader.Name == XMLPropNames.strKnockBackSpeed)
             mRoarKnockBackSpeed = reader.ReadElementContentAsFloat();
         else if (reader.Name == XMLPropNames.strDuration)
             mRoarDuration = reader.ReadElementContentAsInt();
         else if (reader.Name == XMLPropNames.strStunDuration)
             mRoarStunDuration = reader.ReadElementContentAsInt();
         else if (reader.Name == XMLPropNames.strRange)
             mRoarRange = reader.ReadElementContentAsInt();
         else if (reader.NodeType == XmlNodeType.EndElement &&
                  reader.Name == XMLPropNames.strAbility)
             break;
     }
 }