Unpack() public method

Unpack and OSDMap and initialize the appearance from it
public Unpack ( OSDMap data ) : void
data OSDMap
return void
Esempio n. 1
0
        LSL_Key NpcCreate(
            string firstname, string lastname, LSL_Types.Vector3 position, string notecard, bool owned, bool senseAsAgent)
        {
            IBotManager manager = World.RequestModuleInterface<IBotManager>();
            if (manager != null)
            {
                MainConsole.Instance.DebugFormat ("Creating NPC: {0} {1}, Position: {2}, Appearence: {3}, Options: {4} {5}",
                    firstname, lastname, position, notecard, owned, senseAsAgent);

                // check for notecard or UUID for appearance...
                AvatarAppearance appearance = null;
                UUID appearanceId;
                UUID.TryParse (notecard, out appearanceId);

                if (appearanceId == UUID.Zero)
                {
                    // not a UUID so try for a notecard
                    string appearanceSerialized = LoadNotecard(notecard);

                    if (appearanceSerialized != null)
                    {
                        var appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
                        appearance = new AvatarAppearance();
                        appearance.Unpack(appearanceOsd);
                    }
                    else
                    {
                        OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard));
                    }
                }

                UUID ownerID = UUID.Zero;
                if (owned)
                    ownerID = m_host.OwnerID;

                var npcPosition = position.ToVector3();
                UUID newBotId;

                if (appearance == null)
                {
                    newBotId = manager.CreateAvatar (
                        firstname,
                        lastname,
                        World,
                        appearanceId,
                        ownerID,
                        npcPosition
                    );
                } else
                {
                    newBotId = manager.CreateAvatar (
                        firstname,
                        lastname,
                        World,
                        appearance,
                        ownerID,
                        npcPosition
                    );

                }
                return new LSL_Key(newBotId.ToString());
            }

            return new LSL_Key(UUID.Zero.ToString());
        }
 AvatarAppearance ConvertXMLToAvatarAppearance (OSDMap map)
 {
     AvatarAppearance appearance = new AvatarAppearance ();
     appearance.Unpack (map);
     return appearance;
 }
Esempio n. 3
0
        public void osNpcLoadAppearance(LSL_Key npc, string notecard)
        {
            if (!ScriptProtection.CheckThreatLevel(ThreatLevel.High, "osNpcLoadAppearance", m_host, "OSSL", m_itemID))
                return;

            IBotManager manager = World.RequestModuleInterface<IBotManager>();
            if (manager != null)
            {
                UUID npcId;
                if (!UUID.TryParse(npc.m_string, out npcId))
                    return;

                if (!manager.CheckPermission(npcId, m_host.OwnerID))
                    return;

                string appearanceSerialized = LoadNotecard(notecard);

                if (appearanceSerialized == null)
                    OSSLError(string.Format("osNpcCreate: Notecard reference '{0}' not found.", notecard));

                OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(appearanceSerialized);
                AvatarAppearance appearance = new AvatarAppearance();
                appearance.Unpack(appearanceOsd);

                manager.SetAvatarAppearance(npcId, appearance, m_host.ParentEntity.Scene);
            }
        }