internal static TaskInventorySnapshot FromTaskInventory(OpenSim.Region.Framework.Scenes.SceneObjectPart part)
        {
            TaskInventorySnapshot snapshot = new TaskInventorySnapshot
            {
                Serial = part.InventorySerial,
                Items  = ExtractInventoryItems(part)
            };

            return(snapshot);
        }
Пример #2
0
        static public SceneObjectPartSnapshot FromSceneObjectPart(SceneObjectPart part, SerializationFlags flags)
        {
            bool serializePhysicsShapes  = (flags & SerializationFlags.SerializePhysicsShapes) != 0;
            bool serializeScriptBytecode = (flags & SerializationFlags.SerializeScriptBytecode) != 0;

            StopScriptReason stopScriptReason;

            if ((flags & SerializationFlags.StopScripts) == 0)
            {
                stopScriptReason = StopScriptReason.None;
            }
            else
            {
                if ((flags & SerializationFlags.FromCrossing) != 0)
                {
                    stopScriptReason = StopScriptReason.Crossing;
                }
                else
                {
                    stopScriptReason = StopScriptReason.Derez;
                }
            }

            SceneObjectPartSnapshot partSnap = new SceneObjectPartSnapshot
            {
                AngularVelocity       = part.PhysicalAngularVelocity,
                AngularVelocityTarget = part.AngularVelocity,
                BaseMask             = part.BaseMask,
                Category             = part.Category,
                ClickAction          = part.ClickAction,
                CollisionSound       = part.CollisionSound.Guid,
                CollisionSoundVolume = part.CollisionSoundVolume,
                CreationDate         = part.CreationDate,
                CreatorId            = part.CreatorID.Guid,
                Description          = part.Description,
                EveryoneMask         = part.EveryoneMask,
                Flags     = part.Flags,
                GroupId   = part.GroupID.Guid,
                GroupMask = part.GroupMask,

                //if this is an attachment, dont fill out the group position. This prevents an issue where
                //a user is crossing to a new region and the vehicle has already been sent. Since the attachment's
                //group position is actually the wearer's position and the wearer's position is the vehicle position,
                //trying to get the attachment grp pos triggers an error and a ton of log spam.
                GroupPosition = part.ParentGroup.IsAttachment ? OpenMetaverse.Vector3.Zero : part.GroupPosition,

                HoverText             = part.Text,
                Id                    = part.UUID.Guid,
                Inventory             = TaskInventorySnapshot.FromTaskInventory(part),
                KeyframeAnimation     = KeyframeAnimationSnapshot.FromKeyframeAnimation(part.KeyframeAnimation),
                LastOwnerId           = part.LastOwnerID.Guid,
                LinkNumber            = part.LinkNum,
                LocalId               = part.LocalId,
                Material              = (OpenMetaverse.Material)part.Material,
                MediaUrl              = part.MediaUrl,
                Name                  = part.Name,
                NextOwnerMask         = part.NextOwnerMask,
                ObjectFlags           = (OpenMetaverse.PrimFlags)part.ObjectFlags,
                ObjectSaleType        = part.ObjectSaleType,
                OffsetPosition        = part.OffsetPosition,
                OwnerId               = part.OwnerID.Guid,
                OwnerMask             = part.OwnerMask,
                OwnershipCost         = part.OwnershipCost,
                ParentId              = part.ParentID,
                ParticleSystem        = part.ParticleSystem,
                PassTouches           = part.PassTouches,
                PayPrice              = part.PayPrice,
                RegionHandle          = part.RegionHandle,
                RotationOffset        = part.RotationOffset,
                SalePrice             = part.SalePrice,
                SavedAttachmentPoint  = part.SavedAttachmentPoint,
                SavedAttachmentPos    = part.SavedAttachmentPos,
                SavedAttachmentRot    = part.SavedAttachmentRot,
                Scale                 = part.Scale,
                ScriptAccessPin       = part.ScriptAccessPin,
                SerializedPhysicsData = part.SerializedPhysicsData,
                ServerWeight          = part.ServerWeight,
                Shape                 = PrimShapeSnapshot.FromShape(part.Shape),
                SitName               = part.SitName,
                SitTargetOrientation  = part.SitTargetOrientation,
                SitTargetPosition     = part.SitTargetPosition,
                Sound                 = part.Sound.Guid,
                SoundFlags            = part.SoundOptions,
                SoundGain             = part.SoundGain,
                SoundRadius           = part.SoundRadius,
                StreamingCost         = part.StreamingCost,
                TextColor             = part.TextColor,
                TextureAnimation      = part.TextureAnimation,
                TouchName             = part.TouchName,
                Velocity              = part.Velocity,
                FromItemId            = part.FromItemID.Guid
            };

            Dictionary <OpenMetaverse.UUID, byte[]> states;
            Dictionary <OpenMetaverse.UUID, byte[]> byteCode;

            if (serializeScriptBytecode)
            {
                Tuple <Dictionary <OpenMetaverse.UUID, byte[]>, Dictionary <OpenMetaverse.UUID, byte[]> >
                statesAndBytecode = part.Inventory.GetBinaryScriptStatesAndCompiledScripts(stopScriptReason);

                states   = statesAndBytecode.Item1;
                byteCode = statesAndBytecode.Item2;
            }
            else
            {
                states   = part.Inventory.GetBinaryScriptStates(stopScriptReason);
                byteCode = null;
            }


            partSnap.SerializedScriptStates = new Dictionary <Guid, byte[]>(states.Count);
            foreach (var kvp in states)
            {
                //map from UUID to Guid
                partSnap.SerializedScriptStates[kvp.Key.Guid] = kvp.Value;
            }

            if (byteCode != null)
            {
                partSnap.SeralizedScriptBytecode = new Dictionary <Guid, byte[]>();

                foreach (var kvp in byteCode)
                {
                    //map from UUID to Guid
                    partSnap.SeralizedScriptBytecode[kvp.Key.Guid] = kvp.Value;
                }
            }

            if (serializePhysicsShapes)
            {
                partSnap.SerializedPhysicsShapes = part.SerializedPhysicsShapes;
            }

            return(partSnap);
        }