Example #1
0
        public static new Avatar FromOSD(OSD O)
        {
            OSDMap tex = (OSDMap)O;

            Avatar A = new Avatar();

            Primitive P = Primitive.FromOSD(O);

            Type Prim = typeof(Primitive);

            FieldInfo[] Fields = Prim.GetFields();

            for (int x = 0; x < Fields.Length; x++)
            {
                Logger.Log("Field Matched in FromOSD: " + Fields[x].Name, Helpers.LogLevel.Debug);
                Fields[x].SetValue(A, Fields[x].GetValue(P));
            }

            A.Groups = new List <UUID>();

            foreach (OSD U in (OSDArray)tex["groups"])
            {
                A.Groups.Add(U.AsUUID());
            }

            A.ProfileStatistics = Statistics.FromOSD(tex["profile_statistics"]);
            A.ProfileProperties = AvatarProperties.FromOSD(tex["profile_properties"]);
            A.ProfileInterests  = Interests.FromOSD(tex["profile_interest"]);
            A.ControlFlags      = (AgentManager.ControlFlags)tex["control_flags"].AsInteger();

            OSDArray vp = (OSDArray)tex["visual_parameters"];

            A.VisualParameters = new byte[vp.Count];

            for (int i = 0; i < vp.Count; i++)
            {
                A.VisualParameters[i] = (byte)vp[i].AsInteger();
            }

            // *********************From Code Above *******************************

            /*if (NameValues[i].Name == "FirstName" && NameValues[i].Type == NameValue.ValueType.String)
             *                firstName = (string)NameValues[i].Value;
             *            else if (NameValues[i].Name == "LastName" && NameValues[i].Type == NameValue.ValueType.String)
             *                lastName = (string)NameValues[i].Value;*/
            // ********************************************************************

            A.NameValues = new NameValue[3];

            NameValue First = new NameValue();

            First.Name  = "FirstName";
            First.Type  = NameValue.ValueType.String;
            First.Value = tex["first_name"].AsString();

            NameValue Last = new NameValue();

            Last.Name  = "LastName";
            Last.Type  = NameValue.ValueType.String;
            Last.Value = tex["last_name"].AsString();

            // ***************From Code Above***************
            // if (NameValues[i].Name == "Title" && NameValues[i].Type == NameValue.ValueType.String)
            // *********************************************

            NameValue Group = new NameValue();

            Group.Name  = "Title";
            Group.Type  = NameValue.ValueType.String;
            Group.Value = tex["group_name"].AsString();



            A.NameValues[0] = First;
            A.NameValues[1] = Last;
            A.NameValues[2] = Group;

            return(A);
        }